1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-30 18:09:09 +00:00

Compare commits

..

47 Commits

Author SHA1 Message Date
frosch
46ba435529 (svn r26981) -Release: 1.4.4-RC1 2014-10-08 18:30:54 +00:00
frosch
7fcd735ebc (svn r26980) [1.4] -Update documentation 2014-10-08 18:29:27 +00:00
rubidium
28bc11a9f1 (svn r26977) [1.4] -Backport: strings from trunk 2014-10-07 17:47:35 +00:00
frosch
2147c81162 (svn r26974) [1.4] -Backport from trunk:
- Fix: Owner of road depot road types were not properly changed upon bankruptcy [FS#6126] (r26955)
2014-10-06 20:18:11 +00:00
frosch
ee3f8c3ef2 (svn r26973) [1.4] -Backport from trunk:
- Fix: Image widgets stored 32bit SpriteID in uint16 (r26971)
- Fix: Compilation on HAIKU (r26922)
- Fix: Crash when enabling 'Full animation' if multiplayer chat text is on screen [FS#6096] (r26919)
- Fix: Height computation of game script text in town GUI did not consider margins [FS#6119] (r26859)
2014-10-06 20:14:44 +00:00
frosch
628b52921f (svn r26972) [1.4] -Backport from trunk:
- Fix: Compilation of strgen on various platforms like Solaris (r26850)
- Fix: Better display of refit information for articulated vehicles [FS#6113] (r26849, r26848)
- Fix: Do not assign a next hop when returning cargo [FS#6110] (r26847)
- Fix: The ok-button in the OSK for the signs list should just close the OSK [FS#6116] (r26827)
2014-10-06 20:10:07 +00:00
rubidium
cac97612ac (svn r26958) [1.4] -Backport from trunk:
- Cleanup [Squirrel]: remove many unused bits and pieces
2014-10-04 20:34:41 +00:00
frosch
4bd5dcb3b4 (svn r26913) [1.4] -Update documentation 2014-09-23 18:33:31 +00:00
frosch
c37b98b58b (svn r26824) [1.4] -Update documentation 2014-09-14 16:07:01 +00:00
rubidium
b0425dbdc5 (svn r26823) [1.4] -Fix (r26822): a few string changes too many were backported 2014-09-14 15:44:57 +00:00
rubidium
9d34dbf080 (svn r26822) [1.4] -Backport from trunk: language updates 2014-09-14 15:33:52 +00:00
frosch
57f6cb970b (svn r26820) [1.4] -Backport from trunk:
- Fix: Crashes on joining a server with pending order backups [FS#6112] (r26819)
- Fix: Crashes on start due to dereferencing the -1 index of the file names array of music files (r26809)
2014-09-14 15:24:39 +00:00
frosch
6043b839af (svn r26794) [1.4] -Update documentation 2014-09-07 15:56:49 +00:00
frosch
45bb3caba2 (svn r26793) [1.4] -Backport from trunk:
- Fix: TC_NO_SHADE did not work for 32bpp text rendering (r26792)
2014-09-07 15:41:03 +00:00
rubidium
126b11db63 (svn r26791) [1.4] -Backport from trunk: language updates 2014-09-07 15:18:58 +00:00
frosch
2134c2e905 (svn r26790) [1.4] -Backport from trunk:
- Fix: Loading a game with order backups leaked Orders and left unreachable items in the pool (r26787)
- Fix: Buffer overrun in SQCompiler::Error (r26764)
- Fix: Desync due to not always properly restoring game state from the savegame (r26753)
- Fix: [Script] Crashes and infinite loops when using lists in item-descending order [FS#6085] (r26744)
2014-09-07 15:09:05 +00:00
frosch
8e36fb0ada (svn r26789) [1.4] -Backport from trunk:
- Fix: Incorrect CFLAGS when enabling gprof profiling (r26737, r26735)
- Fix: Do not reset the last selected airport or layout, unless it is really necessary [FS#6083] (r26732)
- Fix: Use the normal search path to look for xdg-open at Unix [FS#6077] (r26724)
- Fix: Properly check for cargo acceptance of houses [FS#5997] (r26723)
2014-09-07 15:07:22 +00:00
frosch
12c3ba3095 (svn r26739) [1.4] -Update documentation 2014-08-16 18:30:47 +00:00
frosch
0db873d6da (svn r26718) [1.4] -Update documentation 2014-08-03 15:33:49 +00:00
frosch
17507b217c (svn r26717) [1.4] -Backport from trunk:
- Fix: CMD_CLEAR_ORDER_BACKUP should not be suppressed by pause modes (r26716)
- Fix: Discard incorrectly saved order backups when clients join [FS#6066] (r26700)
2014-08-03 15:04:09 +00:00
frosch
48bd683010 (svn r26715) [1.4] -Backport from trunk:
- Fix: [NewGRF] Parameters to SCC_NEWGRF_PUSH_WORD and SCC_NEWGRF_UNPRINT were not skipped during drawing (r26713)
- Fix: [OSX] Compilation fails with some lzo2 versions, if __LP64__ is defined to 0 instead of checking whether it is defined [FS#6069] (r26709)
- Codechange: Use awk instead of trying to convince cpp to preprocess nfo files (r26708)
- Fix: Wrong breakdown sound was played for ships [FS#6015] (r26706)
2014-08-03 14:06:04 +00:00
frosch
3614c4447f (svn r26714) [1.4] -Backport from trunk:
- Fix: Integer overflows in acceleration code causing either too low acceleration or too high acceleration [FS#6067] (r26702)
- Fix: Do not crash when trying to show an error about vehicle in a NewGRF and the NewGRF was not loaded at all (r26699)
- Fix: Tighten parameter bound checks on GSCargoMonitor functions, and return -1 on out-of-bound parameters (r26685)
2014-08-03 14:03:07 +00:00
rubidium
3630a2cc4e (svn r26710) [1.4] -Backport from trunk: language updates 2014-07-31 06:18:10 +00:00
frosch
26ed360ccd (svn r26673) [1.4] -Update documentation 2014-07-03 18:34:46 +00:00
frosch
8dc0522434 (svn r26670) [1.4] -Backport from trunk:
- Fix: CargoPacket::SourceStation() returns a StationID (r26660)
- Fix: Production cheat cannot be allowed to be active in multiplayer for desync reasons, even when activated in singleplayer previously [FS#6044] (r26656)
- Fix: Make sure an 'abs' is used that supports int64 when using 'abs' on those variables (r26651)
- Fix: Support save/load chunk lengths of up to (1 << 32) - 1 [FS#6041] (r26650)
2014-07-01 20:13:23 +00:00
rubidium
13378995d9 (svn r26668) [1.4] -Backport from trunk:
- Fix: Days in dates are not represented by ordinal numbers in all languages [FS#6047]
- Language updates
2014-06-29 17:58:58 +00:00
frosch
1708243e51 (svn r26653) [1.4] -Backport from trunk:
- Fix: Incorrect usage of string commands in the base language [FS#6037] (r26642, r26640, r26639, r26632)
2014-06-17 19:14:59 +00:00
frosch
324e17d827 (svn r26652) [1.4] -Backport from trunk:
- Fix: Segmentation fault when encountering a .obg/.obs/.obm with empty string/zero length MD5 checksums [FS#6038] (r26637)
- Fix: The 'Load' button was not properly enabled/disabled for old savegames without NewGRF information (r26634)
- Fix: If the video driver fails to supply a list of resolutions, display an error message [FS#6012] (r26629)
2014-06-17 19:08:07 +00:00
frosch
bcfc0ec957 (svn r26626) [1.4] -Update documentation 2014-06-02 18:19:54 +00:00
frosch
5702b3951c (svn r26625) [1.4] -Backport from trunk:
- Fix: First send packages about new company, then clients joining it to admin port [FS#6025] (r26616)
2014-06-02 18:18:35 +00:00
frosch
491b3e3efc (svn r26599) [1.4] -Update documentation 2014-05-18 18:30:18 +00:00
rubidium
2759e32451 (svn r26597) [1.4] -Backport from trunk: language updates 2014-05-18 15:21:31 +00:00
frosch
d3c41a9d0e (svn r26596) [1.4] -Backport from trunk:
- Fix: Save/load issues on big endian machines (r26593, r26590, r26589)
- Fix: Consider multiheaded trains in station refits [FS#5995] (r26586)
- Fix: Game script could be changed in game by double clicking [FS#5974] (r26583)
2014-05-18 11:26:09 +00:00
frosch
3cd96a459b (svn r26595) [1.4] -Backport from trunk:
- Fix: Transfer stations also should have a cargo rating [FS#5989] (r26581, r26580)
- Fix: [Network] AIs would not reset certain network state information upon creation of their company [FS#6003] (r26578, r26576)
- Fix: [Network] Client of non-dedicated server was not correctly put into the first company for all state variables [FS#6001] (r26577)
2014-05-18 11:21:59 +00:00
frosch
1d18ef48a4 (svn r26561) [1.4] -Update documentation 2014-05-04 18:24:43 +00:00
rubidium
a6e95ace5c (svn r26559) [1.4] -Backport from trunk: language updates 2014-05-04 16:17:25 +00:00
frosch
c57b316570 (svn r26544) [1.4] -Backport from trunk:
- Fix: [Windows] Crash when the operating system performs the "paint" callback during window creation [FS#5994] (r26539, r26538)
- Fix: OpenBSD compilation [FS#5992] (r26523)
- Fix: prevent from ever reading huge (or negative) amounts of data in strgen (r26521)
- Fix: Severity rating of dedicated server messages during world generation (r26518)
2014-04-29 18:41:19 +00:00
frosch
b720a16a1c (svn r26543) [1.4] -Backport from trunk:
- Fix: Buffer overruns in handling of symbolic links inside tars (r26514)
- Fix: Incorrect usage of strecpy (r26505, r26485)
- Fix: Reading console input on dedicated server relied on unspecified behaviour (r26496)
2014-04-29 18:35:01 +00:00
frosch
7a0b2bff18 (svn r26542) [1.4] -Backport from trunk:
- Change: Remove demand calculation based on tiles (r26484)
- Fix: Allow single-vehicle consists to station-refit in a meaningful way (r26483)
2014-04-29 18:21:49 +00:00
frosch
34bff06d8a (svn r26541) [1.4] -Backport from trunk:
- Fix: Prevent comparing to NULL when strndup could not allocate memory (r26476)
- Fix: Potentially undefined shifts in NewGRF code (r26475)
- Fix: Make sure there is no uninitialised sprite data (r26473)
- Fix: Draw text shadow for ellipses (r26467)
- Fix: Add special handling for PALETTE_CRASH to work for non-8bpp-mapped sprites (r26463)
2014-04-29 18:18:52 +00:00
rubidium
be4eae9456 (svn r26532) [1.4] -Backport: language updates 2014-04-27 20:01:21 +00:00
frosch
f8b956bc2c (svn r26461) [1.4] -Backport from trunk:
- Fix: Avoid division by 0 when scaling flow values [FS#5970] (r26448)
- Feature: Draw links to match _settings_game.vehicle.road_side [FS#5961] (r26445)
- Change: Use pkg-config for libpng as well (r26435, r26433, r26432)
- Feature: Load button for heightmap list [FS#5953] (r26428)
2014-04-13 10:52:19 +00:00
frosch
42c7cb38fa (svn r26460) [1.4] -Backport from trunk:
- Fix: Do not crash when supplying an invalid filename without extension to cmd parameter -q (r26423)
- Fix: Some road constructions used the rail sound effect [FS#5946] (r26422)
- Fix: Goal GUI failed to shade [FS#5948] (r26420)
- Fix: Shares button state was not appropriately updated when switching setting or company [FS#5947] (r26416)
- Change: Use better distance metric for link graph [FS#5941] (r26411)
2014-04-13 10:47:39 +00:00
frosch
9d2f06c42c (svn r26439) [1.4] -Update documentation 2014-04-01 18:29:34 +00:00
frosch
0c2be35fa1 (svn r26414) [1.4] -Update: documentation 2014-03-18 19:51:54 +00:00
planetmaker
80a3b5e78f (svn r26412) [1.4] -Change: We have a new titlegame (Fleashosio) 2014-03-18 18:13:33 +00:00
frosch
8ca5334562 (svn r26405) [1.4] -Branch: Less excuses to not do stuff in trunk. 2014-03-17 19:53:30 +00:00
693 changed files with 13031 additions and 28536 deletions

View File

@@ -172,7 +172,6 @@ install: bundle
$(Q)install -d "$(INSTALL_BINARY_DIR)" $(Q)install -d "$(INSTALL_BINARY_DIR)"
$(Q)install -d "$(INSTALL_ICON_DIR)" $(Q)install -d "$(INSTALL_ICON_DIR)"
$(Q)install -d "$(INSTALL_DATA_DIR)/ai" $(Q)install -d "$(INSTALL_DATA_DIR)/ai"
$(Q)install -d "$(INSTALL_DATA_DIR)/game"
$(Q)install -d "$(INSTALL_DATA_DIR)/baseset" $(Q)install -d "$(INSTALL_DATA_DIR)/baseset"
$(Q)install -d "$(INSTALL_DATA_DIR)/lang" $(Q)install -d "$(INSTALL_DATA_DIR)/lang"
$(Q)install -d "$(INSTALL_DATA_DIR)/scripts" $(Q)install -d "$(INSTALL_DATA_DIR)/scripts"
@@ -183,7 +182,6 @@ else
endif endif
$(Q)install -m 644 "$(BUNDLE_DIR)/lang/"* "$(INSTALL_DATA_DIR)/lang" $(Q)install -m 644 "$(BUNDLE_DIR)/lang/"* "$(INSTALL_DATA_DIR)/lang"
$(Q)install -m 644 "$(BUNDLE_DIR)/ai/"* "$(INSTALL_DATA_DIR)/ai" $(Q)install -m 644 "$(BUNDLE_DIR)/ai/"* "$(INSTALL_DATA_DIR)/ai"
$(Q)install -m 644 "$(BUNDLE_DIR)/game/"* "$(INSTALL_DATA_DIR)/game"
$(Q)install -m 644 "$(BUNDLE_DIR)/baseset/"* "$(INSTALL_DATA_DIR)/baseset" $(Q)install -m 644 "$(BUNDLE_DIR)/baseset/"* "$(INSTALL_DATA_DIR)/baseset"
$(Q)install -m 644 "$(BUNDLE_DIR)/scripts/"* "$(INSTALL_DATA_DIR)/scripts" $(Q)install -m 644 "$(BUNDLE_DIR)/scripts/"* "$(INSTALL_DATA_DIR)/scripts"
ifndef DO_NOT_INSTALL_DOCS ifndef DO_NOT_INSTALL_DOCS

View File

@@ -43,23 +43,23 @@ RES := $(shell mkdir -p $(BIN_DIR)/lang )
all: table/strings.h $(LANGS) all: table/strings.h $(LANGS)
strgen_base.o: $(SRC_DIR)/strgen/strgen_base.cpp $(SRC_DIR)/strgen/strgen.h endian_host.h $(SRC_DIR)/table/control_codes.h $(SRC_DIR)/table/strgen_tables.h $(SRC_DIR)/safeguards.h strgen_base.o: $(SRC_DIR)/strgen/strgen_base.cpp $(SRC_DIR)/strgen/strgen.h endian_host.h $(SRC_DIR)/table/control_codes.h $(SRC_DIR)/table/strgen_tables.h
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)' $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $< $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<
strgen.o: $(SRC_DIR)/strgen/strgen.cpp $(SRC_DIR)/strgen/strgen.h endian_host.h $(SRC_DIR)/table/control_codes.h $(SRC_DIR)/table/strgen_tables.h $(SRC_DIR)/safeguards.h strgen.o: $(SRC_DIR)/strgen/strgen.cpp $(SRC_DIR)/strgen/strgen.h endian_host.h $(SRC_DIR)/table/control_codes.h $(SRC_DIR)/table/strgen_tables.h
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)' $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $< $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<
string.o: $(SRC_DIR)/string.cpp endian_host.h $(SRC_DIR)/safeguards.h string.o: $(SRC_DIR)/string.cpp endian_host.h
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)' $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $< $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<
alloc_func.o: $(SRC_DIR)/core/alloc_func.cpp endian_host.h $(SRC_DIR)/safeguards.h alloc_func.o: $(SRC_DIR)/core/alloc_func.cpp endian_host.h
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)' $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $< $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<
getoptdata.o: $(SRC_DIR)/misc/getoptdata.cpp $(SRC_DIR)/misc/getoptdata.h $(SRC_DIR)/safeguards.h getoptdata.o: $(SRC_DIR)/misc/getoptdata.cpp $(SRC_DIR)/misc/getoptdata.h
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/misc/%.cpp=%.cpp)' $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/misc/%.cpp=%.cpp)'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $< $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<

View File

@@ -28,23 +28,23 @@ endif
all: table/settings.h all: table/settings.h
settingsgen.o: $(SRC_DIR)/settingsgen/settingsgen.cpp $(SRC_DIR)/string_func.h $(SRC_DIR)/strings_type.h $(SRC_DIR)/misc/getoptdata.h $(SRC_DIR)/ini_type.h $(SRC_DIR)/core/smallvec_type.hpp $(SRC_DIR)/safeguards.h settingsgen.o: $(SRC_DIR)/settingsgen/settingsgen.cpp $(SRC_DIR)/string_func.h $(SRC_DIR)/strings_type.h $(SRC_DIR)/misc/getoptdata.h $(SRC_DIR)/ini_type.h $(SRC_DIR)/core/smallvec_type.hpp
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)' $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $< $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
alloc_func.o: $(SRC_DIR)/core/alloc_func.cpp endian_host.h $(SRC_DIR)/safeguards.h alloc_func.o: $(SRC_DIR)/core/alloc_func.cpp endian_host.h
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)' $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $< $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
getoptdata.o: $(SRC_DIR)/misc/getoptdata.cpp $(SRC_DIR)/misc/getoptdata.h $(SRC_DIR)/safeguards.h getoptdata.o: $(SRC_DIR)/misc/getoptdata.cpp $(SRC_DIR)/misc/getoptdata.h
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/misc/%.cpp=%.cpp)' $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/misc/%.cpp=%.cpp)'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $< $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
string.o: $(SRC_DIR)/string.cpp endian_host.h $(SRC_DIR)/safeguards.h string.o: $(SRC_DIR)/string.cpp endian_host.h
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)' $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $< $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
ini_load.o: $(SRC_DIR)/ini_load.cpp $(SRC_DIR)/core/alloc_func.hpp $(SRC_DIR)/core/mem_func.hpp $(SRC_DIR)/ini_type.h $(SRC_DIR)/string_func.h $(SRC_DIR)/safeguards.h ini_load.o: $(SRC_DIR)/ini_load.cpp $(SRC_DIR)/core/alloc_func.hpp $(SRC_DIR)/core/mem_func.hpp $(SRC_DIR)/ini_type.h $(SRC_DIR)/string_func.h
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)' $(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $< $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<

View File

@@ -7,7 +7,7 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/ */
AILog.Info("0.7 API compatibility in effect:"); AILog.Info("0.7 API compatability in effect:");
AILog.Info(" - AITown::GetLastMonthProduction's behaviour has slightly changed."); AILog.Info(" - AITown::GetLastMonthProduction's behaviour has slightly changed.");
AILog.Info(" - AISubsidy::GetDestination returns STATION_INVALID for awarded subsidies."); AILog.Info(" - AISubsidy::GetDestination returns STATION_INVALID for awarded subsidies.");
AILog.Info(" - AISubsidy::GetSource returns STATION_INVALID for awarded subsidies."); AILog.Info(" - AISubsidy::GetSource returns STATION_INVALID for awarded subsidies.");

View File

@@ -7,7 +7,7 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/ */
AILog.Info("1.0 API compatibility in effect."); AILog.Info("1.0 API compatability in effect.");
AIRoad._BuildRoadStation <- AIRoad.BuildRoadStation; AIRoad._BuildRoadStation <- AIRoad.BuildRoadStation;
AIRoad.BuildRoadStation <- function(tile, front, road_veh_type, station_id) AIRoad.BuildRoadStation <- function(tile, front, road_veh_type, station_id)

View File

@@ -7,7 +7,7 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/ */
AILog.Info("1.1 API compatibility in effect."); AILog.Info("1.1 API compatability in effect.");
AICompany.GetCompanyValue <- function(company) AICompany.GetCompanyValue <- function(company)
{ {

View File

@@ -7,4 +7,4 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/ */
AILog.Info("1.2 API compatibility in effect."); AILog.Info("1.2 API compatability in effect.");

View File

@@ -7,4 +7,4 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/ */
AILog.Info("1.3 API compatibility in effect."); AILog.Info("1.3 API compatability in effect.");

View File

@@ -1,4 +1,4 @@
/* $Id$ */ /* $Id: compat_1.3.nut 23969 2012-02-19 19:14:17Z rubidium $ */
/* /*
* This file is part of OpenTTD. * This file is part of OpenTTD.
@@ -6,5 +6,3 @@
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/ */
AILog.Info("1.4 API compatibility in effect.");

View File

@@ -1,8 +0,0 @@
/* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/

View File

@@ -2,12 +2,12 @@
# $Id$ # $Id$
if ! [ -f ai/regression/completeness.sh ]; then if ! [ -f ai/regression/regression.nut ]; then
echo "Make sure you are in the root of OpenTTD before starting this script." echo "Make sure you are in the root of OpenTTD before starting this script."
exit 1 exit 1
fi fi
cat ai/regression/tst_*/main.nut | tr ';' '\n' | awk ' cat ai/regression/regression.nut | tr ';' '\n' | awk '
/^function/ { /^function/ {
for (local in locals) { for (local in locals) {
delete locals[local] delete locals[local]
@@ -61,7 +61,7 @@ cat ai/regression/tst_*/main.nut | tr ';' '\n' | awk '
} }
' | sed 's/ //g' | sort | uniq > tmp.in_regression ' | sed 's/ //g' | sort | uniq > tmp.in_regression
grep 'DefSQ.*Method' ../src/script/api/ai/*.hpp.sq | grep -v 'AIError::' | grep -v 'AIAbstractList::Valuate' | grep -v '::GetClassName' | sed 's/^[^,]*, &//g;s/,[^,]*//g' | sort > tmp.in_api grep 'DefSQ.*Method' ../src/ai/api/*.hpp.sq | grep -v 'AIError::' | grep -v 'AIAbstractList::Valuate' | grep -v '::GetClassName' | sed 's/^[^,]*, &//g;s/,[^,]*//g' | sort > tmp.in_api
diff -u tmp.in_regression tmp.in_api | grep -v '^+++' | grep '^+' | sed 's/^+//' diff -u tmp.in_regression tmp.in_api | grep -v '^+++' | grep '^+' | sed 's/^+//'

View File

@@ -972,7 +972,48 @@ function Regression::Order()
print(" SetStopLocation(): " + AIOrder.SetStopLocation(20, 0, AIOrder.STOPLOCATION_MIDDLE)); print(" SetStopLocation(): " + AIOrder.SetStopLocation(20, 0, AIOrder.STOPLOCATION_MIDDLE));
print(" GetStopLocation(): " + AIOrder.GetStopLocation(20, 0)); print(" GetStopLocation(): " + AIOrder.GetStopLocation(20, 0));
local list = AIVehicleList_Station(3); local list = AIStationList_Vehicle(12);
print("");
print("--StationList_Vehicle--");
print(" Count(): " + list.Count());
list.Valuate(AIStation.GetLocation);
print(" Location ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIStation.GetCargoWaiting, 0);
print(" CargoWaiting(0) ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIStation.GetCargoWaiting, 1);
print(" CargoWaiting(1) ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIStation.GetCargoRating, 1);
print(" CargoRating(1) ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIStation.GetDistanceManhattanToTile, 30000);
print(" DistanceManhattanToTile(30000) ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIStation.GetDistanceSquareToTile, 30000);
print(" DistanceSquareToTile(30000) ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIStation.IsWithinTownInfluence, 0);
print(" IsWithinTownInfluence(0) ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list = AIVehicleList_Station(3);
print(""); print("");
print("--VehicleList_Station--"); print("--VehicleList_Station--");
@@ -1193,6 +1234,10 @@ function Regression::Station()
print(" GetLocation(1000): " + AIStation.GetLocation(1000)); print(" GetLocation(1000): " + AIStation.GetLocation(1000));
print(" GetStationID(33411): " + AIStation.GetStationID(33411)); print(" GetStationID(33411): " + AIStation.GetStationID(33411));
print(" GetStationID(34411): " + AIStation.GetStationID(34411)); print(" GetStationID(34411): " + AIStation.GetStationID(34411));
print(" GetCargoWaiting(0, 0): " + AIStation.GetCargoWaiting(0, 0));
print(" GetCargoWaiting(1000, 0): " + AIStation.GetCargoWaiting(1000, 0));
print(" GetCargoWaiting(0, 1000): " + AIStation.GetCargoWaiting(0, 1000));
print(" GetStationID(33411): " + AIStation.GetStationID(33411)); print(" GetStationID(33411): " + AIStation.GetStationID(33411));
print(" HasRoadType(3, TRAM): " + AIStation.HasRoadType(3, AIRoad.ROADTYPE_TRAM)); print(" HasRoadType(3, TRAM): " + AIStation.HasRoadType(3, AIRoad.ROADTYPE_TRAM));
print(" HasRoadType(3, ROAD): " + AIStation.HasRoadType(3, AIRoad.ROADTYPE_ROAD)); print(" HasRoadType(3, ROAD): " + AIStation.HasRoadType(3, AIRoad.ROADTYPE_ROAD));
@@ -1209,42 +1254,25 @@ function Regression::Station()
print(" GetNearestTown(): " + AIStation.GetNearestTown(10000)); print(" GetNearestTown(): " + AIStation.GetNearestTown(10000));
print(" GetNearestTown(): " + AIStation.GetNearestTown(3)); print(" GetNearestTown(): " + AIStation.GetNearestTown(3));
print(""); local list = AIStationList(AIStation.STATION_BUS_STOP + AIStation.STATION_TRUCK_STOP);
print("--CargoWaiting--");
for (local cargo = 0; cargo <= 1000; cargo += 1000) {
for (local station0 = 0; station0 <= 1000; station0 += 1000) {
print(" GetCargoWaiting(" + station0 + ", " + cargo + "): " +
AIStation.GetCargoWaiting(station0, cargo));
for (local station1 = 0; station1 <= 1000; station1 += 1000) {
print(" GetCargoWaitingFrom(" + station0 + ", " + station1 + ", " + cargo + "): " +
AIStation.GetCargoWaitingFrom(station0, station1, cargo));
print(" GetCargoWaitingVia(" + station0 + ", " + station1 + ", " + cargo + "): " +
AIStation.GetCargoWaitingFrom(station0, station1, cargo));
for (local station2 = 0; station2 <= 1000; station2 += 1000) {
print(" GetCargoWaitingFromVia(" + station0 + ", " + station1 + ", " + station2 + ", " + cargo + "): " +
AIStation.GetCargoWaitingFromVia(station0, station1, station2, cargo));
}
}
}
}
print(""); print("");
print("--CargoPlanned--"); print("--StationList--");
for (local cargo = 0; cargo <= 1000; cargo += 1000) { print(" Count(): " + list.Count());
for (local station0 = 0; station0 <= 1000; station0 += 1000) { list.Valuate(AIStation.GetLocation);
print(" GetCargoPlanned(" + station0 + ", " + cargo + "): " + print(" Location ListDump:");
AIStation.GetCargoPlanned(station0, cargo)); for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
for (local station1 = 0; station1 <= 1000; station1 += 1000) { print(" " + i + " => " + list.GetValue(i));
print(" GetCargoPlannedFrom(" + station0 + ", " + station1 + ", " + cargo + "): " + }
AIStation.GetCargoPlannedFrom(station0, station1, cargo)); list.Valuate(AIStation.GetCargoWaiting, 0);
print(" GetCargoPlannedVia(" + station0 + ", " + station1 + ", " + cargo + "): " + print(" CargoWaiting(0) ListDump:");
AIStation.GetCargoPlannedFrom(station0, station1, cargo)); for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
for (local station2 = 0; station2 <= 1000; station2 += 1000) { print(" " + i + " => " + list.GetValue(i));
print(" GetCargoPlannedFromVia(" + station0 + ", " + station1 + ", " + station2 + ", " + cargo + "): " + }
AIStation.GetCargoPlannedFromVia(station0, station1, station2, cargo)); list.Valuate(AIStation.GetCargoWaiting, 1);
} print(" CargoWaiting(1) ListDump:");
} for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
} print(" " + i + " => " + list.GetValue(i));
} }
} }

View File

@@ -7487,6 +7487,9 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(1000): -1 GetLocation(1000): -1
GetStationID(33411): 4 GetStationID(33411): 4
GetStationID(34411): 65535 GetStationID(34411): 65535
GetCargoWaiting(0, 0): 0
GetCargoWaiting(1000, 0): -1
GetCargoWaiting(0, 1000): -1
GetStationID(33411): 4 GetStationID(33411): 4
HasRoadType(3, TRAM): false HasRoadType(3, TRAM): false
HasRoadType(3, ROAD): false HasRoadType(3, ROAD): false
@@ -7501,81 +7504,17 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetNearestTown(): 65535 GetNearestTown(): 65535
GetNearestTown(): 10 GetNearestTown(): 10
--CargoWaiting-- --StationList--
GetCargoWaiting(0, 0): 0 Count(): 2
GetCargoWaitingFrom(0, 0, 0): 0 Location ListDump:
GetCargoWaitingVia(0, 0, 0): 0 5 => 33421
GetCargoWaitingFromVia(0, 0, 0, 0): 0 4 => 33411
GetCargoWaitingFromVia(0, 0, 1000, 0): -1 CargoWaiting(0) ListDump:
GetCargoWaitingFrom(0, 1000, 0): -1 5 => 0
GetCargoWaitingVia(0, 1000, 0): -1 4 => 0
GetCargoWaitingFromVia(0, 1000, 0, 0): -1 CargoWaiting(1) ListDump:
GetCargoWaitingFromVia(0, 1000, 1000, 0): -1 5 => 0
GetCargoWaiting(1000, 0): -1 4 => 0
GetCargoWaitingFrom(1000, 0, 0): -1
GetCargoWaitingVia(1000, 0, 0): -1
GetCargoWaitingFromVia(1000, 0, 0, 0): -1
GetCargoWaitingFromVia(1000, 0, 1000, 0): -1
GetCargoWaitingFrom(1000, 1000, 0): -1
GetCargoWaitingVia(1000, 1000, 0): -1
GetCargoWaitingFromVia(1000, 1000, 0, 0): -1
GetCargoWaitingFromVia(1000, 1000, 1000, 0): -1
GetCargoWaiting(0, 1000): -1
GetCargoWaitingFrom(0, 0, 1000): -1
GetCargoWaitingVia(0, 0, 1000): -1
GetCargoWaitingFromVia(0, 0, 0, 1000): -1
GetCargoWaitingFromVia(0, 0, 1000, 1000): -1
GetCargoWaitingFrom(0, 1000, 1000): -1
GetCargoWaitingVia(0, 1000, 1000): -1
GetCargoWaitingFromVia(0, 1000, 0, 1000): -1
GetCargoWaitingFromVia(0, 1000, 1000, 1000): -1
GetCargoWaiting(1000, 1000): -1
GetCargoWaitingFrom(1000, 0, 1000): -1
GetCargoWaitingVia(1000, 0, 1000): -1
GetCargoWaitingFromVia(1000, 0, 0, 1000): -1
GetCargoWaitingFromVia(1000, 0, 1000, 1000): -1
GetCargoWaitingFrom(1000, 1000, 1000): -1
GetCargoWaitingVia(1000, 1000, 1000): -1
GetCargoWaitingFromVia(1000, 1000, 0, 1000): -1
GetCargoWaitingFromVia(1000, 1000, 1000, 1000): -1
--CargoPlanned--
GetCargoPlanned(0, 0): 0
GetCargoPlannedFrom(0, 0, 0): 0
GetCargoPlannedVia(0, 0, 0): 0
GetCargoPlannedFromVia(0, 0, 0, 0): 0
GetCargoPlannedFromVia(0, 0, 1000, 0): -1
GetCargoPlannedFrom(0, 1000, 0): -1
GetCargoPlannedVia(0, 1000, 0): -1
GetCargoPlannedFromVia(0, 1000, 0, 0): -1
GetCargoPlannedFromVia(0, 1000, 1000, 0): -1
GetCargoPlanned(1000, 0): -1
GetCargoPlannedFrom(1000, 0, 0): -1
GetCargoPlannedVia(1000, 0, 0): -1
GetCargoPlannedFromVia(1000, 0, 0, 0): -1
GetCargoPlannedFromVia(1000, 0, 1000, 0): -1
GetCargoPlannedFrom(1000, 1000, 0): -1
GetCargoPlannedVia(1000, 1000, 0): -1
GetCargoPlannedFromVia(1000, 1000, 0, 0): -1
GetCargoPlannedFromVia(1000, 1000, 1000, 0): -1
GetCargoPlanned(0, 1000): -1
GetCargoPlannedFrom(0, 0, 1000): -1
GetCargoPlannedVia(0, 0, 1000): -1
GetCargoPlannedFromVia(0, 0, 0, 1000): -1
GetCargoPlannedFromVia(0, 0, 1000, 1000): -1
GetCargoPlannedFrom(0, 1000, 1000): -1
GetCargoPlannedVia(0, 1000, 1000): -1
GetCargoPlannedFromVia(0, 1000, 0, 1000): -1
GetCargoPlannedFromVia(0, 1000, 1000, 1000): -1
GetCargoPlanned(1000, 1000): -1
GetCargoPlannedFrom(1000, 0, 1000): -1
GetCargoPlannedVia(1000, 0, 1000): -1
GetCargoPlannedFromVia(1000, 0, 0, 1000): -1
GetCargoPlannedFromVia(1000, 0, 1000, 1000): -1
GetCargoPlannedFrom(1000, 1000, 1000): -1
GetCargoPlannedVia(1000, 1000, 1000): -1
GetCargoPlannedFromVia(1000, 1000, 0, 1000): -1
GetCargoPlannedFromVia(1000, 1000, 1000, 1000): -1
--Tile-- --Tile--
HasTreeOnTile(): false HasTreeOnTile(): false
@@ -9167,6 +9106,30 @@ ERROR: IsEnd() is invalid as Begin() is never called
SetStopLocation(): true SetStopLocation(): true
GetStopLocation(): 1 GetStopLocation(): 1
--StationList_Vehicle--
Count(): 2
Location ListDump:
5 => 33421
4 => 33411
CargoWaiting(0) ListDump:
5 => 0
4 => 0
CargoWaiting(1) ListDump:
5 => 0
4 => 0
CargoRating(1) ListDump:
5 => -1
4 => -1
DistanceManhattanToTile(30000) ListDump:
5 => 106
4 => 96
DistanceSquareToTile(30000) ListDump:
5 => 8818
4 => 7058
IsWithinTownInfluence(0) ListDump:
5 => 0
4 => 0
--VehicleList_Station-- --VehicleList_Station--
Count(): 1 Count(): 1
Location ListDump: Location ListDump:

View File

@@ -4,9 +4,9 @@ class Regression extends AIInfo {
function GetAuthor() { return "OpenTTD NoAI Developers Team"; } function GetAuthor() { return "OpenTTD NoAI Developers Team"; }
function GetName() { return "Regression"; } function GetName() { return "Regression"; }
function GetShortName() { return "REGR"; } function GetShortName() { return "REGR"; }
function GetDescription() { return "This runs regression-tests on some commands. On the same map the result should always be the same."; } function GetDescription() { return "This runs regression-tests on all commands. On the same map the result should always be the same."; }
function GetVersion() { return 1; } function GetVersion() { return 1; }
function GetAPIVersion() { return "1.5"; } function GetAPIVersion() { return "1.3"; }
function GetDate() { return "2007-03-18"; } function GetDate() { return "2007-03-18"; }
function CreateInstance() { return "Regression"; } function CreateInstance() { return "Regression"; }
} }

View File

@@ -2,11 +2,14 @@
# $Id$ # $Id$
if ! [ -f ai/regression/run.sh ]; then if ! [ -f ai/regression/regression.nut ]; then
echo "Make sure you are in the root of OpenTTD before starting this script." echo "Make sure you are in the root of OpenTTD before starting this script."
exit 1 exit 1
fi fi
cp ai/regression/regression.nut ai/regression/main.nut
cp ai/regression/regression_info.nut ai/regression/info.nut
if [ -f scripts/game_start.scr ]; then if [ -f scripts/game_start.scr ]; then
mv scripts/game_start.scr scripts/game_start.scr.regression mv scripts/game_start.scr scripts/game_start.scr.regression
fi fi
@@ -19,46 +22,27 @@ fi
if [ "$1" = "-g" ]; then if [ "$1" = "-g" ]; then
gdb="gdb --ex run --args " gdb="gdb --ex run --args "
fi fi
if [ -n "$gdb" ]; then
if [ -d "ai/regression/tst_$1" ]; then $gdb ./openttd -x -c ai/regression/regression.cfg $params -g ai/regression/regression.sav
tests="ai/regression/tst_$1"
elif [ -d "ai/regression/tst_$2" ]; then
tests="ai/regression/tst_$2"
else else
tests=ai/regression/tst_* ./openttd -x -c ai/regression/regression.cfg $params -g ai/regression/regression.sav -d script=2 -d misc=9 2>&1 | awk '{ gsub("0x(\\(nil\\)|0+)(x0)?", "0x00000000", $0); gsub("^dbg: \\[script\\]", "", $0); gsub("^ ", "ERROR: ", $0); gsub("ERROR: \\[1\\] ", "", $0); gsub("\\[P\\] ", "", $0); print $0; }' | grep -v '^dbg: \[.*\]' > tmp.regression
fi fi
ret=0 ret=0
for tst in $tests; do if [ -z "$gdb" ]; then
echo -n "Running $tst... " res="`diff -ub ai/regression/regression.txt tmp.regression`"
if [ -z "$res" ]; then
# Make sure that only one info.nut is present for each test run. Otherwise openttd gets confused. echo "Regression test passed!"
cp ai/regression/regression_info.nut $tst/info.nut
sav=$tst/test.sav
if ! [ -f $sav ]; then
sav=ai/regression/empty.sav
fi
if [ -n "$gdb" ]; then
$gdb ./openttd -x -c ai/regression/regression.cfg $params -g $sav
else else
./openttd -x -c ai/regression/regression.cfg $params -g $sav -d script=2 -d misc=9 2>&1 | awk '{ gsub("0x(\\(nil\\)|0+)(x0)?", "0x00000000", $0); gsub("^dbg: \\[script\\]", "", $0); gsub("^ ", "ERROR: ", $0); gsub("ERROR: \\[1\\] ", "", $0); gsub("\\[P\\] ", "", $0); print $0; }' | grep -v '^dbg: \[.*\]' > tmp.regression echo "Regression test failed! Difference:"
echo "$res"
ret=1
fi fi
echo ""
echo "Regression test done"
fi
if [ -z "$gdb" ]; then rm -f ai/regression/main.nut ai/regression/info.nut
res="`diff -ub $tst/result.txt tmp.regression`"
if [ -z "$res" ]; then
echo "passed!"
else
echo "failed! Difference:"
echo "$res"
ret=1
fi
fi
rm $tst/info.nut
done
if [ -f scripts/game_start.scr.regression ]; then if [ -f scripts/game_start.scr.regression ]; then
mv scripts/game_start.scr.regression scripts/game_start.scr mv scripts/game_start.scr.regression scripts/game_start.scr

View File

@@ -1,216 +0,0 @@
/* $Id$ */
class Regression extends AIController {
function Start();
};
function Regression::StationList()
{
local list = AIStationList(AIStation.STATION_BUS_STOP + AIStation.STATION_TRUCK_STOP);
print("");
print("--StationList--");
print(" Count(): " + list.Count());
list.Valuate(AIStation.GetLocation);
print(" Location ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIStation.GetCargoWaiting, 0);
print(" CargoWaiting(0) ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIStation.GetCargoWaiting, 1);
print(" CargoWaiting(1) ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
};
function Regression::StationList_Cargo()
{
print("");
print("--StationList_Cargo--");
for (local mode = AIStationList_Cargo.CM_WAITING; mode <= AIStationList_Cargo.CM_PLANNED; ++mode) {
print(" " + mode);
for (local selector = AIStationList_Cargo.CS_BY_FROM; selector <= AIStationList_Cargo.CS_FROM_BY_VIA ; ++selector) {
print(" " + selector);
local list = AIStationList_Cargo(mode, selector, 6, 0, 7);
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
}
}
};
function Regression::StationList_CargoPlanned()
{
print("");
print("--StationList_CargoPlanned--");
for (local selector = AIStationList_Cargo.CS_BY_FROM; selector <= AIStationList_Cargo.CS_FROM_BY_VIA; ++selector) {
print(" " + selector);
local list = AIStationList_CargoPlanned(selector, 6, 0, 7);
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
}
};
function Regression::StationList_CargoPlannedByFrom()
{
print("");
print("--StationList_CargoPlannedByFrom--");
local list = AIStationList_CargoPlannedByFrom(2, 0);
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
};
function Regression::StationList_CargoPlannedByVia()
{
print("");
print("--StationList_CargoPlannedByVia--");
local list = AIStationList_CargoPlannedByVia(2, 0);
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
};
function Regression::StationList_CargoPlannedViaByFrom()
{
print("");
print("--StationList_CargoPlannedViaByFrom--");
local list = AIStationList_CargoPlannedViaByFrom(6, 0, 7);
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
};
function Regression::StationList_CargoPlannedFromByVia()
{
print("");
print("--StationList_CargoPlannedFromByVia--");
local list = AIStationList_CargoPlannedFromByVia(6, 0, 7);
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
};
function Regression::StationList_CargoWaiting()
{
print("");
print("--StationList_CargoWaiting--");
for (local selector = AIStationList_Cargo.CS_BY_FROM; selector <= AIStationList_Cargo.CS_FROM_BY_VIA; ++selector) {
print(" " + selector);
local list = AIStationList_CargoWaiting(selector, 6, 0, 7);
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
}
};
function Regression::StationList_CargoWaitingByFrom()
{
print("");
print("--StationList_CargoWaitingByFrom--");
local list = AIStationList_CargoWaitingByFrom(2, 0);
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
};
function Regression::StationList_CargoWaitingByVia()
{
print("");
print("--StationList_CargoWaitingByVia--");
local list = AIStationList_CargoWaitingByVia(2, 0);
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
};
function Regression::StationList_CargoWaitingViaByFrom()
{
print("");
print("--StationList_CargoWaitingViaByFrom--");
local list = AIStationList_CargoWaitingViaByFrom(6, 0, 7);
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
};
function Regression::StationList_CargoWaitingFromByVia()
{
print("");
print("--StationList_CargoWaitingFromByVia--");
local list = AIStationList_CargoWaitingFromByVia(2, 0, 2);
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
};
function Regression::StationList_Vehicle()
{
local list = AIStationList_Vehicle(12);
print("");
print("--StationList_Vehicle--");
print(" Count(): " + list.Count());
list.Valuate(AIStation.GetLocation);
print(" Location ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIStation.GetCargoWaiting, 0);
print(" CargoWaiting(0) ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIStation.GetCargoWaiting, 1);
print(" CargoWaiting(1) ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIStation.GetCargoRating, 1);
print(" CargoRating(1) ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIStation.GetDistanceManhattanToTile, 30000);
print(" DistanceManhattanToTile(30000) ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIStation.GetDistanceSquareToTile, 30000);
print(" DistanceSquareToTile(30000) ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
list.Valuate(AIStation.IsWithinTownInfluence, 0);
print(" IsWithinTownInfluence(0) ListDump:");
for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) {
print(" " + i + " => " + list.GetValue(i));
}
}
function Regression::Start()
{
StationList();
StationList_Cargo();
StationList_CargoPlanned();
StationList_CargoPlannedByFrom();
StationList_CargoPlannedByVia();
StationList_CargoPlannedViaByFrom();
StationList_CargoPlannedFromByVia();
StationList_CargoWaiting();
StationList_CargoWaitingByFrom();
StationList_CargoWaitingByVia();
StationList_CargoWaitingViaByFrom();
StationList_CargoWaitingFromByVia();
StationList_Vehicle();
}

View File

@@ -1,127 +0,0 @@
--StationList--
Count(): 5
Location ListDump:
6 => 42341
2 => 41831
7 => 41825
5 => 33421
4 => 33411
CargoWaiting(0) ListDump:
7 => 6
6 => 6
2 => 3
5 => 0
4 => 0
CargoWaiting(1) ListDump:
7 => 0
6 => 0
5 => 0
4 => 0
2 => 0
--StationList_Cargo--
0
0
6 => 6
1
6 => 2
2
2 => 4
7 => 2
3
1
0
7 => 18
6 => 16
2 => 7
1
6 => 8
2 => 3
2
2 => 16
6 => 14
7 => 11
3
6 => 10
2 => 8
--StationList_CargoPlanned--
0
7 => 18
6 => 16
2 => 7
1
6 => 8
2 => 3
2
2 => 16
6 => 14
7 => 11
3
6 => 10
2 => 8
--StationList_CargoPlannedByFrom--
7 => 8
6 => 8
2 => 7
--StationList_CargoPlannedByVia--
2 => 16
6 => 7
--StationList_CargoPlannedViaByFrom--
6 => 8
2 => 3
--StationList_CargoPlannedFromByVia--
6 => 10
2 => 8
--StationList_CargoWaiting--
0
6 => 6
1
6 => 2
2
2 => 4
7 => 2
3
--StationList_CargoWaitingByFrom--
2 => 3
--StationList_CargoWaitingByVia--
6 => 3
--StationList_CargoWaitingViaByFrom--
6 => 2
--StationList_CargoWaitingFromByVia--
6 => 3
--StationList_Vehicle--
Count(): 2
Location ListDump:
5 => 33421
4 => 33411
CargoWaiting(0) ListDump:
5 => 0
4 => 0
CargoWaiting(1) ListDump:
5 => 0
4 => 0
CargoRating(1) ListDump:
5 => -1
4 => -1
DistanceManhattanToTile(30000) ListDump:
5 => 106
4 => 96
DistanceSquareToTile(30000) ListDump:
5 => 8818
4 => 7058
IsWithinTownInfluence(0) ListDump:
5 => 0
4 => 0
ERROR: The script died unexpectedly.

View File

@@ -24,7 +24,6 @@ description.es_ES = Un conjunto de música vacío.
description.et_EE = Muusikakogu ilma muusikata. description.et_EE = Muusikakogu ilma muusikata.
description.fi_FI = Musiikkipaketti, jossa ei ole musiikkia. description.fi_FI = Musiikkipaketti, jossa ei ole musiikkia.
description.fr_FR = Un pack de musiques sans musiques. description.fr_FR = Un pack de musiques sans musiques.
description.ga_IE = Pacáiste ceoil gan aon cheol iarbhír ann.
description.gd_GB = Pacaid ciùil anns nach eil fonn sam bith. description.gd_GB = Pacaid ciùil anns nach eil fonn sam bith.
description.gl_ES = Un conxunto de músicas sen ningunha música. description.gl_ES = Un conxunto de músicas sen ningunha música.
description.hr_HR = Muzički paket bez ikakve muzike. description.hr_HR = Muzički paket bez ikakve muzike.
@@ -34,7 +33,6 @@ description.is_IS = Tónlistarpakki sem er í raun án tónlistar.
description.it_IT = Un pacchetto musicale non contenente alcuna musica. description.it_IT = Un pacchetto musicale non contenente alcuna musica.
description.ja_JP = 空の音楽パック description.ja_JP = 空の音楽パック
description.ko_KR = 실제 음악이 없는 음악 목록입니다. description.ko_KR = 실제 음악이 없는 음악 목록입니다.
description.la_VA = Sarcina musicae sine ulla musica.
description.lb_LU = E Musikpack ouni aktuell Musik. description.lb_LU = E Musikpack ouni aktuell Musik.
description.lt_LT = Muzikos pakas be muzikos. description.lt_LT = Muzikos pakas be muzikos.
description.lv_LV = Mūzikas kopa bez mūzikas description.lv_LV = Mūzikas kopa bez mūzikas

View File

@@ -25,7 +25,6 @@ description.et_EE = Helikogu ilma helideta.
description.eu_ES = Soinurik gabeko soinu pakete bat description.eu_ES = Soinurik gabeko soinu pakete bat
description.fi_FI = Äänipaketti, jossa ei ole ääniä. description.fi_FI = Äänipaketti, jossa ei ole ääniä.
description.fr_FR = Un pack de sons sans sons. description.fr_FR = Un pack de sons sans sons.
description.ga_IE = Pacáiste fuaimeanna gan aon fhuaimeanna ann.
description.gd_GB = Pacaid fhuaimean anns nach eil fuaim sam bith. description.gd_GB = Pacaid fhuaimean anns nach eil fuaim sam bith.
description.gl_ES = Un conxunto de sons sen ningún son description.gl_ES = Un conxunto de sons sen ningún son
description.hr_HR = Zvučni paket bez ikakvih zvukova. description.hr_HR = Zvučni paket bez ikakvih zvukova.
@@ -35,8 +34,7 @@ description.is_IS = Hljóðpakki án hljóðs.
description.it_IT = Un pacchetto sonoro non contenente alcun suono. description.it_IT = Un pacchetto sonoro non contenente alcun suono.
description.ja_JP = 空の効果音パック description.ja_JP = 空の効果音パック
description.ko_KR = 아무런 효과음도 없는 효과음 팩입니다. description.ko_KR = 아무런 효과음도 없는 효과음 팩입니다.
description.la_VA = Sarcina sonorum sine ullis sonis. description.lb_LU = En Soundpack mat all den Sounds.
description.lb_LU = E Soundpack ouni iergendee Sound.
description.lt_LT = Garsų pakas be jokių garsų. description.lt_LT = Garsų pakas be jokių garsų.
description.nb_NO = En lydpakke uten noen lyder. description.nb_NO = En lydpakke uten noen lyder.
description.nl_NL = Een geluidset zonder geluid. description.nl_NL = Een geluidset zonder geluid.

Binary file not shown.

Binary file not shown.

View File

@@ -25,7 +25,6 @@ description.es_ES = Gráficos originales de Transport Tycoon Deluxe versión DOS
description.et_EE = Algse Transport Tycoon Deluxe DOSi versiooni graafika. description.et_EE = Algse Transport Tycoon Deluxe DOSi versiooni graafika.
description.fi_FI = Alkuperäiset Transport Tycoon Deluxen DOS-version grafiikat. description.fi_FI = Alkuperäiset Transport Tycoon Deluxen DOS-version grafiikat.
description.fr_FR = Graphiques originaux de Transport Tycoon Deluxe (version DOS). description.fr_FR = Graphiques originaux de Transport Tycoon Deluxe (version DOS).
description.ga_IE = Grafaicí bunaidhTransport Tycoon Deluxe, eagrán DOS.
description.gd_GB = Grafaigeachd aig an deasachadh DOS tùsail aig Transport Tycoon Deluxe. description.gd_GB = Grafaigeachd aig an deasachadh DOS tùsail aig Transport Tycoon Deluxe.
description.gl_ES = Graficos da edición orixinal de Transport Tycoon Deluxe para DOS. description.gl_ES = Graficos da edición orixinal de Transport Tycoon Deluxe para DOS.
description.hr_HR = Originalna grafika za Transport Tycoon Deluxe DOS izdanje. description.hr_HR = Originalna grafika za Transport Tycoon Deluxe DOS izdanje.
@@ -35,7 +34,6 @@ description.is_IS = Upprunalega grafíkin úr Transport Tycoon Deluxe DOS útgá
description.it_IT = Grafica originale di Transport Tycoon Deluxe, edizione DOS. description.it_IT = Grafica originale di Transport Tycoon Deluxe, edizione DOS.
description.ja_JP = Transport Tycoon Deluxe オリジナル版 グラフィック (DOS) description.ja_JP = Transport Tycoon Deluxe オリジナル版 グラフィック (DOS)
description.ko_KR = 오리지널 트랜스포트 타이쿤 디럭스 도스 에디션의 그래픽입니다. description.ko_KR = 오리지널 트랜스포트 타이쿤 디럭스 도스 에디션의 그래픽입니다.
description.la_VA = Graphica ex editione originale Transport Tycoon Deluxe DOS.
description.lb_LU = Original Transport Tycoon Deluxe DOS Editioun Grafik. description.lb_LU = Original Transport Tycoon Deluxe DOS Editioun Grafik.
description.lt_LT = Originali Transport Tycoon Deluxe DOS leidimo grafika. description.lt_LT = Originali Transport Tycoon Deluxe DOS leidimo grafika.
description.nb_NO = Original grafikk fra Transport Tycoon Deluxe for DOS. description.nb_NO = Original grafikk fra Transport Tycoon Deluxe for DOS.
@@ -72,7 +70,7 @@ TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8
TRGC.GRF = ed446637e034104c5559b32c18afe78d TRGC.GRF = ed446637e034104c5559b32c18afe78d
TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9 TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9
TRGT.GRF = e30e8a398ae86c03dc534a8ac7dfb3b6 TRGT.GRF = e30e8a398ae86c03dc534a8ac7dfb3b6
OPENTTD.GRF = 505d96061556d3bb5cec6234096ec5bc OPENTTD.GRF = 75a93cea2ed455c2fd5dcbda39e53538
[origin] [origin]
default = You can find it on your Transport Tycoon Deluxe CD-ROM. default = You can find it on your Transport Tycoon Deluxe CD-ROM.

View File

@@ -24,7 +24,6 @@ description.es_ES = Sonidos originales de Transport Tycoon Deluxe versión DOS.
description.et_EE = Algse Transport Tycoon Deluxe DOSi versiooni helid. description.et_EE = Algse Transport Tycoon Deluxe DOSi versiooni helid.
description.fi_FI = Alkuperäiset Transport Tycoon Deluxen DOS-version äänet. description.fi_FI = Alkuperäiset Transport Tycoon Deluxen DOS-version äänet.
description.fr_FR = Sons originaux de Transport Tycoon Deluxe (version DOS). description.fr_FR = Sons originaux de Transport Tycoon Deluxe (version DOS).
description.ga_IE = Fuaimeanna bunaidh Transport Tycoon Deluxe, eagrán DOS.
description.gd_GB = Fuaimean aig an deasachadh DOS tùsail aig Transport Tycoon Deluxe. description.gd_GB = Fuaimean aig an deasachadh DOS tùsail aig Transport Tycoon Deluxe.
description.gl_ES = Sons da edición orixinal de Transport Tycoon Deluxe para DOS. description.gl_ES = Sons da edición orixinal de Transport Tycoon Deluxe para DOS.
description.hr_HR = Originalni zvukovi za Transport Tycoon Deluxe DOS izdanje. description.hr_HR = Originalni zvukovi za Transport Tycoon Deluxe DOS izdanje.
@@ -34,7 +33,6 @@ description.is_IS = Upprunalega hljóðið úr Transport Tycoon Deluxe DOS útg
description.it_IT = Suoni originali di Transport Tycoon Deluxe, edizione DOS. description.it_IT = Suoni originali di Transport Tycoon Deluxe, edizione DOS.
description.ja_JP = Transport Tycoon Deluxe オリジナル版 効果音 (DOS) description.ja_JP = Transport Tycoon Deluxe オリジナル版 効果音 (DOS)
description.ko_KR = 오리지널 트랜스포트 타이쿤 도스 에디션의 효과음입니다. description.ko_KR = 오리지널 트랜스포트 타이쿤 도스 에디션의 효과음입니다.
description.la_VA = Soni ex editione originale Transport Tycoon Deluxe DOS.
description.lb_LU = Original Transport Tycoon Deluxe DOS Editioun Sound. description.lb_LU = Original Transport Tycoon Deluxe DOS Editioun Sound.
description.lt_LT = Originalūs Transport Tycoon Deluxe DOS leidimo garsai. description.lt_LT = Originalūs Transport Tycoon Deluxe DOS leidimo garsai.
description.nb_NO = Originale lyder fra Transport Tycoon Deluxe for DOS. description.nb_NO = Originale lyder fra Transport Tycoon Deluxe for DOS.

View File

@@ -25,7 +25,6 @@ description.es_ES = Gráficos originales de Transport Tycoon Deluxe versión DOS
description.et_EE = Algse Transport Tycoon Deluxe DOSi (Saksa) versiooni graafika. description.et_EE = Algse Transport Tycoon Deluxe DOSi (Saksa) versiooni graafika.
description.fi_FI = Alkuperäiset Saksassa julkaistun Transport Tycoon Deluxen DOS-version grafiikat. description.fi_FI = Alkuperäiset Saksassa julkaistun Transport Tycoon Deluxen DOS-version grafiikat.
description.fr_FR = Graphiques originaux de Transport Tycoon Deluxe (version DOS allemande). description.fr_FR = Graphiques originaux de Transport Tycoon Deluxe (version DOS allemande).
description.ga_IE = Grafaicí bunaidhTransport Tycoon Deluxe, eagrán DOS (Gearmánach).
description.gd_GB = Grafaigeachd aig an deasachadh DOS (Gearmailteach) tùsail aig Transport Tycoon Deluxe. description.gd_GB = Grafaigeachd aig an deasachadh DOS (Gearmailteach) tùsail aig Transport Tycoon Deluxe.
description.gl_ES = Graficos da edición orixinal (alemá) de Transport Tycoon Deluxe para DOS. description.gl_ES = Graficos da edición orixinal (alemá) de Transport Tycoon Deluxe para DOS.
description.hr_HR = Originalna grafika za Transport Tycoon Deluxe DOS (Njemački) izdanje. description.hr_HR = Originalna grafika za Transport Tycoon Deluxe DOS (Njemački) izdanje.
@@ -35,7 +34,6 @@ description.is_IS = Upprunalega grafíkin úr Transport Tycoon Deluxe DOS (þýs
description.it_IT = Grafica originale di Transport Tycoon Deluxe (tedesco), edizione DOS. description.it_IT = Grafica originale di Transport Tycoon Deluxe (tedesco), edizione DOS.
description.ja_JP = Transport Tycoon Deluxe オリジナル版 グラフィック (DOS・ドイツ版) description.ja_JP = Transport Tycoon Deluxe オリジナル版 グラフィック (DOS・ドイツ版)
description.ko_KR = 오리지널 트랜스포트 타이쿤 디럭스 도스 에디션(독일)의 그래픽입니다. description.ko_KR = 오리지널 트랜스포트 타이쿤 디럭스 도스 에디션(독일)의 그래픽입니다.
description.la_VA = Graphica ex editione originale Transport Tycoon Deluxe DOS (Germanica).
description.lb_LU = Original Transport Tycoon Deluxe DOS (Däitsch) Editioun Grafik. description.lb_LU = Original Transport Tycoon Deluxe DOS (Däitsch) Editioun Grafik.
description.lt_LT = Originali Transport Tycoon Deluxe DOS (Vokiečių) leidimo grafika. description.lt_LT = Originali Transport Tycoon Deluxe DOS (Vokiečių) leidimo grafika.
description.nb_NO = Original grafikk fra Transport Tycoon Deluxe for DOS (tysk). description.nb_NO = Original grafikk fra Transport Tycoon Deluxe for DOS (tysk).
@@ -72,7 +70,7 @@ TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8
TRGC.GRF = ed446637e034104c5559b32c18afe78d TRGC.GRF = ed446637e034104c5559b32c18afe78d
TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9 TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9
TRGT.GRF = fcde1d7e8a74197d72a62695884b909e TRGT.GRF = fcde1d7e8a74197d72a62695884b909e
OPENTTD.GRF = 505d96061556d3bb5cec6234096ec5bc OPENTTD.GRF = 75a93cea2ed455c2fd5dcbda39e53538
[origin] [origin]
default = You can find it on your Transport Tycoon Deluxe CD-ROM. default = You can find it on your Transport Tycoon Deluxe CD-ROM.

View File

@@ -25,7 +25,6 @@ description.es_ES = Gráficos originales de Transport Tycoon Deluxe versión Win
description.et_EE = Algse Transport Tycoon Deluxe Windowsi versiooni graafika. description.et_EE = Algse Transport Tycoon Deluxe Windowsi versiooni graafika.
description.fi_FI = Alkuperäiset Transport Tycoon Deluxen Windows-version grafiikat. description.fi_FI = Alkuperäiset Transport Tycoon Deluxen Windows-version grafiikat.
description.fr_FR = Graphiques originaux de Transport Tycoon Deluxe (version Windows). description.fr_FR = Graphiques originaux de Transport Tycoon Deluxe (version Windows).
description.ga_IE = Grafaicí bunaidhTransport Tycoon Deluxe, eagrán Windows.
description.gd_GB = Grafaigeachd aig an deasachadh Windows tùsail aig Transport Tycoon Deluxe. description.gd_GB = Grafaigeachd aig an deasachadh Windows tùsail aig Transport Tycoon Deluxe.
description.gl_ES = Graficos da edición orixinal de Transport Tycoon Deluxe para Windows. description.gl_ES = Graficos da edición orixinal de Transport Tycoon Deluxe para Windows.
description.hr_HR = Originalna grafika za Transport Tycoon Deluxe Windows izdanje. description.hr_HR = Originalna grafika za Transport Tycoon Deluxe Windows izdanje.
@@ -35,7 +34,6 @@ description.is_IS = Upprunalega grafíkin úr Transport Tycoon Deluxe Windows ú
description.it_IT = Grafica originale di Transport Tycoon Deluxe, edizione Windows. description.it_IT = Grafica originale di Transport Tycoon Deluxe, edizione Windows.
description.ja_JP = Transport Tycoon Deluxe オリジナル版 グラフィック (Windows) description.ja_JP = Transport Tycoon Deluxe オリジナル版 グラフィック (Windows)
description.ko_KR = 오리지널 트랜스포트 타이쿤 디럭스 윈도 에디션의 그래픽입니다. description.ko_KR = 오리지널 트랜스포트 타이쿤 디럭스 윈도 에디션의 그래픽입니다.
description.la_VA = Graphica ex editione originale Transport Tycoon Deluxe Windows.
description.lb_LU = Original Transport Tycoon Deluxe Windows Editioun Grafik. description.lb_LU = Original Transport Tycoon Deluxe Windows Editioun Grafik.
description.lt_LT = Originali Transport Tycoon Deluxe Windows leidimo grafika. description.lt_LT = Originali Transport Tycoon Deluxe Windows leidimo grafika.
description.nb_NO = Original grafikk fra Transport Tycoon Deluxe for Windows. description.nb_NO = Original grafikk fra Transport Tycoon Deluxe for Windows.
@@ -72,7 +70,7 @@ TRGIR.GRF = 0c2484ff6be49fc63a83be6ab5c38f32
TRGCR.GRF = 3668f410c761a050b5e7095a2b14879b TRGCR.GRF = 3668f410c761a050b5e7095a2b14879b
TRGHR.GRF = 06bf2b7a31766f048baac2ebe43457b1 TRGHR.GRF = 06bf2b7a31766f048baac2ebe43457b1
TRGTR.GRF = de53650517fe661ceaa3138c6edb0eb8 TRGTR.GRF = de53650517fe661ceaa3138c6edb0eb8
OPENTTD.GRF = 505d96061556d3bb5cec6234096ec5bc OPENTTD.GRF = 75a93cea2ed455c2fd5dcbda39e53538
[origin] [origin]
default = You can find it on your Transport Tycoon Deluxe CD-ROM. default = You can find it on your Transport Tycoon Deluxe CD-ROM.

View File

@@ -24,7 +24,6 @@ description.es_ES = Música original de Transport Tycoon Deluxe versión Windows
description.et_EE = Algse Transport Tycoon Deluxe Windowsi versiooni muusika. description.et_EE = Algse Transport Tycoon Deluxe Windowsi versiooni muusika.
description.fi_FI = Alkuperäinen Transport Tycoon Deluxen Windows-version musiikki. description.fi_FI = Alkuperäinen Transport Tycoon Deluxen Windows-version musiikki.
description.fr_FR = Musiques originales de Transport Tycoon Deluxe (version Windows). description.fr_FR = Musiques originales de Transport Tycoon Deluxe (version Windows).
description.ga_IE = Ceol bunaidh Transport Tycoon Deluxe, eagrán Windows.
description.gd_GB = Ceòl aig an deasachadh Windows tùsail aig Transport Tycoon Deluxe. description.gd_GB = Ceòl aig an deasachadh Windows tùsail aig Transport Tycoon Deluxe.
description.gl_ES = Música da edición orixinal de Transport Tycoon Deluxe para Windows. description.gl_ES = Música da edición orixinal de Transport Tycoon Deluxe para Windows.
description.hr_HR = Originalna muzika za Transport Tycoon Deluxe Windows izdanje. description.hr_HR = Originalna muzika za Transport Tycoon Deluxe Windows izdanje.
@@ -34,8 +33,7 @@ description.is_IS = Upprunalega tónlistin úr Transport Tycoon Deluxe Windows
description.it_IT = Musica originale di Transport Tycoon Deluxe, edizione Windows. description.it_IT = Musica originale di Transport Tycoon Deluxe, edizione Windows.
description.ja_JP = Transport Tycoon Deluxe オリジナル版 音楽 (Windows) description.ja_JP = Transport Tycoon Deluxe オリジナル版 音楽 (Windows)
description.ko_KR = 오리지널 트랜스포트 타이쿤 디럭스 윈도 에디션의 음악입니다. description.ko_KR = 오리지널 트랜스포트 타이쿤 디럭스 윈도 에디션의 음악입니다.
description.la_VA = Musica ex editione originale Transport Tycoon Deluxe Windows. description.lb_LU = Original Transport Tycoon Deluxe Windows Editioun Music.
description.lb_LU = Original Transport Tycoon Deluxe Windows Editioun Musik.
description.lt_LT = Originali Transport Tycoon Deluxe Windows leidimo muzika. description.lt_LT = Originali Transport Tycoon Deluxe Windows leidimo muzika.
description.lv_LV = Oriģinālā Transport Tycoon Deluxe Windows izdevuma mūzika. description.lv_LV = Oriģinālā Transport Tycoon Deluxe Windows izdevuma mūzika.
description.nb_NO = Original musikk fra Transport Tycoon Deluxe for Windows. description.nb_NO = Original musikk fra Transport Tycoon Deluxe for Windows.

View File

@@ -24,7 +24,6 @@ description.es_ES = Sonidos originales de Transport Tycoon Deluxe versión Windo
description.et_EE = Algse Transport Tycoon Deluxe Windowsi versiooni helid. description.et_EE = Algse Transport Tycoon Deluxe Windowsi versiooni helid.
description.fi_FI = Alkuperäiset Transport Tycoon Deluxen Windows-version äänet. description.fi_FI = Alkuperäiset Transport Tycoon Deluxen Windows-version äänet.
description.fr_FR = Sons originaux de Transport Tycoon Deluxe (version Windows). description.fr_FR = Sons originaux de Transport Tycoon Deluxe (version Windows).
description.ga_IE = Fuaimeanna bunaidh Transport Tycoon Deluxe, eagrán Windows.
description.gd_GB = Fuaimean aig an deasachadh Windows tùsail aig Transport Tycoon Deluxe. description.gd_GB = Fuaimean aig an deasachadh Windows tùsail aig Transport Tycoon Deluxe.
description.gl_ES = Sons da edición orixinal de Transport Tycoon Deluxe para Windows. description.gl_ES = Sons da edición orixinal de Transport Tycoon Deluxe para Windows.
description.hr_HR = Originalni zvukovi za Transport Tycoon Deluxe Windows izdanje. description.hr_HR = Originalni zvukovi za Transport Tycoon Deluxe Windows izdanje.
@@ -34,7 +33,6 @@ description.is_IS = Upprunalega hljóðið úr Transport Tycoon Deluxe Windows
description.it_IT = Suoni originali di Transport Tycoon Deluxe, edizione Windows. description.it_IT = Suoni originali di Transport Tycoon Deluxe, edizione Windows.
description.ja_JP = Transport Tycoon Deluxe オリジナル版 効果音 (Windows) description.ja_JP = Transport Tycoon Deluxe オリジナル版 効果音 (Windows)
description.ko_KR = 오리지널 트랜스포트 타이쿤 디럭스 윈도 에디션의 효과음입니다. description.ko_KR = 오리지널 트랜스포트 타이쿤 디럭스 윈도 에디션의 효과음입니다.
description.la_VA = Soni ex editione originale Transport Tycoon Deluxe Windows.
description.lb_LU = Original Transport Tycoon Deluxe Windows Editioun Sound. description.lb_LU = Original Transport Tycoon Deluxe Windows Editioun Sound.
description.lt_LT = Originalūs Transport Tycoon Deluxe Windows leidimo garsai. description.lt_LT = Originalūs Transport Tycoon Deluxe Windows leidimo garsai.
description.nb_NO = Originale lyder fra Transport Tycoon Deluxe for Windows. description.nb_NO = Originale lyder fra Transport Tycoon Deluxe for Windows.

View File

@@ -7,7 +7,7 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/ */
GSLog.Info("1.2 API compatibility in effect."); GSLog.Info("1.2 API compatability in effect.");
GSTown._SetGrowthRate <- GSTown.SetGrowthRate; GSTown._SetGrowthRate <- GSTown.SetGrowthRate;
GSTown.SetGrowthRate <- function(town_id, days_between_town_growth) GSTown.SetGrowthRate <- function(town_id, days_between_town_growth)
@@ -16,10 +16,3 @@ GSTown.SetGrowthRate <- function(town_id, days_between_town_growth)
if (days_between_town_growth == 0) days_between_town_growth = GSTown.TOWN_GROWTH_NORMAL; if (days_between_town_growth == 0) days_between_town_growth = GSTown.TOWN_GROWTH_NORMAL;
return GSTown._SetGrowthRate(town_id, days_between_town_growth); return GSTown._SetGrowthRate(town_id, days_between_town_growth);
} }
/* 1.5 adds a game element reference to the news. */
GSNews._Create <- GSNews.Create;
GSNews.Create <- function(type, text, company)
{
return GSNews._Create(type, text, company, GSNews.NR_NONE, 0);
}

View File

@@ -7,7 +7,7 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/ */
GSLog.Info("1.3 API compatibility in effect."); GSLog.Info("1.3 API compatability in effect.");
GSTown._SetGrowthRate <- GSTown.SetGrowthRate; GSTown._SetGrowthRate <- GSTown.SetGrowthRate;
GSTown.SetGrowthRate <- function(town_id, days_between_town_growth) GSTown.SetGrowthRate <- function(town_id, days_between_town_growth)
@@ -16,10 +16,3 @@ GSTown.SetGrowthRate <- function(town_id, days_between_town_growth)
if (days_between_town_growth == 0) days_between_town_growth = GSTown.TOWN_GROWTH_NORMAL; if (days_between_town_growth == 0) days_between_town_growth = GSTown.TOWN_GROWTH_NORMAL;
return GSTown._SetGrowthRate(town_id, days_between_town_growth); return GSTown._SetGrowthRate(town_id, days_between_town_growth);
} }
/* 1.5 adds a game element reference to the news. */
GSNews._Create <- GSNews.Create;
GSNews.Create <- function(type, text, company)
{
return GSNews._Create(type, text, company, GSNews.NR_NONE, 0);
}

View File

@@ -1,4 +1,4 @@
/* $Id$ */ /* $Id: compat_1.3.nut 24469 2012-08-13 19:33:17Z yexo $ */
/* /*
* This file is part of OpenTTD. * This file is part of OpenTTD.
@@ -6,12 +6,3 @@
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/ */
GSLog.Info("1.4 API compatibility in effect.");
/* 1.5 adds a game element reference to the news. */
GSNews._Create <- GSNews.Create;
GSNews.Create <- function(type, text, company)
{
return GSNews._Create(type, text, company, GSNews.NR_NONE, 0);
}

View File

@@ -1,8 +0,0 @@
/* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/

View File

@@ -1,180 +1,3 @@
1.5.3 (2015-12-01)
------------------------------------------------------------------------
(None)
1.5.3-RC1 (2015-11-01)
------------------------------------------------------------------------
- Fix: When selecting a refit cargo for orders, do not check whether the vehicle is in a depot or station, and do not ask whether the vehicle currently allows station-refitting. Also hide the refit cost for orders, it is not predictable (r27428)
- Fix: Use the NewGRF railtype sorting order in the infrastructure window (r27427)
- Fix: Crash when switching to or taking over companies, when an order window of a vehicle of the new company was opened. Now close those windows [FS#5842] (r27425)
- Fix: Towns did not connect roads to existing roads, unless they had only a single roadbit. Otoh, towns also tried to connect to single roadbit tiles such as tunnels and depots, even though they were not connectable in the direction of interest [FS#6374] (r27424)
- Fix: When towns expanded single-bit roadtiles using a grid-layout, they used the layout position of the neighbouring tile (r27423)
- Fix: Aircraft picked the wrong airport entry point, if airports were rotated by 180 degree [FS#6341] (r27422)
- Fix: Consider text and icon sizes when drawing the client list [FS#6265] (r27421)
- Fix: GrowTownAtRoad sometimes returned false, even when a house was built [FS#6362] (r27420)
- Fix: CmdSellRailWagon did not revert all actions properly when no orderlist could be allocated [FS#6369] (r27419)
- Fix: Desync due to incorrect storage of segments with different railtype in the YAPF cache [FS#6329] [FS#6379] (r27418)
- Fix: When a dedicated server was paused with no clients, the master server advertisement interval was slowed, causing deadvertisement of the server [FS#6368] (r27400)
- Fix: [Makefile] Game script directory and compat*.nut were never installed on *nix (r27399)
- Fix: There are two different availability conditions for fdatasync in the manpage. Use them both, since at least on some MinGW versions one is not enough (r27389)
- Fix: win32 sound driver failed to report errors (r27383)
- Fix: Clickareas in settings tree were misaligned when the filter warning was displayed, if the setting height was defined by the icons instead of the font [FS#6358] (r27366)
- Fix: Center settings filter warning also vertically, and also in case of multiple lines (r27365)
1.5.2 (2015-09-01)
------------------------------------------------------------------------
(None)
1.5.2-RC1 (2015-08-01)
------------------------------------------------------------------------
- Change: Auto-complete partial roads when building level-crossings [FS#6283] (r27309)
- Fix: Do not rerandomise the town name when only cost-estimating the founding [FS#6332] (r27341)
- Fix: Make variety distribution not assume that sea level is at height 0.2 / 3 * TGPGetMaxHeight() [FS#6335] (r27331, r27330, r27329, r27328)
- Fix: Remove corner-case optimisation for line drawing, which failed for dashed lines (r27324)
- Fix: Clipping of inclined lines did not account for the 'horizontal width' being bigger than the 'real width' (r27323, r27322)
- Fix: Incorrect owner assignment when adding/removing road/tram to/from bridges [FS#6317] (r27313, r27312)
- Fix: Mark infrastructure window dirty in more cases (r27311)
- Fix: Prevent breaking of tram-reversal points by adding more road pieces [FS#6283] (r27308)
- Fix: Error message window with manager face failed with GUI zoom [FS#6259] (r27307)
- Fix: Account for road-bridges and drive-through-stops in CanFollowRoad [FS#6320] (r27306, r27305)
- Fix: Password window layout with GUI zoom [FS#6321] (r27304, r27303)
- Fix: Speed-only timetables got assigned times in stations [FS#6313] (r27302, r27301)
- Fix: Enforce the company's default service intervals when purchasing another company [FS#6254] (r27282, r27281)
- Fix: Cloning/autoreplace/autorenew did not copy custom service intervals (r27280)
1.5.1 (2015-06-01)
------------------------------------------------------------------------
(None)
1.5.1-RC1 (2015-05-08)
------------------------------------------------------------------------
- Fix: Do not consider road junctions with trivial dead ends as branch points during town growth [FS#6245] (r27260, r27259, r27244)
- Fix: ScriptList::RemoveList failed to remove a list from itself [FS#6287] (r27258)
- Fix: Combined button+dropdown widgets in order and autoreplace GUI had incorrect hitbox when using GUI zoom [FS#6270] (r27255)
- Fix: When building a lock on DC_AUTO-removable water-based objects, the water class was always set to canal [FS#6264] (r27254)
- Fix: When crossing tram tracks with railroads, cost of extra roads was not being counted [FS#6282] (r27253)
- Fix: Invalid infrastructure counting when crossing tram tracks with railroads [FS#6281] (r27252)
- Fix: Broken error message in configure [FS#6286] (r27250)
- Fix: In some cases town growth failure was considered as success [FS#6240] (r27249, r27247)
- Fix: Town labels on smallmap and zoomed-out viewports were not centered [FS#6257] (r27248)
- Fix: Removing a rail waypoint used the remove-rail-station cost [FS#6251] (r27245)
- Fix: Duplicate frees due to pool item classes not having copy constructors [FS#6285] (r27243)
- Fix: Crash when no AIs were installed due to improper handling of non-ASCII characters by the string pointer lexer [FS#6272] (r27233)
- Fix: Compilation on DragonflyBSD [FS#6274] (r27224, r27223)
- Fix: Use the current maximum speed as limited by bridges, orders etc. for all vehicle types alike when considering increased smoke emissions of vehicles [FS#6278] (r27222)
- Fix: Multi-value keys in the desktop entry shall end with a trailing separator (r27221)
- Fix: Draw path reservation on the whole bridge, not only on the bridge heads (r27209)
- Fix: Draw correct overlay sprites for path reservations on bridges and tunnels (r27208)
1.5.0 (2015-04-01)
------------------------------------------------------------------------
- Fix: [NewGRF] Add Misc. GRF Feature Flag 6 to enable the second rocky tile set [FS#6260] (r27200)
1.5.0-RC1 (2015-03-18)
------------------------------------------------------------------------
- Feature: [NewGRF] Display relative offset changes in the sprite aligner [FS#6236] (r27174)
- Fix: Original road vehicle acceleration crashed for vehicles taking over [FS#6255] (r27190)
- Fix: GCC 5 compilation (r27185, r27183)
- Fix: Data race due to lazy initialisation of objects [FS#5969] (r27178)
- Fix: Compilation with MinGW64 (r27176)
- Fix: Use the regular clipping functions in the sprite aligner instead of some magic [FS#6237] (r27173)
- Fix: Windows randomly drops SetCursorPos calls, breaking the RMB-scrolling [FS#6238] (r27172)
1.5.0-beta2 (2015-02-24)
------------------------------------------------------------------------
- Feature: [NoGo] Game scripts can point to a location, station, industry, or town when publishing news (r27164)
- Feature: Allow changing max heightlevel in scenario editor (r27151)
- Feature: Make use of both rocky tile sets from the base graphics (r27117)
- Change: Scale (non-custom) default window sizes according to GUI zoom (r27147)
- Change: Make statusbar and chat-entry window use the same width as the toolbar (r27146)
- Change: The chatbox-width setting now uses percent of screen width instead of pixels (r27144)
- Change: [NewGRF] Interpret negative positions in industry layouts depending on GRF version (r27138)
- Fix: [SDL, Windows] Right-mouse-button scrolling scrolled/jumped too far, when OpenTTD lagged during mouse event processing (r27167)
- Fix: Toolbars were not invalidated when changing max-vehicles settings [FS#6204] (r27163)
- Fix: Tile selection was drawn outside of map in some cases [FS#6208] (r27162)
- Fix: Reimplement the viewport drawing algorithm [FS#6156] [FS#6206] (r27161)
- Fix: Issues with smallmap and viewport coordinates and transformations (r27160, r27159, r27158)
- Fix: Mark bridge middle tiles dirty when building/removing/changing bridges (r27157)
- Fix: Rounding and unit-conversion inconsistencies in calls to MarkAllViewportsDirty (r27148)
- Fix: Oilrig empty-tile checks were incorrect due to wrong TileIndexDiff->TileIndexDiffC conversion (r27137)
- Fix: Misalignment in generate world window in case of small fonts (r27135)
- Fix: Dragging of free wagons in depot failed with GUI zoom (r27133)
- Fix: Reduce memory footprint of map array by shuffling its members [FS#6218] (r27132, r27126)
- Fix: Dropdown- and tooltip-windows should not steal the focus (r27131)
- Fix: [NewGRF] Action 7/9 condition 0A failed for present, but disabled, NewGRF (r27119)
- Fix: Road vehicles could not reverse to be sent to depots when the following tile has the right type to run on, but could not be entered [FS#6183] (r27107)
- Fix: Use the actual max speed of the vehicle in front when determining if a RV can overtake [FS#6176] (r27106)
- Fix: grow_counter was not properly bounded by growth_rate, but by some other value used to calculate growth_rate [FS#6195] (r27105)
- Fix: [Script] Support 64 bits integers in ScriptLists [FS#6194] (r27104)
- Fix: [Script] Money values would end up wrong in strings when outside the bounds of a 32 bits integer [FS#6194] (r27102)
1.5.0-beta1 (2014-12-24)
------------------------------------------------------------------------
- Feature: Support .txt.gz and -txt.xz changelog, readme and license files in basesets, NewGRFs, etc (r27035, r27034)
- Feature: More height levels [FS#4126] (r27010)
- Feature: Latin translation (r26993)
- Feature: Add option to choose normal, double or quad-size interface (r26990)
- Feature: [Script] Swap method for script lists (r26894)
- Feature: [Script] ScriptStationList_Cargo for sorting cargo by from and via (r26893)
- Feature: [Script] API for retrieving planned flow (r26892)
- Feature: [CargoDist] Predict links for station-autorefitting vehicles (r26889)
- Feature: Setting for limiting the height of bridges (r26882)
- Feature: Make aircraft ascend/descend when they are too close to the ground or too far away (r26866)
- Feature: Allow hiding of non-interesting engines in the GUI (r26805, r26804)
- Feature: Vehicle sorting in autoreplace GUI [FS#1640] (r26800)
- Feature: [NewGRF] Advanced visual effects with multiple effect sprites independent of spawning model (r26988, r26747)
- Feature: Warn about missing industries after generating a map (r26729)
- Feature: Upgrade currently active NewGRFs to newest installed version (r26613)
- Feature: Save and load grfid and md5sum of NewGRFs in config file (r26611)
- Feature: Select an editable preset name for saving (r26610)
- Feature: Cancel cargo delivery from industries/houses to stations after about 21 months of not having picked up any of the cargo (r26582)
- Feature: Give a warning when a plane's orders tell it to use a runway which is too short for it [FS#6009] (r26566)
- Feature: [Script] Extended API for CargoDist (r26557)
- Feature: Show measured order times in timetable GUI also when not timetabled (r26550)
- Feature: Prompt for confirmation when deleting a vehicle group (r26455)
- Feature: Hierarchical vehicle subgroups (r26450)
- Feature: Allow more sound sleep for dedicated servers when there's nothing to do and nobody paying attention (r26449)
- Feature: [NewGRF] Add vehicle modflag 1 (unloading in progress) (r26430)
- Change: Improvements to the man page (r27091, r27012)
- Change: Allow to set the granularity of the tooltip hover time in milliseconds instead of seconds. New default value is 250ms (r26815)
- Change: Follow SI recommendation about spaces between numbers and units [FS#6086] (r26733)
- Change: [CargoDist] Save locations instead of distances in link graphs to reduce size (r26646)
- Change: [Squirrel] Make the internal integer for scripts always 64 bits, so scripts behave the same on 32 and 64 bit architectures and money can be represented properly (r26585, r26584)
- Change: Reshuffle advanced settings tree (r26614, r26536)
- Change: Add backend-independent config-file setting to disable 8bpp video modes, and disable 8bpp by default (r26522)
- Fix: [OS/2] Compile again [FS#6186] (r27092)
- Fix: Compilation with freetype2 version 2.5.4 and newer [FS#6185] (r27079)
- Fix: Variable 47 used the carge translation table of the wrong GRF in case of callback 1D [FS#6182] (r27075)
- Fix: Some lists did not use natural string sorting [FS#6172] (r27063)
- Fix: Mercurial version detection failed if personal presets were configured (r27059)
- Fix: [OSX] Don't require double-press from non-dead console hotkeys [FS#5812] (r27046)
- Fix: Crash when having the vehicle list opened from a buoy or oil rig when the buoy/oil rig is removed (r27030)
- Fix: Unit number was not always fully shown in depots [FS#6102] (r27014)
- Fix: [CargoDist] Reserve cargo only after unloading finished or if the vehicle has the desired cargo already [FS#6110] (r26918)
- Fix: [Squirrel] Loading a value saved as boolean caused it to be of type integer instead of boolean (r26785)
- Fix: [Squirrel] Harden string handling (r26777)
- Fix: [OSX] Implement more of the text editing API to prevent crashes and improve IME support [FS#5972] (r26758)
- Fix: Incorrect saving of order backups [FS#6066] (r26700)
- Fix: Ordering a vehicle to a competitor's rail waypoint displayed an error message. Ignore the click as is done for the other order types to competitor's stuff [FS#6059] (r26692)
- Fix: [Script] Loading/parsing of info .nuts was done in the same VM, causing e.g. constants to break the loading of info of other scripts [FS#5973] (r26617)
- Fix: [CargoDist] Improve estimation of link capacitites (r26549)
- Remove: A bunch of archaic settings from the GUI (r26528, r26526, r26525)
1.4.4 (2014-10-21)
------------------------------------------------------------------------
(None)
1.4.4-RC1 (2014-10-08) 1.4.4-RC1 (2014-10-08)
------------------------------------------------------------------------ ------------------------------------------------------------------------
- Fix: Image widgets stored 32bit SpriteID in uint16 (r26971) - Fix: Image widgets stored 32bit SpriteID in uint16 (r26971)

View File

@@ -526,10 +526,10 @@ check_params() {
log 1 " PREPROCESSOR is only available for OSX" log 1 " PREPROCESSOR is only available for OSX"
exit 1 exit 1
fi fi
# OS only allows DETECT, UNIX, OSX, FREEBSD, DRAGONFLY, OPENBSD, NETBSD, MORPHOS, BEOS, HAIKU, SUNOS, CYGWIN, MINGW, OS2, DOS, WINCE, and PSP # OS only allows DETECT, UNIX, OSX, FREEBSD, OPENBSD, MORPHOS, BEOS, HAIKU, SUNOS, CYGWIN, MINGW, OS2, DOS, WINCE, and PSP
if [ -z "`echo $os | egrep '^(DETECT|UNIX|OSX|FREEBSD|DRAGONFLY|OPENBSD|NETBSD|HPUX|MORPHOS|BEOS|HAIKU|SUNOS|CYGWIN|MINGW|OS2|DOS|WINCE|PSP)$'`" ]; then if [ -z "`echo $os | egrep '^(DETECT|UNIX|OSX|FREEBSD|OPENBSD|NETBSD|HPUX|MORPHOS|BEOS|HAIKU|SUNOS|CYGWIN|MINGW|OS2|DOS|WINCE|PSP)$'`" ]; then
log 1 "configure: error: invalid option --os=$os" log 1 "configure: error: invalid option --os=$os"
log 1 " Available options are: --os=[DETECT|UNIX|OSX|FREEBSD|DRAGONFLY|OPENBSD|NETBSD|HPUX|MORPHOS|BEOS|HAIKU|SUNOS|CYGWIN|MINGW|OS2|DOS|WINCE|PSP]" log 1 " Available options are: --os=[DETECT|UNIX|OSX|FREEBSD|OPENBSD|NETBSD|HPUX|MORPHOS|BEOS|HAIKU|SUNOS|CYGWIN|MINGW|OS2|DOS|WINCE|PSP]"
exit 1 exit 1
fi fi
# cpu_type can be either 32 or 64 # cpu_type can be either 32 or 64
@@ -862,7 +862,7 @@ check_params() {
endian="PREPROCESSOR" endian="PREPROCESSOR"
fi fi
log 1 "checking endianness... $endian" log 1 "checking endianess... $endian"
# Suppress language errors when there is a version defined, indicating a release # Suppress language errors when there is a version defined, indicating a release
# It just isn't pretty if any release produces warnings in the languages. # It just isn't pretty if any release produces warnings in the languages.
@@ -1037,7 +1037,7 @@ check_params() {
log 1 "checking revision... svn detection (tag)" log 1 "checking revision... svn detection (tag)"
elif [ -d "$ROOT_DIR/.git" ] && [ -n "`git help 2>/dev/null`" ]; then elif [ -d "$ROOT_DIR/.git" ] && [ -n "`git help 2>/dev/null`" ]; then
log 1 "checking revision... git detection" log 1 "checking revision... git detection"
elif [ -d "$ROOT_DIR/.hg" ] && [ -n "`HGPLAIN= hg help 2>/dev/null`" ]; then elif [ -d "$ROOT_DIR/.hg" ] && [ -n "`hg help 2>/dev/null`" ]; then
log 1 "checking revision... hg detection" log 1 "checking revision... hg detection"
elif [ -f "$ROOT_DIR/.ottdrev" ]; then elif [ -f "$ROOT_DIR/.ottdrev" ]; then
log 1 "checking revision... source tarball" log 1 "checking revision... source tarball"
@@ -1054,7 +1054,7 @@ check_params() {
fi fi
if [ "$doc_dir" = "1" ]; then if [ "$doc_dir" = "1" ]; then
if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "DRAGONFLY" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then
doc_dir="share/doc/openttd" doc_dir="share/doc/openttd"
else else
doc_dir="$data_dir/docs" doc_dir="$data_dir/docs"
@@ -1064,7 +1064,7 @@ check_params() {
fi fi
if [ "$icon_theme_dir" = "1" ]; then if [ "$icon_theme_dir" = "1" ]; then
if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "DRAGONFLY" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then
icon_theme_dir="share/icons/hicolor" icon_theme_dir="share/icons/hicolor"
else else
icon_theme_dir="" icon_theme_dir=""
@@ -1098,7 +1098,7 @@ check_params() {
if [ "$man_dir" = "1" ]; then if [ "$man_dir" = "1" ]; then
# add manpage on UNIX systems # add manpage on UNIX systems
if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "DRAGONFLY" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OSX" ]; then if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OSX" ]; then
man_dir="share/man/man6" man_dir="share/man/man6"
else else
man_dir="" man_dir=""
@@ -1109,7 +1109,7 @@ check_params() {
if [ "$menu_dir" = "1" ]; then if [ "$menu_dir" = "1" ]; then
# add a freedesktop menu item only for some UNIX systems # add a freedesktop menu item only for some UNIX systems
if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "DRAGONFLY" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then
menu_dir="share/applications" menu_dir="share/applications"
else else
menu_dir="" menu_dir=""
@@ -1538,7 +1538,7 @@ make_cflags_and_ldflags() {
fi fi
fi fi
if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "FREEBSD" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then
LIBS="$LIBS -lpthread" LIBS="$LIBS -lpthread"
fi fi
@@ -1565,6 +1565,10 @@ make_cflags_and_ldflags() {
LIBS="$LIBS -pthread" LIBS="$LIBS -pthread"
fi fi
if [ "$os" = "FREEBSD" ]; then
LIBS="$LIBS -lpthread"
fi
if [ "$os" = "OSX" ]; then if [ "$os" = "OSX" ]; then
LDFLAGS="$LDFLAGS -framework Cocoa" LDFLAGS="$LDFLAGS -framework Cocoa"
@@ -1606,7 +1610,7 @@ make_cflags_and_ldflags() {
fi fi
# Most targets act like UNIX, just with some additions # Most targets act like UNIX, just with some additions
if [ "$os" = "BEOS" ] || [ "$os" = "HAIKU" ] || [ "$os" = "OSX" ] || [ "$os" = "MORPHOS" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "DRAGONFLY" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OS2" ]; then if [ "$os" = "BEOS" ] || [ "$os" = "HAIKU" ] || [ "$os" = "OSX" ] || [ "$os" = "MORPHOS" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OS2" ]; then
CFLAGS="$CFLAGS -DUNIX" CFLAGS="$CFLAGS -DUNIX"
fi fi
# And others like Windows # And others like Windows
@@ -2264,54 +2268,52 @@ detect_awk() {
detect_os() { detect_os() {
if [ "$os" = "DETECT" ]; then if [ "$os" = "DETECT" ]; then
# Detect UNIX, OSX, FREEBSD, DRAGONFLY, OPENBSD, NETBSD, HPUX, MORPHOS, BEOS, SUNOS, CYGWIN, MINGW, OS2, DOS, WINCE, and PSP # Detect UNIX, OSX, FREEBSD, OPENBSD, NETBSD, HPUX, MORPHOS, BEOS, SUNOS, CYGWIN, MINGW, OS2, DOS, WINCE, and PSP
# Try first via dumpmachine, then via uname # Try first via dumpmachine, then via uname
os=`echo "$host" | tr '[A-Z]' '[a-z]' | $awk ' os=`echo "$host" | tr '[A-Z]' '[a-z]' | $awk '
/linux/ { print "UNIX"; exit} /linux/ { print "UNIX"; exit}
/darwin/ { print "OSX"; exit} /darwin/ { print "OSX"; exit}
/freebsd/ { print "FREEBSD"; exit} /freebsd/ { print "FREEBSD"; exit}
/dragonfly/ { print "DRAGONFLY"; exit} /openbsd/ { print "OPENBSD"; exit}
/openbsd/ { print "OPENBSD"; exit} /netbsd/ { print "NETBSD"; exit}
/netbsd/ { print "NETBSD"; exit} /hp-ux/ { print "HPUX"; exit}
/hp-ux/ { print "HPUX"; exit} /morphos/ { print "MORPHOS"; exit}
/morphos/ { print "MORPHOS"; exit} /beos/ { print "BEOS"; exit}
/beos/ { print "BEOS"; exit} /haiku/ { print "HAIKU"; exit}
/haiku/ { print "HAIKU"; exit} /sunos/ { print "SUNOS"; exit}
/sunos/ { print "SUNOS"; exit} /solaris/ { print "SUNOS"; exit}
/solaris/ { print "SUNOS"; exit} /cygwin/ { print "CYGWIN"; exit}
/cygwin/ { print "CYGWIN"; exit} /mingw/ { print "MINGW"; exit}
/mingw/ { print "MINGW"; exit} /os2/ { print "OS2"; exit}
/os2/ { print "OS2"; exit} /dos/ { print "DOS"; exit}
/dos/ { print "DOS"; exit} /wince/ { print "WINCE"; exit}
/wince/ { print "WINCE"; exit} /psp/ { print "PSP"; exit}
/psp/ { print "PSP"; exit}
'` '`
if [ -z "$os" ]; then if [ -z "$os" ]; then
os=`LC_ALL=C uname | tr '[A-Z]' '[a-z]' | $awk ' os=`LC_ALL=C uname | tr '[A-Z]' '[a-z]' | $awk '
/linux/ { print "UNIX"; exit} /linux/ { print "UNIX"; exit}
/darwin/ { print "OSX"; exit} /darwin/ { print "OSX"; exit}
/freebsd/ { print "FREEBSD"; exit} /freebsd/ { print "FREEBSD"; exit}
/dragonfly/ { print "DRAGONFLY"; exit} /openbsd/ { print "OPENBSD"; exit}
/openbsd/ { print "OPENBSD"; exit} /netbsd/ { print "NETBSD"; exit}
/netbsd/ { print "NETBSD"; exit} /hp-ux/ { print "HPUX"; exit}
/hp-ux/ { print "HPUX"; exit} /morphos/ { print "MORPHOS"; exit}
/morphos/ { print "MORPHOS"; exit} /beos/ { print "BEOS"; exit}
/beos/ { print "BEOS"; exit} /haiku/ { print "HAIKU"; exit}
/haiku/ { print "HAIKU"; exit} /sunos/ { print "SUNOS"; exit}
/sunos/ { print "SUNOS"; exit} /cygwin/ { print "CYGWIN"; exit}
/cygwin/ { print "CYGWIN"; exit} /mingw/ { print "MINGW"; exit}
/mingw/ { print "MINGW"; exit} /os\/2/ { print "OS2"; exit}
/os\/2/ { print "OS2"; exit} /gnu/ { print "UNIX"; exit}
/gnu/ { print "UNIX"; exit}
'` '`
fi fi
if [ -z "$os" ]; then if [ -z "$os" ]; then
log 1 "detecting OS... none detected" log 1 "detecting OS... none detected"
log 1 "I couldn't detect your OS. Please use --os=OS to force one" log 1 "I couldn't detect your OS. Please use --os=OS to force one"
log 1 "Allowed values are: UNIX, OSX, FREEBSD, DRAGONFLY, OPENBSD, NETBSD, MORPHOS, HPUX, BEOS, HAIKU, SUNOS, CYGWIN, MINGW, OS2, DOS, WINCE, and PSP" log 1 "Allowed values are: UNIX, OSX, FREEBSD, OPENBSD, NETBSD, MORPHOS, HPUX, BEOS, HAIKU, SUNOS, CYGWIN, MINGW, OS2, DOS, WINCE, and PSP"
exit 1 exit 1
fi fi
@@ -2940,7 +2942,7 @@ detect_icu() {
# It was forced, so it should be found. # It was forced, so it should be found.
if [ "$with_icu" != "1" ]; then if [ "$with_icu" != "1" ]; then
log 1 "configure: error: icu-config couldn't be found" log 1 "configure: error: icu-config couldn't be found"
log 1 "configure: error: you supplied '$with_icu', but it seems invalid" log 1 "configure: error: you supplied '$with_icuconfig', but it seems invalid"
exit 1 exit 1
fi fi
@@ -3181,9 +3183,9 @@ detect_grfcodec() {
log 2 " returned $version" log 2 " returned $version"
log 2 " exit code $ret" log 2 " exit code $ret"
if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version" -lt "985" ]; then if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version" -lt "949" ]; then
if [ -n "$version" ] && [ "$version" -lt "985" ]; then if [ -n "$version" ] && [ "$version" -lt "949" ]; then
log 1 "checking grfcodec... needs at least version 6.0.5 (r985), disabled" log 1 "checking grfcodec... needs at least version 6.0.2 (r949), disabled"
else else
log 1 "checking grfcodec... not found" log 1 "checking grfcodec... not found"
fi fi
@@ -3223,9 +3225,9 @@ detect_nforenum() {
log 2 " returned $version" log 2 " returned $version"
log 2 " exit code $ret" log 2 " exit code $ret"
if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version" -lt "985" ]; then if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version" -lt "949" ]; then
if [ -n "$version" ] && [ "$version" -lt "985" ]; then if [ -n "$version" ] && [ "$version" -lt "949" ]; then
log 1 "checking nforenum... needs at least version 6.0.5 (r985), disabled" log 1 "checking nforenum... needs at least version 6.0.2 (r949), disabled"
else else
log 1 "checking nforenum... not found" log 1 "checking nforenum... not found"
fi fi
@@ -3590,9 +3592,9 @@ showhelp() {
echo " --awk=AWK the awk to use in configure [awk]" echo " --awk=AWK the awk to use in configure [awk]"
echo " --lipo=LIPO the lipo to use (OSX ONLY) [HOST-lipo]" echo " --lipo=LIPO the lipo to use (OSX ONLY) [HOST-lipo]"
echo " --os=OS the OS we are compiling for [DETECT]" echo " --os=OS the OS we are compiling for [DETECT]"
echo " DETECT/UNIX/OSX/FREEBSD/DRAGONFLY/OPENBSD/" echo " DETECT/UNIX/OSX/FREEBSD/OPENBSD/NETBSD/"
echo " NETBSD/MORPHOS/HPUX/BEOS/SUNOS/CYGWIN/" echo " MORPHOS/HPUX/BEOS/SUNOS/CYGWIN/MINGW/OS2/"
echo " MINGW/OS2/DOS/WINCE/PSP/HAIKU" echo " DOS/WINCE/PSP/HAIKU"
echo " --endian=ENDIAN set the endian of the HOST (AUTO/LE/BE)" echo " --endian=ENDIAN set the endian of the HOST (AUTO/LE/BE)"
echo "" echo ""
echo "Paths:" echo "Paths:"

View File

@@ -106,7 +106,7 @@ Table of contents
The important thing here is: The detection of the Desync is The important thing here is: The detection of the Desync is
only an ultimate failure detection. It does not give any only an ultimate failure detection. It does not give any
indication on when the Desync happened. The Desync may after indication on when the Desync happened. The Desync may after
all have occurred long ago, and just did not affect the checksum all have occured long ago, and just did not affect the checksum
up to now. The checksum may have matched 10 times or more up to now. The checksum may have matched 10 times or more
since the Desync happend, and only now the Desync has spiraled since the Desync happend, and only now the Desync has spiraled
enough to finally affect the checksum. (There was once a desync enough to finally affect the checksum. (There was once a desync
@@ -194,7 +194,6 @@ Table of contents
- Get the same version of OpenTTD as the original server was running. - Get the same version of OpenTTD as the original server was running.
- Uncomment/enable the define 'DEBUG_DUMP_COMMANDS' in - Uncomment/enable the define 'DEBUG_DUMP_COMMANDS' in
'src/network/network_func.h'. 'src/network/network_func.h'.
(DEBUG_FAILED_DUMP_COMMANDS is explained later)
- Put the 'commands-out.log' into the root save folder, and rename - Put the 'commands-out.log' into the root save folder, and rename
it to 'commands.log'. it to 'commands.log'.
- Run 'openttd -D -d desync=3 -g startsavegame.sav'. - Run 'openttd -D -d desync=3 -g startsavegame.sav'.
@@ -218,11 +217,6 @@ Table of contents
the last dmp_cmds that reproduces the replay and the first one the last dmp_cmds that reproduces the replay and the first one
that fails. that fails.
If the replay does not succeed without mismatch, you can check the logs
whether there were failed commands. Then you may try to replay with
DEBUG_FAILED_DUMP_COMMANDS enabled. If the replay then fails, the
command test-run of the failed command modified the game state.
If you have the original 'dmp_cmds_*.sav', you can also compare those If you have the original 'dmp_cmds_*.sav', you can also compare those
savegames with your own ones from the replay. You can also comment/disable savegames with your own ones from the replay. You can also comment/disable
the 'NOT_REACHED' mentioned above, to get another 'dmp_cmds_*.sav' from the 'NOT_REACHED' mentioned above, to get another 'dmp_cmds_*.sav' from

View File

@@ -15,60 +15,20 @@
For a graphical representation of the tile-layout have a look at For a graphical representation of the tile-layout have a look at
<a href="landscape_grid.html">Landscape grid</a> page. <a href="landscape_grid.html">Landscape grid</a> page.
</p> </p>
<p>Nine attributes (counting &quot;<span style="font-weight: bold;">type</span>&quot; and <p>Eight attributes (counting &quot;<span style="font-weight: bold;">type_height</span>&quot;) hold the informations about a tile.<BR>
&quot;<span style="font-weight: bold;">height</span>&quot;) hold the informations about a tile.<BR>
These attributes are referred to as These attributes are referred to as
&quot;<span style="font-weight: bold;">type</span>", &quot;<span style="font-weight: bold;">type_height</span>",
&quot;<span style="font-weight: bold;">height</span>",
&quot;<span style="font-weight: bold;">m1</span>&quot;, &quot;<span style="font-weight: bold;">m2</span>&quot;, &quot;<span style="font-weight: bold;">m1</span>&quot;, &quot;<span style="font-weight: bold;">m2</span>&quot;,
&quot;<span style="font-weight: bold;">m3</span>&quot;, &quot;<span style="font-weight: bold;">m4</span>&quot;, &quot;<span style="font-weight: bold;">m3</span>&quot;, &quot;<span style="font-weight: bold;">m4</span>&quot;,
&quot;<span style="font-weight: bold;">m5</span>&quot;, &quot;<span style="font-weight: bold;">m6</span>&quot; &quot;<span style="font-weight: bold;">m5</span>&quot;, &quot;<span style="font-weight: bold;">m6</span>&quot;
and "<span style="font-weight: bold;">m7</span>".<br> and "<span style="font-weight: bold;">m7</span>".<br>
The most important value is the class of a tile, stored in the upper 4 bits The most important value is the class of a tile, stored in the upper 4 bits
of the <span style="font-weight: bold;">type</span> attribute. of the <span style="font-weight: bold;">type_height</span> attribute. The lower 4 bits are used to encode the height and
slope data.
</p> </p>
Frequently repeating patterns: Frequently repeating patterns:
<ul> <ul>
<li><span style="font-weight: bold;">type</span>
<ul>
<li>
<a name="type"></a>
Bits 7..4:
<table border="1" style="width: 30em;">
<tr bgcolor="#CCCCCC"><td colspan="2">The tile type.</td></tr>
<tr><td style="width: 5em;"><tt>00</tt></td><td>Ground</td></tr>
<tr><td><tt>01</tt></td><td>Railway tracks</td></tr>
<tr><td><tt>02</tt></td><td>Roads</td></tr>
<tr><td><tt>03</tt></td><td>Town building</td></tr>
<tr><td><tt>04</tt></td><td>Trees</td></tr>
<tr><td><tt>05</tt></td><td>Station tiles</td></tr>
<tr><td><tt>06</tt></td><td>Water</td></tr>
<tr><td><tt>07</tt></td><td>Void</td></tr>
<tr><td><tt>08</tt></td><td>Industries</td></tr>
<tr><td><tt>09</tt></td><td>Tunnel / bridge</td></tr>
<tr><td><tt>0A</tt></td><td>Objects</td></tr>
</table>
</li>
Bits 3..2:
<table border="1" style="width: 30em;">
<tr bgcolor="#CCCCCC"><td colspan="2">Presence and direction of bridge above.</td></tr>
<tr><td style="width: 5em;"><tt>00</tt></td><td>no bridge</td></tr>
<tr><td><tt>01</tt></td><td>Axis X (North-East)</td></tr>
<tr><td><tt>02</tt></td><td>Axis Y (South-West)</td></tr>
</table>
<li>
<a name="tropic_zone"></a>
Bits 1..0:
<table border="1" style="width: 30em;">
<tr bgcolor="#CCCCCC"><td colspan="2">Only meaningfull in tropic climate. It contains the definition of the available zones</td></tr>
<tr><td style="width: 5em;"><tt>00</tt></td><td>normal</td></tr>
<tr><td><tt>01</tt></td><td>desert</td></tr>
<tr><td><tt>02</tt></td><td>rain forest</td></tr>
</table>
In any other climate these 2 bits are theoretically free of use, however using them does not seem useful.
</li>
</ul>
<li><span style="font-weight: bold;">m1</span> <li><span style="font-weight: bold;">m1</span>
<ul> <ul>
<li> <li>
@@ -98,6 +58,32 @@
</li> </li>
</ul> </ul>
</li> </li>
<li><span style="font-weight: bold;">m6</span>
<ul>
<li>
<a name="bridge_direction"></a>
Bits 7..6:
<table border="1" style="width: 30em;">
<tr bgcolor="#CCCCCC"><td colspan="2">Presence and direction of bridge above, for tiles that support this.</td></tr>
<tr><td style="width: 5em;"><tt>00</tt></td><td>no bridge</td></tr>
<tr><td><tt>01</tt></td><td>Axis X (North-East)</td></tr>
<tr><td><tt>02</tt></td><td>Axis Y (South-West)</td></tr>
</table>
Some tiles, such as houses do not support bridges over them and use these bits for other purposes.
</li>
<li>
<a name="tropic_zone"></a>
Bits 1..0:
<table border="1" style="width: 30em;">
<tr bgcolor="#CCCCCC"><td colspan="2">Only meaningfull in tropic climate. It contains the definition of the available zones</td></tr>
<tr><td style="width: 5em;"><tt>00</tt></td><td>normal</td></tr>
<tr><td><tt>01</tt></td><td>desert</td></tr>
<tr><td><tt>02</tt></td><td>rain forest</td></tr>
</table>
In any other climate these 2 bits are theoretically free of use, however using them does not seem useful.
</li>
</ul>
</li>
<li><span style="font-weight: bold;">m7:</span><br> <li><span style="font-weight: bold;">m7:</span><br>
Animation frame/state. Used for houses, industries, objects and stations. Animation frame/state. Used for houses, industries, objects and stations.
</li> </li>
@@ -210,7 +196,9 @@
</tr> </tr>
</table> </table>
</li> </li>
<li>m6 bits 7..6 : Possibility of a bridge above, in the <a href="#bridge_direction">direction specified</a></li>
<li>m6 bits 4..2: type of hedge on NW border of the tile</li> <li>m6 bits 4..2: type of hedge on NW border of the tile</li>
<li>m6 bits 1..0 : <a href="#tropic_zone">Tropic zone definition</a></li>
</ul> </ul>
</td> </td>
</tr> </tr>
@@ -522,6 +510,8 @@
<li>m5 bit 4: pbs reservation state</li> <li>m5 bit 4: pbs reservation state</li>
</ul> </ul>
</li> </li>
<li>m6 bits 7..6 : Possibility of a bridge above, in the <a href="#bridge_direction">direction specified</a></li>
<li>m6 bits 1..0 : <a href="#tropic_zone">Tropic zone definition</a></li>
</ul> </ul>
</td> </td>
</tr> </tr>
@@ -676,6 +666,8 @@
<li>m7 bits 4..0: <a href="#OwnershipInfo">owner</a> of the road type 0 (normal road)</li> <li>m7 bits 4..0: <a href="#OwnershipInfo">owner</a> of the road type 0 (normal road)</li>
</ul> </ul>
</li> </li>
<li>m6 bits 7..6 : Possibility of a bridge above, in the <a href="#bridge_direction">direction specified</a></li>
<li>m6 bits 1..0 : <a href="#tropic_zone">Tropic zone definition</a></li>
</ul> </ul>
</td> </td>
</tr> </tr>
@@ -722,6 +714,7 @@
<li>bits 7..2 : lift position (for houses type 04 and 05)</li> <li>bits 7..2 : lift position (for houses type 04 and 05)</li>
</ul> </ul>
</li> </li>
<li>bits 1..0 : tropic zone specifier</li>
</ul> </ul>
</li> </li>
<li>m7 : <li>m7 :
@@ -843,6 +836,7 @@
</tr> </tr>
</table> </table>
</li> </li>
<li>m6 bits 1..0 : <a href="#tropic_zone">Tropic zone definition</a></li>
</ul> </ul>
</td> </td>
</tr> </tr>
@@ -976,6 +970,7 @@
<li>m6 bits 5..3: the station type (rail, airport, truck, bus, oilrig, dock, buoy, waypoint)</li> <li>m6 bits 5..3: the station type (rail, airport, truck, bus, oilrig, dock, buoy, waypoint)</li>
<li>m6 bit 2: pbs reservation state for railway stations/waypoints</li> <li>m6 bit 2: pbs reservation state for railway stations/waypoints</li>
<li>m6 bits 1..0 : <a href="#tropic_zone">Tropic zone definition</a></li>
<li>m7 bits 4..0: <a href="#OwnershipInfo">owner</a> of road (road stops)</li> <li>m7 bits 4..0: <a href="#OwnershipInfo">owner</a> of road (road stops)</li>
<li>m7 bits 7..6: present road types (road stops)</li> <li>m7 bits 7..6: present road types (road stops)</li>
<li>m7: animation frame (railway stations/waypoints, airports)</li> <li>m7: animation frame (railway stations/waypoints, airports)</li>
@@ -1088,6 +1083,8 @@
</tr> </tr>
</table> </table>
</li> </li>
<li>m6 bits 7..6 : Possibility of a bridge above, in the <a href="#bridge_direction">direction specified</a></li>
<li>m6 bits 1..0 : <a href="#tropic_zone">Tropic zone definition</a></li>
</ul> </ul>
</td> </td>
</tr> </tr>
@@ -1105,7 +1102,7 @@
<tr bgcolor="#CCCCCC"> <tr bgcolor="#CCCCCC">
<td valign=top nowrap><strong><a name="Class8"><tt> 8</tt></a></strong></td> <td valign=top nowrap><strong><a name="Class8"><tt> 8</tt></a></strong></td>
<td><strong>Industries </strong></td> <td><strong>Industry tile </strong></td>
</tr> </tr>
<tr> <tr>
<td valign=top nowrap>&nbsp;</td> <td valign=top nowrap>&nbsp;</td>
@@ -1429,6 +1426,7 @@
</li> </li>
<li>m6 bits 5..3: random triggers (NewGRF)</li> <li>m6 bits 5..3: random triggers (NewGRF)</li>
<li>m6 bit 2: bit 8 of type (see m5)</li> <li>m6 bit 2: bit 8 of type (see m5)</li>
<li>m6 bits 1..0 : <a href="#tropic_zone">Tropic zone definition</a></li>
<li>m7: animation frame</li> <li>m7: animation frame</li>
</ul> </ul>
</td> </td>
@@ -1579,6 +1577,8 @@
</tr> </tr>
</table> </table>
</li> </li>
<li>m6 bits 7..6 : Possibility of a bridge above, in the <a href="#bridge_direction">direction specified</a></li>
<li>m6 bits 1..0 : <a href="#tropic_zone">Tropic zone definition</a></li>
<li>m7 bits 4..0: <a href="#OwnershipInfo">owner</a> of road</li> <li>m7 bits 4..0: <a href="#OwnershipInfo">owner</a> of road</li>
<li>m7 bit 5 set = on snow or desert</li> <li>m7 bit 5 set = on snow or desert</li>
<li>m7 bits 7..6: present road types for road</li> <li>m7 bits 7..6: present road types for road</li>
@@ -1599,6 +1599,8 @@
<li>m2: index into the array of objects, bits 0 to 15 (upper bits in m5)</li> <li>m2: index into the array of objects, bits 0 to 15 (upper bits in m5)</li>
<li>m3: random bits</li> <li>m3: random bits</li>
<li>m5: index into the array of objects, bits 16 to 23 (lower bits in m2)</li> <li>m5: index into the array of objects, bits 16 to 23 (lower bits in m2)</li>
<li>m6 bits 7..6 : Possibility of a bridge above, in the <a href="#bridge_direction">direction specified</a></li>
<li>m6 bits 1..0 : <a href="#tropic_zone">Tropic zone definition</a></li>
<li>m7: animation counter</li> <li>m7: animation counter</li>
</ul> </ul>
</td> </td>

View File

@@ -28,14 +28,13 @@ the array so you can quickly see what is used and what is not.
</ul> </ul>
<p> <p>
<ul> <ul>
<li><span style="font-weight: bold;">type</span> - 8 bits in size, tile class (bits 4..7), bridge (bits 2..3) tropic zone (bits 0..1, only valid in tropic climate)</li> <li><span style="font-weight: bold;">type_height</span> - 8 bits in size, stores tile height (lower 4 bits) and tile class (upper 4 bits)</li>
<li><span style="font-weight: bold;">height</span> - 8 bits in size, stores tile height</li>
<li><span style="font-weight: bold;">m1</span> - 8 bits in size, used to identify the owner of that tile (eg piece of rail, bridge, etc.)</li> <li><span style="font-weight: bold;">m1</span> - 8 bits in size, used to identify the owner of that tile (eg piece of rail, bridge, etc.)</li>
<li><span style="font-weight: bold;">m2</span> - 16 bits in size, used to identify the index of the given tile (object) in the (object-)array</li> <li><span style="font-weight: bold;">m2</span> - 16 bits in size, used to identify the index of the given tile (object) in the (object-)array</li>
<li><span style="font-weight: bold;">m3</span> - 8 bits in size, is used for general storage</li> <li><span style="font-weight: bold;">m3</span> - 8 bits in size, is used for general storage</li>
<li><span style="font-weight: bold;">m4</span> - 8 bits in size, is used for general storage</li> <li><span style="font-weight: bold;">m4</span> - 8 bits in size, is used for general storage</li>
<li><span style="font-weight: bold;">m5</span> - 8 bits in size, is used for general storage</li> <li><span style="font-weight: bold;">m5</span> - 8 bits in size, is used for general storage</li>
<li><span style="font-weight: bold;">m6</span> - 8 bits in size, is used for general storage</li> <li><span style="font-weight: bold;">m6</span> - 8 bits in size, special meaning : lower 2 bits only valid in tropic climate, upper 2 bits for bridges</li>
<li><span style="font-weight: bold;">m7</span> - 8 bits in size, is used for general storage</li> <li><span style="font-weight: bold;">m7</span> - 8 bits in size, is used for general storage</li>
</ul> </ul>
@@ -43,8 +42,7 @@ the array so you can quickly see what is used and what is not.
<tbody> <tbody>
<tr> <tr>
<th colspan=2>class</th> <th colspan=2>class</th>
<th>type (8)</th> <th>type_height (8)</th>
<th>height (8)</th>
<th>m1 (8)</th> <th>m1 (8)</th>
<th>m2 (16)</th> <th>m2 (16)</th>
<th>m3 (8)</th> <th>m3 (8)</th>
@@ -57,7 +55,6 @@ the array so you can quickly see what is used and what is not.
<td colspan=2 class="caption">bits</td> <td colspan=2 class="caption">bits</td>
<td class="bits">7654 3210</td> <td class="bits">7654 3210</td>
<td class="bits">7654 3210</td> <td class="bits">7654 3210</td>
<td class="bits">7654 3210</td>
<td class="bits">FEDC BA98 7654 3210</td> <td class="bits">FEDC BA98 7654 3210</td>
<td class="bits">7654 3210</td> <td class="bits">7654 3210</td>
<td class="bits">7654 3210</td> <td class="bits">7654 3210</td>
@@ -69,75 +66,69 @@ the array so you can quickly see what is used and what is not.
<td rowspan="2">0</td> <td rowspan="2">0</td>
<td class="caption">ground</td> <td class="caption">ground</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OOO</span><span class="option">~ ~~~~</span></td> <td class="bits"><span class="free">OOO</span><span class="option">~ ~~~~</span></td>
<td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
<td class="bits">XXXX <span class="free">OOOO</span></td> <td class="bits">XXXX <span class="free">OOOO</span></td>
<td class="bits">XXXX XX<span class="free">OO</span></td> <td class="bits">XXXX XX<span class="free">OO</span></td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OOO</span>X XX<span class="free">OO</span></td> <td class="bits">XX<span class="free">O</span>X XXXX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
</tr> </tr>
<tr> <tr>
<td class="caption">farmland</td> <td class="caption">farmland</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td>
<td class="bits">XXXX XXXX XXXX XXXX</td> <td class="bits">XXXX XXXX XXXX XXXX</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits"><span class="free">OOO</span>X XX<span class="free">OO</span></td> <td class="bits">XX<span class="free">O</span>X XXXX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
</tr> </tr>
<tr> <tr>
<td rowspan=3>1</td> <td rowspan=3>1</td>
<td class="caption">rail</td> <td class="caption">rail</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OOO</span>X XXXX</td> <td class="bits"><span class="free">OOO</span>X XXXX</td>
<td class="bits"><span class="free">OOOO</span> XXXX <span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO</span> XXXX <span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="free">OOOO</span> XXXX</td> <td class="bits"><span class="free">OOOO</span> XXXX</td>
<td class="bits"><span class="free">OOOO</span> XXXX</td> <td class="bits"><span class="free">OOOO</span> XXXX</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits">XX<span class="free">OO OO</span>XX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
</tr> </tr>
<tr> <tr>
<td class="caption">rail with signals</td> <td class="caption">rail with signals</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td>
<td class="bits"><span class="free">OOOO</span> XXXX XXXX XXXX</td> <td class="bits"><span class="free">OOOO</span> XXXX XXXX XXXX</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits">XX<span class="free">OO OO</span>XX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
</tr> </tr>
<tr> <tr>
<td class="caption">depot</td> <td class="caption">depot</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td>
<td class="bits">XXXX XXXX XXXX XXXX</td> <td class="bits">XXXX XXXX XXXX XXXX</td>
<td class="bits"><span class="free">OOOO</span> XXXX</td> <td class="bits"><span class="free">OOOO</span> XXXX</td>
<td class="bits"><span class="free">OOOO</span> XXXX</td> <td class="bits"><span class="free">OOOO</span> XXXX</td>
<td class="bits">XX<span class="free">O</span>X <span class="free">OO</span>XX</td> <td class="bits">XX<span class="free">O</span>X <span class="free">OO</span>XX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits">XX<span class="free">OO OO</span>XX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
</tr> </tr>
<tr> <tr>
<td rowspan=3>2</td> <td rowspan=3>2</td>
<td class="caption">road</td> <td class="caption">road</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OOO</span>X XXXX</td> <td class="bits"><span class="free">OOO</span>X XXXX</td>
<td class="bits">XXXX XXXX XXXX XXXX</td> <td class="bits">XXXX XXXX XXXX XXXX</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OO</span>XX X<span class="free">OOO</span></td> <td class="bits">XXXX X<span class="free">O</span>XX</td>
<td class="bits">XXX<span class="free">O</span> XXXX</td> <td class="bits">XXX<span class="free">O</span> XXXX</td>
</tr> </tr>
<tr> <tr>
@@ -145,11 +136,10 @@ the array so you can quickly see what is used and what is not.
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">XXXX<span class="free"> OOO</span>X</td> <td class="bits">XXXX<span class="free"> OOO</span>X</td>
<td class="bits"><span class="free">OO</span>XX X<span class="free">OOO</span></td> <td class="bits">XXXX X<span class="free">O</span>XX</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
</tr> </tr>
<tr> <tr>
@@ -157,11 +147,10 @@ the array so you can quickly see what is used and what is not.
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td>
<td class="bits">XXXX <span class="free">OOOO</span></td> <td class="bits">XXXX <span class="free">OOOO</span></td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits">XX<span class="free">OO OO</span>XX</td> <td class="bits">XX<span class="free">OO OO</span>XX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits">XX<span class="free">OO OO</span>XX</td>
<td class="bits">XXX<span class="free">O</span> XXXX</td> <td class="bits">XXX<span class="free">O</span> XXXX</td>
</tr> </tr>
<tr> <tr>
@@ -169,38 +158,35 @@ the array so you can quickly see what is used and what is not.
<td class="caption">house</td> <td class="caption">house</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">XXXX XXXX</td>
<td class="bits">XXXX XXXX XXXX XXXX</td> <td class="bits">XXXX XXXX XXXX XXXX</td>
<td class="bits">XX<span class="free">O</span><span class="option">~ ~~</span>XX</td> <td class="bits">XX<span class="free">O</span><span class="option">~ ~~</span>XX</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">XXX<span class="abuse">X XXXX</span></td> <td class="bits">XXX<span class="abuse">X XXXX</span></td>
<td class="bits"><span class="abuse">XXXX XX</span><span class="free">OO</span></td> <td class="bits"><span class="abuse">XXXX XX</span>XX</td>
<td class="bits">XXXX <span class="abuse">XXXX</span></td> <td class="bits">XXXX <span class="abuse">XXXX</span></td>
</tr> </tr>
<tr> <tr>
<td>4</td> <td>4</td>
<td class="caption">trees</td> <td class="caption">trees</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OOO</span><span class="option">~ ~~~~</span></td> <td class="bits"><span class="free">OOO</span><span class="option">~ ~~~~</span></td>
<td class="bits"><span class="free">OOOO OOO</span>X XXXX XXXX</td> <td class="bits"><span class="free">OOOO OOO</span>X XXXX XXXX</td>
<td class="bits"><span class="option">~~</span>XX XXXX</td> <td class="bits"><span class="option">~~</span>XX XXXX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits">XX<span class="free">OO O</span>XXX</td> <td class="bits">XX<span class="free">OO O</span>XXX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OO</span>XX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
</tr> </tr>
<tr> <tr>
<td rowspan=7>5</td> <td rowspan=7>5</td>
<td class="caption">rail station</td> <td class="caption">rail station</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">O</span>XXX XXXX</td> <td class="bits"><span class="free">O</span>XXX XXXX</td>
<td class="bits">XXXX XXXX XXXX XXXX</td> <td class="bits">XXXX XXXX XXXX XXXX</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OO</span>XX XX<span class="free">OO</span></td> <td class="bits"><span class="free">OO</span>XX XXXX</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
</tr> </tr>
<tr> <tr>
@@ -213,18 +199,16 @@ the array so you can quickly see what is used and what is not.
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td>
</tr> </tr>
<tr> <tr>
<td class="caption">road stop</td> <td class="caption">road stop</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td>
<td class="bits">XXXX <span class="free">OOOO</span></td> <td class="bits">XXXX <span class="free">OOOO</span></td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="option">~~~~ ~</span>XXX</td> <td class="bits"><span class="option">~~~~ ~</span>XXX</td>
<td class="bits"><span class="free">OO</span>XX X<span class="free">OOO</span></td> <td class="bits"><span class="free">OO</span>XX X<span class="free">O</span>XX</td>
<td class="bits">XX<span class="free">O</span>X XXXX</td> <td class="bits">XX<span class="free">O</span>X XXXX</td>
</tr> </tr>
<tr> <tr>
@@ -232,11 +216,10 @@ the array so you can quickly see what is used and what is not.
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="option">~~~~ ~</span>XXX</td> <td class="bits"><span class="option">~~~~ ~</span>XXX</td>
<td class="bits"><span class="free">OO</span>XX X<span class="free">OOO</span></td> <td class="bits"><span class="free">OO</span>XX X<span class="free">O</span>XX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
</tr> </tr>
<tr> <tr>
@@ -244,11 +227,10 @@ the array so you can quickly see what is used and what is not.
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td>
<td class="bits">XXXX <span class="free">OOOO</span></td> <td class="bits">XXXX <span class="free">OOOO</span></td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OO</span>XX X<span class="free">OOO</span></td> <td class="bits"><span class="free">OO</span>XX X<span class="free">O</span>XX</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
</tr> </tr>
<tr> <tr>
@@ -256,11 +238,10 @@ the array so you can quickly see what is used and what is not.
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="option">~~~~ ~~~~</span></td> <td class="bits"><span class="option">~~~~ ~~~~</span></td>
<td class="bits"><span class="free">OO</span>XX X<span class="free">OOO</span></td> <td class="bits"><span class="free">OO</span>XX X<span class="free">O</span>XX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
</tr> </tr>
<tr> <tr>
@@ -268,74 +249,68 @@ the array so you can quickly see what is used and what is not.
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="option">~~~~ ~~~~</span></td> <td class="bits"><span class="option">~~~~ ~~~~</span></td>
<td class="bits"><span class="free">OO</span>XX X<span class="free">OOO</span></td> <td class="bits"><span class="free">OO</span>XX X<span class="free">O</span>XX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
</tr> </tr>
<tr> <tr>
<td rowspan=3>6</td> <td rowspan=3>6</td>
<td class="caption">sea, shore</td> <td class="caption">sea, shore</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">O</span>XXX XXXX</td> <td class="bits"><span class="free">O</span>XXX XXXX</td>
<td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits">X<span class="option">~~</span>X XXXX</td> <td class="bits">X<span class="option">~~</span>X XXXX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits">XX<span class="free">OO OO</span>XX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
</tr> </tr>
<tr> <tr>
<td class="caption">canal, river</td> <td class="caption">canal, river</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td>
<td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits">XX<span class="free">OO OO</span>XX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
</tr> </tr>
<tr> <tr>
<td class="caption">shipdepot</td> <td class="caption">shipdepot</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td>
<td class="bits">XXXX XXXX XXXX XXXX</td> <td class="bits">XXXX XXXX XXXX XXXX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits">XX<span class="free">OO OO</span>XX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
</tr> </tr>
<tr> <tr>
<td>8</td> <td>8</td>
<td class="caption">industry</td> <td class="caption">industry</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">XXXX XXXX</td>
<td class="bits">XXX<span class="free">O</span> <span class="abuse">XXXX</span></td> <td class="bits">XXX<span class="free">O</span> <span class="abuse">XXXX</span></td>
<td class="bits">XXXX XXXX XXXX XXXX</td> <td class="bits">XXXX XXXX XXXX XXXX</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OO</span>XX XX<span class="free">OO</span></td> <td class="bits"><span class="free">OO</span>XX XXXX</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
</tr> </tr>
<tr> <tr>
<td rowspan=2>9</td> <td rowspan=2>9</td>
<td class="caption">tunnel entrance</td> <td class="caption">tunnel entrance</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OOO</span>X XXXX</td> <td class="bits"><span class="free">OOO</span>X XXXX</td>
<td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits">X<span class="free">OO</span>X XXXX</td> <td class="bits">X<span class="free">OO</span>X XXXX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits">XX<span class="free">OO OO</span>XX</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
</tr> </tr>
<tr> <tr>
@@ -346,21 +321,19 @@ the array so you can quickly see what is used and what is not.
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
<td class="bits">-inherit-</td> <td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OO</span>XX XX<span class="free">OO</span></td>
<td class="bits">-inherit-</td> <td class="bits">-inherit-</td>
</tr> </tr>
<tr> <tr>
<td rowspan=2>A</td> <td rowspan=2>A</td>
<td class="caption">objects</td> <td class="caption">objects</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">O</span>XXX XXXX</td> <td class="bits"><span class="free">O</span>XXX XXXX</td>
<td class="bits">XXXX XXXX XXXX XXXX</td> <td class="bits">XXXX XXXX XXXX XXXX</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits"><span class="free">OOOO OOOO</span></td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OOOO OOOO</span></td> <td class="bits">XX<span class="free">OO OO</span>XX</td>
<td class="bits">XXXX XXXX</td> <td class="bits">XXXX XXXX</td>
</tr> </tr>
</tbody> </tbody>

View File

@@ -1,152 +1,112 @@
.\" Hey, EMACS: -*- nroff -*- .\" Hey, EMACS: -*- nroff -*-
.\" Please adjust this date whenever revising the manpage. .\" Please adjust this date whenever revising the manpage.
.Dd October 13, 2014 .Dd May 31, 2011
.Dt OPENTTD 6 .Dt OPENTTD 6
.Os
.Sh NAME .Sh NAME
.Nm openttd .Nm openttd
.Nd open source clone of the Microprose game \(lqTransport Tycoon Deluxe\(rq .Nd An open source clone of the Microprose game "Transport Tycoon Deluxe"
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl efhx .Op Fl efhx
.Op Fl b Ar blitter .Op Fl b Ar blitter
.Op Fl c Ar config_file .Op Fl c Ar config_file
.Op Fl d Op Ar level | Ar cat Ns = Ns Ar lvl Ns Op , Ns Ar ... .Op Fl d Ar [level | cat=lvl[,...]]
.Op Fl D Oo Ar host Oc Ns Op : Ns Ar port .Op Fl D Ar [host][:port]
.Op Fl g Op Ar savegame .Op Fl g Ar [savegame]
.Op Fl G Ar seed .Op Fl G Ar seed
.Op Fl I Ar graphicsset .Op Fl I Ar graphicsset
.Op Fl l Ar host Ns Op : Ns Ar port .Op Fl l Ar host[:port]
.Op Fl m Ar driver .Op Fl m Ar driver
.Op Fl M Ar musicset .Op Fl M Ar musicset
.Op Fl n Ar host Ns Oo : Ns Ar port Oc Ns Op # Ns Ar player .Op Fl n Ar host[:port][#player]
.Op Fl p Ar password .Op Fl p Ar password
.Op Fl P Ar password .Op Fl P Ar password
.Op Fl q Ar savegame .Op Fl q Ar savegame
.Op Fl r Ar width Ns x Ns Ar height .Op Fl r Ar widthxheight
.Op Fl s Ar driver .Op Fl s Ar driver
.Op Fl S Ar soundset .Op Fl S Ar soundset
.Op Fl t Ar year .Op Fl t Ar year
.Op Fl v Ar driver .Op Fl v Ar driver
.Sh OPTIONS .Sh OPTIONS
.Bl -tag -width "-n host[:port][#player]" .Bl -tag -width ".Fl n Ar host[:port][#player]"
.It Fl b Ar blitter .It Fl b Ar blitter
Select the blitter Set the blitter, see
.Ar blitter ;
see
.Fl h .Fl h
for a full list. for a full list
.It Fl c Ar config_file .It Fl c Ar config_file
Use Use 'config_file' instead of 'openttd.cfg'
.Ar config_file
instead of
.Pa openttd.cfg .
.It Fl d Ar [level] .It Fl d Ar [level]
Set debug verbosity for all categories to Set debug verbosity for all categories to
.Ar level , .Ar level
or 1 if omitted. or 1 if omitted
.It Fl d Ar cat Ns = Ns Ar lvl Ns Op , Ns Ar ... .It Fl d Ar cat=level[,...]
Set debug verbosity to Set debug verbosity for a specific category
.Ar lvl .It Fl D Ar [host][:port]
for a specific category Start a dedicated server. Sets network debug level to 6. If you want to change this, use
.Ar cat .
.It Fl D Oo Ar host Oc Ns Op : Ns Ar port
Start a dedicated server.
.Pp
Network debug level will be set to 6.
If you want to change this, set
.Fl d .Fl d
after setting after
.Fl D . .Fl D
.It Fl G Ar seed
Seed the pseudo random number generator
.It Fl e .It Fl e
Start in world editor mode. Start in world editor mode
.It Fl f .It Fl f
Fork into background (dedicated server only, see Fork into background (dedicated server only, see
.Fl D ) . .Fl D )
.It Fl g Op Ar savegame .It Fl g Ar [savegame]
Load Load
.Ar savegame .Ar savegame
at start or start a new game if omitted. at start or start a new game if omitted. The
.Ar savegame .Ar savegame
must be either an absolute path or one relative to the current path or one of must be either absolute or relative to the current path or one of the search paths.
the search paths.
.It Fl G Ar seed
Seed the pseudo random number generator with
.Ar seed .
.It Fl h .It Fl h
Display a summary of all options and list all the available AIs, blitters, Display a summary of all options and lists all the available AIs, blitters, sound, music and video drivers, graphics sets and sound sets.
sound, music and video drivers, graphics sets and sound sets.
.It Fl I Ar graphicsset .It Fl I Ar graphicsset
Select the graphics set Set the graphics set, see
.Ar graphicsset ;
see
.Fl h .Fl h
for a full list. for a full list
.It Fl l Ar host Ns Op : Ns Ar port .It Fl l Ar host[:port]
Redirect Redirect DEBUG(), See
.Fn DEBUG .Fl D
output; see
.Fl D .
.It Fl m Ar driver .It Fl m Ar driver
Select the music driver Set the music driver, see
.Ar driver ;
see
.Fl h .Fl h
for a full list. for a full list
.It Fl M Ar musicset .It Fl M Ar musicset
Select the music set Set the music set, see
.Ar musicset ;
see
.Fl h .Fl h
for a full list. for a full list
.It Fl n Ar host Ns Oo : Ns Ar port Oc Ns Op # Ns Ar player .It Fl n Ar host[:port][#player]
Join a network game, optionally specifying a port to connect to and player to Join a network game, optionally specify a port to connect to and player to play as
play as.
.It Fl p Ar password .It Fl p Ar password
Password used to join server. Password used to join server. Only useful with
Only useful with .Fl n
.Fl n .
.It Fl P Ar password .It Fl P Ar password
Password used to join company. Password used to join company. Only useful with
Only useful with .Fl n
.Fl n .
.It Fl q Ar savegame .It Fl q Ar savegame
Write some information about the specified savegame and exit. Write some information about the savegame and exit
.It Fl r Ar width Ns x Ns Ar height .It Fl r Ar widthxheight
Set the resolution to Set the resolution
.Ar width
\(mu
.Ar height
pixels.
.It Fl s Ar driver .It Fl s Ar driver
Select the sound driver Set the sound driver, see
.Ar driver ;
see
.Fl h .Fl h
for a full list. for a full list
.It Fl S Ar soundset .It Fl S Ar soundset
Select the sound set Set the sound set, see
.Ar soundset ;
see
.Fl h .Fl h
for a full list. for a full list
.It Fl t Ar year .It Fl t Ar year
Set the starting year to Set the starting year
.Ar year .
.It Fl v Ar driver .It Fl v Ar driver
Select the video driver Set the video driver, see
.Ar driver ;
see
.Fl h .Fl h
for a full list. for a full list
.It Fl x .It Fl x
Do not automatically save to config file on exit. Do not automatically save to config file on exit
.El .El
.Sh SEE ALSO .Sh SEE ALSO
.Lk https://wiki.openttd.org "Wiki" http://wiki.openttd.org/, http://www.openttd.org
(includes community maintained manual),
.Lk https://forum.openttd.org "Forum",
.Lk https://www.openttd.org "News"
.Sh HISTORY .Sh HISTORY
Transport Tycoon Deluxe was written by Chris Sawyer and published by Microprose. Transport Tycoon Deluxe was written by Chris Sawyer and published by Microprose.
.Nm .Nm

View File

@@ -106,21 +106,21 @@ elif [ -d "$ROOT_DIR/.git" ]; then
fi fi
elif [ -d "$ROOT_DIR/.hg" ]; then elif [ -d "$ROOT_DIR/.hg" ]; then
# We are a hg checkout # We are a hg checkout
if [ -n "`HGPLAIN= hg status | grep -v '^?'`" ]; then if [ -n "`hg status | grep -v '^?'`" ]; then
MODIFIED="2" MODIFIED="2"
fi fi
HASH=`LC_ALL=C HGPLAIN= hg id -i | cut -c1-12` HASH=`LC_ALL=C hg id -i | cut -c1-12`
REV="h`echo $HASH | cut -c1-8`" REV="h`echo $HASH | cut -c1-8`"
BRANCH="`HGPLAIN= hg branch | sed 's@^default$@@'`" BRANCH="`hg branch | sed 's@^default$@@'`"
TAG="`HGPLAIN= hg id -t | grep -v 'tip$'`" TAG="`hg id -t | grep -v 'tip$'`"
if [ -n "$TAG" ]; then if [ -n "$TAG" ]; then
BRANCH="" BRANCH=""
REV="$TAG" REV="$TAG"
fi fi
REV_NR=`LC_ALL=C HGPLAIN= hg log -f -k "(svn r" -l 1 --template "{desc|firstline}\n" | grep "^(svn r[0-9]*)" | sed "s@.*(svn r\([0-9]*\)).*@\1@"` REV_NR=`LC_ALL=C hg log -f -k "(svn r" -l 1 --template "{desc|firstline}\n" | grep "^(svn r[0-9]*)" | sed "s@.*(svn r\([0-9]*\)).*@\1@"`
if [ -z "$REV_NR" ]; then if [ -z "$REV_NR" ]; then
# No rev? Maybe it is a custom hgsubversion clone # No rev? Maybe it is a custom hgsubversion clone
REV_NR=`LC_ALL=C HGPLAIN= hg parent --template="{svnrev}"` REV_NR=`LC_ALL=C hg parent --template="{svnrev}"`
fi fi
elif [ -f "$ROOT_DIR/.ottdrev" ]; then elif [ -f "$ROOT_DIR/.ottdrev" ]; then
# We are an exported source bundle # We are an exported source bundle

View File

@@ -1,6 +1,6 @@
OpenTTD's known bugs OpenTTD's known bugs
Last updated: 2015-12-01 Last updated: 2014-10-08
Release version: 1.5.3 Release version: 1.4.4-RC1
------------------------------------------------------------------------ ------------------------------------------------------------------------

View File

@@ -104,4 +104,3 @@
#include "rivers/tropic.nfo" #include "rivers/tropic.nfo"
#include "rivers/toyland.nfo" #include "rivers/toyland.nfo"
#include "tunnel_portals.nfo" #include "tunnel_portals.nfo"
#include "palette.nfo"

View File

@@ -1,20 +0,0 @@
//
// $Id$
//
// This file is part of OpenTTD.
// OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
// OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
//
-1 * 0 0C "All black palette"
-1 * 0 05 18 01
-1 * 0 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
01

View File

@@ -9,4 +9,4 @@ Exec=!!TTD!!
Terminal=false Terminal=false
Categories=!!MENU_GROUP!! Categories=!!MENU_GROUP!!
Comment=A clone of Transport Tycoon Deluxe Comment=A clone of Transport Tycoon Deluxe
Keywords=game;simulation;transport;tycoon;deluxe;economics;multiplayer;money;train;ship;bus;truck;aircraft;cargo; Keywords=game;simulation;transport;tycoon;deluxe;economics;multiplayer;money;train;ship;bus;truck;aircraft;cargo

View File

@@ -1,69 +1,3 @@
openttd (1.5.3-0) unstable; urgency=low
* New upstream release 1.5.3
-- OpenTTD <info@openttd.org> Tue, 01 Dec 2015 21:00:00 +0100
openttd (1.5.3~RC1-0) unstable; urgency=low
* New upstream release 1.5.3-RC1
-- OpenTTD <info@openttd.org> Sun, 01 Nov 2015 14:00:00 +0100
openttd (1.5.2-0) unstable; urgency=low
* New upstream release 1.5.2
-- OpenTTD <info@openttd.org> Tue, 01 Sep 2015 21:00:00 +0200
openttd (1.5.2~RC1-0) unstable; urgency=low
* New upstream release 1.5.2-RC1
-- OpenTTD <info@openttd.org> Sat, 01 Aug 2015 13:00:00 +0200
openttd (1.5.1-0) unstable; urgency=low
* New upstream release 1.5.1
-- OpenTTD <info@openttd.org> Mon, 01 Jun 2015 21:00:00 +0200
openttd (1.5.1~RC1-0) unstable; urgency=low
* New upstream release 1.5.1-RC1
-- OpenTTD <info@openttd.org> Fri, 08 May 2015 21:00:00 +0200
openttd (1.5.0-0) unstable; urgency=low
* New upstream release 1.5.0
-- OpenTTD <info@openttd.org> Wed, 01 Apr 2015 21:00:00 +0200
openttd (1.5.0~RC1-0) unstable; urgency=low
* New upstream release 1.5.0-RC1
-- OpenTTD <info@openttd.org> Wed, 18 Mar 2015 21:00:00 +0100
openttd (1.5.0~beta2-0) unstable; urgency=low
* New upstream release 1.5.0-beta2
-- OpenTTD <info@openttd.org> Tue, 24 Feb 2015 21:00:00 +0100
openttd (1.5.0~beta1-0) unstable; urgency=low
* New upstream release 1.5.0-beta1
-- OpenTTD <info@openttd.org> Wed, 24 Dec 2014 21:00:00 +0100
openttd (1.4.4-0) unstable; urgency=low
* New upstream release 1.4.4
-- OpenTTD <info@openttd.org> Tue, 21 Oct 2014 21:00:00 +0200
openttd (1.4.4~RC1-0) unstable; urgency=low openttd (1.4.4~RC1-0) unstable; urgency=low
* New upstream release 1.4.4-RC1 * New upstream release 1.4.4-RC1

View File

@@ -1,6 +1,6 @@
@echo off @echo off
set OPENTTD_VERSION=1.5.0 set OPENTTD_VERSION=1.4.0
set OPENSFX_VERSION=0.8.0 set OPENSFX_VERSION=0.8.0
set NOSOUND_VERSION=0.8.0 set NOSOUND_VERSION=0.8.0
set OPENGFX_VERSION=1.2.0 set OPENGFX_VERSION=1.2.0

View File

@@ -17,9 +17,9 @@
# #
Name: openttd Name: openttd
Version: 1.5.beta1 Version: 1.3.beta2
Release: 0 Release: 0
%define srcver 1.5.0-beta1 %define srcver 1.3.0-beta2
Summary: An open source reimplementation of Chris Sawyer's Transport Tycoon Deluxe Summary: An open source reimplementation of Chris Sawyer's Transport Tycoon Deluxe
License: GPL-2.0 License: GPL-2.0
Group: Amusements/Games/Strategy/Other Group: Amusements/Games/Strategy/Other

View File

@@ -1,9 +1,9 @@
# Version numbers to update # Version numbers to update
!define APPV_MAJOR 1 !define APPV_MAJOR 1
!define APPV_MINOR 5 !define APPV_MINOR 4
!define APPV_MAINT 3 !define APPV_MAINT 4
!define APPV_BUILD 1 !define APPV_BUILD 0
!define APPV_EXTRA "" !define APPV_EXTRA "-RC1"
!define APPNAME "OpenTTD" ; Define application name !define APPNAME "OpenTTD" ; Define application name
!define APPVERSION "${APPV_MAJOR}.${APPV_MINOR}.${APPV_MAINT}${APPV_EXTRA}" ; Define application version !define APPVERSION "${APPV_MAJOR}.${APPV_MINOR}.${APPV_MAINT}${APPV_EXTRA}" ; Define application version

View File

@@ -77,7 +77,7 @@ safety_check() {
done done
} }
grep '\.h' "$ROOT_DIR/source.list" | grep -v '../objs/langs/table/strings.h\|../objs/settings/table/settings.h' | sed 's/ //g' | sort > tmp.headers.source.list grep '\.h' "$ROOT_DIR/source.list" | grep -v '../objs/langs/table/strings.h\|../objs/settings/table/settings.h' | sed 's/ //' | sort > tmp.headers.source.list
find "$ROOT_DIR/src" \( -iname "*.h" -or -iname "*.hpp" \) -and -not -ipath "*/.svn/*" | sed "s~$ROOT_DIR/src/~~" | sort > tmp.headers.src find "$ROOT_DIR/src" \( -iname "*.h" -or -iname "*.hpp" \) -and -not -ipath "*/.svn/*" | sed "s~$ROOT_DIR/src/~~" | sort > tmp.headers.src
if [ -n "`diff tmp.headers.source.list tmp.headers.src`" ]; then if [ -n "`diff tmp.headers.source.list tmp.headers.src`" ]; then
echo "The following headers are missing in source.list and not in /src/ or vice versa." echo "The following headers are missing in source.list and not in /src/ or vice versa."

View File

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

View File

@@ -97,9 +97,6 @@
<CustomBuild Include="..\src\lang\korean.txt"> <CustomBuild Include="..\src\lang\korean.txt">
<Filter>Translations</Filter> <Filter>Translations</Filter>
</CustomBuild> </CustomBuild>
<CustomBuild Include="..\src\lang\latin.txt">
<Filter>Translations</Filter>
</CustomBuild>
<CustomBuild Include="..\src\lang\latvian.txt"> <CustomBuild Include="..\src\lang\latvian.txt">
<Filter>Translations</Filter> <Filter>Translations</Filter>
</CustomBuild> </CustomBuild>

View File

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

View File

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

View File

@@ -311,7 +311,6 @@
<ClCompile Include="..\src\debug.cpp" /> <ClCompile Include="..\src\debug.cpp" />
<ClCompile Include="..\src\dedicated.cpp" /> <ClCompile Include="..\src\dedicated.cpp" />
<ClCompile Include="..\src\depot.cpp" /> <ClCompile Include="..\src\depot.cpp" />
<ClCompile Include="..\src\disaster_vehicle.cpp" />
<ClCompile Include="..\src\driver.cpp" /> <ClCompile Include="..\src\driver.cpp" />
<ClCompile Include="..\src\economy.cpp" /> <ClCompile Include="..\src\economy.cpp" />
<ClCompile Include="..\src\effectvehicle.cpp" /> <ClCompile Include="..\src\effectvehicle.cpp" />
@@ -438,7 +437,6 @@
<ClInclude Include="..\src\depot_type.h" /> <ClInclude Include="..\src\depot_type.h" />
<ClInclude Include="..\src\direction_func.h" /> <ClInclude Include="..\src\direction_func.h" />
<ClInclude Include="..\src\direction_type.h" /> <ClInclude Include="..\src\direction_type.h" />
<ClInclude Include="..\src\disaster_vehicle.h" />
<ClInclude Include="..\src\music\dmusic.h" /> <ClInclude Include="..\src\music\dmusic.h" />
<ClInclude Include="..\src\driver.h" /> <ClInclude Include="..\src\driver.h" />
<ClInclude Include="..\src\economy_base.h" /> <ClInclude Include="..\src\economy_base.h" />
@@ -570,7 +568,6 @@
<ClInclude Include="..\src\road_type.h" /> <ClInclude Include="..\src\road_type.h" />
<ClInclude Include="..\src\roadstop_base.h" /> <ClInclude Include="..\src\roadstop_base.h" />
<ClInclude Include="..\src\roadveh.h" /> <ClInclude Include="..\src\roadveh.h" />
<ClInclude Include="..\src\safeguards.h" />
<ClInclude Include="..\src\screenshot.h" /> <ClInclude Include="..\src\screenshot.h" />
<ClInclude Include="..\src\sdl.h" /> <ClInclude Include="..\src\sdl.h" />
<ClInclude Include="..\src\sound\sdl_s.h" /> <ClInclude Include="..\src\sound\sdl_s.h" />
@@ -807,6 +804,7 @@
<ClCompile Include="..\src\clear_cmd.cpp" /> <ClCompile Include="..\src\clear_cmd.cpp" />
<ClCompile Include="..\src\company_cmd.cpp" /> <ClCompile Include="..\src\company_cmd.cpp" />
<ClCompile Include="..\src\depot_cmd.cpp" /> <ClCompile Include="..\src\depot_cmd.cpp" />
<ClCompile Include="..\src\disaster_cmd.cpp" />
<ClCompile Include="..\src\group_cmd.cpp" /> <ClCompile Include="..\src\group_cmd.cpp" />
<ClCompile Include="..\src\industry_cmd.cpp" /> <ClCompile Include="..\src\industry_cmd.cpp" />
<ClCompile Include="..\src\misc_cmd.cpp" /> <ClCompile Include="..\src\misc_cmd.cpp" />
@@ -883,7 +881,6 @@
<ClInclude Include="..\src\table\elrail_data.h" /> <ClInclude Include="..\src\table\elrail_data.h" />
<ClInclude Include="..\src\table\engines.h" /> <ClInclude Include="..\src\table\engines.h" />
<ClInclude Include="..\src\table\genland.h" /> <ClInclude Include="..\src\table\genland.h" />
<ClInclude Include="..\src\table\heightmap_colours.h" />
<ClInclude Include="..\src\table\industry_land.h" /> <ClInclude Include="..\src\table\industry_land.h" />
<ClInclude Include="..\src\table\landscape_sprite.h" /> <ClInclude Include="..\src\table\landscape_sprite.h" />
<ClInclude Include="..\src\table\newgrf_debug_data.h" /> <ClInclude Include="..\src\table\newgrf_debug_data.h" />
@@ -954,7 +951,6 @@
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqstate.h" /> <ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqstate.h" />
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdaux.h" /> <ClInclude Include="..\src\3rdparty\squirrel\include\sqstdaux.h" />
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdmath.h" /> <ClInclude Include="..\src\3rdparty\squirrel\include\sqstdmath.h" />
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdstring.h" />
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqstring.h" /> <ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqstring.h" />
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqtable.h" /> <ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqtable.h" />
<ClInclude Include="..\src\3rdparty\squirrel\include\squirrel.h" /> <ClInclude Include="..\src\3rdparty\squirrel\include\squirrel.h" />

View File

@@ -162,9 +162,6 @@
<ClCompile Include="..\src\depot.cpp"> <ClCompile Include="..\src\depot.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\src\disaster_vehicle.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\driver.cpp"> <ClCompile Include="..\src\driver.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@@ -543,9 +540,6 @@
<ClInclude Include="..\src\direction_type.h"> <ClInclude Include="..\src\direction_type.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\src\disaster_vehicle.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\music\dmusic.h"> <ClInclude Include="..\src\music\dmusic.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@@ -939,9 +933,6 @@
<ClInclude Include="..\src\roadveh.h"> <ClInclude Include="..\src\roadveh.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\src\safeguards.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\screenshot.h"> <ClInclude Include="..\src\screenshot.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@@ -1650,6 +1641,9 @@
<ClCompile Include="..\src\depot_cmd.cpp"> <ClCompile Include="..\src\depot_cmd.cpp">
<Filter>Command handlers</Filter> <Filter>Command handlers</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\src\disaster_cmd.cpp">
<Filter>Command handlers</Filter>
</ClCompile>
<ClCompile Include="..\src\group_cmd.cpp"> <ClCompile Include="..\src\group_cmd.cpp">
<Filter>Command handlers</Filter> <Filter>Command handlers</Filter>
</ClCompile> </ClCompile>
@@ -1878,9 +1872,6 @@
<ClInclude Include="..\src\table\genland.h"> <ClInclude Include="..\src\table\genland.h">
<Filter>Tables</Filter> <Filter>Tables</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\src\table\heightmap_colours.h">
<Filter>Tables</Filter>
</ClInclude>
<ClInclude Include="..\src\table\industry_land.h"> <ClInclude Include="..\src\table\industry_land.h">
<Filter>Tables</Filter> <Filter>Tables</Filter>
</ClInclude> </ClInclude>
@@ -2091,9 +2082,6 @@
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdmath.h"> <ClInclude Include="..\src\3rdparty\squirrel\include\sqstdmath.h">
<Filter>Squirrel headers</Filter> <Filter>Squirrel headers</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdstring.h">
<Filter>Squirrel headers</Filter>
</ClInclude>
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqstring.h"> <ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqstring.h">
<Filter>Squirrel headers</Filter> <Filter>Squirrel headers</Filter>
</ClInclude> </ClInclude>

View File

@@ -514,10 +514,6 @@
RelativePath=".\..\src\depot.cpp" RelativePath=".\..\src\depot.cpp"
> >
</File> </File>
<File
RelativePath=".\..\src\disaster_vehicle.cpp"
>
</File>
<File <File
RelativePath=".\..\src\driver.cpp" RelativePath=".\..\src\driver.cpp"
> >
@@ -1026,10 +1022,6 @@
RelativePath=".\..\src\direction_type.h" RelativePath=".\..\src\direction_type.h"
> >
</File> </File>
<File
RelativePath=".\..\src\disaster_vehicle.h"
>
</File>
<File <File
RelativePath=".\..\src\music\dmusic.h" RelativePath=".\..\src\music\dmusic.h"
> >
@@ -1554,10 +1546,6 @@
RelativePath=".\..\src\roadveh.h" RelativePath=".\..\src\roadveh.h"
> >
</File> </File>
<File
RelativePath=".\..\src\safeguards.h"
>
</File>
<File <File
RelativePath=".\..\src\screenshot.h" RelativePath=".\..\src\screenshot.h"
> >
@@ -2518,6 +2506,10 @@
RelativePath=".\..\src\depot_cmd.cpp" RelativePath=".\..\src\depot_cmd.cpp"
> >
</File> </File>
<File
RelativePath=".\..\src\disaster_cmd.cpp"
>
</File>
<File <File
RelativePath=".\..\src\group_cmd.cpp" RelativePath=".\..\src\group_cmd.cpp"
> >
@@ -2830,10 +2822,6 @@
RelativePath=".\..\src\table\genland.h" RelativePath=".\..\src\table\genland.h"
> >
</File> </File>
<File
RelativePath=".\..\src\table\heightmap_colours.h"
>
</File>
<File <File
RelativePath=".\..\src\table\industry_land.h" RelativePath=".\..\src\table\industry_land.h"
> >
@@ -3130,10 +3118,6 @@
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdmath.h" RelativePath=".\..\src\3rdparty\squirrel\include\sqstdmath.h"
> >
</File> </File>
<File
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdstring.h"
>
</File>
<File <File
RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqstring.h" RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqstring.h"
> >

View File

@@ -511,10 +511,6 @@
RelativePath=".\..\src\depot.cpp" RelativePath=".\..\src\depot.cpp"
> >
</File> </File>
<File
RelativePath=".\..\src\disaster_vehicle.cpp"
>
</File>
<File <File
RelativePath=".\..\src\driver.cpp" RelativePath=".\..\src\driver.cpp"
> >
@@ -1023,10 +1019,6 @@
RelativePath=".\..\src\direction_type.h" RelativePath=".\..\src\direction_type.h"
> >
</File> </File>
<File
RelativePath=".\..\src\disaster_vehicle.h"
>
</File>
<File <File
RelativePath=".\..\src\music\dmusic.h" RelativePath=".\..\src\music\dmusic.h"
> >
@@ -1551,10 +1543,6 @@
RelativePath=".\..\src\roadveh.h" RelativePath=".\..\src\roadveh.h"
> >
</File> </File>
<File
RelativePath=".\..\src\safeguards.h"
>
</File>
<File <File
RelativePath=".\..\src\screenshot.h" RelativePath=".\..\src\screenshot.h"
> >
@@ -2515,6 +2503,10 @@
RelativePath=".\..\src\depot_cmd.cpp" RelativePath=".\..\src\depot_cmd.cpp"
> >
</File> </File>
<File
RelativePath=".\..\src\disaster_cmd.cpp"
>
</File>
<File <File
RelativePath=".\..\src\group_cmd.cpp" RelativePath=".\..\src\group_cmd.cpp"
> >
@@ -2827,10 +2819,6 @@
RelativePath=".\..\src\table\genland.h" RelativePath=".\..\src\table\genland.h"
> >
</File> </File>
<File
RelativePath=".\..\src\table\heightmap_colours.h"
>
</File>
<File <File
RelativePath=".\..\src\table\industry_land.h" RelativePath=".\..\src\table\industry_land.h"
> >
@@ -3127,10 +3115,6 @@
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdmath.h" RelativePath=".\..\src\3rdparty\squirrel\include\sqstdmath.h"
> >
</File> </File>
<File
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdstring.h"
>
</File>
<File <File
RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqstring.h" RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqstring.h"
> >

View File

@@ -1,5 +1,5 @@
Last updated: 2015-12-01 Last updated: 2014-10-08
Release version: 1.5.3 Release version: 1.4.4-RC1
------------------------------------------------------------------------ ------------------------------------------------------------------------
@@ -661,12 +661,6 @@ The md5 implementation in src/3rdparty/md5 is licensed under the Zlib
license. See the comments in the source files in src/3rdparty/md5 for license. See the comments in the source files in src/3rdparty/md5 for
the complete license text. the complete license text.
The implementations of Posix getaddrinfo and getnameinfo for OS/2 in
src/3rdparty/os2 are distributed partly under the GNU Lesser General Public
License 2.1, and partly under the (3-clause) BSD license. The exact licensing
terms can be found in src/3rdparty/os2/getaddrinfo.c resp.
src/3rdparty/os2/getnameinfo.c.
The exe2coff implementation in os/dos/exe2coff is available under the The exe2coff implementation in os/dos/exe2coff is available under the
GPL, with a number of additional terms. See os/dos/exe2coff/copying and GPL, with a number of additional terms. See os/dos/exe2coff/copying and
os/dos/exe2coff/copying.dj for the exact licensing terms. os/dos/exe2coff/copying.dj for the exact licensing terms.
@@ -729,6 +723,7 @@ Thanks to:
George - Canal graphics George - Canal graphics
Andrew Parkhouse (andythenorth) - River graphics Andrew Parkhouse (andythenorth) - River graphics
David Dallaston (Pikka) - Tram tracks David Dallaston (Pikka) - Tram tracks
Fleashosio - Titlegame
All Translators - For their support to make OpenTTD a truly international game All Translators - For their support to make OpenTTD a truly international game
Bug Reporters - Thanks for all bug reports Bug Reporters - Thanks for all bug reports
Chris Sawyer - For an amazing game! Chris Sawyer - For an amazing game!

View File

@@ -19,7 +19,6 @@ date.cpp
debug.cpp debug.cpp
dedicated.cpp dedicated.cpp
depot.cpp depot.cpp
disaster_vehicle.cpp
driver.cpp driver.cpp
economy.cpp economy.cpp
effectvehicle.cpp effectvehicle.cpp
@@ -99,10 +98,6 @@ townname.cpp
#else #else
#if OS2 #if OS2
os/os2/os2.cpp os/os2/os2.cpp
3rdparty/os2/getaddrinfo.c
3rdparty/os2/getaddrinfo.h
3rdparty/os2/getnameinfo.c
3rdparty/os2/getnameinfo.h
#else #else
#if OSX #if OSX
os/macosx/crashlog_osx.cpp os/macosx/crashlog_osx.cpp
@@ -177,7 +172,6 @@ depot_map.h
depot_type.h depot_type.h
direction_func.h direction_func.h
direction_type.h direction_type.h
disaster_vehicle.h
music/dmusic.h music/dmusic.h
driver.h driver.h
economy_base.h economy_base.h
@@ -309,7 +303,6 @@ road_internal.h
road_type.h road_type.h
roadstop_base.h roadstop_base.h
roadveh.h roadveh.h
safeguards.h
screenshot.h screenshot.h
sdl.h sdl.h
sound/sdl_s.h sound/sdl_s.h
@@ -569,6 +562,7 @@ autoreplace_cmd.cpp
clear_cmd.cpp clear_cmd.cpp
company_cmd.cpp company_cmd.cpp
depot_cmd.cpp depot_cmd.cpp
disaster_cmd.cpp
group_cmd.cpp group_cmd.cpp
industry_cmd.cpp industry_cmd.cpp
misc_cmd.cpp misc_cmd.cpp
@@ -649,7 +643,6 @@ table/control_codes.h
table/elrail_data.h table/elrail_data.h
table/engines.h table/engines.h
table/genland.h table/genland.h
table/heightmap_colours.h
table/industry_land.h table/industry_land.h
table/landscape_sprite.h table/landscape_sprite.h
table/newgrf_debug_data.h table/newgrf_debug_data.h
@@ -728,7 +721,6 @@ script/squirrel_std.hpp
3rdparty/squirrel/squirrel/sqstate.h 3rdparty/squirrel/squirrel/sqstate.h
3rdparty/squirrel/include/sqstdaux.h 3rdparty/squirrel/include/sqstdaux.h
3rdparty/squirrel/include/sqstdmath.h 3rdparty/squirrel/include/sqstdmath.h
3rdparty/squirrel/include/sqstdstring.h
3rdparty/squirrel/squirrel/sqstring.h 3rdparty/squirrel/squirrel/sqstring.h
3rdparty/squirrel/squirrel/sqtable.h 3rdparty/squirrel/squirrel/sqtable.h
3rdparty/squirrel/include/squirrel.h 3rdparty/squirrel/include/squirrel.h
@@ -1110,10 +1102,7 @@ music/null_m.cpp
#else #else
#if DOS #if DOS
#else #else
#if MORPHOS music/extmidi.cpp
#else
music/extmidi.cpp
#end
#end #end
#end #end
#end #end

View File

@@ -60,8 +60,6 @@
#include "../../core/endian_func.hpp" #include "../../core/endian_func.hpp"
#include "md5.h" #include "md5.h"
#include "../../safeguards.h"
#define T_MASK ((uint32)~0) #define T_MASK ((uint32)~0)
#define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87) #define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87)
#define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9) #define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9)

View File

@@ -1,299 +0,0 @@
/*
* This file is part of libESMTP, a library for submission of RFC 2822
* formatted electronic mail messages using the SMTP protocol described
* in RFC 2821.
*
* Copyright (C) 2001,2002 Brian Stafford <brian@stafford.uklinux.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* An emulation of the RFC 2553 / Posix getaddrinfo resolver interface.
*/
#if !HAVE_GETADDRINFO
/* Need to turn off Posix features in glibc to build this */
#undef _POSIX_C_SOURCE
#undef _XOPEN_SOURCE
#include "getaddrinfo.h"
//#include "compat/inet_pton.h"
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
static struct addrinfo *
dup_addrinfo (struct addrinfo *info, void *addr, size_t addrlen) {
struct addrinfo *ret;
ret = malloc (sizeof (struct addrinfo));
if (ret == NULL)
return NULL;
memcpy (ret, info, sizeof (struct addrinfo));
ret->ai_addr = malloc (addrlen);
if (ret->ai_addr == NULL) {
free (ret);
return NULL;
}
memcpy (ret->ai_addr, addr, addrlen);
ret->ai_addrlen = addrlen;
return ret;
}
int
getaddrinfo (const char *nodename, const char *servname,
const struct addrinfo *hints, struct addrinfo **res)
{
struct hostent *hp;
struct servent *servent;
const char *socktype;
int port;
struct addrinfo hint, result;
struct addrinfo *ai, *sai, *eai;
char **addrs;
if (servname == NULL && nodename == NULL)
return EAI_NONAME;
memset (&result, 0, sizeof result);
/* default for hints */
if (hints == NULL) {
memset (&hint, 0, sizeof hint);
hint.ai_family = PF_UNSPEC;
hints = &hint;
}
if (servname == NULL)
port = 0;
else {
/* check for tcp or udp sockets only */
if (hints->ai_socktype == SOCK_STREAM)
socktype = "tcp";
else if (hints->ai_socktype == SOCK_DGRAM)
socktype = "udp";
else
return EAI_SERVICE;
result.ai_socktype = hints->ai_socktype;
/* Note: maintain port in host byte order to make debugging easier */
if (isdigit (*servname))
port = strtol (servname, NULL, 10);
else if ((servent = getservbyname (servname, socktype)) != NULL)
port = ntohs (servent->s_port);
else
return EAI_NONAME;
}
/* if nodename == NULL refer to the local host for a client or any
for a server */
if (nodename == NULL) {
struct sockaddr_in sin;
/* check protocol family is PF_UNSPEC or PF_INET - could try harder
for IPv6 but that's more code than I'm prepared to write */
if (hints->ai_family == PF_UNSPEC || hints->ai_family == PF_INET)
result.ai_family = AF_INET;
else
return EAI_FAMILY;
sin.sin_family = result.ai_family;
sin.sin_port = htons (port);
if (hints->ai_flags & AI_PASSIVE)
sin.sin_addr.s_addr = htonl (INADDR_ANY);
else
sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
/* Duplicate result and addr and return */
*res = dup_addrinfo (&result, &sin, sizeof sin);
return (*res == NULL) ? EAI_MEMORY : 0;
}
/* If AI_NUMERIC is specified, use inet_pton to translate numbers and
dots notation. */
if (hints->ai_flags & AI_NUMERICHOST) {
struct sockaddr_in sin;
/* check protocol family is PF_UNSPEC or PF_INET */
if (hints->ai_family == PF_UNSPEC || hints->ai_family == PF_INET)
result.ai_family = AF_INET;
else
return EAI_FAMILY;
sin.sin_family = result.ai_family;
sin.sin_port = htons (port);
if (inet_pton(result.ai_family, nodename, &sin.sin_addr)==0)
return EAI_NONAME;
sin.sin_addr.s_addr = inet_addr (nodename);
/* Duplicate result and addr and return */
*res = dup_addrinfo (&result, &sin, sizeof sin);
return (*res == NULL) ? EAI_MEMORY : 0;
}
#if HAVE_H_ERRNO
h_errno = 0;
#endif
errno = 0;
hp = gethostbyname(nodename);
if (hp == NULL) {
#ifdef EAI_SYSTEM
if (errno != 0) {
return EAI_SYSTEM;
}
#endif
switch (h_errno) {
case HOST_NOT_FOUND:
return EAI_NODATA;
case NO_DATA:
return EAI_NODATA;
#if defined(NO_ADDRESS) && NO_ADDRESS != NO_DATA
case NO_ADDRESS:
return EAI_NODATA;
#endif
case NO_RECOVERY:
return EAI_FAIL;
case TRY_AGAIN:
return EAI_AGAIN;
default:
return EAI_FAIL;
}
return EAI_FAIL;
}
/* Check that the address family is acceptable.
*/
switch (hp->h_addrtype) {
case AF_INET:
if (!(hints->ai_family == PF_UNSPEC || hints->ai_family == PF_INET))
return EAI_FAMILY;
break;
#ifndef __OS2__
case AF_INET6:
if (!(hints->ai_family == PF_UNSPEC || hints->ai_family == PF_INET6))
return EAI_FAMILY;
break;
#endif
default:
return EAI_FAMILY;
}
/* For each element pointed to by hp, create an element in the
result linked list. */
sai = eai = NULL;
for (addrs = hp->h_addr_list; *addrs != NULL; addrs++) {
struct sockaddr sa;
size_t addrlen;
if (hp->h_length < 1)
continue;
sa.sa_family = hp->h_addrtype;
switch (hp->h_addrtype) {
case AF_INET:
((struct sockaddr_in *) &sa)->sin_port = htons (port);
memcpy (&((struct sockaddr_in *) &sa)->sin_addr,
*addrs, hp->h_length);
addrlen = sizeof (struct sockaddr_in);
break;
#ifndef __OS2__
case AF_INET6:
#if SIN6_LEN
((struct sockaddr_in6 *) &sa)->sin6_len = hp->h_length;
#endif
((struct sockaddr_in6 *) &sa)->sin6_port = htons (port);
memcpy (&((struct sockaddr_in6 *) &sa)->sin6_addr,
*addrs, hp->h_length);
addrlen = sizeof (struct sockaddr_in6);
break;
#endif
default:
continue;
}
result.ai_family = hp->h_addrtype;
ai = dup_addrinfo (&result, &sa, addrlen);
if (ai == NULL) {
freeaddrinfo (sai);
return EAI_MEMORY;
}
if (sai == NULL)
sai = ai;
else
eai->ai_next = ai;
eai = ai;
}
if (sai == NULL) {
return EAI_NODATA;
}
if (hints->ai_flags & AI_CANONNAME) {
sai->ai_canonname = malloc (strlen (hp->h_name) + 1);
if (sai->ai_canonname == NULL) {
freeaddrinfo (sai);
return EAI_MEMORY;
}
strcpy (sai->ai_canonname, hp->h_name);
}
*res = sai;
return 0;
}
void
freeaddrinfo (struct addrinfo *ai)
{
struct addrinfo *next;
while (ai != NULL) {
next = ai->ai_next;
if (ai->ai_canonname != NULL)
free (ai->ai_canonname);
if (ai->ai_addr != NULL)
free (ai->ai_addr);
free (ai);
ai = next;
}
}
const char *
gai_strerror (int ecode)
{
static const char *eai_descr[] = {
"no error",
"address family for nodename not supported", /* EAI_ADDRFAMILY */
"temporary failure in name resolution", /* EAI_AGAIN */
"invalid value for ai_flags", /* EAI_BADFLAGS */
"non-recoverable failure in name resolution", /* EAI_FAIL */
"ai_family not supported", /* EAI_FAMILY */
"memory allocation failure", /* EAI_MEMORY */
"no address associated with nodename", /* EAI_NODATA */
"nodename nor servname provided, or not known", /* EAI_NONAME */
"servname not supported for ai_socktype", /* EAI_SERVICE */
"ai_socktype not supported", /* EAI_SOCKTYPE */
"system error returned in errno", /* EAI_SYSTEM */
"argument buffer overflow", /* EAI_OVERFLOW */
};
if (ecode < 0 || ecode > (int) (sizeof eai_descr/ sizeof eai_descr[0]))
return "unknown error";
return eai_descr[ecode];
}
#endif /* HAVE_GETADDRINFO */

View File

@@ -1,101 +0,0 @@
#ifndef _getaddrinfo_h
#define _getaddrinfo_h
/*
* Shamelessly duplicated from the fetchmail public sources
* for use by the Squid Project under GNU Public License.
*
* Update/Maintenance History:
*
* 15-Aug-2007 : Copied from fetchmail 6.3.8
* - added protection around libray headers
*
* 16-Aug-2007 : Altered configure checks
* Un-hacked slightly to use system gethostbyname()
*
* Original License and code follows.
*/
/*
* This file is part of libESMTP, a library for submission of RFC 2822
* formatted electronic mail messages using the SMTP protocol described
* in RFC 2821.
*
* Copyright (C) 2001,2002 Brian Stafford <brian@stafford.uklinux.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Structure and prototypes taken from RFC 2553 */
/* SG 23/09/2007:
On Windows the following definitions are already available, may be that
this could be needed on some other platform */
typedef int socklen_t;
struct addrinfo {
int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
int ai_family; /* PF_xxx */
int ai_socktype; /* SOCK_xxx */
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
socklen_t ai_addrlen; /* length of ai_addr */
char *ai_canonname; /* canonical name for nodename */
struct sockaddr *ai_addr; /* binary address */
struct addrinfo *ai_next; /* next structure in linked list */
};
/* Supposed to be defined in <netdb.h> */
#define AI_ADDRCONFIG 0
#define AI_PASSIVE 1 /* Socket address is intended for `bind'. */
#define AI_CANONNAME 2 /* Request for canonical name. */
#define AI_NUMERICHOST 4 /* Don't use name resolution. */
/* Supposed to be defined in <netdb.h> */
#define EAI_ADDRFAMILY 1 /* address family for nodename not supported */
#define EAI_AGAIN 2 /* temporary failure in name resolution */
#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
#define EAI_FAMILY 5 /* ai_family not supported */
#define EAI_MEMORY 6 /* memory allocation failure */
#define EAI_NODATA 7 /* no address associated with nodename */
#define EAI_NONAME 8 /* nodename nor servname provided, or not known */
#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
#ifndef EAI_SYSTEM
/* Not defined on mingw32. */
#define EAI_SYSTEM 11 /* System error returned in `errno'. */
#endif
#ifndef EAI_OVERFLOW
/* Not defined on mingw32. */
#define EAI_OVERFLOW 12 /* Argument buffer overflow. */
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* RFC 2553 / Posix resolver */
int getaddrinfo (const char *nodename, const char *servname,
const struct addrinfo *hints, struct addrinfo **res);
/* Free addrinfo structure and associated storage */
void freeaddrinfo (struct addrinfo *ai);
/* Convert error return from getaddrinfo() to string */
const char *gai_strerror (int code);
#ifdef __cplusplus
}
#endif
#endif /* _getaddrinfo_h */

View File

@@ -1,367 +0,0 @@
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Issues to be discussed:
* - RFC2553 says that we should raise error on short buffer. X/Open says
* we need to truncate the result. We obey RFC2553 (and X/Open should be
* modified). ipngwg rough consensus seems to follow RFC2553. RFC3493 says
* nothing about it, but defines a new error code EAI_OVERFLOW which seems
* to be intended the code for this case.
* - What is "local" in NI_NOFQDN? (see comments in the code)
* - NI_NAMEREQD and NI_NUMERICHOST conflict with each other.
* - (KAME extension) always attach textual scopeid (fe80::1%lo0), if
* sin6_scope_id is filled - standardization status?
* - what should we do if we should do getservbyport("sctp")?
*/
/*
* Considerations about thread-safeness
* The code in this file is thread-safe, and so the thread-safeness of
* getnameinfo() depends on the property of backend functions.
* - getservbyport() is not thread safe for most systems we are targeting.
* - getipnodebyaddr() is thread safe. However, many resolver libraries
* used in the function are not thread safe.
* - gethostbyaddr() is usually not thread safe.
*/
#if !HAVE_GETNAMEINFO
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <netdb.h>
#include <resolv.h>
#include <string.h>
#include <stddef.h>
#include <errno.h>
#include <inttypes.h>
#include "getaddrinfo.h"
#include "getnameinfo.h"
static const struct afd {
int a_af;
int a_addrlen;
int a_socklen;
int a_off;
int a_portoff;
} afdl [] = {
#if INET6
{PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
offsetof(struct sockaddr_in6, sin6_addr),
offsetof(struct sockaddr_in6, sin6_port)},
#endif
{PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in),
offsetof(struct sockaddr_in, sin_addr),
offsetof(struct sockaddr_in, sin_port)},
{0, 0, 0, 0, 0},
};
#if INET6
static int ip6_parsenumeric __P((const struct sockaddr *, const char *, char *,
size_t, int));
static int ip6_sa2str __P((const struct sockaddr_in6 *, char *, size_t, int));
#endif
int
getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
const struct sockaddr *sa;
socklen_t salen;
char *host;
size_t hostlen;
char *serv;
size_t servlen;
int flags;
{
const struct afd *afd;
struct servent *sp;
struct hostent *hp;
unsigned short port;
int family, i;
const char *addr;
uint32_t v4a;
char numserv[512];
if (sa == NULL)
return EAI_FAIL;
#if HAVE_SA_LEN /*XXX*/
if (sa->sa_len != salen)
return EAI_FAIL;
#endif
family = sa->sa_family;
for (i = 0; afdl[i].a_af; i++)
if (afdl[i].a_af == family) {
afd = &afdl[i];
goto found;
}
return EAI_FAMILY;
found:
if (salen != afd->a_socklen)
return EAI_FAIL;
/* network byte order */
memcpy(&port, (const char *)sa + afd->a_portoff, sizeof(port));
addr = (const char *)sa + afd->a_off;
if (serv == NULL || servlen == 0) {
/*
* do nothing in this case.
* in case you are wondering if "&&" is more correct than
* "||" here: RFC3493 says that serv == NULL OR servlen == 0
* means that the caller does not want the result.
*/
} else {
if (flags & NI_NUMERICSERV)
sp = NULL;
else {
sp = getservbyport(port,
(flags & NI_DGRAM) ? "udp" : "tcp");
}
if (sp) {
if (strlen(sp->s_name) + 1 > servlen)
return EAI_OVERFLOW;
strncpy(serv, sp->s_name, servlen);
} else {
snprintf(numserv, sizeof(numserv), "%u", ntohs(port));
if (strlen(numserv) + 1 > servlen)
return EAI_OVERFLOW;
strncpy(serv, numserv, servlen);
}
}
switch (sa->sa_family) {
case AF_INET:
v4a = (uint32_t)
ntohl(((const struct sockaddr_in *)sa)->sin_addr.s_addr);
if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
flags |= NI_NUMERICHOST;
v4a >>= IN_CLASSA_NSHIFT;
if (v4a == 0)
flags |= NI_NUMERICHOST;
break;
#if INET6
case AF_INET6: {
const struct sockaddr_in6 *sin6;
sin6 = (const struct sockaddr_in6 *)sa;
switch (sin6->sin6_addr.s6_addr[0]) {
case 0x00:
if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
;
else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
;
else
flags |= NI_NUMERICHOST;
break;
default:
if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr))
flags |= NI_NUMERICHOST;
else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
flags |= NI_NUMERICHOST;
break;
}
}
break;
#endif
}
if (host == NULL || hostlen == 0) {
/*
* do nothing in this case.
* in case you are wondering if "&&" is more correct than
* "||" here: RFC3493 says that host == NULL or hostlen == 0
* means that the caller does not want the result.
*/
} else if (flags & NI_NUMERICHOST) {
/* NUMERICHOST and NAMEREQD conflicts with each other */
if (flags & NI_NAMEREQD)
return EAI_NONAME;
goto numeric;
} else {
#if USE_GETIPNODEBY
int h_error = 0;
hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
#else
hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
#if 0 // getnameinfo.c:161:9: error: variable 'h_error' set but not used
#if HAVE_H_ERRNO
h_error = h_errno;
#else
h_error = EINVAL;
#endif
#endif /* 0 */
#endif
if (hp) {
#if 0
if (flags & NI_NOFQDN) {
/*
* According to RFC3493 section 6.2, NI_NOFQDN
* means "node name portion of the FQDN shall
* be returned for local hosts." The following
* code tries to implement it by returning the
* first label (the part before the first
* period) of the FQDN. However, it is not
* clear if this always makes sense, since the
* given address may be outside of "local
* hosts." Due to the unclear description, we
* disable the code in this implementation.
*/
char *p;
p = strchr(hp->h_name, '.');
if (p)
*p = '\0';
}
#endif
if (strlen(hp->h_name) + 1 > hostlen) {
#if USE_GETIPNODEBY
freehostent(hp);
#endif
return EAI_OVERFLOW;
}
strncpy(host, hp->h_name, hostlen);
#if USE_GETIPNODEBY
freehostent(hp);
#endif
} else {
if (flags & NI_NAMEREQD)
return EAI_NONAME;
numeric:
switch (afd->a_af) {
#if INET6
case AF_INET6: {
int error;
if ((error = ip6_parsenumeric(sa, addr, host,
hostlen,
flags)) != 0)
return(error);
break;
}
#endif
default:
if (inet_ntop(afd->a_af, addr, host,
hostlen) == NULL)
return EAI_SYSTEM;
break;
}
}
}
return(0);
}
#if INET6
static int
ip6_parsenumeric(sa, addr, host, hostlen, flags)
const struct sockaddr *sa;
const char *addr;
char *host;
size_t hostlen;
int flags;
{
int numaddrlen;
char numaddr[512];
if (inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr)) == NULL)
return EAI_SYSTEM;
numaddrlen = strlen(numaddr);
if (numaddrlen + 1 > hostlen) /* don't forget terminator */
return EAI_OVERFLOW;
strncpy(host, numaddr, hostlen);
if (((const struct sockaddr_in6 *)sa)->sin6_scope_id) {
char zonebuf[SQUIDHOSTNAMELEN];
int zonelen;
zonelen = ip6_sa2str(
(const struct sockaddr_in6 *)(const void *)sa,
zonebuf, sizeof(zonebuf), flags);
if (zonelen < 0)
return EAI_OVERFLOW;
if (zonelen + 1 + numaddrlen + 1 > hostlen)
return EAI_OVERFLOW;
/* construct <numeric-addr><delim><zoneid> */
memcpy(host + numaddrlen + 1, zonebuf,
(size_t)zonelen);
host[numaddrlen] = SCOPE_DELIMITER;
host[numaddrlen + 1 + zonelen] = '\0';
}
return 0;
}
/* ARGSUSED */
static int
ip6_sa2str(sa6, buf, bufsiz, flags)
const struct sockaddr_in6 *sa6;
char *buf;
size_t bufsiz;
int flags;
{
unsigned int ifindex;
const struct in6_addr *a6;
int n;
ifindex = (unsigned int)sa6->sin6_scope_id;
a6 = &sa6->sin6_addr;
#if NI_NUMERICSCOPE
if ((flags & NI_NUMERICSCOPE) != 0) {
n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id);
if (n < 0 || n >= bufsiz)
return -1;
else
return n;
}
#endif
/* if_indextoname() does not take buffer size. not a good api... */
if ((IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6) ||
IN6_IS_ADDR_MC_NODELOCAL(a6)) && bufsiz >= IF_NAMESIZE) {
char *p = if_indextoname(ifindex, buf);
if (p)
return (strlen(p));
}
/* last resort */
n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id);
if (n < 0 || n >= bufsiz)
return -1;
else
return n;
}
#endif /* INET6 */
#endif

View File

@@ -1,29 +0,0 @@
#ifndef _getnameinfo_h
#define _getnameinfo_h
/*
* Reconstructed from KAME getnameinfo.c (in lib/)
*/
/* getnameinfo flags */
#define NI_NOFQDN 0x0001
#define NI_NUMERICHOST 0x0002 /* return numeric form of address */
#define NI_NAMEREQD 0x0004 /* request DNS name */
#define NI_NUMERICSERV 0x0008
#define NI_DGRAM 0x0010
#ifdef __cplusplus
extern "C" {
#endif
/* RFC 2553 / Posix resolver */
int getnameinfo(const struct sockaddr *sa,
socklen_t salen,
char *host,
size_t hostlen,
char *serv,
size_t servlen,
int flags );
#ifdef __cplusplus
}
#endif
#endif /* _getnameinfo_h */

View File

@@ -2,7 +2,15 @@
#ifndef _SQSTD_AUXLIB_H_ #ifndef _SQSTD_AUXLIB_H_
#define _SQSTD_AUXLIB_H_ #define _SQSTD_AUXLIB_H_
void sqstd_seterrorhandlers(HSQUIRRELVM v); #ifdef __cplusplus
void sqstd_printcallstack(HSQUIRRELVM v); extern "C" {
#endif
SQUIRREL_API void sqstd_seterrorhandlers(HSQUIRRELVM v);
SQUIRREL_API void sqstd_printcallstack(HSQUIRRELVM v);
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /* _SQSTD_AUXLIB_H_ */ #endif /* _SQSTD_AUXLIB_H_ */

View File

@@ -2,6 +2,14 @@
#ifndef _SQSTD_MATH_H_ #ifndef _SQSTD_MATH_H_
#define _SQSTD_MATH_H_ #define _SQSTD_MATH_H_
SQRESULT sqstd_register_mathlib(HSQUIRRELVM v); #ifdef __cplusplus
extern "C" {
#endif
SQUIRREL_API SQRESULT sqstd_register_mathlib(HSQUIRRELVM v);
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*_SQSTD_MATH_H_*/ #endif /*_SQSTD_MATH_H_*/

View File

@@ -2,6 +2,10 @@
#ifndef _SQSTD_STRING_H_ #ifndef _SQSTD_STRING_H_
#define _SQSTD_STRING_H_ #define _SQSTD_STRING_H_
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned int SQRexBool; typedef unsigned int SQRexBool;
typedef struct SQRex SQRex; typedef struct SQRex SQRex;
@@ -10,16 +14,20 @@ typedef struct {
SQInteger len; SQInteger len;
} SQRexMatch; } SQRexMatch;
SQRex *sqstd_rex_compile(const SQChar *pattern,const SQChar **error); SQUIRREL_API SQRex *sqstd_rex_compile(const SQChar *pattern,const SQChar **error);
void sqstd_rex_free(SQRex *exp); SQUIRREL_API void sqstd_rex_free(SQRex *exp);
SQBool sqstd_rex_match(SQRex* exp,const SQChar* text); SQUIRREL_API SQBool sqstd_rex_match(SQRex* exp,const SQChar* text);
SQBool sqstd_rex_search(SQRex* exp,const SQChar* text, const SQChar** out_begin, const SQChar** out_end); SQUIRREL_API SQBool sqstd_rex_search(SQRex* exp,const SQChar* text, const SQChar** out_begin, const SQChar** out_end);
SQBool sqstd_rex_searchrange(SQRex* exp,const SQChar* text_begin,const SQChar* text_end,const SQChar** out_begin, const SQChar** out_end); SQUIRREL_API SQBool sqstd_rex_searchrange(SQRex* exp,const SQChar* text_begin,const SQChar* text_end,const SQChar** out_begin, const SQChar** out_end);
SQInteger sqstd_rex_getsubexpcount(SQRex* exp); SQUIRREL_API SQInteger sqstd_rex_getsubexpcount(SQRex* exp);
SQBool sqstd_rex_getsubexp(SQRex* exp, SQInteger n, SQRexMatch *subexp); SQUIRREL_API SQBool sqstd_rex_getsubexp(SQRex* exp, SQInteger n, SQRexMatch *subexp);
SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen,SQChar **output); SQUIRREL_API SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen,SQChar **output);
SQRESULT sqstd_register_stringlib(HSQUIRRELVM v); SQUIRREL_API SQRESULT sqstd_register_stringlib(HSQUIRRELVM v);
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*_SQSTD_STRING_H_*/ #endif /*_SQSTD_STRING_H_*/

View File

@@ -1,41 +1,81 @@
/* /*
* Copyright (c) 2003-2011 Alberto Demichelis Copyright (c) 2003-2011 Alberto Demichelis
*
* This software is provided 'as-is', without any This software is provided 'as-is', without any
* express or implied warranty. In no event will the express or implied warranty. In no event will the
* authors be held liable for any damages arising from authors be held liable for any damages arising from
* the use of this software. the use of this software.
*
* Permission is granted to anyone to use this software Permission is granted to anyone to use this software
* for any purpose, including commercial applications, for any purpose, including commercial applications,
* and to alter it and redistribute it freely, subject and to alter it and redistribute it freely, subject
* to the following restrictions: to the following restrictions:
*
* 1. The origin of this software must not be 1. The origin of this software must not be
* misrepresented; you must not claim that misrepresented; you must not claim that
* you wrote the original software. If you you wrote the original software. If you
* use this software in a product, an use this software in a product, an
* acknowledgment in the product acknowledgment in the product
* documentation would be appreciated but is documentation would be appreciated but is
* not required. not required.
*
* 2. Altered source versions must be plainly 2. Altered source versions must be plainly
* marked as such, and must not be marked as such, and must not be
* misrepresented as being the original misrepresented as being the original
* software. software.
*
* 3. This notice may not be removed or 3. This notice may not be removed or
* altered from any source distribution. altered from any source distribution.
*/
*/
#ifndef _SQUIRREL_H_ #ifndef _SQUIRREL_H_
#define _SQUIRREL_H_ #define _SQUIRREL_H_
#include "../../../string_type.h" #ifdef __cplusplus
extern "C" {
#endif
#if defined(_MSC_VER)
# define inline __forceinline
#endif /* _MSC_VER */
#if defined(_MSC_VER) && _MSC_VER >= 1400 // MSVC 2005 safety checks
# pragma warning(disable: 4996) // '_wfopen' was declared deprecated
# define _CRT_SECURE_NO_DEPRECATE // all deprecated 'unsafe string functions
# define _CRT_NON_CONFORMING_SWPRINTFS // another deprecated stuff
#endif /* _MSC_VER >= 1400 */
#ifndef SQUIRREL_API
#define SQUIRREL_API extern
#endif
#if (defined(_WIN64) || defined(_LP64))
#ifndef _SQ64
#define _SQ64
#endif
#endif
#ifdef _SQ64
#ifdef _MSC_VER
typedef __int64 SQInteger; typedef __int64 SQInteger;
typedef unsigned __int64 SQUnsignedInteger; typedef unsigned __int64 SQUnsignedInteger;
typedef unsigned __int64 SQHash; /*should be the same size of a pointer*/ typedef unsigned __int64 SQHash; /*should be the same size of a pointer*/
#elif defined(_WIN32)
typedef long long SQInteger;
typedef unsigned long long SQUnsignedInteger;
typedef unsigned long long SQHash; /*should be the same size of a pointer*/
#else
typedef long SQInteger;
typedef unsigned long SQUnsignedInteger;
typedef unsigned long SQHash; /*should be the same size of a pointer*/
#endif
typedef int SQInt32; typedef int SQInt32;
#else
typedef int SQInteger;
typedef int SQInt32; /*must be 32 bits(also on 64bits processors)*/
typedef unsigned int SQUnsignedInteger;
typedef unsigned int SQHash; /*should be the same size of a pointer*/
#endif
#ifdef SQUSEDOUBLE #ifdef SQUSEDOUBLE
@@ -44,8 +84,17 @@ typedef double SQFloat;
typedef float SQFloat; typedef float SQFloat;
#endif #endif
#if defined(SQUSEDOUBLE) && !defined(_SQ64) || !defined(SQUSEDOUBLE) && defined(_SQ64)
#ifdef _MSC_VER
typedef __int64 SQRawObjectVal; //must be 64bits typedef __int64 SQRawObjectVal; //must be 64bits
#else
typedef long long SQRawObjectVal; //must be 64bits
#endif
#define SQ_OBJECT_RAWINIT() { _unVal.raw = 0; } #define SQ_OBJECT_RAWINIT() { _unVal.raw = 0; }
#else
typedef SQUnsignedInteger SQRawObjectVal; //is 32 bits on 32 bits builds and 64 bits otherwise
#define SQ_OBJECT_RAWINIT()
#endif
typedef void* SQUserPointer; typedef void* SQUserPointer;
typedef SQUnsignedInteger SQBool; typedef SQUnsignedInteger SQBool;
@@ -68,12 +117,78 @@ struct SQClass;
struct SQInstance; struct SQInstance;
struct SQDelegable; struct SQDelegable;
typedef char SQChar; #ifdef _UNICODE
#define MAX_CHAR 0xFFFF #define SQUNICODE
#endif
#define SQUIRREL_VERSION "Squirrel 2.2.5 stable - With custom OpenTTD modifications" #ifdef SQUNICODE
#define SQUIRREL_COPYRIGHT "Copyright (C) 2003-2010 Alberto Demichelis" #if (defined(_MSC_VER) && _MSC_VER >= 1400) // 1400 = VS8
#define SQUIRREL_AUTHOR "Alberto Demichelis"
#ifndef _WCHAR_T_DEFINED //this is if the compiler considers wchar_t as native type
typedef unsigned short wchar_t;
#endif
#endif
typedef wchar_t SQChar;
#define _SC(a) L##a
#define scstrcmp wcscmp
#define scsprintf swprintf
#define scsnprintf _snwprintf
#define scstrlen wcslen
#define scstrtod wcstod
#define scstrtol wcstol
#define scatoi _wtoi
#define scstrtoul wcstoul
#define scvsprintf vswprintf
#define scstrstr wcsstr
#define scisspace iswspace
#define scisdigit iswdigit
#define scisxdigit iswxdigit
#define scisalpha iswalpha
#define sciscntrl iswcntrl
#define scisalnum iswalnum
#define scprintf wprintf
#define scfprintf fwprintf
#define scvprintf vwprintf
#define scvfprintf vfwprintf
#define scvsnprintf _vsnwprintf
#define scstrdup _wcsdup
#define scstrrchr wcsrchr
#define scstrcat wcscat
#define MAX_CHAR 0xFFFF
#else
typedef char SQChar;
#define _SC(a) a
#define scstrcmp strcmp
#define scsprintf sprintf
#define scsnprintf snprintf
#define scstrlen strlen
#define scstrtod strtod
#define scstrtol strtol
#define scatoi atoi
#define scstrtoul strtoul
#define scvsprintf vsprintf
#define scstrstr strstr
#define scisspace isspace
#define scisdigit isdigit
#define scisxdigit isxdigit
#define sciscntrl iscntrl
#define scisalpha isalpha
#define scisalnum isalnum
#define scprintf printf
#define scfprintf fprintf
#define scvprintf vprintf
#define scvfprintf vfprintf
#define scvsnprintf vsnprintf
#define scstrdup strdup
#define scstrrchr strrchr
#define scstrcat strcat
#define MAX_CHAR 0xFFFF
#endif
#define SQUIRREL_VERSION _SC("Squirrel 2.2.5 stable - With custom OpenTTD modifications")
#define SQUIRREL_COPYRIGHT _SC("Copyright (C) 2003-2010 Alberto Demichelis")
#define SQUIRREL_AUTHOR _SC("Alberto Demichelis")
#define SQUIRREL_VERSION_NUMBER 225 #define SQUIRREL_VERSION_NUMBER 225
#define SQ_VMSTATE_IDLE 0 #define SQ_VMSTATE_IDLE 0
@@ -179,7 +294,7 @@ typedef void (*SQPRINTFUNCTION)(HSQUIRRELVM,const SQChar * ,...);
typedef SQInteger (*SQWRITEFUNC)(SQUserPointer,SQUserPointer,SQInteger); typedef SQInteger (*SQWRITEFUNC)(SQUserPointer,SQUserPointer,SQInteger);
typedef SQInteger (*SQREADFUNC)(SQUserPointer,SQUserPointer,SQInteger); typedef SQInteger (*SQREADFUNC)(SQUserPointer,SQUserPointer,SQInteger);
typedef WChar (*SQLEXREADFUNC)(SQUserPointer); typedef SQInteger (*SQLEXREADFUNC)(SQUserPointer);
typedef struct tagSQRegFunction{ typedef struct tagSQRegFunction{
const SQChar *name; const SQChar *name;
@@ -196,147 +311,147 @@ typedef struct tagSQFunctionInfo {
/*vm*/ /*vm*/
bool sq_can_suspend(HSQUIRRELVM v); SQUIRREL_API bool sq_can_suspend(HSQUIRRELVM v);
HSQUIRRELVM sq_open(SQInteger initialstacksize); SQUIRREL_API HSQUIRRELVM sq_open(SQInteger initialstacksize);
HSQUIRRELVM sq_newthread(HSQUIRRELVM friendvm, SQInteger initialstacksize); SQUIRREL_API HSQUIRRELVM sq_newthread(HSQUIRRELVM friendvm, SQInteger initialstacksize);
void sq_seterrorhandler(HSQUIRRELVM v); SQUIRREL_API void sq_seterrorhandler(HSQUIRRELVM v);
void sq_close(HSQUIRRELVM v); SQUIRREL_API void sq_close(HSQUIRRELVM v);
void sq_setforeignptr(HSQUIRRELVM v,SQUserPointer p); SQUIRREL_API void sq_setforeignptr(HSQUIRRELVM v,SQUserPointer p);
SQUserPointer sq_getforeignptr(HSQUIRRELVM v); SQUIRREL_API SQUserPointer sq_getforeignptr(HSQUIRRELVM v);
void sq_setprintfunc(HSQUIRRELVM v, SQPRINTFUNCTION printfunc); SQUIRREL_API void sq_setprintfunc(HSQUIRRELVM v, SQPRINTFUNCTION printfunc);
SQPRINTFUNCTION sq_getprintfunc(HSQUIRRELVM v); SQUIRREL_API SQPRINTFUNCTION sq_getprintfunc(HSQUIRRELVM v);
SQRESULT sq_suspendvm(HSQUIRRELVM v); SQUIRREL_API SQRESULT sq_suspendvm(HSQUIRRELVM v);
bool sq_resumecatch(HSQUIRRELVM v, int suspend = -1); SQUIRREL_API bool sq_resumecatch(HSQUIRRELVM v, int suspend = -1);
bool sq_resumeerror(HSQUIRRELVM v); SQUIRREL_API bool sq_resumeerror(HSQUIRRELVM v);
SQRESULT sq_wakeupvm(HSQUIRRELVM v,SQBool resumedret,SQBool retval,SQBool raiseerror,SQBool throwerror); SQUIRREL_API SQRESULT sq_wakeupvm(HSQUIRRELVM v,SQBool resumedret,SQBool retval,SQBool raiseerror,SQBool throwerror);
SQInteger sq_getvmstate(HSQUIRRELVM v); SQUIRREL_API SQInteger sq_getvmstate(HSQUIRRELVM v);
void sq_decreaseops(HSQUIRRELVM v, int amount); SQUIRREL_API void sq_decreaseops(HSQUIRRELVM v, int amount);
/*compiler*/ /*compiler*/
SQRESULT sq_compile(HSQUIRRELVM v,SQLEXREADFUNC read,SQUserPointer p,const SQChar *sourcename,SQBool raiseerror); SQUIRREL_API SQRESULT sq_compile(HSQUIRRELVM v,SQLEXREADFUNC read,SQUserPointer p,const SQChar *sourcename,SQBool raiseerror);
SQRESULT sq_compilebuffer(HSQUIRRELVM v,const SQChar *s,SQInteger size,const SQChar *sourcename,SQBool raiseerror); SQUIRREL_API SQRESULT sq_compilebuffer(HSQUIRRELVM v,const SQChar *s,SQInteger size,const SQChar *sourcename,SQBool raiseerror);
void sq_enabledebuginfo(HSQUIRRELVM v, SQBool enable); SQUIRREL_API void sq_enabledebuginfo(HSQUIRRELVM v, SQBool enable);
void sq_notifyallexceptions(HSQUIRRELVM v, SQBool enable); SQUIRREL_API void sq_notifyallexceptions(HSQUIRRELVM v, SQBool enable);
void sq_setcompilererrorhandler(HSQUIRRELVM v,SQCOMPILERERROR f); SQUIRREL_API void sq_setcompilererrorhandler(HSQUIRRELVM v,SQCOMPILERERROR f);
/*stack operations*/ /*stack operations*/
void sq_push(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API void sq_push(HSQUIRRELVM v,SQInteger idx);
void sq_pop(HSQUIRRELVM v,SQInteger nelemstopop); SQUIRREL_API void sq_pop(HSQUIRRELVM v,SQInteger nelemstopop);
void sq_poptop(HSQUIRRELVM v); SQUIRREL_API void sq_poptop(HSQUIRRELVM v);
void sq_remove(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API void sq_remove(HSQUIRRELVM v,SQInteger idx);
SQInteger sq_gettop(HSQUIRRELVM v); SQUIRREL_API SQInteger sq_gettop(HSQUIRRELVM v);
void sq_settop(HSQUIRRELVM v,SQInteger newtop); SQUIRREL_API void sq_settop(HSQUIRRELVM v,SQInteger newtop);
void sq_reservestack(HSQUIRRELVM v,SQInteger nsize); SQUIRREL_API void sq_reservestack(HSQUIRRELVM v,SQInteger nsize);
SQInteger sq_cmp(HSQUIRRELVM v); SQUIRREL_API SQInteger sq_cmp(HSQUIRRELVM v);
void sq_move(HSQUIRRELVM dest,HSQUIRRELVM src,SQInteger idx); SQUIRREL_API void sq_move(HSQUIRRELVM dest,HSQUIRRELVM src,SQInteger idx);
/*object creation handling*/ /*object creation handling*/
SQUserPointer sq_newuserdata(HSQUIRRELVM v,SQUnsignedInteger size); SQUIRREL_API SQUserPointer sq_newuserdata(HSQUIRRELVM v,SQUnsignedInteger size);
void sq_newtable(HSQUIRRELVM v); SQUIRREL_API void sq_newtable(HSQUIRRELVM v);
void sq_newarray(HSQUIRRELVM v,SQInteger size); SQUIRREL_API void sq_newarray(HSQUIRRELVM v,SQInteger size);
void sq_newclosure(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars); SQUIRREL_API void sq_newclosure(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars);
SQRESULT sq_setparamscheck(HSQUIRRELVM v,SQInteger nparamscheck,const SQChar *typemask); SQUIRREL_API SQRESULT sq_setparamscheck(HSQUIRRELVM v,SQInteger nparamscheck,const SQChar *typemask);
SQRESULT sq_bindenv(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQRESULT sq_bindenv(HSQUIRRELVM v,SQInteger idx);
void sq_pushstring(HSQUIRRELVM v,const SQChar *s,SQInteger len); SQUIRREL_API void sq_pushstring(HSQUIRRELVM v,const SQChar *s,SQInteger len);
void sq_pushfloat(HSQUIRRELVM v,SQFloat f); SQUIRREL_API void sq_pushfloat(HSQUIRRELVM v,SQFloat f);
void sq_pushinteger(HSQUIRRELVM v,SQInteger n); SQUIRREL_API void sq_pushinteger(HSQUIRRELVM v,SQInteger n);
void sq_pushbool(HSQUIRRELVM v,SQBool b); SQUIRREL_API void sq_pushbool(HSQUIRRELVM v,SQBool b);
void sq_pushuserpointer(HSQUIRRELVM v,SQUserPointer p); SQUIRREL_API void sq_pushuserpointer(HSQUIRRELVM v,SQUserPointer p);
void sq_pushnull(HSQUIRRELVM v); SQUIRREL_API void sq_pushnull(HSQUIRRELVM v);
SQObjectType sq_gettype(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQObjectType sq_gettype(HSQUIRRELVM v,SQInteger idx);
SQInteger sq_getsize(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQInteger sq_getsize(HSQUIRRELVM v,SQInteger idx);
SQRESULT sq_getbase(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQRESULT sq_getbase(HSQUIRRELVM v,SQInteger idx);
SQBool sq_instanceof(HSQUIRRELVM v); SQUIRREL_API SQBool sq_instanceof(HSQUIRRELVM v);
void sq_tostring(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API void sq_tostring(HSQUIRRELVM v,SQInteger idx);
void sq_tobool(HSQUIRRELVM v, SQInteger idx, SQBool *b); SQUIRREL_API void sq_tobool(HSQUIRRELVM v, SQInteger idx, SQBool *b);
SQRESULT sq_getstring(HSQUIRRELVM v,SQInteger idx,const SQChar **c); SQUIRREL_API SQRESULT sq_getstring(HSQUIRRELVM v,SQInteger idx,const SQChar **c);
SQRESULT sq_getinteger(HSQUIRRELVM v,SQInteger idx,SQInteger *i); SQUIRREL_API SQRESULT sq_getinteger(HSQUIRRELVM v,SQInteger idx,SQInteger *i);
SQRESULT sq_getfloat(HSQUIRRELVM v,SQInteger idx,SQFloat *f); SQUIRREL_API SQRESULT sq_getfloat(HSQUIRRELVM v,SQInteger idx,SQFloat *f);
SQRESULT sq_getbool(HSQUIRRELVM v,SQInteger idx,SQBool *b); SQUIRREL_API SQRESULT sq_getbool(HSQUIRRELVM v,SQInteger idx,SQBool *b);
SQRESULT sq_getthread(HSQUIRRELVM v,SQInteger idx,HSQUIRRELVM *thread); SQUIRREL_API SQRESULT sq_getthread(HSQUIRRELVM v,SQInteger idx,HSQUIRRELVM *thread);
SQRESULT sq_getuserpointer(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p); SQUIRREL_API SQRESULT sq_getuserpointer(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p);
SQRESULT sq_getuserdata(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p,SQUserPointer *typetag); SQUIRREL_API SQRESULT sq_getuserdata(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p,SQUserPointer *typetag);
SQRESULT sq_settypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer typetag); SQUIRREL_API SQRESULT sq_settypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer typetag);
SQRESULT sq_gettypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer *typetag); SQUIRREL_API SQRESULT sq_gettypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer *typetag);
void sq_setreleasehook(HSQUIRRELVM v,SQInteger idx,SQRELEASEHOOK hook); SQUIRREL_API void sq_setreleasehook(HSQUIRRELVM v,SQInteger idx,SQRELEASEHOOK hook);
SQChar *sq_getscratchpad(HSQUIRRELVM v,SQInteger minsize); SQUIRREL_API SQChar *sq_getscratchpad(HSQUIRRELVM v,SQInteger minsize);
SQRESULT sq_getfunctioninfo(HSQUIRRELVM v,SQInteger idx,SQFunctionInfo *fi); SQUIRREL_API SQRESULT sq_getfunctioninfo(HSQUIRRELVM v,SQInteger idx,SQFunctionInfo *fi);
SQRESULT sq_getclosureinfo(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger *nparams,SQUnsignedInteger *nfreevars); SQUIRREL_API SQRESULT sq_getclosureinfo(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger *nparams,SQUnsignedInteger *nfreevars);
SQRESULT sq_setnativeclosurename(HSQUIRRELVM v,SQInteger idx,const SQChar *name); SQUIRREL_API SQRESULT sq_setnativeclosurename(HSQUIRRELVM v,SQInteger idx,const SQChar *name);
SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p); SQUIRREL_API SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p);
SQRESULT sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserPointer typetag); SQUIRREL_API SQRESULT sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserPointer typetag);
SQRESULT sq_setclassudsize(HSQUIRRELVM v, SQInteger idx, SQInteger udsize); SQUIRREL_API SQRESULT sq_setclassudsize(HSQUIRRELVM v, SQInteger idx, SQInteger udsize);
SQRESULT sq_newclass(HSQUIRRELVM v,SQBool hasbase); SQUIRREL_API SQRESULT sq_newclass(HSQUIRRELVM v,SQBool hasbase);
SQRESULT sq_createinstance(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQRESULT sq_createinstance(HSQUIRRELVM v,SQInteger idx);
SQRESULT sq_setattributes(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQRESULT sq_setattributes(HSQUIRRELVM v,SQInteger idx);
SQRESULT sq_getattributes(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQRESULT sq_getattributes(HSQUIRRELVM v,SQInteger idx);
SQRESULT sq_getclass(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQRESULT sq_getclass(HSQUIRRELVM v,SQInteger idx);
void sq_weakref(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API void sq_weakref(HSQUIRRELVM v,SQInteger idx);
SQRESULT sq_getdefaultdelegate(HSQUIRRELVM v,SQObjectType t); SQUIRREL_API SQRESULT sq_getdefaultdelegate(HSQUIRRELVM v,SQObjectType t);
/*object manipulation*/ /*object manipulation*/
void sq_pushroottable(HSQUIRRELVM v); SQUIRREL_API void sq_pushroottable(HSQUIRRELVM v);
void sq_pushregistrytable(HSQUIRRELVM v); SQUIRREL_API void sq_pushregistrytable(HSQUIRRELVM v);
void sq_pushconsttable(HSQUIRRELVM v); SQUIRREL_API void sq_pushconsttable(HSQUIRRELVM v);
SQRESULT sq_setroottable(HSQUIRRELVM v); SQUIRREL_API SQRESULT sq_setroottable(HSQUIRRELVM v);
SQRESULT sq_setconsttable(HSQUIRRELVM v); SQUIRREL_API SQRESULT sq_setconsttable(HSQUIRRELVM v);
SQRESULT sq_newslot(HSQUIRRELVM v, SQInteger idx, SQBool bstatic); SQUIRREL_API SQRESULT sq_newslot(HSQUIRRELVM v, SQInteger idx, SQBool bstatic);
SQRESULT sq_deleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval); SQUIRREL_API SQRESULT sq_deleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval);
SQRESULT sq_set(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQRESULT sq_set(HSQUIRRELVM v,SQInteger idx);
SQRESULT sq_get(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQRESULT sq_get(HSQUIRRELVM v,SQInteger idx);
SQRESULT sq_rawget(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQRESULT sq_rawget(HSQUIRRELVM v,SQInteger idx);
SQRESULT sq_rawset(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQRESULT sq_rawset(HSQUIRRELVM v,SQInteger idx);
SQRESULT sq_rawdeleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval); SQUIRREL_API SQRESULT sq_rawdeleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval);
SQRESULT sq_arrayappend(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQRESULT sq_arrayappend(HSQUIRRELVM v,SQInteger idx);
SQRESULT sq_arraypop(HSQUIRRELVM v,SQInteger idx,SQBool pushval); SQUIRREL_API SQRESULT sq_arraypop(HSQUIRRELVM v,SQInteger idx,SQBool pushval);
SQRESULT sq_arrayresize(HSQUIRRELVM v,SQInteger idx,SQInteger newsize); SQUIRREL_API SQRESULT sq_arrayresize(HSQUIRRELVM v,SQInteger idx,SQInteger newsize);
SQRESULT sq_arrayreverse(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQRESULT sq_arrayreverse(HSQUIRRELVM v,SQInteger idx);
SQRESULT sq_arrayremove(HSQUIRRELVM v,SQInteger idx,SQInteger itemidx); SQUIRREL_API SQRESULT sq_arrayremove(HSQUIRRELVM v,SQInteger idx,SQInteger itemidx);
SQRESULT sq_arrayinsert(HSQUIRRELVM v,SQInteger idx,SQInteger destpos); SQUIRREL_API SQRESULT sq_arrayinsert(HSQUIRRELVM v,SQInteger idx,SQInteger destpos);
SQRESULT sq_setdelegate(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQRESULT sq_setdelegate(HSQUIRRELVM v,SQInteger idx);
SQRESULT sq_getdelegate(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQRESULT sq_getdelegate(HSQUIRRELVM v,SQInteger idx);
SQRESULT sq_clone(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQRESULT sq_clone(HSQUIRRELVM v,SQInteger idx);
SQRESULT sq_setfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval); SQUIRREL_API SQRESULT sq_setfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval);
SQRESULT sq_next(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQRESULT sq_next(HSQUIRRELVM v,SQInteger idx);
SQRESULT sq_getweakrefval(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQRESULT sq_getweakrefval(HSQUIRRELVM v,SQInteger idx);
SQRESULT sq_clear(HSQUIRRELVM v,SQInteger idx); SQUIRREL_API SQRESULT sq_clear(HSQUIRRELVM v,SQInteger idx);
/*calls*/ /*calls*/
SQRESULT sq_call(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror, int suspend = -1); SQUIRREL_API SQRESULT sq_call(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror, int suspend = -1);
SQRESULT sq_resume(HSQUIRRELVM v,SQBool retval,SQBool raiseerror); SQUIRREL_API SQRESULT sq_resume(HSQUIRRELVM v,SQBool retval,SQBool raiseerror);
const SQChar *sq_getlocal(HSQUIRRELVM v,SQUnsignedInteger level,SQUnsignedInteger idx); SQUIRREL_API const SQChar *sq_getlocal(HSQUIRRELVM v,SQUnsignedInteger level,SQUnsignedInteger idx);
const SQChar *sq_getfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval); SQUIRREL_API const SQChar *sq_getfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval);
SQRESULT sq_throwerror(HSQUIRRELVM v,const SQChar *err); SQUIRREL_API SQRESULT sq_throwerror(HSQUIRRELVM v,const SQChar *err);
void sq_reseterror(HSQUIRRELVM v); SQUIRREL_API void sq_reseterror(HSQUIRRELVM v);
void sq_getlasterror(HSQUIRRELVM v); SQUIRREL_API void sq_getlasterror(HSQUIRRELVM v);
/*raw object handling*/ /*raw object handling*/
SQRESULT sq_getstackobj(HSQUIRRELVM v,SQInteger idx,HSQOBJECT *po); SQUIRREL_API SQRESULT sq_getstackobj(HSQUIRRELVM v,SQInteger idx,HSQOBJECT *po);
void sq_pushobject(HSQUIRRELVM v,HSQOBJECT obj); SQUIRREL_API void sq_pushobject(HSQUIRRELVM v,HSQOBJECT obj);
void sq_addref(HSQUIRRELVM v,HSQOBJECT *po); SQUIRREL_API void sq_addref(HSQUIRRELVM v,HSQOBJECT *po);
SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po); SQUIRREL_API SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po);
void sq_resetobject(HSQOBJECT *po); SQUIRREL_API void sq_resetobject(HSQOBJECT *po);
const SQChar *sq_objtostring(HSQOBJECT *o); SQUIRREL_API const SQChar *sq_objtostring(HSQOBJECT *o);
SQBool sq_objtobool(HSQOBJECT *o); SQUIRREL_API SQBool sq_objtobool(HSQOBJECT *o);
SQInteger sq_objtointeger(HSQOBJECT *o); SQUIRREL_API SQInteger sq_objtointeger(HSQOBJECT *o);
SQFloat sq_objtofloat(HSQOBJECT *o); SQUIRREL_API SQFloat sq_objtofloat(HSQOBJECT *o);
SQRESULT sq_getobjtypetag(HSQOBJECT *o,SQUserPointer * typetag); SQUIRREL_API SQRESULT sq_getobjtypetag(HSQOBJECT *o,SQUserPointer * typetag);
/*GC*/ /*GC*/
SQInteger sq_collectgarbage(HSQUIRRELVM v); SQUIRREL_API SQInteger sq_collectgarbage(HSQUIRRELVM v);
/*serialization*/ /*serialization*/
SQRESULT sq_writeclosure(HSQUIRRELVM vm,SQWRITEFUNC writef,SQUserPointer up); SQUIRREL_API SQRESULT sq_writeclosure(HSQUIRRELVM vm,SQWRITEFUNC writef,SQUserPointer up);
SQRESULT sq_readclosure(HSQUIRRELVM vm,SQREADFUNC readf,SQUserPointer up); SQUIRREL_API SQRESULT sq_readclosure(HSQUIRRELVM vm,SQREADFUNC readf,SQUserPointer up);
/*mem allocation*/ /*mem allocation*/
void *sq_malloc(SQUnsignedInteger size); SQUIRREL_API void *sq_malloc(SQUnsignedInteger size);
void *sq_realloc(void* p,SQUnsignedInteger oldsize,SQUnsignedInteger newsize); SQUIRREL_API void *sq_realloc(void* p,SQUnsignedInteger oldsize,SQUnsignedInteger newsize);
void sq_free(void *p,SQUnsignedInteger size); SQUIRREL_API void sq_free(void *p,SQUnsignedInteger size);
/*debug*/ /*debug*/
SQRESULT sq_stackinfos(HSQUIRRELVM v,SQInteger level,SQStackInfos *si); SQUIRREL_API SQRESULT sq_stackinfos(HSQUIRRELVM v,SQInteger level,SQStackInfos *si);
void sq_setdebughook(HSQUIRRELVM v); SQUIRREL_API void sq_setdebughook(HSQUIRRELVM v);
/*UTILITY MACRO*/ /*UTILITY MACRO*/
#define sq_isnumeric(o) ((o)._type&SQOBJECT_NUMERIC) #define sq_isnumeric(o) ((o)._type&SQOBJECT_NUMERIC)
@@ -368,4 +483,8 @@ void sq_setdebughook(HSQUIRRELVM v);
#define SQ_FAILED(res) (res<0) #define SQ_FAILED(res) (res<0)
#define SQ_SUCCEEDED(res) (res>=0) #define SQ_SUCCEEDED(res) (res>=0)
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*_SQUIRREL_H_*/ #endif /*_SQUIRREL_H_*/

View File

@@ -1,11 +1,8 @@
/* see copyright notice in squirrel.h */ /* see copyright notice in squirrel.h */
#include "../../../stdafx.h"
#include <squirrel.h> #include <squirrel.h>
#include <sqstdaux.h> #include <sqstdaux.h>
#include <assert.h>
#include "../../../safeguards.h" #include <string.h>
void sqstd_printcallstack(HSQUIRRELVM v) void sqstd_printcallstack(HSQUIRRELVM v)
{ {
@@ -19,30 +16,30 @@ void sqstd_printcallstack(HSQUIRRELVM v)
SQInteger level=1; //1 is to skip this function that is level 0 SQInteger level=1; //1 is to skip this function that is level 0
const SQChar *name=0; const SQChar *name=0;
SQInteger seq=0; SQInteger seq=0;
pf(v,"\nCALLSTACK\n"); pf(v,_SC("\nCALLSTACK\n"));
while(SQ_SUCCEEDED(sq_stackinfos(v,level,&si))) while(SQ_SUCCEEDED(sq_stackinfos(v,level,&si)))
{ {
const SQChar *fn="unknown"; const SQChar *fn=_SC("unknown");
const SQChar *src="unknown"; const SQChar *src=_SC("unknown");
if(si.funcname)fn=si.funcname; if(si.funcname)fn=si.funcname;
if(si.source) { if(si.source) {
/* We don't want to bother users with absolute paths to all AI files. /* We don't want to bother users with absolute paths to all AI files.
* Since the path only reaches NoAI code in a formatted string we have * Since the path only reaches NoAI code in a formatted string we have
* to strip it here. Let's hope nobody installs openttd in a subdirectory * to strip it here. Let's hope nobody installs openttd in a subdirectory
* of a directory named /ai/. */ * of a directory named /ai/. */
src = strstr(si.source, "\\ai\\"); src = scstrstr(si.source, _SC("\\ai\\"));
if (!src) src = strstr(si.source, "/ai/"); if (!src) src = scstrstr(si.source, _SC("/ai/"));
if (src) { if (src) {
src += 4; src += 4;
} else { } else {
src = si.source; src = si.source;
} }
} }
pf(v,"*FUNCTION [%s()] %s line [%d]\n",fn,src,si.line); pf(v,_SC("*FUNCTION [%s()] %s line [%d]\n"),fn,src,si.line);
level++; level++;
} }
level=0; level=0;
pf(v,"\nLOCALS\n"); pf(v,_SC("\nLOCALS\n"));
for(level=0;level<10;level++){ for(level=0;level<10;level++){
seq=0; seq=0;
@@ -52,56 +49,56 @@ void sqstd_printcallstack(HSQUIRRELVM v)
switch(sq_gettype(v,-1)) switch(sq_gettype(v,-1))
{ {
case OT_NULL: case OT_NULL:
pf(v,"[%s] NULL\n",name); pf(v,_SC("[%s] NULL\n"),name);
break; break;
case OT_INTEGER: case OT_INTEGER:
sq_getinteger(v,-1,&i); sq_getinteger(v,-1,&i);
pf(v,"[%s] %d\n",name,i); pf(v,_SC("[%s] %d\n"),name,i);
break; break;
case OT_FLOAT: case OT_FLOAT:
sq_getfloat(v,-1,&f); sq_getfloat(v,-1,&f);
pf(v,"[%s] %.14g\n",name,f); pf(v,_SC("[%s] %.14g\n"),name,f);
break; break;
case OT_USERPOINTER: case OT_USERPOINTER:
pf(v,"[%s] USERPOINTER\n",name); pf(v,_SC("[%s] USERPOINTER\n"),name);
break; break;
case OT_STRING: case OT_STRING:
sq_getstring(v,-1,&s); sq_getstring(v,-1,&s);
pf(v,"[%s] \"%s\"\n",name,s); pf(v,_SC("[%s] \"%s\"\n"),name,s);
break; break;
case OT_TABLE: case OT_TABLE:
pf(v,"[%s] TABLE\n",name); pf(v,_SC("[%s] TABLE\n"),name);
break; break;
case OT_ARRAY: case OT_ARRAY:
pf(v,"[%s] ARRAY\n",name); pf(v,_SC("[%s] ARRAY\n"),name);
break; break;
case OT_CLOSURE: case OT_CLOSURE:
pf(v,"[%s] CLOSURE\n",name); pf(v,_SC("[%s] CLOSURE\n"),name);
break; break;
case OT_NATIVECLOSURE: case OT_NATIVECLOSURE:
pf(v,"[%s] NATIVECLOSURE\n",name); pf(v,_SC("[%s] NATIVECLOSURE\n"),name);
break; break;
case OT_GENERATOR: case OT_GENERATOR:
pf(v,"[%s] GENERATOR\n",name); pf(v,_SC("[%s] GENERATOR\n"),name);
break; break;
case OT_USERDATA: case OT_USERDATA:
pf(v,"[%s] USERDATA\n",name); pf(v,_SC("[%s] USERDATA\n"),name);
break; break;
case OT_THREAD: case OT_THREAD:
pf(v,"[%s] THREAD\n",name); pf(v,_SC("[%s] THREAD\n"),name);
break; break;
case OT_CLASS: case OT_CLASS:
pf(v,"[%s] CLASS\n",name); pf(v,_SC("[%s] CLASS\n"),name);
break; break;
case OT_INSTANCE: case OT_INSTANCE:
pf(v,"[%s] INSTANCE\n",name); pf(v,_SC("[%s] INSTANCE\n"),name);
break; break;
case OT_WEAKREF: case OT_WEAKREF:
pf(v,"[%s] WEAKREF\n",name); pf(v,_SC("[%s] WEAKREF\n"),name);
break; break;
case OT_BOOL:{ case OT_BOOL:{
sq_getbool(v,-1,&b); sq_getbool(v,-1,&b);
pf(v,"[%s] %s\n",name,b?"true":"false"); pf(v,_SC("[%s] %s\n"),name,b?_SC("true"):_SC("false"));
} }
break; break;
default: assert(0); break; default: assert(0); break;
@@ -119,10 +116,10 @@ static SQInteger _sqstd_aux_printerror(HSQUIRRELVM v)
const SQChar *sErr = 0; const SQChar *sErr = 0;
if(sq_gettop(v)>=1) { if(sq_gettop(v)>=1) {
if(SQ_SUCCEEDED(sq_getstring(v,2,&sErr))) { if(SQ_SUCCEEDED(sq_getstring(v,2,&sErr))) {
pf(v,"\nAN ERROR HAS OCCURED [%s]\n",sErr); pf(v,_SC("\nAN ERROR HAS OCCURED [%s]\n"),sErr);
} }
else{ else{
pf(v,"\nAN ERROR HAS OCCURED [unknown]\n"); pf(v,_SC("\nAN ERROR HAS OCCURED [unknown]\n"));
} }
sqstd_printcallstack(v); sqstd_printcallstack(v);
} }
@@ -134,7 +131,7 @@ void _sqstd_compiler_error(HSQUIRRELVM v,const SQChar *sErr,const SQChar *sSourc
{ {
SQPRINTFUNCTION pf = sq_getprintfunc(v); SQPRINTFUNCTION pf = sq_getprintfunc(v);
if(pf) { if(pf) {
pf(v,"%s line = (%d) column = (%d) : error %s\n",sSource,line,column,sErr); pf(v,_SC("%s line = (%d) column = (%d) : error %s\n"),sSource,line,column,sErr);
} }
} }

View File

@@ -1,13 +1,9 @@
/* see copyright notice in squirrel.h */ /* see copyright notice in squirrel.h */
#include "../../../stdafx.h"
#include <squirrel.h> #include <squirrel.h>
#include <math.h> #include <math.h>
#include <stdlib.h>
#include <sqstdmath.h> #include <sqstdmath.h>
#include "../../../safeguards.h"
#define SINGLE_ARG_FUNC(_funcname, num_ops) static SQInteger math_##_funcname(HSQUIRRELVM v){ \ #define SINGLE_ARG_FUNC(_funcname, num_ops) static SQInteger math_##_funcname(HSQUIRRELVM v){ \
SQFloat f; \ SQFloat f; \
sq_decreaseops(v,num_ops); \ sq_decreaseops(v,num_ops); \
@@ -30,7 +26,7 @@ static SQInteger math_srand(HSQUIRRELVM v)
{ {
SQInteger i; SQInteger i;
if(SQ_FAILED(sq_getinteger(v,2,&i))) if(SQ_FAILED(sq_getinteger(v,2,&i)))
return sq_throwerror(v,"invalid param"); return sq_throwerror(v,_SC("invalid param"));
srand((unsigned int)i); srand((unsigned int)i);
return 0; return 0;
} }
@@ -66,28 +62,28 @@ SINGLE_ARG_FUNC(floor, 1)
SINGLE_ARG_FUNC(ceil, 1) SINGLE_ARG_FUNC(ceil, 1)
SINGLE_ARG_FUNC(exp, 100) SINGLE_ARG_FUNC(exp, 100)
#define _DECL_FUNC(name,nparams,tycheck) {#name,math_##name,nparams,tycheck} #define _DECL_FUNC(name,nparams,tycheck) {_SC(#name),math_##name,nparams,tycheck}
static SQRegFunction mathlib_funcs[] = { static SQRegFunction mathlib_funcs[] = {
_DECL_FUNC(sqrt,2,".n"), _DECL_FUNC(sqrt,2,_SC(".n")),
_DECL_FUNC(sin,2,".n"), _DECL_FUNC(sin,2,_SC(".n")),
_DECL_FUNC(cos,2,".n"), _DECL_FUNC(cos,2,_SC(".n")),
_DECL_FUNC(asin,2,".n"), _DECL_FUNC(asin,2,_SC(".n")),
_DECL_FUNC(acos,2,".n"), _DECL_FUNC(acos,2,_SC(".n")),
_DECL_FUNC(log,2,".n"), _DECL_FUNC(log,2,_SC(".n")),
_DECL_FUNC(log10,2,".n"), _DECL_FUNC(log10,2,_SC(".n")),
_DECL_FUNC(tan,2,".n"), _DECL_FUNC(tan,2,_SC(".n")),
_DECL_FUNC(atan,2,".n"), _DECL_FUNC(atan,2,_SC(".n")),
_DECL_FUNC(atan2,3,".nn"), _DECL_FUNC(atan2,3,_SC(".nn")),
_DECL_FUNC(pow,3,".nn"), _DECL_FUNC(pow,3,_SC(".nn")),
_DECL_FUNC(floor,2,".n"), _DECL_FUNC(floor,2,_SC(".n")),
_DECL_FUNC(ceil,2,".n"), _DECL_FUNC(ceil,2,_SC(".n")),
_DECL_FUNC(exp,2,".n"), _DECL_FUNC(exp,2,_SC(".n")),
#ifdef EXPORT_DEFAULT_SQUIRREL_FUNCTIONS #ifdef EXPORT_DEFAULT_SQUIRREL_FUNCTIONS
_DECL_FUNC(srand,2,".n"), _DECL_FUNC(srand,2,_SC(".n")),
_DECL_FUNC(rand,1,NULL), _DECL_FUNC(rand,1,NULL),
#endif /* EXPORT_DEFAULT_SQUIRREL_FUNCTIONS */ #endif /* EXPORT_DEFAULT_SQUIRREL_FUNCTIONS */
_DECL_FUNC(fabs,2,".n"), _DECL_FUNC(fabs,2,_SC(".n")),
_DECL_FUNC(abs,2,".n"), _DECL_FUNC(abs,2,_SC(".n")),
{0,0,0,0}, {0,0,0,0},
}; };
@@ -107,11 +103,11 @@ SQRESULT sqstd_register_mathlib(HSQUIRRELVM v)
i++; i++;
} }
#ifdef EXPORT_DEFAULT_SQUIRREL_FUNCTIONS #ifdef EXPORT_DEFAULT_SQUIRREL_FUNCTIONS
sq_pushstring(v,"RAND_MAX",-1); sq_pushstring(v,_SC("RAND_MAX"),-1);
sq_pushinteger(v,RAND_MAX); sq_pushinteger(v,RAND_MAX);
sq_createslot(v,-3); sq_createslot(v,-3);
#endif /* EXPORT_DEFAULT_SQUIRREL_FUNCTIONS */ #endif /* EXPORT_DEFAULT_SQUIRREL_FUNCTIONS */
sq_pushstring(v,"PI",-1); sq_pushstring(v,_SC("PI"),-1);
sq_pushfloat(v,(SQFloat)M_PI); sq_pushfloat(v,(SQFloat)M_PI);
sq_createslot(v,-3); sq_createslot(v,-3);
return SQ_OK; return SQ_OK;

View File

@@ -1,5 +1,7 @@
/* see copyright notice in squirrel.h */ /* see copyright notice in squirrel.h */
#include <squirrel.h> #include <squirrel.h>
#include <string.h>
#include <ctype.h>
#include <exception> #include <exception>
#include "sqstdstring.h" #include "sqstdstring.h"
@@ -10,13 +12,14 @@
#endif #endif
#ifdef _DEBUG #ifdef _DEBUG
#include <stdio.h>
static const SQChar *g_nnames[] = static const SQChar *g_nnames[] =
{ {
"NONE","OP_GREEDY", "OP_OR", _SC("NONE"),_SC("OP_GREEDY"), _SC("OP_OR"),
"OP_EXPR","OP_NOCAPEXPR","OP_DOT", "OP_CLASS", _SC("OP_EXPR"),_SC("OP_NOCAPEXPR"),_SC("OP_DOT"), _SC("OP_CLASS"),
"OP_CCLASS","OP_NCLASS","OP_RANGE","OP_CHAR", _SC("OP_CCLASS"),_SC("OP_NCLASS"),_SC("OP_RANGE"),_SC("OP_CHAR"),
"OP_EOL","OP_BOL","OP_WB" _SC("OP_EOL"),_SC("OP_BOL"),_SC("OP_WB")
}; };
#endif #endif
@@ -96,7 +99,7 @@ static void sqstd_rex_error(SQRex *exp,const SQChar *error)
static void sqstd_rex_expect(SQRex *exp, SQChar n){ static void sqstd_rex_expect(SQRex *exp, SQChar n){
if((*exp->_p) != n) if((*exp->_p) != n)
sqstd_rex_error(exp, "expected paren"); sqstd_rex_error(exp, _SC("expected paren"));
exp->_p++; exp->_p++;
} }
@@ -112,7 +115,7 @@ static SQChar sqstd_rex_escapechar(SQRex *exp)
case 'f': exp->_p++; return '\f'; case 'f': exp->_p++; return '\f';
default: return (*exp->_p++); default: return (*exp->_p++);
} }
} else if(!scisprint(*exp->_p)) sqstd_rex_error(exp,"letter expected"); } else if(!scisprint(*exp->_p)) sqstd_rex_error(exp,_SC("letter expected"));
return (*exp->_p++); return (*exp->_p++);
} }
@@ -156,7 +159,7 @@ static SQInteger sqstd_rex_charnode(SQRex *exp,SQBool isclass)
} }
else if(!scisprint(*exp->_p)) { else if(!scisprint(*exp->_p)) {
sqstd_rex_error(exp,"letter expected"); sqstd_rex_error(exp,_SC("letter expected"));
} }
t = *exp->_p; exp->_p++; t = *exp->_p; exp->_p++;
return sqstd_rex_newnode(exp,t); return sqstd_rex_newnode(exp,t);
@@ -170,15 +173,15 @@ static SQInteger sqstd_rex_class(SQRex *exp)
exp->_p++; exp->_p++;
}else ret = sqstd_rex_newnode(exp,OP_CLASS); }else ret = sqstd_rex_newnode(exp,OP_CLASS);
if(*exp->_p == ']') sqstd_rex_error(exp,"empty class"); if(*exp->_p == ']') sqstd_rex_error(exp,_SC("empty class"));
chain = ret; chain = ret;
while(*exp->_p != ']' && exp->_p != exp->_eol) { while(*exp->_p != ']' && exp->_p != exp->_eol) {
if(*exp->_p == '-' && first != -1){ if(*exp->_p == '-' && first != -1){
SQInteger r; SQInteger r;
if(*exp->_p++ == ']') sqstd_rex_error(exp,"unfinished range"); if(*exp->_p++ == ']') sqstd_rex_error(exp,_SC("unfinished range"));
r = sqstd_rex_newnode(exp,OP_RANGE); r = sqstd_rex_newnode(exp,OP_RANGE);
if(exp->_nodes[first].type>*exp->_p) sqstd_rex_error(exp,"invalid range"); if(exp->_nodes[first].type>*exp->_p) sqstd_rex_error(exp,_SC("invalid range"));
if(exp->_nodes[first].type == OP_CCLASS) sqstd_rex_error(exp,"cannot use character classes in ranges"); if(exp->_nodes[first].type == OP_CCLASS) sqstd_rex_error(exp,_SC("cannot use character classes in ranges"));
exp->_nodes[r].left = exp->_nodes[first].type; exp->_nodes[r].left = exp->_nodes[first].type;
SQInteger t = sqstd_rex_escapechar(exp); SQInteger t = sqstd_rex_escapechar(exp);
exp->_nodes[r].right = t; exp->_nodes[r].right = t;
@@ -217,7 +220,7 @@ static SQInteger sqstd_rex_parsenumber(SQRex *exp)
exp->_p++; exp->_p++;
while(isdigit(*exp->_p)) { while(isdigit(*exp->_p)) {
ret = ret*10+(*exp->_p++-'0'); ret = ret*10+(*exp->_p++-'0');
if(positions==1000000000) sqstd_rex_error(exp,"overflow in numeric constant"); if(positions==1000000000) sqstd_rex_error(exp,_SC("overflow in numeric constant"));
positions *= 10; positions *= 10;
}; };
return ret; return ret;
@@ -235,7 +238,7 @@ static SQInteger sqstd_rex_element(SQRex *exp)
if(*exp->_p =='?') { if(*exp->_p =='?') {
exp->_p++; exp->_p++;
sqstd_rex_expect(exp,':'); sqstd_rex_expect(exp,_SC(':'));
expr = sqstd_rex_newnode(exp,OP_NOCAPEXPR); expr = sqstd_rex_newnode(exp,OP_NOCAPEXPR);
} }
else else
@@ -243,13 +246,13 @@ static SQInteger sqstd_rex_element(SQRex *exp)
SQInteger newn = sqstd_rex_list(exp); SQInteger newn = sqstd_rex_list(exp);
exp->_nodes[expr].left = newn; exp->_nodes[expr].left = newn;
ret = expr; ret = expr;
sqstd_rex_expect(exp,')'); sqstd_rex_expect(exp,_SC(')'));
} }
break; break;
case '[': case '[':
exp->_p++; exp->_p++;
ret = sqstd_rex_class(exp); ret = sqstd_rex_class(exp);
sqstd_rex_expect(exp,']'); sqstd_rex_expect(exp,_SC(']'));
break; break;
case SQREX_SYMBOL_END_OF_STRING: exp->_p++; ret = sqstd_rex_newnode(exp,OP_EOL);break; case SQREX_SYMBOL_END_OF_STRING: exp->_p++; ret = sqstd_rex_newnode(exp,OP_EOL);break;
case SQREX_SYMBOL_ANY_CHAR: exp->_p++; ret = sqstd_rex_newnode(exp,OP_DOT);break; case SQREX_SYMBOL_ANY_CHAR: exp->_p++; ret = sqstd_rex_newnode(exp,OP_DOT);break;
@@ -268,7 +271,7 @@ static SQInteger sqstd_rex_element(SQRex *exp)
case SQREX_SYMBOL_GREEDY_ZERO_OR_ONE: p0 = 0; p1 = 1; exp->_p++; isgreedy = SQTrue; break; case SQREX_SYMBOL_GREEDY_ZERO_OR_ONE: p0 = 0; p1 = 1; exp->_p++; isgreedy = SQTrue; break;
case '{': case '{':
exp->_p++; exp->_p++;
if(!isdigit(*exp->_p)) sqstd_rex_error(exp,"number expected"); if(!isdigit(*exp->_p)) sqstd_rex_error(exp,_SC("number expected"));
p0 = (unsigned short)sqstd_rex_parsenumber(exp); p0 = (unsigned short)sqstd_rex_parsenumber(exp);
/*******************************/ /*******************************/
switch(*exp->_p) { switch(*exp->_p) {
@@ -281,10 +284,10 @@ static SQInteger sqstd_rex_element(SQRex *exp)
if(isdigit(*exp->_p)){ if(isdigit(*exp->_p)){
p1 = (unsigned short)sqstd_rex_parsenumber(exp); p1 = (unsigned short)sqstd_rex_parsenumber(exp);
} }
sqstd_rex_expect(exp,'}'); sqstd_rex_expect(exp,_SC('}'));
break; break;
default: default:
sqstd_rex_error(exp,", or } expected"); sqstd_rex_error(exp,_SC(", or } expected"));
} }
/*******************************/ /*******************************/
isgreedy = SQTrue; isgreedy = SQTrue;
@@ -523,7 +526,7 @@ SQRex *sqstd_rex_compile(const SQChar *pattern,const SQChar **error)
SQRex *exp = (SQRex *)sq_malloc(sizeof(SQRex)); SQRex *exp = (SQRex *)sq_malloc(sizeof(SQRex));
exp->_eol = exp->_bol = NULL; exp->_eol = exp->_bol = NULL;
exp->_p = pattern; exp->_p = pattern;
exp->_nallocated = (SQInteger)strlen(pattern) * sizeof(SQChar); exp->_nallocated = (SQInteger)scstrlen(pattern) * sizeof(SQChar);
exp->_nodes = (SQRexNode *)sq_malloc(exp->_nallocated * sizeof(SQRexNode)); exp->_nodes = (SQRexNode *)sq_malloc(exp->_nallocated * sizeof(SQRexNode));
exp->_nsize = 0; exp->_nsize = 0;
exp->_matches = 0; exp->_matches = 0;
@@ -534,23 +537,23 @@ SQRex *sqstd_rex_compile(const SQChar *pattern,const SQChar **error)
SQInteger res = sqstd_rex_list(exp); SQInteger res = sqstd_rex_list(exp);
exp->_nodes[exp->_first].left = res; exp->_nodes[exp->_first].left = res;
if(*exp->_p!='\0') if(*exp->_p!='\0')
sqstd_rex_error(exp,"unexpected character"); sqstd_rex_error(exp,_SC("unexpected character"));
#ifdef _DEBUG #ifdef _DEBUG
{ {
SQInteger nsize,i; SQInteger nsize,i;
SQRexNode *t; SQRexNode *t;
nsize = exp->_nsize; nsize = exp->_nsize;
t = &exp->_nodes[0]; t = &exp->_nodes[0];
printf("\n"); scprintf(_SC("\n"));
/* XXX -- The (int) casts are needed to silent warnings on 64bit systems (SQInteger is 64bit, %d assumes 32bit, (int) is 32bit) */ /* XXX -- The (int) casts are needed to silent warnings on 64bit systems (SQInteger is 64bit, %d assumes 32bit, (int) is 32bit) */
for(i = 0;i < nsize; i++) { for(i = 0;i < nsize; i++) {
if(exp->_nodes[i].type>MAX_CHAR) if(exp->_nodes[i].type>MAX_CHAR)
printf("[%02d] %10s ",(int)i,g_nnames[exp->_nodes[i].type-MAX_CHAR]); scprintf(_SC("[%02d] %10s "),(int)i,g_nnames[exp->_nodes[i].type-MAX_CHAR]);
else else
printf("[%02d] %10c ",(int)i,exp->_nodes[i].type); scprintf(_SC("[%02d] %10c "),(int)i,exp->_nodes[i].type);
printf("left %02d right %02d next %02d\n",(int)exp->_nodes[i].left,(int)exp->_nodes[i].right,(int)exp->_nodes[i].next); scprintf(_SC("left %02d right %02d next %02d\n"),(int)exp->_nodes[i].left,(int)exp->_nodes[i].right,(int)exp->_nodes[i].next);
} }
printf("\n"); scprintf(_SC("\n"));
} }
#endif #endif
exp->_matches = (SQRexMatch *) sq_malloc(exp->_nsubexpr * sizeof(SQRexMatch)); exp->_matches = (SQRexMatch *) sq_malloc(exp->_nsubexpr * sizeof(SQRexMatch));
@@ -576,7 +579,7 @@ SQBool sqstd_rex_match(SQRex* exp,const SQChar* text)
{ {
const SQChar* res = NULL; const SQChar* res = NULL;
exp->_bol = text; exp->_bol = text;
exp->_eol = text + strlen(text); exp->_eol = text + scstrlen(text);
exp->_currsubexp = 0; exp->_currsubexp = 0;
res = sqstd_rex_matchnode(exp,exp->_nodes,text,NULL); res = sqstd_rex_matchnode(exp,exp->_nodes,text,NULL);
if(res == NULL || res != exp->_eol) if(res == NULL || res != exp->_eol)
@@ -615,7 +618,7 @@ SQBool sqstd_rex_searchrange(SQRex* exp,const SQChar* text_begin,const SQChar* t
SQBool sqstd_rex_search(SQRex* exp,const SQChar* text, const SQChar** out_begin, const SQChar** out_end) SQBool sqstd_rex_search(SQRex* exp,const SQChar* text, const SQChar** out_begin, const SQChar** out_end)
{ {
return sqstd_rex_searchrange(exp,text,text + strlen(text),out_begin,out_end); return sqstd_rex_searchrange(exp,text,text + scstrlen(text),out_begin,out_end);
} }
SQInteger sqstd_rex_getsubexpcount(SQRex* exp) SQInteger sqstd_rex_getsubexpcount(SQRex* exp)

View File

@@ -1,11 +1,22 @@
/* see copyright notice in squirrel.h */ /* see copyright notice in squirrel.h */
#include <squirrel.h> #include <squirrel.h>
#include <sqstdstring.h> #include <sqstdstring.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <assert.h>
#include <stdarg.h> #include <stdarg.h>
#ifdef SQUNICODE
#define scstrchr wcschr
#define scatoi _wtoi
#define scstrtok wcstok
#else
#define scstrchr strchr #define scstrchr strchr
#define scatoi atoi #define scatoi atoi
#define scstrtok strtok #define scstrtok strtok
#endif
#define MAX_FORMAT_LEN 20 #define MAX_FORMAT_LEN 20
#define MAX_WFORMAT_LEN 3 #define MAX_WFORMAT_LEN 3
#define ADDITIONAL_FORMAT_SPACE (100*sizeof(SQChar)) #define ADDITIONAL_FORMAT_SPACE (100*sizeof(SQChar))
@@ -16,17 +27,17 @@ static SQInteger validate_format(HSQUIRRELVM v, SQChar *fmt, const SQChar *src,
SQInteger wc = 0; SQInteger wc = 0;
SQInteger start = n; SQInteger start = n;
fmt[0] = '%'; fmt[0] = '%';
while (scstrchr("-+ #0", src[n])) n++; while (scstrchr(_SC("-+ #0"), src[n])) n++;
while (isdigit(src[n])) { while (scisdigit(src[n])) {
swidth[wc] = src[n]; swidth[wc] = src[n];
n++; n++;
wc++; wc++;
if(wc>=MAX_WFORMAT_LEN) if(wc>=MAX_WFORMAT_LEN)
return sq_throwerror(v,"width format too long"); return sq_throwerror(v,_SC("width format too long"));
} }
swidth[wc] = '\0'; swidth[wc] = '\0';
if(wc > 0) { if(wc > 0) {
width = atoi(swidth); width = scatoi(swidth);
} }
else else
width = 0; width = 0;
@@ -34,20 +45,20 @@ static SQInteger validate_format(HSQUIRRELVM v, SQChar *fmt, const SQChar *src,
n++; n++;
wc = 0; wc = 0;
while (isdigit(src[n])) { while (scisdigit(src[n])) {
swidth[wc] = src[n]; swidth[wc] = src[n];
n++; n++;
wc++; wc++;
if(wc>=MAX_WFORMAT_LEN) if(wc>=MAX_WFORMAT_LEN)
return sq_throwerror(v,"precision format too long"); return sq_throwerror(v,_SC("precision format too long"));
} }
swidth[wc] = '\0'; swidth[wc] = '\0';
if(wc > 0) { if(wc > 0) {
width += atoi(swidth); width += scatoi(swidth);
} }
} }
if (n-start > MAX_FORMAT_LEN ) if (n-start > MAX_FORMAT_LEN )
return sq_throwerror(v,"format too long"); return sq_throwerror(v,_SC("format too long"));
memcpy(&fmt[1],&src[start],((n-start)+1)*sizeof(SQChar)); memcpy(&fmt[1],&src[start],((n-start)+1)*sizeof(SQChar));
fmt[(n-start)+2] = '\0'; fmt[(n-start)+2] = '\0';
return n; return n;
@@ -64,7 +75,7 @@ static void _append_string(SQInteger &i, SQChar *dest, SQInteger allocated, cons
{ {
va_list va; va_list va;
va_start(va, fmt); va_start(va, fmt);
i += vsnprintf(&dest[i],allocated-i,fmt,va); i += scvsnprintf(&dest[i],allocated-i,fmt,va);
va_end(va); va_end(va);
} }
@@ -91,7 +102,7 @@ SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen
else { else {
n++; n++;
if( nparam > sq_gettop(v) ) if( nparam > sq_gettop(v) )
return sq_throwerror(v,"not enough paramters for the given format string"); return sq_throwerror(v,_SC("not enough paramters for the given format string"));
n = validate_format(v,fmt,format,n,w); n = validate_format(v,fmt,format,n,w);
if(n < 0) return -1; if(n < 0) return -1;
SQInteger addlen = 0; SQInteger addlen = 0;
@@ -102,24 +113,24 @@ SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen
switch(format[n]) { switch(format[n]) {
case 's': case 's':
if(SQ_FAILED(sq_getstring(v,nparam,&ts))) if(SQ_FAILED(sq_getstring(v,nparam,&ts)))
return sq_throwerror(v,"string expected for the specified format"); return sq_throwerror(v,_SC("string expected for the specified format"));
addlen = (sq_getsize(v,nparam)*sizeof(SQChar))+((w+1)*sizeof(SQChar)); addlen = (sq_getsize(v,nparam)*sizeof(SQChar))+((w+1)*sizeof(SQChar));
valtype = 's'; valtype = 's';
break; break;
case 'i': case 'd': case 'c':case 'o': case 'u': case 'x': case 'X': case 'i': case 'd': case 'c':case 'o': case 'u': case 'x': case 'X':
if(SQ_FAILED(sq_getinteger(v,nparam,&ti))) if(SQ_FAILED(sq_getinteger(v,nparam,&ti)))
return sq_throwerror(v,"integer expected for the specified format"); return sq_throwerror(v,_SC("integer expected for the specified format"));
addlen = (ADDITIONAL_FORMAT_SPACE)+((w+1)*sizeof(SQChar)); addlen = (ADDITIONAL_FORMAT_SPACE)+((w+1)*sizeof(SQChar));
valtype = 'i'; valtype = 'i';
break; break;
case 'f': case 'g': case 'G': case 'e': case 'E': case 'f': case 'g': case 'G': case 'e': case 'E':
if(SQ_FAILED(sq_getfloat(v,nparam,&tf))) if(SQ_FAILED(sq_getfloat(v,nparam,&tf)))
return sq_throwerror(v,"float expected for the specified format"); return sq_throwerror(v,_SC("float expected for the specified format"));
addlen = (ADDITIONAL_FORMAT_SPACE)+((w+1)*sizeof(SQChar)); addlen = (ADDITIONAL_FORMAT_SPACE)+((w+1)*sizeof(SQChar));
valtype = 'f'; valtype = 'f';
break; break;
default: default:
return sq_throwerror(v,"invalid format"); return sq_throwerror(v,_SC("invalid format"));
} }
n++; n++;
allocated += addlen + sizeof(SQChar); allocated += addlen + sizeof(SQChar);
@@ -151,7 +162,7 @@ static SQInteger _string_format(HSQUIRRELVM v)
static void __strip_l(const SQChar *str,const SQChar **start) static void __strip_l(const SQChar *str,const SQChar **start)
{ {
const SQChar *t = str; const SQChar *t = str;
while(((*t) != '\0') && isspace(*t)){ t++; } while(((*t) != '\0') && scisspace(*t)){ t++; }
*start = t; *start = t;
} }
@@ -162,7 +173,7 @@ static void __strip_r(const SQChar *str,SQInteger len,const SQChar **end)
return; return;
} }
const SQChar *t = &str[len-1]; const SQChar *t = &str[len-1];
while(t != str && isspace(*t)) { t--; } while(t != str && scisspace(*t)) { t--; }
*end = t+1; *end = t+1;
} }
@@ -202,7 +213,7 @@ static SQInteger _string_split(HSQUIRRELVM v)
SQChar *stemp,*tok; SQChar *stemp,*tok;
sq_getstring(v,2,&str); sq_getstring(v,2,&str);
sq_getstring(v,3,&seps); sq_getstring(v,3,&seps);
if(sq_getsize(v,3) == 0) return sq_throwerror(v,"empty separators string"); if(sq_getsize(v,3) == 0) return sq_throwerror(v,_SC("empty separators string"));
SQInteger memsize = (sq_getsize(v,2)+1)*sizeof(SQChar); SQInteger memsize = (sq_getsize(v,2)+1)*sizeof(SQChar);
stemp = sq_getscratchpad(v,memsize); stemp = sq_getscratchpad(v,memsize);
memcpy(stemp,str,memsize); memcpy(stemp,str,memsize);
@@ -244,10 +255,10 @@ static SQInteger _regexp_match(HSQUIRRELVM v)
static void _addrexmatch(HSQUIRRELVM v,const SQChar *str,const SQChar *begin,const SQChar *end) static void _addrexmatch(HSQUIRRELVM v,const SQChar *str,const SQChar *begin,const SQChar *end)
{ {
sq_newtable(v); sq_newtable(v);
sq_pushstring(v,"begin",-1); sq_pushstring(v,_SC("begin"),-1);
sq_pushinteger(v,begin - str); sq_pushinteger(v,begin - str);
sq_rawset(v,-3); sq_rawset(v,-3);
sq_pushstring(v,"end",-1); sq_pushstring(v,_SC("end"),-1);
sq_pushinteger(v,end - str); sq_pushinteger(v,end - str);
sq_rawset(v,-3); sq_rawset(v,-3);
} }
@@ -310,35 +321,35 @@ static SQInteger _regexp_constructor(HSQUIRRELVM v)
static SQInteger _regexp__typeof(HSQUIRRELVM v) static SQInteger _regexp__typeof(HSQUIRRELVM v)
{ {
sq_pushstring(v,"regexp",-1); sq_pushstring(v,_SC("regexp"),-1);
return 1; return 1;
} }
#define _DECL_REX_FUNC(name,nparams,pmask) {#name,_regexp_##name,nparams,pmask} #define _DECL_REX_FUNC(name,nparams,pmask) {_SC(#name),_regexp_##name,nparams,pmask}
static SQRegFunction rexobj_funcs[]={ static SQRegFunction rexobj_funcs[]={
_DECL_REX_FUNC(constructor,2,".s"), _DECL_REX_FUNC(constructor,2,_SC(".s")),
_DECL_REX_FUNC(search,-2,"xsn"), _DECL_REX_FUNC(search,-2,_SC("xsn")),
_DECL_REX_FUNC(match,2,"xs"), _DECL_REX_FUNC(match,2,_SC("xs")),
_DECL_REX_FUNC(capture,-2,"xsn"), _DECL_REX_FUNC(capture,-2,_SC("xsn")),
_DECL_REX_FUNC(subexpcount,1,"x"), _DECL_REX_FUNC(subexpcount,1,_SC("x")),
_DECL_REX_FUNC(_typeof,1,"x"), _DECL_REX_FUNC(_typeof,1,_SC("x")),
{0,0,0,0} {0,0,0,0}
}; };
#define _DECL_FUNC(name,nparams,pmask) {#name,_string_##name,nparams,pmask} #define _DECL_FUNC(name,nparams,pmask) {_SC(#name),_string_##name,nparams,pmask}
static SQRegFunction stringlib_funcs[]={ static SQRegFunction stringlib_funcs[]={
_DECL_FUNC(format,-2,".s"), _DECL_FUNC(format,-2,_SC(".s")),
_DECL_FUNC(strip,2,".s"), _DECL_FUNC(strip,2,_SC(".s")),
_DECL_FUNC(lstrip,2,".s"), _DECL_FUNC(lstrip,2,_SC(".s")),
_DECL_FUNC(rstrip,2,".s"), _DECL_FUNC(rstrip,2,_SC(".s")),
_DECL_FUNC(split,3,".ss"), _DECL_FUNC(split,3,_SC(".ss")),
{0,0,0,0} {0,0,0,0}
}; };
SQInteger sqstd_register_stringlib(HSQUIRRELVM v) SQInteger sqstd_register_stringlib(HSQUIRRELVM v)
{ {
sq_pushstring(v,"regexp",-1); sq_pushstring(v,_SC("regexp"),-1);
sq_newclass(v,SQFalse); sq_newclass(v,SQFalse);
SQInteger i = 0; SQInteger i = 0;
while(rexobj_funcs[i].name != 0) { while(rexobj_funcs[i].name != 0) {

View File

@@ -1,9 +1,6 @@
/* /*
* see copyright notice in squirrel.h see copyright notice in squirrel.h
*/ */
#include "../../../stdafx.h"
#include <squirrel.h> #include <squirrel.h>
#include "sqpcheader.h" #include "sqpcheader.h"
#include "sqvm.h" #include "sqvm.h"
@@ -17,16 +14,12 @@
#include "sqfuncstate.h" #include "sqfuncstate.h"
#include "sqclass.h" #include "sqclass.h"
#include "../../../string_func.h"
#include "../../../safeguards.h"
bool sq_aux_gettypedarg(HSQUIRRELVM v,SQInteger idx,SQObjectType type,SQObjectPtr **o) bool sq_aux_gettypedarg(HSQUIRRELVM v,SQInteger idx,SQObjectType type,SQObjectPtr **o)
{ {
*o = &stack_get(v,idx); *o = &stack_get(v,idx);
if(type(**o) != type){ if(type(**o) != type){
SQObjectPtr oval = v->PrintObjVal(**o); SQObjectPtr oval = v->PrintObjVal(**o);
v->Raise_Error("wrong argument type, expected '%s' got '%.50s'",IdType2Name(type),_stringval(oval)); v->Raise_Error(_SC("wrong argument type, expected '%s' got '%.50s'"),IdType2Name(type),_stringval(oval));
return false; return false;
} }
return true; return true;
@@ -36,7 +29,7 @@ bool sq_aux_gettypedarg(HSQUIRRELVM v,SQInteger idx,SQObjectType type,SQObjectPt
#define sq_aux_paramscheck(v,count) \ #define sq_aux_paramscheck(v,count) \
{ \ { \
if(sq_gettop(v) < count){ v->Raise_Error("not enough params in the stack"); return SQ_ERROR; }\ if(sq_gettop(v) < count){ v->Raise_Error(_SC("not enough params in the stack")); return SQ_ERROR; }\
} }
SQInteger sq_aux_throwobject(HSQUIRRELVM v,SQObjectPtr &e) SQInteger sq_aux_throwobject(HSQUIRRELVM v,SQObjectPtr &e)
@@ -47,9 +40,8 @@ SQInteger sq_aux_throwobject(HSQUIRRELVM v,SQObjectPtr &e)
SQInteger sq_aux_invalidtype(HSQUIRRELVM v,SQObjectType type) SQInteger sq_aux_invalidtype(HSQUIRRELVM v,SQObjectType type)
{ {
char buf[100]; scsprintf(_ss(v)->GetScratchPad(100), _SC("unexpected type %s"), IdType2Name(type));
seprintf(buf, lastof(buf), "unexpected type %s", IdType2Name(type)); return sq_throwerror(v, _ss(v)->GetScratchPad(-1));
return sq_throwerror(v, buf);
} }
HSQUIRRELVM sq_open(SQInteger initialstacksize) HSQUIRRELVM sq_open(SQInteger initialstacksize)
@@ -57,6 +49,7 @@ HSQUIRRELVM sq_open(SQInteger initialstacksize)
SQSharedState *ss; SQSharedState *ss;
SQVM *v; SQVM *v;
sq_new(ss, SQSharedState); sq_new(ss, SQSharedState);
ss->Init();
v = (SQVM *)SQ_MALLOC(sizeof(SQVM)); v = (SQVM *)SQ_MALLOC(sizeof(SQVM));
new (v) SQVM(ss); new (v) SQVM(ss);
ss->_root_vm = v; ss->_root_vm = v;
@@ -260,7 +253,7 @@ SQRESULT sq_newclass(HSQUIRRELVM v,SQBool hasbase)
if(hasbase) { if(hasbase) {
SQObjectPtr &base = stack_get(v,-1); SQObjectPtr &base = stack_get(v,-1);
if(type(base) != OT_CLASS) if(type(base) != OT_CLASS)
return sq_throwerror(v,"invalid base type"); return sq_throwerror(v,_SC("invalid base type"));
baseclass = _class(base); baseclass = _class(base);
} }
SQClass *newclass = SQClass::Create(_ss(v), baseclass); SQClass *newclass = SQClass::Create(_ss(v), baseclass);
@@ -274,7 +267,7 @@ SQBool sq_instanceof(HSQUIRRELVM v)
SQObjectPtr &inst = stack_get(v,-1); SQObjectPtr &inst = stack_get(v,-1);
SQObjectPtr &cl = stack_get(v,-2); SQObjectPtr &cl = stack_get(v,-2);
if(type(inst) != OT_INSTANCE || type(cl) != OT_CLASS) if(type(inst) != OT_INSTANCE || type(cl) != OT_CLASS)
return sq_throwerror(v,"invalid param type"); return sq_throwerror(v,_SC("invalid param type"));
return _instance(inst)->InstanceOf(_class(cl))?SQTrue:SQFalse; return _instance(inst)->InstanceOf(_class(cl))?SQTrue:SQFalse;
} }
@@ -298,7 +291,7 @@ SQRESULT sq_arraypop(HSQUIRRELVM v,SQInteger idx,SQBool pushval)
_array(*arr)->Pop(); _array(*arr)->Pop();
return SQ_OK; return SQ_OK;
} }
return sq_throwerror(v, "empty array"); return sq_throwerror(v, _SC("empty array"));
} }
SQRESULT sq_arrayresize(HSQUIRRELVM v,SQInteger idx,SQInteger newsize) SQRESULT sq_arrayresize(HSQUIRRELVM v,SQInteger idx,SQInteger newsize)
@@ -310,7 +303,7 @@ SQRESULT sq_arrayresize(HSQUIRRELVM v,SQInteger idx,SQInteger newsize)
_array(*arr)->Resize(newsize); _array(*arr)->Resize(newsize);
return SQ_OK; return SQ_OK;
} }
return sq_throwerror(v,"negative size"); return sq_throwerror(v,_SC("negative size"));
} }
@@ -339,7 +332,7 @@ SQRESULT sq_arrayremove(HSQUIRRELVM v,SQInteger idx,SQInteger itemidx)
sq_aux_paramscheck(v, 1); sq_aux_paramscheck(v, 1);
SQObjectPtr *arr; SQObjectPtr *arr;
_GETSAFE_OBJ(v, idx, OT_ARRAY,arr); _GETSAFE_OBJ(v, idx, OT_ARRAY,arr);
return _array(*arr)->Remove(itemidx) ? SQ_OK : sq_throwerror(v,"index out of range"); return _array(*arr)->Remove(itemidx) ? SQ_OK : sq_throwerror(v,_SC("index out of range"));
} }
SQRESULT sq_arrayinsert(HSQUIRRELVM v,SQInteger idx,SQInteger destpos) SQRESULT sq_arrayinsert(HSQUIRRELVM v,SQInteger idx,SQInteger destpos)
@@ -347,7 +340,7 @@ SQRESULT sq_arrayinsert(HSQUIRRELVM v,SQInteger idx,SQInteger destpos)
sq_aux_paramscheck(v, 1); sq_aux_paramscheck(v, 1);
SQObjectPtr *arr; SQObjectPtr *arr;
_GETSAFE_OBJ(v, idx, OT_ARRAY,arr); _GETSAFE_OBJ(v, idx, OT_ARRAY,arr);
SQRESULT ret = _array(*arr)->Insert(destpos, v->GetUp(-1)) ? SQ_OK : sq_throwerror(v,"index out of range"); SQRESULT ret = _array(*arr)->Insert(destpos, v->GetUp(-1)) ? SQ_OK : sq_throwerror(v,_SC("index out of range"));
v->Pop(); v->Pop();
return ret; return ret;
} }
@@ -356,6 +349,7 @@ SQRESULT sq_arrayinsert(HSQUIRRELVM v,SQInteger idx,SQInteger destpos)
void sq_newclosure(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars) void sq_newclosure(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars)
{ {
SQNativeClosure *nc = SQNativeClosure::Create(_ss(v), func); SQNativeClosure *nc = SQNativeClosure::Create(_ss(v), func);
nc->_nparamscheck = 0;
for(SQUnsignedInteger i = 0; i < nfreevars; i++) { for(SQUnsignedInteger i = 0; i < nfreevars; i++) {
nc->_outervalues.push_back(v->Top()); nc->_outervalues.push_back(v->Top());
v->Pop(); v->Pop();
@@ -373,7 +367,7 @@ SQRESULT sq_getclosureinfo(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger *nparam
*nfreevars = (SQUnsignedInteger)c->_outervalues.size(); *nfreevars = (SQUnsignedInteger)c->_outervalues.size();
return SQ_OK; return SQ_OK;
} }
return sq_throwerror(v,"the object is not a closure"); return sq_throwerror(v,_SC("the object is not a closure"));
} }
SQRESULT sq_setnativeclosurename(HSQUIRRELVM v,SQInteger idx,const SQChar *name) SQRESULT sq_setnativeclosurename(HSQUIRRELVM v,SQInteger idx,const SQChar *name)
@@ -384,20 +378,20 @@ SQRESULT sq_setnativeclosurename(HSQUIRRELVM v,SQInteger idx,const SQChar *name)
nc->_name = SQString::Create(_ss(v),name); nc->_name = SQString::Create(_ss(v),name);
return SQ_OK; return SQ_OK;
} }
return sq_throwerror(v,"the object is not a nativeclosure"); return sq_throwerror(v,_SC("the object is not a nativeclosure"));
} }
SQRESULT sq_setparamscheck(HSQUIRRELVM v,SQInteger nparamscheck,const SQChar *typemask) SQRESULT sq_setparamscheck(HSQUIRRELVM v,SQInteger nparamscheck,const SQChar *typemask)
{ {
SQObject o = stack_get(v, -1); SQObject o = stack_get(v, -1);
if(!sq_isnativeclosure(o)) if(!sq_isnativeclosure(o))
return sq_throwerror(v, "native closure expected"); return sq_throwerror(v, _SC("native closure expected"));
SQNativeClosure *nc = _nativeclosure(o); SQNativeClosure *nc = _nativeclosure(o);
nc->_nparamscheck = nparamscheck; nc->_nparamscheck = nparamscheck;
if(typemask) { if(typemask) {
SQIntVec res; SQIntVec res;
if(!CompileTypemask(res, typemask)) if(!CompileTypemask(res, typemask))
return sq_throwerror(v, "invalid typemask"); return sq_throwerror(v, _SC("invalid typemask"));
nc->_typecheck.copy(res); nc->_typecheck.copy(res);
} }
else { else {
@@ -414,12 +408,12 @@ SQRESULT sq_bindenv(HSQUIRRELVM v,SQInteger idx)
SQObjectPtr &o = stack_get(v,idx); SQObjectPtr &o = stack_get(v,idx);
if(!sq_isnativeclosure(o) && if(!sq_isnativeclosure(o) &&
!sq_isclosure(o)) !sq_isclosure(o))
return sq_throwerror(v,"the target is not a closure"); return sq_throwerror(v,_SC("the target is not a closure"));
SQObjectPtr &env = stack_get(v,-1); SQObjectPtr &env = stack_get(v,-1);
if(!sq_istable(env) && if(!sq_istable(env) &&
!sq_isclass(env) && !sq_isclass(env) &&
!sq_isinstance(env)) !sq_isinstance(env))
return sq_throwerror(v,"invalid environment"); return sq_throwerror(v,_SC("invalid environment"));
SQObjectPtr w = _refcounted(env)->GetWeakRef(type(env)); SQObjectPtr w = _refcounted(env)->GetWeakRef(type(env));
SQObjectPtr ret; SQObjectPtr ret;
if(sq_isclosure(o)) { if(sq_isclosure(o)) {
@@ -444,7 +438,7 @@ SQRESULT sq_clear(HSQUIRRELVM v,SQInteger idx)
case OT_TABLE: _table(o)->Clear(); break; case OT_TABLE: _table(o)->Clear(); break;
case OT_ARRAY: _array(o)->Resize(0); break; case OT_ARRAY: _array(o)->Resize(0); break;
default: default:
return sq_throwerror(v, "clear only works on table and array"); return sq_throwerror(v, _SC("clear only works on table and array"));
break; break;
} }
@@ -474,7 +468,7 @@ SQRESULT sq_setroottable(HSQUIRRELVM v)
v->Pop(); v->Pop();
return SQ_OK; return SQ_OK;
} }
return sq_throwerror(v, "ivalid type"); return sq_throwerror(v, _SC("ivalid type"));
} }
SQRESULT sq_setconsttable(HSQUIRRELVM v) SQRESULT sq_setconsttable(HSQUIRRELVM v)
@@ -485,7 +479,7 @@ SQRESULT sq_setconsttable(HSQUIRRELVM v)
v->Pop(); v->Pop();
return SQ_OK; return SQ_OK;
} }
return sq_throwerror(v, "ivalid type, expected table"); return sq_throwerror(v, _SC("ivalid type, expected table"));
} }
void sq_setforeignptr(HSQUIRRELVM v,SQUserPointer p) void sq_setforeignptr(HSQUIRRELVM v,SQUserPointer p)
@@ -611,7 +605,7 @@ SQRESULT sq_settypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer typetag)
switch(type(o)) { switch(type(o)) {
case OT_USERDATA: _userdata(o)->_typetag = typetag; break; case OT_USERDATA: _userdata(o)->_typetag = typetag; break;
case OT_CLASS: _class(o)->_typetag = typetag; break; case OT_CLASS: _class(o)->_typetag = typetag; break;
default: return sq_throwerror(v,"invalid object type"); default: return sq_throwerror(v,_SC("invalid object type"));
} }
return SQ_OK; return SQ_OK;
} }
@@ -631,7 +625,7 @@ SQRESULT sq_gettypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer *typetag)
{ {
SQObjectPtr &o = stack_get(v,idx); SQObjectPtr &o = stack_get(v,idx);
if(SQ_FAILED(sq_getobjtypetag(&o,typetag))) if(SQ_FAILED(sq_getobjtypetag(&o,typetag)))
return sq_throwerror(v,"invalid object type"); return sq_throwerror(v,_SC("invalid object type"));
return SQ_OK; return SQ_OK;
} }
@@ -646,7 +640,7 @@ SQRESULT sq_getuserpointer(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p)
SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p) SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p)
{ {
SQObjectPtr &o = stack_get(v,idx); SQObjectPtr &o = stack_get(v,idx);
if(type(o) != OT_INSTANCE) return sq_throwerror(v,"the object is not a class instance"); if(type(o) != OT_INSTANCE) return sq_throwerror(v,_SC("the object is not a class instance"));
_instance(o)->_userpointer = p; _instance(o)->_userpointer = p;
return SQ_OK; return SQ_OK;
} }
@@ -654,8 +648,8 @@ SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p)
SQRESULT sq_setclassudsize(HSQUIRRELVM v, SQInteger idx, SQInteger udsize) SQRESULT sq_setclassudsize(HSQUIRRELVM v, SQInteger idx, SQInteger udsize)
{ {
SQObjectPtr &o = stack_get(v,idx); SQObjectPtr &o = stack_get(v,idx);
if(type(o) != OT_CLASS) return sq_throwerror(v,"the object is not a class"); if(type(o) != OT_CLASS) return sq_throwerror(v,_SC("the object is not a class"));
if(_class(o)->_locked) return sq_throwerror(v,"the class is locked"); if(_class(o)->_locked) return sq_throwerror(v,_SC("the class is locked"));
_class(o)->_udsize = udsize; _class(o)->_udsize = udsize;
return SQ_OK; return SQ_OK;
} }
@@ -664,7 +658,7 @@ SQRESULT sq_setclassudsize(HSQUIRRELVM v, SQInteger idx, SQInteger udsize)
SQRESULT sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserPointer typetag) SQRESULT sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserPointer typetag)
{ {
SQObjectPtr &o = stack_get(v,idx); SQObjectPtr &o = stack_get(v,idx);
if(type(o) != OT_INSTANCE) return sq_throwerror(v,"the object is not a class instance"); if(type(o) != OT_INSTANCE) return sq_throwerror(v,_SC("the object is not a class instance"));
(*p) = _instance(o)->_userpointer; (*p) = _instance(o)->_userpointer;
if(typetag != 0) { if(typetag != 0) {
SQClass *cl = _instance(o)->_class; SQClass *cl = _instance(o)->_class;
@@ -673,7 +667,7 @@ SQRESULT sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserP
return SQ_OK; return SQ_OK;
cl = cl->_base; cl = cl->_base;
}while(cl != NULL); }while(cl != NULL);
return sq_throwerror(v,"invalid type tag"); return sq_throwerror(v,_SC("invalid type tag"));
} }
return SQ_OK; return SQ_OK;
} }
@@ -723,7 +717,7 @@ SQRESULT sq_newslot(HSQUIRRELVM v, SQInteger idx, SQBool bstatic)
SQObjectPtr &self = stack_get(v, idx); SQObjectPtr &self = stack_get(v, idx);
if(type(self) == OT_TABLE || type(self) == OT_CLASS) { if(type(self) == OT_TABLE || type(self) == OT_CLASS) {
SQObjectPtr &key = v->GetUp(-2); SQObjectPtr &key = v->GetUp(-2);
if(type(key) == OT_NULL) return sq_throwerror(v, "null is not a valid key"); if(type(key) == OT_NULL) return sq_throwerror(v, _SC("null is not a valid key"));
v->NewSlot(self, key, v->GetUp(-1),bstatic?true:false); v->NewSlot(self, key, v->GetUp(-1),bstatic?true:false);
v->Pop(2); v->Pop(2);
} }
@@ -736,7 +730,7 @@ SQRESULT sq_deleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval)
SQObjectPtr *self; SQObjectPtr *self;
_GETSAFE_OBJ(v, idx, OT_TABLE,self); _GETSAFE_OBJ(v, idx, OT_TABLE,self);
SQObjectPtr &key = v->GetUp(-1); SQObjectPtr &key = v->GetUp(-1);
if(type(key) == OT_NULL) return sq_throwerror(v, "null is not a valid key"); if(type(key) == OT_NULL) return sq_throwerror(v, _SC("null is not a valid key"));
SQObjectPtr res; SQObjectPtr res;
if(!v->DeleteSlot(*self, key, res)){ if(!v->DeleteSlot(*self, key, res)){
return SQ_ERROR; return SQ_ERROR;
@@ -759,7 +753,7 @@ SQRESULT sq_set(HSQUIRRELVM v,SQInteger idx)
SQRESULT sq_rawset(HSQUIRRELVM v,SQInteger idx) SQRESULT sq_rawset(HSQUIRRELVM v,SQInteger idx)
{ {
SQObjectPtr &self = stack_get(v, idx); SQObjectPtr &self = stack_get(v, idx);
if(type(v->GetUp(-2)) == OT_NULL) return sq_throwerror(v, "null key"); if(type(v->GetUp(-2)) == OT_NULL) return sq_throwerror(v, _SC("null key"));
switch(type(self)) { switch(type(self)) {
case OT_TABLE: case OT_TABLE:
_table(self)->NewSlot(v->GetUp(-2), v->GetUp(-1)); _table(self)->NewSlot(v->GetUp(-2), v->GetUp(-1));
@@ -785,7 +779,7 @@ SQRESULT sq_rawset(HSQUIRRELVM v,SQInteger idx)
break; break;
default: default:
v->Pop(2); v->Pop(2);
return sq_throwerror(v, "rawset works only on array/table/class and instance"); return sq_throwerror(v, _SC("rawset works only on array/table/class and instance"));
} }
v->Raise_IdxError(v->GetUp(-2));return SQ_ERROR; v->Raise_IdxError(v->GetUp(-2));return SQ_ERROR;
} }
@@ -798,7 +792,7 @@ SQRESULT sq_setdelegate(HSQUIRRELVM v,SQInteger idx)
switch(type) { switch(type) {
case OT_TABLE: case OT_TABLE:
if(type(mt) == OT_TABLE) { if(type(mt) == OT_TABLE) {
if(!_table(self)->SetDelegate(_table(mt))) return sq_throwerror(v, "delagate cycle"); v->Pop();} if(!_table(self)->SetDelegate(_table(mt))) return sq_throwerror(v, _SC("delagate cycle")); v->Pop();}
else if(type(mt)==OT_NULL) { else if(type(mt)==OT_NULL) {
_table(self)->SetDelegate(NULL); v->Pop(); } _table(self)->SetDelegate(NULL); v->Pop(); }
else return sq_aux_invalidtype(v,type); else return sq_aux_invalidtype(v,type);
@@ -847,7 +841,7 @@ SQRESULT sq_getdelegate(HSQUIRRELVM v,SQInteger idx)
} }
v->Push(SQObjectPtr(_delegable(self)->_delegate)); v->Push(SQObjectPtr(_delegable(self)->_delegate));
break; break;
default: return sq_throwerror(v,"wrong type"); break; default: return sq_throwerror(v,_SC("wrong type")); break;
} }
return SQ_OK; return SQ_OK;
@@ -859,7 +853,7 @@ SQRESULT sq_get(HSQUIRRELVM v,SQInteger idx)
if(v->Get(self,v->GetUp(-1),v->GetUp(-1),false,false)) if(v->Get(self,v->GetUp(-1),v->GetUp(-1),false,false))
return SQ_OK; return SQ_OK;
v->Pop(1); v->Pop(1);
return sq_throwerror(v,"the index doesn't exist"); return sq_throwerror(v,_SC("the index doesn't exist"));
} }
SQRESULT sq_rawget(HSQUIRRELVM v,SQInteger idx) SQRESULT sq_rawget(HSQUIRRELVM v,SQInteger idx)
@@ -884,10 +878,10 @@ SQRESULT sq_rawget(HSQUIRRELVM v,SQInteger idx)
break; break;
default: default:
v->Pop(1); v->Pop(1);
return sq_throwerror(v,"rawget works only on array/table/instance and class"); return sq_throwerror(v,_SC("rawget works only on array/table/instance and class"));
} }
v->Pop(1); v->Pop(1);
return sq_throwerror(v,"the index doesn't exist"); return sq_throwerror(v,_SC("the index doesn't exist"));
} }
SQRESULT sq_getstackobj(HSQUIRRELVM v,SQInteger idx,HSQOBJECT *po) SQRESULT sq_getstackobj(HSQUIRRELVM v,SQInteger idx,HSQOBJECT *po)
@@ -965,7 +959,7 @@ SQRESULT sq_resume(HSQUIRRELVM v,SQBool retval,SQBool raiseerror)
v->Pop(); v->Pop();
return SQ_OK; return SQ_OK;
} }
return sq_throwerror(v,"only generators can be resumed"); return sq_throwerror(v,_SC("only generators can be resumed"));
} }
SQRESULT sq_call(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror, int suspend) SQRESULT sq_call(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror, int suspend)
@@ -987,6 +981,9 @@ SQRESULT sq_call(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror,
v->Pop(params); v->Pop(params);
return SQ_ERROR; return SQ_ERROR;
} }
if(!v->_suspended)
v->Pop(params);
return sq_throwerror(v,_SC("call failed"));
} }
SQRESULT sq_suspendvm(HSQUIRRELVM v) SQRESULT sq_suspendvm(HSQUIRRELVM v)
@@ -998,7 +995,7 @@ SQRESULT sq_wakeupvm(HSQUIRRELVM v,SQBool wakeupret,SQBool retval,SQBool raiseer
{ {
SQObjectPtr ret; SQObjectPtr ret;
if(!v->_suspended) if(!v->_suspended)
return sq_throwerror(v,"cannot resume a vm that is not running any code"); return sq_throwerror(v,_SC("cannot resume a vm that is not running any code"));
if(wakeupret) { if(wakeupret) {
v->GetAt(v->_stackbase+v->_suspended_target)=v->GetUp(-1); //retval v->GetAt(v->_stackbase+v->_suspended_target)=v->GetUp(-1); //retval
v->Pop(); v->Pop();
@@ -1054,7 +1051,7 @@ SQRESULT sq_writeclosure(HSQUIRRELVM v,SQWRITEFUNC w,SQUserPointer up)
_GETSAFE_OBJ(v, -1, OT_CLOSURE,o); _GETSAFE_OBJ(v, -1, OT_CLOSURE,o);
unsigned short tag = SQ_BYTECODE_STREAM_TAG; unsigned short tag = SQ_BYTECODE_STREAM_TAG;
if(w(up,&tag,2) != 2) if(w(up,&tag,2) != 2)
return sq_throwerror(v,"io error"); return sq_throwerror(v,_SC("io error"));
if(!_closure(*o)->Save(v,up,w)) if(!_closure(*o)->Save(v,up,w))
return SQ_ERROR; return SQ_ERROR;
return SQ_OK; return SQ_OK;
@@ -1066,9 +1063,9 @@ SQRESULT sq_readclosure(HSQUIRRELVM v,SQREADFUNC r,SQUserPointer up)
unsigned short tag; unsigned short tag;
if(r(up,&tag,2) != 2) if(r(up,&tag,2) != 2)
return sq_throwerror(v,"io error"); return sq_throwerror(v,_SC("io error"));
if(tag != SQ_BYTECODE_STREAM_TAG) if(tag != SQ_BYTECODE_STREAM_TAG)
return sq_throwerror(v,"invalid stream"); return sq_throwerror(v,_SC("invalid stream"));
if(!SQClosure::Load(v,up,r,closure)) if(!SQClosure::Load(v,up,r,closure))
return SQ_ERROR; return SQ_ERROR;
v->Push(closure); v->Push(closure);
@@ -1113,13 +1110,13 @@ SQRESULT sq_setfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval)
if(_closure(self)->_outervalues.size()>nval){ if(_closure(self)->_outervalues.size()>nval){
_closure(self)->_outervalues[nval]=stack_get(v,-1); _closure(self)->_outervalues[nval]=stack_get(v,-1);
} }
else return sq_throwerror(v,"invalid free var index"); else return sq_throwerror(v,_SC("invalid free var index"));
break; break;
case OT_NATIVECLOSURE: case OT_NATIVECLOSURE:
if(_nativeclosure(self)->_outervalues.size()>nval){ if(_nativeclosure(self)->_outervalues.size()>nval){
_nativeclosure(self)->_outervalues[nval]=stack_get(v,-1); _nativeclosure(self)->_outervalues[nval]=stack_get(v,-1);
} }
else return sq_throwerror(v,"invalid free var index"); else return sq_throwerror(v,_SC("invalid free var index"));
break; break;
default: default:
return sq_aux_invalidtype(v,type(self)); return sq_aux_invalidtype(v,type(self));
@@ -1147,7 +1144,7 @@ SQRESULT sq_setattributes(HSQUIRRELVM v,SQInteger idx)
v->Push(attrs); v->Push(attrs);
return SQ_OK; return SQ_OK;
} }
return sq_throwerror(v,"wrong index"); return sq_throwerror(v,_SC("wrong index"));
} }
SQRESULT sq_getattributes(HSQUIRRELVM v,SQInteger idx) SQRESULT sq_getattributes(HSQUIRRELVM v,SQInteger idx)
@@ -1167,7 +1164,7 @@ SQRESULT sq_getattributes(HSQUIRRELVM v,SQInteger idx)
v->Push(attrs); v->Push(attrs);
return SQ_OK; return SQ_OK;
} }
return sq_throwerror(v,"wrong index"); return sq_throwerror(v,_SC("wrong index"));
} }
SQRESULT sq_getbase(HSQUIRRELVM v,SQInteger idx) SQRESULT sq_getbase(HSQUIRRELVM v,SQInteger idx)
@@ -1211,7 +1208,7 @@ SQRESULT sq_getweakrefval(HSQUIRRELVM v,SQInteger idx)
{ {
SQObjectPtr &o = stack_get(v,idx); SQObjectPtr &o = stack_get(v,idx);
if(type(o) != OT_WEAKREF) { if(type(o) != OT_WEAKREF) {
return sq_throwerror(v,"the object must be a weakref"); return sq_throwerror(v,_SC("the object must be a weakref"));
} }
v->Push(_weakref(o)->_obj); v->Push(_weakref(o)->_obj);
return SQ_OK; return SQ_OK;
@@ -1231,7 +1228,7 @@ SQRESULT sq_getdefaultdelegate(HSQUIRRELVM v,SQObjectType t)
case OT_CLASS: v->Push(ss->_class_default_delegate); break; case OT_CLASS: v->Push(ss->_class_default_delegate); break;
case OT_INSTANCE: v->Push(ss->_instance_default_delegate); break; case OT_INSTANCE: v->Push(ss->_instance_default_delegate); break;
case OT_WEAKREF: v->Push(ss->_weakref_default_delegate); break; case OT_WEAKREF: v->Push(ss->_weakref_default_delegate); break;
default: return sq_throwerror(v,"the type doesn't have a default delegate"); default: return sq_throwerror(v,_SC("the type doesn't have a default delegate"));
} }
return SQ_OK; return SQ_OK;
} }
@@ -1240,7 +1237,7 @@ SQRESULT sq_next(HSQUIRRELVM v,SQInteger idx)
{ {
SQObjectPtr o=stack_get(v,idx),&refpos = stack_get(v,-1),realkey,val; SQObjectPtr o=stack_get(v,idx),&refpos = stack_get(v,-1),realkey,val;
if(type(o) == OT_GENERATOR) { if(type(o) == OT_GENERATOR) {
return sq_throwerror(v,"cannot iterate a generator"); return sq_throwerror(v,_SC("cannot iterate a generator"));
} }
int faketojump; int faketojump;
if(!v->FOREACH_OP(o,realkey,val,refpos,0,666,faketojump)) if(!v->FOREACH_OP(o,realkey,val,refpos,0,666,faketojump))
@@ -1259,30 +1256,12 @@ struct BufState{
SQInteger size; SQInteger size;
}; };
WChar buf_lexfeed(SQUserPointer file) SQInteger buf_lexfeed(SQUserPointer file)
{ {
/* Convert an UTF-8 character into a WChar */ BufState *buf=(BufState*)file;
BufState *buf = (BufState *)file; if(buf->size<(buf->ptr+1))
const char *p = &buf->buf[buf->ptr]; return 0;
return buf->buf[buf->ptr++];
if (buf->size < buf->ptr + 1) return 0;
/* Read the first character, and get the length based on UTF-8 specs. If invalid, bail out. */
uint len = Utf8EncodedCharLen(*p);
if (len == 0) {
buf->ptr++;
return -1;
}
/* Read the remaining bits. */
if (buf->size < buf->ptr + len) return 0;
buf->ptr += len;
/* Convert the character, and when definitely invalid, bail out as well. */
WChar c;
if (Utf8Decode(&c, p) != len) return -1;
return c;
} }
SQRESULT sq_compilebuffer(HSQUIRRELVM v,const SQChar *s,SQInteger size,const SQChar *sourcename,SQBool raiseerror) { SQRESULT sq_compilebuffer(HSQUIRRELVM v,const SQChar *s,SQInteger size,const SQChar *sourcename,SQBool raiseerror) {

View File

@@ -1,13 +1,8 @@
/* /*
* see copyright notice in squirrel.h see copyright notice in squirrel.h
*/ */
/* /* Needs to be first due to a squirrel header defining type() and type()
* Needs to be first due to a squirrel header defining type() and type() * being used in some versions of the headers included by algorithm. */
* being used in some versions of the headers included by algorithm.
*/
#include "../../../stdafx.h"
#include <algorithm> #include <algorithm>
#include "sqpcheader.h" #include "sqpcheader.h"
#include "sqvm.h" #include "sqvm.h"
@@ -17,22 +12,21 @@
#include "sqfuncproto.h" #include "sqfuncproto.h"
#include "sqclosure.h" #include "sqclosure.h"
#include "sqclass.h" #include "sqclass.h"
#include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <ctype.h> #include <ctype.h>
#include "../../../safeguards.h"
bool str2num(const SQChar *s,SQObjectPtr &res) bool str2num(const SQChar *s,SQObjectPtr &res)
{ {
SQChar *end; SQChar *end;
if(strstr(s,".")){ if(scstrstr(s,_SC("."))){
SQFloat r = SQFloat(strtod(s,&end)); SQFloat r = SQFloat(scstrtod(s,&end));
if(s == end) return false; if(s == end) return false;
res = r; res = r;
return true; return true;
} }
else{ else{
SQInteger r = SQInteger(strtol(s,&end,10)); SQInteger r = SQInteger(scstrtol(s,&end,10));
if(s == end) return false; if(s == end) return false;
res = r; res = r;
return true; return true;
@@ -110,21 +104,21 @@ static SQInteger base_getstackinfos(HSQUIRRELVM v)
sq_getinteger(v, -1, &level); sq_getinteger(v, -1, &level);
if (SQ_SUCCEEDED(sq_stackinfos(v, level, &si))) if (SQ_SUCCEEDED(sq_stackinfos(v, level, &si)))
{ {
const SQChar *fn = "unknown"; const SQChar *fn = _SC("unknown");
const SQChar *src = "unknown"; const SQChar *src = _SC("unknown");
if(si.funcname)fn = si.funcname; if(si.funcname)fn = si.funcname;
if(si.source)src = si.source; if(si.source)src = si.source;
sq_newtable(v); sq_newtable(v);
sq_pushstring(v, "func", -1); sq_pushstring(v, _SC("func"), -1);
sq_pushstring(v, fn, -1); sq_pushstring(v, fn, -1);
sq_createslot(v, -3); sq_createslot(v, -3);
sq_pushstring(v, "src", -1); sq_pushstring(v, _SC("src"), -1);
sq_pushstring(v, src, -1); sq_pushstring(v, src, -1);
sq_createslot(v, -3); sq_createslot(v, -3);
sq_pushstring(v, "line", -1); sq_pushstring(v, _SC("line"), -1);
sq_pushinteger(v, si.line); sq_pushinteger(v, si.line);
sq_createslot(v, -3); sq_createslot(v, -3);
sq_pushstring(v, "locals", -1); sq_pushstring(v, _SC("locals"), -1);
sq_newtable(v); sq_newtable(v);
seq=0; seq=0;
while ((name = sq_getlocal(v, level, seq))) { while ((name = sq_getlocal(v, level, seq))) {
@@ -145,7 +139,7 @@ static SQInteger base_getstackinfos(HSQUIRRELVM v)
static SQInteger base_assert(HSQUIRRELVM v) static SQInteger base_assert(HSQUIRRELVM v)
{ {
if(v->IsFalse(stack_get(v,2))){ if(v->IsFalse(stack_get(v,2))){
return sq_throwerror(v,"assertion failed"); return sq_throwerror(v,_SC("assertion failed"));
} }
return 0; return 0;
} }
@@ -177,7 +171,7 @@ static SQInteger base_print(HSQUIRRELVM v)
const SQChar *str; const SQChar *str;
sq_tostring(v,2); sq_tostring(v,2);
sq_getstring(v,-1,&str); sq_getstring(v,-1,&str);
if(_ss(v)->_printfunc) _ss(v)->_printfunc(v,"%s",str); if(_ss(v)->_printfunc) _ss(v)->_printfunc(v,_SC("%s"),str);
return 0; return 0;
} }
@@ -185,7 +179,7 @@ static SQInteger base_print(HSQUIRRELVM v)
static SQInteger base_compilestring(HSQUIRRELVM v) static SQInteger base_compilestring(HSQUIRRELVM v)
{ {
SQInteger nargs=sq_gettop(v); SQInteger nargs=sq_gettop(v);
const SQChar *src=NULL,*name="unnamedbuffer"; const SQChar *src=NULL,*name=_SC("unnamedbuffer");
SQInteger size; SQInteger size;
sq_getstring(v,2,&src); sq_getstring(v,2,&src);
size=sq_getsize(v,2); size=sq_getsize(v,2);
@@ -219,7 +213,7 @@ static SQInteger base_array(HSQUIRRELVM v)
SQInteger nInitialSize = tointeger(stack_get(v,2)); SQInteger nInitialSize = tointeger(stack_get(v,2));
SQInteger ret = 1; SQInteger ret = 1;
if (nInitialSize < 0) { if (nInitialSize < 0) {
v->Raise_Error("can't create/resize array with/to size %d", nInitialSize); v->Raise_Error(_SC("can't create/resize array with/to size %d"), nInitialSize);
nInitialSize = 0; nInitialSize = 0;
ret = -1; ret = -1;
} }
@@ -244,28 +238,28 @@ static SQInteger base_type(HSQUIRRELVM v)
static SQRegFunction base_funcs[]={ static SQRegFunction base_funcs[]={
//generic //generic
#ifdef EXPORT_DEFAULT_SQUIRREL_FUNCTIONS #ifdef EXPORT_DEFAULT_SQUIRREL_FUNCTIONS
{"seterrorhandler",base_seterrorhandler,2, NULL}, {_SC("seterrorhandler"),base_seterrorhandler,2, NULL},
{"setdebughook",base_setdebughook,2, NULL}, {_SC("setdebughook"),base_setdebughook,2, NULL},
{"enabledebuginfo",base_enabledebuginfo,2, NULL}, {_SC("enabledebuginfo"),base_enabledebuginfo,2, NULL},
{"getstackinfos",base_getstackinfos,2, ".n"}, {_SC("getstackinfos"),base_getstackinfos,2, _SC(".n")},
{"getroottable",base_getroottable,1, NULL}, {_SC("getroottable"),base_getroottable,1, NULL},
{"setroottable",base_setroottable,2, NULL}, {_SC("setroottable"),base_setroottable,2, NULL},
{"getconsttable",base_getconsttable,1, NULL}, {_SC("getconsttable"),base_getconsttable,1, NULL},
{"setconsttable",base_setconsttable,2, NULL}, {_SC("setconsttable"),base_setconsttable,2, NULL},
#endif #endif
{"assert",base_assert,2, NULL}, {_SC("assert"),base_assert,2, NULL},
{"print",base_print,2, NULL}, {_SC("print"),base_print,2, NULL},
#ifdef EXPORT_DEFAULT_SQUIRREL_FUNCTIONS #ifdef EXPORT_DEFAULT_SQUIRREL_FUNCTIONS
{"compilestring",base_compilestring,-2, ".ss"}, {_SC("compilestring"),base_compilestring,-2, _SC(".ss")},
{"newthread",base_newthread,2, ".c"}, {_SC("newthread"),base_newthread,2, _SC(".c")},
{"suspend",base_suspend,-1, NULL}, {_SC("suspend"),base_suspend,-1, NULL},
#endif #endif
{"array",base_array,-2, ".n"}, {_SC("array"),base_array,-2, _SC(".n")},
{"type",base_type,2, NULL}, {_SC("type"),base_type,2, NULL},
#ifdef EXPORT_DEFAULT_SQUIRREL_FUNCTIONS #ifdef EXPORT_DEFAULT_SQUIRREL_FUNCTIONS
{"dummy",base_dummy,0,NULL}, {_SC("dummy"),base_dummy,0,NULL},
#ifndef NO_GARBAGE_COLLECTOR #ifndef NO_GARBAGE_COLLECTOR
{"collectgarbage",base_collectgarbage,1, "t"}, {_SC("collectgarbage"),base_collectgarbage,1, _SC("t")},
#endif #endif
#endif #endif
{0,0,0,0} {0,0,0,0}
@@ -283,16 +277,16 @@ void sq_base_register(HSQUIRRELVM v)
sq_createslot(v,-3); sq_createslot(v,-3);
i++; i++;
} }
sq_pushstring(v,"_version_",-1); sq_pushstring(v,_SC("_version_"),-1);
sq_pushstring(v,SQUIRREL_VERSION,-1); sq_pushstring(v,SQUIRREL_VERSION,-1);
sq_createslot(v,-3); sq_createslot(v,-3);
sq_pushstring(v,"_charsize_",-1); sq_pushstring(v,_SC("_charsize_"),-1);
sq_pushinteger(v,sizeof(SQChar)); sq_pushinteger(v,sizeof(SQChar));
sq_createslot(v,-3); sq_createslot(v,-3);
sq_pushstring(v,"_intsize_",-1); sq_pushstring(v,_SC("_intsize_"),-1);
sq_pushinteger(v,sizeof(SQInteger)); sq_pushinteger(v,sizeof(SQInteger));
sq_createslot(v,-3); sq_createslot(v,-3);
sq_pushstring(v,"_floatsize_",-1); sq_pushstring(v,_SC("_floatsize_"),-1);
sq_pushinteger(v,sizeof(SQFloat)); sq_pushinteger(v,sizeof(SQFloat));
sq_createslot(v,-3); sq_createslot(v,-3);
sq_pop(v,1); sq_pop(v,1);
@@ -314,7 +308,7 @@ static SQInteger default_delegate_tofloat(HSQUIRRELVM v)
v->Push(SQObjectPtr(tofloat(res))); v->Push(SQObjectPtr(tofloat(res)));
break; break;
}} }}
return sq_throwerror(v, "cannot convert the string"); return sq_throwerror(v, _SC("cannot convert the string"));
break; break;
case OT_INTEGER:case OT_FLOAT: case OT_INTEGER:case OT_FLOAT:
v->Push(SQObjectPtr(tofloat(o))); v->Push(SQObjectPtr(tofloat(o)));
@@ -339,7 +333,7 @@ static SQInteger default_delegate_tointeger(HSQUIRRELVM v)
v->Push(SQObjectPtr(tointeger(res))); v->Push(SQObjectPtr(tointeger(res)));
break; break;
}} }}
return sq_throwerror(v, "cannot convert the string"); return sq_throwerror(v, _SC("cannot convert the string"));
break; break;
case OT_INTEGER:case OT_FLOAT: case OT_INTEGER:case OT_FLOAT:
v->Push(SQObjectPtr(tointeger(o))); v->Push(SQObjectPtr(tointeger(o)));
@@ -415,14 +409,14 @@ static SQInteger table_rawget(HSQUIRRELVM v)
SQRegFunction SQSharedState::_table_default_delegate_funcz[]={ SQRegFunction SQSharedState::_table_default_delegate_funcz[]={
{"len",default_delegate_len,1, "t"}, {_SC("len"),default_delegate_len,1, _SC("t")},
{"rawget",table_rawget,2, "t"}, {_SC("rawget"),table_rawget,2, _SC("t")},
{"rawset",table_rawset,3, "t"}, {_SC("rawset"),table_rawset,3, _SC("t")},
{"rawdelete",table_rawdelete,2, "t"}, {_SC("rawdelete"),table_rawdelete,2, _SC("t")},
{"rawin",container_rawexists,2, "t"}, {_SC("rawin"),container_rawexists,2, _SC("t")},
{"weakref",obj_delegate_weakref,1, NULL }, {_SC("weakref"),obj_delegate_weakref,1, NULL },
{"tostring",default_delegate_tostring,1, "."}, {_SC("tostring"),default_delegate_tostring,1, _SC(".")},
{"clear",obj_clear,1, "."}, {_SC("clear"),obj_clear,1, _SC(".")},
{0,0,0,0} {0,0,0,0}
}; };
@@ -456,7 +450,7 @@ static SQInteger array_top(HSQUIRRELVM v)
v->Push(_array(o)->Top()); v->Push(_array(o)->Top());
return 1; return 1;
} }
else return sq_throwerror(v,"top() on a empty array"); else return sq_throwerror(v,_SC("top() on a empty array"));
} }
static SQInteger array_insert(HSQUIRRELVM v) static SQInteger array_insert(HSQUIRRELVM v)
@@ -465,7 +459,7 @@ static SQInteger array_insert(HSQUIRRELVM v)
SQObject &idx=stack_get(v,2); SQObject &idx=stack_get(v,2);
SQObject &val=stack_get(v,3); SQObject &val=stack_get(v,3);
if(!_array(o)->Insert(tointeger(idx),val)) if(!_array(o)->Insert(tointeger(idx),val))
return sq_throwerror(v,"index out of range"); return sq_throwerror(v,_SC("index out of range"));
return 0; return 0;
} }
@@ -473,14 +467,14 @@ static SQInteger array_remove(HSQUIRRELVM v)
{ {
SQObject &o = stack_get(v, 1); SQObject &o = stack_get(v, 1);
SQObject &idx = stack_get(v, 2); SQObject &idx = stack_get(v, 2);
if(!sq_isnumeric(idx)) return sq_throwerror(v, "wrong type"); if(!sq_isnumeric(idx)) return sq_throwerror(v, _SC("wrong type"));
SQObjectPtr val; SQObjectPtr val;
if(_array(o)->Get(tointeger(idx), val)) { if(_array(o)->Get(tointeger(idx), val)) {
_array(o)->Remove(tointeger(idx)); _array(o)->Remove(tointeger(idx));
v->Push(val); v->Push(val);
return 1; return 1;
} }
return sq_throwerror(v, "idx out of range"); return sq_throwerror(v, _SC("idx out of range"));
} }
static SQInteger array_resize(HSQUIRRELVM v) static SQInteger array_resize(HSQUIRRELVM v)
@@ -494,7 +488,7 @@ static SQInteger array_resize(HSQUIRRELVM v)
_array(o)->Resize(tointeger(nsize),fill); _array(o)->Resize(tointeger(nsize),fill);
return 0; return 0;
} }
return sq_throwerror(v, "size must be a number"); return sq_throwerror(v, _SC("size must be a number"));
} }
@@ -511,11 +505,11 @@ bool _sort_compare(HSQUIRRELVM v,SQObjectPtr &a,SQObjectPtr &b,SQInteger func,SQ
v->Push(b); v->Push(b);
if(SQ_FAILED(sq_call(v, 3, SQTrue, SQFalse))) { if(SQ_FAILED(sq_call(v, 3, SQTrue, SQFalse))) {
if(!sq_isstring( v->_lasterror)) if(!sq_isstring( v->_lasterror))
v->Raise_Error("compare func failed"); v->Raise_Error(_SC("compare func failed"));
return false; return false;
} }
if(SQ_FAILED(sq_getinteger(v, -1, &ret))) { if(SQ_FAILED(sq_getinteger(v, -1, &ret))) {
v->Raise_Error("numeric value expected as return value of the compare function"); v->Raise_Error(_SC("numeric value expected as return value of the compare function"));
return false; return false;
} }
sq_settop(v, top); sq_settop(v, top);
@@ -551,7 +545,7 @@ bool _hsort_sift_down(HSQUIRRELVM v,SQArray *arr, SQInteger root, SQInteger bott
return false; return false;
if (ret < 0) { if (ret < 0) {
if (root == maxChild) { if (root == maxChild) {
v->Raise_Error("inconsistent compare function"); v->Raise_Error(_SC("inconsistent compare function"));
return false; // We'd be swapping ourselve. The compare function is incorrect return false; // We'd be swapping ourselve. The compare function is incorrect
} }
_Swap(arr->_values[root],arr->_values[maxChild]); _Swap(arr->_values[root],arr->_values[maxChild]);
@@ -602,8 +596,8 @@ static SQInteger array_slice(HSQUIRRELVM v)
SQInteger alen = _array(o)->Size(); SQInteger alen = _array(o)->Size();
if(sidx < 0)sidx = alen + sidx; if(sidx < 0)sidx = alen + sidx;
if(eidx < 0)eidx = alen + eidx; if(eidx < 0)eidx = alen + eidx;
if(eidx < sidx)return sq_throwerror(v,"wrong indexes"); if(eidx < sidx)return sq_throwerror(v,_SC("wrong indexes"));
if(eidx > alen)return sq_throwerror(v,"slice out of range"); if(eidx > alen)return sq_throwerror(v,_SC("slice out of range"));
SQArray *arr=SQArray::Create(_ss(v),eidx-sidx); SQArray *arr=SQArray::Create(_ss(v),eidx-sidx);
SQObjectPtr t; SQObjectPtr t;
SQInteger count=0; SQInteger count=0;
@@ -617,21 +611,21 @@ static SQInteger array_slice(HSQUIRRELVM v)
} }
SQRegFunction SQSharedState::_array_default_delegate_funcz[]={ SQRegFunction SQSharedState::_array_default_delegate_funcz[]={
{"len",default_delegate_len,1, "a"}, {_SC("len"),default_delegate_len,1, _SC("a")},
{"append",array_append,2, "a"}, {_SC("append"),array_append,2, _SC("a")},
{"extend",array_extend,2, "aa"}, {_SC("extend"),array_extend,2, _SC("aa")},
{"push",array_append,2, "a"}, {_SC("push"),array_append,2, _SC("a")},
{"pop",array_pop,1, "a"}, {_SC("pop"),array_pop,1, _SC("a")},
{"top",array_top,1, "a"}, {_SC("top"),array_top,1, _SC("a")},
{"insert",array_insert,3, "an"}, {_SC("insert"),array_insert,3, _SC("an")},
{"remove",array_remove,2, "an"}, {_SC("remove"),array_remove,2, _SC("an")},
{"resize",array_resize,-2, "an"}, {_SC("resize"),array_resize,-2, _SC("an")},
{"reverse",array_reverse,1, "a"}, {_SC("reverse"),array_reverse,1, _SC("a")},
{"sort",array_sort,-1, "ac"}, {_SC("sort"),array_sort,-1, _SC("ac")},
{"slice",array_slice,-1, "ann"}, {_SC("slice"),array_slice,-1, _SC("ann")},
{"weakref",obj_delegate_weakref,1, NULL }, {_SC("weakref"),obj_delegate_weakref,1, NULL },
{"tostring",default_delegate_tostring,1, "."}, {_SC("tostring"),default_delegate_tostring,1, _SC(".")},
{"clear",obj_clear,1, "."}, {_SC("clear"),obj_clear,1, _SC(".")},
{0,0,0,0} {0,0,0,0}
}; };
@@ -644,8 +638,8 @@ static SQInteger string_slice(HSQUIRRELVM v)
SQInteger slen = _string(o)->_len; SQInteger slen = _string(o)->_len;
if(sidx < 0)sidx = slen + sidx; if(sidx < 0)sidx = slen + sidx;
if(eidx < 0)eidx = slen + eidx; if(eidx < 0)eidx = slen + eidx;
if(eidx < sidx) return sq_throwerror(v,"wrong indexes"); if(eidx < sidx) return sq_throwerror(v,_SC("wrong indexes"));
if(eidx > slen) return sq_throwerror(v,"slice out of range"); if(eidx > slen) return sq_throwerror(v,_SC("slice out of range"));
v->Push(SQString::Create(_ss(v),&_stringval(o)[sidx],eidx-sidx)); v->Push(SQString::Create(_ss(v),&_stringval(o)[sidx],eidx-sidx));
return 1; return 1;
} }
@@ -657,7 +651,7 @@ static SQInteger string_find(HSQUIRRELVM v)
if(((top=sq_gettop(v))>1) && SQ_SUCCEEDED(sq_getstring(v,1,&str)) && SQ_SUCCEEDED(sq_getstring(v,2,&substr))){ if(((top=sq_gettop(v))>1) && SQ_SUCCEEDED(sq_getstring(v,1,&str)) && SQ_SUCCEEDED(sq_getstring(v,2,&substr))){
if(top>2)sq_getinteger(v,3,&start_idx); if(top>2)sq_getinteger(v,3,&start_idx);
if((sq_getsize(v,1)>start_idx) && (start_idx>=0)){ if((sq_getsize(v,1)>start_idx) && (start_idx>=0)){
ret=strstr(&str[start_idx],substr); ret=scstrstr(&str[start_idx],substr);
if(ret){ if(ret){
sq_pushinteger(v,(SQInteger)(ret-str)); sq_pushinteger(v,(SQInteger)(ret-str));
return 1; return 1;
@@ -665,7 +659,7 @@ static SQInteger string_find(HSQUIRRELVM v)
} }
return 0; return 0;
} }
return sq_throwerror(v,"invalid param"); return sq_throwerror(v,_SC("invalid param"));
} }
#define STRING_TOFUNCZ(func) static SQInteger string_##func(HSQUIRRELVM v) \ #define STRING_TOFUNCZ(func) static SQInteger string_##func(HSQUIRRELVM v) \
@@ -673,7 +667,7 @@ static SQInteger string_find(HSQUIRRELVM v)
SQObject str=stack_get(v,1); \ SQObject str=stack_get(v,1); \
SQInteger len=_string(str)->_len; \ SQInteger len=_string(str)->_len; \
const SQChar *sThis=_stringval(str); \ const SQChar *sThis=_stringval(str); \
SQChar *sNew=(_ss(v)->GetScratchPad(len)); \ SQChar *sNew=(_ss(v)->GetScratchPad(rsl(len))); \
for(SQInteger i=0;i<len;i++) sNew[i]=func(sThis[i]); \ for(SQInteger i=0;i<len;i++) sNew[i]=func(sThis[i]); \
v->Push(SQString::Create(_ss(v),sNew,len)); \ v->Push(SQString::Create(_ss(v),sNew,len)); \
return 1; \ return 1; \
@@ -684,25 +678,25 @@ STRING_TOFUNCZ(tolower)
STRING_TOFUNCZ(toupper) STRING_TOFUNCZ(toupper)
SQRegFunction SQSharedState::_string_default_delegate_funcz[]={ SQRegFunction SQSharedState::_string_default_delegate_funcz[]={
{"len",default_delegate_len,1, "s"}, {_SC("len"),default_delegate_len,1, _SC("s")},
{"tointeger",default_delegate_tointeger,1, "s"}, {_SC("tointeger"),default_delegate_tointeger,1, _SC("s")},
{"tofloat",default_delegate_tofloat,1, "s"}, {_SC("tofloat"),default_delegate_tofloat,1, _SC("s")},
{"tostring",default_delegate_tostring,1, "."}, {_SC("tostring"),default_delegate_tostring,1, _SC(".")},
{"slice",string_slice,-1, " s n n"}, {_SC("slice"),string_slice,-1, _SC(" s n n")},
{"find",string_find,-2, "s s n "}, {_SC("find"),string_find,-2, _SC("s s n ")},
{"tolower",string_tolower,1, "s"}, {_SC("tolower"),string_tolower,1, _SC("s")},
{"toupper",string_toupper,1, "s"}, {_SC("toupper"),string_toupper,1, _SC("s")},
{"weakref",obj_delegate_weakref,1, NULL }, {_SC("weakref"),obj_delegate_weakref,1, NULL },
{0,0,0,0} {0,0,0,0}
}; };
//INTEGER DEFAULT DELEGATE////////////////////////// //INTEGER DEFAULT DELEGATE//////////////////////////
SQRegFunction SQSharedState::_number_default_delegate_funcz[]={ SQRegFunction SQSharedState::_number_default_delegate_funcz[]={
{"tointeger",default_delegate_tointeger,1, "n|b"}, {_SC("tointeger"),default_delegate_tointeger,1, _SC("n|b")},
{"tofloat",default_delegate_tofloat,1, "n|b"}, {_SC("tofloat"),default_delegate_tofloat,1, _SC("n|b")},
{"tostring",default_delegate_tostring,1, "."}, {_SC("tostring"),default_delegate_tostring,1, _SC(".")},
{"tochar",number_delegate_tochar,1, "n|b"}, {_SC("tochar"),number_delegate_tochar,1, _SC("n|b")},
{"weakref",obj_delegate_weakref,1, NULL }, {_SC("weakref"),obj_delegate_weakref,1, NULL },
{0,0,0,0} {0,0,0,0}
}; };
@@ -754,19 +748,19 @@ static SQInteger closure_getinfos(HSQUIRRELVM v) {
_array(params)->Set((SQInteger)n,f->_parameters[n]); _array(params)->Set((SQInteger)n,f->_parameters[n]);
} }
if(f->_varparams) { if(f->_varparams) {
_array(params)->Set(nparams-1,SQString::Create(_ss(v),"...",-1)); _array(params)->Set(nparams-1,SQString::Create(_ss(v),_SC("..."),-1));
} }
res->NewSlot(SQString::Create(_ss(v),"native",-1),false); res->NewSlot(SQString::Create(_ss(v),_SC("native"),-1),false);
res->NewSlot(SQString::Create(_ss(v),"name",-1),f->_name); res->NewSlot(SQString::Create(_ss(v),_SC("name"),-1),f->_name);
res->NewSlot(SQString::Create(_ss(v),"src",-1),f->_sourcename); res->NewSlot(SQString::Create(_ss(v),_SC("src"),-1),f->_sourcename);
res->NewSlot(SQString::Create(_ss(v),"parameters",-1),params); res->NewSlot(SQString::Create(_ss(v),_SC("parameters"),-1),params);
res->NewSlot(SQString::Create(_ss(v),"varargs",-1),f->_varparams); res->NewSlot(SQString::Create(_ss(v),_SC("varargs"),-1),f->_varparams);
} }
else { //OT_NATIVECLOSURE else { //OT_NATIVECLOSURE
SQNativeClosure *nc = _nativeclosure(o); SQNativeClosure *nc = _nativeclosure(o);
res->NewSlot(SQString::Create(_ss(v),"native",-1),true); res->NewSlot(SQString::Create(_ss(v),_SC("native"),-1),true);
res->NewSlot(SQString::Create(_ss(v),"name",-1),nc->_name); res->NewSlot(SQString::Create(_ss(v),_SC("name"),-1),nc->_name);
res->NewSlot(SQString::Create(_ss(v),"paramscheck",-1),nc->_nparamscheck); res->NewSlot(SQString::Create(_ss(v),_SC("paramscheck"),-1),nc->_nparamscheck);
SQObjectPtr typecheck; SQObjectPtr typecheck;
if(nc->_typecheck.size() > 0) { if(nc->_typecheck.size() > 0) {
typecheck = typecheck =
@@ -775,7 +769,7 @@ static SQInteger closure_getinfos(HSQUIRRELVM v) {
_array(typecheck)->Set((SQInteger)n,nc->_typecheck[n]); _array(typecheck)->Set((SQInteger)n,nc->_typecheck[n]);
} }
} }
res->NewSlot(SQString::Create(_ss(v),"typecheck",-1),typecheck); res->NewSlot(SQString::Create(_ss(v),_SC("typecheck"),-1),typecheck);
} }
v->Push(res); v->Push(res);
return 1; return 1;
@@ -783,14 +777,14 @@ static SQInteger closure_getinfos(HSQUIRRELVM v) {
SQRegFunction SQSharedState::_closure_default_delegate_funcz[]={ SQRegFunction SQSharedState::_closure_default_delegate_funcz[]={
{"call",closure_call,-1, "c"}, {_SC("call"),closure_call,-1, _SC("c")},
{"pcall",closure_pcall,-1, "c"}, {_SC("pcall"),closure_pcall,-1, _SC("c")},
{"acall",closure_acall,2, "ca"}, {_SC("acall"),closure_acall,2, _SC("ca")},
{"pacall",closure_pacall,2, "ca"}, {_SC("pacall"),closure_pacall,2, _SC("ca")},
{"weakref",obj_delegate_weakref,1, NULL }, {_SC("weakref"),obj_delegate_weakref,1, NULL },
{"tostring",default_delegate_tostring,1, "."}, {_SC("tostring"),default_delegate_tostring,1, _SC(".")},
{"bindenv",closure_bindenv,2, "c x|y|t"}, {_SC("bindenv"),closure_bindenv,2, _SC("c x|y|t")},
{"getinfos",closure_getinfos,1, "c"}, {_SC("getinfos"),closure_getinfos,1, _SC("c")},
{0,0,0,0} {0,0,0,0}
}; };
@@ -799,17 +793,17 @@ static SQInteger generator_getstatus(HSQUIRRELVM v)
{ {
SQObject &o=stack_get(v,1); SQObject &o=stack_get(v,1);
switch(_generator(o)->_state){ switch(_generator(o)->_state){
case SQGenerator::eSuspended:v->Push(SQString::Create(_ss(v),"suspended"));break; case SQGenerator::eSuspended:v->Push(SQString::Create(_ss(v),_SC("suspended")));break;
case SQGenerator::eRunning:v->Push(SQString::Create(_ss(v),"running"));break; case SQGenerator::eRunning:v->Push(SQString::Create(_ss(v),_SC("running")));break;
case SQGenerator::eDead:v->Push(SQString::Create(_ss(v),"dead"));break; case SQGenerator::eDead:v->Push(SQString::Create(_ss(v),_SC("dead")));break;
} }
return 1; return 1;
} }
SQRegFunction SQSharedState::_generator_default_delegate_funcz[]={ SQRegFunction SQSharedState::_generator_default_delegate_funcz[]={
{"getstatus",generator_getstatus,1, "g"}, {_SC("getstatus"),generator_getstatus,1, _SC("g")},
{"weakref",obj_delegate_weakref,1, NULL }, {_SC("weakref"),obj_delegate_weakref,1, NULL },
{"tostring",default_delegate_tostring,1, "."}, {_SC("tostring"),default_delegate_tostring,1, _SC(".")},
{0,0,0,0} {0,0,0,0}
}; };
@@ -832,7 +826,7 @@ static SQInteger thread_call(HSQUIRRELVM v)
v->_lasterror = _thread(o)->_lasterror; v->_lasterror = _thread(o)->_lasterror;
return SQ_ERROR; return SQ_ERROR;
} }
return sq_throwerror(v,"wrong parameter"); return sq_throwerror(v,_SC("wrong parameter"));
} }
static SQInteger thread_wakeup(HSQUIRRELVM v) static SQInteger thread_wakeup(HSQUIRRELVM v)
@@ -844,10 +838,10 @@ static SQInteger thread_wakeup(HSQUIRRELVM v)
if(state != SQ_VMSTATE_SUSPENDED) { if(state != SQ_VMSTATE_SUSPENDED) {
switch(state) { switch(state) {
case SQ_VMSTATE_IDLE: case SQ_VMSTATE_IDLE:
return sq_throwerror(v,"cannot wakeup a idle thread"); return sq_throwerror(v,_SC("cannot wakeup a idle thread"));
break; break;
case SQ_VMSTATE_RUNNING: case SQ_VMSTATE_RUNNING:
return sq_throwerror(v,"cannot wakeup a running thread"); return sq_throwerror(v,_SC("cannot wakeup a running thread"));
break; break;
} }
} }
@@ -868,7 +862,7 @@ static SQInteger thread_wakeup(HSQUIRRELVM v)
v->_lasterror = thread->_lasterror; v->_lasterror = thread->_lasterror;
return SQ_ERROR; return SQ_ERROR;
} }
return sq_throwerror(v,"wrong parameter"); return sq_throwerror(v,_SC("wrong parameter"));
} }
static SQInteger thread_getstatus(HSQUIRRELVM v) static SQInteger thread_getstatus(HSQUIRRELVM v)
@@ -876,26 +870,26 @@ static SQInteger thread_getstatus(HSQUIRRELVM v)
SQObjectPtr &o = stack_get(v,1); SQObjectPtr &o = stack_get(v,1);
switch(sq_getvmstate(_thread(o))) { switch(sq_getvmstate(_thread(o))) {
case SQ_VMSTATE_IDLE: case SQ_VMSTATE_IDLE:
sq_pushstring(v,"idle",-1); sq_pushstring(v,_SC("idle"),-1);
break; break;
case SQ_VMSTATE_RUNNING: case SQ_VMSTATE_RUNNING:
sq_pushstring(v,"running",-1); sq_pushstring(v,_SC("running"),-1);
break; break;
case SQ_VMSTATE_SUSPENDED: case SQ_VMSTATE_SUSPENDED:
sq_pushstring(v,"suspended",-1); sq_pushstring(v,_SC("suspended"),-1);
break; break;
default: default:
return sq_throwerror(v,"internal VM error"); return sq_throwerror(v,_SC("internal VM error"));
} }
return 1; return 1;
} }
SQRegFunction SQSharedState::_thread_default_delegate_funcz[] = { SQRegFunction SQSharedState::_thread_default_delegate_funcz[] = {
{"call", thread_call, -1, "v"}, {_SC("call"), thread_call, -1, _SC("v")},
{"wakeup", thread_wakeup, -1, "v"}, {_SC("wakeup"), thread_wakeup, -1, _SC("v")},
{"getstatus", thread_getstatus, 1, "v"}, {_SC("getstatus"), thread_getstatus, 1, _SC("v")},
{"weakref",obj_delegate_weakref,1, NULL }, {_SC("weakref"),obj_delegate_weakref,1, NULL },
{"tostring",default_delegate_tostring,1, "."}, {_SC("tostring"),default_delegate_tostring,1, _SC(".")},
{0,0,0,0}, {0,0,0,0},
}; };
@@ -921,12 +915,12 @@ static SQInteger class_instance(HSQUIRRELVM v)
} }
SQRegFunction SQSharedState::_class_default_delegate_funcz[] = { SQRegFunction SQSharedState::_class_default_delegate_funcz[] = {
{"getattributes", class_getattributes, 2, "y."}, {_SC("getattributes"), class_getattributes, 2, _SC("y.")},
{"setattributes", class_setattributes, 3, "y.."}, {_SC("setattributes"), class_setattributes, 3, _SC("y..")},
{"rawin",container_rawexists,2, "y"}, {_SC("rawin"),container_rawexists,2, _SC("y")},
{"weakref",obj_delegate_weakref,1, NULL }, {_SC("weakref"),obj_delegate_weakref,1, NULL },
{"tostring",default_delegate_tostring,1, "."}, {_SC("tostring"),default_delegate_tostring,1, _SC(".")},
{"instance",class_instance,1, "y"}, {_SC("instance"),class_instance,1, _SC("y")},
{0,0,0,0} {0,0,0,0}
}; };
@@ -938,10 +932,10 @@ static SQInteger instance_getclass(HSQUIRRELVM v)
} }
SQRegFunction SQSharedState::_instance_default_delegate_funcz[] = { SQRegFunction SQSharedState::_instance_default_delegate_funcz[] = {
{"getclass", instance_getclass, 1, "x"}, {_SC("getclass"), instance_getclass, 1, _SC("x")},
{"rawin",container_rawexists,2, "x"}, {_SC("rawin"),container_rawexists,2, _SC("x")},
{"weakref",obj_delegate_weakref,1, NULL }, {_SC("weakref"),obj_delegate_weakref,1, NULL },
{"tostring",default_delegate_tostring,1, "."}, {_SC("tostring"),default_delegate_tostring,1, _SC(".")},
{0,0,0,0} {0,0,0,0}
}; };
@@ -953,9 +947,9 @@ static SQInteger weakref_ref(HSQUIRRELVM v)
} }
SQRegFunction SQSharedState::_weakref_default_delegate_funcz[] = { SQRegFunction SQSharedState::_weakref_default_delegate_funcz[] = {
{"ref",weakref_ref,1, "r"}, {_SC("ref"),weakref_ref,1, _SC("r")},
{"weakref",obj_delegate_weakref,1, NULL }, {_SC("weakref"),obj_delegate_weakref,1, NULL },
{"tostring",default_delegate_tostring,1, "."}, {_SC("tostring"),default_delegate_tostring,1, _SC(".")},
{0,0,0,0} {0,0,0,0}
}; };

View File

@@ -1,17 +1,12 @@
/* /*
* see copyright notice in squirrel.h see copyright notice in squirrel.h
*/ */
#include "../../../stdafx.h"
#include "sqpcheader.h" #include "sqpcheader.h"
#include "sqvm.h" #include "sqvm.h"
#include "sqtable.h" #include "sqtable.h"
#include "sqclass.h" #include "sqclass.h"
#include "sqclosure.h" #include "sqclosure.h"
#include "../../../safeguards.h"
SQClass::SQClass(SQSharedState *ss,SQClass *base) SQClass::SQClass(SQSharedState *ss,SQClass *base)
{ {
_base = base; _base = base;

View File

@@ -80,7 +80,7 @@ public:
struct SQNativeClosure : public CHAINABLE_OBJ struct SQNativeClosure : public CHAINABLE_OBJ
{ {
private: private:
SQNativeClosure(SQSharedState *ss,SQFUNCTION func) : _nparamscheck(0) {_function=func;INIT_CHAIN();ADD_TO_CHAIN(&_ss(this)->_gc_chain,this); } SQNativeClosure(SQSharedState *ss,SQFUNCTION func){_function=func;INIT_CHAIN();ADD_TO_CHAIN(&_ss(this)->_gc_chain,this); }
public: public:
static SQNativeClosure *Create(SQSharedState *ss,SQFUNCTION func) static SQNativeClosure *Create(SQSharedState *ss,SQFUNCTION func)
{ {

View File

@@ -1,9 +1,6 @@
/* /*
* see copyright notice in squirrel.h see copyright notice in squirrel.h
*/ */
#include "../../../stdafx.h"
#include <squirrel.h> #include <squirrel.h>
#include "sqpcheader.h" #include "sqpcheader.h"
#include <stdarg.h> #include <stdarg.h>
@@ -16,10 +13,6 @@
#include "sqvm.h" #include "sqvm.h"
#include "sqtable.h" #include "sqtable.h"
#include "../../../string_func.h"
#include "../../../safeguards.h"
#define DEREF_NO_DEREF -1 #define DEREF_NO_DEREF -1
#define DEREF_FIELD -2 #define DEREF_FIELD -2
@@ -57,22 +50,23 @@ typedef sqvector<ExpState> ExpStateVec;
class SQCompiler class SQCompiler
{ {
public: public:
SQCompiler(SQVM *v, SQLEXREADFUNC rg, SQUserPointer up, const SQChar* sourcename, bool raiseerror, bool lineinfo) : _lex(_ss(v), rg, up,ThrowError,this) SQCompiler(SQVM *v, SQLEXREADFUNC rg, SQUserPointer up, const SQChar* sourcename, bool raiseerror, bool lineinfo)
{ {
_vm=v; _vm=v;
_lex.Init(_ss(v), rg, up,ThrowError,this);
_sourcename = SQString::Create(_ss(v), sourcename); _sourcename = SQString::Create(_ss(v), sourcename);
_lineinfo = lineinfo;_raiseerror = raiseerror; _lineinfo = lineinfo;_raiseerror = raiseerror;
} }
NORETURN static void ThrowError(void *ud, const SQChar *s) { static void ThrowError(void *ud, const SQChar *s) {
SQCompiler *c = (SQCompiler *)ud; SQCompiler *c = (SQCompiler *)ud;
c->Error(s); c->Error(s);
} }
NORETURN void Error(const SQChar *s, ...) void Error(const SQChar *s, ...)
{ {
static SQChar temp[256]; static SQChar temp[256];
va_list vl; va_list vl;
va_start(vl, s); va_start(vl, s);
vseprintf(temp, lastof(temp), s, vl); scvsnprintf(temp, sizeof(temp), s, vl);
va_end(vl); va_end(vl);
throw temp; throw temp;
} }
@@ -81,7 +75,7 @@ public:
bool IsDerefToken(SQInteger tok) bool IsDerefToken(SQInteger tok)
{ {
switch(tok){ switch(tok){
case '=': case '(': case TK_NEWSLOT: case _SC('='): case _SC('('): case TK_NEWSLOT:
case TK_MODEQ: case TK_MULEQ: case TK_DIVEQ: case TK_MINUSEQ: case TK_PLUSEQ: case TK_PLUSPLUS: case TK_MINUSMINUS: return true; case TK_MODEQ: case TK_MULEQ: case TK_DIVEQ: case TK_MINUSEQ: case TK_PLUSEQ: case TK_PLUSPLUS: case TK_MINUSMINUS: return true;
} }
return false; return false;
@@ -97,7 +91,7 @@ public:
if(_token != tok) { if(_token != tok) {
if(_token == TK_CONSTRUCTOR && tok == TK_IDENTIFIER) { if(_token == TK_CONSTRUCTOR && tok == TK_IDENTIFIER) {
//ret = SQString::Create(_ss(_vm),"constructor"); //ret = SQString::Create(_ss(_vm),_SC("constructor"));
//do nothing //do nothing
} }
else { else {
@@ -106,23 +100,23 @@ public:
switch(tok) switch(tok)
{ {
case TK_IDENTIFIER: case TK_IDENTIFIER:
etypename = "IDENTIFIER"; etypename = _SC("IDENTIFIER");
break; break;
case TK_STRING_LITERAL: case TK_STRING_LITERAL:
etypename = "STRING_LITERAL"; etypename = _SC("STRING_LITERAL");
break; break;
case TK_INTEGER: case TK_INTEGER:
etypename = "INTEGER"; etypename = _SC("INTEGER");
break; break;
case TK_FLOAT: case TK_FLOAT:
etypename = "FLOAT"; etypename = _SC("FLOAT");
break; break;
default: default:
etypename = _lex.Tok2Str(tok); etypename = _lex.Tok2Str(tok);
} }
Error("expected '%s'", etypename); Error(_SC("expected '%s'"), etypename);
} }
Error("expected '%c'", tok); Error(_SC("expected '%c'"), tok);
} }
} }
SQObjectPtr ret; SQObjectPtr ret;
@@ -144,12 +138,12 @@ public:
Lex(); Lex();
return ret; return ret;
} }
bool IsEndOfStatement() { return ((_lex._prevtoken == '\n') || (_token == SQUIRREL_EOB) || (_token == '}') || (_token == ';')); } bool IsEndOfStatement() { return ((_lex._prevtoken == _SC('\n')) || (_token == SQUIRREL_EOB) || (_token == _SC('}')) || (_token == _SC(';'))); }
void OptionalSemicolon() void OptionalSemicolon()
{ {
if(_token == ';') { Lex(); return; } if(_token == _SC(';')) { Lex(); return; }
if(!IsEndOfStatement()) { if(!IsEndOfStatement()) {
Error("end of statement expected (; or lf)"); Error(_SC("end of statement expected (; or lf)"));
} }
} }
void MoveIfCurrentTargetIsLocal() { void MoveIfCurrentTargetIsLocal() {
@@ -165,16 +159,16 @@ public:
_debugop = 0; _debugop = 0;
SQFuncState funcstate(_ss(_vm), NULL,ThrowError,this); SQFuncState funcstate(_ss(_vm), NULL,ThrowError,this);
funcstate._name = SQString::Create(_ss(_vm), "main"); funcstate._name = SQString::Create(_ss(_vm), _SC("main"));
_fs = &funcstate; _fs = &funcstate;
_fs->AddParameter(_fs->CreateString("this")); _fs->AddParameter(_fs->CreateString(_SC("this")));
_fs->_sourcename = _sourcename; _fs->_sourcename = _sourcename;
SQInteger stacksize = _fs->GetStackSize(); SQInteger stacksize = _fs->GetStackSize();
try { try {
Lex(); Lex();
while(_token > 0){ while(_token > 0){
Statement(); Statement();
if(_lex._prevtoken != '}') OptionalSemicolon(); if(_lex._prevtoken != _SC('}')) OptionalSemicolon();
} }
CleanStack(stacksize); CleanStack(stacksize);
_fs->AddLineInfos(_lex._currentline, _lineinfo, true); _fs->AddLineInfos(_lex._currentline, _lineinfo, true);
@@ -188,7 +182,7 @@ public:
} }
catch (SQChar *compilererror) { catch (SQChar *compilererror) {
if(_raiseerror && _ss(_vm)->_compilererrorhandler) { if(_raiseerror && _ss(_vm)->_compilererrorhandler) {
_ss(_vm)->_compilererrorhandler(_vm, compilererror, type(_sourcename) == OT_STRING?_stringval(_sourcename):"unknown", _ss(_vm)->_compilererrorhandler(_vm, compilererror, type(_sourcename) == OT_STRING?_stringval(_sourcename):_SC("unknown"),
_lex._currentline, _lex._currentcolumn); _lex._currentline, _lex._currentcolumn);
} }
_vm->_lasterror = SQString::Create(_ss(_vm), compilererror, -1); _vm->_lasterror = SQString::Create(_ss(_vm), compilererror, -1);
@@ -197,16 +191,16 @@ public:
} }
void Statements() void Statements()
{ {
while(_token != '}' && _token != TK_DEFAULT && _token != TK_CASE) { while(_token != _SC('}') && _token != TK_DEFAULT && _token != TK_CASE) {
Statement(); Statement();
if(_lex._prevtoken != '}' && _lex._prevtoken != ';') OptionalSemicolon(); if(_lex._prevtoken != _SC('}') && _lex._prevtoken != _SC(';')) OptionalSemicolon();
} }
} }
void Statement() void Statement()
{ {
_fs->AddLineInfos(_lex._currentline, _lineinfo); _fs->AddLineInfos(_lex._currentline, _lineinfo);
switch(_token){ switch(_token){
case ';': Lex(); break; case _SC(';'): Lex(); break;
case TK_IF: IfStatement(); break; case TK_IF: IfStatement(); break;
case TK_WHILE: WhileStatement(); break; case TK_WHILE: WhileStatement(); break;
case TK_DO: DoWhileStatement(); break; case TK_DO: DoWhileStatement(); break;
@@ -242,7 +236,7 @@ public:
} }
break;} break;}
case TK_BREAK: case TK_BREAK:
if(_fs->_breaktargets.size() <= 0)Error("'break' has to be in a loop block"); if(_fs->_breaktargets.size() <= 0)Error(_SC("'break' has to be in a loop block"));
if(_fs->_breaktargets.top() > 0){ if(_fs->_breaktargets.top() > 0){
_fs->AddInstruction(_OP_POPTRAP, _fs->_breaktargets.top(), 0); _fs->AddInstruction(_OP_POPTRAP, _fs->_breaktargets.top(), 0);
} }
@@ -252,7 +246,7 @@ public:
Lex(); Lex();
break; break;
case TK_CONTINUE: case TK_CONTINUE:
if(_fs->_continuetargets.size() <= 0)Error("'continue' has to be in a loop block"); if(_fs->_continuetargets.size() <= 0)Error(_SC("'continue' has to be in a loop block"));
if(_fs->_continuetargets.top() > 0) { if(_fs->_continuetargets.top() > 0) {
_fs->AddInstruction(_OP_POPTRAP, _fs->_continuetargets.top(), 0); _fs->AddInstruction(_OP_POPTRAP, _fs->_continuetargets.top(), 0);
} }
@@ -270,11 +264,11 @@ public:
case TK_ENUM: case TK_ENUM:
EnumStatement(); EnumStatement();
break; break;
case '{':{ case _SC('{'):{
SQInteger stacksize = _fs->GetStackSize(); SQInteger stacksize = _fs->GetStackSize();
Lex(); Lex();
Statements(); Statements();
Expect('}'); Expect(_SC('}'));
_fs->AddInstruction(_OP_SCOPE_END, stacksize, _fs->GetStackSize()); _fs->AddInstruction(_OP_SCOPE_END, stacksize, _fs->GetStackSize());
_fs->SetStackSize(stacksize); _fs->SetStackSize(stacksize);
} }
@@ -354,7 +348,7 @@ public:
_exst._funcarg = funcarg; _exst._funcarg = funcarg;
LogicalOrExp(); LogicalOrExp();
switch(_token) { switch(_token) {
case '=': case _SC('='):
case TK_NEWSLOT: case TK_NEWSLOT:
case TK_MINUSEQ: case TK_MINUSEQ:
case TK_PLUSEQ: case TK_PLUSEQ:
@@ -365,19 +359,19 @@ public:
SQInteger op = _token; SQInteger op = _token;
SQInteger ds = _exst._deref; SQInteger ds = _exst._deref;
bool freevar = _exst._freevar; bool freevar = _exst._freevar;
if(ds == DEREF_NO_DEREF) Error("can't assign expression"); if(ds == DEREF_NO_DEREF) Error(_SC("can't assign expression"));
Lex(); Expression(); Lex(); Expression();
switch(op){ switch(op){
case TK_NEWSLOT: case TK_NEWSLOT:
if(freevar) Error("free variables cannot be modified"); if(freevar) Error(_SC("free variables cannot be modified"));
if(ds == DEREF_FIELD) if(ds == DEREF_FIELD)
EmitDerefOp(_OP_NEWSLOT); EmitDerefOp(_OP_NEWSLOT);
else //if _derefstate != DEREF_NO_DEREF && DEREF_FIELD so is the index of a local else //if _derefstate != DEREF_NO_DEREF && DEREF_FIELD so is the index of a local
Error("can't 'create' a local slot"); Error(_SC("can't 'create' a local slot"));
break; break;
case '=': //ASSIGN case _SC('='): //ASSIGN
if(freevar) Error("free variables cannot be modified"); if(freevar) Error(_SC("free variables cannot be modified"));
if(ds == DEREF_FIELD) if(ds == DEREF_FIELD)
EmitDerefOp(_OP_SET); EmitDerefOp(_OP_SET);
else {//if _derefstate != DEREF_NO_DEREF && DEREF_FIELD so is the index of a local else {//if _derefstate != DEREF_NO_DEREF && DEREF_FIELD so is the index of a local
@@ -396,7 +390,7 @@ public:
} }
} }
break; break;
case '?': { case _SC('?'): {
Lex(); Lex();
_fs->AddInstruction(_OP_JZ, _fs->PopTarget()); _fs->AddInstruction(_OP_JZ, _fs->PopTarget());
SQInteger jzpos = _fs->GetCurrentPos(); SQInteger jzpos = _fs->GetCurrentPos();
@@ -406,7 +400,7 @@ public:
if(trg != first_exp) _fs->AddInstruction(_OP_MOVE, trg, first_exp); if(trg != first_exp) _fs->AddInstruction(_OP_MOVE, trg, first_exp);
SQInteger endfirstexp = _fs->GetCurrentPos(); SQInteger endfirstexp = _fs->GetCurrentPos();
_fs->AddInstruction(_OP_JMP, 0, 0); _fs->AddInstruction(_OP_JMP, 0, 0);
Expect(':'); Expect(_SC(':'));
SQInteger jmppos = _fs->GetCurrentPos(); SQInteger jmppos = _fs->GetCurrentPos();
Expression(); Expression();
SQInteger second_exp = _fs->PopTarget(); SQInteger second_exp = _fs->PopTarget();
@@ -428,7 +422,7 @@ public:
void LogicalOrExp() void LogicalOrExp()
{ {
LogicalAndExp(); LogicalAndExp();
if(_token == TK_OR) { for(;;) if(_token == TK_OR) {
SQInteger first_exp = _fs->PopTarget(); SQInteger first_exp = _fs->PopTarget();
SQInteger trg = _fs->PushTarget(); SQInteger trg = _fs->PushTarget();
_fs->AddInstruction(_OP_OR, trg, 0, first_exp, 0); _fs->AddInstruction(_OP_OR, trg, 0, first_exp, 0);
@@ -440,7 +434,8 @@ public:
if(trg != second_exp) _fs->AddInstruction(_OP_MOVE, trg, second_exp); if(trg != second_exp) _fs->AddInstruction(_OP_MOVE, trg, second_exp);
_fs->SnoozeOpt(); _fs->SnoozeOpt();
_fs->SetIntructionParam(jpos, 1, (_fs->GetCurrentPos() - jpos)); _fs->SetIntructionParam(jpos, 1, (_fs->GetCurrentPos() - jpos));
} break;
}else return;
} }
void LogicalAndExp() void LogicalAndExp()
{ {
@@ -469,21 +464,21 @@ public:
void BitwiseOrExp() void BitwiseOrExp()
{ {
BitwiseXorExp(); BitwiseXorExp();
for(;;) if(_token == '|') for(;;) if(_token == _SC('|'))
{BIN_EXP(_OP_BITW, &SQCompiler::BitwiseXorExp,BW_OR); {BIN_EXP(_OP_BITW, &SQCompiler::BitwiseXorExp,BW_OR);
}else return; }else return;
} }
void BitwiseXorExp() void BitwiseXorExp()
{ {
BitwiseAndExp(); BitwiseAndExp();
for(;;) if(_token == '^') for(;;) if(_token == _SC('^'))
{BIN_EXP(_OP_BITW, &SQCompiler::BitwiseAndExp,BW_XOR); {BIN_EXP(_OP_BITW, &SQCompiler::BitwiseAndExp,BW_XOR);
}else return; }else return;
} }
void BitwiseAndExp() void BitwiseAndExp()
{ {
CompExp(); CompExp();
for(;;) if(_token == '&') for(;;) if(_token == _SC('&'))
{BIN_EXP(_OP_BITW, &SQCompiler::CompExp,BW_AND); {BIN_EXP(_OP_BITW, &SQCompiler::CompExp,BW_AND);
}else return; }else return;
} }
@@ -492,8 +487,8 @@ public:
ShiftExp(); ShiftExp();
for(;;) switch(_token) { for(;;) switch(_token) {
case TK_EQ: BIN_EXP(_OP_EQ, &SQCompiler::ShiftExp); break; case TK_EQ: BIN_EXP(_OP_EQ, &SQCompiler::ShiftExp); break;
case '>': BIN_EXP(_OP_CMP, &SQCompiler::ShiftExp,CMP_G); break; case _SC('>'): BIN_EXP(_OP_CMP, &SQCompiler::ShiftExp,CMP_G); break;
case '<': BIN_EXP(_OP_CMP, &SQCompiler::ShiftExp,CMP_L); break; case _SC('<'): BIN_EXP(_OP_CMP, &SQCompiler::ShiftExp,CMP_L); break;
case TK_GE: BIN_EXP(_OP_CMP, &SQCompiler::ShiftExp,CMP_GE); break; case TK_GE: BIN_EXP(_OP_CMP, &SQCompiler::ShiftExp,CMP_GE); break;
case TK_LE: BIN_EXP(_OP_CMP, &SQCompiler::ShiftExp,CMP_LE); break; case TK_LE: BIN_EXP(_OP_CMP, &SQCompiler::ShiftExp,CMP_LE); break;
case TK_NE: BIN_EXP(_OP_NE, &SQCompiler::ShiftExp); break; case TK_NE: BIN_EXP(_OP_NE, &SQCompiler::ShiftExp); break;
@@ -514,7 +509,7 @@ public:
{ {
MultExp(); MultExp();
for(;;) switch(_token) { for(;;) switch(_token) {
case '+': case '-': case _SC('+'): case _SC('-'):
BIN_EXP(_OP_ARITH, &SQCompiler::MultExp,_token); break; BIN_EXP(_OP_ARITH, &SQCompiler::MultExp,_token); break;
default: return; default: return;
} }
@@ -524,7 +519,7 @@ public:
{ {
PrefixedExpr(); PrefixedExpr();
for(;;) switch(_token) { for(;;) switch(_token) {
case '*': case '/': case '%': case _SC('*'): case _SC('/'): case _SC('%'):
BIN_EXP(_OP_ARITH, &SQCompiler::PrefixedExpr,_token); break; BIN_EXP(_OP_ARITH, &SQCompiler::PrefixedExpr,_token); break;
default: return; default: return;
} }
@@ -536,13 +531,13 @@ public:
for(;;) { for(;;) {
switch(_token) { switch(_token) {
case '.': { case _SC('.'): {
pos = -1; pos = -1;
Lex(); Lex();
if(_token == TK_PARENT) { if(_token == TK_PARENT) {
Lex(); Lex();
if(!NeedGet()) if(!NeedGet())
Error("parent cannot be set"); Error(_SC("parent cannot be set"));
SQInteger src = _fs->PopTarget(); SQInteger src = _fs->PopTarget();
_fs->AddInstruction(_OP_GETPARENT, _fs->PushTarget(), src); _fs->AddInstruction(_OP_GETPARENT, _fs->PushTarget(), src);
} }
@@ -554,9 +549,9 @@ public:
_exst._freevar = false; _exst._freevar = false;
} }
break; break;
case '[': case _SC('['):
if(_lex._prevtoken == '\n') Error("cannot brake deref/or comma needed after [exp]=exp slot declaration"); if(_lex._prevtoken == _SC('\n')) Error(_SC("cannot brake deref/or comma needed after [exp]=exp slot declaration"));
Lex(); Expression(); Expect(']'); Lex(); Expression(); Expect(_SC(']'));
pos = -1; pos = -1;
if(NeedGet()) Emit2ArgsOP(_OP_GET); if(NeedGet()) Emit2ArgsOP(_OP_GET);
_exst._deref = DEREF_FIELD; _exst._deref = DEREF_FIELD;
@@ -576,7 +571,7 @@ public:
} }
return; return;
break; break;
case '(': case _SC('('):
{ {
if(_exst._deref != DEREF_NO_DEREF) { if(_exst._deref != DEREF_NO_DEREF) {
if(pos<0) { if(pos<0) {
@@ -614,9 +609,9 @@ public:
break; break;
case TK_VARGC: Lex(); _fs->AddInstruction(_OP_VARGC, _fs->PushTarget()); break; case TK_VARGC: Lex(); _fs->AddInstruction(_OP_VARGC, _fs->PushTarget()); break;
case TK_VARGV: { Lex(); case TK_VARGV: { Lex();
Expect('['); Expect(_SC('['));
Expression(); Expression();
Expect(']'); Expect(_SC(']'));
SQInteger src = _fs->PopTarget(); SQInteger src = _fs->PopTarget();
_fs->AddInstruction(_OP_GETVARGV, _fs->PushTarget(), src); _fs->AddInstruction(_OP_GETVARGV, _fs->PushTarget(), src);
} }
@@ -629,8 +624,8 @@ public:
SQObject constant; SQObject constant;
switch(_token) { switch(_token) {
case TK_IDENTIFIER: id = _fs->CreateString(_lex._svalue); break; case TK_IDENTIFIER: id = _fs->CreateString(_lex._svalue); break;
case TK_THIS: id = _fs->CreateString("this"); break; case TK_THIS: id = _fs->CreateString(_SC("this")); break;
case TK_CONSTRUCTOR: id = _fs->CreateString("constructor"); break; case TK_CONSTRUCTOR: id = _fs->CreateString(_SC("constructor")); break;
} }
SQInteger pos = -1; SQInteger pos = -1;
Lex(); Lex();
@@ -648,7 +643,7 @@ public:
Expect('.'); constid = Expect(TK_IDENTIFIER); Expect('.'); constid = Expect(TK_IDENTIFIER);
if(!_table(constant)->Get(constid,constval)) { if(!_table(constant)->Get(constid,constval)) {
constval.Null(); constval.Null();
Error("invalid constant [%s.%s]", _stringval(id),_stringval(constid)); Error(_SC("invalid constant [%s.%s]"), _stringval(id),_stringval(constid));
} }
} }
else { else {
@@ -688,7 +683,7 @@ public:
case TK_DOUBLE_COLON: // "::" case TK_DOUBLE_COLON: // "::"
_fs->AddInstruction(_OP_LOADROOTTABLE, _fs->PushTarget()); _fs->AddInstruction(_OP_LOADROOTTABLE, _fs->PushTarget());
_exst._deref = DEREF_FIELD; _exst._deref = DEREF_FIELD;
_token = '.'; //hack _token = _SC('.'); //hack
return -1; return -1;
break; break;
case TK_NULL: case TK_NULL:
@@ -718,13 +713,13 @@ public:
_fs->AddInstruction(_OP_LOADBOOL, _fs->PushTarget(),_token == TK_TRUE?1:0); _fs->AddInstruction(_OP_LOADBOOL, _fs->PushTarget(),_token == TK_TRUE?1:0);
Lex(); Lex();
break; break;
case '[': { case _SC('['): {
_fs->AddInstruction(_OP_NEWARRAY, _fs->PushTarget()); _fs->AddInstruction(_OP_NEWARRAY, _fs->PushTarget());
SQInteger apos = _fs->GetCurrentPos(),key = 0; SQInteger apos = _fs->GetCurrentPos(),key = 0;
Lex(); Lex();
while(_token != ']') { while(_token != _SC(']')) {
Expression(); Expression();
if(_token == ',') Lex(); if(_token == _SC(',')) Lex();
SQInteger val = _fs->PopTarget(); SQInteger val = _fs->PopTarget();
SQInteger array = _fs->TopTarget(); SQInteger array = _fs->TopTarget();
_fs->AddInstruction(_OP_APPENDARRAY, array, val); _fs->AddInstruction(_OP_APPENDARRAY, array, val);
@@ -734,16 +729,16 @@ public:
Lex(); Lex();
} }
break; break;
case '{':{ case _SC('{'):{
_fs->AddInstruction(_OP_NEWTABLE, _fs->PushTarget()); _fs->AddInstruction(_OP_NEWTABLE, _fs->PushTarget());
Lex();ParseTableOrClass(','); Lex();ParseTableOrClass(_SC(','));
} }
break; break;
case TK_FUNCTION: FunctionExp(_token);break; case TK_FUNCTION: FunctionExp(_token);break;
case TK_CLASS: Lex(); ClassExp();break; case TK_CLASS: Lex(); ClassExp();break;
case '-': UnaryOP(_OP_NEG); break; case _SC('-'): UnaryOP(_OP_NEG); break;
case '!': UnaryOP(_OP_NOT); break; case _SC('!'): UnaryOP(_OP_NOT); break;
case '~': UnaryOP(_OP_BWNOT); break; case _SC('~'): UnaryOP(_OP_BWNOT); break;
case TK_TYPEOF : UnaryOP(_OP_TYPEOF); break; case TK_TYPEOF : UnaryOP(_OP_TYPEOF); break;
case TK_RESUME : UnaryOP(_OP_RESUME); break; case TK_RESUME : UnaryOP(_OP_RESUME); break;
case TK_CLONE : UnaryOP(_OP_CLONE); break; case TK_CLONE : UnaryOP(_OP_CLONE); break;
@@ -751,9 +746,9 @@ public:
case TK_PLUSPLUS :PrefixIncDec(_token); break; case TK_PLUSPLUS :PrefixIncDec(_token); break;
case TK_DELETE : DeleteExpr(); break; case TK_DELETE : DeleteExpr(); break;
case TK_DELEGATE : DelegateExpr(); break; case TK_DELEGATE : DelegateExpr(); break;
case '(': Lex(); CommaExpr(); Expect(')'); case _SC('('): Lex(); CommaExpr(); Expect(_SC(')'));
break; break;
default: Error("expression expected"); default: Error(_SC("expression expected"));
} }
return -1; return -1;
} }
@@ -766,23 +761,23 @@ public:
bool NeedGet() bool NeedGet()
{ {
switch(_token) { switch(_token) {
case '=': case '(': case TK_NEWSLOT: case TK_PLUSPLUS: case TK_MINUSMINUS: case _SC('='): case _SC('('): case TK_NEWSLOT: case TK_PLUSPLUS: case TK_MINUSMINUS:
case TK_PLUSEQ: case TK_MINUSEQ: case TK_MULEQ: case TK_DIVEQ: case TK_MODEQ: case TK_PLUSEQ: case TK_MINUSEQ: case TK_MULEQ: case TK_DIVEQ: case TK_MODEQ:
return false; return false;
} }
return (!_exst._class_or_delete) || (_exst._class_or_delete && (_token == '.' || _token == '[')); return (!_exst._class_or_delete) || (_exst._class_or_delete && (_token == _SC('.') || _token == _SC('[')));
} }
void FunctionCallArgs() void FunctionCallArgs()
{ {
SQInteger nargs = 1;//this SQInteger nargs = 1;//this
while(_token != ')') { while(_token != _SC(')')) {
Expression(true); Expression(true);
MoveIfCurrentTargetIsLocal(); MoveIfCurrentTargetIsLocal();
nargs++; nargs++;
if(_token == ','){ if(_token == _SC(',')){
Lex(); Lex();
if(_token == ')') Error("expression expected, found ')'"); if(_token == ')') Error(_SC("expression expected, found ')'"));
} }
} }
Lex(); Lex();
@@ -815,20 +810,20 @@ public:
case TK_CONSTRUCTOR:{ case TK_CONSTRUCTOR:{
SQInteger tk = _token; SQInteger tk = _token;
Lex(); Lex();
SQObject id = tk == TK_FUNCTION ? Expect(TK_IDENTIFIER) : _fs->CreateString("constructor"); SQObject id = tk == TK_FUNCTION ? Expect(TK_IDENTIFIER) : _fs->CreateString(_SC("constructor"));
Expect('('); Expect(_SC('('));
_fs->AddInstruction(_OP_LOAD, _fs->PushTarget(), _fs->GetConstant(id)); _fs->AddInstruction(_OP_LOAD, _fs->PushTarget(), _fs->GetConstant(id));
CreateFunction(id); CreateFunction(id);
_fs->AddInstruction(_OP_CLOSURE, _fs->PushTarget(), _fs->_functions.size() - 1, 0); _fs->AddInstruction(_OP_CLOSURE, _fs->PushTarget(), _fs->_functions.size() - 1, 0);
} }
break; break;
case '[': case _SC('['):
Lex(); CommaExpr(); Expect(']'); Lex(); CommaExpr(); Expect(_SC(']'));
Expect('='); Expression(); Expect(_SC('=')); Expression();
break; break;
default : default :
_fs->AddInstruction(_OP_LOAD, _fs->PushTarget(), _fs->GetConstant(Expect(TK_IDENTIFIER))); _fs->AddInstruction(_OP_LOAD, _fs->PushTarget(), _fs->GetConstant(Expect(TK_IDENTIFIER)));
Expect('='); Expression(); Expect(_SC('=')); Expression();
} }
if(_token == separator) Lex();//optional comma/semicolon if(_token == separator) Lex();//optional comma/semicolon
@@ -842,7 +837,7 @@ public:
_fs->AddInstruction(_OP_NEWSLOTA, flags, table, key, val); _fs->AddInstruction(_OP_NEWSLOTA, flags, table, key, val);
//_fs->PopTarget(); //_fs->PopTarget();
} }
if(separator == ',') //hack recognizes a table from the separator if(separator == _SC(',')) //hack recognizes a table from the separator
_fs->SetIntructionParam(tpos, 1, nkeys); _fs->SetIntructionParam(tpos, 1, nkeys);
Lex(); Lex();
} }
@@ -851,7 +846,7 @@ public:
SQObject varname; SQObject varname;
do { do {
Lex(); varname = Expect(TK_IDENTIFIER); Lex(); varname = Expect(TK_IDENTIFIER);
if(_token == '=') { if(_token == _SC('=')) {
Lex(); Expression(); Lex(); Expression();
SQInteger src = _fs->PopTarget(); SQInteger src = _fs->PopTarget();
SQInteger dest = _fs->PushTarget(); SQInteger dest = _fs->PushTarget();
@@ -863,20 +858,20 @@ public:
_fs->PopTarget(); _fs->PopTarget();
_fs->PushLocalVariable(varname); _fs->PushLocalVariable(varname);
} while(_token == ','); } while(_token == _SC(','));
} }
void IfStatement() void IfStatement()
{ {
SQInteger jmppos; SQInteger jmppos;
bool haselse = false; bool haselse = false;
Lex(); Expect('('); CommaExpr(); Expect(')'); Lex(); Expect(_SC('(')); CommaExpr(); Expect(_SC(')'));
_fs->AddInstruction(_OP_JZ, _fs->PopTarget()); _fs->AddInstruction(_OP_JZ, _fs->PopTarget());
SQInteger jnepos = _fs->GetCurrentPos(); SQInteger jnepos = _fs->GetCurrentPos();
SQInteger stacksize = _fs->GetStackSize(); SQInteger stacksize = _fs->GetStackSize();
Statement(); Statement();
// //
if(_token != '}' && _token != TK_ELSE) OptionalSemicolon(); if(_token != _SC('}') && _token != TK_ELSE) OptionalSemicolon();
CleanStack(stacksize); CleanStack(stacksize);
SQInteger endifblock = _fs->GetCurrentPos(); SQInteger endifblock = _fs->GetCurrentPos();
@@ -897,7 +892,7 @@ public:
SQInteger jzpos, jmppos; SQInteger jzpos, jmppos;
SQInteger stacksize = _fs->GetStackSize(); SQInteger stacksize = _fs->GetStackSize();
jmppos = _fs->GetCurrentPos(); jmppos = _fs->GetCurrentPos();
Lex(); Expect('('); CommaExpr(); Expect(')'); Lex(); Expect(_SC('(')); CommaExpr(); Expect(_SC(')'));
BEGIN_BREAKBLE_BLOCK(); BEGIN_BREAKBLE_BLOCK();
_fs->AddInstruction(_OP_JZ, _fs->PopTarget()); _fs->AddInstruction(_OP_JZ, _fs->PopTarget());
@@ -925,7 +920,7 @@ public:
_fs->AddLineInfos(_lex._currentline, _lineinfo, true); _fs->AddLineInfos(_lex._currentline, _lineinfo, true);
Expect(TK_WHILE); Expect(TK_WHILE);
SQInteger continuetrg = _fs->GetCurrentPos(); SQInteger continuetrg = _fs->GetCurrentPos();
Expect('('); CommaExpr(); Expect(')'); Expect(_SC('(')); CommaExpr(); Expect(_SC(')'));
_fs->AddInstruction(_OP_JNZ, _fs->PopTarget(), jzpos - _fs->GetCurrentPos() - 1); _fs->AddInstruction(_OP_JNZ, _fs->PopTarget(), jzpos - _fs->GetCurrentPos() - 1);
END_BREAKBLE_BLOCK(continuetrg); END_BREAKBLE_BLOCK(continuetrg);
} }
@@ -933,25 +928,25 @@ public:
{ {
Lex(); Lex();
SQInteger stacksize = _fs->GetStackSize(); SQInteger stacksize = _fs->GetStackSize();
Expect('('); Expect(_SC('('));
if(_token == TK_LOCAL) LocalDeclStatement(); if(_token == TK_LOCAL) LocalDeclStatement();
else if(_token != ';'){ else if(_token != _SC(';')){
CommaExpr(); CommaExpr();
_fs->PopTarget(); _fs->PopTarget();
} }
Expect(';'); Expect(_SC(';'));
_fs->SnoozeOpt(); _fs->SnoozeOpt();
SQInteger jmppos = _fs->GetCurrentPos(); SQInteger jmppos = _fs->GetCurrentPos();
SQInteger jzpos = -1; SQInteger jzpos = -1;
if(_token != ';') { CommaExpr(); _fs->AddInstruction(_OP_JZ, _fs->PopTarget()); jzpos = _fs->GetCurrentPos(); } if(_token != _SC(';')) { CommaExpr(); _fs->AddInstruction(_OP_JZ, _fs->PopTarget()); jzpos = _fs->GetCurrentPos(); }
Expect(';'); Expect(_SC(';'));
_fs->SnoozeOpt(); _fs->SnoozeOpt();
SQInteger expstart = _fs->GetCurrentPos() + 1; SQInteger expstart = _fs->GetCurrentPos() + 1;
if(_token != ')') { if(_token != _SC(')')) {
CommaExpr(); CommaExpr();
_fs->PopTarget(); _fs->PopTarget();
} }
Expect(')'); Expect(_SC(')'));
_fs->SnoozeOpt(); _fs->SnoozeOpt();
SQInteger expend = _fs->GetCurrentPos(); SQInteger expend = _fs->GetCurrentPos();
SQInteger expsize = (expend - expstart) + 1; SQInteger expsize = (expend - expstart) + 1;
@@ -978,20 +973,20 @@ public:
void ForEachStatement() void ForEachStatement()
{ {
SQObject idxname, valname; SQObject idxname, valname;
Lex(); Expect('('); valname = Expect(TK_IDENTIFIER); Lex(); Expect(_SC('(')); valname = Expect(TK_IDENTIFIER);
if(_token == ',') { if(_token == _SC(',')) {
idxname = valname; idxname = valname;
Lex(); valname = Expect(TK_IDENTIFIER); Lex(); valname = Expect(TK_IDENTIFIER);
} }
else{ else{
idxname = _fs->CreateString("@INDEX@"); idxname = _fs->CreateString(_SC("@INDEX@"));
} }
Expect(TK_IN); Expect(TK_IN);
//save the stack size //save the stack size
SQInteger stacksize = _fs->GetStackSize(); SQInteger stacksize = _fs->GetStackSize();
//put the table in the stack(evaluate the table expression) //put the table in the stack(evaluate the table expression)
Expression(); Expect(')'); Expression(); Expect(_SC(')'));
SQInteger container = _fs->TopTarget(); SQInteger container = _fs->TopTarget();
//push the index local var //push the index local var
SQInteger indexpos = _fs->PushLocalVariable(idxname); SQInteger indexpos = _fs->PushLocalVariable(idxname);
@@ -1000,7 +995,7 @@ public:
SQInteger valuepos = _fs->PushLocalVariable(valname); SQInteger valuepos = _fs->PushLocalVariable(valname);
_fs->AddInstruction(_OP_LOADNULLS, valuepos,1); _fs->AddInstruction(_OP_LOADNULLS, valuepos,1);
//push reference index //push reference index
SQInteger itrpos = _fs->PushLocalVariable(_fs->CreateString("@ITERATOR@")); //use invalid id to make it inaccessible SQInteger itrpos = _fs->PushLocalVariable(_fs->CreateString(_SC("@ITERATOR@"))); //use invalid id to make it inaccessible
_fs->AddInstruction(_OP_LOADNULLS, itrpos,1); _fs->AddInstruction(_OP_LOADNULLS, itrpos,1);
SQInteger jmppos = _fs->GetCurrentPos(); SQInteger jmppos = _fs->GetCurrentPos();
_fs->AddInstruction(_OP_FOREACH, container, 0, indexpos); _fs->AddInstruction(_OP_FOREACH, container, 0, indexpos);
@@ -1019,8 +1014,8 @@ public:
} }
void SwitchStatement() void SwitchStatement()
{ {
Lex(); Expect('('); CommaExpr(); Expect(')'); Lex(); Expect(_SC('(')); CommaExpr(); Expect(_SC(')'));
Expect('{'); Expect(_SC('{'));
SQInteger expr = _fs->TopTarget(); SQInteger expr = _fs->TopTarget();
bool bfirst = true; bool bfirst = true;
SQInteger tonextcondjmp = -1; SQInteger tonextcondjmp = -1;
@@ -1035,7 +1030,7 @@ public:
_fs->SetIntructionParam(tonextcondjmp, 1, _fs->GetCurrentPos() - tonextcondjmp); _fs->SetIntructionParam(tonextcondjmp, 1, _fs->GetCurrentPos() - tonextcondjmp);
} }
//condition //condition
Lex(); Expression(); Expect(':'); Lex(); Expression(); Expect(_SC(':'));
SQInteger trg = _fs->PopTarget(); SQInteger trg = _fs->PopTarget();
_fs->AddInstruction(_OP_EQ, trg, trg, expr); _fs->AddInstruction(_OP_EQ, trg, trg, expr);
_fs->AddInstruction(_OP_JZ, trg, 0); _fs->AddInstruction(_OP_JZ, trg, 0);
@@ -1054,13 +1049,13 @@ public:
_fs->SetIntructionParam(tonextcondjmp, 1, _fs->GetCurrentPos() - tonextcondjmp); _fs->SetIntructionParam(tonextcondjmp, 1, _fs->GetCurrentPos() - tonextcondjmp);
if(_token == TK_DEFAULT) { if(_token == TK_DEFAULT) {
// _fs->AddLineInfos(_lex._currentline, _lineinfo); // _fs->AddLineInfos(_lex._currentline, _lineinfo);
Lex(); Expect(':'); Lex(); Expect(_SC(':'));
SQInteger stacksize = _fs->GetStackSize(); SQInteger stacksize = _fs->GetStackSize();
_last_stacksize = _fs->GetStackSize(); _last_stacksize = _fs->GetStackSize();
Statements(); Statements();
_fs->SetStackSize(stacksize); _fs->SetStackSize(stacksize);
} }
Expect('}'); Expect(_SC('}'));
_fs->PopTarget(); _fs->PopTarget();
__nbreaks__ = _fs->_unresolvedbreaks.size() - __nbreaks__; __nbreaks__ = _fs->_unresolvedbreaks.size() - __nbreaks__;
if(__nbreaks__ > 0)ResolveBreaks(_fs, __nbreaks__); if(__nbreaks__ > 0)ResolveBreaks(_fs, __nbreaks__);
@@ -1081,7 +1076,7 @@ public:
_fs->AddInstruction(_OP_LOAD, _fs->PushTarget(), _fs->GetConstant(id)); _fs->AddInstruction(_OP_LOAD, _fs->PushTarget(), _fs->GetConstant(id));
if(_token == TK_DOUBLE_COLON) Emit2ArgsOP(_OP_GET); if(_token == TK_DOUBLE_COLON) Emit2ArgsOP(_OP_GET);
} }
Expect('('); Expect(_SC('('));
CreateFunction(id); CreateFunction(id);
_fs->AddInstruction(_OP_CLOSURE, _fs->PushTarget(), _fs->_functions.size() - 1, 0); _fs->AddInstruction(_OP_CLOSURE, _fs->PushTarget(), _fs->_functions.size() - 1, 0);
EmitDerefOp(_OP_NEWSLOT); EmitDerefOp(_OP_NEWSLOT);
@@ -1095,13 +1090,13 @@ public:
_exst._funcarg = false; _exst._funcarg = false;
PrefixedExpr(); PrefixedExpr();
es = PopExpState(); es = PopExpState();
if(es._deref == DEREF_NO_DEREF) Error("invalid class name"); if(es._deref == DEREF_NO_DEREF) Error(_SC("invalid class name"));
if(es._deref == DEREF_FIELD) { if(es._deref == DEREF_FIELD) {
ClassExp(); ClassExp();
EmitDerefOp(_OP_NEWSLOT); EmitDerefOp(_OP_NEWSLOT);
_fs->PopTarget(); _fs->PopTarget();
} }
else Error("cannot create a class in a local with the syntax(class <local>)"); else Error(_SC("cannot create a class in a local with the syntax(class <local>)"));
} }
SQObject ExpectScalar() SQObject ExpectScalar()
{ {
@@ -1131,12 +1126,12 @@ public:
val._unVal.fFloat = -_lex._fvalue; val._unVal.fFloat = -_lex._fvalue;
break; break;
default: default:
Error("scalar expected : integer,float"); Error(_SC("scalar expected : integer,float"));
val._type = OT_NULL; // Silent compile-warning val._type = OT_NULL; // Silent compile-warning
} }
break; break;
default: default:
Error("scalar expected : integer,float or string"); Error(_SC("scalar expected : integer,float or string"));
val._type = OT_NULL; // Silent compile-warning val._type = OT_NULL; // Silent compile-warning
} }
Lex(); Lex();
@@ -1147,14 +1142,14 @@ public:
Lex(); Lex();
SQObject id = Expect(TK_IDENTIFIER); SQObject id = Expect(TK_IDENTIFIER);
Expect('{'); Expect(_SC('{'));
SQObject table = _fs->CreateTable(); SQObject table = _fs->CreateTable();
SQInteger nval = 0; SQInteger nval = 0;
while(_token != '}') { while(_token != _SC('}')) {
SQObject key = Expect(TK_IDENTIFIER); SQObject key = Expect(TK_IDENTIFIER);
SQObject val; SQObject val;
if(_token == '=') { if(_token == _SC('=')) {
Lex(); Lex();
val = ExpectScalar(); val = ExpectScalar();
} }
@@ -1170,7 +1165,7 @@ public:
/*SQObjectPtr dummy; /*SQObjectPtr dummy;
if(enums->Get(strongid,dummy)) { if(enums->Get(strongid,dummy)) {
dummy.Null(); strongid.Null(); dummy.Null(); strongid.Null();
Error("enumeration already exists"); Error(_SC("enumeration already exists"));
}*/ }*/
enums->NewSlot(SQObjectPtr(strongid),SQObjectPtr(table)); enums->NewSlot(SQObjectPtr(strongid),SQObjectPtr(table));
strongid.Null(); strongid.Null();
@@ -1194,7 +1189,7 @@ public:
_fs->AddInstruction(_OP_JMP, 0, 0); _fs->AddInstruction(_OP_JMP, 0, 0);
SQInteger jmppos = _fs->GetCurrentPos(); SQInteger jmppos = _fs->GetCurrentPos();
_fs->SetIntructionParam(trappos, 1, (_fs->GetCurrentPos() - trappos)); _fs->SetIntructionParam(trappos, 1, (_fs->GetCurrentPos() - trappos));
Expect(TK_CATCH); Expect('('); exid = Expect(TK_IDENTIFIER); Expect(')'); Expect(TK_CATCH); Expect(_SC('(')); exid = Expect(TK_IDENTIFIER); Expect(_SC(')'));
SQInteger stacksize = _fs->GetStackSize(); SQInteger stacksize = _fs->GetStackSize();
SQInteger ex_target = _fs->PushLocalVariable(exid); SQInteger ex_target = _fs->PushLocalVariable(exid);
_fs->SetIntructionParam(trappos, 0, ex_target); _fs->SetIntructionParam(trappos, 0, ex_target);
@@ -1204,7 +1199,7 @@ public:
} }
void FunctionExp(SQInteger ftype) void FunctionExp(SQInteger ftype)
{ {
Lex(); Expect('('); Lex(); Expect(_SC('('));
CreateFunction(_null_); CreateFunction(_null_);
_fs->AddInstruction(_OP_CLOSURE, _fs->PushTarget(), _fs->_functions.size() - 1, ftype == TK_FUNCTION?0:1); _fs->AddInstruction(_OP_CLOSURE, _fs->PushTarget(), _fs->_functions.size() - 1, ftype == TK_FUNCTION?0:1);
} }
@@ -1219,19 +1214,19 @@ public:
if(_token == TK_ATTR_OPEN) { if(_token == TK_ATTR_OPEN) {
Lex(); Lex();
_fs->AddInstruction(_OP_NEWTABLE, _fs->PushTarget()); _fs->AddInstruction(_OP_NEWTABLE, _fs->PushTarget());
ParseTableOrClass(',',TK_ATTR_CLOSE); ParseTableOrClass(_SC(','),TK_ATTR_CLOSE);
attrs = _fs->TopTarget(); attrs = _fs->TopTarget();
} }
Expect('{'); Expect(_SC('{'));
if(attrs != -1) _fs->PopTarget(); if(attrs != -1) _fs->PopTarget();
if(base != -1) _fs->PopTarget(); if(base != -1) _fs->PopTarget();
_fs->AddInstruction(_OP_CLASS, _fs->PushTarget(), base, attrs); _fs->AddInstruction(_OP_CLASS, _fs->PushTarget(), base, attrs);
ParseTableOrClass(';'); ParseTableOrClass(_SC(';'));
} }
void DelegateExpr() void DelegateExpr()
{ {
Lex(); CommaExpr(); Lex(); CommaExpr();
Expect(':'); Expect(_SC(':'));
CommaExpr(); CommaExpr();
SQInteger table = _fs->PopTarget(), delegate = _fs->PopTarget(); SQInteger table = _fs->PopTarget(), delegate = _fs->PopTarget();
_fs->AddInstruction(_OP_DELEGATE, _fs->PushTarget(), table, delegate); _fs->AddInstruction(_OP_DELEGATE, _fs->PushTarget(), table, delegate);
@@ -1244,9 +1239,9 @@ public:
_exst._funcarg = false; _exst._funcarg = false;
PrefixedExpr(); PrefixedExpr();
es = PopExpState(); es = PopExpState();
if(es._deref == DEREF_NO_DEREF) Error("can't delete an expression"); if(es._deref == DEREF_NO_DEREF) Error(_SC("can't delete an expression"));
if(es._deref == DEREF_FIELD) Emit2ArgsOP(_OP_DELETE); if(es._deref == DEREF_FIELD) Emit2ArgsOP(_OP_DELETE);
else Error("cannot delete a local"); else Error(_SC("cannot delete a local"));
} }
void PrefixIncDec(SQInteger token) void PrefixIncDec(SQInteger token)
{ {
@@ -1268,46 +1263,46 @@ public:
SQFuncState *funcstate = _fs->PushChildState(_ss(_vm)); SQFuncState *funcstate = _fs->PushChildState(_ss(_vm));
funcstate->_name = name; funcstate->_name = name;
SQObject paramname; SQObject paramname;
funcstate->AddParameter(_fs->CreateString("this")); funcstate->AddParameter(_fs->CreateString(_SC("this")));
funcstate->_sourcename = _sourcename; funcstate->_sourcename = _sourcename;
SQInteger defparams = 0; SQInteger defparams = 0;
while(_token!=')') { while(_token!=_SC(')')) {
if(_token == TK_VARPARAMS) { if(_token == TK_VARPARAMS) {
if(defparams > 0) Error("function with default parameters cannot have variable number of parameters"); if(defparams > 0) Error(_SC("function with default parameters cannot have variable number of parameters"));
funcstate->_varparams = true; funcstate->_varparams = true;
Lex(); Lex();
if(_token != ')') Error("expected ')'"); if(_token != _SC(')')) Error(_SC("expected ')'"));
break; break;
} }
else { else {
paramname = Expect(TK_IDENTIFIER); paramname = Expect(TK_IDENTIFIER);
funcstate->AddParameter(paramname); funcstate->AddParameter(paramname);
if(_token == '=') { if(_token == _SC('=')) {
Lex(); Lex();
Expression(); Expression();
funcstate->AddDefaultParam(_fs->TopTarget()); funcstate->AddDefaultParam(_fs->TopTarget());
defparams++; defparams++;
} }
else { else {
if(defparams > 0) Error("expected '='"); if(defparams > 0) Error(_SC("expected '='"));
} }
if(_token == ',') Lex(); if(_token == _SC(',')) Lex();
else if(_token != ')') Error("expected ')' or ','"); else if(_token != _SC(')')) Error(_SC("expected ')' or ','"));
} }
} }
Expect(')'); Expect(_SC(')'));
for(SQInteger n = 0; n < defparams; n++) { for(SQInteger n = 0; n < defparams; n++) {
_fs->PopTarget(); _fs->PopTarget();
} }
//outer values //outer values
if(_token == ':') { if(_token == _SC(':')) {
Lex(); Expect('('); Lex(); Expect(_SC('('));
while(_token != ')') { while(_token != _SC(')')) {
paramname = Expect(TK_IDENTIFIER); paramname = Expect(TK_IDENTIFIER);
//outers are treated as implicit local variables //outers are treated as implicit local variables
funcstate->AddOuterValue(paramname); funcstate->AddOuterValue(paramname);
if(_token == ',') Lex(); if(_token == _SC(',')) Lex();
else if(_token != ')') Error("expected ')' or ','"); else if(_token != _SC(')')) Error(_SC("expected ')' or ','"));
} }
Lex(); Lex();
} }
@@ -1315,7 +1310,7 @@ public:
SQFuncState *currchunk = _fs; SQFuncState *currchunk = _fs;
_fs = funcstate; _fs = funcstate;
Statement(); Statement();
funcstate->AddLineInfos(_lex._prevtoken == '\n'?_lex._lasttokenline:_lex._currentline, _lineinfo, true); funcstate->AddLineInfos(_lex._prevtoken == _SC('\n')?_lex._lasttokenline:_lex._currentline, _lineinfo, true);
funcstate->AddInstruction(_OP_RETURN, -1); funcstate->AddInstruction(_OP_RETURN, -1);
funcstate->SetStackSize(0); funcstate->SetStackSize(0);
//_fs->->_stacksize = _fs->_stacksize; //_fs->->_stacksize = _fs->_stacksize;

View File

@@ -71,12 +71,7 @@ struct SQVM;
#define TK_ENUM 323 #define TK_ENUM 323
#define TK_CONST 324 #define TK_CONST 324
/* MSVC doesn't like NORETURN for function prototypes, but we kinda need it for GCC. */
#if defined(_MSC_VER)
typedef void(*CompilerErrorFunc)(void *ud, const SQChar *s);
#else
typedef NORETURN void(*CompilerErrorFunc)(void *ud, const SQChar *s);
#endif
typedef void(*CompilerErrorFunc)(void *ud, const SQChar *s);
bool Compile(SQVM *vm, SQLEXREADFUNC rg, SQUserPointer up, const SQChar *sourcename, SQObjectPtr &out, bool raiseerror, bool lineinfo); bool Compile(SQVM *vm, SQLEXREADFUNC rg, SQUserPointer up, const SQChar *sourcename, SQObjectPtr &out, bool raiseerror, bool lineinfo);
#endif //_SQCOMPILER_H_ #endif //_SQCOMPILER_H_

View File

@@ -1,21 +1,14 @@
/* /*
* see copyright notice in squirrel.h see copyright notice in squirrel.h
*/ */
#include "../../../stdafx.h"
#include <squirrel.h> #include <squirrel.h>
#include "sqpcheader.h" #include "sqpcheader.h"
#include <stdarg.h>
#include "sqvm.h" #include "sqvm.h"
#include "sqfuncproto.h" #include "sqfuncproto.h"
#include "sqclosure.h" #include "sqclosure.h"
#include "sqstring.h" #include "sqstring.h"
#include "../../../core/alloc_func.hpp"
#include "../../../string_func.h"
#include "../../../safeguards.h"
SQRESULT sq_getfunctioninfo(HSQUIRRELVM v,SQInteger level,SQFunctionInfo *fi) SQRESULT sq_getfunctioninfo(HSQUIRRELVM v,SQInteger level,SQFunctionInfo *fi)
{ {
SQInteger cssize = v->_callsstacksize; SQInteger cssize = v->_callsstacksize;
@@ -25,12 +18,12 @@ SQRESULT sq_getfunctioninfo(HSQUIRRELVM v,SQInteger level,SQFunctionInfo *fi)
SQClosure *c = _closure(ci._closure); SQClosure *c = _closure(ci._closure);
SQFunctionProto *proto = _funcproto(c->_function); SQFunctionProto *proto = _funcproto(c->_function);
fi->funcid = proto; fi->funcid = proto;
fi->name = type(proto->_name) == OT_STRING?_stringval(proto->_name):"unknown"; fi->name = type(proto->_name) == OT_STRING?_stringval(proto->_name):_SC("unknown");
fi->source = type(proto->_name) == OT_STRING?_stringval(proto->_sourcename):"unknown"; fi->source = type(proto->_name) == OT_STRING?_stringval(proto->_sourcename):_SC("unknown");
return SQ_OK; return SQ_OK;
} }
} }
return sq_throwerror(v,"the object is not a closure"); return sq_throwerror(v,_SC("the object is not a closure"));
} }
SQRESULT sq_stackinfos(HSQUIRRELVM v, SQInteger level, SQStackInfos *si) SQRESULT sq_stackinfos(HSQUIRRELVM v, SQInteger level, SQStackInfos *si)
@@ -50,8 +43,8 @@ SQRESULT sq_stackinfos(HSQUIRRELVM v, SQInteger level, SQStackInfos *si)
} }
break; break;
case OT_NATIVECLOSURE: case OT_NATIVECLOSURE:
si->source = "NATIVE"; si->source = _SC("NATIVE");
si->funcname = "unknown"; si->funcname = _SC("unknown");
if(type(_nativeclosure(ci._closure)->_name) == OT_STRING) if(type(_nativeclosure(ci._closure)->_name) == OT_STRING)
si->funcname = _stringval(_nativeclosure(ci._closure)->_name); si->funcname = _stringval(_nativeclosure(ci._closure)->_name);
si->line = -1; si->line = -1;
@@ -67,12 +60,9 @@ void SQVM::Raise_Error(const SQChar *s, ...)
{ {
va_list vl; va_list vl;
va_start(vl, s); va_start(vl, s);
size_t len = strlen(s)+(NUMBER_MAX_CHAR*2); scvsprintf(_sp(rsl((SQInteger)scstrlen(s)+(NUMBER_MAX_CHAR*2))), s, vl);
char *buffer = MallocT<char>(len + 1);
vseprintf(buffer, buffer + len, s, vl);
va_end(vl); va_end(vl);
_lasterror = SQString::Create(_ss(this),buffer,-1); _lasterror = SQString::Create(_ss(this),_spval,-1);
free(buffer);
} }
void SQVM::Raise_Error(SQObjectPtr &desc) void SQVM::Raise_Error(SQObjectPtr &desc)
@@ -82,15 +72,20 @@ void SQVM::Raise_Error(SQObjectPtr &desc)
SQString *SQVM::PrintObjVal(const SQObject &o) SQString *SQVM::PrintObjVal(const SQObject &o)
{ {
char buf[NUMBER_MAX_CHAR+1];
switch(type(o)) { switch(type(o)) {
case OT_STRING: return _string(o); case OT_STRING: return _string(o);
case OT_INTEGER: case OT_INTEGER:
seprintf(buf, lastof(buf), OTTD_PRINTF64, _integer(o)); #if defined(_SQ64)
return SQString::Create(_ss(this), buf); scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)), _SC("%ld"), _integer(o));
#else
scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)), _SC("%d"), _integer(o));
#endif
return SQString::Create(_ss(this), _spval);
break;
case OT_FLOAT: case OT_FLOAT:
seprintf(buf, lastof(buf), "%.14g", _float(o)); scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)), _SC("%.14g"), _float(o));
return SQString::Create(_ss(this), buf); return SQString::Create(_ss(this), _spval);
break;
default: default:
return SQString::Create(_ss(this), GetTypeName(o)); return SQString::Create(_ss(this), GetTypeName(o));
} }
@@ -99,28 +94,28 @@ SQString *SQVM::PrintObjVal(const SQObject &o)
void SQVM::Raise_IdxError(const SQObject &o) void SQVM::Raise_IdxError(const SQObject &o)
{ {
SQObjectPtr oval = PrintObjVal(o); SQObjectPtr oval = PrintObjVal(o);
Raise_Error("the index '%.50s' does not exist", _stringval(oval)); Raise_Error(_SC("the index '%.50s' does not exist"), _stringval(oval));
} }
void SQVM::Raise_CompareError(const SQObject &o1, const SQObject &o2) void SQVM::Raise_CompareError(const SQObject &o1, const SQObject &o2)
{ {
SQObjectPtr oval1 = PrintObjVal(o1), oval2 = PrintObjVal(o2); SQObjectPtr oval1 = PrintObjVal(o1), oval2 = PrintObjVal(o2);
Raise_Error("comparsion between '%.50s' and '%.50s'", _stringval(oval1), _stringval(oval2)); Raise_Error(_SC("comparsion between '%.50s' and '%.50s'"), _stringval(oval1), _stringval(oval2));
} }
void SQVM::Raise_ParamTypeError(SQInteger nparam,SQInteger typemask,SQInteger type) void SQVM::Raise_ParamTypeError(SQInteger nparam,SQInteger typemask,SQInteger type)
{ {
SQObjectPtr exptypes = SQString::Create(_ss(this), "", -1); SQObjectPtr exptypes = SQString::Create(_ss(this), _SC(""), -1);
SQInteger found = 0; SQInteger found = 0;
for(SQInteger i=0; i<16; i++) for(SQInteger i=0; i<16; i++)
{ {
SQInteger mask = 0x00000001 << i; SQInteger mask = 0x00000001 << i;
if(typemask & (mask)) { if(typemask & (mask)) {
if(found>0) StringCat(exptypes,SQString::Create(_ss(this), "|", -1), exptypes); if(found>0) StringCat(exptypes,SQString::Create(_ss(this), _SC("|"), -1), exptypes);
found ++; found ++;
StringCat(exptypes,SQString::Create(_ss(this), IdType2Name((SQObjectType)mask), -1), exptypes); StringCat(exptypes,SQString::Create(_ss(this), IdType2Name((SQObjectType)mask), -1), exptypes);
} }
} }
Raise_Error("parameter %d has an invalid type '%s' ; expected: '%s'", nparam, IdType2Name((SQObjectType)type), _stringval(exptypes)); Raise_Error(_SC("parameter %d has an invalid type '%s' ; expected: '%s'"), nparam, IdType2Name((SQObjectType)type), _stringval(exptypes));
} }

View File

@@ -7,13 +7,13 @@
enum SQOuterType { enum SQOuterType {
otLOCAL = 0, otLOCAL = 0,
otSYMBOL = 1, otSYMBOL = 1,
otOUTER = 2, otOUTER = 2
}; };
struct SQOuterVar struct SQOuterVar
{ {
SQOuterVar() : _type(otLOCAL) {} SQOuterVar(){}
SQOuterVar(const SQObjectPtr &name,const SQObjectPtr &src,SQOuterType t) SQOuterVar(const SQObjectPtr &name,const SQObjectPtr &src,SQOuterType t)
{ {
_name = name; _name = name;
@@ -33,7 +33,7 @@ struct SQOuterVar
struct SQLocalVarInfo struct SQLocalVarInfo
{ {
SQLocalVarInfo():_start_op(0),_end_op(0), _pos(0){} SQLocalVarInfo():_start_op(0),_end_op(0){}
SQLocalVarInfo(const SQLocalVarInfo &lvi) SQLocalVarInfo(const SQLocalVarInfo &lvi)
{ {
_name=lvi._name; _name=lvi._name;
@@ -73,37 +73,9 @@ typedef sqvector<SQLineInfo> SQLineInfoVec;
struct SQFunctionProto : public SQRefCounted struct SQFunctionProto : public SQRefCounted
{ {
private: private:
SQFunctionProto(SQInteger ninstructions, SQFunctionProto(){
SQInteger nliterals,SQInteger nparameters, _stacksize=0;
SQInteger nfunctions,SQInteger noutervalues, _bgenerator=false;}
SQInteger nlineinfos,SQInteger nlocalvarinfos,SQInteger ndefaultparams)
{
_stacksize=0;
_bgenerator=false;
_varparams = false;
_ninstructions = ninstructions;
_literals = (SQObjectPtr*)&_instructions[ninstructions];
_nliterals = nliterals;
_parameters = (SQObjectPtr*)&_literals[nliterals];
_nparameters = nparameters;
_functions = (SQObjectPtr*)&_parameters[nparameters];
_nfunctions = nfunctions;
_outervalues = (SQOuterVar*)&_functions[nfunctions];
_noutervalues = noutervalues;
_lineinfos = (SQLineInfo *)&_outervalues[noutervalues];
_nlineinfos = nlineinfos;
_localvarinfos = (SQLocalVarInfo *)&_lineinfos[nlineinfos];
_nlocalvarinfos = nlocalvarinfos;
_defaultparams = (SQInteger *)&_localvarinfos[nlocalvarinfos];
_ndefaultparams = ndefaultparams;
_CONSTRUCT_VECTOR(SQObjectPtr,_nliterals,_literals);
_CONSTRUCT_VECTOR(SQObjectPtr,_nparameters,_parameters);
_CONSTRUCT_VECTOR(SQObjectPtr,_nfunctions,_functions);
_CONSTRUCT_VECTOR(SQOuterVar,_noutervalues,_outervalues);
//_CONSTRUCT_VECTOR(SQLineInfo,_nlineinfos,_lineinfos); //not required are 2 integers
_CONSTRUCT_VECTOR(SQLocalVarInfo,_nlocalvarinfos,_localvarinfos);
}
public: public:
static SQFunctionProto *Create(SQInteger ninstructions, static SQFunctionProto *Create(SQInteger ninstructions,
SQInteger nliterals,SQInteger nparameters, SQInteger nliterals,SQInteger nparameters,
@@ -113,7 +85,29 @@ public:
SQFunctionProto *f; SQFunctionProto *f;
//I compact the whole class and members in a single memory allocation //I compact the whole class and members in a single memory allocation
f = (SQFunctionProto *)sq_vm_malloc(_FUNC_SIZE(ninstructions,nliterals,nparameters,nfunctions,noutervalues,nlineinfos,nlocalvarinfos,ndefaultparams)); f = (SQFunctionProto *)sq_vm_malloc(_FUNC_SIZE(ninstructions,nliterals,nparameters,nfunctions,noutervalues,nlineinfos,nlocalvarinfos,ndefaultparams));
new (f) SQFunctionProto(ninstructions, nliterals, nparameters, nfunctions, noutervalues, nlineinfos, nlocalvarinfos, ndefaultparams); new (f) SQFunctionProto;
f->_ninstructions = ninstructions;
f->_literals = (SQObjectPtr*)&f->_instructions[ninstructions];
f->_nliterals = nliterals;
f->_parameters = (SQObjectPtr*)&f->_literals[nliterals];
f->_nparameters = nparameters;
f->_functions = (SQObjectPtr*)&f->_parameters[nparameters];
f->_nfunctions = nfunctions;
f->_outervalues = (SQOuterVar*)&f->_functions[nfunctions];
f->_noutervalues = noutervalues;
f->_lineinfos = (SQLineInfo *)&f->_outervalues[noutervalues];
f->_nlineinfos = nlineinfos;
f->_localvarinfos = (SQLocalVarInfo *)&f->_lineinfos[nlineinfos];
f->_nlocalvarinfos = nlocalvarinfos;
f->_defaultparams = (SQInteger *)&f->_localvarinfos[nlocalvarinfos];
f->_ndefaultparams = ndefaultparams;
_CONSTRUCT_VECTOR(SQObjectPtr,f->_nliterals,f->_literals);
_CONSTRUCT_VECTOR(SQObjectPtr,f->_nparameters,f->_parameters);
_CONSTRUCT_VECTOR(SQObjectPtr,f->_nfunctions,f->_functions);
_CONSTRUCT_VECTOR(SQOuterVar,f->_noutervalues,f->_outervalues);
//_CONSTRUCT_VECTOR(SQLineInfo,f->_nlineinfos,f->_lineinfos); //not required are 2 integers
_CONSTRUCT_VECTOR(SQLocalVarInfo,f->_nlocalvarinfos,f->_localvarinfos);
return f; return f;
} }
void Release(){ void Release(){

View File

@@ -1,9 +1,6 @@
/* /*
* see copyright notice in squirrel.h see copyright notice in squirrel.h
*/ */
#include "../../../stdafx.h"
#include "sqpcheader.h" #include "sqpcheader.h"
#include "sqcompiler.h" #include "sqcompiler.h"
#include "sqfuncproto.h" #include "sqfuncproto.h"
@@ -12,82 +9,84 @@
#include "sqopcodes.h" #include "sqopcodes.h"
#include "sqfuncstate.h" #include "sqfuncstate.h"
#include "../../../safeguards.h"
#ifdef _DEBUG_DUMP #ifdef _DEBUG_DUMP
SQInstructionDesc g_InstrDesc[]={ SQInstructionDesc g_InstrDesc[]={
{"_OP_LINE"}, {_SC("_OP_LINE")},
{"_OP_LOAD"}, {_SC("_OP_LOAD")},
{"_OP_LOADINT"}, {_SC("_OP_LOADINT")},
{"_OP_LOADFLOAT"}, {_SC("_OP_LOADFLOAT")},
{"_OP_DLOAD"}, {_SC("_OP_DLOAD")},
{"_OP_TAILCALL"}, {_SC("_OP_TAILCALL")},
{"_OP_CALL"}, {_SC("_OP_CALL")},
{"_OP_PREPCALL"}, {_SC("_OP_PREPCALL")},
{"_OP_PREPCALLK"}, {_SC("_OP_PREPCALLK")},
{"_OP_GETK"}, {_SC("_OP_GETK")},
{"_OP_MOVE"}, {_SC("_OP_MOVE")},
{"_OP_NEWSLOT"}, {_SC("_OP_NEWSLOT")},
{"_OP_DELETE"}, {_SC("_OP_DELETE")},
{"_OP_SET"}, {_SC("_OP_SET")},
{"_OP_GET"}, {_SC("_OP_GET")},
{"_OP_EQ"}, {_SC("_OP_EQ")},
{"_OP_NE"}, {_SC("_OP_NE")},
{"_OP_ARITH"}, {_SC("_OP_ARITH")},
{"_OP_BITW"}, {_SC("_OP_BITW")},
{"_OP_RETURN"}, {_SC("_OP_RETURN")},
{"_OP_LOADNULLS"}, {_SC("_OP_LOADNULLS")},
{"_OP_LOADROOTTABLE"}, {_SC("_OP_LOADROOTTABLE")},
{"_OP_LOADBOOL"}, {_SC("_OP_LOADBOOL")},
{"_OP_DMOVE"}, {_SC("_OP_DMOVE")},
{"_OP_JMP"}, {_SC("_OP_JMP")},
{"_OP_JNZ"}, {_SC("_OP_JNZ")},
{"_OP_JZ"}, {_SC("_OP_JZ")},
{"_OP_LOADFREEVAR"}, {_SC("_OP_LOADFREEVAR")},
{"_OP_VARGC"}, {_SC("_OP_VARGC")},
{"_OP_GETVARGV"}, {_SC("_OP_GETVARGV")},
{"_OP_NEWTABLE"}, {_SC("_OP_NEWTABLE")},
{"_OP_NEWARRAY"}, {_SC("_OP_NEWARRAY")},
{"_OP_APPENDARRAY"}, {_SC("_OP_APPENDARRAY")},
{"_OP_GETPARENT"}, {_SC("_OP_GETPARENT")},
{"_OP_COMPARITH"}, {_SC("_OP_COMPARITH")},
{"_OP_COMPARITHL"}, {_SC("_OP_COMPARITHL")},
{"_OP_INC"}, {_SC("_OP_INC")},
{"_OP_INCL"}, {_SC("_OP_INCL")},
{"_OP_PINC"}, {_SC("_OP_PINC")},
{"_OP_PINCL"}, {_SC("_OP_PINCL")},
{"_OP_CMP"}, {_SC("_OP_CMP")},
{"_OP_EXISTS"}, {_SC("_OP_EXISTS")},
{"_OP_INSTANCEOF"}, {_SC("_OP_INSTANCEOF")},
{"_OP_AND"}, {_SC("_OP_AND")},
{"_OP_OR"}, {_SC("_OP_OR")},
{"_OP_NEG"}, {_SC("_OP_NEG")},
{"_OP_NOT"}, {_SC("_OP_NOT")},
{"_OP_BWNOT"}, {_SC("_OP_BWNOT")},
{"_OP_CLOSURE"}, {_SC("_OP_CLOSURE")},
{"_OP_YIELD"}, {_SC("_OP_YIELD")},
{"_OP_RESUME"}, {_SC("_OP_RESUME")},
{"_OP_FOREACH"}, {_SC("_OP_FOREACH")},
{"_OP_POSTFOREACH"}, {_SC("_OP_POSTFOREACH")},
{"_OP_DELEGATE"}, {_SC("_OP_DELEGATE")},
{"_OP_CLONE"}, {_SC("_OP_CLONE")},
{"_OP_TYPEOF"}, {_SC("_OP_TYPEOF")},
{"_OP_PUSHTRAP"}, {_SC("_OP_PUSHTRAP")},
{"_OP_POPTRAP"}, {_SC("_OP_POPTRAP")},
{"_OP_THROW"}, {_SC("_OP_THROW")},
{"_OP_CLASS"}, {_SC("_OP_CLASS")},
{"_OP_NEWSLOTA"}, {_SC("_OP_NEWSLOTA")},
{"_OP_SCOPE_END"} {_SC("_OP_SCOPE_END")}
}; };
#endif #endif
void DumpLiteral(SQObjectPtr &o) void DumpLiteral(SQObjectPtr &o)
{ {
switch(type(o)){ switch(type(o)){
case OT_STRING: printf("\"%s\"",_stringval(o));break; case OT_STRING: scprintf(_SC("\"%s\""),_stringval(o));break;
case OT_FLOAT: printf("{%f}",_float(o));break; case OT_FLOAT: scprintf(_SC("{%f}"),_float(o));break;
case OT_INTEGER: printf("{" OTTD_PRINTF64 "}",_integer(o));break; #if defined(_SQ64)
case OT_BOOL: printf("%s",_integer(o)?"true":"false");break; case OT_INTEGER: scprintf(_SC("{%ld}"),_integer(o));break;
default: printf("(%s %p)",GetTypeName(o),(void*)_rawval(o));break; break; //shut up compiler #else
case OT_INTEGER: scprintf(_SC("{%d}"),_integer(o));break;
#endif
case OT_BOOL: scprintf(_SC("%s"),_integer(o)?_SC("true"):_SC("false"));break;
default: scprintf(_SC("(%s %p)"),GetTypeName(o),(void*)_rawval(o));break; break; //shut up compiler
} }
} }
@@ -120,11 +119,11 @@ void SQFuncState::Dump(SQFunctionProto *func)
{ {
SQUnsignedInteger n=0,i; SQUnsignedInteger n=0,i;
SQInteger si; SQInteger si;
printf("SQInstruction sizeof %d\n",sizeof(SQInstruction)); scprintf(_SC("SQInstruction sizeof %d\n"),sizeof(SQInstruction));
printf("SQObject sizeof %d\n",sizeof(SQObject)); scprintf(_SC("SQObject sizeof %d\n"),sizeof(SQObject));
printf("--------------------------------------------------------------------\n"); scprintf(_SC("--------------------------------------------------------------------\n"));
printf("*****FUNCTION [%s]\n",type(func->_name)==OT_STRING?_stringval(func->_name):"unknown"); scprintf(_SC("*****FUNCTION [%s]\n"),type(func->_name)==OT_STRING?_stringval(func->_name):_SC("unknown"));
printf("-----LITERALS\n"); scprintf(_SC("-----LITERALS\n"));
SQObjectPtr refidx,key,val; SQObjectPtr refidx,key,val;
SQInteger idx; SQInteger idx;
SQObjectPtrVec templiterals; SQObjectPtrVec templiterals;
@@ -134,43 +133,43 @@ void SQFuncState::Dump(SQFunctionProto *func)
templiterals[_integer(val)]=key; templiterals[_integer(val)]=key;
} }
for(i=0;i<templiterals.size();i++){ for(i=0;i<templiterals.size();i++){
printf("[%d] ",n); scprintf(_SC("[%d] "),n);
DumpLiteral(templiterals[i]); DumpLiteral(templiterals[i]);
printf("\n"); scprintf(_SC("\n"));
n++; n++;
} }
printf("-----PARAMS\n"); scprintf(_SC("-----PARAMS\n"));
if(_varparams) if(_varparams)
printf("<<VARPARAMS>>\n"); scprintf(_SC("<<VARPARAMS>>\n"));
n=0; n=0;
for(i=0;i<_parameters.size();i++){ for(i=0;i<_parameters.size();i++){
printf("[%d] ",n); scprintf(_SC("[%d] "),n);
DumpLiteral(_parameters[i]); DumpLiteral(_parameters[i]);
printf("\n"); scprintf(_SC("\n"));
n++; n++;
} }
printf("-----LOCALS\n"); scprintf(_SC("-----LOCALS\n"));
for(si=0;si<func->_nlocalvarinfos;si++){ for(si=0;si<func->_nlocalvarinfos;si++){
SQLocalVarInfo lvi=func->_localvarinfos[si]; SQLocalVarInfo lvi=func->_localvarinfos[si];
printf("[%d] %s \t%d %d\n",lvi._pos,_stringval(lvi._name),lvi._start_op,lvi._end_op); scprintf(_SC("[%d] %s \t%d %d\n"),lvi._pos,_stringval(lvi._name),lvi._start_op,lvi._end_op);
n++; n++;
} }
printf("-----LINE INFO\n"); scprintf(_SC("-----LINE INFO\n"));
for(i=0;i<_lineinfos.size();i++){ for(i=0;i<_lineinfos.size();i++){
SQLineInfo li=_lineinfos[i]; SQLineInfo li=_lineinfos[i];
printf("op [%d] line [%d] \n",li._op,li._line); scprintf(_SC("op [%d] line [%d] \n"),li._op,li._line);
n++; n++;
} }
printf("-----dump\n"); scprintf(_SC("-----dump\n"));
n=0; n=0;
for(i=0;i<_instructions.size();i++){ for(i=0;i<_instructions.size();i++){
SQInstruction &inst=_instructions[i]; SQInstruction &inst=_instructions[i];
if(inst.op==_OP_LOAD || inst.op==_OP_DLOAD || inst.op==_OP_PREPCALLK || inst.op==_OP_GETK ){ if(inst.op==_OP_LOAD || inst.op==_OP_DLOAD || inst.op==_OP_PREPCALLK || inst.op==_OP_GETK ){
SQInteger lidx = inst._arg1; SQInteger lidx = inst._arg1;
printf("[%03d] %15s %d ",n,g_InstrDesc[inst.op].name,inst._arg0); scprintf(_SC("[%03d] %15s %d "),n,g_InstrDesc[inst.op].name,inst._arg0);
if(lidx >= 0xFFFFFFFF) if(lidx >= 0xFFFFFFFF)
printf("null"); scprintf(_SC("null"));
else { else {
SQInteger refidx; SQInteger refidx;
SQObjectPtr val,key,refo; SQObjectPtr val,key,refo;
@@ -180,13 +179,13 @@ void SQFuncState::Dump(SQFunctionProto *func)
DumpLiteral(key); DumpLiteral(key);
} }
if(inst.op != _OP_DLOAD) { if(inst.op != _OP_DLOAD) {
printf(" %d %d \n",inst._arg2,inst._arg3); scprintf(_SC(" %d %d \n"),inst._arg2,inst._arg3);
} }
else { else {
printf(" %d ",inst._arg2); scprintf(_SC(" %d "),inst._arg2);
lidx = inst._arg3; lidx = inst._arg3;
if(lidx >= 0xFFFFFFFF) if(lidx >= 0xFFFFFFFF)
printf("null"); scprintf(_SC("null"));
else { else {
SQInteger refidx; SQInteger refidx;
SQObjectPtr val,key,refo; SQObjectPtr val,key,refo;
@@ -194,23 +193,23 @@ void SQFuncState::Dump(SQFunctionProto *func)
refo = refidx; refo = refidx;
} }
DumpLiteral(key); DumpLiteral(key);
printf("\n"); scprintf(_SC("\n"));
} }
} }
} }
else if(inst.op==_OP_LOADFLOAT) { else if(inst.op==_OP_LOADFLOAT) {
printf("[%03d] %15s %d %f %d %d\n",n,g_InstrDesc[inst.op].name,inst._arg0,*((SQFloat*)&inst._arg1),inst._arg2,inst._arg3); scprintf(_SC("[%03d] %15s %d %f %d %d\n"),n,g_InstrDesc[inst.op].name,inst._arg0,*((SQFloat*)&inst._arg1),inst._arg2,inst._arg3);
} }
else if(inst.op==_OP_ARITH){ else if(inst.op==_OP_ARITH){
printf("[%03d] %15s %d %d %d %c\n",n,g_InstrDesc[inst.op].name,inst._arg0,inst._arg1,inst._arg2,inst._arg3); scprintf(_SC("[%03d] %15s %d %d %d %c\n"),n,g_InstrDesc[inst.op].name,inst._arg0,inst._arg1,inst._arg2,inst._arg3);
} }
else else
printf("[%03d] %15s %d %d %d %d\n",n,g_InstrDesc[inst.op].name,inst._arg0,inst._arg1,inst._arg2,inst._arg3); scprintf(_SC("[%03d] %15s %d %d %d %d\n"),n,g_InstrDesc[inst.op].name,inst._arg0,inst._arg1,inst._arg2,inst._arg3);
n++; n++;
} }
printf("-----\n"); scprintf(_SC("-----\n"));
printf("stack size[%d]\n",func->_stacksize); scprintf(_SC("stack size[%d]\n"),func->_stacksize);
printf("--------------------------------------------------------------------\n\n"); scprintf(_SC("--------------------------------------------------------------------\n\n"));
} }
#endif #endif
@@ -234,7 +233,7 @@ SQInteger SQFuncState::GetConstant(const SQObject &cons)
_nliterals++; _nliterals++;
if(_nliterals > MAX_LITERALS) { if(_nliterals > MAX_LITERALS) {
val.Null(); val.Null();
Error("internal compiler error: too many literals"); Error(_SC("internal compiler error: too many literals"));
} }
} }
return _integer(val); return _integer(val);
@@ -263,7 +262,7 @@ SQInteger SQFuncState::AllocStackPos()
SQInteger npos=_vlocals.size(); SQInteger npos=_vlocals.size();
_vlocals.push_back(SQLocalVarInfo()); _vlocals.push_back(SQLocalVarInfo());
if(_vlocals.size()>((SQUnsignedInteger)_stacksize)) { if(_vlocals.size()>((SQUnsignedInteger)_stacksize)) {
if(_stacksize>MAX_FUNC_STACKSIZE) Error("internal compiler error: too many locals"); if(_stacksize>MAX_FUNC_STACKSIZE) Error(_SC("internal compiler error: too many locals"));
_stacksize=_vlocals.size(); _stacksize=_vlocals.size();
} }
return npos; return npos;
@@ -419,6 +418,7 @@ void SQFuncState::AddInstruction(SQInstruction &i)
break; break;
case _OP_GET: case _OP_GET:
if( pi.op == _OP_LOAD && pi._arg0 == i._arg2 && (!IsLocal(pi._arg0))){ if( pi.op == _OP_LOAD && pi._arg0 == i._arg2 && (!IsLocal(pi._arg0))){
pi._arg1 = pi._arg1;
pi._arg2 = (unsigned char)i._arg1; pi._arg2 = (unsigned char)i._arg1;
pi.op = _OP_GETK; pi.op = _OP_GETK;
pi._arg0 = i._arg0; pi._arg0 = i._arg0;
@@ -430,6 +430,7 @@ void SQFuncState::AddInstruction(SQInstruction &i)
if( pi.op == _OP_LOAD && pi._arg0 == i._arg1 && (!IsLocal(pi._arg0))){ if( pi.op == _OP_LOAD && pi._arg0 == i._arg1 && (!IsLocal(pi._arg0))){
pi.op = _OP_PREPCALLK; pi.op = _OP_PREPCALLK;
pi._arg0 = i._arg0; pi._arg0 = i._arg0;
pi._arg1 = pi._arg1;
pi._arg2 = i._arg2; pi._arg2 = i._arg2;
pi._arg3 = i._arg3; pi._arg3 = i._arg3;
return; return;
@@ -439,6 +440,7 @@ void SQFuncState::AddInstruction(SQInstruction &i)
if(pi.op == _OP_LOAD && pi._arg0 == i._arg1 && (!IsLocal(pi._arg0))){ if(pi.op == _OP_LOAD && pi._arg0 == i._arg1 && (!IsLocal(pi._arg0))){
pi.op = _OP_APPENDARRAY; pi.op = _OP_APPENDARRAY;
pi._arg0 = i._arg0; pi._arg0 = i._arg0;
pi._arg1 = pi._arg1;
pi._arg2 = MAX_FUNC_STACKSIZE; pi._arg2 = MAX_FUNC_STACKSIZE;
pi._arg3 = MAX_FUNC_STACKSIZE; pi._arg3 = MAX_FUNC_STACKSIZE;
return; return;
@@ -473,6 +475,7 @@ void SQFuncState::AddInstruction(SQInstruction &i)
{ {
pi.op = i.op; pi.op = i.op;
pi._arg0 = i._arg0; pi._arg0 = i._arg0;
pi._arg1 = pi._arg1;
pi._arg2 = i._arg2; pi._arg2 = i._arg2;
pi._arg3 = MAX_FUNC_STACKSIZE; pi._arg3 = MAX_FUNC_STACKSIZE;
return; return;
@@ -538,7 +541,7 @@ SQFunctionProto *SQFuncState::BuildProto()
for(SQUnsignedInteger no = 0; no < _lineinfos.size(); no++) f->_lineinfos[no] = _lineinfos[no]; for(SQUnsignedInteger no = 0; no < _lineinfos.size(); no++) f->_lineinfos[no] = _lineinfos[no];
for(SQUnsignedInteger no = 0; no < _defaultparams.size(); no++) f->_defaultparams[no] = _defaultparams[no]; for(SQUnsignedInteger no = 0; no < _defaultparams.size(); no++) f->_defaultparams[no] = _defaultparams[no];
memcpy(f->_instructions,&_instructions[0],(size_t)_instructions.size()*sizeof(SQInstruction)); memcpy(f->_instructions,&_instructions[0],_instructions.size()*sizeof(SQInstruction));
f->_varparams = _varparams; f->_varparams = _varparams;

View File

@@ -1,41 +1,30 @@
/* /*
* see copyright notice in squirrel.h see copyright notice in squirrel.h
*/ */
#include "../../../stdafx.h"
#include "sqpcheader.h" #include "sqpcheader.h"
#include <ctype.h> #include <ctype.h>
#include <stdlib.h>
#include "sqtable.h" #include "sqtable.h"
#include "sqstring.h" #include "sqstring.h"
#include "sqcompiler.h" #include "sqcompiler.h"
#include "sqlexer.h" #include "sqlexer.h"
#include "../../../string_func.h"
#include "../../../safeguards.h"
#define CUR_CHAR (_currdata) #define CUR_CHAR (_currdata)
#define RETURN_TOKEN(t) { _prevtoken = _curtoken; _curtoken = t; return t;} #define RETURN_TOKEN(t) { _prevtoken = _curtoken; _curtoken = t; return t;}
#define IS_EOB() (CUR_CHAR <= SQUIRREL_EOB) #define IS_EOB() (CUR_CHAR <= SQUIRREL_EOB)
#define NEXT() {Next();_currentcolumn++;} #define NEXT() {Next();_currentcolumn++;}
#define ADD_KEYWORD(key,id) _keywords->NewSlot( SQString::Create(ss, #key) ,SQInteger(id)) #define INIT_TEMP_STRING() { _longstr.resize(0);}
#define APPEND_CHAR(c) { _longstr.push_back(c);}
#define TERMINATE_BUFFER() {_longstr.push_back(_SC('\0'));}
#define ADD_KEYWORD(key,id) _keywords->NewSlot( SQString::Create(ss, _SC(#key)) ,SQInteger(id))
SQLexer::SQLexer(){}
SQLexer::~SQLexer() SQLexer::~SQLexer()
{ {
_keywords->Release(); _keywords->Release();
} }
void SQLexer::APPEND_CHAR(WChar c) void SQLexer::Init(SQSharedState *ss, SQLEXREADFUNC rg, SQUserPointer up,CompilerErrorFunc efunc,void *ed)
{
char buf[4];
size_t chars = Utf8Encode(buf, c);
for (size_t i = 0; i < chars; i++) {
_longstr.push_back(buf[i]);
}
}
SQLexer::SQLexer(SQSharedState *ss, SQLEXREADFUNC rg, SQUserPointer up,CompilerErrorFunc efunc,void *ed)
{ {
_errfunc = efunc; _errfunc = efunc;
_errtarget = ed; _errtarget = ed;
@@ -85,26 +74,20 @@ SQLexer::SQLexer(SQSharedState *ss, SQLEXREADFUNC rg, SQUserPointer up,CompilerE
_lasttokenline = _currentline = 1; _lasttokenline = _currentline = 1;
_currentcolumn = 0; _currentcolumn = 0;
_prevtoken = -1; _prevtoken = -1;
_curtoken = -1;
_svalue = NULL;
_nvalue = 0;
_fvalue = 0;
Next(); Next();
} }
NORETURN void SQLexer::Error(const SQChar *err) void SQLexer::Error(const SQChar *err)
{ {
_errfunc(_errtarget,err); _errfunc(_errtarget,err);
} }
void SQLexer::Next() void SQLexer::Next()
{ {
WChar t = _readf(_up); SQInteger t = _readf(_up);
if(t > MAX_CHAR) Error("Invalid character"); if(t > MAX_CHAR) Error(_SC("Invalid character"));
if(t != 0) { if(t != 0) {
_currdata = t; _currdata = (LexChar)t;
return; return;
} }
_currdata = SQUIRREL_EOB; _currdata = SQUIRREL_EOB;
@@ -127,9 +110,9 @@ void SQLexer::LexBlockComment()
bool done = false; bool done = false;
while(!done) { while(!done) {
switch(CUR_CHAR) { switch(CUR_CHAR) {
case '*': { NEXT(); if(CUR_CHAR == '/') { done = true; NEXT(); }}; continue; case _SC('*'): { NEXT(); if(CUR_CHAR == _SC('/')) { done = true; NEXT(); }}; continue;
case '\n': _currentline++; NEXT(); continue; case _SC('\n'): _currentline++; NEXT(); continue;
case SQUIRREL_EOB: Error("missing \"*/\" in comment"); case SQUIRREL_EOB: Error(_SC("missing \"*/\" in comment"));
default: NEXT(); default: NEXT();
} }
} }
@@ -140,134 +123,136 @@ SQInteger SQLexer::Lex()
_lasttokenline = _currentline; _lasttokenline = _currentline;
while(CUR_CHAR != SQUIRREL_EOB) { while(CUR_CHAR != SQUIRREL_EOB) {
switch(CUR_CHAR){ switch(CUR_CHAR){
case '\t': case '\r': case ' ': NEXT(); continue; case _SC('\t'): case _SC('\r'): case _SC(' '): NEXT(); continue;
case '\n': case _SC('\n'):
_currentline++; _currentline++;
_prevtoken=_curtoken; _prevtoken=_curtoken;
_curtoken='\n'; _curtoken=_SC('\n');
NEXT(); NEXT();
_currentcolumn=1; _currentcolumn=1;
continue; continue;
case '/': case _SC('/'):
NEXT(); NEXT();
switch(CUR_CHAR){ switch(CUR_CHAR){
case '*': case _SC('*'):
NEXT(); NEXT();
LexBlockComment(); LexBlockComment();
continue; continue;
case '/': case _SC('/'):
do { NEXT(); } while (CUR_CHAR != '\n' && (!IS_EOB())); do { NEXT(); } while (CUR_CHAR != _SC('\n') && (!IS_EOB()));
continue; continue;
case '=': case _SC('='):
NEXT(); NEXT();
RETURN_TOKEN(TK_DIVEQ); RETURN_TOKEN(TK_DIVEQ);
case '>': continue;
case _SC('>'):
NEXT(); NEXT();
RETURN_TOKEN(TK_ATTR_CLOSE); RETURN_TOKEN(TK_ATTR_CLOSE);
continue;
default: default:
RETURN_TOKEN('/'); RETURN_TOKEN('/');
} }
case '=': case _SC('='):
NEXT(); NEXT();
if (CUR_CHAR != '='){ RETURN_TOKEN('=') } if (CUR_CHAR != _SC('=')){ RETURN_TOKEN('=') }
else { NEXT(); RETURN_TOKEN(TK_EQ); } else { NEXT(); RETURN_TOKEN(TK_EQ); }
case '<': case _SC('<'):
NEXT(); NEXT();
if ( CUR_CHAR == '=' ) { NEXT(); RETURN_TOKEN(TK_LE) } if ( CUR_CHAR == _SC('=') ) { NEXT(); RETURN_TOKEN(TK_LE) }
else if ( CUR_CHAR == '-' ) { NEXT(); RETURN_TOKEN(TK_NEWSLOT); } else if ( CUR_CHAR == _SC('-') ) { NEXT(); RETURN_TOKEN(TK_NEWSLOT); }
else if ( CUR_CHAR == '<' ) { NEXT(); RETURN_TOKEN(TK_SHIFTL); } else if ( CUR_CHAR == _SC('<') ) { NEXT(); RETURN_TOKEN(TK_SHIFTL); }
else if ( CUR_CHAR == '/' ) { NEXT(); RETURN_TOKEN(TK_ATTR_OPEN); } else if ( CUR_CHAR == _SC('/') ) { NEXT(); RETURN_TOKEN(TK_ATTR_OPEN); }
//else if ( CUR_CHAR == '[' ) { NEXT(); ReadMultilineString(); RETURN_TOKEN(TK_STRING_LITERAL); } //else if ( CUR_CHAR == _SC('[') ) { NEXT(); ReadMultilineString(); RETURN_TOKEN(TK_STRING_LITERAL); }
else { RETURN_TOKEN('<') } else { RETURN_TOKEN('<') }
case '>': case _SC('>'):
NEXT(); NEXT();
if (CUR_CHAR == '='){ NEXT(); RETURN_TOKEN(TK_GE);} if (CUR_CHAR == _SC('=')){ NEXT(); RETURN_TOKEN(TK_GE);}
else if(CUR_CHAR == '>'){ else if(CUR_CHAR == _SC('>')){
NEXT(); NEXT();
if(CUR_CHAR == '>'){ if(CUR_CHAR == _SC('>')){
NEXT(); NEXT();
RETURN_TOKEN(TK_USHIFTR); RETURN_TOKEN(TK_USHIFTR);
} }
RETURN_TOKEN(TK_SHIFTR); RETURN_TOKEN(TK_SHIFTR);
} }
else { RETURN_TOKEN('>') } else { RETURN_TOKEN('>') }
case '!': case _SC('!'):
NEXT(); NEXT();
if (CUR_CHAR != '='){ RETURN_TOKEN('!')} if (CUR_CHAR != _SC('=')){ RETURN_TOKEN('!')}
else { NEXT(); RETURN_TOKEN(TK_NE); } else { NEXT(); RETURN_TOKEN(TK_NE); }
case '@': { case _SC('@'): {
SQInteger stype; SQInteger stype;
NEXT(); NEXT();
if(CUR_CHAR != '"') if(CUR_CHAR != _SC('"'))
Error("string expected"); Error(_SC("string expected"));
if((stype=ReadString('"',true))!=-1) { if((stype=ReadString(_SC('"'),true))!=-1) {
RETURN_TOKEN(stype); RETURN_TOKEN(stype);
} }
Error("error parsing the string"); Error(_SC("error parsing the string"));
} }
case '"': case _SC('"'):
case '\'': { case _SC('\''): {
SQInteger stype; SQInteger stype;
if((stype=ReadString(CUR_CHAR,false))!=-1){ if((stype=ReadString(CUR_CHAR,false))!=-1){
RETURN_TOKEN(stype); RETURN_TOKEN(stype);
} }
Error("error parsing the string"); Error(_SC("error parsing the string"));
} }
case '{': case '}': case '(': case ')': case '[': case ']': case _SC('{'): case _SC('}'): case _SC('('): case _SC(')'): case _SC('['): case _SC(']'):
case ';': case ',': case '?': case '^': case '~': case _SC(';'): case _SC(','): case _SC('?'): case _SC('^'): case _SC('~'):
{SQInteger ret = CUR_CHAR; {SQInteger ret = CUR_CHAR;
NEXT(); RETURN_TOKEN(ret); } NEXT(); RETURN_TOKEN(ret); }
case '.': case _SC('.'):
NEXT(); NEXT();
if (CUR_CHAR != '.'){ RETURN_TOKEN('.') } if (CUR_CHAR != _SC('.')){ RETURN_TOKEN('.') }
NEXT(); NEXT();
if (CUR_CHAR != '.'){ Error("invalid token '..'"); } if (CUR_CHAR != _SC('.')){ Error(_SC("invalid token '..'")); }
NEXT(); NEXT();
RETURN_TOKEN(TK_VARPARAMS); RETURN_TOKEN(TK_VARPARAMS);
case '&': case _SC('&'):
NEXT(); NEXT();
if (CUR_CHAR != '&'){ RETURN_TOKEN('&') } if (CUR_CHAR != _SC('&')){ RETURN_TOKEN('&') }
else { NEXT(); RETURN_TOKEN(TK_AND); } else { NEXT(); RETURN_TOKEN(TK_AND); }
case '|': case _SC('|'):
NEXT(); NEXT();
if (CUR_CHAR != '|'){ RETURN_TOKEN('|') } if (CUR_CHAR != _SC('|')){ RETURN_TOKEN('|') }
else { NEXT(); RETURN_TOKEN(TK_OR); } else { NEXT(); RETURN_TOKEN(TK_OR); }
case ':': case _SC(':'):
NEXT(); NEXT();
if (CUR_CHAR != ':'){ RETURN_TOKEN(':') } if (CUR_CHAR != _SC(':')){ RETURN_TOKEN(':') }
else { NEXT(); RETURN_TOKEN(TK_DOUBLE_COLON); } else { NEXT(); RETURN_TOKEN(TK_DOUBLE_COLON); }
case '*': case _SC('*'):
NEXT(); NEXT();
if (CUR_CHAR == '='){ NEXT(); RETURN_TOKEN(TK_MULEQ);} if (CUR_CHAR == _SC('=')){ NEXT(); RETURN_TOKEN(TK_MULEQ);}
else RETURN_TOKEN('*'); else RETURN_TOKEN('*');
case '%': case _SC('%'):
NEXT(); NEXT();
if (CUR_CHAR == '='){ NEXT(); RETURN_TOKEN(TK_MODEQ);} if (CUR_CHAR == _SC('=')){ NEXT(); RETURN_TOKEN(TK_MODEQ);}
else RETURN_TOKEN('%'); else RETURN_TOKEN('%');
case '-': case _SC('-'):
NEXT(); NEXT();
if (CUR_CHAR == '='){ NEXT(); RETURN_TOKEN(TK_MINUSEQ);} if (CUR_CHAR == _SC('=')){ NEXT(); RETURN_TOKEN(TK_MINUSEQ);}
else if (CUR_CHAR == '-'){ NEXT(); RETURN_TOKEN(TK_MINUSMINUS);} else if (CUR_CHAR == _SC('-')){ NEXT(); RETURN_TOKEN(TK_MINUSMINUS);}
else RETURN_TOKEN('-'); else RETURN_TOKEN('-');
case '+': case _SC('+'):
NEXT(); NEXT();
if (CUR_CHAR == '='){ NEXT(); RETURN_TOKEN(TK_PLUSEQ);} if (CUR_CHAR == _SC('=')){ NEXT(); RETURN_TOKEN(TK_PLUSEQ);}
else if (CUR_CHAR == '+'){ NEXT(); RETURN_TOKEN(TK_PLUSPLUS);} else if (CUR_CHAR == _SC('+')){ NEXT(); RETURN_TOKEN(TK_PLUSPLUS);}
else RETURN_TOKEN('+'); else RETURN_TOKEN('+');
case SQUIRREL_EOB: case SQUIRREL_EOB:
return 0; return 0;
default:{ default:{
if (isdigit(CUR_CHAR)) { if (scisdigit(CUR_CHAR)) {
SQInteger ret = ReadNumber(); SQInteger ret = ReadNumber();
RETURN_TOKEN(ret); RETURN_TOKEN(ret);
} }
else if (isalpha(CUR_CHAR) || CUR_CHAR == '_') { else if (scisalpha(CUR_CHAR) || CUR_CHAR == _SC('_')) {
SQInteger t = ReadID(); SQInteger t = ReadID();
RETURN_TOKEN(t); RETURN_TOKEN(t);
} }
else { else {
SQInteger c = CUR_CHAR; SQInteger c = CUR_CHAR;
if (iscntrl((int)c)) Error("unexpected character(control)"); if (sciscntrl((int)c)) Error(_SC("unexpected character(control)"));
NEXT(); NEXT();
RETURN_TOKEN(c); RETURN_TOKEN(c);
} }
@@ -288,7 +273,7 @@ SQInteger SQLexer::GetIDType(SQChar *s)
} }
SQInteger SQLexer::ReadString(WChar ndelim,bool verbatim) SQInteger SQLexer::ReadString(SQChar ndelim,bool verbatim)
{ {
INIT_TEMP_STRING(); INIT_TEMP_STRING();
NEXT(); NEXT();
@@ -297,22 +282,22 @@ SQInteger SQLexer::ReadString(WChar ndelim,bool verbatim)
while(CUR_CHAR != ndelim) { while(CUR_CHAR != ndelim) {
switch(CUR_CHAR) { switch(CUR_CHAR) {
case SQUIRREL_EOB: case SQUIRREL_EOB:
Error("unfinished string"); Error(_SC("unfinished string"));
return -1; return -1;
case '\n': case _SC('\n'):
if(!verbatim) Error("newline in a constant"); if(!verbatim) Error(_SC("newline in a constant"));
APPEND_CHAR(CUR_CHAR); NEXT(); APPEND_CHAR(CUR_CHAR); NEXT();
_currentline++; _currentline++;
break; break;
case '\\': case _SC('\\'):
if(verbatim) { if(verbatim) {
APPEND_CHAR('\\'); NEXT(); APPEND_CHAR('\\'); NEXT();
} }
else { else {
NEXT(); NEXT();
switch(CUR_CHAR) { switch(CUR_CHAR) {
case 'x': NEXT(); { case _SC('x'): NEXT(); {
if(!isxdigit(CUR_CHAR)) Error("hexadecimal number expected"); if(!isxdigit(CUR_CHAR)) Error(_SC("hexadecimal number expected"));
const SQInteger maxdigits = 4; const SQInteger maxdigits = 4;
SQChar temp[maxdigits+1]; SQChar temp[maxdigits+1];
SQInteger n = 0; SQInteger n = 0;
@@ -323,22 +308,22 @@ SQInteger SQLexer::ReadString(WChar ndelim,bool verbatim)
} }
temp[n] = 0; temp[n] = 0;
SQChar *sTemp; SQChar *sTemp;
APPEND_CHAR((SQChar)strtoul(temp,&sTemp,16)); APPEND_CHAR((SQChar)scstrtoul(temp,&sTemp,16));
} }
break; break;
case 't': APPEND_CHAR('\t'); NEXT(); break; case _SC('t'): APPEND_CHAR(_SC('\t')); NEXT(); break;
case 'a': APPEND_CHAR('\a'); NEXT(); break; case _SC('a'): APPEND_CHAR(_SC('\a')); NEXT(); break;
case 'b': APPEND_CHAR('\b'); NEXT(); break; case _SC('b'): APPEND_CHAR(_SC('\b')); NEXT(); break;
case 'n': APPEND_CHAR('\n'); NEXT(); break; case _SC('n'): APPEND_CHAR(_SC('\n')); NEXT(); break;
case 'r': APPEND_CHAR('\r'); NEXT(); break; case _SC('r'): APPEND_CHAR(_SC('\r')); NEXT(); break;
case 'v': APPEND_CHAR('\v'); NEXT(); break; case _SC('v'): APPEND_CHAR(_SC('\v')); NEXT(); break;
case 'f': APPEND_CHAR('\f'); NEXT(); break; case _SC('f'): APPEND_CHAR(_SC('\f')); NEXT(); break;
case '0': APPEND_CHAR('\0'); NEXT(); break; case _SC('0'): APPEND_CHAR(_SC('\0')); NEXT(); break;
case '\\': APPEND_CHAR('\\'); NEXT(); break; case _SC('\\'): APPEND_CHAR(_SC('\\')); NEXT(); break;
case '"': APPEND_CHAR('"'); NEXT(); break; case _SC('"'): APPEND_CHAR(_SC('"')); NEXT(); break;
case '\'': APPEND_CHAR('\''); NEXT(); break; case _SC('\''): APPEND_CHAR(_SC('\'')); NEXT(); break;
default: default:
Error("unrecognised escaper char"); Error(_SC("unrecognised escaper char"));
break; break;
} }
} }
@@ -359,9 +344,9 @@ SQInteger SQLexer::ReadString(WChar ndelim,bool verbatim)
} }
TERMINATE_BUFFER(); TERMINATE_BUFFER();
SQInteger len = _longstr.size()-1; SQInteger len = _longstr.size()-1;
if(ndelim == '\'') { if(ndelim == _SC('\'')) {
if(len == 0) Error("empty constant"); if(len == 0) Error(_SC("empty constant"));
if(len > 1) Error("constant too long"); if(len > 1) Error(_SC("constant too long"));
_nvalue = _longstr[0]; _nvalue = _longstr[0];
return TK_INTEGER; return TK_INTEGER;
} }
@@ -374,8 +359,8 @@ void LexHexadecimal(const SQChar *s,SQUnsignedInteger *res)
*res = 0; *res = 0;
while(*s != 0) while(*s != 0)
{ {
if(isdigit(*s)) *res = (*res)*16+((*s++)-'0'); if(scisdigit(*s)) *res = (*res)*16+((*s++)-'0');
else if(isxdigit(*s)) *res = (*res)*16+(toupper(*s++)-'A'+10); else if(scisxdigit(*s)) *res = (*res)*16+(toupper(*s++)-'A'+10);
else { assert(0); } else { assert(0); }
} }
} }
@@ -389,7 +374,7 @@ void LexInteger(const SQChar *s,SQUnsignedInteger *res)
} }
} }
SQInteger scisodigit(SQChar c) { return c >= '0' && c <= '7'; } SQInteger scisodigit(SQChar c) { return c >= _SC('0') && c <= _SC('7'); }
void LexOctal(const SQChar *s,SQUnsignedInteger *res) void LexOctal(const SQChar *s,SQUnsignedInteger *res)
{ {
@@ -416,14 +401,14 @@ SQInteger SQLexer::ReadNumber()
SQChar *sTemp; SQChar *sTemp;
INIT_TEMP_STRING(); INIT_TEMP_STRING();
NEXT(); NEXT();
if(firstchar == '0' && (toupper(CUR_CHAR) == 'X' || scisodigit(CUR_CHAR)) ) { if(firstchar == _SC('0') && (toupper(CUR_CHAR) == _SC('X') || scisodigit(CUR_CHAR)) ) {
if(scisodigit(CUR_CHAR)) { if(scisodigit(CUR_CHAR)) {
type = TOCTAL; type = TOCTAL;
while(scisodigit(CUR_CHAR)) { while(scisodigit(CUR_CHAR)) {
APPEND_CHAR(CUR_CHAR); APPEND_CHAR(CUR_CHAR);
NEXT(); NEXT();
} }
if(isdigit(CUR_CHAR)) Error("invalid octal number"); if(scisdigit(CUR_CHAR)) Error(_SC("invalid octal number"));
} }
else { else {
NEXT(); NEXT();
@@ -432,15 +417,15 @@ SQInteger SQLexer::ReadNumber()
APPEND_CHAR(CUR_CHAR); APPEND_CHAR(CUR_CHAR);
NEXT(); NEXT();
} }
if(_longstr.size() > MAX_HEX_DIGITS) Error("too many digits for an Hex number"); if(_longstr.size() > MAX_HEX_DIGITS) Error(_SC("too many digits for an Hex number"));
} }
} }
else { else {
APPEND_CHAR((int)firstchar); APPEND_CHAR((int)firstchar);
while (CUR_CHAR == '.' || isdigit(CUR_CHAR) || isexponent(CUR_CHAR)) { while (CUR_CHAR == _SC('.') || scisdigit(CUR_CHAR) || isexponent(CUR_CHAR)) {
if(CUR_CHAR == '.' || isexponent(CUR_CHAR)) type = TFLOAT; if(CUR_CHAR == _SC('.') || isexponent(CUR_CHAR)) type = TFLOAT;
if(isexponent(CUR_CHAR)) { if(isexponent(CUR_CHAR)) {
if(type != TFLOAT) Error("invalid numeric format"); if(type != TFLOAT) Error(_SC("invalid numeric format"));
type = TSCIENTIFIC; type = TSCIENTIFIC;
APPEND_CHAR(CUR_CHAR); APPEND_CHAR(CUR_CHAR);
NEXT(); NEXT();
@@ -448,7 +433,7 @@ SQInteger SQLexer::ReadNumber()
APPEND_CHAR(CUR_CHAR); APPEND_CHAR(CUR_CHAR);
NEXT(); NEXT();
} }
if(!isdigit(CUR_CHAR)) Error("exponent expected"); if(!scisdigit(CUR_CHAR)) Error(_SC("exponent expected"));
} }
APPEND_CHAR(CUR_CHAR); APPEND_CHAR(CUR_CHAR);
@@ -459,7 +444,7 @@ SQInteger SQLexer::ReadNumber()
switch(type) { switch(type) {
case TSCIENTIFIC: case TSCIENTIFIC:
case TFLOAT: case TFLOAT:
_fvalue = (SQFloat)strtod(&_longstr[0],&sTemp); _fvalue = (SQFloat)scstrtod(&_longstr[0],&sTemp);
return TK_FLOAT; return TK_FLOAT;
case TINT: case TINT:
LexInteger(&_longstr[0],(SQUnsignedInteger *)&_nvalue); LexInteger(&_longstr[0],(SQUnsignedInteger *)&_nvalue);
@@ -481,7 +466,7 @@ SQInteger SQLexer::ReadID()
do { do {
APPEND_CHAR(CUR_CHAR); APPEND_CHAR(CUR_CHAR);
NEXT(); NEXT();
} while(isalnum(CUR_CHAR) || CUR_CHAR == '_'); } while(scisalnum(CUR_CHAR) || CUR_CHAR == _SC('_'));
TERMINATE_BUFFER(); TERMINATE_BUFFER();
res = GetIDType(&_longstr[0]); res = GetIDType(&_longstr[0]);
if(res == TK_IDENTIFIER || res == TK_CONSTRUCTOR) { if(res == TK_IDENTIFIER || res == TK_CONSTRUCTOR) {

View File

@@ -2,26 +2,25 @@
#ifndef _SQLEXER_H_ #ifndef _SQLEXER_H_
#define _SQLEXER_H_ #define _SQLEXER_H_
typedef unsigned short LexChar;
struct SQLexer struct SQLexer
{ {
SQLexer();
~SQLexer(); ~SQLexer();
SQLexer(SQSharedState *ss,SQLEXREADFUNC rg,SQUserPointer up,CompilerErrorFunc efunc,void *ed); void Init(SQSharedState *ss,SQLEXREADFUNC rg,SQUserPointer up,CompilerErrorFunc efunc,void *ed);
NORETURN void Error(const SQChar *err); void Error(const SQChar *err);
SQInteger Lex(); SQInteger Lex();
const SQChar *Tok2Str(SQInteger tok); const SQChar *Tok2Str(SQInteger tok);
private: private:
SQInteger GetIDType(SQChar *s); SQInteger GetIDType(SQChar *s);
SQInteger ReadString(WChar ndelim,bool verbatim); SQInteger ReadString(SQChar ndelim,bool verbatim);
SQInteger ReadNumber(); SQInteger ReadNumber();
void LexBlockComment(); void LexBlockComment();
SQInteger ReadID(); SQInteger ReadID();
void Next(); void Next();
SQInteger _curtoken; SQInteger _curtoken;
SQTable *_keywords; SQTable *_keywords;
void INIT_TEMP_STRING() { _longstr.resize(0); }
void APPEND_CHAR(WChar c);
void TERMINATE_BUFFER() { _longstr.push_back('\0'); }
public: public:
SQInteger _prevtoken; SQInteger _prevtoken;
SQInteger _currentline; SQInteger _currentline;
@@ -32,7 +31,7 @@ public:
SQFloat _fvalue; SQFloat _fvalue;
SQLEXREADFUNC _readf; SQLEXREADFUNC _readf;
SQUserPointer _up; SQUserPointer _up;
WChar _currdata; LexChar _currdata;
SQSharedState *_sharedstate; SQSharedState *_sharedstate;
sqvector<SQChar> _longstr; sqvector<SQChar> _longstr;
CompilerErrorFunc _errfunc; CompilerErrorFunc _errfunc;

View File

@@ -1,16 +1,9 @@
/* /*
* see copyright notice in squirrel.h see copyright notice in squirrel.h
*/ */
#include "../../../stdafx.h"
#include "sqpcheader.h" #include "sqpcheader.h"
void *sq_vm_malloc(SQUnsignedInteger size){ return malloc(size); }
#include "../../../core/alloc_func.hpp" void *sq_vm_realloc(void *p, SQUnsignedInteger oldsize, SQUnsignedInteger size){ return realloc(p, size); }
#include "../../../safeguards.h"
void *sq_vm_malloc(SQUnsignedInteger size){ return MallocT<char>((size_t)size); }
void *sq_vm_realloc(void *p, SQUnsignedInteger oldsize, SQUnsignedInteger size){ return ReallocT<char>(static_cast<char*>(p), (size_t)size); }
void sq_vm_free(void *p, SQUnsignedInteger size){ free(p); } void sq_vm_free(void *p, SQUnsignedInteger size){ free(p); }

View File

@@ -1,9 +1,6 @@
/* /*
* see copyright notice in squirrel.h see copyright notice in squirrel.h
*/ */
#include "../../../stdafx.h"
#include "sqpcheader.h" #include "sqpcheader.h"
#include "sqvm.h" #include "sqvm.h"
#include "sqstring.h" #include "sqstring.h"
@@ -14,32 +11,30 @@
#include "sqclass.h" #include "sqclass.h"
#include "sqclosure.h" #include "sqclosure.h"
#include "../../../safeguards.h"
const SQChar *IdType2Name(SQObjectType type) const SQChar *IdType2Name(SQObjectType type)
{ {
switch(_RAW_TYPE(type)) switch(_RAW_TYPE(type))
{ {
case _RT_NULL:return "null"; case _RT_NULL:return _SC("null");
case _RT_INTEGER:return "integer"; case _RT_INTEGER:return _SC("integer");
case _RT_FLOAT:return "float"; case _RT_FLOAT:return _SC("float");
case _RT_BOOL:return "bool"; case _RT_BOOL:return _SC("bool");
case _RT_STRING:return "string"; case _RT_STRING:return _SC("string");
case _RT_TABLE:return "table"; case _RT_TABLE:return _SC("table");
case _RT_ARRAY:return "array"; case _RT_ARRAY:return _SC("array");
case _RT_GENERATOR:return "generator"; case _RT_GENERATOR:return _SC("generator");
case _RT_CLOSURE: case _RT_CLOSURE:
case _RT_NATIVECLOSURE: case _RT_NATIVECLOSURE:
return "function"; return _SC("function");
case _RT_USERDATA: case _RT_USERDATA:
case _RT_USERPOINTER: case _RT_USERPOINTER:
return "userdata"; return _SC("userdata");
case _RT_THREAD: return "thread"; case _RT_THREAD: return _SC("thread");
case _RT_FUNCPROTO: return "function"; case _RT_FUNCPROTO: return _SC("function");
case _RT_CLASS: return "class"; case _RT_CLASS: return _SC("class");
case _RT_INSTANCE: return "instance"; case _RT_INSTANCE: return _SC("instance");
case _RT_WEAKREF: return "weakref"; case _RT_WEAKREF: return _SC("weakref");
default: default:
return NULL; return NULL;
} }
@@ -135,8 +130,8 @@ bool SQDelegable::SetDelegate(SQTable *mt)
bool SQGenerator::Yield(SQVM *v) bool SQGenerator::Yield(SQVM *v)
{ {
if(_state==eSuspended) { v->Raise_Error("internal vm error, yielding dead generator"); return false;} if(_state==eSuspended) { v->Raise_Error(_SC("internal vm error, yielding dead generator")); return false;}
if(_state==eDead) { v->Raise_Error("internal vm error, yielding a dead generator"); return false; } if(_state==eDead) { v->Raise_Error(_SC("internal vm error, yielding a dead generator")); return false; }
SQInteger size = v->_top-v->_stackbase; SQInteger size = v->_top-v->_stackbase;
_ci=*v->ci; _ci=*v->ci;
_stack.resize(size); _stack.resize(size);
@@ -161,8 +156,8 @@ bool SQGenerator::Yield(SQVM *v)
bool SQGenerator::Resume(SQVM *v,SQInteger target) bool SQGenerator::Resume(SQVM *v,SQInteger target)
{ {
SQInteger size=_stack.size(); SQInteger size=_stack.size();
if(_state==eDead){ v->Raise_Error("resuming dead generator"); return false; } if(_state==eDead){ v->Raise_Error(_SC("resuming dead generator")); return false; }
if(_state==eRunning){ v->Raise_Error("resuming active generator"); return false; } if(_state==eRunning){ v->Raise_Error(_SC("resuming active generator")); return false; }
SQInteger prevtop=v->_top-v->_stackbase; SQInteger prevtop=v->_top-v->_stackbase;
PUSH_CALLINFO(v,_ci); PUSH_CALLINFO(v,_ci);
SQInteger oldstackbase=v->_stackbase; SQInteger oldstackbase=v->_stackbase;
@@ -189,7 +184,7 @@ bool SQGenerator::Resume(SQVM *v,SQInteger target)
v->ci->_prevstkbase = (SQInt32)(v->_stackbase - oldstackbase); v->ci->_prevstkbase = (SQInt32)(v->_stackbase - oldstackbase);
_state=eRunning; _state=eRunning;
if (type(v->_debughook) != OT_NULL && _rawval(v->_debughook) != _rawval(v->ci->_closure)) if (type(v->_debughook) != OT_NULL && _rawval(v->_debughook) != _rawval(v->ci->_closure))
v->CallDebugHook('c'); v->CallDebugHook(_SC('c'));
return true; return true;
} }
@@ -237,7 +232,7 @@ SQInteger SQFunctionProto::GetLine(SQInstruction *curr)
bool SafeWrite(HSQUIRRELVM v,SQWRITEFUNC write,SQUserPointer up,SQUserPointer dest,SQInteger size) bool SafeWrite(HSQUIRRELVM v,SQWRITEFUNC write,SQUserPointer up,SQUserPointer dest,SQInteger size)
{ {
if(write(up,dest,size) != size) { if(write(up,dest,size) != size) {
v->Raise_Error("io error (write function failure)"); v->Raise_Error(_SC("io error (write function failure)"));
return false; return false;
} }
return true; return true;
@@ -246,7 +241,7 @@ bool SafeWrite(HSQUIRRELVM v,SQWRITEFUNC write,SQUserPointer up,SQUserPointer de
bool SafeRead(HSQUIRRELVM v,SQWRITEFUNC read,SQUserPointer up,SQUserPointer dest,SQInteger size) bool SafeRead(HSQUIRRELVM v,SQWRITEFUNC read,SQUserPointer up,SQUserPointer dest,SQInteger size)
{ {
if(size && read(up,dest,size) != size) { if(size && read(up,dest,size) != size) {
v->Raise_Error("io error, read function failure, the origin stream could be corrupted/trucated"); v->Raise_Error(_SC("io error, read function failure, the origin stream could be corrupted/trucated"));
return false; return false;
} }
return true; return true;
@@ -262,7 +257,7 @@ bool CheckTag(HSQUIRRELVM v,SQWRITEFUNC read,SQUserPointer up,SQInteger tag)
SQInteger t; SQInteger t;
_CHECK_IO(SafeRead(v,read,up,&t,sizeof(t))); _CHECK_IO(SafeRead(v,read,up,&t,sizeof(t)));
if(t != tag){ if(t != tag){
v->Raise_Error("invalid or corrupted closure stream"); v->Raise_Error(_SC("invalid or corrupted closure stream"));
return false; return false;
} }
return true; return true;
@@ -274,7 +269,7 @@ bool WriteObject(HSQUIRRELVM v,SQUserPointer up,SQWRITEFUNC write,SQObjectPtr &o
switch(type(o)){ switch(type(o)){
case OT_STRING: case OT_STRING:
_CHECK_IO(SafeWrite(v,write,up,&_string(o)->_len,sizeof(SQInteger))); _CHECK_IO(SafeWrite(v,write,up,&_string(o)->_len,sizeof(SQInteger)));
_CHECK_IO(SafeWrite(v,write,up,_stringval(o),_string(o)->_len)); _CHECK_IO(SafeWrite(v,write,up,_stringval(o),rsl(_string(o)->_len)));
break; break;
case OT_INTEGER: case OT_INTEGER:
_CHECK_IO(SafeWrite(v,write,up,&_integer(o),sizeof(SQInteger)));break; _CHECK_IO(SafeWrite(v,write,up,&_integer(o),sizeof(SQInteger)));break;
@@ -283,7 +278,7 @@ bool WriteObject(HSQUIRRELVM v,SQUserPointer up,SQWRITEFUNC write,SQObjectPtr &o
case OT_NULL: case OT_NULL:
break; break;
default: default:
v->Raise_Error("cannot serialize a %s",GetTypeName(o)); v->Raise_Error(_SC("cannot serialize a %s"),GetTypeName(o));
return false; return false;
} }
return true; return true;
@@ -297,7 +292,7 @@ bool ReadObject(HSQUIRRELVM v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &o)
case OT_STRING:{ case OT_STRING:{
SQInteger len; SQInteger len;
_CHECK_IO(SafeRead(v,read,up,&len,sizeof(SQInteger))); _CHECK_IO(SafeRead(v,read,up,&len,sizeof(SQInteger)));
_CHECK_IO(SafeRead(v,read,up,_ss(v)->GetScratchPad(len),len)); _CHECK_IO(SafeRead(v,read,up,_ss(v)->GetScratchPad(rsl(len)),rsl(len)));
o=SQString::Create(_ss(v),_ss(v)->GetScratchPad(-1),len); o=SQString::Create(_ss(v),_ss(v)->GetScratchPad(-1),len);
} }
break; break;
@@ -313,7 +308,7 @@ bool ReadObject(HSQUIRRELVM v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &o)
o=_null_; o=_null_;
break; break;
default: default:
v->Raise_Error("cannot serialize a %s",IdType2Name(t)); v->Raise_Error(_SC("cannot serialize a %s"),IdType2Name(t));
return false; return false;
} }
return true; return true;

View File

@@ -32,24 +32,24 @@ enum SQMetaMethod{
MT_LAST = 18 MT_LAST = 18
}; };
#define MM_ADD "_add" #define MM_ADD _SC("_add")
#define MM_SUB "_sub" #define MM_SUB _SC("_sub")
#define MM_MUL "_mul" #define MM_MUL _SC("_mul")
#define MM_DIV "_div" #define MM_DIV _SC("_div")
#define MM_UNM "_unm" #define MM_UNM _SC("_unm")
#define MM_MODULO "_modulo" #define MM_MODULO _SC("_modulo")
#define MM_SET "_set" #define MM_SET _SC("_set")
#define MM_GET "_get" #define MM_GET _SC("_get")
#define MM_TYPEOF "_typeof" #define MM_TYPEOF _SC("_typeof")
#define MM_NEXTI "_nexti" #define MM_NEXTI _SC("_nexti")
#define MM_CMP "_cmp" #define MM_CMP _SC("_cmp")
#define MM_CALL "_call" #define MM_CALL _SC("_call")
#define MM_CLONED "_cloned" #define MM_CLONED _SC("_cloned")
#define MM_NEWSLOT "_newslot" #define MM_NEWSLOT _SC("_newslot")
#define MM_DELSLOT "_delslot" #define MM_DELSLOT _SC("_delslot")
#define MM_TOSTRING "_tostring" #define MM_TOSTRING _SC("_tostring")
#define MM_NEWMEMBER "_newmember" #define MM_NEWMEMBER _SC("_newmember")
#define MM_INHERITED "_inherited" #define MM_INHERITED _SC("_inherited")
#define MINPOWER2 4 #define MINPOWER2 4

View File

@@ -92,7 +92,8 @@ struct SQInstructionDesc {
struct SQInstruction struct SQInstruction
{ {
SQInstruction(SQOpcode _op=_OP_SCOPE_END,SQInteger a0=0,SQInteger a1=0,SQInteger a2=0,SQInteger a3=0) SQInstruction(){};
SQInstruction(SQOpcode _op,SQInteger a0=0,SQInteger a1=0,SQInteger a2=0,SQInteger a3=0)
{ op = _op; { op = _op;
_arg0 = (unsigned char)a0;_arg1 = (SQInt32)a1; _arg0 = (unsigned char)a0;_arg1 = (SQInt32)a1;
_arg2 = (unsigned char)a2;_arg3 = (unsigned char)a3; _arg2 = (unsigned char)a2;_arg3 = (unsigned char)a3;

View File

@@ -6,6 +6,10 @@
#include <crtdbg.h> #include <crtdbg.h>
#endif #endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <new> #include <new>
//squirrel stuff //squirrel stuff
#include <squirrel.h> #include <squirrel.h>

View File

@@ -1,9 +1,6 @@
/* /*
* see copyright notice in squirrel.h see copyright notice in squirrel.h
*/ */
#include "../../../stdafx.h"
#include "sqpcheader.h" #include "sqpcheader.h"
#include "sqopcodes.h" #include "sqopcodes.h"
#include "sqvm.h" #include "sqvm.h"
@@ -15,14 +12,20 @@
#include "squserdata.h" #include "squserdata.h"
#include "sqclass.h" #include "sqclass.h"
#include "../../../safeguards.h"
SQObjectPtr _null_; SQObjectPtr _null_;
SQObjectPtr _true_(true); SQObjectPtr _true_(true);
SQObjectPtr _false_(false); SQObjectPtr _false_(false);
SQObjectPtr _one_((SQInteger)1); SQObjectPtr _one_((SQInteger)1);
SQObjectPtr _minusone_((SQInteger)-1); SQObjectPtr _minusone_((SQInteger)-1);
SQSharedState::SQSharedState()
{
_compilererrorhandler = NULL;
_printfunc = NULL;
_debuginfo = false;
_notifyallexceptions = false;
}
#define newsysstring(s) { \ #define newsysstring(s) { \
_systemstrings->push_back(SQString::Create(this,s)); \ _systemstrings->push_back(SQString::Create(this,s)); \
} }
@@ -91,12 +94,8 @@ SQTable *CreateDefaultDelegate(SQSharedState *ss,SQRegFunction *funcz)
return t; return t;
} }
SQSharedState::SQSharedState() void SQSharedState::Init()
{ {
_compilererrorhandler = NULL;
_printfunc = NULL;
_debuginfo = false;
_notifyallexceptions = false;
_scratchpad=NULL; _scratchpad=NULL;
_scratchpadsize=0; _scratchpadsize=0;
#ifndef NO_GARBAGE_COLLECTOR #ifndef NO_GARBAGE_COLLECTOR
@@ -109,21 +108,21 @@ SQSharedState::SQSharedState()
_metamethodsmap = SQTable::Create(this,MT_LAST-1); _metamethodsmap = SQTable::Create(this,MT_LAST-1);
//adding type strings to avoid memory trashing //adding type strings to avoid memory trashing
//types names //types names
newsysstring("null"); newsysstring(_SC("null"));
newsysstring("table"); newsysstring(_SC("table"));
newsysstring("array"); newsysstring(_SC("array"));
newsysstring("closure"); newsysstring(_SC("closure"));
newsysstring("string"); newsysstring(_SC("string"));
newsysstring("userdata"); newsysstring(_SC("userdata"));
newsysstring("integer"); newsysstring(_SC("integer"));
newsysstring("float"); newsysstring(_SC("float"));
newsysstring("userpointer"); newsysstring(_SC("userpointer"));
newsysstring("function"); newsysstring(_SC("function"));
newsysstring("generator"); newsysstring(_SC("generator"));
newsysstring("thread"); newsysstring(_SC("thread"));
newsysstring("class"); newsysstring(_SC("class"));
newsysstring("instance"); newsysstring(_SC("instance"));
newsysstring("bool"); newsysstring(_SC("bool"));
//meta methods //meta methods
newmetamethod(MM_ADD); newmetamethod(MM_ADD);
newmetamethod(MM_SUB); newmetamethod(MM_SUB);
@@ -144,7 +143,7 @@ SQSharedState::SQSharedState()
newmetamethod(MM_NEWMEMBER); newmetamethod(MM_NEWMEMBER);
newmetamethod(MM_INHERITED); newmetamethod(MM_INHERITED);
_constructoridx = SQString::Create(this,"constructor"); _constructoridx = SQString::Create(this,_SC("constructor"));
_registry = SQTable::Create(this,0); _registry = SQTable::Create(this,0);
_consts = SQTable::Create(this,0); _consts = SQTable::Create(this,0);
_table_default_delegate = CreateDefaultDelegate(this,_table_default_delegate_funcz); _table_default_delegate = CreateDefaultDelegate(this,_table_default_delegate_funcz);
@@ -487,10 +486,10 @@ void RefTable::AllocNodes(SQUnsignedInteger size)
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
//SQStringTable //SQStringTable
/* /*
* The following code is based on Lua 4.0 (Copyright 1994-2002 Tecgraf, PUC-Rio.) * The following code is based on Lua 4.0 (Copyright 1994-2002 Tecgraf, PUC-Rio.)
* http://www.lua.org/copyright.html#4 * http://www.lua.org/copyright.html#4
* http://www.lua.org/source/4.0.1/src_lstring.c.html * http://www.lua.org/source/4.0.1/src_lstring.c.html
*/ */
SQStringTable::SQStringTable() SQStringTable::SQStringTable()
{ {
@@ -508,22 +507,26 @@ void SQStringTable::AllocNodes(SQInteger size)
{ {
_numofslots = size; _numofslots = size;
_strings = (SQString**)SQ_MALLOC(sizeof(SQString*)*_numofslots); _strings = (SQString**)SQ_MALLOC(sizeof(SQString*)*_numofslots);
memset(_strings,0,sizeof(SQString*)*(size_t)_numofslots); memset(_strings,0,sizeof(SQString*)*_numofslots);
} }
SQString *SQStringTable::Add(const SQChar *news,SQInteger len) SQString *SQStringTable::Add(const SQChar *news,SQInteger len)
{ {
if(len<0) if(len<0)
len = (SQInteger)strlen(news); len = (SQInteger)scstrlen(news);
SQHash h = ::_hashstr(news,(size_t)len)&(_numofslots-1); SQHash h = ::_hashstr(news,len)&(_numofslots-1);
SQString *s; SQString *s;
for (s = _strings[h]; s; s = s->_next){ for (s = _strings[h]; s; s = s->_next){
if(s->_len == len && (!memcmp(news,s->_val,(size_t)len))) if(s->_len == len && (!memcmp(news,s->_val,rsl(len))))
return s; //found return s; //found
} }
SQString *t=(SQString *)SQ_MALLOC(len+sizeof(SQString)); SQString *t=(SQString *)SQ_MALLOC(rsl(len)+sizeof(SQString));
new (t) SQString(news, len); new (t) SQString;
memcpy(t->_val,news,rsl(len));
t->_val[len] = _SC('\0');
t->_len = len;
t->_hash = ::_hashstr(news,len);
t->_next = _strings[h]; t->_next = _strings[h];
_strings[h] = t; _strings[h] = t;
_slotused++; _slotused++;
@@ -532,16 +535,6 @@ SQString *SQStringTable::Add(const SQChar *news,SQInteger len)
return t; return t;
} }
SQString::SQString(const SQChar *news, SQInteger len)
{
memcpy(_val,news,(size_t)len);
_val[len] = '\0';
_len = len;
_hash = ::_hashstr(news,(size_t)len);
_next = NULL;
_sharedstate = NULL;
}
void SQStringTable::Resize(SQInteger size) void SQStringTable::Resize(SQInteger size)
{ {
SQInteger oldsize=_numofslots; SQInteger oldsize=_numofslots;
@@ -575,7 +568,7 @@ void SQStringTable::Remove(SQString *bs)
_slotused--; _slotused--;
SQInteger slen = s->_len; SQInteger slen = s->_len;
s->~SQString(); s->~SQString();
SQ_FREE(s,sizeof(SQString) + slen); SQ_FREE(s,sizeof(SQString) + rsl(slen));
return; return;
} }
prev = s; prev = s;

View File

@@ -58,6 +58,7 @@ struct SQSharedState
{ {
SQSharedState(); SQSharedState();
~SQSharedState(); ~SQSharedState();
void Init();
public: public:
SQChar* GetScratchPad(SQInteger size); SQChar* GetScratchPad(SQInteger size);
SQInteger GetMetaMethodIdxByName(const SQObjectPtr &name); SQInteger GetMetaMethodIdxByName(const SQObjectPtr &name);
@@ -122,6 +123,12 @@ private:
#define _instance_ddel _table(_sharedstate->_instance_default_delegate) #define _instance_ddel _table(_sharedstate->_instance_default_delegate)
#define _weakref_ddel _table(_sharedstate->_weakref_default_delegate) #define _weakref_ddel _table(_sharedstate->_weakref_default_delegate)
#ifdef SQUNICODE //rsl REAL STRING LEN
#define rsl(l) ((l)<<1)
#else
#define rsl(l) (l)
#endif
extern SQObjectPtr _null_; extern SQObjectPtr _null_;
extern SQObjectPtr _true_; extern SQObjectPtr _true_;
extern SQObjectPtr _false_; extern SQObjectPtr _false_;

View File

@@ -13,7 +13,7 @@ inline SQHash _hashstr (const SQChar *s, size_t l)
struct SQString : public SQRefCounted struct SQString : public SQRefCounted
{ {
SQString(const SQChar *news, SQInteger len); SQString(){}
~SQString(){} ~SQString(){}
public: public:
static SQString *Create(SQSharedState *ss, const SQChar *, SQInteger len = -1 ); static SQString *Create(SQSharedState *ss, const SQChar *, SQInteger len = -1 );

View File

@@ -1,17 +1,12 @@
/* /*
* see copyright notice in squirrel.h see copyright notice in squirrel.h
*/ */
#include "../../../stdafx.h"
#include "sqpcheader.h" #include "sqpcheader.h"
#include "sqvm.h" #include "sqvm.h"
#include "sqtable.h" #include "sqtable.h"
#include "sqfuncproto.h" #include "sqfuncproto.h"
#include "sqclosure.h" #include "sqclosure.h"
#include "../../../safeguards.h"
SQTable::SQTable(SQSharedState *ss,SQInteger nInitialSize) SQTable::SQTable(SQSharedState *ss,SQInteger nInitialSize)
{ {
SQInteger pow2size=MINPOWER2; SQInteger pow2size=MINPOWER2;

View File

@@ -2,10 +2,10 @@
#ifndef _SQTABLE_H_ #ifndef _SQTABLE_H_
#define _SQTABLE_H_ #define _SQTABLE_H_
/* /*
* The following code is based on Lua 4.0 (Copyright 1994-2002 Tecgraf, PUC-Rio.) * The following code is based on Lua 4.0 (Copyright 1994-2002 Tecgraf, PUC-Rio.)
* http://www.lua.org/copyright.html#4 * http://www.lua.org/copyright.html#4
* http://www.lua.org/source/4.0.1/src_ltable.c.html * http://www.lua.org/source/4.0.1/src_ltable.c.html
*/ */
#include "sqstring.h" #include "sqstring.h"

View File

@@ -4,8 +4,7 @@
struct SQUserData : SQDelegable struct SQUserData : SQDelegable
{ {
SQUserData(SQSharedState *ss, SQInteger size){ _delegate = 0; _hook = NULL; INIT_CHAIN(); ADD_TO_CHAIN(&_ss(this)->_gc_chain, this); _size = size; _typetag = 0; SQUserData(SQSharedState *ss){ _delegate = 0; _hook = NULL; INIT_CHAIN(); ADD_TO_CHAIN(&_ss(this)->_gc_chain, this); }
}
~SQUserData() ~SQUserData()
{ {
REMOVE_FROM_CHAIN(&_ss(this)->_gc_chain, this); REMOVE_FROM_CHAIN(&_ss(this)->_gc_chain, this);
@@ -14,7 +13,9 @@ struct SQUserData : SQDelegable
static SQUserData* Create(SQSharedState *ss, SQInteger size) static SQUserData* Create(SQSharedState *ss, SQInteger size)
{ {
SQUserData* ud = (SQUserData*)SQ_MALLOC(sizeof(SQUserData)+(size-1)); SQUserData* ud = (SQUserData*)SQ_MALLOC(sizeof(SQUserData)+(size-1));
new (ud) SQUserData(ss, size); new (ud) SQUserData(ss);
ud->_size = size;
ud->_typetag = 0;
return ud; return ud;
} }
#ifndef NO_GARBAGE_COLLECTOR #ifndef NO_GARBAGE_COLLECTOR

View File

@@ -41,7 +41,7 @@ public:
size_t allocated_size = _allocated * sizeof(T); size_t allocated_size = _allocated * sizeof(T);
_allocated = 0; _allocated = 0;
for(size_t i = 0; i < _size; i++) for(SQUnsignedInteger i = 0; i < _size; i++)
_vals[i].~T(); _vals[i].~T();
SQ_FREE(_vals, allocated_size); SQ_FREE(_vals, allocated_size);
} }
@@ -61,7 +61,7 @@ public:
for(SQUnsignedInteger i = newsize; i < _size; i++) { for(SQUnsignedInteger i = newsize; i < _size; i++) {
_vals[i].~T(); _vals[i].~T();
} }
_size = (size_t)newsize; _size = newsize;
} }
} }
void shrinktofit() { if(_size > 4) { _realloc(_size); } } void shrinktofit() { if(_size > 4) { _realloc(_size); } }
@@ -90,7 +90,7 @@ public:
{ {
_vals[idx].~T(); _vals[idx].~T();
if(idx < (_size - 1)) { if(idx < (_size - 1)) {
memmove(&_vals[idx], &_vals[idx+1], sizeof(T) * (_size - (size_t)idx - 1)); memmove(&_vals[idx], &_vals[idx+1], sizeof(T) * (_size - idx - 1));
} }
_size--; _size--;
} }
@@ -103,10 +103,10 @@ private:
{ {
newsize = (newsize > 0)?newsize:4; newsize = (newsize > 0)?newsize:4;
_vals = (T*)SQ_REALLOC(_vals, _allocated * sizeof(T), newsize * sizeof(T)); _vals = (T*)SQ_REALLOC(_vals, _allocated * sizeof(T), newsize * sizeof(T));
_allocated = (size_t)newsize; _allocated = newsize;
} }
size_t _size; SQUnsignedInteger _size;
size_t _allocated; SQUnsignedInteger _allocated;
}; };
#endif //_SQUTILS_H_ #endif //_SQUTILS_H_

View File

@@ -1,12 +1,10 @@
/* /*
* see copyright notice in squirrel.h see copyright notice in squirrel.h
*/ */
#include "../../../stdafx.h"
#include <squirrel.h> #include <squirrel.h>
#include "sqpcheader.h" #include "sqpcheader.h"
#include <math.h> #include <math.h>
#include <stdlib.h>
#include "sqopcodes.h" #include "sqopcodes.h"
#include "sqfuncproto.h" #include "sqfuncproto.h"
#include "sqvm.h" #include "sqvm.h"
@@ -17,10 +15,6 @@
#include "sqarray.h" #include "sqarray.h"
#include "sqclass.h" #include "sqclass.h"
#include "../../../string_func.h"
#include "../../../safeguards.h"
#define TOP() (_stack._vals[_top-1]) #define TOP() (_stack._vals[_top-1])
#define CLEARSTACK(_last_top) { if((_last_top) >= _top) ClearStack(_last_top); } #define CLEARSTACK(_last_top) { if((_last_top) >= _top) ClearStack(_last_top); }
@@ -51,10 +45,10 @@ bool SQVM::BW_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,con
case BW_SHIFTL: res = i1 << i2; break; case BW_SHIFTL: res = i1 << i2; break;
case BW_SHIFTR: res = i1 >> i2; break; case BW_SHIFTR: res = i1 >> i2; break;
case BW_USHIFTR:res = (SQInteger)(*((SQUnsignedInteger*)&i1) >> i2); break; case BW_USHIFTR:res = (SQInteger)(*((SQUnsignedInteger*)&i1) >> i2); break;
default: { Raise_Error("internal vm error bitwise op failed"); return false; } default: { Raise_Error(_SC("internal vm error bitwise op failed")); return false; }
} }
} }
else { Raise_Error("bitwise op between '%s' and '%s'",GetTypeName(o1),GetTypeName(o2)); return false;} else { Raise_Error(_SC("bitwise op between '%s' and '%s'"),GetTypeName(o1),GetTypeName(o2)); return false;}
trg = res; trg = res;
return true; return true;
} }
@@ -67,11 +61,11 @@ bool SQVM::ARITH_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,
switch(op) { switch(op) {
case '+': res = i1 + i2; break; case '+': res = i1 + i2; break;
case '-': res = i1 - i2; break; case '-': res = i1 - i2; break;
case '/': if(i2 == 0) { Raise_Error("division by zero"); return false; } case '/': if(i2 == 0) { Raise_Error(_SC("division by zero")); return false; }
res = i1 / i2; res = i1 / i2;
break; break;
case '*': res = i1 * i2; break; case '*': res = i1 * i2; break;
case '%': if(i2 == 0) { Raise_Error("modulo by zero"); return false; } case '%': if(i2 == 0) { Raise_Error(_SC("modulo by zero")); return false; }
res = i1 % i2; res = i1 % i2;
break; break;
default: res = 0xDEADBEEF; default: res = 0xDEADBEEF;
@@ -94,7 +88,7 @@ bool SQVM::ARITH_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,
if(!StringCat(o1, o2, trg)) return false; if(!StringCat(o1, o2, trg)) return false;
} }
else if(!ArithMetaMethod(op,o1,o2,trg)) { else if(!ArithMetaMethod(op,o1,o2,trg)) {
Raise_Error("arith op %c on between '%s' and '%s'",op,GetTypeName(o1),GetTypeName(o2)); return false; Raise_Error(_SC("arith op %c on between '%s' and '%s'"),op,GetTypeName(o1),GetTypeName(o2)); return false;
} }
} }
return true; return true;
@@ -115,11 +109,6 @@ SQVM::SQVM(SQSharedState *ss)
_can_suspend = false; _can_suspend = false;
_in_stackoverflow = false; _in_stackoverflow = false;
_ops_till_suspend = 0; _ops_till_suspend = 0;
_callsstack = NULL;
_callsstacksize = 0;
_alloccallsstacksize = 0;
_top = 0;
_stackbase = 0;
ci = NULL; ci = NULL;
INIT_CHAIN();ADD_TO_CHAIN(&_ss(this)->_gc_chain,this); INIT_CHAIN();ADD_TO_CHAIN(&_ss(this)->_gc_chain,this);
} }
@@ -148,11 +137,11 @@ bool SQVM::ArithMetaMethod(SQInteger op,const SQObjectPtr &o1,const SQObjectPtr
{ {
SQMetaMethod mm; SQMetaMethod mm;
switch(op){ switch(op){
case '+': mm=MT_ADD; break; case _SC('+'): mm=MT_ADD; break;
case '-': mm=MT_SUB; break; case _SC('-'): mm=MT_SUB; break;
case '/': mm=MT_DIV; break; case _SC('/'): mm=MT_DIV; break;
case '*': mm=MT_MUL; break; case _SC('*'): mm=MT_MUL; break;
case '%': mm=MT_MODULO; break; case _SC('%'): mm=MT_MODULO; break;
default: mm = MT_ADD; assert(0); break; //shutup compiler default: mm = MT_ADD; assert(0); break; //shutup compiler
} }
if(is_delegable(o1) && _delegable(o1)->_delegate) { if(is_delegable(o1) && _delegable(o1)->_delegate) {
@@ -184,7 +173,7 @@ bool SQVM::NEG_OP(SQObjectPtr &trg,const SQObjectPtr &o)
} }
default:break; //shutup compiler default:break; //shutup compiler
} }
Raise_Error("attempt to negate a %s", GetTypeName(o)); Raise_Error(_SC("attempt to negate a %s"), GetTypeName(o));
return false; return false;
} }
@@ -196,7 +185,7 @@ bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,SQInteger &result)
SQObjectPtr res; SQObjectPtr res;
switch(type(o1)){ switch(type(o1)){
case OT_STRING: case OT_STRING:
_RET_SUCCEED(strcmp(_stringval(o1),_stringval(o2))); _RET_SUCCEED(scstrcmp(_stringval(o1),_stringval(o2)));
case OT_INTEGER: case OT_INTEGER:
/* FS#3954: wrong integer comparison */ /* FS#3954: wrong integer comparison */
_RET_SUCCEED((_integer(o1)<_integer(o2))?-1:(_integer(o1)==_integer(o2))?0:1); _RET_SUCCEED((_integer(o1)<_integer(o2))?-1:(_integer(o1)==_integer(o2))?0:1);
@@ -209,7 +198,7 @@ bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,SQInteger &result)
Push(o1);Push(o2); Push(o1);Push(o2);
if(CallMetaMethod(_delegable(o1),MT_CMP,2,res)) { if(CallMetaMethod(_delegable(o1),MT_CMP,2,res)) {
if(type(res) != OT_INTEGER) { if(type(res) != OT_INTEGER) {
Raise_Error("_cmp must return an integer"); Raise_Error(_SC("_cmp must return an integer"));
return false; return false;
} }
_RET_SUCCEED(_integer(res)) _RET_SUCCEED(_integer(res))
@@ -262,19 +251,22 @@ bool SQVM::CMP_OP(CmpOP op, const SQObjectPtr &o1,const SQObjectPtr &o2,SQObject
void SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res) void SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res)
{ {
char buf[64];
switch(type(o)) { switch(type(o)) {
case OT_STRING: case OT_STRING:
res = o; res = o;
return; return;
case OT_FLOAT: case OT_FLOAT:
seprintf(buf, lastof(buf),"%g",_float(o)); scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)),_SC("%g"),_float(o));
break; break;
case OT_INTEGER: case OT_INTEGER:
seprintf(buf, lastof(buf),OTTD_PRINTF64,_integer(o)); #if defined(_SQ64)
scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)),_SC("%ld"),_integer(o));
#else
scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)),_SC("%d"),_integer(o));
#endif
break; break;
case OT_BOOL: case OT_BOOL:
seprintf(buf, lastof(buf),_integer(o)?"true":"false"); scsprintf(_sp(rsl(6)),_integer(o)?_SC("true"):_SC("false"));
break; break;
case OT_TABLE: case OT_TABLE:
case OT_USERDATA: case OT_USERDATA:
@@ -288,9 +280,9 @@ void SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res)
} }
} }
default: default:
seprintf(buf, lastof(buf),"(%s : 0x%p)",GetTypeName(o),(void*)_rawval(o)); scsprintf(_sp(rsl(sizeof(void*)+20)),_SC("(%s : 0x%p)"),GetTypeName(o),(void*)_rawval(o));
} }
res = SQString::Create(_ss(this),buf); res = SQString::Create(_ss(this),_spval);
} }
@@ -300,9 +292,9 @@ bool SQVM::StringCat(const SQObjectPtr &str,const SQObjectPtr &obj,SQObjectPtr &
ToString(str, a); ToString(str, a);
ToString(obj, b); ToString(obj, b);
SQInteger l = _string(a)->_len , ol = _string(b)->_len; SQInteger l = _string(a)->_len , ol = _string(b)->_len;
SQChar *s = _sp(l + ol + 1); SQChar *s = _sp(rsl(l + ol + 1));
memcpy(s, _stringval(a), (size_t)l); memcpy(s, _stringval(a), rsl(l));
memcpy(s + l, _stringval(b), (size_t)ol); memcpy(s + l, _stringval(b), rsl(ol));
dest = SQString::Create(_ss(this), _spval, l + ol); dest = SQString::Create(_ss(this), _spval, l + ol);
return true; return true;
} }
@@ -358,7 +350,7 @@ bool SQVM::StartCall(SQClosure *closure,SQInteger target,SQInteger args,SQIntege
else if(func->_varparams) else if(func->_varparams)
{ {
if (nargs < paramssize) { if (nargs < paramssize) {
Raise_Error("wrong number of parameters"); Raise_Error(_SC("wrong number of parameters"));
return false; return false;
} }
for(SQInteger n = 0; n < nargs - paramssize; n++) { for(SQInteger n = 0; n < nargs - paramssize; n++) {
@@ -367,7 +359,7 @@ bool SQVM::StartCall(SQClosure *closure,SQInteger target,SQInteger args,SQIntege
} }
} }
else { else {
Raise_Error("wrong number of parameters"); Raise_Error(_SC("wrong number of parameters"));
return false; return false;
} }
} }
@@ -404,7 +396,7 @@ bool SQVM::StartCall(SQClosure *closure,SQInteger target,SQInteger args,SQIntege
_top = newtop; _top = newtop;
_stackbase = stackbase; _stackbase = stackbase;
if (type(_debughook) != OT_NULL && _rawval(_debughook) != _rawval(ci->_closure)) if (type(_debughook) != OT_NULL && _rawval(_debughook) != _rawval(ci->_closure))
CallDebugHook('c'); CallDebugHook(_SC('c'));
return true; return true;
} }
@@ -412,7 +404,7 @@ bool SQVM::Return(SQInteger _arg0, SQInteger _arg1, SQObjectPtr &retval)
{ {
if (type(_debughook) != OT_NULL && _rawval(_debughook) != _rawval(ci->_closure)) if (type(_debughook) != OT_NULL && _rawval(_debughook) != _rawval(ci->_closure))
for(SQInteger i=0;i<ci->_ncalls;i++) for(SQInteger i=0;i<ci->_ncalls;i++)
CallDebugHook('r'); CallDebugHook(_SC('r'));
SQBool broot = ci->_root; SQBool broot = ci->_root;
SQInteger last_top = _top; SQInteger last_top = _top;
@@ -478,9 +470,9 @@ bool SQVM::DerefInc(SQInteger op,SQObjectPtr &target, SQObjectPtr &self, SQObjec
SQRESULT SQVM::Suspend() SQRESULT SQVM::Suspend()
{ {
if (_suspended) if (_suspended)
return sq_throwerror(this, "cannot suspend an already suspended vm"); return sq_throwerror(this, _SC("cannot suspend an already suspended vm"));
if (_nnativecalls!=2) if (_nnativecalls!=2)
return sq_throwerror(this, "cannot suspend through native calls/metamethods"); return sq_throwerror(this, _SC("cannot suspend through native calls/metamethods"));
return SQ_SUSPEND_FLAG; return SQ_SUSPEND_FLAG;
} }
@@ -518,12 +510,12 @@ bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr
o4 = o2 = itr; o4 = o2 = itr;
if(type(itr) == OT_NULL) _FINISH(exitpos); if(type(itr) == OT_NULL) _FINISH(exitpos);
if(!Get(o1, itr, o3, false,false)) { if(!Get(o1, itr, o3, false,false)) {
Raise_Error("_nexti returned an invalid idx"); Raise_Error(_SC("_nexti returned an invalid idx"));
return false; return false;
} }
_FINISH(1); _FINISH(1);
} }
Raise_Error("_nexti failed"); Raise_Error(_SC("_nexti failed"));
return false; return false;
} }
break; break;
@@ -539,20 +531,19 @@ bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr
_generator(o1)->Resume(this, arg_2+1); _generator(o1)->Resume(this, arg_2+1);
_FINISH(0); _FINISH(0);
} }
/* FALL THROUGH */
default: default:
Raise_Error("cannot iterate %s", GetTypeName(o1)); Raise_Error(_SC("cannot iterate %s"), GetTypeName(o1));
} }
return false; //cannot be hit(just to avoid warnings) return false; //cannot be hit(just to avoid warnings)
} }
bool SQVM::DELEGATE_OP(SQObjectPtr &trg,SQObjectPtr &o1,SQObjectPtr &o2) bool SQVM::DELEGATE_OP(SQObjectPtr &trg,SQObjectPtr &o1,SQObjectPtr &o2)
{ {
if(type(o1) != OT_TABLE) { Raise_Error("delegating a '%s'", GetTypeName(o1)); return false; } if(type(o1) != OT_TABLE) { Raise_Error(_SC("delegating a '%s'"), GetTypeName(o1)); return false; }
switch(type(o2)) { switch(type(o2)) {
case OT_TABLE: case OT_TABLE:
if(!_table(o1)->SetDelegate(_table(o2))){ if(!_table(o1)->SetDelegate(_table(o2))){
Raise_Error("delegate cycle detected"); Raise_Error(_SC("delegate cycle detected"));
return false; return false;
} }
break; break;
@@ -560,7 +551,7 @@ bool SQVM::DELEGATE_OP(SQObjectPtr &trg,SQObjectPtr &o1,SQObjectPtr &o2)
_table(o1)->SetDelegate(NULL); _table(o1)->SetDelegate(NULL);
break; break;
default: default:
Raise_Error("using '%s' as delegate", GetTypeName(o2)); Raise_Error(_SC("using '%s' as delegate"), GetTypeName(o2));
return false; return false;
break; break;
} }
@@ -612,15 +603,15 @@ bool SQVM::CLOSURE_OP(SQObjectPtr &target, SQFunctionProto *func)
bool SQVM::GETVARGV_OP(SQObjectPtr &target,SQObjectPtr &index,CallInfo *ci) bool SQVM::GETVARGV_OP(SQObjectPtr &target,SQObjectPtr &index,CallInfo *ci)
{ {
if(ci->_vargs.size == 0) { if(ci->_vargs.size == 0) {
Raise_Error("the function doesn't have var args"); Raise_Error(_SC("the function doesn't have var args"));
return false; return false;
} }
if(!sq_isnumeric(index)){ if(!sq_isnumeric(index)){
Raise_Error("indexing 'vargv' with %s",GetTypeName(index)); Raise_Error(_SC("indexing 'vargv' with %s"),GetTypeName(index));
return false; return false;
} }
SQInteger idx = tointeger(index); SQInteger idx = tointeger(index);
if(idx < 0 || idx >= ci->_vargs.size){ Raise_Error("vargv index out of range"); return false; } if(idx < 0 || idx >= ci->_vargs.size){ Raise_Error(_SC("vargv index out of range")); return false; }
target = _vargsstack[ci->_vargs.base+idx]; target = _vargsstack[ci->_vargs.base+idx];
return true; return true;
} }
@@ -630,7 +621,7 @@ bool SQVM::CLASS_OP(SQObjectPtr &target,SQInteger baseclass,SQInteger attributes
SQClass *base = NULL; SQClass *base = NULL;
SQObjectPtr attrs; SQObjectPtr attrs;
if(baseclass != -1) { if(baseclass != -1) {
if(type(_stack._vals[_stackbase+baseclass]) != OT_CLASS) { Raise_Error("trying to inherit from a %s",GetTypeName(_stack._vals[_stackbase+baseclass])); return false; } if(type(_stack._vals[_stackbase+baseclass]) != OT_CLASS) { Raise_Error(_SC("trying to inherit from a %s"),GetTypeName(_stack._vals[_stackbase+baseclass])); return false; }
base = _class(_stack._vals[_stackbase + baseclass]); base = _class(_stack._vals[_stackbase + baseclass]);
} }
if(attributes != MAX_FUNC_STACKSIZE) { if(attributes != MAX_FUNC_STACKSIZE) {
@@ -685,7 +676,7 @@ bool SQVM::GETPARENT_OP(SQObjectPtr &o,SQObjectPtr &target)
case OT_CLASS: target = _class(o)->_base?_class(o)->_base:_null_; case OT_CLASS: target = _class(o)->_base?_class(o)->_base:_null_;
break; break;
default: default:
Raise_Error("the %s type doesn't have a parent slot", GetTypeName(o)); Raise_Error(_SC("the %s type doesn't have a parent slot"), GetTypeName(o));
return false; return false;
} }
return true; return true;
@@ -693,7 +684,7 @@ bool SQVM::GETPARENT_OP(SQObjectPtr &o,SQObjectPtr &target)
bool SQVM::Execute(SQObjectPtr &closure, SQInteger target, SQInteger nargs, SQInteger stackbase,SQObjectPtr &outres, SQBool raiseerror,ExecutionType et) bool SQVM::Execute(SQObjectPtr &closure, SQInteger target, SQInteger nargs, SQInteger stackbase,SQObjectPtr &outres, SQBool raiseerror,ExecutionType et)
{ {
if ((_nnativecalls + 1) > MAX_NATIVE_CALLS) { Raise_Error("Native stack overflow"); return false; } if ((_nnativecalls + 1) > MAX_NATIVE_CALLS) { Raise_Error(_SC("Native stack overflow")); return false; }
_nnativecalls++; _nnativecalls++;
AutoDec ad(&_nnativecalls); AutoDec ad(&_nnativecalls);
SQInteger traps = 0; SQInteger traps = 0;
@@ -748,12 +739,12 @@ exception_restore:
const SQInstruction &_i_ = *ci->_ip++; const SQInstruction &_i_ = *ci->_ip++;
//dumpstack(_stackbase); //dumpstack(_stackbase);
//printf("%s %d %d %d %d\n",g_InstrDesc[_i_.op].name,arg0,arg1,arg2,arg3); //scprintf("%s %d %d %d %d\n",g_InstrDesc[_i_.op].name,arg0,arg1,arg2,arg3);
switch(_i_.op) switch(_i_.op)
{ {
case _OP_LINE: case _OP_LINE:
if(type(_debughook) != OT_NULL && _rawval(_debughook) != _rawval(ci->_closure)) if(type(_debughook) != OT_NULL && _rawval(_debughook) != _rawval(ci->_closure))
CallDebugHook('l',arg1); CallDebugHook(_SC('l'),arg1);
continue; continue;
case _OP_LOAD: TARGET = ci->_literals[arg1]; continue; case _OP_LOAD: TARGET = ci->_literals[arg1]; continue;
case _OP_LOADINT: TARGET = (SQInteger)arg1; continue; case _OP_LOADINT: TARGET = (SQInteger)arg1; continue;
@@ -769,7 +760,6 @@ exception_restore:
ct_stackbase = _stackbase; ct_stackbase = _stackbase;
goto common_call; goto common_call;
} }
/* FALL THROUGH */
case _OP_CALL: { case _OP_CALL: {
ct_tailcall = false; ct_tailcall = false;
ct_target = arg0; ct_target = arg0;
@@ -839,11 +829,11 @@ common_call:
STK(ct_target) = clo; STK(ct_target) = clo;
break; break;
} }
Raise_Error("attempt to call '%s'", GetTypeName(clo)); Raise_Error(_SC("attempt to call '%s'"), GetTypeName(clo));
SQ_THROW(); SQ_THROW();
} }
default: default:
Raise_Error("attempt to call '%s'", GetTypeName(clo)); Raise_Error(_SC("attempt to call '%s'"), GetTypeName(clo));
SQ_THROW(); SQ_THROW();
} }
} }
@@ -945,7 +935,7 @@ common_call:
case _OP_EXISTS: TARGET = Get(STK(arg1), STK(arg2), temp_reg, true,false)?_true_:_false_;continue; case _OP_EXISTS: TARGET = Get(STK(arg1), STK(arg2), temp_reg, true,false)?_true_:_false_;continue;
case _OP_INSTANCEOF: case _OP_INSTANCEOF:
if(type(STK(arg1)) != OT_CLASS || type(STK(arg2)) != OT_INSTANCE) if(type(STK(arg1)) != OT_CLASS || type(STK(arg2)) != OT_INSTANCE)
{Raise_Error("cannot apply instanceof between a %s and a %s",GetTypeName(STK(arg1)),GetTypeName(STK(arg2))); SQ_THROW();} {Raise_Error(_SC("cannot apply instanceof between a %s and a %s"),GetTypeName(STK(arg1)),GetTypeName(STK(arg2))); SQ_THROW();}
TARGET = _instance(STK(arg2))->InstanceOf(_class(STK(arg1)))?_true_:_false_; TARGET = _instance(STK(arg2))->InstanceOf(_class(STK(arg1)))?_true_:_false_;
continue; continue;
case _OP_AND: case _OP_AND:
@@ -968,7 +958,7 @@ common_call:
TARGET = SQInteger(~t); TARGET = SQInteger(~t);
continue; continue;
} }
Raise_Error("attempt to perform a bitwise op on a %s", GetTypeName(STK(arg1))); Raise_Error(_SC("attempt to perform a bitwise op on a %s"), GetTypeName(STK(arg1)));
SQ_THROW(); SQ_THROW();
case _OP_CLOSURE: { case _OP_CLOSURE: {
SQClosure *c = ci->_closure._unVal.pClosure; SQClosure *c = ci->_closure._unVal.pClosure;
@@ -983,7 +973,7 @@ common_call:
traps -= ci->_etraps; traps -= ci->_etraps;
if(sarg1 != MAX_FUNC_STACKSIZE) STK(arg1) = temp_reg; if(sarg1 != MAX_FUNC_STACKSIZE) STK(arg1) = temp_reg;
} }
else { Raise_Error("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->_closure)); SQ_THROW();}
if(Return(arg0, arg1, temp_reg)){ if(Return(arg0, arg1, temp_reg)){
assert(traps == 0); assert(traps == 0);
outres = temp_reg; outres = temp_reg;
@@ -993,7 +983,7 @@ common_call:
} }
continue; continue;
case _OP_RESUME: case _OP_RESUME:
if(type(STK(arg1)) != OT_GENERATOR){ Raise_Error("trying to resume a '%s',only genenerator can be resumed", GetTypeName(STK(arg1))); SQ_THROW();} if(type(STK(arg1)) != OT_GENERATOR){ Raise_Error(_SC("trying to resume a '%s',only genenerator can be resumed"), GetTypeName(STK(arg1))); SQ_THROW();}
_GUARD(_generator(STK(arg1))->Resume(this, arg0)); _GUARD(_generator(STK(arg1))->Resume(this, arg0));
traps += ci->_etraps; traps += ci->_etraps;
continue; continue;
@@ -1009,7 +999,7 @@ common_call:
case _OP_DELEGATE: _GUARD(DELEGATE_OP(TARGET,STK(arg1),STK(arg2))); continue; case _OP_DELEGATE: _GUARD(DELEGATE_OP(TARGET,STK(arg1),STK(arg2))); continue;
case _OP_CLONE: case _OP_CLONE:
if(!Clone(STK(arg1), TARGET)) if(!Clone(STK(arg1), TARGET))
{ Raise_Error("cloning a %s", GetTypeName(STK(arg1))); SQ_THROW();} { Raise_Error(_SC("cloning a %s"), GetTypeName(STK(arg1))); SQ_THROW();}
continue; continue;
case _OP_TYPEOF: TypeOf(STK(arg1), TARGET); continue; case _OP_TYPEOF: TypeOf(STK(arg1), TARGET); continue;
case _OP_PUSHTRAP:{ case _OP_PUSHTRAP:{
@@ -1025,7 +1015,7 @@ common_call:
} }
} }
continue; continue;
case _OP_THROW: Raise_Error(TARGET); SQ_THROW(); case _OP_THROW: Raise_Error(TARGET); SQ_THROW(); continue;
case _OP_CLASS: _GUARD(CLASS_OP(TARGET,arg1,arg2)); continue; case _OP_CLASS: _GUARD(CLASS_OP(TARGET,arg1,arg2)); continue;
case _OP_NEWSLOTA: case _OP_NEWSLOTA:
bool bstatic = (arg0&NEW_SLOT_STATIC_FLAG)?true:false; bool bstatic = (arg0&NEW_SLOT_STATIC_FLAG)?true:false;
@@ -1135,11 +1125,11 @@ void SQVM::CallDebugHook(SQInteger type,SQInteger forcedline)
bool SQVM::CallNative(SQNativeClosure *nclosure,SQInteger nargs,SQInteger stackbase,SQObjectPtr &retval,bool &suspend) bool SQVM::CallNative(SQNativeClosure *nclosure,SQInteger nargs,SQInteger stackbase,SQObjectPtr &retval,bool &suspend)
{ {
if (_nnativecalls + 1 > MAX_NATIVE_CALLS) { Raise_Error("Native stack overflow"); return false; } if (_nnativecalls + 1 > MAX_NATIVE_CALLS) { Raise_Error(_SC("Native stack overflow")); return false; }
SQInteger nparamscheck = nclosure->_nparamscheck; SQInteger nparamscheck = nclosure->_nparamscheck;
if(((nparamscheck > 0) && (nparamscheck != nargs)) if(((nparamscheck > 0) && (nparamscheck != nargs))
|| ((nparamscheck < 0) && (nargs < (-nparamscheck)))) { || ((nparamscheck < 0) && (nargs < (-nparamscheck)))) {
Raise_Error("wrong number of parameters"); Raise_Error(_SC("wrong number of parameters"));
return false; return false;
} }
@@ -1347,10 +1337,10 @@ bool SQVM::Set(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr
} }
break; break;
case OT_ARRAY: case OT_ARRAY:
if(!sq_isnumeric(key)) {Raise_Error("indexing %s with %s",GetTypeName(self),GetTypeName(key)); return false; } if(!sq_isnumeric(key)) {Raise_Error(_SC("indexing %s with %s"),GetTypeName(self),GetTypeName(key)); return false; }
return _array(self)->Set(tointeger(key),val); return _array(self)->Set(tointeger(key),val);
default: default:
Raise_Error("trying to set '%s'",GetTypeName(self)); Raise_Error(_SC("trying to set '%s'"),GetTypeName(self));
return false; return false;
} }
if(fetchroot) { if(fetchroot) {
@@ -1389,7 +1379,7 @@ cloned_mt:
bool SQVM::NewSlot(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,bool bstatic) bool SQVM::NewSlot(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,bool bstatic)
{ {
if(type(key) == OT_NULL) { Raise_Error("null cannot be used as index"); return false; } if(type(key) == OT_NULL) { Raise_Error(_SC("null cannot be used as index")); return false; }
switch(type(self)) { switch(type(self)) {
case OT_TABLE: { case OT_TABLE: {
bool rawcall = true; bool rawcall = true;
@@ -1407,25 +1397,25 @@ bool SQVM::NewSlot(const SQObjectPtr &self,const SQObjectPtr &key,const SQObject
SQObjectPtr res; SQObjectPtr res;
Push(self);Push(key);Push(val); Push(self);Push(key);Push(val);
if(!CallMetaMethod(_instance(self),MT_NEWSLOT,3,res)) { if(!CallMetaMethod(_instance(self),MT_NEWSLOT,3,res)) {
Raise_Error("class instances do not support the new slot operator"); Raise_Error(_SC("class instances do not support the new slot operator"));
return false; return false;
} }
break;} break;}
case OT_CLASS: case OT_CLASS:
if(!_class(self)->NewSlot(_ss(this),key,val,bstatic)) { if(!_class(self)->NewSlot(_ss(this),key,val,bstatic)) {
if(_class(self)->_locked) { if(_class(self)->_locked) {
Raise_Error("trying to modify a class that has already been instantiated"); Raise_Error(_SC("trying to modify a class that has already been instantiated"));
return false; return false;
} }
else { else {
SQObjectPtr oval = PrintObjVal(key); SQObjectPtr oval = PrintObjVal(key);
Raise_Error("the property '%s' already exists",_stringval(oval)); Raise_Error(_SC("the property '%s' already exists"),_stringval(oval));
return false; return false;
} }
} }
break; break;
default: default:
Raise_Error("indexing %s with %s",GetTypeName(self),GetTypeName(key)); Raise_Error(_SC("indexing %s with %s"),GetTypeName(self),GetTypeName(key));
return false; return false;
break; break;
} }
@@ -1456,7 +1446,7 @@ bool SQVM::DeleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr
} }
} }
else { else {
Raise_Error("cannot delete a slot from %s",GetTypeName(self)); Raise_Error(_SC("cannot delete a slot from %s"),GetTypeName(self));
return false; return false;
} }
} }
@@ -1464,7 +1454,7 @@ bool SQVM::DeleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr
} }
break; break;
default: default:
Raise_Error("attempt to delete a slot from a %s",GetTypeName(self)); Raise_Error(_SC("attempt to delete a slot from a %s"),GetTypeName(self));
return false; return false;
} }
return true; return true;
@@ -1568,37 +1558,37 @@ void SQVM::dumpstack(SQInteger stackbase,bool dumpall)
{ {
SQInteger size=dumpall?_stack.size():_top; SQInteger size=dumpall?_stack.size():_top;
SQInteger n=0; SQInteger n=0;
printf("\n>>>>stack dump<<<<\n"); scprintf(_SC("\n>>>>stack dump<<<<\n"));
CallInfo &ci=_callsstack[_callsstacksize-1]; CallInfo &ci=_callsstack[_callsstacksize-1];
printf("IP: %p\n",ci._ip); scprintf(_SC("IP: %p\n"),ci._ip);
printf("prev stack base: %d\n",ci._prevstkbase); scprintf(_SC("prev stack base: %d\n"),ci._prevstkbase);
printf("prev top: %d\n",ci._prevtop); scprintf(_SC("prev top: %d\n"),ci._prevtop);
for(SQInteger i=0;i<size;i++){ for(SQInteger i=0;i<size;i++){
SQObjectPtr &obj=_stack[i]; SQObjectPtr &obj=_stack[i];
if(stackbase==i)printf(">");else printf(" "); if(stackbase==i)scprintf(_SC(">"));else scprintf(_SC(" "));
printf("[%d]:",n); scprintf(_SC("[%d]:"),n);
switch(type(obj)){ switch(type(obj)){
case OT_FLOAT: printf("FLOAT %.3f",_float(obj));break; case OT_FLOAT: scprintf(_SC("FLOAT %.3f"),_float(obj));break;
case OT_INTEGER: printf("INTEGER %d",_integer(obj));break; case OT_INTEGER: scprintf(_SC("INTEGER %d"),_integer(obj));break;
case OT_BOOL: printf("BOOL %s",_integer(obj)?"true":"false");break; case OT_BOOL: scprintf(_SC("BOOL %s"),_integer(obj)?"true":"false");break;
case OT_STRING: printf("STRING %s",_stringval(obj));break; case OT_STRING: scprintf(_SC("STRING %s"),_stringval(obj));break;
case OT_NULL: printf("NULL"); break; case OT_NULL: scprintf(_SC("NULL")); break;
case OT_TABLE: printf("TABLE %p[%p]",_table(obj),_table(obj)->_delegate);break; case OT_TABLE: scprintf(_SC("TABLE %p[%p]"),_table(obj),_table(obj)->_delegate);break;
case OT_ARRAY: printf("ARRAY %p",_array(obj));break; case OT_ARRAY: scprintf(_SC("ARRAY %p"),_array(obj));break;
case OT_CLOSURE: printf("CLOSURE [%p]",_closure(obj));break; case OT_CLOSURE: scprintf(_SC("CLOSURE [%p]"),_closure(obj));break;
case OT_NATIVECLOSURE: printf("NATIVECLOSURE");break; case OT_NATIVECLOSURE: scprintf(_SC("NATIVECLOSURE"));break;
case OT_USERDATA: printf("USERDATA %p[%p]",_userdataval(obj),_userdata(obj)->_delegate);break; case OT_USERDATA: scprintf(_SC("USERDATA %p[%p]"),_userdataval(obj),_userdata(obj)->_delegate);break;
case OT_GENERATOR: printf("GENERATOR %p",_generator(obj));break; case OT_GENERATOR: scprintf(_SC("GENERATOR %p"),_generator(obj));break;
case OT_THREAD: printf("THREAD [%p]",_thread(obj));break; case OT_THREAD: scprintf(_SC("THREAD [%p]"),_thread(obj));break;
case OT_USERPOINTER: printf("USERPOINTER %p",_userpointer(obj));break; case OT_USERPOINTER: scprintf(_SC("USERPOINTER %p"),_userpointer(obj));break;
case OT_CLASS: printf("CLASS %p",_class(obj));break; case OT_CLASS: scprintf(_SC("CLASS %p"),_class(obj));break;
case OT_INSTANCE: printf("INSTANCE %p",_instance(obj));break; case OT_INSTANCE: scprintf(_SC("INSTANCE %p"),_instance(obj));break;
case OT_WEAKREF: printf("WEAKERF %p",_weakref(obj));break; case OT_WEAKREF: scprintf(_SC("WEAKERF %p"),_weakref(obj));break;
default: default:
assert(0); assert(0);
break; break;
}; };
printf("\n"); scprintf(_SC("\n"));
++n; ++n;
} }
} }

View File

@@ -203,7 +203,7 @@ inline SQObjectPtr &stack_get(HSQUIRRELVM v,SQInteger idx){return ((idx>=0)?(v->
if(v->_callsstacksize == v->_alloccallsstacksize) { \ if(v->_callsstacksize == v->_alloccallsstacksize) { \
if (v->_callsstacksize > 65535 && !v->_in_stackoverflow) {\ if (v->_callsstacksize > 65535 && !v->_in_stackoverflow) {\
v->_in_stackoverflow = true; \ v->_in_stackoverflow = true; \
v->Raise_Error("stack overflow");\ v->Raise_Error(_SC("stack overflow"));\
v->CallErrorHandler(v->_lasterror);\ v->CallErrorHandler(v->_lasterror);\
return false;\ return false;\
}\ }\

View File

@@ -11,13 +11,10 @@
#include "../stdafx.h" #include "../stdafx.h"
#include "../settings_type.h" #include "../settings_type.h"
#include "../string_func.h"
#include "ai.hpp" #include "ai.hpp"
#include "ai_config.hpp" #include "ai_config.hpp"
#include "ai_info.hpp" #include "ai_info.hpp"
#include "../safeguards.h"
/** Configuration for AI start date, every AI has this setting. */ /** Configuration for AI start date, every AI has this setting. */
ScriptConfigItem _start_date_config = { ScriptConfigItem _start_date_config = {
"start_date", "start_date",
@@ -110,7 +107,7 @@ void AIConfig::SetSetting(const char *name, int value)
if (it != this->settings.end()) { if (it != this->settings.end()) {
(*it).second = value; (*it).second = value;
} else { } else {
this->settings[stredup(name)] = value; this->settings[strdup(name)] = value;
} }
return; return;

View File

@@ -22,8 +22,6 @@
#include "ai_info.hpp" #include "ai_info.hpp"
#include "ai.hpp" #include "ai.hpp"
#include "../safeguards.h"
/* static */ uint AI::frame_counter = 0; /* static */ uint AI::frame_counter = 0;
/* static */ AIScannerInfo *AI::scanner_info = NULL; /* static */ AIScannerInfo *AI::scanner_info = NULL;
/* static */ AIScannerLibrary *AI::scanner_library = NULL; /* static */ AIScannerLibrary *AI::scanner_library = NULL;

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