1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-09-02 19:39:12 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
rubidium
109294c6c4 (svn r15913) -Release: not the April Fools' edition of OpenTTD. 2009-04-01 14:36:05 +00:00
270 changed files with 9868 additions and 14379 deletions

View File

@@ -93,7 +93,7 @@ ifeq ($(shell if test -f config.cache; then echo 1; fi), 1)
@echo " Going to reconfigure with last known settings..."
@echo "----------------"
# Make sure we don't lock config.cache
@$(shell cat config.cache | sed 's@\\ @\\\\ @g') || exit 1
@$(shell cat config.cache | sed 's~\\ ~\\\\ ~g') || exit 1
@echo "----------------"
@echo "Reconfig done. Please re-execute make."
@echo "----------------"

View File

@@ -19,8 +19,8 @@ BIN_DIR = "$(ROOT_DIR)/bin"
SRC_DIR = "$(ROOT_DIR)/src"
BUNDLE_DIR = "$(ROOT_DIR)/bundle"
BUNDLES_DIR = "$(ROOT_DIR)/bundles"
TTD = openttd.exe
TARGET := $(shell echo $(PLATFORM) | sed "s@win64@x64@;s@win32@Win32@")
TTD = "openttd.exe"
TARGET := $(shell echo $(PLATFORM) | sed "s~win64~x64~;s~win32~Win32~")
all:
$(Q)cp objs/$(TARGET)/Release/$(TTD) $(BIN_DIR)/$(TTD)

View File

@@ -4,6 +4,7 @@ CC_BUILD = !!CC_BUILD!!
CXX_BUILD = !!CXX_BUILD!!
WINDRES = !!WINDRES!!
STRIP = !!STRIP!!
CC_CFLAGS = !!CC_CFLAGS!!
CFLAGS = !!CFLAGS!!
CFLAGS_BUILD = !!CFLAGS_BUILD!!
LIBS = !!LIBS!!
@@ -27,6 +28,7 @@ CFLAGS_MAKEDEP= !!CFLAGS_MAKEDEP!!
SORT = !!SORT!!
REVISION = !!REVISION!!
AWK = !!AWK!!
GCC295 = !!GCC295!!
CONFIG_CACHE_COMPILER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_COMPILER!!
CONFIG_CACHE_LINKER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_LINKER!!
CONFIG_CACHE_ENDIAN = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_ENDIAN!!
@@ -51,6 +53,20 @@ CFLAGS_MAKEDEP += -I $(SRC_OBJS_DIR) -I $(LANG_OBJS_DIR) -I $(SCRIPT_SRC_DIR)
ENDIAN_TARGETS := endian_target.h $(ENDIAN_CHECK)
# This 'sed' basicly just removes 'const' from the line if it is a 2+D array
# For more information, please check:
# http://maillist.openttd.org/pipermail/devs/2007-April/000284.html
# http://maillist.openttd.org/pipermail/devs/2007-February/000248.html
GCC295_FIX=sed -r 's~^(\t*)(.*)( const )([A-Za-z0-9_ ]+(\[.*\]){2,})(( = \{)|(;))(.*)$$~\1\2 \4\6\8\9~g'
# This 'sed' removes the 3rd '4' in the # lines of the -E output of
# gcc 2.95.3 and lower, as it should indicate that it is a C-linkage, but the
# compiler can't handle that information (just don't ask). So we remove it
# and then it compiles happily and without bitching :)
# Furthermore gcc 2.95 has some trouble with protected and private when
# accessing the protected/private stuff of the enclosing class (or the
# super class of the enclosing class).
GCC295_FIX_2=sed -e 's~\(^\# [0-9][0-9]* "[^"]*"[ 0-9]*\) 4$$~\1~g;s~private:~public:~g;s~protected:~public:~g'
# Check if we want to show what we are doing
ifdef VERBOSE
Q =
@@ -82,7 +98,7 @@ MODIFIED := $(shell echo "$(VERSIONS)" | cut -f 3 -d' ')
ifdef REVISION
# Use specified revision (which should be of the form "r000").
REV := $(REVISION)
REV_NR := $(shell echo $(REVISION) | sed "s@[^0-9]@@g")
REV_NR := $(shell echo $(REVISION) | sed "s~[^0-9]~~g")
else
# Use autodetected revisions
REV := $(shell echo "$(VERSIONS)" | cut -f 1 -d' ')
@@ -98,7 +114,7 @@ REV_NR := 0
endif
# This helps to recompile if flags change
RES := $(shell if [ "`cat $(CONFIG_CACHE_COMPILER) 2>/dev/null`" != "$(CFLAGS)" ]; then echo "$(CFLAGS)" > $(CONFIG_CACHE_COMPILER); fi )
RES := $(shell if [ "`cat $(CONFIG_CACHE_COMPILER) 2>/dev/null`" != "$(CC_CFLAGS) $(CFLAGS)" ]; then echo "$(CC_CFLAGS) $(CFLAGS)" > $(CONFIG_CACHE_COMPILER); fi )
RES := $(shell if [ "`cat $(CONFIG_CACHE_LINKER) 2>/dev/null`" != "$(LDFLAGS) $(LIBS)" ]; then echo "$(LDFLAGS) $(LIBS)" > $(CONFIG_CACHE_LINKER); fi )
RES := $(shell if [ "`cat $(CONFIG_CACHE_ENDIAN) 2>/dev/null`" != "$(ENDIAN_FORCE)" ]; then echo "$(ENDIAN_FORCE)" > $(CONFIG_CACHE_ENDIAN); fi )
@@ -127,15 +143,15 @@ endif
$(OBJS_C:%.o=%.d): %.d: $(SRC_DIR)/%.c $(FILE_DEP)
$(E) '$(STAGE) DEP $(<:$(SRC_DIR)/%.c=%.c)'
$(Q)$(CC_HOST) $(CC_CFLAGS) $(CFLAGS) -MM $< | sed 's@^$(@F:%.d=%.o):@$@ $(@:%.d=%.o):@' > $@
$(Q)$(CC_HOST) $(CC_CFLAGS) $(CFLAGS) -MM $< | sed 's~^$(@F:%.d=%.o):~$@ $(@:%.d=%.o):~' > $@
$(OBJS_CPP:%.o=%.d): %.d: $(SRC_DIR)/%.cpp $(FILE_DEP)
$(E) '$(STAGE) DEP $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$(Q)$(CXX_HOST) $(CFLAGS) -MM $< | sed 's@^$(@F:%.d=%.o):@$@ $(@:%.d=%.o):@' > $@
$(Q)$(CXX_HOST) $(CFLAGS) -MM $< | sed 's~^$(@F:%.d=%.o):~$@ $(@:%.d=%.o):~' > $@
$(OBJS_MM:%.o=%.d): %.d: $(SRC_DIR)/%.mm $(FILE_DEP)
$(E) '$(STAGE) DEP $(<:$(SRC_DIR)/%.mm=%.mm)'
$(Q)$(CC_HOST) $(CFLAGS) -MM $< | sed 's@^$(@F:%.d=%.o):@$@ $(@:%.d=%.o):@' > $@
$(Q)$(CC_HOST) $(CFLAGS) -MM $< | sed 's~^$(@F:%.d=%.o):~$@ $(@:%.d=%.o):~' > $@
$(OBJS_RC:%.o=%.d): %.d: $(SRC_DIR)/%.rc $(FILE_DEP)
$(E) '$(STAGE) DEP $(<:$(SRC_DIR)/%.mm=%.mm)'
@@ -166,7 +182,7 @@ endif
# Convert x:/... paths to /x/... for mingw
ifeq ($(OS), MINGW)
@cat Makefile.dep.tmp | sed 's@/\([a-zA-Z]\):\/@\/\1\/@g' > Makefile.dep.tmp.mingw
@cat Makefile.dep.tmp | sed 's~\([a-zA-Z]\):\/~\/\1\/~g' > Makefile.dep.tmp.mingw
@cp Makefile.dep.tmp.mingw Makefile.dep.tmp
@rm -f Makefile.dep.tmp.mingw
endif
@@ -176,7 +192,7 @@ endif
@$(AWK) ' \
/^# DO NOT/ { print $$0 ; next} \
/^#/ {next} \
/: / { \
/:/ { \
left = NF - 1; \
for (n = 2; n <= NF; n++) { \
if (match($$n, "^$(ROOT_DIR)") == 0) { \
@@ -195,7 +211,7 @@ endif
{ \
print $$0 \
} \
' < Makefile.dep.tmp | sed 's@ *@ @g;s@ $$@@' | $(SORT) > Makefile.dep
' < Makefile.dep.tmp | sed 's~ *~ ~g;s~ $$~~' | $(SORT) > Makefile.dep
$(Q)rm -f Makefile.dep.tmp Makefile.dep.tmp.bak
@@ -210,9 +226,17 @@ endif
# Compile all the files according to the targets
$(OBJS_C): %.o: $(SRC_DIR)/%.c $(DEP_MASK) $(FILE_DEP)
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.c=%.c)'
$(Q)$(CC_HOST) $(CC_CFLAGS) $(CFLAGS) -c -o $@ $<
$(OBJS_CPP): %.o: $(SRC_DIR)/%.cpp $(DEP_MASK) $(FILE_DEP)
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
ifeq ($(GCC295), 1)
$(Q)$(CXX_HOST) -E $(CFLAGS) $< | $(GCC295_FIX) | $(GCC295_FIX_2) | $(CXX_HOST) $(CFLAGS) -c -o $@ -x c++ -
else
$(Q)$(CXX_HOST) $(CFLAGS) -c -o $@ $<
endif
$(OBJS_MM): %.o: $(SRC_DIR)/%.mm $(DEP_MASK) $(FILE_DEP)
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.mm=%.mm)'
@@ -256,10 +280,10 @@ $(ENDIAN_CHECK): $(SRC_DIR)/endian_check.cpp
# Revision files
$(SRC_DIR)/rev.cpp: $(CONFIG_CACHE_VERSION) $(SRC_DIR)/rev.cpp.in
$(Q)cat $(SRC_DIR)/rev.cpp.in | sed "s@\!\!REVISION\!\!@$(REV_NR)@g;s@!!VERSION!!@$(REV)@g;s@!!MODIFIED!!@$(MODIFIED)@g;s@!!DATE!!@`date +%d.%m.%y`@g" > $(SRC_DIR)/rev.cpp
$(Q)cat $(SRC_DIR)/rev.cpp.in | sed "s~@@REVISION@@~$(REV_NR)~g;s~@@VERSION@@~$(REV)~g;s~@@MODIFIED@@~$(MODIFIED)~g;s~@@DATE@@~`date +%d.%m.%y`~g" > $(SRC_DIR)/rev.cpp
$(SRC_DIR)/ottdres.rc: $(CONFIG_CACHE_VERSION) $(SRC_DIR)/ottdres.rc.in
$(Q)cat $(SRC_DIR)/ottdres.rc.in | sed "s@\!\!REVISION\!\!@$(REV_NR)@g;s@!!VERSION!!@$(REV)@g;s@!!DATE!!@`date +%d.%m.%y`@g" > $(SRC_DIR)/ottdres.rc
$(Q)cat $(SRC_DIR)/ottdres.rc.in | sed "s~@@REVISION@@~$(REV_NR)~g;s~@@VERSION@@~$(REV)~g;s~@@DATE@@~`date +%d.%m.%y`~g" > $(SRC_DIR)/ottdres.rc
FORCE:

View File

@@ -220,7 +220,6 @@ function Regression::Airport()
}
print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.COMPANY_SELF));
print(" GetPrice(): " + AIAirport.GetPrice(0));
print(" BuildAirport(): " + AIAirport.BuildAirport(32116, 0, AIStation.STATION_JOIN_ADJACENT));
print(" IsHangarTile(): " + AIAirport.IsHangarTile(32116));
print(" IsAirportTile(): " + AIAirport.IsAirportTile(32116));
@@ -1077,10 +1076,9 @@ function Regression::Sign()
print(" BuildSign(33409, 'Some other Sign'): " + sign_id);
print(" RemoveSign(" + sign_id + "): " + AISign.RemoveSign(sign_id));
print("");
local list = AISignList();
list.Sort(AIAbstractList.SORT_BY_ITEM, true);
for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
j++;
print(" GetMaxSignID(): " + AISign.GetMaxSignID());
for (local i = -1; i < AISign.GetMaxSignID() + 1; i++) {
if (AISign.IsValidSign(i)) j++;
print(" Sign " + i);
print(" IsValidSign(): " + AISign.IsValidSign(i));
print(" GetName(): " + AISign.GetName(i));
@@ -1191,7 +1189,7 @@ function Regression::TileList()
print("");
print("--TileList--");
print(" Count(): " + list.Count());
list.AddRectangle(34436, 256 * 2 + 34436 + 8);
list.AddRectangle(41895 - 256 * 2, 256 * 2 + 41895 + 8);
print(" Count(): " + list.Count());
list.Valuate(AITile.GetHeight);
@@ -1202,30 +1200,6 @@ function Regression::TileList()
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AITile.GetCornerHeight, AITile.CORNER_N);
print(" CornerHeight(North): done");
print(" Count(): " + list.Count());
print(" ListDump:");
for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AITile.GetMinHeight);
print(" MinHeight(): done");
print(" Count(): " + list.Count());
print(" ListDump:");
for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AITile.GetMaxHeight);
print(" MaxHeight(): done");
print(" Count(): " + list.Count());
print(" ListDump:");
for (local i = list.Begin(); list.HasNext(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AITile.GetSlope);
list.KeepValue(0);
print(" Slope(): done");
@@ -1236,8 +1210,6 @@ function Regression::TileList()
print(" " + i + " => " + list.GetValue(i));
}
list.Clear();
list.AddRectangle(41895 - 256 * 2, 256 * 2 + 41895 + 8);
list.Valuate(AITile.IsBuildable);
list.KeepValue(1);
print(" Buildable(): done");

View File

@@ -620,7 +620,6 @@
GetAirportHeight(9): -1
GetAirportCoverageRadius(9): -1
GetBankBalance(): 100000
GetPrice(): 84
BuildAirport(): true
IsHangarTile(): false
IsAirportTile(): true
@@ -1072,7 +1071,7 @@
GetAutoRenewStatus(); true
SetAutoRenewStatus(true); false
SetAutoRenewStatus(false); true
GetAutoRenewMonths(); 6
GetAutoRenewMonths(); -6
SetAutoRenewMonths(-12); true
GetAutoRenewMonths(); -12
SetAutoRenewMonths(-12); false
@@ -7242,6 +7241,11 @@
BuildSign(33409, 'Some other Sign'): 2
RemoveSign(2): true
GetMaxSignID(): 3
Sign -1
IsValidSign(): false
GetName(): (null : 0x00000000)
GetLocation(): -1
Sign 0
IsValidSign(): true
GetName(): Some Sign
@@ -7250,6 +7254,14 @@
IsValidSign(): true
GetName(): Test2
GetLocation(): 33411
Sign 2
IsValidSign(): false
GetName(): (null : 0x00000000)
GetLocation(): -1
Sign 3
IsValidSign(): false
GetName(): (null : 0x00000000)
GetLocation(): -1
Valid Signs: 2
--Station--
@@ -7316,7 +7328,7 @@
Count(): 9
ListDump:
27631 => 29
27631 => 65535
27631 => 255
27631 => true
27631 => false
27888 => 13
@@ -7354,178 +7366,125 @@
--TileList--
Count(): 0
Count(): 27
Count(): 45
Height(): done
Count(): 27
Count(): 45
ListDump:
34956 => 4
34700 => 4
34444 => 4
34955 => 3
34954 => 3
34953 => 3
34699 => 3
34698 => 3
34697 => 3
34693 => 3
34692 => 3
34443 => 3
34442 => 3
34441 => 3
34439 => 3
34438 => 3
34437 => 3
34436 => 3
34952 => 2
34951 => 2
34950 => 2
34949 => 2
34948 => 2
34696 => 2
34695 => 2
34694 => 2
34440 => 2
CornerHeight(North): done
Count(): 27
ListDump:
34956 => 4
34700 => 4
34444 => 4
34955 => 3
34954 => 3
34953 => 3
34699 => 3
34698 => 3
34697 => 3
34693 => 3
34692 => 3
34443 => 3
34442 => 3
34441 => 3
34439 => 3
34438 => 3
34437 => 3
34436 => 3
34952 => 2
34951 => 2
34950 => 2
34949 => 2
34948 => 2
34696 => 2
34695 => 2
34694 => 2
34440 => 2
MinHeight(): done
Count(): 27
ListDump:
34956 => 4
34700 => 4
34444 => 4
34955 => 3
34954 => 3
34953 => 3
34699 => 3
34698 => 3
34697 => 3
34443 => 3
34442 => 3
34441 => 3
34436 => 3
34952 => 2
34951 => 2
34950 => 2
34949 => 2
34948 => 2
34696 => 2
34695 => 2
34694 => 2
34693 => 2
34692 => 2
34440 => 2
34439 => 2
34438 => 2
34437 => 2
MaxHeight(): done
Count(): 27
ListDump:
34956 => 4
34955 => 4
34700 => 4
34699 => 4
34444 => 4
34443 => 4
34954 => 3
34953 => 3
34952 => 3
34951 => 3
34950 => 3
34949 => 3
34948 => 3
34698 => 3
34697 => 3
34696 => 3
34693 => 3
34692 => 3
34442 => 3
34441 => 3
34440 => 3
34439 => 3
34438 => 3
34437 => 3
34436 => 3
34695 => 2
34694 => 2
Slope(): done
KeepValue(0): done
Count(): 12
ListDump:
34956 => 0
34954 => 0
34953 => 0
34700 => 0
34698 => 0
34697 => 0
34695 => 0
34694 => 0
34444 => 0
34442 => 0
34441 => 0
34436 => 0
Buildable(): done
KeepValue(1): done
Count(): 35
BuildableRectangle(3, 3) ListDump:
42411 => 2
42410 => 2
42409 => 2
42408 => 2
42407 => 2
42154 => 2
42153 => 2
42152 => 2
42151 => 2
41898 => 2
41897 => 2
41896 => 2
41895 => 2
41642 => 2
41641 => 2
41640 => 2
41639 => 2
41386 => 2
41385 => 2
41384 => 2
41383 => 2
42415 => 1
42414 => 1
42413 => 1
42412 => 1
42411 => 1
42410 => 1
42159 => 1
42158 => 1
42157 => 1
42156 => 1
42155 => 1
42154 => 1
41903 => 1
41902 => 1
41901 => 1
41900 => 1
41899 => 1
41898 => 1
41647 => 1
41646 => 1
41645 => 1
41644 => 1
41643 => 1
41642 => 1
41391 => 1
41390 => 1
41389 => 1
41388 => 1
41387 => 1
Slope(): done
KeepValue(0): done
Count(): 38
ListDump:
42415 => 0
42414 => 0
42413 => 0
42410 => 0
42409 => 0
42408 => 0
42407 => 0
42159 => 0
42158 => 0
42157 => 0
42156 => 0
42153 => 0
42152 => 0
42151 => 0
41903 => 0
41902 => 0
41901 => 0
41900 => 0
41899 => 0
41897 => 0
41896 => 0
41895 => 0
41647 => 0
41646 => 0
41645 => 0
41644 => 0
41643 => 0
41641 => 0
41640 => 0
41639 => 0
41391 => 0
41390 => 0
41389 => 0
41388 => 0
41387 => 0
41385 => 0
41384 => 0
41383 => 0
Buildable(): done
KeepValue(1): done
Count(): 28
BuildableRectangle(3, 3) ListDump:
42415 => 1
42414 => 1
42413 => 1
42410 => 1
42159 => 1
42158 => 1
42157 => 1
42156 => 1
41903 => 1
41902 => 1
41901 => 1
41900 => 1
41899 => 1
41647 => 1
41646 => 1
41645 => 1
41644 => 1
41643 => 1
41641 => 1
41391 => 1
41390 => 1
41389 => 1
41388 => 1
41387 => 1
41386 => 1
41385 => 1
42153 => 0
41897 => 0
@@ -7537,33 +7496,26 @@
42413 => 173
42158 => 173
41903 => 173
42412 => 172
42157 => 172
41902 => 172
41647 => 172
42411 => 171
42156 => 171
41901 => 171
41646 => 171
41391 => 171
42410 => 170
42155 => 170
41900 => 170
41645 => 170
41390 => 170
42154 => 169
41899 => 169
41644 => 169
41389 => 169
42153 => 168
41898 => 168
41643 => 168
41388 => 168
41897 => 167
41642 => 167
41387 => 167
41641 => 166
41386 => 166
41385 => 165
41384 => 164
DistanceSquareToTile(30000) ListDump:
@@ -7580,24 +7532,17 @@
42157 => 17834
41390 => 17812
41901 => 17741
42412 => 17680
41645 => 17650
42156 => 17585
41389 => 17561
41900 => 17492
42411 => 17433
41644 => 17401
42155 => 17338
41388 => 17312
41899 => 17245
42410 => 17188
41643 => 17154
42154 => 17093
41387 => 17065
41898 => 17000
41642 => 16909
42153 => 16850
41386 => 16820
41897 => 16757
41641 => 16666
41385 => 16577
@@ -7606,77 +7551,63 @@
42415 => -1
42414 => -1
42413 => -1
42412 => -1
42411 => -1
42410 => -1
42159 => -1
42158 => -1
42157 => -1
42156 => -1
42155 => -1
42154 => -1
42153 => -1
41903 => -1
41902 => -1
41901 => -1
41900 => -1
41899 => -1
41898 => -1
41897 => -1
41647 => -1
41646 => -1
41645 => -1
41644 => -1
41643 => -1
41642 => -1
41641 => -1
41391 => -1
41390 => -1
41389 => -1
41388 => -1
41387 => -1
41386 => -1
41385 => -1
41384 => -1
GetClosestTown() ListDump:
42415 => 3
42414 => 3
42413 => 3
42412 => 3
42411 => 3
42410 => 3
42159 => 3
42158 => 3
42157 => 3
42156 => 3
42155 => 3
42154 => 3
42153 => 3
41903 => 3
41902 => 3
41901 => 3
41900 => 3
41899 => 3
41898 => 3
41897 => 3
41647 => 3
41646 => 3
41645 => 3
41644 => 3
41643 => 3
41642 => 3
41641 => 3
41391 => 3
41390 => 3
41389 => 3
41388 => 3
41387 => 3
41386 => 3
41385 => 3
41384 => 3
CargoAcceptance(): done
KeepAboveValue(10): done
Count(): 15
Count(): 9
ListDump:
41897 => 29
41385 => 26
@@ -7684,15 +7615,9 @@
42153 => 25
41641 => 23
41899 => 17
41898 => 17
41387 => 17
41386 => 17
41643 => 14
41642 => 14
42411 => 13
42410 => 13
42155 => 13
42154 => 13
RoadTile(): done
KeepValue(1): done
Count(): 0

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,7 @@ log() {
}
set_default() {
released_version="0.7.2-RC2"
released_version="0.7.0"
ignore_extra_parameters="0"
# We set all kinds of defaults for params. Later on the user can override
@@ -47,8 +47,8 @@ set_default() {
enable_static="1"
enable_translator="0"
enable_unicode="1"
enable_assert="1"
enable_strip="0"
enable_assert="0"
enable_strip="1"
enable_universal="1"
enable_osx_g5="0"
enable_cocoa_quartz="1"
@@ -415,7 +415,7 @@ save_params() {
configure="$CONFIGURE_EXECUTABLE --ignore-extra-parameters"
for p in $save_params_array; do
eval "v=\"\$$p\""
p=`echo "$p" | sed 's@_@-@g;s@\n@@g;s@ @\\ @g'`
p=`echo "$p" | sed 's~_~-~g;s~\n~~g;s~ ~\\ ~g'`
# Only save those params that aren't empty
configure="$configure --$p=\"$v\""
done
@@ -815,7 +815,6 @@ check_params() {
fi
if [ "$os" = "OSX" ]; then
check_osx_sdk
# Test on G5
if [ "$enable_osx_g5" != "0" ]; then
@@ -904,7 +903,7 @@ check_params() {
doc_dir="$data_dir/docs"
fi
else
doc_dir="`echo $doc_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
doc_dir="`echo $doc_dir | sed 's~\([^\]\)\\\\ ~\1\\\\\\\\ ~g;s~\([^\]\) ~\1\\\\\\\\ ~g'`"
fi
if [ "$icon_theme_dir" = "1" ]; then
@@ -914,7 +913,7 @@ check_params() {
icon_theme_dir=""
fi
else
icon_theme_dir="`echo $icon_theme_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
icon_theme_dir="`echo $icon_theme_dir | sed 's~\([^\]\)\\\\ ~\1\\\\\\\\ ~g;s~\([^\]\) ~\1\\\\\\\\ ~g'`"
fi
if [ "$personal_dir" = "1" ]; then
@@ -926,7 +925,7 @@ check_params() {
personal_dir=".openttd"
fi
else
personal_dir="`echo $personal_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
personal_dir="`echo $personal_dir | sed 's~\([^\]\)\\\\ ~\1\\\\\\\\ ~g;s~\([^\]\) ~\1\\\\\\\\ ~g'`"
fi
if [ "$shared_dir" = "1" ]; then
@@ -937,7 +936,7 @@ check_params() {
shared_dir=""
fi
else
shared_dir="`echo $shared_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
shared_dir="`echo $shared_dir | sed 's~\([^\]\)\\\\ ~\1\\\\\\\\ ~g;s~\([^\]\) ~\1\\\\\\\\ ~g'`"
fi
if [ "$man_dir" = "1" ]; then
@@ -948,7 +947,7 @@ check_params() {
man_dir=""
fi
else
man_dir="`echo $man_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
man_dir="`echo $man_dir | sed 's~\([^\]\)\\\\ ~\1\\\\\\\\ ~g;s~\([^\]\) ~\1\\\\\\\\ ~g'`"
fi
if [ "$menu_dir" = "1" ]; then
@@ -959,7 +958,7 @@ check_params() {
menu_dir=""
fi
else
menu_dir="`echo $menu_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
menu_dir="`echo $menu_dir | sed 's~\([^\]\)\\\\ ~\1\\\\\\\\ ~g;s~\([^\]\) ~\1\\\\\\\\ ~g'`"
fi
# "set_universal_binary_flags" needs to be before "detect_iconv"
@@ -1009,74 +1008,13 @@ check_params() {
fi
}
make_compiler_cflags() {
# Params:
# $1 - compiler
# $2 - the current cflags
# $3 - variable to finally write to
flags="$2"
if [ `echo $1 | cut -c 1-3` = "icc" ]; then
# Enable some things only for certain ICC versions
cc_version=`$1 -dumpversion | cut -c 1-4`
if [ "$cc_version" = "10.1" ]; then
flags="$flags -Wno-multichar"
fi
if [ "$cc_version" = "11.0" ]; then
# warning 1899: multicharacter character literal (potential portability problem) (e.g. 'FOOD')
# vec report defaults to telling where it did loop vectorisation, which is not very important
flags="$flags -vec-report=0 -wd1899"
fi
else
# Enable some things only for certain GCC versions
cc_version=`$1 -dumpversion | cut -c 1,3`
if [ $cc_version -lt 30 ]; then
log 1 "configure: error: gcc older than 3.0 can't compile OpenTTD because of its poor template support"
exit 1
fi
flags="$flags -Wall -Wno-multichar -Wsign-compare -Wundef"
flags="$flags -Wwrite-strings -Wpointer-arith"
flags="$flags -Wno-uninitialized"
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
flags="$flags -Wno-unused-variable"
fi
if [ $cc_version -ge 40 ]; then
# GCC 4.0+ complains about that we break strict-aliasing.
# On most places we don't see how to fix it, and it doesn't
# break anything. So disable strict-aliasing to make the
# compiler all happy.
flags="$flags -fno-strict-aliasing"
fi
if [ $cc_version -ge 42 ]; then
# GCC 4.2+ automatically assumes that signed overflows do
# not occur in signed arithmetics, whereas we are not
# sure that they will not happen. It furthermore complains
# about it's own optimized code in some places.
flags="$flags -fno-strict-overflow"
fi
fi
eval "$3=\"$flags\""
}
make_cflags_and_ldflags() {
# General CFlags for BUILD
CFLAGS_BUILD=""
# General CFlags for HOST
CFLAGS="$CFLAGS -D$os"
# CFlags for HOST and C-Compiler
CC_FLAGS=""
# Libs to compile. In fact this is just LDFLAGS
LIBS="-lstdc++"
# LDFLAGS used for HOST
@@ -1125,16 +1063,58 @@ make_cflags_and_ldflags() {
CFLAGS="$CFLAGS -DNO_THREADS"
fi
make_compiler_cflags "$cc_build" "$CFLAGS_BUILD" "CFLAGS_BUILD"
make_compiler_cflags "$cc_host" "$CFLAGS" "CFLAGS"
if [ `echo $cc_host | cut -c 1-3` = "icc" ]; then
# Enable some things only for certain ICC versions
cc_version=`$cc_host -dumpversion | cut -c 1-4`
if [ "$cc_version" = "10.1" ]; then
CFLAGS="$CFLAGS -Wno-multichar"
fi
else
# Enable some things only for certain GCC versions
cc_version=`$cc_host -dumpversion | cut -c 1,3`
if [ $cc_version -ge 29 ]; then
CFLAGS="$CFLAGS -Wall -Wno-multichar -Wsign-compare -Wundef"
CFLAGS="$CFLAGS -Wwrite-strings -Wpointer-arith"
CFLAGS="$CFLAGS -Wno-uninitialized"
CC_CFLAGS="$CC_CFLAGS -Wstrict-prototypes"
fi
gcc295=""
if [ "$cc_version" = 29 ]; then
# Make sure we mark GCC 2.95 flag for Makefile.src.in, as we
# need a lovely hack there to make it compile correctly.
gcc295="1"
# Disable warnings about unused variables when
# compiling with asserts disabled
if [ $enable_assert -eq 0 ]; then
CFLAGS="$CFLAGS -Wno-unused"
fi
fi
if [ $cc_version -ge 30 ]; then
CFLAGS="$CFLAGS -W -Wno-unused-parameter -Wformat=2"
CFLAGS="$CFLAGS -Wredundant-decls"
# Do not warn about unused variables when building without asserts
if [ $enable_assert -eq 0 ]; then
CFLAGS="$CFLAGS -Wno-unused-variable"
fi
fi
if [ $cc_version -ge 34 ]; then
CC_CFLAGS="$CC_CFLAGS -Wdeclaration-after-statement -Wold-style-definition"
fi
if [ "`echo $1 | cut -c 1-3`" != "icc" ]; then
if [ "$os" = "CYGWIN" ]; then
flags="$flags -mwin32"
CFLAGS="$CFLAGS -mwin32"
LDFLAGS="$LDFLAGS -mwin32"
fi
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
flags="$flags -mno-cygwin"
CFLAGS="$CFLAGS -mno-cygwin"
LDFLAGS="$LDFLAGS -mno-cygwin"
fi
@@ -1142,6 +1122,22 @@ make_cflags_and_ldflags() {
LDFLAGS="$LDFLAGS -Wl,--subsystem,windows"
LIBS="$LIBS -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32"
fi
# GCC 4.0+ complains about that we break strict-aliasing.
# On most places we don't see how to fix it, and it doesn't
# break anything. So disable strict-aliasing to make the
# compiler all happy.
if [ $cc_version -ge 40 ]; then
CFLAGS="$CFLAGS -fno-strict-aliasing"
fi
# GCC 4.2+ automatically assumes that signed overflows do
# not occur in signed arithmetics, whereas we are not
# sure that they will not happen. It furthermore complains
# about it's own optimized code in some places.
if [ $cc_version -ge 42 ]; then
CFLAGS="$CFLAGS -fno-strict-overflow"
fi
fi
if [ "$os" != "CYGWIN" ] && [ "$os" != "FREEBSD" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then
@@ -1210,7 +1206,7 @@ make_cflags_and_ldflags() {
if [ -n "$sdl_config" ]; then
CFLAGS="$CFLAGS -DWITH_SDL"
# SDL must not add _GNU_SOURCE as it breaks many platforms
CFLAGS="$CFLAGS `$sdl_config --cflags | sed 's@-D_GNU_SOURCE[^ ]*@@'`"
CFLAGS="$CFLAGS `$sdl_config --cflags | sed 's~-D_GNU_SOURCE[^ ]*~~'`"
if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] && [ "$os" != "WINCE" ]; then
if [ "$enable_static" != "0" ]; then
LIBS="$LIBS `$sdl_config --static-libs`"
@@ -1272,7 +1268,7 @@ make_cflags_and_ldflags() {
if [ "$os" = "OSX" ]; then
# fontconfig_config goes via pkg-config on all systems, which doesn't know --prefix
# Also, despite the reason we link to the .a file ourself (because we can't use -static), we do need to ask pkg-config about possible other deps
LIBS="$LIBS `$fontconfig_config --variable=prefix`/lib/libfontconfig.a `$fontconfig_config --libs --static | sed s@-lfontconfig@@`"
LIBS="$LIBS `$fontconfig_config --variable=prefix`/lib/libfontconfig.a `$fontconfig_config --libs --static | sed s~-lfontconfig~~`"
else
LIBS="$LIBS `$fontconfig_config --libs --static | tr '\n\r' ' '`"
fi
@@ -1382,7 +1378,7 @@ make_cflags_and_ldflags() {
fi
if [ "$enable_osx_g5" != "0" ]; then
CFLAGS="$CFLAGS -mcpu=G5 -mpowerpc64 -mtune=970 -mcpu=970 -mpowerpc-gpopt"
CFLAGS="$CFLAGS -mtune=970 -mcpu=970 -mpowerpc-gpopt"
fi
if [ -n "$personal_dir" ]; then
@@ -1395,7 +1391,7 @@ make_cflags_and_ldflags() {
CFLAGS="$CFLAGS -DGLOBAL_DATA_DIR=\\\\\"$prefix_dir/$data_dir\\\\\""
log 1 "using CFLAGS... $CFLAGS"
log 1 "using CFLAGS... $CFLAGS $CC_CFLAGS"
log 1 "using LDFLAGS... $LIBS $LDFLAGS"
# Makedepend doesn't like something like: -isysroot /OSX/blabla
@@ -1404,10 +1400,8 @@ make_cflags_and_ldflags() {
# Lovely hackish, not?
# Btw, this almost always comes from outside the configure, so it is
# not something we can control.
# Also make makedepend aware of compiler's built-in defines.
if [ "$with_makedepend" != "0" ]; then
cflags_makedep="`echo | $cxx_host -E -x c++ -dM - | sed 's@.define @-D@g;s@ .*@ @g;s@(.*)@@g' | tr -d '\r\n'`"
cflags_makedep="$cflags_makedep `echo "$CFLAGS" | sed 's@ /@ -@g;s@-I[ ]*[^ ]*@@g'`"
cflags_makedep="` echo "$CFLAGS" | sed 's~ /~ -~g;s~-I[ ]*[^ ]*~~g'`"
else
makedepend=""
fi
@@ -1586,7 +1580,7 @@ check_strip() {
elif [ "$os" = "OSX" ]; then
# Most targets have -V in strip, to see if they exists... OSX doesn't.. so execute something
echo "int main(int argc, char *argv[]) { }" > strip.test.c
$cxx_host strip.test.c -o strip.test
$cc_host strip.test.c -o strip.test
check_compiler "host strip" "strip" "$host" "$strip" "$STRIP" "strip" "strip" "3" "strip.test"
rm -f strip.test.c strip.test
else
@@ -1597,7 +1591,7 @@ check_strip() {
check_lipo() {
if [ "$os" = "OSX" ] && [ "$enable_universal" != "0" ]; then
echo "int main(int argc, char *argv[]) { }" > lipo.test.c
$cxx_host lipo.test.c -o lipo.test
$cc_host lipo.test.c -o lipo.test
check_compiler "host lipo" "lipo" "$host" "$lipo" "$LIPO" "lipo" "lipo" "4" "-info lipo.test"
rm -f lipo.test.c lipo.test
fi
@@ -1623,28 +1617,6 @@ set_universal_binary_flags() {
fi
}
check_osx_sdk() {
cat > tmp.osx.mm << EOF
#include <Cocoa/Cocoa.h>
int main() {
kCGBitmapByteOrder32Host;
return 0;
}
EOF
execute="$cxx_host $CFLAGS tmp.osx.mm -framework Cocoa -o tmp.osx 2>&1"
eval $execute > /dev/null
ret=$?
log 2 "executing $execute"
log 2 " exit code $ret"
rm -f tmp.osx.mm tmp.osx
if [ "$ret" != "0" ]; then
log 1 "Your system SDK is probably too old"
log 1 "Please install/upgrade your Xcode to >= 2.5"
exit 1
fi
}
check_direct_music() {
echo "
#include <windows.h>
@@ -2433,7 +2405,7 @@ int main() {
}
EOF
execute="$cxx_host $CFLAGS -c tmp.iconv.cpp -o tmp.iconv -DTESTING 2>&1"
eval $execute > /dev/null
eval $execute >&/dev/null
ret=$?
log 2 "executing $execute"
log 2 " exit code $ret"
@@ -2454,7 +2426,7 @@ int main() {
}
EOF
execute="$cxx_host $CFLAGS tmp.iconv.cpp -o tmp.iconv -DTESTING 2>&1"
eval $execute > /dev/null
eval $execute >&/dev/null
ret=$?
log 2 "executing $execute"
log 2 " exit code $ret"
@@ -2529,8 +2501,7 @@ detect_cputype() {
log 1 "forcing cpu-type... $cpu_type bits"
return;
fi
echo "#define _SQ64 1" > tmp.64bit.cpp
echo "#include \"src/stdafx.h\"" >> tmp.64bit.cpp
echo "#include \"src/stdafx.h\"" > tmp.64bit.cpp
echo "assert_compile(sizeof(size_t) == 8);" >> tmp.64bit.cpp
echo "int main() { return 0; }" >> tmp.64bit.cpp
execute="$cxx_host $CFLAGS tmp.64bit.cpp -o tmp.64bit -DTESTING 2>&1"
@@ -2548,6 +2519,17 @@ make_sed() {
T_CFLAGS="$CFLAGS"
T_LDFLAGS="$LDFLAGS"
# We check here if we are PPC, because then we need to enable FOUR_BYTE_BOOL
# We do this here, and not sooner, so universal builds also have this
# automatically correct
# FOUR_BYTE_BOOL is needed, because C++ uses 4byte for a bool on PPC, where
# we use 1 byte per bool normally in C part. So convert that last one to 4
# bytes too, but only for PPC.
ppc=`$cc_host -dumpmachine | egrep "powerpc|ppc"`
if [ -n "$ppc" ]; then
T_CFLAGS="$T_CFLAGS -DFOUR_BYTE_BOOL"
fi
SRC_OBJS_DIR="$BASE_SRC_OBJS_DIR/$OBJS_SUBDIR"
# All the data needed to compile a single target
@@ -2555,102 +2537,104 @@ make_sed() {
# use multiple OBJS_DIR, because all in-between
# binaries are stored in there, and nowhere else.
SRC_REPLACE="
s@!!CC_HOST!!@$cc_host@g;
s@!!CXX_HOST!!@$cxx_host@g;
s@!!CC_BUILD!!@$cc_build@g;
s@!!CXX_BUILD!!@$cxx_build@g;
s@!!WINDRES!!@$windres@g;
s@!!STRIP!!@$strip $strip_arg@g;
s@!!LIPO!!@$lipo@g;
s@!!CFLAGS!!@$T_CFLAGS@g;
s@!!CFLAGS_BUILD!!@$CFLAGS_BUILD@g;
s@!!STRGEN_FLAGS!!@$strgen_flags@g;
s@!!LIBS!!@$LIBS@g;
s@!!LDFLAGS!!@$T_LDFLAGS@g;
s@!!BIN_DIR!!@$BIN_DIR@g;
s@!!ROOT_DIR!!@$ROOT_DIR@g;
s@!!MEDIA_DIR!!@$MEDIA_DIR@g;
s@!!SOURCE_LIST!!@$SOURCE_LIST@g;
s@!!SRC_OBJS_DIR!!@$SRC_OBJS_DIR@g;
s@!!LANG_OBJS_DIR!!@$LANG_OBJS_DIR@g;
s@!!SRC_DIR!!@$SRC_DIR@g;
s@!!SCRIPT_SRC_DIR!!@$SCRIPT_SRC_DIR@g;
s@!!OSXAPP!!@$OSXAPP@g;
s@!!LANG_DIR!!@$LANG_DIR@g;
s@!!TTD!!@$TTD@g;
s@!!BINARY_DIR!!@$prefix_dir/$binary_dir@g;
s@!!DATA_DIR!!@$prefix_dir/$data_dir@g;
s@!!DOC_DIR!!@$prefix_dir/$doc_dir@g;
s@!!MAN_DIR!!@$prefix_dir/$man_dir@g;
s@!!ICON_DIR!!@$prefix_dir/$icon_dir@g;
s@!!ICON_THEME_DIR!!@$prefix_dir/$icon_theme_dir@g;
s@!!PERSONAL_DIR!!@$personal_dir@g;
s@!!SHARED_DIR!!@$shared_dir@g;
s@!!INSTALL_DIR!!@$install_dir@g;
s@!!BINARY_NAME!!@$binary_name@g;
s@!!STRGEN!!@$STRGEN@g;
s@!!ENDIAN_CHECK!!@$ENDIAN_CHECK@g;
s@!!ENDIAN_FORCE!!@$endian@g;
s@!!STAGE!!@$STAGE@g;
s@!!MAKEDEPEND!!@$makedepend@g;
s@!!CFLAGS_MAKEDEP!!@$cflags_makedep@g;
s@!!SORT!!@$sort@g;
s@!!CONFIG_CACHE_COMPILER!!@config.cache.compiler@g;
s@!!CONFIG_CACHE_LINKER!!@config.cache.linker@g;
s@!!CONFIG_CACHE_ENDIAN!!@config.cache.endian@g;
s@!!CONFIG_CACHE_SOURCE!!@config.cache.source@g;
s@!!CONFIG_CACHE_VERSION!!@config.cache.version@g;
s@!!CONFIG_CACHE_SOURCE_LIST!!@config.cache.source.list@g;
s@!!CONFIG_CACHE_PWD!!@config.cache.pwd@g;
s@!!LANG_SUPPRESS!!@$lang_suppress@g;
s@!!OBJS_C!!@$OBJS_C@g;
s@!!OBJS_CPP!!@$OBJS_CPP@g;
s@!!OBJS_MM!!@$OBJS_MM@g;
s@!!OBJS_RC!!@$OBJS_RC@g;
s@!!SRCS!!@$SRCS@g;
s@!!OS!!@$os@g;
s@!!CONFIGURE_FILES!!@$CONFIGURE_FILES@g;
s@!!REVISION!!@$revision@g;
s@!!AWK!!@$awk@g;
s@!!DISTCC!!@$distcc@g;
s~!!CC_HOST!!~$cc_host~g;
s~!!CXX_HOST!!~$cxx_host~g;
s~!!CC_BUILD!!~$cc_build~g;
s~!!CXX_BUILD!!~$cxx_build~g;
s~!!WINDRES!!~$windres~g;
s~!!STRIP!!~$strip $strip_arg~g;
s~!!LIPO!!~$lipo~g;
s~!!CC_CFLAGS!!~$CC_CFLAGS~g;
s~!!CFLAGS!!~$T_CFLAGS~g;
s~!!CFLAGS_BUILD!!~$CFLAGS_BUILD~g;
s~!!STRGEN_FLAGS!!~$strgen_flags~g;
s~!!LIBS!!~$LIBS~g;
s~!!LDFLAGS!!~$T_LDFLAGS~g;
s~!!BIN_DIR!!~$BIN_DIR~g;
s~!!ROOT_DIR!!~$ROOT_DIR~g;
s~!!MEDIA_DIR!!~$MEDIA_DIR~g;
s~!!SOURCE_LIST!!~$SOURCE_LIST~g;
s~!!SRC_OBJS_DIR!!~$SRC_OBJS_DIR~g;
s~!!LANG_OBJS_DIR!!~$LANG_OBJS_DIR~g;
s~!!SRC_DIR!!~$SRC_DIR~g;
s~!!SCRIPT_SRC_DIR!!~$SCRIPT_SRC_DIR~g;
s~!!OSXAPP!!~$OSXAPP~g;
s~!!LANG_DIR!!~$LANG_DIR~g;
s~!!TTD!!~$TTD~g;
s~!!BINARY_DIR!!~$prefix_dir/$binary_dir~g;
s~!!DATA_DIR!!~$prefix_dir/$data_dir~g;
s~!!DOC_DIR!!~$prefix_dir/$doc_dir~g;
s~!!MAN_DIR!!~$prefix_dir/$man_dir~g;
s~!!ICON_DIR!!~$prefix_dir/$icon_dir~g;
s~!!ICON_THEME_DIR!!~$prefix_dir/$icon_theme_dir~g;
s~!!PERSONAL_DIR!!~$personal_dir~g;
s~!!SHARED_DIR!!~$shared_dir~g;
s~!!INSTALL_DIR!!~$install_dir~g;
s~!!BINARY_NAME!!~$binary_name~g;
s~!!STRGEN!!~$STRGEN~g;
s~!!ENDIAN_CHECK!!~$ENDIAN_CHECK~g;
s~!!ENDIAN_FORCE!!~$endian~g;
s~!!STAGE!!~$STAGE~g;
s~!!MAKEDEPEND!!~$makedepend~g;
s~!!CFLAGS_MAKEDEP!!~$cflags_makedep~g;
s~!!SORT!!~$sort~g;
s~!!CONFIG_CACHE_COMPILER!!~config.cache.compiler~g;
s~!!CONFIG_CACHE_LINKER!!~config.cache.linker~g;
s~!!CONFIG_CACHE_ENDIAN!!~config.cache.endian~g;
s~!!CONFIG_CACHE_SOURCE!!~config.cache.source~g;
s~!!CONFIG_CACHE_VERSION!!~config.cache.version~g;
s~!!CONFIG_CACHE_SOURCE_LIST!!~config.cache.source.list~g;
s~!!CONFIG_CACHE_PWD!!~config.cache.pwd~g;
s~!!LANG_SUPPRESS!!~$lang_suppress~g;
s~!!OBJS_C!!~$OBJS_C~g;
s~!!OBJS_CPP!!~$OBJS_CPP~g;
s~!!OBJS_MM!!~$OBJS_MM~g;
s~!!OBJS_RC!!~$OBJS_RC~g;
s~!!SRCS!!~$SRCS~g;
s~!!OS!!~$os~g;
s~!!CONFIGURE_FILES!!~$CONFIGURE_FILES~g;
s~!!REVISION!!~$revision~g;
s~!!AWK!!~$awk~g;
s~!!GCC295!!~$gcc295~g;
s~!!DISTCC!!~$distcc~g;
"
if [ "$icon_theme_dir" != "" ]; then
SRC_REPLACE="$SRC_REPLACE
s@!!ICON_THEME_DIR!!@$prefix_dir/$icon_theme_dir@g;
s#!!ICON_THEME_DIR!!#$prefix_dir/$icon_theme_dir#g;
"
else
SRC_REPLACE="$SRC_REPLACE
s@!!ICON_THEME_DIR!!@@g;
s#!!ICON_THEME_DIR!!##g;
"
fi
if [ "$man_dir" != "" ]; then
SRC_REPLACE="$SRC_REPLACE
s@!!MAN_DIR!!@$prefix_dir/$man_dir@g;
s#!!MAN_DIR!!#$prefix_dir/$man_dir#g;
"
else
SRC_REPLACE="$SRC_REPLACE
s@!!MAN_DIR!!@@g;
s#!!MAN_DIR!!##g;
"
fi
if [ "$menu_dir" != "" ]; then
SRC_REPLACE="$SRC_REPLACE
s@!!MENU_DIR!!@$prefix_dir/$menu_dir@g;
s#!!MENU_DIR!!#$prefix_dir/$menu_dir#g;
"
else
SRC_REPLACE="$SRC_REPLACE
s@!!MENU_DIR!!@@g;
s#!!MENU_DIR!!##g;
"
fi
}
generate_menu_item() {
MENU_REPLACE="
s@!!TTD!!@$TTD@g;
s@!!MENU_GROUP!!@$menu_group@g;
s@!!MENU_NAME!!@$menu_name@g
s~!!TTD!!~$TTD~g;
s~!!MENU_GROUP!!~$menu_group~g;
s~!!MENU_NAME!!~$menu_name~g
"
log 1 "Generating menu item..."
mkdir -p media

27
configure vendored
View File

@@ -1,13 +1,5 @@
#!/bin/sh
check_path_characters() {
if [ -n "`echo $ROOT_DIR | grep '[^-_A-Za-z0-9\/\\\.:]'`" ]; then
echo "WARNING: The path contains a non-alphanumeric character that might cause"
echo " failures in subsequent build stages. Any failures with the build"
echo " will most likely be caused by this."
fi
}
CONFIGURE_EXECUTABLE="$_"
# On *nix systems those two are equal when ./configure is done
if [ "$0" != "$CONFIGURE_EXECUTABLE" ]; then
@@ -22,16 +14,9 @@ if [ "$0" != "$CONFIGURE_EXECUTABLE" ]; then
fi
# Find out where configure is (in what dir)
ROOT_DIR="`dirname $0`"
# For MSYS/MinGW we want to know the FULL path. This as that path is generated
# once you call an outside binary. Having the same path for the rest is needed
# for dependency checking.
# pwd -W returns said FULL path, but doesn't exist on others so fall back.
ROOT_DIR="`cd $ROOT_DIR && (pwd -W 2>/dev/null || pwd 2>/dev/null)`"
ROOT_DIR="`cd $ROOT_DIR && pwd`"
check_path_characters
# Same here as for the ROOT_DIR above
PWD="`pwd -W 2>/dev/null || pwd 2>/dev/null`"
PWD="`pwd`"
PREFIX="$PWD/bin"
. $ROOT_DIR/config.lib
@@ -52,7 +37,7 @@ if [ "$1" = "--reconfig" ] || [ "$1" = "--reconfigure" ]; then
exit 1
fi
# Make sure we don't lock config.cache
cat config.cache | sed 's@\\ @\\\\ @g' > cache.tmp
cat config.cache | sed 's~\\ ~\\\\ ~g' > cache.tmp
sh cache.tmp
rm -f cache.tmp
exit $?
@@ -74,7 +59,7 @@ STRGEN="strgen$EXE"
ENDIAN_CHECK="endian_check$EXE"
if [ -z "$sort" ]; then
PIPE_SORT="sed s@a@a@"
PIPE_SORT="sed s~a~a~"
else
PIPE_SORT="$sort"
fi
@@ -140,7 +125,7 @@ SRCS="` echo \"$SRCS\" | $awk ' { ORS = " " } { print $0; }'`"
# In makefiles, we always use -u for sort
if [ -z "$sort" ]; then
sort="sed s@a@a@"
sort="sed s~a~a~"
else
sort="$sort -u"
fi
@@ -150,5 +135,3 @@ CONFIGURE_FILES="$ROOT_DIR/configure $ROOT_DIR/config.lib $ROOT_DIR/Makefile.in
generate_main
generate_lang
generate_src
check_path_characters

View File

@@ -1,7 +1,7 @@
STRGEN USAGE
------------
This guide is only interesting for people who want to alter something
themselves without access to translator.openttd.org. Please note that
themselves without access to WT2 (translator2.openttd.org). Please note that
your compiled language file will only be compatible with the OpenTTD version
you have downloaded english.txt, the master language file, for. While this is
not always true, namely when changes in the code have not touched language

View File

@@ -86,17 +86,17 @@ elif [ -d "$ROOT_DIR/.git" ]; then
fi
HASH=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null`
REV="g`echo $HASH | cut -c1-8`"
BRANCH=`git branch|grep '[*]' | sed 's@\* @@;s@^master$@@'`
REV_NR=`LC_ALL=C git log --pretty=format:%s "$SRC_DIR" | grep "^(svn r[0-9]*)" | head -n 1 | sed "s@.*(svn r\([0-9]*\)).*@\1@"`
BRANCH=`git branch|grep '[*]' | sed 's~\* ~~;s~^master$~~'`
REV_NR=`LC_ALL=C git log --pretty=format:%s "$SRC_DIR" | grep "^(svn r[0-9]*)" | head -n 1 | sed "s~.*(svn r\([0-9]*\)).*~\1~"`
elif [ -d "$ROOT_DIR/.hg" ]; then
# We are a hg checkout
if [ -n "`hg status \"$SRC_DIR\" | grep -v '^?'`" ]; then
MODIFIED="2"
fi
HASH=`LC_ALL=C hg parents --template="{node}"`
HASH=`LC_ALL=C hg parents 2>/dev/null | head -n 1 | cut -d: -f3`
REV="h`echo $HASH | cut -c1-8`"
BRANCH=`hg branch | sed 's@^default$@@'`
REV_NR=`LC_ALL=C hg log -r $HASH:0 -k "svn" -l 1 --template "{desc}\n" "$SRC_DIR" | grep "^(svn r[0-9]*)" | head -n 1 | sed "s@.*(svn r\([0-9]*\)).*@\1@"`
BRANCH=`hg branch | sed 's~^default$~~'`
REV_NR=`LC_ALL=C hg log -r $HASH:0 -k "svn" -l 1 --template "{desc}\n" "$SRC_DIR" | grep "^(svn r[0-9]*)" | head -n 1 | sed "s~.*(svn r\([0-9]*\)).*~\1~"`
else
# We don't know
MODIFIED="1"

View File

@@ -11,18 +11,14 @@ by the number below on http://bugs.openttd.org.
If the bug report is closed, it has been fixed, which then can be verified
in the latest SVN version of /trunk.
Bugs for 0.7.1
Bugs for 0.7.0
------------------------------------------------------------------------
URL: http://bugs.openttd.org
- 3040 Not all alternatives are always shown in the "Join station" list
- 2955 With path signals depots are less likely to be visited
- 2891 Ignore signal does not keep the train running when in path signalled block till the next signal
- 2769 No offer for buying bankrupt AIs
- 2737 Self-crossing trains ignore "forbid 90 degree turn" setting
- 2616 Cloning creates vehicles with invalid subcargos
- 2585 [OSX] OS' mouse pointer showing
- 2484 [OSX] Cannot enter CJK characters
- 2427 Vehicle owner gets paid for whole cargo feeder share
- 1944 Road vehicles not picking empty drivethrough platform
- 1762 Strange Autoreplace behaviour

View File

@@ -1,64 +1,28 @@
openttd (0.7.2~RC2) unstable; urgency=low
* New upstream release.
-- Matthijs Kooijman <matthijs@stdin.nl> Tue, 21 Jul 2008 20:25:56 +0200
openttd (0.7.2~RC1) unstable; urgency=low
* New upstream release.
-- Matthijs Kooijman <matthijs@stdin.nl> Wed, 15 Jul 2008 22:25:56 +0200
openttd (0.7.1) unstable; urgency=low
* New upstream release.
-- Matthijs Kooijman <matthijs@stdin.nl> Tue, 09 Jun 2008 01:34:56 +0200
openttd (0.7.1~RC3) unstable; urgency=low
* New upstream release.
-- Matthijs Kooijman <matthijs@stdin.nl> Wed, 03 Jun 2008 15:34:56 +0200
openttd (0.7.1~RC2) unstable; urgency=low
* New upstream release.
-- Matthijs Kooijman <matthijs@stdin.nl> Thu, 21 Mar 2008 14:34:56 +0200
openttd (0.7.1~RC1) unstable; urgency=low
* New upstream release.
-- Matthijs Kooijman <matthijs@stdin.nl> Mon, 11 Mar 2008 17:34:56 +0200
openttd (0.7.0) unstable; urgency=low
* New upstream release.
-- Matthijs Kooijman <matthijs@stdin.nl> Wed, 01 Apr 2008 13:37:42 +0000
openttd (0.7.0~RC2) unstable; urgency=low
openttd (0.7.0-RC2) unstable; urgency=low
* New upstream release.
-- Matthijs Kooijman <matthijs@stdin.nl> Mon, 23 Mar 2008 00:42:00 +0200
openttd (0.7.0~RC1) unstable; urgency=low
openttd (0.7.0-RC1) unstable; urgency=low
* New upstream release.
-- Matthijs Kooijman <matthijs@stdin.nl> Mon, 16 Mar 2008 00:07:00 +0200
openttd (0.7.0~beta2) unstable; urgency=low
openttd (0.7.0-beta2) unstable; urgency=low
* New upstream release.
-- Matthijs Kooijman <matthijs@stdin.nl> Tue, 10 Mar 2009 00:33:05 +0100
openttd (0.7.0~beta1) unstable; urgency=low
openttd (0.7.0-beta1) unstable; urgency=low
* New upstream release.

View File

@@ -10,7 +10,7 @@
#-------------------------------------------------------------------------------
Name: openttd
Version: 0.7.2-RC2
Version: 0.7.0
Release: 1%{?dist}
Group: Amusements/Games

View File

@@ -1,11 +1,11 @@
!define APPNAME "OpenTTD" ; Define application name
!define APPVERSION "0.7.2-RC2" ; Define application version
!define APPVERSIONINTERNAL "0.7.2.0" ; Define application version in X.X.X.X
!define INSTALLERVERSION 64 ; NEED TO UPDATE THIS FOR EVERY RELEASE!!!
!define APPVERSION "0.7.0" ; Define application version
!define INSTALLERVERSION 58 ; NEED TO UPDATE THIS FOR EVERY RELEASE!!!
!include ${VERSION_INCLUDE}
!define APPURLLINK "http://www.openttd.org"
!define APPNAMEANDVERSION "${APPNAME} ${APPVERSION}"
!define APPVERSIONINTERNAL "${APPVERSION}.0" ; Needs to be of the format X.X.X.X
!define MUI_ICON "..\..\..\media\openttd.ico"
!define MUI_UNICON "..\..\..\media\openttd.ico"
@@ -112,6 +112,13 @@ Section "!OpenTTD" Section1
File ${PATH_ROOT}bin\data\*.grf
File ${PATH_ROOT}bin\data\*.obg
File ${PATH_ROOT}bin\data\opntitle.dat
; Copy scenario files (don't choke if they don't exist)
SetOutPath "$INSTDIR\scenario\"
File /nonfatal ${PATH_ROOT}bin\scenario\*.scn
; Copy heightmap files (don't choke if they don't exist)
SetOutPath "$INSTDIR\scenario\heightmap\"
File /nonfatal ${PATH_ROOT}bin\scenario\heightmap\*.*
; Copy the scripts
SetOutPath "$INSTDIR\scripts\"

View File

@@ -16,10 +16,10 @@ End Sub
Sub UpdateFile(modified, revision, version, cur_date, filename)
FSO.CopyFile filename & ".in", filename
FindReplaceInFile filename, "!!MODIFIED!!", modified
FindReplaceInFile filename, "!!REVISION!!", revision
FindReplaceInFile filename, "!!VERSION!!", version
FindReplaceInFile filename, "!!DATE!!", cur_date
FindReplaceInFile filename, "@@MODIFIED@@", modified
FindReplaceInFile filename, "@@REVISION@@", revision
FindReplaceInFile filename, "@@VERSION@@", version
FindReplaceInFile filename, "@@DATE@@", cur_date
End Sub
Sub UpdateFiles(version)
@@ -32,7 +32,7 @@ Sub UpdateFiles(version)
modified = Mid(version, InStrRev(version, Chr(9)) + 1)
version = Mid(version, 1, InStr(version, Chr(9)) - 1)
Else
version = "0.7.2-RC2"
version = "0.7.0"
revision = 0
modified = 1
End If

View File

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

View File

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

View File

@@ -60,7 +60,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs;..\src\3rdparty\squirrel\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;WITH_ASSERT"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -103,8 +103,6 @@
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
SubSystem="2"
StackReserveSize="1048576"
StackCommitSize="1048576"
OptimizeReferences="2"
OptimizeForWindows98="1"
TargetMachine="1"
@@ -203,8 +201,6 @@
IgnoreDefaultLibraryNames="LIBCMT.lib"
GenerateDebugInformation="true"
SubSystem="2"
StackReserveSize="1048576"
StackCommitSize="1048576"
TargetMachine="1"
/>
<Tool
@@ -273,7 +269,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs;..\src\3rdparty\squirrel\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;_SQ64;WITH_ASSERT"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;_SQ64"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -316,8 +312,6 @@
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
SubSystem="2"
StackReserveSize="1048576"
StackCommitSize="1048576"
OptimizeReferences="2"
OptimizeForWindows98="1"
TargetMachine="17"
@@ -419,8 +413,6 @@
IgnoreDefaultLibraryNames="LIBCMT.lib"
GenerateDebugInformation="true"
SubSystem="2"
StackReserveSize="1048576"
StackCommitSize="1048576"
TargetMachine="17"
/>
<Tool
@@ -955,10 +947,6 @@
RelativePath=".\..\src\driver.h"
>
</File>
<File
RelativePath=".\..\src\economy_base.h"
>
</File>
<File
RelativePath=".\..\src\economy_func.h"
>
@@ -2671,10 +2659,6 @@
RelativePath=".\..\src\ai\api\ai_sign.hpp"
>
</File>
<File
RelativePath=".\..\src\ai\api\ai_signlist.hpp"
>
</File>
<File
RelativePath=".\..\src\ai\api\ai_station.hpp"
>
@@ -2879,10 +2863,6 @@
RelativePath=".\..\src\ai\api\ai_sign.cpp"
>
</File>
<File
RelativePath=".\..\src\ai\api\ai_signlist.cpp"
>
</File>
<File
RelativePath=".\..\src\ai\api\ai_station.cpp"
>

View File

@@ -60,7 +60,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs;..\src\3rdparty\squirrel\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;WITH_ASSERT"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -103,8 +103,6 @@
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
SubSystem="2"
StackReserveSize="1048576"
StackCommitSize="1048576"
OptimizeReferences="2"
OptimizeForWindows98="1"
TargetMachine="1"
@@ -203,8 +201,6 @@
IgnoreDefaultLibraryNames="LIBCMT.lib"
GenerateDebugInformation="true"
SubSystem="2"
StackReserveSize="1048576"
StackCommitSize="1048576"
TargetMachine="1"
/>
<Tool
@@ -273,7 +269,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs;..\src\3rdparty\squirrel\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;_SQ64;WITH_ASSERT"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;_SQ64"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -316,8 +312,6 @@
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
SubSystem="2"
StackReserveSize="1048576"
StackCommitSize="1048576"
OptimizeReferences="2"
OptimizeForWindows98="1"
TargetMachine="17"
@@ -419,8 +413,6 @@
IgnoreDefaultLibraryNames="LIBCMT.lib"
GenerateDebugInformation="true"
SubSystem="2"
StackReserveSize="1048576"
StackCommitSize="1048576"
TargetMachine="17"
/>
<Tool

View File

@@ -61,7 +61,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs;..\src\3rdparty\squirrel\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;WITH_ASSERT"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -104,8 +104,6 @@
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
SubSystem="2"
StackReserveSize="1048576"
StackCommitSize="1048576"
OptimizeReferences="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
@@ -202,8 +200,6 @@
IgnoreDefaultLibraryNames="LIBCMT.lib"
GenerateDebugInformation="true"
SubSystem="2"
StackReserveSize="1048576"
StackCommitSize="1048576"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
@@ -271,7 +267,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs;..\src\3rdparty\squirrel\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;_SQ64;WITH_ASSERT"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;_SQ64"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -314,8 +310,6 @@
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
SubSystem="2"
StackReserveSize="1048576"
StackCommitSize="1048576"
OptimizeReferences="2"
TargetMachine="17"
/>
@@ -416,8 +410,6 @@
IgnoreDefaultLibraryNames="LIBCMT.lib"
GenerateDebugInformation="true"
SubSystem="2"
StackReserveSize="1048576"
StackCommitSize="1048576"
TargetMachine="17"
/>
<Tool
@@ -952,10 +944,6 @@
RelativePath=".\..\src\driver.h"
>
</File>
<File
RelativePath=".\..\src\economy_base.h"
>
</File>
<File
RelativePath=".\..\src\economy_func.h"
>
@@ -2668,10 +2656,6 @@
RelativePath=".\..\src\ai\api\ai_sign.hpp"
>
</File>
<File
RelativePath=".\..\src\ai\api\ai_signlist.hpp"
>
</File>
<File
RelativePath=".\..\src\ai\api\ai_station.hpp"
>
@@ -2876,10 +2860,6 @@
RelativePath=".\..\src\ai\api\ai_sign.cpp"
>
</File>
<File
RelativePath=".\..\src\ai\api\ai_signlist.cpp"
>
</File>
<File
RelativePath=".\..\src\ai\api\ai_station.cpp"
>

View File

@@ -61,7 +61,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs;..\src\3rdparty\squirrel\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;WITH_ASSERT"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -104,8 +104,6 @@
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
SubSystem="2"
StackReserveSize="1048576"
StackCommitSize="1048576"
OptimizeReferences="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
@@ -202,8 +200,6 @@
IgnoreDefaultLibraryNames="LIBCMT.lib"
GenerateDebugInformation="true"
SubSystem="2"
StackReserveSize="1048576"
StackCommitSize="1048576"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
@@ -271,7 +267,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs;..\src\3rdparty\squirrel\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;_SQ64;WITH_ASSERT"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;WITH_ICU;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;_SQ64"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -314,8 +310,6 @@
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
SubSystem="2"
StackReserveSize="1048576"
StackCommitSize="1048576"
OptimizeReferences="2"
TargetMachine="17"
/>
@@ -416,8 +410,6 @@
IgnoreDefaultLibraryNames="LIBCMT.lib"
GenerateDebugInformation="true"
SubSystem="2"
StackReserveSize="1048576"
StackCommitSize="1048576"
TargetMachine="17"
/>
<Tool

View File

@@ -1,6 +1,6 @@
OpenTTD README
Last updated: 2009-06-09
Release version: 0.7.1
Last updated: 2009-04-01
Release version: 0.7.0
------------------------------------------------------------------------
@@ -381,8 +381,10 @@ The following libraries are used by OpenTTD for:
See http://www.openttd.org/development for up-to-date information.
The use of the online Translator service, located at
http://translator.openttd.org/, is highly encouraged. For getting an account
simply follow the guidelines in the FAQ of the translator website.
http://translator2.openttd.org/, is highly encouraged. For a username/password
combo you should contact the development team, either by mail, IRC or the
forums. The system is straightforward to use, and if you have any problems,
read the online help located there.
If for some reason the website is down for a longer period of time, the
information below might be of help.

View File

@@ -167,7 +167,6 @@ direction_func.h
direction_type.h
music/dmusic.h
driver.h
economy_base.h
economy_func.h
economy_type.h
effectvehicle_base.h
@@ -621,7 +620,6 @@ ai/api/ai_rail.hpp
ai/api/ai_railtypelist.hpp
ai/api/ai_road.hpp
ai/api/ai_sign.hpp
ai/api/ai_signlist.hpp
ai/api/ai_station.hpp
ai/api/ai_stationlist.hpp
ai/api/ai_subsidy.hpp
@@ -674,7 +672,6 @@ ai/api/ai_rail.cpp
ai/api/ai_railtypelist.cpp
ai/api/ai_road.cpp
ai/api/ai_sign.cpp
ai/api/ai_signlist.cpp
ai/api/ai_station.cpp
ai/api/ai_stationlist.cpp
ai/api/ai_subsidy.cpp

View File

@@ -275,7 +275,6 @@ typedef struct tagSQRegFunction{
}SQRegFunction;
/*vm*/
SQUIRREL_API bool sq_can_suspend(HSQUIRRELVM v);
SQUIRREL_API HSQUIRRELVM sq_open(SQInteger initialstacksize);
SQUIRREL_API HSQUIRRELVM sq_newthread(HSQUIRRELVM friendvm, SQInteger initialstacksize);
SQUIRREL_API void sq_seterrorhandler(HSQUIRRELVM v);

View File

@@ -90,11 +90,6 @@ SQInteger sq_getvmstate(HSQUIRRELVM v)
}
}
bool sq_can_suspend(HSQUIRRELVM v)
{
return v->_nnativecalls <= 2;
}
void sq_seterrorhandler(HSQUIRRELVM v)
{
SQObject o = stack_get(v, -1);

View File

@@ -188,13 +188,9 @@ SQSharedState::~SQSharedState()
#ifndef NO_GARBAGE_COLLECTOR
SQCollectable *t = _gc_chain;
SQCollectable *nx = NULL;
while(t) {
t->_uiRef++;
t = t->_next;
}
t = _gc_chain;
while(t) {
t->UnMark();
t->_uiRef++;
t->Finalize();
nx = t->_next;
if(--t->_uiRef == 0)

View File

@@ -83,7 +83,7 @@ SQVM::SQVM(SQSharedState *ss)
_suspended = SQFalse;
_suspended_target=-1;
_suspended_root = SQFalse;
_suspended_traps=0;
_suspended_traps=-1;
_foreignptr=NULL;
_nnativecalls=0;
_lasterror = _null_;
@@ -688,7 +688,6 @@ bool SQVM::Execute(SQObjectPtr &closure, SQInteger target, SQInteger nargs, SQIn
_suspended = SQFalse;
break;
case ET_RESUME_OPENTTD:
traps = _suspended_traps;
_suspended = SQFalse;
break;
}
@@ -699,7 +698,7 @@ exception_restore:
for(;;)
{
DecreaseOps(1);
if (ShouldSuspend()) { _suspended = SQTrue; _suspended_traps = traps; return true; }
if (ShouldSuspend()) { _suspended = SQTrue; return true; }
const SQInstruction &_i_ = *ci->_ip++;
//dumpstack(_stackbase);
@@ -749,16 +748,7 @@ common_call:
case OT_NATIVECLOSURE: {
bool suspend;
_suspended_target = ct_target;
try {
_GUARD(CallNative(_nativeclosure(clo), arg3, ct_stackbase, clo,suspend));
} catch (...) {
_suspended = SQTrue;
_suspended_target = ct_target;
_suspended_root = ci->_root;
_suspended_traps = traps;
_suspend_varargs = ci->_vargs;
throw;
}
_GUARD(CallNative(_nativeclosure(clo), arg3, ct_stackbase, clo,suspend));
if(suspend){
_suspended = SQTrue;
_suspended_target = ct_target;
@@ -938,7 +928,7 @@ common_call:
traps -= ci->_etraps;
if(sarg1 != MAX_FUNC_STACKSIZE) STK(arg1) = temp_reg;
}
else { Raise_Error(_SC("trying to yield a '%s',only genenerator can be yielded"), GetTypeName(ci->_closure)); SQ_THROW();}
else { Raise_Error(_SC("trying to yield a '%s',only genenerator can be yielded"), GetTypeName(ci->_generator)); SQ_THROW();}
if(Return(arg0, arg1, temp_reg)){
assert(traps == 0);
outres = temp_reg;

View File

@@ -103,11 +103,6 @@ struct AIListWindow : public Window {
sprintf(buf, "%d", selected_info->GetVersion());
DoDrawStringTruncated(buf, x + 5, y, TC_BLACK, this->width - x - 8);
y += 13;
if (selected_info->GetURL() != NULL) {
SetDParamStr(0, selected_info->GetURL());
DrawString(4, y, STR_AI_URL, TC_BLACK);
y += 13;
}
SetDParamStr(0, selected_info->GetDescription());
DrawStringMultiLine(4, y, STR_JUST_RAW_STRING, this->width - 8, this->widget[AIL_WIDGET_INFO_BG].bottom - y);
}
@@ -561,7 +556,6 @@ struct AIDebugWindow : public Window {
enum AIDebugWindowWidgets {
AID_WIDGET_CLOSEBOX = 0,
AID_WIDGET_CAPTION,
AID_WIDGET_STICKY,
AID_WIDGET_VIEW,
AID_WIDGET_NAME_TEXT,
AID_WIDGET_RELOAD_TOGGLE,
@@ -581,8 +575,6 @@ struct AIDebugWindow : public Window {
static CompanyID ai_debug_company;
int redraw_timer;
int last_vscroll_pos;
bool autoscroll;
AIDebugWindow(const WindowDesc *desc, WindowNumber number) : Window(desc, number)
{
@@ -595,8 +587,6 @@ struct AIDebugWindow : public Window {
this->vscroll.cap = 14;
this->vscroll.pos = 0;
this->resize.step_height = 12;
this->last_vscroll_pos = 0;
this->autoscroll = true;
if (ai_debug_company != INVALID_COMPANY) this->LowerWidget(ai_debug_company + AID_WIDGET_COMPANY_BUTTON_START);
@@ -606,7 +596,7 @@ struct AIDebugWindow : public Window {
virtual void OnPaint()
{
/* Check if the currently selected company is still active. */
if (ai_debug_company == INVALID_COMPANY || !IsValidCompanyID(ai_debug_company) || !GetCompany(ai_debug_company)->is_ai) {
if (ai_debug_company == INVALID_COMPANY || !IsValidCompanyID(ai_debug_company)) {
if (ai_debug_company != INVALID_COMPANY) {
/* Raise and disable the widget for the previous selection. */
this->RaiseWidget(ai_debug_company + AID_WIDGET_COMPANY_BUTTON_START);
@@ -674,35 +664,13 @@ struct AIDebugWindow : public Window {
AILog::LogData *log = (AILog::LogData *)AIObject::GetLogPointer();
_current_company = old_company;
int scroll_count = (log == NULL) ? 0 : log->used;
if (this->vscroll.count != scroll_count) {
SetVScrollCount(this, scroll_count);
/* We need a repaint */
this->InvalidateWidget(AID_WIDGET_SCROLLBAR);
}
SetVScrollCount(this, (log == NULL) ? 0 : log->used);
this->InvalidateWidget(AID_WIDGET_SCROLLBAR);
if (log == NULL) return;
/* Detect when the user scrolls the window. Enable autoscroll when the
* bottom-most line becomes visible. */
if (this->last_vscroll_pos != this->vscroll.pos) {
this->autoscroll = this->vscroll.pos >= log->used - this->vscroll.cap;
}
if (this->autoscroll) {
int scroll_pos = max(0, log->used - this->vscroll.cap);
if (scroll_pos != this->vscroll.pos) {
this->vscroll.pos = scroll_pos;
/* We need a repaint */
this->InvalidateWidget(AID_WIDGET_SCROLLBAR);
}
}
last_vscroll_pos = this->vscroll.pos;
int y = 6;
for (int i = this->vscroll.pos; i < (this->vscroll.cap + this->vscroll.pos) && i < log->used; i++) {
uint pos = (i + log->pos + 1 - log->used + log->count) % log->count;
for (int i = this->vscroll.pos; i < (this->vscroll.cap + this->vscroll.pos); i++) {
uint pos = (log->count + log->pos - i) % log->count;
if (log->lines[pos] == NULL) break;
TextColour colour;
@@ -725,8 +693,6 @@ struct AIDebugWindow : public Window {
this->RaiseWidget(ai_debug_company + AID_WIDGET_COMPANY_BUTTON_START);
ai_debug_company = show_ai;
this->LowerWidget(ai_debug_company + AID_WIDGET_COMPANY_BUTTON_START);
this->autoscroll = true;
this->last_vscroll_pos = this->vscroll.pos;
this->SetDirty();
}
@@ -760,7 +726,6 @@ struct AIDebugWindow : public Window {
virtual void OnResize(Point new_size, Point delta)
{
this->vscroll.cap += delta.y / (int)this->resize.step_height;
SetVScrollCount(this, this->vscroll.count); // vscroll.pos should be in a valid range
}
};
@@ -769,7 +734,6 @@ CompanyID AIDebugWindow::ai_debug_company = INVALID_COMPANY;
static const Widget _ai_debug_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // AID_WIDGET_CLOSEBOX
{ WWT_CAPTION, RESIZE_RIGHT, COLOUR_GREY, 11, 298, 0, 13, STR_AI_DEBUG, STR_018C_WINDOW_TITLE_DRAG_THIS}, // AID_WIDGET_CAPTION
{ WWT_STICKYBOX, RESIZE_LR, COLOUR_GREY, 287, 298, 0, 13, 0x0, STR_STICKY_BUTTON }, // AID_WIDGET_STICKY
{ WWT_PANEL, RESIZE_RIGHT, COLOUR_GREY, 0, 298, 14, 40, 0x0, STR_NULL}, // AID_WIDGET_VIEW
{ WWT_PANEL, RESIZE_RIGHT, COLOUR_GREY, 0, 149, 41, 60, 0x0, STR_AI_DEBUG_NAME_TIP}, // AID_WIDGET_NAME_TEXT
@@ -807,7 +771,7 @@ static const Widget _ai_debug_widgets[] = {
static const WindowDesc _ai_debug_desc(
WDP_AUTO, WDP_AUTO, 299, 241, 299, 241,
WC_AI_DEBUG, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
_ai_debug_widgets
);

View File

@@ -36,7 +36,6 @@ AIFileInfo::~AIFileInfo()
free((void *)this->description);
free((void *)this->date);
free((void *)this->instance_name);
free((void *)this->url);
free(this->main_script);
free(this->SQ_instance);
}
@@ -99,11 +98,6 @@ bool AIFileInfo::CheckMethod(const char *name) const
if (!info->engine->CallIntegerMethod(*info->SQ_instance, "GetVersion", &info->version)) return SQ_ERROR;
if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "CreateInstance", &info->instance_name)) return SQ_ERROR;
/* The GetURL function is optional. */
if (info->engine->MethodExists(*info->SQ_instance, "GetURL")) {
if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetURL", &info->url)) return SQ_ERROR;
}
return 0;
}
@@ -131,12 +125,6 @@ bool AIFileInfo::CheckMethod(const char *name) const
} else {
info->min_loadable_version = info->GetVersion();
}
/* When there is an UseAsRandomAI function, call it. */
if (info->engine->MethodExists(*info->SQ_instance, "UseAsRandomAI")) {
if (!info->engine->CallBoolMethod(*info->SQ_instance, "UseAsRandomAI", &info->use_as_random)) return SQ_ERROR;
} else {
info->use_as_random = true;
}
/* Remove the link to the real instance, else it might get deleted by RegisterAI() */
sq_setinstanceup(vm, 2, NULL);

View File

@@ -41,7 +41,7 @@ public:
friend class AIInfo;
friend class AILibrary;
AIFileInfo() : SQ_instance(NULL), main_script(NULL), author(NULL), name(NULL), short_name(NULL), description(NULL), date(NULL), instance_name(NULL), url(NULL) {};
AIFileInfo() : SQ_instance(NULL), main_script(NULL), author(NULL), name(NULL), short_name(NULL), description(NULL), date(NULL), instance_name(NULL) {};
~AIFileInfo();
/**
@@ -84,11 +84,6 @@ public:
*/
const char *GetInstanceName() const { return this->instance_name; }
/**
* Get the website for this script.
*/
const char *GetURL() const { return this->url; }
/**
* Get the filename of the main.nut script.
*/
@@ -116,7 +111,6 @@ private:
const char *date;
const char *instance_name;
int version;
const char *url;
};
class AIInfo : public AIFileInfo {
@@ -161,15 +155,9 @@ public:
*/
int GetSettingDefaultValue(const char *name) const;
/**
* Use this AI as a random AI.
*/
bool UseAsRandomAI() const { return this->use_as_random; }
private:
AIConfigItemList config_list;
int min_loadable_version;
bool use_as_random;
};
class AILibrary : public AIFileInfo {

View File

@@ -19,7 +19,6 @@
#define DEFINE_SCRIPT_FILES
#include "ai_info.hpp"
#include "ai_config.hpp"
#include "ai_storage.hpp"
#include "ai_instance.hpp"
#include "ai_gui.hpp"
@@ -60,7 +59,6 @@
#include "api/ai_railtypelist.hpp.sq"
#include "api/ai_road.hpp.sq"
#include "api/ai_sign.hpp.sq"
#include "api/ai_signlist.hpp.sq"
#include "api/ai_station.hpp.sq"
#include "api/ai_stationlist.hpp.sq"
#include "api/ai_subsidy.hpp.sq"
@@ -100,7 +98,6 @@ AIInstance::AIInstance(AIInfo *info) :
instance(NULL),
is_started(false),
is_dead(false),
is_save_data_on_stack(false),
suspend(0),
callback(NULL)
{
@@ -138,6 +135,10 @@ AIInstance::AIInstance(AIInfo *info) :
/* Register the API functions and classes */
this->RegisterAPI();
/* The topmost stack item is true if there is data from a savegame
* and false otherwise. */
sq_pushbool(this->engine->vm, false);
}
AIInstance::~AIInstance()
@@ -210,7 +211,6 @@ void AIInstance::RegisterAPI()
SQAIRailTypeList_Register(this->engine);
SQAIRoad_Register(this->engine);
SQAISign_Register(this->engine);
SQAISignList_Register(this->engine);
SQAIStation_Register(this->engine);
SQAIStationList_Register(this->engine);
SQAIStationList_Vehicle_Register(this->engine);
@@ -255,15 +255,8 @@ void AIInstance::Died()
this->engine = NULL;
ShowAIDebugWindow(_current_company);
const AIInfo *info = AIConfig::GetConfig(_current_company)->GetInfo();
if (info != NULL) {
if (strcmp(GetCompany(_current_company)->ai_info->GetMainScript(), "%_dummy") != 0) {
ShowErrorMessage(INVALID_STRING_ID, STR_AI_PLEASE_REPORT_CRASH, 0, 0);
if (info->GetURL() != NULL) {
AILog::Info("Please report the error to the following URL:");
AILog::Info(info->GetURL());
}
}
}
@@ -283,10 +276,6 @@ void AIInstance::GameLoop()
/* If there is a callback to call, call that first */
if (this->callback != NULL) {
if (this->is_save_data_on_stack) {
sq_poptop(this->engine->GetVM());
this->is_save_data_on_stack = false;
}
try {
this->callback(this);
} catch (AI_VMSuspend e) {
@@ -305,17 +294,9 @@ void AIInstance::GameLoop()
AIObject::SetAllowDoCommand(false);
/* Run the constructor if it exists. Don't allow any DoCommands in it. */
if (this->engine->MethodExists(*this->instance, "constructor")) {
if (!this->engine->CallMethod(*this->instance, "constructor", 100000) || this->engine->IsSuspended()) {
if (this->engine->IsSuspended()) AILog::Error("This AI took too long to initialize. AI is not started.");
this->Died();
return;
}
}
if (!this->CallLoad() || this->engine->IsSuspended()) {
if (this->engine->IsSuspended()) AILog::Error("This AI took too long in the Load function. AI is not started.");
this->Died();
return;
if (!this->engine->CallMethod(*this->instance, "constructor")) { this->Died(); return; }
}
if (!this->CallLoad()) { this->Died(); return; }
AIObject::SetAllowDoCommand(true);
/* Start the AI by calling Start() */
if (!this->engine->CallMethod(*this->instance, "Start", _settings_game.ai.ai_max_opcode_till_suspend) || !this->engine->IsSuspended()) this->Died();
@@ -327,10 +308,6 @@ void AIInstance::GameLoop()
this->is_started = true;
return;
}
if (this->is_save_data_on_stack) {
sq_poptop(this->engine->GetVM());
this->is_save_data_on_stack = false;
}
/* Continue the VM */
try {
@@ -549,14 +526,20 @@ void AIInstance::Save()
}
HSQUIRRELVM vm = this->engine->GetVM();
if (this->is_save_data_on_stack) {
if (!this->is_started) {
SQBool res;
sq_getbool(vm, -1, &res);
if (!res) {
SaveEmpty();
return;
}
/* Push the loaded savegame data to the top of the stack. */
sq_push(vm, -2);
_ai_sl_byte = 1;
SlObject(NULL, _ai_byte);
/* Save the data that was just loaded. */
SaveObject(vm, -1, AISAVE_MAX_DEPTH, false);
} else if (!this->is_started) {
SaveEmpty();
return;
sq_poptop(vm);
} else if (this->engine->MethodExists(*this->instance, "Save")) {
HSQOBJECT savedata;
/* We don't want to be interrupted during the save function. */
@@ -573,7 +556,6 @@ void AIInstance::Save()
if (!sq_istable(savedata)) {
AILog::Error("Save function should return a table.");
SaveEmpty();
this->engine->CrashOccurred();
return;
}
sq_pushobject(vm, savedata);
@@ -581,11 +563,11 @@ void AIInstance::Save()
_ai_sl_byte = 1;
SlObject(NULL, _ai_byte);
SaveObject(vm, -1, AISAVE_MAX_DEPTH, false);
this->is_save_data_on_stack = true;
} else {
SaveEmpty();
this->engine->CrashOccurred();
_ai_sl_byte = 0;
SlObject(NULL, _ai_byte);
}
sq_pop(vm, 1);
} else {
AILog::Warning("Save function is not implemented");
_ai_sl_byte = 0;
@@ -672,18 +654,21 @@ void AIInstance::Load(int version)
/* Check if there was anything saved at all. */
if (_ai_sl_byte == 0) return;
/* First remove the value "false" since we have data to load. */
sq_poptop(vm);
sq_pushinteger(vm, version);
LoadObjects(vm);
this->is_save_data_on_stack = true;
sq_pushbool(vm, true);
}
bool AIInstance::CallLoad()
{
HSQUIRRELVM vm = this->engine->GetVM();
/* Is there save data that we should load? */
if (!this->is_save_data_on_stack) return true;
/* Whatever happens, after CallLoad the savegame data is removed from the stack. */
this->is_save_data_on_stack = false;
SQBool res;
sq_getbool(vm, -1, &res);
sq_poptop(vm);
if (!res) return true;
if (!this->engine->MethodExists(*this->instance, "Load")) {
AILog::Warning("Loading failed: there was data for the AI to load, but the AI does not have a Load() function.");
@@ -707,7 +692,7 @@ bool AIInstance::CallLoad()
/* Call the AI load function. sq_call removes the arguments (but not the
* function pointer) from the stack. */
if (SQ_FAILED(sq_call(vm, 3, SQFalse, SQFalse, 100000))) return false;
if (SQ_FAILED(sq_call(vm, 3, SQFalse, SQFalse))) return false;
/* Pop 1) The version, 2) the savegame data, 3) the object instance, 4) the function pointer. */
sq_pop(vm, 4);

View File

@@ -30,7 +30,6 @@ private:
class AIInstance {
public:
friend class AIObject;
AIInstance(class AIInfo *info);
~AIInstance();
@@ -118,7 +117,6 @@ private:
bool is_started;
bool is_dead;
bool is_save_data_on_stack;
int suspend;
AISuspendCallbackProc *callback;

View File

@@ -153,7 +153,7 @@ AIScanner::AIScanner() :
/* Create the dummy AI */
this->engine->ResetCrashed();
strecpy(this->main_script, "%_dummy", lastof(this->main_script));
strcpy(this->main_script, "%_dummy");
extern void AI_CreateAIInfoDummy(HSQUIRRELVM vm);
AI_CreateAIInfoDummy(this->engine->GetVM());
}
@@ -345,31 +345,20 @@ void AIScanner::RegisterAI(AIInfo *info)
AIInfo *AIScanner::SelectRandomAI()
{
uint num_random_ais = 0;
for (AIInfoList::iterator it = this->info_single_list.begin(); it != this->info_single_list.end(); it++) {
if (it->second->UseAsRandomAI()) num_random_ais++;
}
if (num_random_ais == 0) {
if (this->info_single_list.size() == 0) {
DEBUG(ai, 0, "No suitable AI found, loading 'dummy' AI.");
return this->info_dummy;
}
/* Find a random AI */
uint pos;
if (_networking) {
pos = InteractiveRandomRange(num_random_ais);
} else {
pos = RandomRange(num_random_ais);
}
if (_networking) pos = InteractiveRandomRange((uint16)this->info_single_list.size());
else pos = RandomRange((uint16)this->info_single_list.size());
/* Find the Nth item from the array */
AIInfoList::iterator it = this->info_single_list.begin();
while (!it->second->UseAsRandomAI()) it++;
for (; pos > 0; pos--) {
it++;
while (!it->second->UseAsRandomAI()) it++;
}
for (; pos > 0; pos--) it++;
AIInfoList::iterator first_it = it;
return (*it).second;
}
@@ -412,7 +401,7 @@ AIInfo *AIScanner::FindInfo(const char *nameParam, int versionParam)
snprintf(ai_name_compare, sizeof(ai_name_compare), "%s", (*it).second->GetName());
strtolower(ai_name_compare);
if (strcasecmp(ai_name, ai_name_compare) == 0 && (*it).second->CanLoadFromVersion(versionParam) && (version == -1 || (*it).second->GetVersion() > version)) {
if (strcasecmp(ai_name, ai_name_compare) == 0 && (*it).second->CanLoadFromVersion(versionParam)) {
version = (*it).second->GetVersion();
info = (*it).second;
}

View File

@@ -31,6 +31,7 @@ SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 2

View File

@@ -8,21 +8,12 @@
#include "../../company_func.h"
#include "../../command_type.h"
#include "../../town.h"
#include "../../economy_func.h"
/* static */ bool AIAirport::IsValidAirportType(AirportType type)
{
return type >= AT_SMALL && type <= AT_HELISTATION && HasBit(::GetValidAirports(), type);
}
/* static */ Money AIAirport::GetPrice(AirportType type)
{
if (!IsValidAirportType(type)) return -1;
const AirportFTAClass *afc = ::GetAirport(type);
return _price.build_airport * afc->size_x * afc->size_y;
}
/* static */ bool AIAirport::IsHangarTile(TileIndex tile)
{
if (!::IsValidTile(tile)) return false;

View File

@@ -53,13 +53,6 @@ public:
*/
static bool IsValidAirportType(AirportType type);
/**
* Get the cost to build this AirportType.
* @param type The AirportType to check.
* @return The cost of building this AirportType.
*/
static Money GetPrice(AirportType type);
/**
* Checks whether the given tile is actually a tile with a hangar.
* @param tile The tile to check.
@@ -129,7 +122,7 @@ public:
* @exception AIError::ERR_FLAT_LAND_REQUIRED
* @exception AIError::ERR_LOCAL_AUTHORITY_REFUSES
* @exception AIStation::ERR_STATION_TOO_LARGE
* @exception AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION
* @exception AIStation::ERR_STATION_TOO_CLOSE_TO_OTHER_STATION
* @return Whether the airport has been/can be build or not.
*/
static bool BuildAirport(TileIndex tile, AirportType type, StationID station_id);

View File

@@ -39,7 +39,6 @@ void SQAIAirport_Register(Squirrel *engine) {
SQAIAirport.DefSQConst(engine, AIAirport::PT_INVALID, "PT_INVALID");
SQAIAirport.DefSQStaticMethod(engine, &AIAirport::IsValidAirportType, "IsValidAirportType", 2, ".i");
SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetPrice, "GetPrice", 2, ".i");
SQAIAirport.DefSQStaticMethod(engine, &AIAirport::IsHangarTile, "IsHangarTile", 2, ".i");
SQAIAirport.DefSQStaticMethod(engine, &AIAirport::IsAirportTile, "IsAirportTile", 2, ".i");
SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetAirportWidth, "GetAirportWidth", 2, ".i");

View File

@@ -32,6 +32,7 @@
static void _DoCommandReturnBuildBridge2(class AIInstance *instance)
{
if (!AIBridge::_BuildBridgeRoad2()) {
AIObject::SetLastCommandRes(false);
AIInstance::DoCommandReturn(instance);
return;
}
@@ -44,6 +45,7 @@ static void _DoCommandReturnBuildBridge2(class AIInstance *instance)
static void _DoCommandReturnBuildBridge1(class AIInstance *instance)
{
if (!AIBridge::_BuildBridgeRoad1()) {
AIObject::SetLastCommandRes(false);
AIInstance::DoCommandReturn(instance);
return;
}
@@ -65,7 +67,7 @@ static void _DoCommandReturnBuildBridge1(class AIInstance *instance)
switch (vehicle_type) {
case AIVehicle::VT_ROAD:
type |= (TRANSPORT_ROAD << 15);
type |= (::RoadTypeToRoadTypes((::RoadType)AIObject::GetRoadType()) << 8);
type |= (RoadTypeToRoadTypes((::RoadType)AIObject::GetRoadType()) << 8);
break;
case AIVehicle::VT_RAIL:
type |= (TRANSPORT_RAIL << 15);
@@ -84,7 +86,10 @@ static void _DoCommandReturnBuildBridge1(class AIInstance *instance)
AIObject::SetCallbackVariable(0, start);
AIObject::SetCallbackVariable(1, end);
return AIObject::DoCommand(end, start, type | bridge_id, CMD_BUILD_BRIDGE, NULL, &_DoCommandReturnBuildBridge1);
if (!AIObject::DoCommand(end, start, type | bridge_id, CMD_BUILD_BRIDGE, NULL, &_DoCommandReturnBuildBridge1)) return false;
/* In case of test-mode, test if we can build both road pieces */
return _BuildBridgeRoad1();
}
/* static */ bool AIBridge::_BuildBridgeRoad1()
@@ -96,7 +101,10 @@ static void _DoCommandReturnBuildBridge1(class AIInstance *instance)
DiagDirection dir_1 = (DiagDirection)((::TileX(start) == ::TileX(end)) ? (::TileY(start) < ::TileY(end) ? DIAGDIR_NW : DIAGDIR_SE) : (::TileX(start) < ::TileX(end) ? DIAGDIR_NE : DIAGDIR_SW));
DiagDirection dir_2 = ::ReverseDiagDir(dir_1);
return AIObject::DoCommand(start + ::TileOffsByDiagDir(dir_1), ::DiagDirToRoadBits(dir_2) | (AIObject::GetRoadType() << 4), 0, CMD_BUILD_ROAD, NULL, &_DoCommandReturnBuildBridge2);
if (!AIObject::DoCommand(start + ::TileOffsByDiagDir(dir_1), ::DiagDirToRoadBits(dir_2) | (AIObject::GetRoadType() << 4), 0, CMD_BUILD_ROAD, NULL, &_DoCommandReturnBuildBridge2)) return false;
/* In case of test-mode, test the other road piece too */
return _BuildBridgeRoad2();
}
/* static */ bool AIBridge::_BuildBridgeRoad2()

View File

@@ -5,7 +5,6 @@
#include "../../stdafx.h"
#include "../../string_func.h"
#include "../../company_base.h"
#include "../../rev.h"
#include "table/strings.h"
#include "../ai.hpp"
@@ -67,11 +66,6 @@ AIController::~AIController()
return AIConfig::GetConfig(_current_company)->GetSetting(name);
}
/* static */ uint AIController::GetVersion()
{
return _openttd_newgrf_version;
}
bool AIController::LoadedLibrary(const char *library_name, int *next_number, char *fake_class_name, int fake_class_name_len)
{
LoadedLibraryList::iterator iter = this->loaded_library.find(library_name);

View File

@@ -50,18 +50,6 @@ public:
*/
static int GetSetting(const char *name);
/**
* Get the OpenTTD version of this executable. The version is formatted
* with the bits having the following meaning:
* 28-31 major version
* 24-27 minor version
* 20-23 build
* 19 1 if it is a release, 0 if it is not.
* 0-18 revision number; 0 when the revision is unknown.
* @return The version in newgrf format.
*/
static uint GetVersion();
/**
* Change the minimum amount of time the AI should be put in suspend mode
* when you execute a command. Normally in SP this is 1, and in MP it is

View File

@@ -5,11 +5,10 @@
void SQAIController_Register(Squirrel *engine) {
DefSQClass <AIController> SQAIController("AIController");
SQAIController.PreRegister(engine);
SQAIController.DefSQStaticMethod(engine, &AIController::GetTick, "GetTick", 1, ".");
SQAIController.DefSQStaticMethod(engine, &AIController::SetCommandDelay, "SetCommandDelay", 2, ".i");
SQAIController.DefSQStaticMethod(engine, &AIController::Sleep, "Sleep", 2, ".i");
SQAIController.DefSQStaticMethod(engine, &AIController::GetSetting, "GetSetting", 2, ".s");
SQAIController.DefSQStaticMethod(engine, &AIController::GetVersion, "GetVersion", 1, ".");
SQAIController.DefSQStaticMethod(engine, &AIController::Print, "Print", 3, ".bs");
SQAIController.DefSQStaticMethod(engine, &AIController::GetTick, "GetTick", 1, "?");
SQAIController.DefSQStaticMethod(engine, &AIController::SetCommandDelay, "SetCommandDelay", 2, "?i");
SQAIController.DefSQStaticMethod(engine, &AIController::Sleep, "Sleep", 2, "?i");
SQAIController.DefSQStaticMethod(engine, &AIController::GetSetting, "GetSetting", 2, "?s");
SQAIController.DefSQStaticMethod(engine, &AIController::Print, "Print", 3, "?bs");
SQAIController.PostRegister(engine);
}

View File

@@ -25,7 +25,7 @@ AIDepotList::AIDepotList(AITile::TransportType transport_type)
if (st->owner == ::_current_company) {
const AirportFTAClass *afc = st->Airport();
for (uint i = 0; i < afc->nof_depots; i++) {
this->AddItem(st->airport_tile + ToTileIndexDiff(afc->airport_depots[i]));
this->AddItem(st->xy + ToTileIndexDiff(afc->airport_depots[i]));
}
}
}

View File

@@ -35,7 +35,6 @@ public:
/**
* @param vehicle The vehicle that crashed.
* @param crash_site Where the vehicle crashed.
* @param crash_reason The reason why the vehicle crashed.
*/
AIEventVehicleCrashed(VehicleID vehicle, TileIndex crash_site, CrashReason crash_reason) :
AIEvent(AI_ET_VEHICLE_CRASHED),

View File

@@ -86,9 +86,7 @@ public:
static TileIndex GetLocation(IndustryID industry_id);
/**
* Get the number of stations around an industry. All stations that can
* service the industry are counted, your own stations but also your
* opponents stations.
* Get the number of stations around an industry.
* @param industry_id The index of the industry.
* @pre IsValidIndustry(industry_id).
* @return The number of stations around an industry.

View File

@@ -32,7 +32,7 @@
log->lines = CallocT<char *>(80);
log->type = CallocT<AILog::AILogType>(80);
log->count = 80;
log->pos = log->count - 1;
log->pos = log->count;
log->used = 0;
}
LogData *log = (LogData *)AIObject::GetLogPointer();

View File

@@ -19,7 +19,7 @@ public:
#endif /* DEFINE_SCRIPT_FILES */
#ifdef DOXYGEN_SKIP
const static TileIndex TILE_INVALID; //!< Invalid TileIndex.
#endif /* DOXYGEN_SKIP */
#endif
static const char *GetClassName() { return "AIMap"; }

View File

@@ -55,13 +55,13 @@
DiagDirection to_other_tile = (TileX(t1) == TileX(t2)) ? DIAGDIR_SE : DIAGDIR_SW;
/* Determine the reachable tracks from the shared edge */
TrackBits gtts1 = ::TrackStatusToTrackBits(::GetTileTrackStatus(t1, TRANSPORT_WATER, 0, to_other_tile)) & ::DiagdirReachesTracks(to_other_tile);
if (gtts1 == TRACK_BIT_NONE) return false;
TrackBits gtts2 = ::TrackStatusToTrackBits(::GetTileTrackStatus(t2, TRANSPORT_WATER, 0, to_other_tile)) & ::DiagdirReachesTracks(to_other_tile);
if (gtts2 == TRACK_BIT_NONE) return false;
to_other_tile = ReverseDiagDir(to_other_tile);
TrackBits gtts2 = ::TrackStatusToTrackBits(::GetTileTrackStatus(t2, TRANSPORT_WATER, 0, to_other_tile)) & ::DiagdirReachesTracks(to_other_tile);
TrackBits gtts1 = ::TrackStatusToTrackBits(::GetTileTrackStatus(t1, TRANSPORT_WATER, 0, to_other_tile)) & ::DiagdirReachesTracks(to_other_tile);
return gtts2 != TRACK_BIT_NONE;
return gtts1 != TRACK_BIT_NONE;
}
/* static */ bool AIMarine::BuildWaterDepot(TileIndex tile, TileIndex front)

View File

@@ -2,11 +2,6 @@
/** @file ai_object.cpp Implementation of AIObject. */
#include "../../stdafx.h"
#include <squirrel.h>
#include "../../script/squirrel.hpp"
#include "../../company_base.h"
#include "ai_log.hpp"
#include "table/strings.h"
#include "../ai.hpp"
@@ -162,8 +157,7 @@ void AIObject::SetAllowDoCommand(bool allow)
bool AIObject::GetAllowDoCommand()
{
Squirrel *squirrel = GetCompany(_current_company)->ai_instance->engine;
return GetStorage()->allow_do_command && squirrel->CanSuspend();
return GetStorage()->allow_do_command;
}
void *&AIObject::GetEventPointer()

View File

@@ -143,24 +143,9 @@ protected:
*/
static void *&GetEventPointer();
/**
* Set the cost of the last command.
*/
static void SetLastCost(Money last_cost);
/**
* Get the cost of the last command.
*/
static Money GetLastCost();
/**
* Set a variable that can be used by callback functions to pass information.
*/
static void SetCallbackVariable(int index, int value);
/**
* Get the variable that is used by callback functions to pass information.
*/
static int GetCallbackVariable(int index);
public:

View File

@@ -23,10 +23,7 @@ static OrderType GetOrderTypeByTile(TileIndex t)
switch (::GetTileType(t)) {
default: break;
case MP_STATION:
if (IsHangar(t)) return OT_GOTO_DEPOT;
return OT_GOTO_STATION;
break;
case MP_STATION: return OT_GOTO_STATION; break;
case MP_WATER: if (::IsShipDepot(t)) return OT_GOTO_DEPOT; break;
case MP_ROAD: if (::GetRoadTileType(t) == ROAD_TILE_DEPOT) return OT_GOTO_DEPOT; break;
case MP_RAILWAY:
@@ -46,47 +43,6 @@ static OrderType GetOrderTypeByTile(TileIndex t)
return AIVehicle::IsValidVehicle(vehicle_id) && order_position >= 0 && (order_position < ::GetVehicle(vehicle_id)->GetNumOrders() || order_position == ORDER_CURRENT);
}
/**
* Get the current order the vehicle is executing. If the current order is in
* the order list, return the order from the orderlist. If the current order
* was a manual order, return the current order.
*/
static const Order *ResolveOrder(VehicleID vehicle_id, AIOrder::OrderPosition order_position)
{
const Vehicle *v = ::GetVehicle(vehicle_id);
if (order_position == AIOrder::ORDER_CURRENT) {
const Order *order = &v->current_order;
if (order->GetType() == OT_GOTO_DEPOT && !(order->GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) return order;
order_position = AIOrder::ResolveOrderPosition(vehicle_id, order_position);
if (order_position == AIOrder::ORDER_INVALID) return NULL;
}
return ::GetVehicleOrder(v, order_position);
}
/* static */ bool AIOrder::IsGotoStationOrder(VehicleID vehicle_id, OrderPosition order_position)
{
if (!IsValidVehicleOrder(vehicle_id, order_position)) return false;
const Order *order = ::ResolveOrder(vehicle_id, order_position);
return order != NULL && order->GetType() == OT_GOTO_STATION;
}
/* static */ bool AIOrder::IsGotoDepotOrder(VehicleID vehicle_id, OrderPosition order_position)
{
if (!IsValidVehicleOrder(vehicle_id, order_position)) return false;
const Order *order = ::ResolveOrder(vehicle_id, order_position);
return order != NULL && order->GetType() == OT_GOTO_DEPOT;
}
/* static */ bool AIOrder::IsGotoWaypointOrder(VehicleID vehicle_id, OrderPosition order_position)
{
if (!IsValidVehicleOrder(vehicle_id, order_position)) return false;
const Order *order = ::ResolveOrder(vehicle_id, order_position);
return order != NULL && order->GetType() == OT_GOTO_WAYPOINT;
}
/* static */ bool AIOrder::IsConditionalOrder(VehicleID vehicle_id, OrderPosition order_position)
{
if (order_position == ORDER_CURRENT) return false;
@@ -96,16 +52,6 @@ static const Order *ResolveOrder(VehicleID vehicle_id, AIOrder::OrderPosition or
return order->GetType() == OT_CONDITIONAL;
}
/* static */ bool AIOrder::IsCurrentOrderPartOfOrderList(VehicleID vehicle_id)
{
if (AIVehicle::IsValidVehicle(vehicle_id)) return false;
if (GetOrderCount(vehicle_id) == 0) return false;
const Order *order = &::GetVehicle(vehicle_id)->current_order;
if (order->GetType() != OT_GOTO_DEPOT) return true;
return (order->GetDepotOrderType() & ODTFB_PART_OF_ORDERS) != 0;
}
/* static */ AIOrder::OrderPosition AIOrder::ResolveOrderPosition(VehicleID vehicle_id, OrderPosition order_position)
{
if (!AIVehicle::IsValidVehicle(vehicle_id)) return ORDER_INVALID;
@@ -128,10 +74,7 @@ static const Order *ResolveOrder(VehicleID vehicle_id, AIOrder::OrderPosition or
(((order_flags & AIOF_NO_UNLOAD) == 0) || ((order_flags & AIOF_NO_LOAD) == 0)) &&
(((order_flags & AIOF_FULL_LOAD_ANY) == 0) || ((order_flags & AIOF_NO_LOAD) == 0));
case OT_GOTO_DEPOT:
return ((order_flags & ~(AIOF_NON_STOP_FLAGS | AIOF_DEPOT_FLAGS)) == 0) &&
(((order_flags & AIOF_SERVICE_IF_NEEDED) == 0) || ((order_flags & AIOF_STOP_IN_DEPOT) == 0));
case OT_GOTO_DEPOT: return (order_flags & ~(AIOF_NON_STOP_FLAGS | AIOF_SERVICE_IF_NEEDED)) == 0;
case OT_GOTO_WAYPOINT: return (order_flags & ~(AIOF_NON_STOP_FLAGS)) == 0;
default: return false;
}
@@ -165,41 +108,21 @@ static const Order *ResolveOrder(VehicleID vehicle_id, AIOrder::OrderPosition or
{
if (!IsValidVehicleOrder(vehicle_id, order_position)) return INVALID_TILE;
const Order *order = ::ResolveOrder(vehicle_id, order_position);
if (order == NULL || order->GetType() == OT_CONDITIONAL) return INVALID_TILE;
const Order *order;
const Vehicle *v = ::GetVehicle(vehicle_id);
if (order_position == ORDER_CURRENT) {
order = &v->current_order;
} else {
order = ::GetVehicleOrder(GetVehicle(vehicle_id), order_position);
if (order->GetType() == OT_CONDITIONAL) return INVALID_TILE;
}
switch (order->GetType()) {
case OT_GOTO_DEPOT: {
case OT_GOTO_DEPOT:
if (v->type != VEH_AIRCRAFT) return ::GetDepot(order->GetDestination())->xy;
/* Aircraft's hangars are referenced by StationID, not DepotID */
const Station *st = ::GetStation(order->GetDestination());
const AirportFTAClass *airport = st->Airport();
if (airport == NULL || airport->nof_depots == 0) return INVALID_TILE;
return st->airport_tile + ::ToTileIndexDiff(st->Airport()->airport_depots[0]);
}
/* FALL THROUGH: aircraft's hangars are referenced by StationID, not DepotID */
case OT_GOTO_STATION: {
const Station *st = ::GetStation(order->GetDestination());
if (st->train_tile != INVALID_TILE) {
for (uint i = 0; i < st->trainst_w; i++) {
TileIndex t = st->train_tile + TileDiffXY(i, 0);
if (st->TileBelongsToRailStation(t)) return t;
}
} else if (st->dock_tile != INVALID_TILE) {
return st->dock_tile;
} else if (st->bus_stops != NULL) {
return st->bus_stops->xy;
} else if (st->truck_stops != NULL) {
return st->truck_stops->xy;
} else if (st->airport_tile != INVALID_TILE) {
const AirportFTAClass *fta = st->Airport();
BEGIN_TILE_LOOP(tile, fta->size_x, fta->size_y, st->airport_tile) {
if (!::IsHangar(tile)) return tile;
} END_TILE_LOOP(tile, fta->size_x, fta->size_y, st->airport_tile)
}
return INVALID_TILE;
}
case OT_GOTO_STATION: return ::GetStation(order->GetDestination())->xy;
case OT_GOTO_WAYPOINT: return ::GetWaypoint(order->GetDestination())->xy;
default: return INVALID_TILE;
}
@@ -209,15 +132,19 @@ static const Order *ResolveOrder(VehicleID vehicle_id, AIOrder::OrderPosition or
{
if (!IsValidVehicleOrder(vehicle_id, order_position)) return AIOF_INVALID;
const Order *order = ::ResolveOrder(vehicle_id, order_position);
if (order == NULL || order->GetType() == OT_CONDITIONAL) return AIOF_INVALID;
const Order *order;
if (order_position == ORDER_CURRENT) {
order = &::GetVehicle(vehicle_id)->current_order;
} else {
order = ::GetVehicleOrder(GetVehicle(vehicle_id), order_position);
if (order->GetType() == OT_CONDITIONAL) return AIOF_INVALID;
}
AIOrderFlags order_flags = AIOF_NONE;
order_flags |= (AIOrderFlags)order->GetNonStopType();
switch (order->GetType()) {
case OT_GOTO_DEPOT:
if (order->GetDepotOrderType() & ODTFB_SERVICE) order_flags |= AIOF_SERVICE_IF_NEEDED;
if (order->GetDepotActionType() & ODATFB_HALT) order_flags |= AIOF_STOP_IN_DEPOT;
break;
case OT_GOTO_STATION:
@@ -333,21 +260,9 @@ static const Order *ResolveOrder(VehicleID vehicle_id, AIOrder::OrderPosition or
Order order;
switch (::GetOrderTypeByTile(destination)) {
case OT_GOTO_DEPOT: {
OrderDepotTypeFlags odtf = (OrderDepotTypeFlags)(ODTFB_PART_OF_ORDERS | ((order_flags & AIOF_SERVICE_IF_NEEDED) ? ODTFB_SERVICE : 0));
OrderDepotActionFlags odaf = (OrderDepotActionFlags)(ODATF_SERVICE_ONLY | ((order_flags & AIOF_STOP_IN_DEPOT) ? ODATFB_HALT : 0));
OrderNonStopFlags onsf = (OrderNonStopFlags)((order_flags & AIOF_NON_STOP_INTERMEDIATE) ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
/* Check explicitly if the order is to a station (for aircraft) or
* to a depot (other vehicle types). */
if (::GetVehicle(vehicle_id)->type == VEH_AIRCRAFT) {
if (!::IsTileType(destination, MP_STATION)) return false;
order.MakeGoToDepot(::GetStationIndex(destination), odtf, onsf, odaf);
} else {
if (::IsTileType(destination, MP_STATION)) return false;
order.MakeGoToDepot(::GetDepotByTile(destination)->index, odtf, onsf, odaf);
}
case OT_GOTO_DEPOT:
order.MakeGoToDepot(::GetDepotByTile(destination)->index, (OrderDepotTypeFlags)(ODTFB_PART_OF_ORDERS | ((order_flags & AIOF_SERVICE_IF_NEEDED) ? ODTFB_SERVICE : 0)));
break;
}
case OT_GOTO_STATION:
order.MakeGoToStation(::GetStationIndex(destination));
@@ -441,11 +356,8 @@ static void _DoCommandReturnSetOrderFlags(class AIInstance *instance)
switch (order->GetType()) {
case OT_GOTO_DEPOT:
if ((current & AIOF_DEPOT_FLAGS) != (order_flags & AIOF_DEPOT_FLAGS)) {
uint data = DA_ALWAYS_GO;
if (order_flags & AIOF_SERVICE_IF_NEEDED) data = DA_SERVICE;
if (order_flags & AIOF_STOP_IN_DEPOT) data = DA_STOP;
return AIObject::DoCommand(0, vehicle_id | (order_position << 16), (data << 4) | MOF_DEPOT_ACTION, CMD_MODIFY_ORDER, NULL, &_DoCommandReturnSetOrderFlags);
if ((current & AIOF_SERVICE_IF_NEEDED) != (order_flags & AIOF_SERVICE_IF_NEEDED)) {
return AIObject::DoCommand(0, vehicle_id | (order_position << 16), MOF_DEPOT_ACTION, CMD_MODIFY_ORDER, NULL, &_DoCommandReturnSetOrderFlags);
}
break;

View File

@@ -57,8 +57,6 @@ public:
/** Service the vehicle when needed, otherwise skip this order; only for depots. */
AIOF_SERVICE_IF_NEEDED = 1 << 2,
/** Stop in the depot instead of only go there for servicing; only for depots. */
AIOF_STOP_IN_DEPOT = 1 << 3,
/** All flags related to non-stop settings. */
AIOF_NON_STOP_FLAGS = AIOF_NON_STOP_INTERMEDIATE | AIOF_NON_STOP_DESTINATION,
@@ -66,8 +64,6 @@ public:
AIOF_UNLOAD_FLAGS = AIOF_TRANSFER | AIOF_UNLOAD | AIOF_NO_UNLOAD,
/** All flags related to loading. */
AIOF_LOAD_FLAGS = AIOF_FULL_LOAD | AIOF_FULL_LOAD_ANY | AIOF_NO_LOAD,
/** All flags related to depots. */
AIOF_DEPOT_FLAGS = AIOF_SERVICE_IF_NEEDED | AIOF_STOP_IN_DEPOT,
/** For marking invalid order flags */
AIOF_INVALID = 0xFFFF,
@@ -118,33 +114,6 @@ public:
*/
static bool IsValidVehicleOrder(VehicleID vehicle_id, OrderPosition order_position);
/**
* Checks whether the given order is a goto-station order.
* @param vehicle_id The vehicle to check.
* @param order_position The order index to check.
* @pre IsValidVehicleOrder(vehicle_id, order_position).
* @return True if and only if the order is a goto-station order.
*/
static bool IsGotoStationOrder(VehicleID vehicle_id, OrderPosition order_position);
/**
* Checks whether the given order is a goto-depot order.
* @param vehicle_id The vehicle to check.
* @param order_position The order index to check.
* @pre IsValidVehicleOrder(vehicle_id, order_position).
* @return True if and only if the order is a goto-depot order.
*/
static bool IsGotoDepotOrder(VehicleID vehicle_id, OrderPosition order_position);
/**
* Checks whether the given order is a goto-waypoint order.
* @param vehicle_id The vehicle to check.
* @param order_position The order index to check.
* @pre IsValidVehicleOrder(vehicle_id, order_position).
* @return True if and only if the order is a goto-waypoint order.
*/
static bool IsGotoWaypointOrder(VehicleID vehicle_id, OrderPosition order_position);
/**
* Checks whether the given order is a conditional order.
* @param vehicle_id The vehicle to check.
@@ -154,17 +123,6 @@ public:
*/
static bool IsConditionalOrder(VehicleID vehicle_id, OrderPosition order_position);
/**
* Checks whether the current order is part of the orderlist.
* @param vehicle_id The vehicle to check.
* @pre AIVehicle::IsValidVehicle(vehicle_id).
* @return True if and only if the current order is part of the order list.
* @note If the order is a non-'non-stop' order, and the vehicle is currently
* (un)loading at a station that is not the final destination, this function
* will still return true.
*/
static bool IsCurrentOrderPartOfOrderList(VehicleID vehicle_id);
/**
* Resolves the given order index to the correct index for the given vehicle.
* If the order index was ORDER_CURRENT it will be resolved to the index of
@@ -288,10 +246,8 @@ public:
* Sets the OrderCondition of the given order for the given vehicle.
* @param vehicle_id The vehicle to set the condition type for.
* @param order_position The order to set the condition type for.
* @param condition The condition to compare on.
* @pre IsValidVehicleOrder(vehicle_id, order_position).
* @pre order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position).
* @pre condition >= OC_LOAD_PERCENTAGE && condition <= OC_UNCONDITIONALLY.
* @return Whether the order has been/can be changed.
*/
static bool SetOrderCondition(VehicleID vehicle_id, OrderPosition order_position, OrderCondition condition);
@@ -300,10 +256,8 @@ public:
* Sets the CompareFunction of the given order for the given vehicle.
* @param vehicle_id The vehicle to set the compare function for.
* @param order_position The order to set the compare function for.
* @param compare The new compare function of the order.
* @pre IsValidVehicleOrder(vehicle_id, order_position).
* @pre order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position).
* @pre compare >= CF_EQUALS && compare <= CF_IS_FALSE.
* @return Whether the order has been/can be changed.
*/
static bool SetOrderCompareFunction(VehicleID vehicle_id, OrderPosition order_position, CompareFunction compare);
@@ -312,7 +266,6 @@ public:
* Sets the value to compare against of the given order for the given vehicle.
* @param vehicle_id The vehicle to set the value for.
* @param order_position The order to set the value for.
* @param value The value to compare against.
* @pre IsValidVehicleOrder(vehicle_id, order_position).
* @pre order_position != ORDER_CURRENT && IsConditionalOrder(vehicle_id, order_position).
* @pre value >= 0 && value < 2048.
@@ -328,7 +281,7 @@ public:
* @pre AIVehicle::IsValidVehicle(vehicle_id).
* @pre AreOrderFlagsValid(destination, order_flags).
* @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY
* @exception AIOrder::ERR_ORDER_TOO_MANY
* @exception AIOrder::ERR_ORDER_NO_MORE_SPACE
* @exception AIOrder::ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION
* @return True if and only if the order was appended.
*/
@@ -341,7 +294,7 @@ public:
* @pre AIVehicle::IsValidVehicle(vehicle_id).
* @pre IsValidVehicleOrder(vehicle_id, jump_to).
* @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY
* @exception AIOrder::ERR_ORDER_TOO_MANY
* @exception AIOrder::ERR_ORDER_NO_MORE_SPACE
* @return True if and only if the order was appended.
*/
static bool AppendConditionalOrder(VehicleID vehicle_id, OrderPosition jump_to);
@@ -355,7 +308,7 @@ public:
* @pre IsValidVehicleOrder(vehicle_id, order_position).
* @pre AreOrderFlagsValid(destination, order_flags).
* @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY
* @exception AIOrder::ERR_ORDER_TOO_MANY
* @exception AIOrder::ERR_ORDER_NO_MORE_SPACE
* @exception AIOrder::ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION
* @return True if and only if the order was inserted.
*/
@@ -369,7 +322,7 @@ public:
* @pre IsValidVehicleOrder(vehicle_id, order_position).
* @pre IsValidVehicleOrder(vehicle_id, jump_to).
* @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY
* @exception AIOrder::ERR_ORDER_TOO_MANY
* @exception AIOrder::ERR_ORDER_NO_MORE_SPACE
* @return True if and only if the order was inserted.
*/
static bool InsertConditionalOrder(VehicleID vehicle_id, OrderPosition order_position, OrderPosition jump_to);
@@ -442,7 +395,7 @@ public:
* @pre AIVehicle::IsValidVehicle(vehicle_id).
* @pre AIVehicle::IsValidVehicle(main_vehicle_id).
* @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY
* @exception AIOrder::ERR_ORDER_TOO_MANY
* @exception AIOrder::ERR_ORDER_NO_MORE_SPACE
* @return True if and only if the copying succeeded.
*/
static bool CopyOrders(VehicleID vehicle_id, VehicleID main_vehicle_id);

View File

@@ -42,11 +42,9 @@ void SQAIOrder_Register(Squirrel *engine) {
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_FULL_LOAD_ANY, "AIOF_FULL_LOAD_ANY");
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_NO_LOAD, "AIOF_NO_LOAD");
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_SERVICE_IF_NEEDED, "AIOF_SERVICE_IF_NEEDED");
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_STOP_IN_DEPOT, "AIOF_STOP_IN_DEPOT");
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_NON_STOP_FLAGS, "AIOF_NON_STOP_FLAGS");
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_UNLOAD_FLAGS, "AIOF_UNLOAD_FLAGS");
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_LOAD_FLAGS, "AIOF_LOAD_FLAGS");
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_DEPOT_FLAGS, "AIOF_DEPOT_FLAGS");
SQAIOrder.DefSQConst(engine, AIOrder::AIOF_INVALID, "AIOF_INVALID");
SQAIOrder.DefSQConst(engine, AIOrder::OC_LOAD_PERCENTAGE, "OC_LOAD_PERCENTAGE");
SQAIOrder.DefSQConst(engine, AIOrder::OC_RELIABILITY, "OC_RELIABILITY");
@@ -73,38 +71,34 @@ void SQAIOrder_Register(Squirrel *engine) {
AIError::RegisterErrorMapString(AIOrder::ERR_ORDER_TOO_MANY, "ERR_ORDER_TOO_MANY");
AIError::RegisterErrorMapString(AIOrder::ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION, "ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::IsValidVehicleOrder, "IsValidVehicleOrder", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::IsGotoStationOrder, "IsGotoStationOrder", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::IsGotoDepotOrder, "IsGotoDepotOrder", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::IsGotoWaypointOrder, "IsGotoWaypointOrder", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::IsConditionalOrder, "IsConditionalOrder", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::IsCurrentOrderPartOfOrderList, "IsCurrentOrderPartOfOrderList", 2, ".i");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::ResolveOrderPosition, "ResolveOrderPosition", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::AreOrderFlagsValid, "AreOrderFlagsValid", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::IsValidConditionalOrder, "IsValidConditionalOrder", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderCount, "GetOrderCount", 2, ".i");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderDestination, "GetOrderDestination", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderFlags, "GetOrderFlags", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderJumpTo, "GetOrderJumpTo", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderCondition, "GetOrderCondition", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderCompareFunction, "GetOrderCompareFunction", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderCompareValue, "GetOrderCompareValue", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::SetOrderJumpTo, "SetOrderJumpTo", 4, ".iii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::SetOrderCondition, "SetOrderCondition", 4, ".iii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::SetOrderCompareFunction, "SetOrderCompareFunction", 4, ".iii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::SetOrderCompareValue, "SetOrderCompareValue", 4, ".iii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::AppendOrder, "AppendOrder", 4, ".iii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::AppendConditionalOrder, "AppendConditionalOrder", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::InsertOrder, "InsertOrder", 5, ".iiii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::InsertConditionalOrder, "InsertConditionalOrder", 4, ".iii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::RemoveOrder, "RemoveOrder", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::SetOrderFlags, "SetOrderFlags", 4, ".iii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::ChangeOrder, "ChangeOrder", 4, ".iii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::MoveOrder, "MoveOrder", 4, ".iii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::SkipToOrder, "SkipToOrder", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::CopyOrders, "CopyOrders", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::ShareOrders, "ShareOrders", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::UnshareOrders, "UnshareOrders", 2, ".i");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::IsValidVehicleOrder, "IsValidVehicleOrder", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::IsConditionalOrder, "IsConditionalOrder", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::ResolveOrderPosition, "ResolveOrderPosition", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::AreOrderFlagsValid, "AreOrderFlagsValid", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::IsValidConditionalOrder, "IsValidConditionalOrder", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderCount, "GetOrderCount", 2, ".i");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderDestination, "GetOrderDestination", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderFlags, "GetOrderFlags", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderJumpTo, "GetOrderJumpTo", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderCondition, "GetOrderCondition", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderCompareFunction, "GetOrderCompareFunction", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderCompareValue, "GetOrderCompareValue", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::SetOrderJumpTo, "SetOrderJumpTo", 4, ".iii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::SetOrderCondition, "SetOrderCondition", 4, ".iii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::SetOrderCompareFunction, "SetOrderCompareFunction", 4, ".iii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::SetOrderCompareValue, "SetOrderCompareValue", 4, ".iii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::AppendOrder, "AppendOrder", 4, ".iii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::AppendConditionalOrder, "AppendConditionalOrder", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::InsertOrder, "InsertOrder", 5, ".iiii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::InsertConditionalOrder, "InsertConditionalOrder", 4, ".iii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::RemoveOrder, "RemoveOrder", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::SetOrderFlags, "SetOrderFlags", 4, ".iii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::ChangeOrder, "ChangeOrder", 4, ".iii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::MoveOrder, "MoveOrder", 4, ".iii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::SkipToOrder, "SkipToOrder", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::CopyOrders, "CopyOrders", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::ShareOrders, "ShareOrders", 3, ".ii");
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::UnshareOrders, "UnshareOrders", 2, ".i");
SQAIOrder.PostRegister(engine);
}

View File

@@ -110,7 +110,7 @@
{
if (!IsRailStationTile(tile)) return RAILTRACK_INVALID;
return (RailTrack)::GetRailStationTrackBits(tile);
return (RailTrack)::GetRailStationTrack(tile);
}
/* static */ bool AIRail::BuildRailDepot(TileIndex tile, TileIndex front)
@@ -203,7 +203,6 @@
if (IsRailWaypointTile(tile)) return ::GetRailWaypointBits(tile);
if (IsRailStationTile(tile)) return ::TrackToTrackBits(::GetRailStationTrack(tile));
if (IsLevelCrossingTile(tile)) return ::GetCrossingRailBits(tile);
if (IsRailDepotTile(tile)) return ::TRACK_BIT_NONE;
return ::GetTrackBits(tile);
}

View File

@@ -293,7 +293,6 @@ public:
/**
* Get all RailTracks on the given tile.
* @note A depot has no railtracks.
* @param tile The tile to check.
* @pre IsRailTile(tile).
* @return A bitmask of RailTrack with all RailTracks on the tile.

View File

@@ -349,7 +349,7 @@ public:
* @exception AIError::ERR_FLAT_LAND_REQUIRED
* @exception AIRoad::ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION
* @exception AIRoad::ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD
* @exception AIError::ERR_VEHICLE_IN_THE_WAY
* @exception AIError:ERR_VEHICLE_IN_THE_WAY
* @exception AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION
* @exception AIStation::ERR_STATION_TOO_MANY_STATIONS
* @exception AIStation::ERR_STATION_TOO_MANY_STATIONS_IN_TOWN
@@ -372,7 +372,7 @@ public:
* @exception AIError::ERR_FLAT_LAND_REQUIRED
* @exception AIRoad::ERR_ROAD_DRIVE_THROUGH_WRONG_DIRECTION
* @exception AIRoad::ERR_ROAD_CANNOT_BUILD_ON_TOWN_ROAD
* @exception AIError::ERR_VEHICLE_IN_THE_WAY
* @exception AIError:ERR_VEHICLE_IN_THE_WAY
* @exception AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION
* @exception AIStation::ERR_STATION_TOO_MANY_STATIONS
* @exception AIStation::ERR_STATION_TOO_MANY_STATIONS_IN_TOWN

View File

@@ -30,7 +30,6 @@ public:
/**
* Gets the maximum sign index; there are no valid signs with a higher index.
* @deprecated This function is deprecated and might be removed in future versions of the API. Use AISignList() instead.
* @return The maximum sign index.
* @post Return value is always non-negative.
*/

View File

@@ -1,15 +0,0 @@
/* $Id$ */
/** @file ai_signlist.cpp Implementation of AISignList and friends. */
#include "ai_signlist.hpp"
#include "ai_sign.hpp"
#include "../../signs_base.h"
AISignList::AISignList()
{
Sign *s;
FOR_ALL_SIGNS(s) {
if (AISign::IsValidSign(s->index)) this->AddItem(s->index);
}
}

View File

@@ -1,20 +0,0 @@
/* $Id$ */
/** @file ai_signlist.hpp List all the signs of your company. */
#ifndef AI_SIGNLIST_HPP
#define AI_SIGNLIST_HPP
#include "ai_abstractlist.hpp"
/**
* Create a list of signs your company has created.
* @ingroup AIList
*/
class AISignList : public AIAbstractList {
public:
static const char *GetClassName() { return "AISignList"; }
AISignList();
};
#endif /* AI_SIGNLIST_HPP */

View File

@@ -1,21 +0,0 @@
/* $Id$ */
/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */
#include "ai_signlist.hpp"
namespace SQConvert {
/* Allow AISignList to be used as Squirrel parameter */
template <> AISignList *GetParam(ForceType<AISignList *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AISignList *)instance; }
template <> AISignList &GetParam(ForceType<AISignList &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AISignList *)instance; }
template <> const AISignList *GetParam(ForceType<const AISignList *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AISignList *)instance; }
template <> const AISignList &GetParam(ForceType<const AISignList &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AISignList *)instance; }
template <> int Return<AISignList *>(HSQUIRRELVM vm, AISignList *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AISignList", res, NULL, DefSQDestructorCallback<AISignList>); return 1; }
}; // namespace SQConvert
void SQAISignList_Register(Squirrel *engine) {
DefSQClass <AISignList> SQAISignList("AISignList");
SQAISignList.PreRegister(engine, "AIAbstractList");
SQAISignList.AddConstructor<void (AISignList::*)(), 1>(engine, "x");
SQAISignList.PostRegister(engine);
}

View File

@@ -17,8 +17,7 @@
/* static */ bool AIStation::IsValidStation(StationID station_id)
{
const Station *st = ::IsValidStationID(station_id) ? GetStation(station_id) : NULL;
return st != NULL && (st->owner == _current_company || st->owner == OWNER_NONE);
return ::IsValidStationID(station_id) && ::GetStation(station_id)->owner == _current_company;
}
/* static */ StationID AIStation::GetStationID(TileIndex tile)

View File

@@ -49,10 +49,6 @@ public:
STATION_ANY = 0x1F, //!< All station types
};
/**
* Special station IDs for building adjacent/new stations when
* the adjacent/distant join features are enabled.
*/
enum SpecialStationIDs {
STATION_NEW = 0xFFFD, //!< Build a new station
STATION_JOIN_ADJACENT = 0xFFFE, //!< Join an neighbouring station if one exists

View File

@@ -11,7 +11,6 @@
#include "../../water_map.h"
#include "../../clear_map.h"
#include "../../town.h"
#include "../../landscape.h"
/* static */ bool AITile::IsBuildable(TileIndex tile)
{
@@ -73,14 +72,14 @@
/* static */ bool AITile::IsSteepSlope(Slope slope)
{
if ((slope & ~(SLOPE_ELEVATED | SLOPE_STEEP | SLOPE_HALFTILE_MASK)) != 0) return false;
if (slope == SLOPE_INVALID) return false;
return ::IsSteepSlope((::Slope)slope);
}
/* static */ bool AITile::IsHalftileSlope(Slope slope)
{
if ((slope & ~(SLOPE_ELEVATED | SLOPE_STEEP | SLOPE_HALFTILE_MASK)) != 0) return false;
if (slope == SLOPE_INVALID) return false;
return ::IsHalftileSlope((::Slope)slope);
}
@@ -124,41 +123,20 @@
/* static */ AITile::Slope AITile::GetComplementSlope(Slope slope)
{
if ((slope & ~SLOPE_ELEVATED) != 0) return SLOPE_INVALID;
if (slope == SLOPE_INVALID) return SLOPE_INVALID;
if (IsSteepSlope(slope)) return SLOPE_INVALID;
if (IsHalftileSlope(slope)) return SLOPE_INVALID;
return (Slope)::ComplementSlope((::Slope)slope);
}
/* static */ int32 AITile::GetHeight(TileIndex tile)
{
if (!::IsValidTile(tile)) return -1;
if (!::IsValidTile(tile)) return false;
return ::TileHeight(tile);
}
/* static */ int32 AITile::GetMinHeight(TileIndex tile)
{
if (!::IsValidTile(tile)) return -1;
return ::GetTileZ(tile) / ::TILE_HEIGHT;
}
/* static */ int32 AITile::GetMaxHeight(TileIndex tile)
{
if (!::IsValidTile(tile)) return -1;
return ::GetTileMaxZ(tile) / ::TILE_HEIGHT;
}
/* static */ int32 AITile::GetCornerHeight(TileIndex tile, Corner corner)
{
if (!::IsValidTile(tile) || !::IsValidCorner((::Corner)corner)) return -1;
uint z;
::Slope slope = ::GetTileSlope(tile, &z);
return (z + ::GetSlopeZInCorner(slope, (::Corner)corner)) / ::TILE_HEIGHT;
}
/* static */ AICompany::CompanyID AITile::GetOwner(TileIndex tile)
{
if (!::IsValidTile(tile)) return AICompany::COMPANY_INVALID;
@@ -175,21 +153,21 @@
return ::TrackStatusToTrackdirBits(::GetTileTrackStatus(tile, (::TransportType)transport_type, UINT32_MAX)) != TRACKDIR_BIT_NONE;
}
/* static */ int32 AITile::GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius)
/* static */ int32 AITile::GetCargoAcceptance(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius)
{
if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius < 0) return -1;
if (!::IsValidTile(tile)) return false;
AcceptedCargo accepts;
::GetAcceptanceAroundTiles(accepts, tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED);
::GetAcceptanceAroundTiles(accepts, tile, width, height, _settings_game.station.modified_catchment ? radius : (uint)CA_UNMODIFIED);
return accepts[cargo_type];
}
/* static */ int32 AITile::GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius)
/* static */ int32 AITile::GetCargoProduction(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius)
{
if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius < 0) return -1;
if (!::IsValidTile(tile)) return false;
AcceptedCargo produced;
::GetProductionAroundTiles(produced, tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED);
::GetProductionAroundTiles(produced, tile, width, height, _settings_game.station.modified_catchment ? radius : (uint)CA_UNMODIFIED);
return produced[cargo_type];
}

View File

@@ -29,28 +29,10 @@ public:
/** Tile can't be lowered any lower */
ERR_TILE_TOO_LOW, // [STR_1003_ALREADY_AT_SEA_LEVEL]
/** The area was already flat */
ERR_AREA_ALREADY_FLAT, // [STR_ALREADY_LEVELLED]
/** There is a tunnel underneed */
ERR_EXCAVATION_WOULD_DAMAGE, // [STR_1002_EXCAVATION_WOULD_DAMAGE]
};
/**
* Enumeration for corners of tiles.
*/
enum Corner {
CORNER_W = 0, //!< West corner
CORNER_S = 1, //!< South corner
CORNER_E = 2, //!< East corner
CORNER_N = 3, //!< North corner
CORNER_INVALID = 0xFF,
};
/**
* Enumeration for the slope-type.
* Enumeration for the slope-type (from slopes.h).
*
* This enumeration use the chars N, E, S, W corresponding the
* direction North, East, South and West. The top corner of a tile
@@ -59,18 +41,18 @@ public:
enum Slope {
/* Values are important, as they represent the internal state of the game. */
SLOPE_FLAT = 0x00, //!< A flat tile
SLOPE_W = 1 << CORNER_W, //!< The west corner of the tile is raised
SLOPE_S = 1 << CORNER_S, //!< The south corner of the tile is raised
SLOPE_E = 1 << CORNER_E, //!< The east corner of the tile is raised
SLOPE_N = 1 << CORNER_N, //!< The north corner of the tile is raised
SLOPE_STEEP = 0x10, //!< Indicates the slope is steep (The corner opposite of the not-raised corner is raised two times)
SLOPE_W = 0x01, //!< The west corner of the tile is raised
SLOPE_S = 0x02, //!< The south corner of the tile is raised
SLOPE_E = 0x04, //!< The east corner of the tile is raised
SLOPE_N = 0x08, //!< The north corner of the tile is raised
SLOPE_STEEP = 0x10, //!< Indicates the slope is steep
SLOPE_NW = SLOPE_N | SLOPE_W, //!< North and west corner are raised
SLOPE_SW = SLOPE_S | SLOPE_W, //!< South and west corner are raised
SLOPE_SE = SLOPE_S | SLOPE_E, //!< South and east corner are raised
SLOPE_NE = SLOPE_N | SLOPE_E, //!< North and east corner are raised
SLOPE_EW = SLOPE_E | SLOPE_W, //!< East and west corner are raised
SLOPE_NS = SLOPE_N | SLOPE_S, //!< North and south corner are raised
SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W, //!< Bit mask containing all 'simple' slopes. Does not appear as a slope.
SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W, //!< All corner are raised, similar to SLOPE_FLAT
SLOPE_NWS = SLOPE_N | SLOPE_W | SLOPE_S, //!< North, west and south corner are raised
SLOPE_WSE = SLOPE_W | SLOPE_S | SLOPE_E, //!< West, south and east corner are raised
SLOPE_SEN = SLOPE_S | SLOPE_E | SLOPE_N, //!< South, east and north corner are raised
@@ -80,7 +62,7 @@ public:
SLOPE_STEEP_E = SLOPE_STEEP | SLOPE_SEN, //!< A steep slope falling to west (from east)
SLOPE_STEEP_N = SLOPE_STEEP | SLOPE_ENW, //!< A steep slope falling to south (from north)
SLOPE_INVALID = 0xFFFF, //!< An invalid slope
SLOPE_INVALID = 0xFF, //!< An invalid slope
};
/**
@@ -147,7 +129,6 @@ public:
/**
* Check if a tile has a steep slope.
* Steep slopes are slopes with a height difference of 2 across one diagonal of the tile.
* @param slope The slope to check on.
* @pre slope != SLOPE_INVALID.
* @return True if the slope is a steep slope.
@@ -156,11 +137,9 @@ public:
/**
* Check if a tile has a halftile slope.
* Halftile slopes appear on top of halftile foundations. E.g. the slope you get when building a horizontal railtrack on the top of a SLOPE_N or SLOPE_STEEP_N.
* @param slope The slope to check on.
* @pre slope != SLOPE_INVALID.
* @return True if the slope is a halftile slope.
* @note Currently there is no API function that would return or accept a halftile slope.
*/
static bool IsHalftileSlope(Slope slope);
@@ -214,10 +193,9 @@ public:
/**
* Get the slope of a tile.
* This is the slope of the bare tile. A possible foundation on the tile does not influence this slope.
* @param tile The tile to check on.
* @pre AIMap::IsValidTile(tile).
* @return Bit mask encoding the slope. See #Slope for a description of the returned values.
* @return 0 means flat, others indicate internal state of slope.
*/
static Slope GetSlope(TileIndex tile);
@@ -233,43 +211,13 @@ public:
static Slope GetComplementSlope(Slope slope);
/**
* Get the height of the north corner of a tile.
* The returned height is the height of the bare tile. A possible foundation on the tile does not influence this height.
* @deprecated This function is deprecated and might be removed in future versions of the API. Use GetMinHeight(), GetMaxHeight() or GetCornerHeight() instead.
* Get the height of the tile.
* @param tile The tile to check on.
* @pre AIMap::IsValidTile(tile).
* @return The height of the north corner of the tile, ranging from 0 to 15.
* @return The height of the tile, ranging from 0 to 15.
*/
static int32 GetHeight(TileIndex tile);
/**
* Get the minimal height on a tile.
* The returned height is the height of the bare tile. A possible foundation on the tile does not influence this height.
* @param tile The tile to check on.
* @pre AIMap::IsValidTile(tile).
* @return The height of the lowest corner of the tile, ranging from 0 to 15.
*/
static int32 GetMinHeight(TileIndex tile);
/**
* Get the maximal height on a tile.
* The returned height is the height of the bare tile. A possible foundation on the tile does not influence this height.
* @param tile The tile to check on.
* @pre AIMap::IsValidTile(tile).
* @return The height of the highest corner of the tile, ranging from 0 to 15.
*/
static int32 GetMaxHeight(TileIndex tile);
/**
* Get the height of a certain corner of a tile.
* The returned height is the height of the bare tile. A possible foundation on the tile does not influence this height.
* @param tile The tile to check on.
* @param corner The corner to query.
* @pre AIMap::IsValidTile(tile).
* @return The height of the lowest corner of the tile, ranging from 0 to 15.
*/
static int32 GetCornerHeight(TileIndex tile, Corner corner);
/**
* Get the owner of the tile.
* @param tile The tile to get the owner from.
@@ -303,12 +251,9 @@ public:
* @param height The height of the station.
* @param radius The radius of the station.
* @pre AIMap::IsValidTile(tile).
* @pre width > 0.
* @pre height > 0.
* @pre radius >= 0.
* @return Value below 8 means no acceptance; the more the better.
*/
static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius);
/**
* Checks how many tiles in the radius produces this cargo.
@@ -320,13 +265,10 @@ public:
* @param height The height of the station.
* @param radius The radius of the station.
* @pre AIMap::IsValidTile(tile).
* @pre width > 0.
* @pre height > 0.
* @pre radius >= 0.
* @return The tiles that produce this cargo within radius of the tile.
* @note Town(houses) are not included in the value.
*/
static int32 GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
static int32 GetCargoProduction(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius);
/**
* Get the manhattan distance from the tile to the tile.
@@ -346,10 +288,7 @@ public:
/**
* Raise the given corners of the tile. The corners can be combined,
* for example: SLOPE_N | SLOPE_W (= SLOPE_NW) will raise the west and the north corner.
* @note The corners will be modified in the order west (first), south, east, north (last).
* Changing one corner might cause another corner to be changed too. So modifiing
* multiple corners may result in changing some corners by multiple steps.
* for example: SLOPE_N | SLOPE_W (= SLOPE_NW)
* @param tile The tile to raise.
* @param slope Corners to raise (SLOPE_xxx).
* @pre tile < AIMap::GetMapSize().
@@ -362,10 +301,7 @@ public:
/**
* Lower the given corners of the tile. The corners can be combined,
* for example: SLOPE_N | SLOPE_W (= SLOPE_NW) will lower the west and the north corner.
* @note The corners will be modified in the order west (first), south, east, north (last).
* Changing one corner might cause another corner to be changed too. So modifiing
* multiple corners may result in changing some corners by multiple steps.
* for example: SLOPE_N | SLOPE_W (= SLOPE_NW)
* @param tile The tile to lower.
* @param slope Corners to lower (SLOPE_xxx).
* @pre tile < AIMap::GetMapSize().

View File

@@ -7,8 +7,6 @@ namespace SQConvert {
/* Allow enums to be used as Squirrel parameters */
template <> AITile::ErrorMessages GetParam(ForceType<AITile::ErrorMessages>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AITile::ErrorMessages)tmp; }
template <> int Return<AITile::ErrorMessages>(HSQUIRRELVM vm, AITile::ErrorMessages res) { sq_pushinteger(vm, (int32)res); return 1; }
template <> AITile::Corner GetParam(ForceType<AITile::Corner>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AITile::Corner)tmp; }
template <> int Return<AITile::Corner>(HSQUIRRELVM vm, AITile::Corner res) { sq_pushinteger(vm, (int32)res); return 1; }
template <> AITile::Slope GetParam(ForceType<AITile::Slope>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AITile::Slope)tmp; }
template <> int Return<AITile::Slope>(HSQUIRRELVM vm, AITile::Slope res) { sq_pushinteger(vm, (int32)res); return 1; }
template <> AITile::TransportType GetParam(ForceType<AITile::TransportType>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AITile::TransportType)tmp; }
@@ -27,53 +25,42 @@ void SQAITile_Register(Squirrel *engine) {
SQAITile.PreRegister(engine);
SQAITile.AddConstructor<void (AITile::*)(), 1>(engine, "x");
SQAITile.DefSQConst(engine, AITile::ERR_TILE_BASE, "ERR_TILE_BASE");
SQAITile.DefSQConst(engine, AITile::ERR_TILE_TOO_HIGH, "ERR_TILE_TOO_HIGH");
SQAITile.DefSQConst(engine, AITile::ERR_TILE_TOO_LOW, "ERR_TILE_TOO_LOW");
SQAITile.DefSQConst(engine, AITile::ERR_AREA_ALREADY_FLAT, "ERR_AREA_ALREADY_FLAT");
SQAITile.DefSQConst(engine, AITile::ERR_EXCAVATION_WOULD_DAMAGE, "ERR_EXCAVATION_WOULD_DAMAGE");
SQAITile.DefSQConst(engine, AITile::CORNER_W, "CORNER_W");
SQAITile.DefSQConst(engine, AITile::CORNER_S, "CORNER_S");
SQAITile.DefSQConst(engine, AITile::CORNER_E, "CORNER_E");
SQAITile.DefSQConst(engine, AITile::CORNER_N, "CORNER_N");
SQAITile.DefSQConst(engine, AITile::CORNER_INVALID, "CORNER_INVALID");
SQAITile.DefSQConst(engine, AITile::SLOPE_FLAT, "SLOPE_FLAT");
SQAITile.DefSQConst(engine, AITile::SLOPE_W, "SLOPE_W");
SQAITile.DefSQConst(engine, AITile::SLOPE_S, "SLOPE_S");
SQAITile.DefSQConst(engine, AITile::SLOPE_E, "SLOPE_E");
SQAITile.DefSQConst(engine, AITile::SLOPE_N, "SLOPE_N");
SQAITile.DefSQConst(engine, AITile::SLOPE_STEEP, "SLOPE_STEEP");
SQAITile.DefSQConst(engine, AITile::SLOPE_NW, "SLOPE_NW");
SQAITile.DefSQConst(engine, AITile::SLOPE_SW, "SLOPE_SW");
SQAITile.DefSQConst(engine, AITile::SLOPE_SE, "SLOPE_SE");
SQAITile.DefSQConst(engine, AITile::SLOPE_NE, "SLOPE_NE");
SQAITile.DefSQConst(engine, AITile::SLOPE_EW, "SLOPE_EW");
SQAITile.DefSQConst(engine, AITile::SLOPE_NS, "SLOPE_NS");
SQAITile.DefSQConst(engine, AITile::SLOPE_ELEVATED, "SLOPE_ELEVATED");
SQAITile.DefSQConst(engine, AITile::SLOPE_NWS, "SLOPE_NWS");
SQAITile.DefSQConst(engine, AITile::SLOPE_WSE, "SLOPE_WSE");
SQAITile.DefSQConst(engine, AITile::SLOPE_SEN, "SLOPE_SEN");
SQAITile.DefSQConst(engine, AITile::SLOPE_ENW, "SLOPE_ENW");
SQAITile.DefSQConst(engine, AITile::SLOPE_STEEP_W, "SLOPE_STEEP_W");
SQAITile.DefSQConst(engine, AITile::SLOPE_STEEP_S, "SLOPE_STEEP_S");
SQAITile.DefSQConst(engine, AITile::SLOPE_STEEP_E, "SLOPE_STEEP_E");
SQAITile.DefSQConst(engine, AITile::SLOPE_STEEP_N, "SLOPE_STEEP_N");
SQAITile.DefSQConst(engine, AITile::SLOPE_INVALID, "SLOPE_INVALID");
SQAITile.DefSQConst(engine, AITile::TRANSPORT_RAIL, "TRANSPORT_RAIL");
SQAITile.DefSQConst(engine, AITile::TRANSPORT_ROAD, "TRANSPORT_ROAD");
SQAITile.DefSQConst(engine, AITile::TRANSPORT_WATER, "TRANSPORT_WATER");
SQAITile.DefSQConst(engine, AITile::TRANSPORT_AIR, "TRANSPORT_AIR");
SQAITile.DefSQConst(engine, AITile::TRANSPORT_INVALID, "TRANSPORT_INVALID");
SQAITile.DefSQConst(engine, AITile::ERR_TILE_BASE, "ERR_TILE_BASE");
SQAITile.DefSQConst(engine, AITile::ERR_TILE_TOO_HIGH, "ERR_TILE_TOO_HIGH");
SQAITile.DefSQConst(engine, AITile::ERR_TILE_TOO_LOW, "ERR_TILE_TOO_LOW");
SQAITile.DefSQConst(engine, AITile::SLOPE_FLAT, "SLOPE_FLAT");
SQAITile.DefSQConst(engine, AITile::SLOPE_W, "SLOPE_W");
SQAITile.DefSQConst(engine, AITile::SLOPE_S, "SLOPE_S");
SQAITile.DefSQConst(engine, AITile::SLOPE_E, "SLOPE_E");
SQAITile.DefSQConst(engine, AITile::SLOPE_N, "SLOPE_N");
SQAITile.DefSQConst(engine, AITile::SLOPE_STEEP, "SLOPE_STEEP");
SQAITile.DefSQConst(engine, AITile::SLOPE_NW, "SLOPE_NW");
SQAITile.DefSQConst(engine, AITile::SLOPE_SW, "SLOPE_SW");
SQAITile.DefSQConst(engine, AITile::SLOPE_SE, "SLOPE_SE");
SQAITile.DefSQConst(engine, AITile::SLOPE_NE, "SLOPE_NE");
SQAITile.DefSQConst(engine, AITile::SLOPE_EW, "SLOPE_EW");
SQAITile.DefSQConst(engine, AITile::SLOPE_NS, "SLOPE_NS");
SQAITile.DefSQConst(engine, AITile::SLOPE_ELEVATED, "SLOPE_ELEVATED");
SQAITile.DefSQConst(engine, AITile::SLOPE_NWS, "SLOPE_NWS");
SQAITile.DefSQConst(engine, AITile::SLOPE_WSE, "SLOPE_WSE");
SQAITile.DefSQConst(engine, AITile::SLOPE_SEN, "SLOPE_SEN");
SQAITile.DefSQConst(engine, AITile::SLOPE_ENW, "SLOPE_ENW");
SQAITile.DefSQConst(engine, AITile::SLOPE_STEEP_W, "SLOPE_STEEP_W");
SQAITile.DefSQConst(engine, AITile::SLOPE_STEEP_S, "SLOPE_STEEP_S");
SQAITile.DefSQConst(engine, AITile::SLOPE_STEEP_E, "SLOPE_STEEP_E");
SQAITile.DefSQConst(engine, AITile::SLOPE_STEEP_N, "SLOPE_STEEP_N");
SQAITile.DefSQConst(engine, AITile::SLOPE_INVALID, "SLOPE_INVALID");
SQAITile.DefSQConst(engine, AITile::TRANSPORT_RAIL, "TRANSPORT_RAIL");
SQAITile.DefSQConst(engine, AITile::TRANSPORT_ROAD, "TRANSPORT_ROAD");
SQAITile.DefSQConst(engine, AITile::TRANSPORT_WATER, "TRANSPORT_WATER");
SQAITile.DefSQConst(engine, AITile::TRANSPORT_AIR, "TRANSPORT_AIR");
SQAITile.DefSQConst(engine, AITile::TRANSPORT_INVALID, "TRANSPORT_INVALID");
AIError::RegisterErrorMap(STR_1003_ALREADY_AT_SEA_LEVEL, AITile::ERR_TILE_TOO_HIGH);
AIError::RegisterErrorMap(STR_1003_ALREADY_AT_SEA_LEVEL, AITile::ERR_TILE_TOO_LOW);
AIError::RegisterErrorMap(STR_ALREADY_LEVELLED, AITile::ERR_AREA_ALREADY_FLAT);
AIError::RegisterErrorMap(STR_1002_EXCAVATION_WOULD_DAMAGE, AITile::ERR_EXCAVATION_WOULD_DAMAGE);
AIError::RegisterErrorMap(STR_1003_ALREADY_AT_SEA_LEVEL, AITile::ERR_TILE_TOO_HIGH);
AIError::RegisterErrorMap(STR_1003_ALREADY_AT_SEA_LEVEL, AITile::ERR_TILE_TOO_LOW);
AIError::RegisterErrorMapString(AITile::ERR_TILE_TOO_HIGH, "ERR_TILE_TOO_HIGH");
AIError::RegisterErrorMapString(AITile::ERR_TILE_TOO_LOW, "ERR_TILE_TOO_LOW");
AIError::RegisterErrorMapString(AITile::ERR_AREA_ALREADY_FLAT, "ERR_AREA_ALREADY_FLAT");
AIError::RegisterErrorMapString(AITile::ERR_EXCAVATION_WOULD_DAMAGE, "ERR_EXCAVATION_WOULD_DAMAGE");
AIError::RegisterErrorMapString(AITile::ERR_TILE_TOO_HIGH, "ERR_TILE_TOO_HIGH");
AIError::RegisterErrorMapString(AITile::ERR_TILE_TOO_LOW, "ERR_TILE_TOO_LOW");
SQAITile.DefSQStaticMethod(engine, &AITile::IsBuildable, "IsBuildable", 2, ".i");
SQAITile.DefSQStaticMethod(engine, &AITile::IsBuildableRectangle, "IsBuildableRectangle", 4, ".iii");
@@ -91,9 +78,6 @@ void SQAITile_Register(Squirrel *engine) {
SQAITile.DefSQStaticMethod(engine, &AITile::GetSlope, "GetSlope", 2, ".i");
SQAITile.DefSQStaticMethod(engine, &AITile::GetComplementSlope, "GetComplementSlope", 2, ".i");
SQAITile.DefSQStaticMethod(engine, &AITile::GetHeight, "GetHeight", 2, ".i");
SQAITile.DefSQStaticMethod(engine, &AITile::GetMinHeight, "GetMinHeight", 2, ".i");
SQAITile.DefSQStaticMethod(engine, &AITile::GetMaxHeight, "GetMaxHeight", 2, ".i");
SQAITile.DefSQStaticMethod(engine, &AITile::GetCornerHeight, "GetCornerHeight", 3, ".ii");
SQAITile.DefSQStaticMethod(engine, &AITile::GetOwner, "GetOwner", 2, ".i");
SQAITile.DefSQStaticMethod(engine, &AITile::HasTransportType, "HasTransportType", 3, ".ii");
SQAITile.DefSQStaticMethod(engine, &AITile::GetCargoAcceptance, "GetCargoAcceptance", 6, ".iiiii");

View File

@@ -68,9 +68,9 @@ void AITileList::RemoveTile(TileIndex tile)
this->RemoveItem(tile);
}
AITileList_IndustryAccepting::AITileList_IndustryAccepting(IndustryID industry_id, int radius)
AITileList_IndustryAccepting::AITileList_IndustryAccepting(IndustryID industry_id, uint radius)
{
if (!AIIndustry::IsValidIndustry(industry_id) || radius <= 0) return;
if (!AIIndustry::IsValidIndustry(industry_id)) return;
const Industry *i = ::GetIndustry(industry_id);
@@ -106,9 +106,9 @@ AITileList_IndustryAccepting::AITileList_IndustryAccepting(IndustryID industry_i
} END_TILE_LOOP(cur_tile, i->width + radius * 2, i->height + radius * 2, i->xy - ::TileDiffXY(radius, radius))
}
AITileList_IndustryProducing::AITileList_IndustryProducing(IndustryID industry_id, int radius)
AITileList_IndustryProducing::AITileList_IndustryProducing(IndustryID industry_id, uint radius)
{
if (!AIIndustry::IsValidIndustry(industry_id) || radius <= 0) return;
if (!AIIndustry::IsValidIndustry(industry_id)) return;
const Industry *i = ::GetIndustry(industry_id);

View File

@@ -71,10 +71,8 @@ public:
/**
* @param industry_id The industry to create the AITileList around.
* @param radius The radius of the station you will be using.
* @pre AIIndustry::IsValidIndustry(industry_id).
* @pre radius > 0.
*/
AITileList_IndustryAccepting(IndustryID industry_id, int radius);
AITileList_IndustryAccepting(IndustryID industry_id, uint radius);
};
/**
@@ -89,10 +87,8 @@ public:
/**
* @param industry_id The industry to create the AITileList around.
* @param radius The radius of the station you will be using.
* @pre AIIndustry::IsValidIndustry(industry_id).
* @pre radius > 0.
*/
AITileList_IndustryProducing(IndustryID industry_id, int radius);
AITileList_IndustryProducing(IndustryID industry_id, uint radius);
};
/**

View File

@@ -37,7 +37,7 @@ namespace SQConvert {
void SQAITileList_IndustryAccepting_Register(Squirrel *engine) {
DefSQClass <AITileList_IndustryAccepting> SQAITileList_IndustryAccepting("AITileList_IndustryAccepting");
SQAITileList_IndustryAccepting.PreRegister(engine, "AITileList");
SQAITileList_IndustryAccepting.AddConstructor<void (AITileList_IndustryAccepting::*)(IndustryID industry_id, int radius), 3>(engine, "xii");
SQAITileList_IndustryAccepting.AddConstructor<void (AITileList_IndustryAccepting::*)(IndustryID industry_id, uint radius), 3>(engine, "xii");
SQAITileList_IndustryAccepting.PostRegister(engine);
}
@@ -54,7 +54,7 @@ namespace SQConvert {
void SQAITileList_IndustryProducing_Register(Squirrel *engine) {
DefSQClass <AITileList_IndustryProducing> SQAITileList_IndustryProducing("AITileList_IndustryProducing");
SQAITileList_IndustryProducing.PreRegister(engine, "AITileList");
SQAITileList_IndustryProducing.AddConstructor<void (AITileList_IndustryProducing::*)(IndustryID industry_id, int radius), 3>(engine, "xii");
SQAITileList_IndustryProducing.AddConstructor<void (AITileList_IndustryProducing::*)(IndustryID industry_id, uint radius), 3>(engine, "xii");
SQAITileList_IndustryProducing.PostRegister(engine);
}

View File

@@ -23,26 +23,14 @@
/* If it's a tunnel alread, take the easy way out! */
if (IsTunnelTile(tile)) return ::GetOtherTunnelEnd(tile);
uint start_z;
Slope start_tileh = ::GetTileSlope(tile, &start_z);
DiagDirection direction = ::GetInclinedSlopeDirection(start_tileh);
if (direction == INVALID_DIAGDIR) return INVALID_TILE;
TileIndexDiff delta = ::TileOffsByDiagDir(direction);
uint end_z;
do {
tile += delta;
if (!::IsValidTile(tile)) return INVALID_TILE;
::GetTileSlope(tile, &end_z);
} while (start_z != end_z);
return tile;
::DoCommand(tile, 0, 0, DC_AUTO, CMD_BUILD_TUNNEL);
return _build_tunnel_endtile == 0 ? INVALID_TILE : _build_tunnel_endtile;
}
static void _DoCommandReturnBuildTunnel2(class AIInstance *instance)
{
if (!AITunnel::_BuildTunnelRoad2()) {
AIObject::SetLastCommandRes(false);
AIInstance::DoCommandReturn(instance);
return;
}
@@ -55,6 +43,7 @@ static void _DoCommandReturnBuildTunnel2(class AIInstance *instance)
static void _DoCommandReturnBuildTunnel1(class AIInstance *instance)
{
if (!AITunnel::_BuildTunnelRoad1()) {
AIObject::SetLastCommandRes(false);
AIInstance::DoCommandReturn(instance);
return;
}
@@ -73,7 +62,7 @@ static void _DoCommandReturnBuildTunnel1(class AIInstance *instance)
uint type = 0;
if (vehicle_type == AIVehicle::VT_ROAD) {
type |= (TRANSPORT_ROAD << 9);
type |= ::RoadTypeToRoadTypes((::RoadType)AIObject::GetRoadType());
type |= RoadTypeToRoadTypes((::RoadType)AIObject::GetRoadType());
} else {
type |= (TRANSPORT_RAIL << 9);
type |= AIRail::GetCurrentRailType();
@@ -85,7 +74,10 @@ static void _DoCommandReturnBuildTunnel1(class AIInstance *instance)
}
AIObject::SetCallbackVariable(0, start);
return AIObject::DoCommand(start, type, 0, CMD_BUILD_TUNNEL, NULL, &_DoCommandReturnBuildTunnel1);
if (!AIObject::DoCommand(start, type, 0, CMD_BUILD_TUNNEL, NULL, &_DoCommandReturnBuildTunnel1)) return false;
/* In case of test-mode, test if we can build both road pieces */
return _BuildTunnelRoad1();
}
/* static */ bool AITunnel::_BuildTunnelRoad1()
@@ -97,7 +89,10 @@ static void _DoCommandReturnBuildTunnel1(class AIInstance *instance)
DiagDirection dir_1 = (DiagDirection)((::TileX(start) == ::TileX(end)) ? (::TileY(start) < ::TileY(end) ? DIAGDIR_NW : DIAGDIR_SE) : (::TileX(start) < ::TileX(end) ? DIAGDIR_NE : DIAGDIR_SW));
DiagDirection dir_2 = ::ReverseDiagDir(dir_1);
return AIObject::DoCommand(start + ::TileOffsByDiagDir(dir_1), ::DiagDirToRoadBits(dir_2) | (AIObject::GetRoadType() << 4), 0, CMD_BUILD_ROAD, NULL, &_DoCommandReturnBuildTunnel2);
if (!AIObject::DoCommand(start + ::TileOffsByDiagDir(dir_1), ::DiagDirToRoadBits(dir_2) | (AIObject::GetRoadType() << 4), 0, CMD_BUILD_ROAD, NULL, &_DoCommandReturnBuildTunnel2)) return false;
/* In case of test-mode, test the other road piece too */
return _BuildTunnelRoad2();
}
/* static */ bool AITunnel::_BuildTunnelRoad2()

View File

@@ -46,15 +46,11 @@ public:
/**
* Get the tile that exits on the other end of a (would be) tunnel starting
* at tile. If there is no 'simple' inclined slope at the start tile,
* this function will return AIMap::TILE_INVALID.
* at tile.
* @param tile The tile that is an entrance to a tunnel or the tile where you may want to build a tunnel.
* @pre AIMap::IsValidTile(tile).
* @return The TileIndex that is the other end of the (would be) tunnel, or
* AIMap::TILE_INVALID if no other end was found (can't build tunnel).
* @note Even if this function returns a valid tile, that is no guarantee
* that building a tunnel will succeed. Use BuildTunnel in AITestMode to
* check whether a tunnel can actually be build.
*/
static TileIndex GetOtherTunnelEnd(TileIndex tile);

View File

@@ -1,75 +1,6 @@
/* $Id$ */
/** @file ai_types.hpp Defines all the types of the game, like IDs of various objects.
*
* IDs are used to identify certain objects. They are only unique within the object type, so for example a vehicle may have VehicleID 2009,
* while a station has StationID 2009 at the same time. Also IDs are assigned arbitrary, you cannot assume them to be consecutive.
* Also note, that some IDs are static and never change, while others are allocated dynamically and might be
* reused for other objects once they are released. So be careful, which IDs you store for which purpose and whether they stay valid all the time.
*
* <table>
* <tr><th>type </th><th> object </th>
* <th> acquired </th>
* <th> released </th>
* <th> reused </th></tr>
* <tr><td>#BridgeID </td><td> bridge type </td>
* <td> introduction \ref newgrf_changes "(1)" </td>
* <td> never \ref newgrf_changes "(1)" </td>
* <td> no \ref newgrf_changes "(1)" </td></tr>
* <tr><td>#CargoID </td><td> cargo type </td>
* <td> game start \ref newgrf_changes "(1)" </td>
* <td> never \ref newgrf_changes "(1)" </td>
* <td> no \ref newgrf_changes "(1)" </td></tr>
* <tr><td>#EngineID </td><td> engine type </td>
* <td> introduction, preview \ref dynamic_engines "(2)" </td>
* <td> engines retires \ref dynamic_engines "(2)" </td>
* <td> no \ref dynamic_engines "(2)" </td></tr>
* <tr><td>#GroupID </td><td> vehicle group </td>
* <td> creation </td>
* <td> deletion </td>
* <td> yes </td></tr>
* <tr><td>#IndustryID </td><td> industry </td>
* <td> construction </td>
* <td> closure </td>
* <td> yes </td></tr>
* <tr><td>#IndustryType</td><td> industry type </td>
* <td> game start \ref newgrf_changes "(1)" </td>
* <td> never \ref newgrf_changes "(1)" </td>
* <td> no </td></tr>
* <tr><td>#SignID </td><td> sign </td>
* <td> construction </td>
* <td> deletion </td>
* <td> yes </td></tr>
* <tr><td>#StationID </td><td> station </td>
* <td> construction </td>
* <td> expiration of 'grey' station sign after deletion </td>
* <td> yes </td></tr>
* <tr><td>#SubsidyID </td><td> subsidy </td>
* <td> offer announcement </td>
* <td> (offer) expiration </td>
* <td> yes </td></tr>
* <tr><td>#TileIndex </td><td> tile on map </td>
* <td> game start </td>
* <td> never </td>
* <td> no </td></tr>
* <tr><td>#TownID </td><td> town </td>
* <td> game start </td>
* <td> never </td>
* <td> no </td></tr>
* <tr><td>#VehicleID </td><td> vehicle </td>
* <td> construction, autorenew, autoreplace </td>
* <td> destruction, autorenew, autoreplace </td>
* <td> yes </td></tr>
* <tr><td>#WaypointID </td><td> waypoint </td>
* <td> construction </td>
* <td> destruction </td>
* <td> yes </td></tr>
* </table>
*
* @remarks
* \li \anchor newgrf_changes (1) in-game changes of newgrfs may reassign/invalidate IDs (will also cause other trouble though).
* \li \anchor dynamic_engines (2) engine IDs are reassigned/invalidated on changing 'allow multiple newgrf engine sets' (only allowed as long as no vehicles are built).
*/
/** @file ai_types.hpp Defines all the types of the game, like VehicleID, .... */
#ifndef AI_TYPES_HPP
#define AI_TYPES_HPP

View File

@@ -160,13 +160,6 @@
return AIObject::DoCommand(0, vehicle_id, 0, GetCmdSendToDepot(::GetVehicle(vehicle_id)));
}
/* static */ bool AIVehicle::SendVehicleToDepotForServicing(VehicleID vehicle_id)
{
EnforcePrecondition(false, IsValidVehicle(vehicle_id));
return AIObject::DoCommand(0, vehicle_id, DEPOT_SERVICE, GetCmdSendToDepot(::GetVehicle(vehicle_id)));
}
/* static */ bool AIVehicle::IsInDepot(VehicleID vehicle_id)
{
if (!IsValidVehicle(vehicle_id)) return false;
@@ -425,11 +418,3 @@
Vehicle *v = ::GetVehicle(vehicle_id);
return v->orders.list != NULL && v->orders.list->GetNumVehicles() > 1;
}
/* static */ int AIVehicle::GetReliability(VehicleID vehicle_id)
{
if (!IsValidVehicle(vehicle_id)) return -1;
const Vehicle *v = ::GetVehicle(vehicle_id);
return v->reliability * 100 >> 16;
}

View File

@@ -43,7 +43,7 @@ public:
ERR_VEHICLE_CANNOT_START_STOP, // [STR_883B_CAN_T_STOP_START_TRAIN, STR_9015_CAN_T_STOP_START_ROAD_VEHICLE, STR_9818_CAN_T_STOP_START_SHIP, STR_A016_CAN_T_STOP_START_AIRCRAFT]
/** Vehicle can't turn */
ERR_VEHICLE_CANNOT_TURN, // [STR_ERROR_CAN_T_MAKE_ROAD_VEHICLE_TURN, STR_ERROR_CAN_T_REVERSE_DIRECTION_TRAIN, STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE, STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE_MULTIPLE_UNITS]
ERR_VEHICLE_CANNOT_TURN, // [STR_8869_CAN_T_REVERSE_DIRECTION, STR_9033_CAN_T_MAKE_VEHICLE_TURN]
/** Vehicle can't be refit */
ERR_VEHICLE_CANNOT_REFIT, // [STR_RAIL_CAN_T_REFIT_VEHICLE, STR_REFIT_ROAD_VEHICLE_CAN_T, STR_9841_CAN_T_REFIT_SHIP, STR_A042_CAN_T_REFIT_AIRCRAFT]
@@ -58,7 +58,7 @@ public:
ERR_VEHICLE_IN_FLIGHT, // [STR_A017_AIRCRAFT_IS_IN_FLIGHT]
/** Vehicle is without power */
ERR_VEHICLE_NO_POWER, // [STR_TRAIN_START_NO_CATENARY]
ERR_VEHCILE_NO_POWER, // [STR_TRAIN_START_NO_CATENARY]
};
@@ -422,25 +422,14 @@ public:
static bool SellWagonChain(VehicleID vehicle_id, int wagon);
/**
* Sends the given vehicle to a depot. If the vehicle has already been
* sent to a depot it continues with its normal orders instead.
* Sends the given vehicle to a depot.
* @param vehicle_id The vehicle to send to a depot.
* @pre IsValidVehicle(vehicle_id).
* @exception AIVehicle::ERR_VEHICLE_CANNOT_SEND_TO_DEPOT
* @return True if the current order was changed.
* @return True if and only if the vehicle has been sent to a depot.
*/
static bool SendVehicleToDepot(VehicleID vehicle_id);
/**
* Sends the given vehicle to a depot for servicing. If the vehicle has
* already been sent to a depot it continues with its normal orders instead.
* @param vehicle_id The vehicle to send to a depot for servicing.
* @pre IsValidVehicle(vehicle_id).
* @exception AIVehicle::ERR_VEHICLE_CANNOT_SEND_TO_DEPOT
* @return True if the current order was changed.
*/
static bool SendVehicleToDepotForServicing(VehicleID vehicle_id);
/**
* Starts or stops the given vehicle depending on the current state.
* @param vehicle_id The vehicle to start/stop.
@@ -525,14 +514,6 @@ public:
*/
static bool HasSharedOrders(VehicleID vehicle_id);
/**
* Get the current reliability of a vehicle.
* @param vehicle_id The vehicle to check.
* @pre IsValidVehicle(vehicle_id).
* @return The current reliability (0-100%).
*/
static int GetReliability(VehicleID vehicle_id);
private:
/**
* Internal function used by SellWagon(Chain).

View File

@@ -37,7 +37,7 @@ void SQAIVehicle_Register(Squirrel *engine) {
SQAIVehicle.DefSQConst(engine, AIVehicle::ERR_VEHICLE_IS_DESTROYED, "ERR_VEHICLE_IS_DESTROYED");
SQAIVehicle.DefSQConst(engine, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT, "ERR_VEHICLE_NOT_IN_DEPOT");
SQAIVehicle.DefSQConst(engine, AIVehicle::ERR_VEHICLE_IN_FLIGHT, "ERR_VEHICLE_IN_FLIGHT");
SQAIVehicle.DefSQConst(engine, AIVehicle::ERR_VEHICLE_NO_POWER, "ERR_VEHICLE_NO_POWER");
SQAIVehicle.DefSQConst(engine, AIVehicle::ERR_VEHCILE_NO_POWER, "ERR_VEHCILE_NO_POWER");
SQAIVehicle.DefSQConst(engine, AIVehicle::VT_RAIL, "VT_RAIL");
SQAIVehicle.DefSQConst(engine, AIVehicle::VT_ROAD, "VT_ROAD");
SQAIVehicle.DefSQConst(engine, AIVehicle::VT_WATER, "VT_WATER");
@@ -52,40 +52,38 @@ void SQAIVehicle_Register(Squirrel *engine) {
SQAIVehicle.DefSQConst(engine, AIVehicle::VS_CRASHED, "VS_CRASHED");
SQAIVehicle.DefSQConst(engine, AIVehicle::VS_INVALID, "VS_INVALID");
AIError::RegisterErrorMap(STR_00E1_TOO_MANY_VEHICLES_IN_GAME, AIVehicle::ERR_VEHICLE_TOO_MANY);
AIError::RegisterErrorMap(STR_AIRCRAFT_NOT_AVAILABLE, AIVehicle::ERR_VEHICLE_NOT_AVAILABLE);
AIError::RegisterErrorMap(STR_ROAD_VEHICLE_NOT_AVAILABLE, AIVehicle::ERR_VEHICLE_NOT_AVAILABLE);
AIError::RegisterErrorMap(STR_SHIP_NOT_AVAILABLE, AIVehicle::ERR_VEHICLE_NOT_AVAILABLE);
AIError::RegisterErrorMap(STR_RAIL_VEHICLE_NOT_AVAILABLE, AIVehicle::ERR_VEHICLE_NOT_AVAILABLE);
AIError::RegisterErrorMap(STR_A008_CAN_T_BUILD_AIRCRAFT, AIVehicle::ERR_VEHICLE_BUILD_DISABLED);
AIError::RegisterErrorMap(STR_980D_CAN_T_BUILD_SHIP, AIVehicle::ERR_VEHICLE_BUILD_DISABLED);
AIError::RegisterErrorMap(STR_9009_CAN_T_BUILD_ROAD_VEHICLE, AIVehicle::ERR_VEHICLE_BUILD_DISABLED);
AIError::RegisterErrorMap(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE, AIVehicle::ERR_VEHICLE_BUILD_DISABLED);
AIError::RegisterErrorMap(STR_DEPOT_WRONG_DEPOT_TYPE, AIVehicle::ERR_VEHICLE_WRONG_DEPOT);
AIError::RegisterErrorMap(STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT, AIVehicle::ERR_VEHICLE_CANNOT_SEND_TO_DEPOT);
AIError::RegisterErrorMap(STR_9018_CAN_T_SEND_VEHICLE_TO_DEPOT, AIVehicle::ERR_VEHICLE_CANNOT_SEND_TO_DEPOT);
AIError::RegisterErrorMap(STR_9819_CAN_T_SEND_SHIP_TO_DEPOT, AIVehicle::ERR_VEHICLE_CANNOT_SEND_TO_DEPOT);
AIError::RegisterErrorMap(STR_A012_CAN_T_SEND_AIRCRAFT_TO, AIVehicle::ERR_VEHICLE_CANNOT_SEND_TO_DEPOT);
AIError::RegisterErrorMap(STR_883B_CAN_T_STOP_START_TRAIN, AIVehicle::ERR_VEHICLE_CANNOT_START_STOP);
AIError::RegisterErrorMap(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE, AIVehicle::ERR_VEHICLE_CANNOT_START_STOP);
AIError::RegisterErrorMap(STR_9818_CAN_T_STOP_START_SHIP, AIVehicle::ERR_VEHICLE_CANNOT_START_STOP);
AIError::RegisterErrorMap(STR_A016_CAN_T_STOP_START_AIRCRAFT, AIVehicle::ERR_VEHICLE_CANNOT_START_STOP);
AIError::RegisterErrorMap(STR_ERROR_CAN_T_MAKE_ROAD_VEHICLE_TURN, AIVehicle::ERR_VEHICLE_CANNOT_TURN);
AIError::RegisterErrorMap(STR_ERROR_CAN_T_REVERSE_DIRECTION_TRAIN, AIVehicle::ERR_VEHICLE_CANNOT_TURN);
AIError::RegisterErrorMap(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE, AIVehicle::ERR_VEHICLE_CANNOT_TURN);
AIError::RegisterErrorMap(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE_MULTIPLE_UNITS, AIVehicle::ERR_VEHICLE_CANNOT_TURN);
AIError::RegisterErrorMap(STR_RAIL_CAN_T_REFIT_VEHICLE, AIVehicle::ERR_VEHICLE_CANNOT_REFIT);
AIError::RegisterErrorMap(STR_REFIT_ROAD_VEHICLE_CAN_T, AIVehicle::ERR_VEHICLE_CANNOT_REFIT);
AIError::RegisterErrorMap(STR_9841_CAN_T_REFIT_SHIP, AIVehicle::ERR_VEHICLE_CANNOT_REFIT);
AIError::RegisterErrorMap(STR_A042_CAN_T_REFIT_AIRCRAFT, AIVehicle::ERR_VEHICLE_CANNOT_REFIT);
AIError::RegisterErrorMap(STR_CAN_T_REFIT_DESTROYED_VEHICLE, AIVehicle::ERR_VEHICLE_IS_DESTROYED);
AIError::RegisterErrorMap(STR_CAN_T_SELL_DESTROYED_VEHICLE, AIVehicle::ERR_VEHICLE_IS_DESTROYED);
AIError::RegisterErrorMap(STR_A01B_AIRCRAFT_MUST_BE_STOPPED, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT);
AIError::RegisterErrorMap(STR_9013_MUST_BE_STOPPED_INSIDE, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT);
AIError::RegisterErrorMap(STR_TRAIN_MUST_BE_STOPPED, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT);
AIError::RegisterErrorMap(STR_980B_SHIP_MUST_BE_STOPPED_IN, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT);
AIError::RegisterErrorMap(STR_A017_AIRCRAFT_IS_IN_FLIGHT, AIVehicle::ERR_VEHICLE_IN_FLIGHT);
AIError::RegisterErrorMap(STR_TRAIN_START_NO_CATENARY, AIVehicle::ERR_VEHICLE_NO_POWER);
AIError::RegisterErrorMap(STR_00E1_TOO_MANY_VEHICLES_IN_GAME, AIVehicle::ERR_VEHICLE_TOO_MANY);
AIError::RegisterErrorMap(STR_AIRCRAFT_NOT_AVAILABLE, AIVehicle::ERR_VEHICLE_NOT_AVAILABLE);
AIError::RegisterErrorMap(STR_ROAD_VEHICLE_NOT_AVAILABLE, AIVehicle::ERR_VEHICLE_NOT_AVAILABLE);
AIError::RegisterErrorMap(STR_SHIP_NOT_AVAILABLE, AIVehicle::ERR_VEHICLE_NOT_AVAILABLE);
AIError::RegisterErrorMap(STR_RAIL_VEHICLE_NOT_AVAILABLE, AIVehicle::ERR_VEHICLE_NOT_AVAILABLE);
AIError::RegisterErrorMap(STR_A008_CAN_T_BUILD_AIRCRAFT, AIVehicle::ERR_VEHICLE_BUILD_DISABLED);
AIError::RegisterErrorMap(STR_980D_CAN_T_BUILD_SHIP, AIVehicle::ERR_VEHICLE_BUILD_DISABLED);
AIError::RegisterErrorMap(STR_9009_CAN_T_BUILD_ROAD_VEHICLE, AIVehicle::ERR_VEHICLE_BUILD_DISABLED);
AIError::RegisterErrorMap(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE, AIVehicle::ERR_VEHICLE_BUILD_DISABLED);
AIError::RegisterErrorMap(STR_DEPOT_WRONG_DEPOT_TYPE, AIVehicle::ERR_VEHICLE_WRONG_DEPOT);
AIError::RegisterErrorMap(STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT, AIVehicle::ERR_VEHICLE_CANNOT_SEND_TO_DEPOT);
AIError::RegisterErrorMap(STR_9018_CAN_T_SEND_VEHICLE_TO_DEPOT, AIVehicle::ERR_VEHICLE_CANNOT_SEND_TO_DEPOT);
AIError::RegisterErrorMap(STR_9819_CAN_T_SEND_SHIP_TO_DEPOT, AIVehicle::ERR_VEHICLE_CANNOT_SEND_TO_DEPOT);
AIError::RegisterErrorMap(STR_A012_CAN_T_SEND_AIRCRAFT_TO, AIVehicle::ERR_VEHICLE_CANNOT_SEND_TO_DEPOT);
AIError::RegisterErrorMap(STR_883B_CAN_T_STOP_START_TRAIN, AIVehicle::ERR_VEHICLE_CANNOT_START_STOP);
AIError::RegisterErrorMap(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE, AIVehicle::ERR_VEHICLE_CANNOT_START_STOP);
AIError::RegisterErrorMap(STR_9818_CAN_T_STOP_START_SHIP, AIVehicle::ERR_VEHICLE_CANNOT_START_STOP);
AIError::RegisterErrorMap(STR_A016_CAN_T_STOP_START_AIRCRAFT, AIVehicle::ERR_VEHICLE_CANNOT_START_STOP);
AIError::RegisterErrorMap(STR_8869_CAN_T_REVERSE_DIRECTION, AIVehicle::ERR_VEHICLE_CANNOT_TURN);
AIError::RegisterErrorMap(STR_9033_CAN_T_MAKE_VEHICLE_TURN, AIVehicle::ERR_VEHICLE_CANNOT_TURN);
AIError::RegisterErrorMap(STR_RAIL_CAN_T_REFIT_VEHICLE, AIVehicle::ERR_VEHICLE_CANNOT_REFIT);
AIError::RegisterErrorMap(STR_REFIT_ROAD_VEHICLE_CAN_T, AIVehicle::ERR_VEHICLE_CANNOT_REFIT);
AIError::RegisterErrorMap(STR_9841_CAN_T_REFIT_SHIP, AIVehicle::ERR_VEHICLE_CANNOT_REFIT);
AIError::RegisterErrorMap(STR_A042_CAN_T_REFIT_AIRCRAFT, AIVehicle::ERR_VEHICLE_CANNOT_REFIT);
AIError::RegisterErrorMap(STR_CAN_T_REFIT_DESTROYED_VEHICLE, AIVehicle::ERR_VEHICLE_IS_DESTROYED);
AIError::RegisterErrorMap(STR_CAN_T_SELL_DESTROYED_VEHICLE, AIVehicle::ERR_VEHICLE_IS_DESTROYED);
AIError::RegisterErrorMap(STR_A01B_AIRCRAFT_MUST_BE_STOPPED, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT);
AIError::RegisterErrorMap(STR_9013_MUST_BE_STOPPED_INSIDE, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT);
AIError::RegisterErrorMap(STR_TRAIN_MUST_BE_STOPPED, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT);
AIError::RegisterErrorMap(STR_980B_SHIP_MUST_BE_STOPPED_IN, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT);
AIError::RegisterErrorMap(STR_A017_AIRCRAFT_IS_IN_FLIGHT, AIVehicle::ERR_VEHICLE_IN_FLIGHT);
AIError::RegisterErrorMap(STR_TRAIN_START_NO_CATENARY, AIVehicle::ERR_VEHCILE_NO_POWER);
AIError::RegisterErrorMapString(AIVehicle::ERR_VEHICLE_TOO_MANY, "ERR_VEHICLE_TOO_MANY");
AIError::RegisterErrorMapString(AIVehicle::ERR_VEHICLE_NOT_AVAILABLE, "ERR_VEHICLE_NOT_AVAILABLE");
@@ -98,51 +96,49 @@ void SQAIVehicle_Register(Squirrel *engine) {
AIError::RegisterErrorMapString(AIVehicle::ERR_VEHICLE_IS_DESTROYED, "ERR_VEHICLE_IS_DESTROYED");
AIError::RegisterErrorMapString(AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT, "ERR_VEHICLE_NOT_IN_DEPOT");
AIError::RegisterErrorMapString(AIVehicle::ERR_VEHICLE_IN_FLIGHT, "ERR_VEHICLE_IN_FLIGHT");
AIError::RegisterErrorMapString(AIVehicle::ERR_VEHICLE_NO_POWER, "ERR_VEHICLE_NO_POWER");
AIError::RegisterErrorMapString(AIVehicle::ERR_VEHCILE_NO_POWER, "ERR_VEHCILE_NO_POWER");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::IsValidVehicle, "IsValidVehicle", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetNumWagons, "GetNumWagons", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::SetName, "SetName", 3, ".is");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetName, "GetName", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetLocation, "GetLocation", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetEngineType, "GetEngineType", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetWagonEngineType, "GetWagonEngineType", 3, ".ii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetUnitNumber, "GetUnitNumber", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetAge, "GetAge", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetWagonAge, "GetWagonAge", 3, ".ii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetMaxAge, "GetMaxAge", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetAgeLeft, "GetAgeLeft", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetCurrentSpeed, "GetCurrentSpeed", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetState, "GetState", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetRunningCost, "GetRunningCost", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetProfitThisYear, "GetProfitThisYear", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetProfitLastYear, "GetProfitLastYear", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetCurrentValue, "GetCurrentValue", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetVehicleType, "GetVehicleType", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetRoadType, "GetRoadType", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::IsInDepot, "IsInDepot", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::IsStoppedInDepot, "IsStoppedInDepot", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::BuildVehicle, "BuildVehicle", 3, ".ii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::CloneVehicle, "CloneVehicle", 4, ".iib");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::MoveWagon, "MoveWagon", 5, ".iiii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::MoveWagonChain, "MoveWagonChain", 5, ".iiii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetRefitCapacity, "GetRefitCapacity", 3, ".ii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::RefitVehicle, "RefitVehicle", 3, ".ii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::SellVehicle, "SellVehicle", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::SellWagon, "SellWagon", 3, ".ii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::SellWagonChain, "SellWagonChain", 3, ".ii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::SendVehicleToDepot, "SendVehicleToDepot", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::SendVehicleToDepotForServicing, "SendVehicleToDepotForServicing", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::StartStopVehicle, "StartStopVehicle", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::SkipToVehicleOrder, "SkipToVehicleOrder", 3, ".ii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::ReverseVehicle, "ReverseVehicle", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetCapacity, "GetCapacity", 3, ".ii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetLength, "GetLength", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetCargoLoad, "GetCargoLoad", 3, ".ii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetGroupID, "GetGroupID", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::IsArticulated, "IsArticulated", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::HasSharedOrders, "HasSharedOrders", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetReliability, "GetReliability", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::IsValidVehicle, "IsValidVehicle", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetNumWagons, "GetNumWagons", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::SetName, "SetName", 3, ".is");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetName, "GetName", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetLocation, "GetLocation", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetEngineType, "GetEngineType", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetWagonEngineType, "GetWagonEngineType", 3, ".ii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetUnitNumber, "GetUnitNumber", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetAge, "GetAge", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetWagonAge, "GetWagonAge", 3, ".ii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetMaxAge, "GetMaxAge", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetAgeLeft, "GetAgeLeft", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetCurrentSpeed, "GetCurrentSpeed", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetState, "GetState", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetRunningCost, "GetRunningCost", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetProfitThisYear, "GetProfitThisYear", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetProfitLastYear, "GetProfitLastYear", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetCurrentValue, "GetCurrentValue", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetVehicleType, "GetVehicleType", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetRoadType, "GetRoadType", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::IsInDepot, "IsInDepot", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::IsStoppedInDepot, "IsStoppedInDepot", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::BuildVehicle, "BuildVehicle", 3, ".ii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::CloneVehicle, "CloneVehicle", 4, ".iib");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::MoveWagon, "MoveWagon", 5, ".iiii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::MoveWagonChain, "MoveWagonChain", 5, ".iiii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetRefitCapacity, "GetRefitCapacity", 3, ".ii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::RefitVehicle, "RefitVehicle", 3, ".ii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::SellVehicle, "SellVehicle", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::SellWagon, "SellWagon", 3, ".ii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::SellWagonChain, "SellWagonChain", 3, ".ii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::SendVehicleToDepot, "SendVehicleToDepot", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::StartStopVehicle, "StartStopVehicle", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::SkipToVehicleOrder, "SkipToVehicleOrder", 3, ".ii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::ReverseVehicle, "ReverseVehicle", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetCapacity, "GetCapacity", 3, ".ii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetLength, "GetLength", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetCargoLoad, "GetCargoLoad", 3, ".ii");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetGroupID, "GetGroupID", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::IsArticulated, "IsArticulated", 2, ".i");
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::HasSharedOrders, "HasSharedOrders", 2, ".i");
SQAIVehicle.PostRegister(engine);
}

View File

@@ -41,7 +41,7 @@ public:
static const char *GetClassName() { return "AIVehicleList_SharedOrders"; }
/**
* @param vehicle_id The vehicle that the rest shared orders with.
* @param station_id The vehicle that the rest shared orders with.
*/
AIVehicleList_SharedOrders(VehicleID vehicle_id);
};

View File

@@ -15,11 +15,8 @@ class AIWaypoint : public AIObject {
public:
static const char *GetClassName() { return "AIWaypoint"; }
/**
* Special waypoint IDs signalling different kinds of waypoints.
*/
enum SpecialWaypointIDs {
WAYPOINT_INVALID = 0xFFFF, //!< An invalid WaypointID.
WAYPOINT_INVALID = -1, //!< An invalid WaypointID.
};
/**

View File

@@ -2,15 +2,6 @@
# $Id$
# We really need gawk for this!
AWK=gawk
${AWK} --version > /dev/null 2> /dev/null
if [ "$?" != "0" ]; then
echo "This script needs gawk to run properly"
exit 1
fi
# This must be called from within the src/ai/api directory.
if [ -z "$1" ]; then
@@ -19,7 +10,7 @@ if [ -z "$1" ]; then
# these files should not be changed by this script
"ai_controller.hpp" | "ai_object.hpp" | "ai_types.hpp" ) continue;
esac
${AWK} -f squirrel_export.awk ${f} > ${f}.tmp
awk -f squirrel_export.awk ${f} > ${f}.tmp
if ! [ -f "${f}.sq" ] || [ -n "`diff -I '$Id' -b ${f}.tmp ${f}.sq 2> /dev/null || echo boo`" ]; then
mv ${f}.tmp ${f}.sq
echo "Updated: ${f}.sq"
@@ -31,7 +22,7 @@ if [ -z "$1" ]; then
fi
done
else
${AWK} -f squirrel_export.awk $1 > $1.tmp
awk -f squirrel_export.awk $1 > $1.tmp
if ! [ -f "${f}.sq" ] || [ -n "`diff -I '$Id' -b $1.sq $1.tmp 2> /dev/null || echo boo`" ]; then
mv $1.tmp $1.sq
echo "Updated: $1.sq"
@@ -93,7 +84,7 @@ echo "
{ print \$0; }
" > ${f}.awk
${AWK} -f ${f}.awk ${f} > ${f}.tmp
awk -f ${f}.awk ${f} > ${f}.tmp
if ! [ -f "${f}" ] || [ -n "`diff -I '$Id' -b ${f} ${f}.tmp 2> /dev/null || echo boo`" ]; then
mv ${f}.tmp ${f}

View File

@@ -337,6 +337,24 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
u->subtype = AIR_SHADOW;
u->UpdateDeltaXY(INVALID_DIR);
if (v->cargo_type != CT_PASSENGERS) {
uint16 callback = CALLBACK_FAILED;
if (HasBit(EngInfo(p1)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
callback = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, v->engine_type, v);
}
if (callback == CALLBACK_FAILED) {
/* Callback failed, or not executed; use the default cargo capacity */
v->cargo_cap = AircraftDefaultCargoCapacity(v->cargo_type, avi);
} else {
v->cargo_cap = callback;
}
/* Set the 'second compartent' capacity to none */
u->cargo_cap = 0;
}
v->reliability = e->reliability;
v->reliability_spd_dec = e->reliability_spd_dec;
v->max_age = e->lifelength * DAYS_IN_LEAP_YEAR;
@@ -377,28 +395,6 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
v->vehicle_flags = 0;
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SetBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
v->InvalidateNewGRFCacheOfChain();
if (v->cargo_type != CT_PASSENGERS) {
uint16 callback = CALLBACK_FAILED;
if (HasBit(EngInfo(p1)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
callback = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, v->engine_type, v);
}
if (callback == CALLBACK_FAILED) {
/* Callback failed, or not executed; use the default cargo capacity */
v->cargo_cap = AircraftDefaultCargoCapacity(v->cargo_type, avi);
} else {
v->cargo_cap = callback;
}
/* Set the 'second compartent' capacity to none */
u->cargo_cap = 0;
}
v->InvalidateNewGRFCacheOfChain();
UpdateAircraftCache(v);
VehicleMove(v, false);
@@ -584,7 +580,6 @@ CommandCost CmdRefitAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
v->cargo_type = new_cid;
v->cargo_subtype = new_subtype;
v->colourmap = PAL_NONE; // invalidate vehicle colour map
v->InvalidateNewGRFCacheOfChain();
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0);

View File

@@ -111,7 +111,7 @@ static void TransferCargo(Vehicle *old_veh, Vehicle *new_head, bool part_of_chai
uint amount = min(src->cargo.Count(), dest->cargo_cap - dest->cargo.Count());
if (amount <= 0) continue;
src->cargo.MoveTo(&dest->cargo, amount, CargoList::MTA_UNLOAD, NULL);
src->cargo.MoveTo(&dest->cargo, amount);
}
}

View File

@@ -5,7 +5,6 @@
#include "stdafx.h"
#include "station_base.h"
#include "oldpool_func.h"
#include "economy_base.h"
/* Initialize the cargopacket-pool */
DEFINE_OLD_POOL_GENERIC(CargoPacket, CargoPacket)
@@ -28,6 +27,7 @@ CargoPacket::CargoPacket(StationID source, uint16 count)
this->count = count;
this->days_in_transit = 0;
this->feeder_share = 0;
this->paid_for = false;
}
CargoPacket::~CargoPacket()
@@ -37,7 +37,7 @@ CargoPacket::~CargoPacket()
bool CargoPacket::SameSource(const CargoPacket *cp) const
{
return this->source_xy == cp->source_xy && this->days_in_transit == cp->days_in_transit;
return this->source_xy == cp->source_xy && this->days_in_transit == cp->days_in_transit && this->paid_for == cp->paid_for;
}
/*
@@ -81,6 +81,11 @@ uint CargoList::Count() const
return count;
}
bool CargoList::UnpaidCargo() const
{
return unpaid_cargo;
}
Money CargoList::FeederShare() const
{
return feeder_share;
@@ -141,10 +146,9 @@ void CargoList::Truncate(uint count)
InvalidateCache();
}
bool CargoList::MoveTo(CargoList *dest, uint count, CargoList::MoveToAction mta, CargoPayment *payment, uint data)
bool CargoList::MoveTo(CargoList *dest, uint count, CargoList::MoveToAction mta, uint data)
{
assert(mta == MTA_FINAL_DELIVERY || dest != NULL);
assert(mta == MTA_UNLOAD || mta == MTA_CARGO_LOAD || payment != NULL);
CargoList tmp;
while (!packets.empty() && count > 0) {
@@ -157,25 +161,20 @@ bool CargoList::MoveTo(CargoList *dest, uint count, CargoList::MoveToAction mta,
if (cp->source == data) {
tmp.Append(cp);
} else {
payment->PayFinalDelivery(cp, cp->count);
count -= cp->count;
delete cp;
}
continue; // of the loop
break;
case MTA_CARGO_LOAD:
cp->loaded_at_xy = data;
break;
case MTA_TRANSFER:
payment->PayTransfer(cp, cp->count);
break;
case MTA_UNLOAD:
/* When cargo is moved into another vehicle you have *always* paid for it */
cp->paid_for = false;
/* FALL THROUGH */
case MTA_OTHER:
count -= cp->count;
dest->packets.push_back(cp);
break;
}
count -= cp->count;
dest->packets.push_back(cp);
} else {
/* Can move only part of the packet, so split it into two pieces */
if (mta != MTA_FINAL_DELIVERY) {
@@ -190,13 +189,11 @@ bool CargoList::MoveTo(CargoList *dest, uint count, CargoList::MoveToAction mta,
cp_new->days_in_transit = cp->days_in_transit;
cp_new->feeder_share = fs;
/* When cargo is moved into another vehicle you have *always* paid for it */
cp_new->paid_for = (mta == MTA_CARGO_LOAD) ? false : cp->paid_for;
cp_new->count = count;
dest->packets.push_back(cp_new);
if (mta == MTA_TRANSFER) payment->PayTransfer(cp_new, count);
} else {
payment->PayFinalDelivery(cp, count);
}
cp->count -= count;
@@ -208,7 +205,7 @@ bool CargoList::MoveTo(CargoList *dest, uint count, CargoList::MoveToAction mta,
if (mta == MTA_FINAL_DELIVERY && !tmp.Empty()) {
/* There are some packets that could not be delivered at the station, put them back */
tmp.MoveTo(this, UINT_MAX, MTA_UNLOAD, NULL);
tmp.MoveTo(this, UINT_MAX);
tmp.packets.clear();
}
@@ -222,6 +219,7 @@ void CargoList::InvalidateCache()
{
empty = packets.empty();
count = 0;
unpaid_cargo = false;
feeder_share = 0;
source = INVALID_STATION;
days_in_transit = 0;
@@ -231,6 +229,7 @@ void CargoList::InvalidateCache()
uint dit = 0;
for (List::const_iterator it = packets.begin(); it != packets.end(); it++) {
count += (*it)->count;
unpaid_cargo |= !(*it)->paid_for;
dit += (*it)->days_in_transit * (*it)->count;
feeder_share += (*it)->feeder_share;
}

View File

@@ -29,6 +29,7 @@ struct CargoPacket : PoolItem<CargoPacket, CargoPacketID, &_CargoPacket_pool> {
uint16 count; ///< The amount of cargo in this packet
byte days_in_transit; ///< Amount of days this packet has been in transit
bool paid_for; ///< Have we been paid for this cargo packet?
/**
* Creates a new cargo packet
@@ -84,8 +85,7 @@ public:
enum MoveToAction {
MTA_FINAL_DELIVERY, ///< "Deliver" the packet to the final destination, i.e. destroy the packet
MTA_CARGO_LOAD, ///< Load the packet onto a vehicle, i.e. set the last loaded station ID
MTA_TRANSFER, ///< The cargo is moved as part of a transfer
MTA_UNLOAD, ///< The cargo is moved as part of a forced unload
MTA_OTHER ///< "Just" move the packet to another cargo list
};
private:
@@ -93,6 +93,7 @@ private:
bool empty; ///< Cache for whether this list is empty or not
uint count; ///< Cache for the number of cargo entities
bool unpaid_cargo; ///< Cache for the unpaid cargo
Money feeder_share; ///< Cache for the feeder share
StationID source; ///< Cache for the source of the packet
uint days_in_transit; ///< Cache for the number of days in transit
@@ -128,6 +129,12 @@ public:
*/
uint Count() const;
/**
* Is there some cargo that has not been paid for?
* @return true if and only if there is such a cargo
*/
bool UnpaidCargo() const;
/**
* Returns total sum of the feeder share for all packets
* @return the before mentioned number
@@ -168,23 +175,18 @@ public:
* Depending on the value of mta the side effects of this function differ:
* - MTA_FINAL_DELIVERY: destroys the packets that do not originate from a specific station
* - MTA_CARGO_LOAD: sets the loaded_at_xy value of the moved packets
* - MTA_TRANSFER: just move without side effects
* - MTA_UNLOAD: just move without side effects
* - MTA_OTHER: just move without side effects
* @param dest the destination to move the cargo to
* @param count the amount of cargo entities to move
* @param mta how to handle the moving (side effects)
* @param data Depending on mta the data of this variable differs:
* - MTA_FINAL_DELIVERY - station ID of packet's origin not to remove
* - MTA_CARGO_LOAD - station's tile index of load
* - MTA_TRANSFER - unused
* - MTA_UNLOAD - unused
* @param payment The payment helper
*
* @pre mta == MTA_FINAL_DELIVERY || dest != NULL
* @pre mta == MTA_UNLOAD || mta == MTA_CARGO_LOAD || payment != NULL
* - MTA_OTHER - unused
* @param mta == MTA_FINAL_DELIVERY || dest != NULL
* @return true if there are still packets that might be moved from this cargo list
*/
bool MoveTo(CargoList *dest, uint count, CargoList::MoveToAction mta, CargoPayment *payment, uint data = 0);
bool MoveTo(CargoList *dest, uint count, CargoList::MoveToAction mta = MTA_OTHER, uint data = 0);
/** Invalidates the cached data and rebuild it */
void InvalidateCache();

View File

@@ -123,6 +123,11 @@ static void GetAcceptedCargo_Clear(TileIndex tile, AcceptedCargo ac)
/* unused */
}
static void AnimateTile_Clear(TileIndex tile)
{
/* unused */
}
void TileLoopClearHelper(TileIndex tile)
{
byte self;
@@ -312,6 +317,12 @@ get_out:;
} while (--i);
}
static bool ClickTile_Clear(TileIndex tile)
{
/* not used */
return false;
}
static TrackStatus GetTileTrackStatus_Clear(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
{
return 0;
@@ -358,8 +369,8 @@ extern const TileTypeProcs _tile_type_clear_procs = {
GetAcceptedCargo_Clear, ///< get_accepted_cargo_proc
GetTileDesc_Clear, ///< get_tile_desc_proc
GetTileTrackStatus_Clear, ///< get_tile_track_status_proc
NULL, ///< click_tile_proc
NULL, ///< animate_tile_proc
ClickTile_Clear, ///< click_tile_proc
AnimateTile_Clear, ///< animate_tile_proc
TileLoop_Clear, ///< tile_loop_clear
ChangeTileOwner_Clear, ///< change_tile_owner_clear
NULL, ///< get_produced_cargo_proc

View File

@@ -445,11 +445,12 @@ Company *DoStartupNewCompany(bool is_ai)
c->inaugurated_year = _cur_year;
RandomCompanyManagerFaceBits(c->face, (GenderEthnicity)Random(), false); // create a random company manager face
/* Settings for non-ai companies are copied from the client settings later. */
if (is_ai) {
c->engine_renew_money = 100000;
c->engine_renew_months = 6;
}
/* Engine renewal settings */
c->engine_renew_list = NULL;
c->renew_keep_length = false;
c->engine_renew = _settings_client.gui.autorenew;
c->engine_renew_months = _settings_client.gui.autorenew_months;
c->engine_renew_money = _settings_client.gui.autorenew_money;
GeneratePresidentName(c);
@@ -755,9 +756,6 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
/* This is the client (or non-dedicated server) who wants a new company */
if (cid == _network_own_client_id) {
/* Create p1 and p2 here because SetLocalCompany resets the gui.autorenew* settings. */
uint32 p1 = (_settings_client.gui.autorenew << 15 ) | (_settings_client.gui.autorenew_months << 16) | 4;
uint32 p2 = _settings_client.gui.autorenew_money;
assert(_local_company == COMPANY_SPECTATOR);
SetLocalCompany(c->index);
if (!StrEmpty(_settings_client.network.default_company_pass)) {
@@ -769,7 +767,13 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
/* Now that we have a new company, broadcast our autorenew settings to
* all clients so everything is in sync */
NetworkSend_Command(0, p1, p2, CMD_SET_AUTOREPLACE, NULL, NULL);
NetworkSend_Command(0,
(_settings_client.gui.autorenew << 15 ) | (_settings_client.gui.autorenew_months << 16) | 4,
_settings_client.gui.autorenew_money,
CMD_SET_AUTOREPLACE,
NULL,
NULL
);
MarkWholeScreenDirty();
}

View File

@@ -462,7 +462,7 @@ public:
this->livery_class = LC_OTHER;
this->sel = 1;
this->LowerWidget(SCLW_WIDGET_CLASS_GENERAL);
this->OnInvalidateData();
this->OnInvalidateData(_loaded_newgrf_features.has_2CC);
this->FindWindowPlacementAndResize(desc);
}
@@ -595,8 +595,14 @@ public:
virtual void OnInvalidateData(int data = 0)
{
int r = this->widget[_loaded_newgrf_features.has_2CC ? SCLW_WIDGET_SEC_COL_DROPDOWN : SCLW_WIDGET_PRI_COL_DROPDOWN].right;
this->SetWidgetHiddenState(SCLW_WIDGET_SEC_COL_DROPDOWN, !_loaded_newgrf_features.has_2CC);
static bool has2cc = true;
if (has2cc == !!data) return;
has2cc = !!data;
int r = this->widget[has2cc ? SCLW_WIDGET_SEC_COL_DROPDOWN : SCLW_WIDGET_PRI_COL_DROPDOWN].right;
this->SetWidgetHiddenState(SCLW_WIDGET_SEC_COL_DROPDOWN, !has2cc);
this->widget[SCLW_WIDGET_CAPTION].right = r;
this->widget[SCLW_WIDGET_SPACER_CLASS].right = r;
this->widget[SCLW_WIDGET_MATRIX].right = r;

View File

@@ -116,13 +116,13 @@ void IConsolePrint(ConsoleColour colour_code, const char *string)
* by any other means. Uses printf() style format, for more information look
* at IConsolePrint()
*/
void CDECL IConsolePrintF(ConsoleColour colour_code, const char *format, ...)
void CDECL IConsolePrintF(ConsoleColour colour_code, const char *s, ...)
{
va_list va;
char buf[ICON_MAX_STREAMSIZE];
va_start(va, format);
vsnprintf(buf, sizeof(buf), format, va);
va_start(va, s);
vsnprintf(buf, sizeof(buf), s, va);
va_end(va);
IConsolePrint(colour_code, buf);

View File

@@ -640,11 +640,6 @@ DEF_CONSOLE_CMD(ConJoinCompany)
return true;
}
if (company_id != COMPANY_SPECTATOR && GetCompany(company_id)->is_ai) {
IConsoleError("Cannot join AI company.");
return true;
}
/* Check if the company requires a password */
if (NetworkCompanyIsPassworded(company_id) && argc < 3) {
IConsolePrintF(CC_ERROR, "Company %d requires a password to join.", company_id + 1);
@@ -683,11 +678,6 @@ DEF_CONSOLE_CMD(ConMoveClient)
return true;
}
if (company_id != COMPANY_SPECTATOR && GetCompany(company_id)->is_ai) {
IConsoleError("You cannot move clients to AI companies.");
return true;
}
if (ci->client_id == CLIENT_ID_SERVER && _network_dedicated) {
IConsoleError("Silly boy, you cannot move the server!");
return true;
@@ -792,8 +782,8 @@ DEF_CONSOLE_CMD(ConNetworkConnect)
/* From a user pov 0 is a new company, internally it's different and all
* companies are offset by one to ease up on users (eg companies 1-8 not 0-7) */
if (_network_playas != COMPANY_SPECTATOR) {
if (_network_playas > MAX_COMPANIES) return false;
_network_playas--;
if (!IsValidCompanyID(_network_playas)) return false;
}
}
if (port != NULL) {
@@ -1199,7 +1189,7 @@ DEF_CONSOLE_CMD(ConInfoVar)
IConsolePrintF(CC_DEFAULT, "variable name: %s", var->name);
IConsolePrintF(CC_DEFAULT, "variable type: %s", _icon_vartypes[var->type]);
IConsolePrintF(CC_DEFAULT, "variable addr: %p", var->addr);
IConsolePrintF(CC_DEFAULT, "variable addr: 0x%X", var->addr);
if (var->hook.access) IConsoleWarning("variable is access hooked");
if (var->hook.pre) IConsoleWarning("variable is pre hooked");
@@ -1226,7 +1216,7 @@ DEF_CONSOLE_CMD(ConInfoCmd)
}
IConsolePrintF(CC_DEFAULT, "command name: %s", cmd->name);
IConsolePrintF(CC_DEFAULT, "command proc: %p", cmd->proc);
IConsolePrintF(CC_DEFAULT, "command proc: 0x%X", cmd->proc);
if (cmd->hook.access) IConsoleWarning("command is access hooked");
if (cmd->hook.pre) IConsoleWarning("command is pre hooked");
@@ -1431,7 +1421,7 @@ DEF_CONSOLE_CMD(ConCompanies)
const NetworkCompanyStats *stats = &company_stats[c->index];
GetString(buffer, STR_00D1_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",
IConsolePrintF(CC_INFO, "#:%d(%s) Company Name: '%s' Year Founded: %d Money: %" OTTD_PRINTF64 "d Loan: %" OTTD_PRINTF64 "d Value: %" OTTD_PRINTF64 "d (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],
@@ -1518,8 +1508,6 @@ bool NetworkChangeCompanyPassword(byte argc, char *argv[])
return true;
}
/* Content downloading only is available with ZLIB */
#if defined(WITH_ZLIB)
#include "network/network_content.h"
/** Resolve a string to a content type. */
@@ -1628,7 +1616,7 @@ DEF_CONSOLE_CMD(ConContent)
return false;
}
#endif /* defined(WITH_ZLIB) */
#endif /* ENABLE_NETWORK */
DEF_CONSOLE_CMD(ConSetting)
@@ -1775,11 +1763,7 @@ void IConsoleStdLibRegister()
#ifdef ENABLE_NETWORK
/* Network hooks; only active in network */
IConsoleCmdHookAdd ("resetengines", ICONSOLE_HOOK_ACCESS, ConHookNoNetwork);
/* Content downloading is only available with ZLIB */
#if defined(WITH_ZLIB)
IConsoleCmdRegister("content", ConContent);
#endif /* defined(WITH_ZLIB) */
/*** Networking commands ***/
IConsoleCmdRegister("say", ConSay);

View File

@@ -17,7 +17,7 @@ void IConsoleClose();
/* console output */
void IConsolePrint(ConsoleColour colour_code, const char *string);
void CDECL IConsolePrintF(ConsoleColour colour_code, const char *format, ...) WARN_FORMAT(2, 3);
void CDECL IConsolePrintF(ConsoleColour colour_code, const char *s, ...);
void IConsoleDebug(const char *dbg, const char *string);
void IConsoleWarning(const char *string);
void IConsoleError(const char *string);

View File

@@ -11,7 +11,7 @@
*/
void NORETURN MallocError(size_t size)
{
error("Out of memory. Cannot allocate " PRINTF_SIZE " bytes", size);
error("Out of memory. Cannot allocate %i bytes", size);
}
/**
@@ -20,5 +20,5 @@ void NORETURN MallocError(size_t size)
*/
void NORETURN ReallocError(size_t size)
{
error("Out of memory. Cannot reallocate " PRINTF_SIZE " bytes", size);
error("Out of memory. Cannot reallocate %i bytes", size);
}

View File

@@ -318,7 +318,7 @@ static FORCEINLINE T ROR(const T x, const uint8 n)
*/
static FORCEINLINE uint32 BSWAP32(uint32 x)
{
#if !defined(__ICC) && defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ >= 3))
#if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ >= 3))
/* GCC >= 4.3 provides a builtin, resulting in faster code */
return (uint32)__builtin_bswap32((int32)x);
#else

View File

@@ -86,7 +86,7 @@ public:
FORCEINLINE OverflowSafeInt operator * (const byte factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; }
/* Operators for division */
FORCEINLINE OverflowSafeInt& operator /= (const int64 divisor) { this->m_value /= divisor; return *this; }
FORCEINLINE OverflowSafeInt& operator /= (const int divisor) { this->m_value /= divisor; return *this; }
FORCEINLINE OverflowSafeInt operator / (const OverflowSafeInt& divisor) const { OverflowSafeInt result = *this; result /= divisor.m_value; return result; }
FORCEINLINE OverflowSafeInt operator / (const int divisor) const { OverflowSafeInt result = *this; result /= divisor; return result; }
FORCEINLINE OverflowSafeInt operator / (const uint divisor) const { OverflowSafeInt result = *this; result /= (int)divisor; return result; }

View File

@@ -108,7 +108,7 @@ static FORCEINLINE uint32 InteractiveRandomRange(uint16 max)
* Checks if a given randomize-number is below a given probability.
*
* This function is used to check if the given probability by the fraction of (a/b)
* is greater than low 16 bits of the given randomize-number r.
* is greater than low 16 bits of the given randomize-number v.
*
* Do not use this function twice on the same random 16 bits as it will yield
* the same result. One can use a random number for two calls to Chance16I,
@@ -117,12 +117,12 @@ static FORCEINLINE uint32 InteractiveRandomRange(uint16 max)
* @param a The numerator of the fraction
* @param b The denominator of the fraction, must of course not be null
* @param r The given randomize-number
* @return True if the probability given by r is less or equal to (a/b)
* @return True if v is less or equals (a/b)
*/
static FORCEINLINE bool Chance16I(const uint a, const uint b, const uint32 r)
{
assert(b != 0);
return (((uint16)r * b + b / 2) >> 16) < a;
return (uint16)r < (uint16)(((a << 16) + b / 2) / b);
}
/**

View File

@@ -35,7 +35,7 @@ static const CurrencySpec origin_currency_specs[NUM_CURRENCY] = {
{ 3, ',', 2002, "NLG ", "", 0, STR_CURR_NLG }, ///< dutch gulden
{ 12, '.', CF_NOEURO, "", " Kr", 1, STR_CURR_NOK }, ///< norwegian krone
{ 6, ' ', CF_NOEURO, "", " zl", 1, STR_CURR_PLN }, ///< polish zloty
{ 5, '.', CF_NOEURO, "", " Lei", 1, STR_CURR_RON }, ///< romanian Lei
{ 5, '.', CF_NOEURO, "", " Lei", 1, STR_CURR_ROL }, ///< romanian Lei
{ 50, ' ', CF_NOEURO, "", " p", 1, STR_CURR_RUR }, ///< russian rouble
{ 352, '.', 2007, "", " SIT", 1, STR_CURR_SIT }, ///< slovenian tolar
{ 13, '.', CF_NOEURO, "", " Kr", 1, STR_CURR_SEK }, ///< swedish krona
@@ -76,7 +76,7 @@ enum {
CURR_NLG,
CURR_NOK,
CURR_PLN,
CURR_RON,
CURR_ROL,
CURR_RUR,
CURR_SIT,
CURR_SEK,

View File

@@ -92,13 +92,15 @@ static void debug_print(const char *dbg, const char *buf)
}
}
void CDECL debug(const char *dbg, const char *format, ...)
void CDECL debug(const char *dbg, ...)
{
va_list va;
va_start(va, dbg);
const char *s;
char buf[1024];
va_list va;
va_start(va, format);
vsnprintf(buf, lengthof(buf), format, va);
s = va_arg(va, const char*);
vsnprintf(buf, lengthof(buf), s, va);
va_end(va);
debug_print(dbg, buf);
@@ -147,7 +149,7 @@ void SetDebugString(const char *s)
if (p != NULL) {
*p = v;
} else {
ShowInfoF("Unknown debug level '%.*s'", (int)(s - t), t);
ShowInfoF("Unknown debug level '%.*s'", s - t, t);
return;
}
}

View File

@@ -50,12 +50,19 @@
extern int _debug_gamelog_level;
extern int _debug_desync_level;
void CDECL debug(const char *dbg, const char *format, ...) WARN_FORMAT(2, 3);
void CDECL debug(const char *dbg, ...);
#endif /* NO_DEBUG_MESSAGES */
void SetDebugString(const char *s);
const char *GetDebugString();
/* MSVCRT of course has to have a different syntax for long long *sigh* */
#if defined(_MSC_VER) || defined(__MINGW32__)
#define OTTD_PRINTF64 "I64"
#else
#define OTTD_PRINTF64 "ll"
#endif
/* Used for profiling
*
* Usage:
@@ -86,13 +93,13 @@ const char *GetDebugString();
#define TOC(str, count)\
__sum__ += ottd_rdtsc() - _xxx_;\
if (++__i__ == count) {\
DEBUG(misc, 0, "[%s] " OTTD_PRINTF64 " [avg: %.1f]\n", str, __sum__, __sum__/(double)__i__);\
DEBUG(misc, 0, "[%s] %" OTTD_PRINTF64 "u [avg: %.1f]\n", str, __sum__, __sum__/(double)__i__);\
__i__ = 0;\
__sum__ = 0;\
}\
}
void ShowInfo(const char *str);
void CDECL ShowInfoF(const char *str, ...) WARN_FORMAT(1, 2);
void CDECL ShowInfoF(const char *str, ...);
#endif /* DEBUG_H */

View File

@@ -948,7 +948,7 @@ struct DepotWindow : Window {
if (this->GetVehicleFromDepotWndPt(pt.x, pt.y, &v, &gdvp) == MODE_DRAG_VEHICLE &&
sel != INVALID_VEHICLE) {
if (gdvp.wagon != NULL && gdvp.wagon->index == sel && _ctrl_pressed) {
DoCommandP(GetVehicle(sel)->tile, GetVehicle(sel)->index, true, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE));
DoCommandP(GetVehicle(sel)->tile, GetVehicle(sel)->index, true, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN));
} else if (gdvp.wagon == NULL || gdvp.wagon->index != sel) {
TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
} else if (gdvp.head != NULL && IsFrontEngine(gdvp.head)) {

View File

@@ -323,7 +323,10 @@ static void DisasterTick_Ufo(Vehicle *v)
} else {
/* Target a vehicle */
u = GetVehicle(v->dest_tile);
assert(u->type == VEH_ROAD && IsRoadVehFront(u));
if (u->type != VEH_ROAD || !IsRoadVehFront(u)) {
delete v;
return;
}
dist = Delta(v->x_pos, u->x_pos) + Delta(v->y_pos, u->y_pos);
@@ -1026,26 +1029,6 @@ void ReleaseDisastersTargetingIndustry(IndustryID i)
}
}
/** Notify disasters that we are about to delete a vehicle. So make them head elsewhere.
* @param vehicle deleted vehicle
*/
void ReleaseDisastersTargetingVehicle(VehicleID vehicle)
{
Vehicle *v;
FOR_ALL_VEHICLES(v) {
/* primary disaster vehicles that have chosen target */
if (v->type == VEH_DISASTER && v->subtype == ST_SMALL_UFO) {
if (v->current_order.GetDestination() != 0 && v->dest_tile == vehicle) {
/* Revert to target-searching */
v->current_order.SetDestination(0);
v->dest_tile = RandomTile();
v->z_pos = 135;
v->age = 0;
}
}
}
}
void DisasterVehicle::UpdateDeltaXY(Direction direction)
{
this->x_offs = -1;

View File

@@ -61,8 +61,8 @@ const Driver *DriverFactoryBase::SelectDriver(const char *name, Driver::Type typ
if (GetDrivers().size() == 0) return NULL;
if (StrEmpty(name)) {
/* Probe for this driver, but do not fall back to dedicated/null! */
for (int priority = 10; priority > 0; priority--) {
/* Probe for this driver */
for (int priority = 10; priority >= 0; priority--) {
Drivers::iterator it = GetDrivers().begin();
for (; it != GetDrivers().end(); ++it) {
DriverFactoryBase *d = (*it).second;

View File

@@ -43,11 +43,22 @@ static void GetTileDesc_Dummy(TileIndex tile, TileDesc *td)
td->owner[0] = OWNER_NONE;
}
static void AnimateTile_Dummy(TileIndex tile)
{
/* not used */
}
static void TileLoop_Dummy(TileIndex tile)
{
/* not used */
}
static bool ClickTile_Dummy(TileIndex tile)
{
/* not used */
return false;
}
static void ChangeTileOwner_Dummy(TileIndex tile, Owner old_owner, Owner new_owner)
{
/* not used */
@@ -70,8 +81,8 @@ extern const TileTypeProcs _tile_type_dummy_procs = {
GetAcceptedCargo_Dummy, // get_accepted_cargo_proc
GetTileDesc_Dummy, // get_tile_desc_proc
GetTileTrackStatus_Dummy, // get_tile_track_status_proc
NULL, // click_tile_proc
NULL, // animate_tile_proc
ClickTile_Dummy, // click_tile_proc
AnimateTile_Dummy, // animate_tile_proc
TileLoop_Dummy, // tile_loop_clear
ChangeTileOwner_Dummy, // change_tile_owner_clear
NULL, // get_produced_cargo_proc

View File

@@ -32,16 +32,10 @@
#include "autoreplace_func.h"
#include "company_gui.h"
#include "signs_base.h"
#include "economy_base.h"
#include "oldpool_func.h"
#include "table/strings.h"
#include "table/sprites.h"
/* Initialize the cargo payment-pool */
DEFINE_OLD_POOL_GENERIC(CargoPayment, CargoPayment)
/**
* Multiply two integer values and shift the results to right.
*
@@ -1226,17 +1220,15 @@ static bool FindIndustryToDeliver(TileIndex ind_tile, void *user_data)
return true;
}
/** The industries we've currently brought cargo to. */
static SmallIndustryList _cargo_delivery_destinations;
/**
* Transfer goods from station to industry.
* All cargo is delivered to the nearest (Manhattan) industry to the station sign, which is inside the acceptance rectangle and actually accepts the cargo.
* @param st The station that accepted the cargo
* @param cargo_type Type of cargo delivered
* @param nun_pieces Amount of cargo delivered
* @param industry_set The destination industry will be inserted into this set
*/
static void DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, int num_pieces)
static void DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, int num_pieces, SmallIndustryList *industry_set)
{
if (st->rect.IsEmpty()) return;
@@ -1275,14 +1267,13 @@ static void DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, int nu
assert(best != NULL);
/* Insert the industry into industry_set, if not yet contained */
_cargo_delivery_destinations.Include(best);
if (industry_set != NULL) industry_set->Include(best);
best->incoming_cargo_waiting[accepted_cargo_index] = min(num_pieces + best->incoming_cargo_waiting[accepted_cargo_index], 0xFFFF);
}
}
static bool CheckSubsidised(Station *from, Station *to, CargoID cargo_type, CompanyID company)
static bool CheckSubsidised(Station *from, Station *to, CargoID cargo_type)
{
Subsidy *s;
TileIndex xy;
@@ -1334,7 +1325,7 @@ static bool CheckSubsidised(Station *from, Station *to, CargoID cargo_type, Comp
pair = SetupSubsidyDecodeParam(s, 0);
InjectDParam(1);
SetDParam(0, company);
SetDParam(0, _current_company);
AddNewsItem(
STR_2031_SERVICE_SUBSIDY_AWARDED + _settings_game.difficulty.subsidy_multiplier,
NS_SUBSIDIES,
@@ -1356,10 +1347,10 @@ static bool CheckSubsidised(Station *from, Station *to, CargoID cargo_type, Comp
* @param dest Station the cargo has been unloaded
* @param source_tile The origin of the cargo for distance calculation
* @param days_in_transit Travel time
* @param company The company delivering the cargo
* @param industry_set The delivered industry will be inserted into this set, if not yet contained
* The cargo is just added to the stockpile of the industry. It is due to the caller to trigger the industry's production machinery
*/
static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID source, StationID dest, TileIndex source_tile, byte days_in_transit, Company *company)
static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID source, StationID dest, TileIndex source_tile, byte days_in_transit, SmallIndustryList *industry_set)
{
bool subsidised;
Station *s_from, *s_to;
@@ -1368,15 +1359,18 @@ static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID source,
assert(num_pieces > 0);
/* Update company statistics */
company->cur_economy.delivered_cargo += num_pieces;
SetBit(company->cargo_types, cargo_type);
{
Company *c = GetCompany(_current_company);
c->cur_economy.delivered_cargo += num_pieces;
SetBit(c->cargo_types, cargo_type);
}
/* Get station pointers. */
s_from = IsValidStationID(source) ? GetStation(source) : NULL;
s_from = GetStation(source);
s_to = GetStation(dest);
/* Check if a subsidy applies. */
subsidised = s_from != NULL && CheckSubsidised(s_from, s_to, cargo_type, company->index);
subsidised = CheckSubsidised(s_from, s_to, cargo_type);
/* Increase town's counter for some special goods types */
const CargoSpec *cs = GetCargo(cargo_type);
@@ -1384,7 +1378,7 @@ static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID source,
if (cs->town_effect == TE_WATER) s_to->town->new_act_water += num_pieces;
/* Give the goods to the industry. */
DeliverGoodsToIndustry(s_to, cargo_type, num_pieces);
DeliverGoodsToIndustry(s_to, cargo_type, num_pieces, industry_set);
/* Determine profit */
profit = GetTransportedGoodsIncome(num_pieces, DistanceManhattan(source_tile, s_to->xy), days_in_transit, cargo_type);
@@ -1438,107 +1432,109 @@ static void TriggerIndustryProduction(Industry *i)
}
/**
* Makes us a new cargo payment helper.
* @param front The front of the train
* @param destinations List to add the destinations of 'our' cargo to
*/
CargoPayment::CargoPayment(Vehicle *front) :
front(front),
current_station(front->last_station_visited)
{
}
CargoPayment::~CargoPayment()
{
if (this->CleaningPool()) return;
this->front->cargo_payment = NULL;
if (this->visual_profit == 0) {
this->front = NULL;
return;
}
CompanyID old_company = _current_company;
_current_company = this->front->owner;
SubtractMoneyFromCompany(CommandCost(this->front->GetExpenseType(true), -this->route_profit));
this->front->profit_this_year += this->visual_profit << 8;
if (this->route_profit != 0) {
if (IsLocalCompany() && !PlayVehicleSound(this->front, VSE_LOAD_UNLOAD)) {
SndPlayVehicleFx(SND_14_CASHTILL, this->front);
}
ShowCostOrIncomeAnimation(this->front->x_pos, this->front->y_pos, this->front->z_pos, -this->visual_profit);
} else {
ShowFeederIncomeAnimation(this->front->x_pos, this->front->y_pos, this->front->z_pos, this->visual_profit);
}
_current_company = old_company;
this->front = NULL;
}
/**
* Handle payment for final delivery of the given cargo packet.
* @param cp The cargo packet to pay for.
* @param count The number of packets to pay for.
*/
void CargoPayment::PayFinalDelivery(CargoPacket *cp, uint count)
{
if (this->owner == NULL) {
this->owner = GetCompany(this->front->owner);
}
/* Handle end of route payment */
Money profit = DeliverGoods(count, this->ct, cp->source, this->current_station, cp->source_xy, cp->days_in_transit, this->owner);
this->route_profit += profit;
/* The vehicle's profit is whatever route profit there is minus feeder shares. */
this->visual_profit += profit - cp->feeder_share;
}
/**
* Handle payment for transfer of the given cargo packet.
* @param cp The cargo packet to pay for.
* @param count The number of packets to pay for.
*/
void CargoPayment::PayTransfer(CargoPacket *cp, uint count)
{
Money profit = GetTransportedGoodsIncome(
count,
/* pay transfer vehicle for only the part of transfer it has done: ie. cargo_loaded_at_xy to here */
DistanceManhattan(cp->loaded_at_xy, GetStation(this->current_station)->xy),
cp->days_in_transit,
this->ct);
this->visual_profit += profit; // accumulate transfer profits for whole vehicle
cp->feeder_share += profit; // account for the (virtual) profit already made for the cargo packet
}
/**
* Prepare the vehicle to be unloaded.
* Performs the vehicle payment _and_ marks the vehicle to be unloaded.
* @param front_v the vehicle to be unloaded
*/
void PrepareUnload(Vehicle *front_v)
void VehiclePayment(Vehicle *front_v)
{
int result = 0;
Money vehicle_profit = 0; // Money paid to the train
Money route_profit = 0; // The grand total amount for the route. A-D of transfer chain A-B-C-D
Money virtual_profit = 0; // The virtual profit for entire vehicle chain
StationID last_visited = front_v->last_station_visited;
Station *st = GetStation(last_visited);
/* The owner of the train wants to be paid */
CompanyID old_company = _current_company;
_current_company = front_v->owner;
/* At this moment loading cannot be finished */
ClrBit(front_v->vehicle_flags, VF_LOADING_FINISHED);
/* Start unloading in at the first possible moment */
front_v->load_unload_time_rem = 1;
if ((front_v->current_order.GetUnloadType() & OUFB_NO_UNLOAD) == 0) {
for (Vehicle *v = front_v; v != NULL; v = v->Next()) {
if (v->cargo_cap > 0 && !v->cargo.Empty()) {
/* Collect delivered industries */
static SmallIndustryList industry_set;
industry_set.Clear();
for (Vehicle *v = front_v; v != NULL; v = v->Next()) {
/* No cargo to unload */
if (v->cargo_cap == 0 || v->cargo.Empty() || front_v->current_order.GetUnloadType() & OUFB_NO_UNLOAD) continue;
/* All cargo has already been paid for, no need to pay again */
if (!v->cargo.UnpaidCargo()) {
SetBit(v->vehicle_flags, VF_CARGO_UNLOADING);
continue;
}
GoodsEntry *ge = &st->goods[v->cargo_type];
const CargoList::List *cargos = v->cargo.Packets();
for (CargoList::List::const_iterator it = cargos->begin(); it != cargos->end(); it++) {
CargoPacket *cp = *it;
if (!cp->paid_for &&
cp->source != last_visited &&
HasBit(ge->acceptance_pickup, GoodsEntry::ACCEPTANCE) &&
(front_v->current_order.GetUnloadType() & OUFB_TRANSFER) == 0) {
/* Deliver goods to the station */
st->time_since_unload = 0;
/* handle end of route payment */
Money profit = DeliverGoods(cp->count, v->cargo_type, cp->source, last_visited, cp->source_xy, cp->days_in_transit, &industry_set);
cp->paid_for = true;
route_profit += profit; // display amount paid for final route delivery, A-D of a chain A-B-C-D
vehicle_profit += profit - cp->feeder_share; // whole vehicle is not payed for transfers picked up earlier
result |= 1;
SetBit(v->vehicle_flags, VF_CARGO_UNLOADING);
} else if (front_v->current_order.GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) {
if (!cp->paid_for && (front_v->current_order.GetUnloadType() & OUFB_TRANSFER) != 0) {
Money profit = GetTransportedGoodsIncome(
cp->count,
/* pay transfer vehicle for only the part of transfer it has done: ie. cargo_loaded_at_xy to here */
DistanceManhattan(cp->loaded_at_xy, GetStation(last_visited)->xy),
cp->days_in_transit,
v->cargo_type);
front_v->profit_this_year += profit << 8;
virtual_profit += profit; // accumulate transfer profits for whole vehicle
cp->feeder_share += profit; // account for the (virtual) profit already made for the cargo packet
cp->paid_for = true; // record that the cargo has been paid for to eliminate double counting
}
result |= 2;
SetBit(v->vehicle_flags, VF_CARGO_UNLOADING);
}
}
v->cargo.InvalidateCache();
}
assert(front_v->cargo_payment == NULL);
front_v->cargo_payment = new CargoPayment(front_v);
/* Call the production machinery of industries only once for every vehicle chain */
const Industry * const *isend = industry_set.End();
for (Industry **iid = industry_set.Begin(); iid != isend; iid++) {
TriggerIndustryProduction(*iid);
}
if (virtual_profit > 0) {
ShowFeederIncomeAnimation(front_v->x_pos, front_v->y_pos, front_v->z_pos, virtual_profit);
}
if (route_profit != 0) {
front_v->profit_this_year += vehicle_profit << 8;
SubtractMoneyFromCompany(CommandCost(front_v->GetExpenseType(true), -route_profit));
if (IsLocalCompany() && !PlayVehicleSound(front_v, VSE_LOAD_UNLOAD)) {
SndPlayVehicleFx(SND_14_CASHTILL, front_v);
}
ShowCostOrIncomeAnimation(front_v->x_pos, front_v->y_pos, front_v->z_pos, -vehicle_profit);
}
_current_company = old_company;
}
/**
@@ -1552,7 +1548,6 @@ void PrepareUnload(Vehicle *front_v)
static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
{
assert(v->current_order.IsType(OT_LOADING));
assert(v->load_unload_time_rem != 0);
/* We have not waited enough time till the next round of loading/unloading */
if (--v->load_unload_time_rem != 0) {
@@ -1588,8 +1583,6 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
v->cur_speed = 0;
CargoPayment *payment = v->cargo_payment;
for (; v != NULL; v = v->Next()) {
if (v->cargo_cap == 0) continue;
@@ -1611,11 +1604,9 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
bool remaining = false; // Are there cargo entities in this vehicle that can still be unloaded here?
bool accepted = false; // Is the cargo accepted by the station?
payment->SetCargo(v->cargo_type);
if (HasBit(ge->acceptance_pickup, GoodsEntry::ACCEPTANCE) && !(u->current_order.GetUnloadType() & OUFB_TRANSFER)) {
/* The cargo has reached it's final destination, the packets may now be destroyed */
remaining = v->cargo.MoveTo(NULL, amount_unloaded, CargoList::MTA_FINAL_DELIVERY, payment, last_visited);
remaining = v->cargo.MoveTo(NULL, amount_unloaded, CargoList::MTA_FINAL_DELIVERY, last_visited);
result |= 1;
accepted = true;
@@ -1627,20 +1618,14 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
* station is still accepting the cargo in the vehicle. It doesn't
* accept cargo that was loaded at the same station. */
if (u->current_order.GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER) && (!accepted || v->cargo.Count() == cargo_count)) {
remaining = v->cargo.MoveTo(&ge->cargo, amount_unloaded, u->current_order.GetUnloadType() & OUFB_TRANSFER ? CargoList::MTA_TRANSFER : CargoList::MTA_UNLOAD, payment);
remaining = v->cargo.MoveTo(&ge->cargo, amount_unloaded);
SetBit(ge->acceptance_pickup, GoodsEntry::PICKUP);
result |= 2;
} else if (!accepted) {
/* The order changed while unloading (unset unload/transfer) or the
* station does not accept our goods. */
* station does not accept goods anymore. */
ClrBit(v->vehicle_flags, VF_CARGO_UNLOADING);
/* Say we loaded something, otherwise we'll think we didn't unload
* something and we didn't load something, so we must be finished
* at this station. Setting the unloaded means that we will get a
* retry for loading in the next cycle. */
anything_unloaded = true;
continue;
}
@@ -1710,7 +1695,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
completely_emptied = false;
anything_loaded = true;
ge->cargo.MoveTo(&v->cargo, cap, CargoList::MTA_CARGO_LOAD, NULL, st->xy);
ge->cargo.MoveTo(&v->cargo, cap, CargoList::MTA_CARGO_LOAD, st->xy);
st->time_since_load = 0;
st->last_vehicle_type = v->type;
@@ -1746,8 +1731,6 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
v = u;
if (!anything_unloaded) delete payment;
if (anything_loaded || anything_unloaded) {
if (_settings_game.order.gradual_loading) {
/* The time it takes to load one 'slice' of cargo or passengers depends
@@ -1824,9 +1807,6 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
*/
void LoadUnloadStation(Station *st)
{
/* No vehicle is here... */
if (st->loading_vehicles.empty()) return;
int cargo_left[NUM_CARGO];
for (uint i = 0; i < NUM_CARGO; i++) cargo_left[i] = st->goods[i].cargo.Count();
@@ -1836,13 +1816,6 @@ void LoadUnloadStation(Station *st)
Vehicle *v = *iter;
if (!(v->vehstatus & (VS_STOPPED | VS_CRASHED))) LoadUnloadVehicle(v, cargo_left);
}
/* Call the production machinery of industries */
const Industry * const *isend = _cargo_delivery_destinations.End();
for (Industry **iid = _cargo_delivery_destinations.Begin(); iid != isend; iid++) {
TriggerIndustryProduction(*iid);
}
_cargo_delivery_destinations.Clear();
}
void CompaniesMonthlyLoop()

View File

@@ -1,51 +0,0 @@
/* $Id$ */
/** @file economy_base.h Base classes related to the economy. */
#ifndef ECONOMY_BASE_H
#define ECONOMY_BASE_H
#include "cargopacket.h"
DECLARE_OLD_POOL(CargoPayment, CargoPayment, 9, 125)
/**
* Helper class to perform the cargo payment.
*/
struct CargoPayment : PoolItem<CargoPayment, CargoPaymentID, &_CargoPayment_pool> {
Vehicle *front; ///< The front vehicle to do the payment of
Money route_profit; ///< The amount of money to add/remove from the bank account
Money visual_profit; ///< The visual profit to show
/* Unsaved variables */
Company *owner; ///< The owner of the vehicle
StationID current_station; ///< The current station
CargoID ct; ///< The currently handled cargo type
/** Constructor for pool saveload */
CargoPayment() {}
CargoPayment(Vehicle *front);
~CargoPayment();
void PayTransfer(CargoPacket *cp, uint count);
void PayFinalDelivery(CargoPacket *cp, uint count);
/**
* Sets the currently handled cargo type.
* @param ct the cargo type to handle from now on.
*/
void SetCargo(CargoID ct) { this->ct = ct; }
inline bool IsValid() const { return this->front != NULL; }
};
#define FOR_ALL_CARGO_PAYMENTS_FROM(v, start) for (v = GetCargoPayment(start); v != NULL; v = (v->index + 1U < GetCargoPaymentPoolSize()) ? GetCargoPayment(v->index + 1) : NULL) if (v->IsValid())
#define FOR_ALL_CARGO_PAYMENTS(var) FOR_ALL_CARGO_PAYMENTS_FROM(var, 0)
/**
* Whether this savegame is a savegame with cargo payment or not.
* This is important to know when loading a savegame.
*/
extern bool _cargo_payment_savegame;
#endif /* ECONOMY_BASE_H */

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