1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-13 09:39:10 +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
249 changed files with 8402 additions and 17764 deletions

View File

@@ -75,10 +75,10 @@ $(BIN_DIR)/%.obm: $(BASESET_DIR)/%.obm $(OBJS_DIR)/langfiles.tmp $(BASESET_DIR)/
$(Q) awk -v langfiles='$(OBJS_DIR)/langfiles.tmp' -f $(BASESET_DIR)/translations.awk $< >$@
# Compile extra grf
$(BIN_DIR)/openttd.grf: $(PNG_FILES) $(NFO_FILES) $(OBJS_DIR)/sprites
$(BIN_DIR)/openttd.grf: $(PNG_FILES) $(NFO_FILES) $(OBJS_DIR)/sprites $(GRF_DIR)/assemble_nfo.awk
$(E) '$(STAGE) Assembling openttd.nfo'
$(Q)-cp $(PNG_FILES) $(OBJS_DIR)/sprites 2> /dev/null
$(Q) $(CC_BUILD) -nostdinc -I$(GRF_DIR) -C -E - < "$(GRF_DIR)/openttd.nfo" | sed -e '/^#/d' -e '/^$$/d' > $(OBJS_DIR)/sprites/openttd.nfo
$(Q) awk -f $(GRF_DIR)/assemble_nfo.awk $(GRF_DIR)/openttd.nfo > $(OBJS_DIR)/sprites/openttd.nfo
$(Q) $(NFORENUM) -s $(OBJS_DIR)/sprites/openttd.nfo
$(E) '$(STAGE) Compiling openttd.grf'
$(Q) $(GRFCODEC) -n -s -e -p1 $(OBJS_DIR)/openttd.grf

View File

@@ -10,7 +10,7 @@ fallback = true
description = A music pack without actual music.
description.af_ZA = 'n Musiek stel sonder enige musiek.
description.ar_EG = مجموعة موسيقى بدون موسيقى
description.be_BY = "Пусты" набор музычнага афармлення, не змяшчаючы ніякай музыкі.
description.be_BY = "Пусты" набор музычнага афармлення, які не зьмяшчае ніякай музыкі.
description.bg_BG = Празен музикален пакет.
description.ca_ES = Un joc de música sense cap música.
description.cs_CZ = Prázná hudební sada.

View File

@@ -10,7 +10,7 @@ fallback = true
description = A sound pack without any sounds.
description.af_ZA = 'n Klank stel sonder enige klanke.
description.ar_EG = مجموعة صوت بدوت اصوات مضافة
description.be_BY = "Пусты" набор гукавога афармленьня, не змяшчаючы ніякіх гукаў.
description.be_BY = "Пусты" набор гукавога афармленьня, які не зьмяшчае ніякіх гукаў.
description.bg_BG = Празен звуков пакет.
description.ca_ES = Un joc de sons sense cap so.
description.cs_CZ = Prázdná sada zvuků.
@@ -22,6 +22,7 @@ description.en_AU = A sound pack without any sounds.
description.en_US = A sound pack without any sounds.
description.es_ES = Un conjunto de sonidos vacío.
description.et_EE = Helikogu ilma helideta.
description.eu_ES = Soinurik gabeko soinu pakete bat
description.fi_FI = Äänipaketti, jossa ei ole ääniä.
description.fr_FR = Un pack de sons sans sons.
description.gd_GB = Pacaid fhuaimean anns nach eil fuaim sam bith.

Binary file not shown.

View File

@@ -11,7 +11,7 @@ palette = DOS
description = Original Transport Tycoon Deluxe DOS edition graphics.
description.af_ZA = Oorspronklike Transport Tycoon Deluxe DOS uitgawe grafieke.
description.ar_EG = النسخة الاصلية من ترانسبورت تايكون ديلوكس الرسومية نسخة الدوس
description.be_BY = Арыгінальная графіка з Transport Tycoon Deluxe для DOS.
description.be_BY = Арыґінальная ґрафіка з Transport Tycoon Deluxe для DOS.
description.bg_BG = Оригинални графики на Transport Tycoon Deluxe за DOS.
description.ca_ES = Gràfics originals de Transport Tycoon Deluxe per a DOS.
description.cs_CZ = Původní sada grafik Transport Tycoon Deluxe (verze pro DOS).

View File

@@ -10,7 +10,7 @@ version = 0
description = Original Transport Tycoon Deluxe DOS edition sounds.
description.af_ZA = Oorspronklike Transport Tycoon Deluxe DOS uitgawe klanke.
description.ar_EG = النسخة الاصلية من ترانسبورت تايكون ديلوكس الصوتية نسخة الدوس
description.be_BY = Арыгінальны набор гукавога афармленьня з гульні Transport Tycoon Deluxe для DOS.
description.be_BY = Арыґінальны набор гукавога афармленьня з гульні Transport Tycoon Deluxe для DOS.
description.bg_BG = Оригинални звуци на Transport Tycoon Deluxe за DOS.
description.ca_ES = Sons originals de Transport Tycoon Deluxe per a DOS.
description.cs_CZ = Původní sada zvuků Transport Tycoon Deluxe (verze pro DOS).

View File

@@ -11,7 +11,7 @@ palette = DOS
description = Original Transport Tycoon Deluxe DOS (German) edition graphics.
description.af_ZA = Oorspronklike Transport Tycoon Deluxe DOS (German) uitgawe grafieke.
description.ar_EG = النسخة الاصلية من ترانسبورت تايكون ديلوكس الالمانية نسخة الدوس
description.be_BY = Арыгінальная графіка з нямецкай версіі Transport Tycoon Deluxe для DOS.
description.be_BY = Арыґінальная ґрафіка зь нямецкай версіі Transport Tycoon Deluxe для DOS.
description.bg_BG = Оригинални графики на Transport Tycoon Deluxe за DOS (немски) .
description.ca_ES = Gràfics originals de Transport Tycoon Deluxe per a DOS (Alemany).
description.cs_CZ = Původní sada grafik Transport Tycoon Deluxe (německá verze pro DOS).

View File

@@ -11,7 +11,7 @@ palette = Windows
description = Original Transport Tycoon Deluxe Windows edition graphics.
description.af_ZA = Oorspronklike Transport Tycoon Deluxe Windows uitgawe grafieke.
description.ar_EG = النسخة الاصلية من ترانسبورت تايكون ديلوكس الرسومية نسخة وندوز
description.be_BY = Арыгінальная графіка з Transport Tycoon Deluxe для Windows.
description.be_BY = Арыґінальная ґрафіка з Transport Tycoon Deluxe для Windows.
description.bg_BG = Оригинални графики на Transport Tycoon Deluxe за Windows.
description.ca_ES = Gràfics originals de Transport Tycoon Deluxe per a Windows.
description.cs_CZ = Původní sada grafik Transport Tycoon Deluxe (verze pro Windows).

View File

@@ -10,7 +10,7 @@ version = 1
description = Original Transport Tycoon Deluxe Windows edition music.
description.af_ZA = Oorspronklike Transport Tycoon Deluxe Windows uitgawe musiek.
description.ar_EG = النسخة الاصلية من ترانسبورت تايكون ديلوكس الموسيقية نسخة وندوز
description.be_BY = Арыгінальны набор музычнага афармленьня з гульні Transport Tycoon Deluxe для Windows.
description.be_BY = Арыґінальны набор музычнага афармленьня з гульні Transport Tycoon Deluxe для Windows.
description.bg_BG = Оригинална музика на Transport Tycoon Deluxe за Windows.
description.ca_ES = Música Original de Transport Tycoon Deluxe per a Windows.
description.cs_CZ = Původní hudba Transport Tycoon Deluxe (verze pro Windows).

View File

@@ -10,7 +10,7 @@ version = 0
description = Original Transport Tycoon Deluxe Windows edition sounds.
description.af_ZA = Oorspronklike Transport Tycoon Deluxe Windows uitgawe klanke.
description.ar_EG = النسخة الاصلية من ترانسبورت تايكون ديلوكس الصوتية نسخة وندوز
description.be_BY = Арыгінальны набор гукавога афармленьня з гульні Transport Tycoon Deluxe для Windows.
description.be_BY = Арыґінальны набор гукавога афармленьня з гульні Transport Tycoon Deluxe для Windows.
description.bg_BG = Оригинални звуци на Transport Tycoon Deluxe за Windows.
description.ca_ES = Sons originals de Transport Tycoon Deluxe per a Windows.
description.cs_CZ = Původní sada zvuků Transport Tycoon Deluxe (verze pro Windows).

View File

@@ -1,3 +1,131 @@
1.4.4-RC1 (2014-10-08)
------------------------------------------------------------------------
- Fix: Image widgets stored 32bit SpriteID in uint16 (r26971)
- Fix: Owner of road depot road types were not properly changed upon bankruptcy [FS#6126] (r26955)
- 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)
- Fix: [Squirrel] Debian lintian issues (r26853)
- 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)
1.4.3 (2014-09-23)
------------------------------------------------------------------------
(None)
1.4.3-RC2 (2014-09-14)
------------------------------------------------------------------------
- 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)
1.4.3-RC1 (2014-09-07)
------------------------------------------------------------------------
- Fix: TC_NO_SHADE did not work for 32bpp text rendering (r26792)
- 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)
- 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)
1.4.2 (2014-08-16)
------------------------------------------------------------------------
(None)
1.4.2-RC2 (2014-08-03)
------------------------------------------------------------------------
- Change: Use awk instead of trying to convince cpp to preprocess nfo files (r26708)
- Fix: CMD_CLEAR_ORDER_BACKUP should not be suppressed by pause modes (r26716)
- 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)
- Fix: Wrong breakdown sound was played for ships [FS#6015] (r26706)
- Fix: Integer overflows in acceleration code causing either too low acceleration or too high acceleration [FS#6067] (r26702)
- Fix: Discard incorrectly saved order backups when clients join [FS#6066] (r26700)
- 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: Slovak uses space as group separator in numbers [FS#6064] (r26695)
- Fix: Tighten parameter bound checks on GSCargoMonitor functions, and return -1 on out-of-bound parameters (r26685)
1.4.2-RC1 (2014-07-03)
------------------------------------------------------------------------
- Fix: CargoPacket::SourceStation() returns a StationID (r26660)
- Fix: Days in dates are not represented by ordinal numbers in all languages [FS#6047] (r26657)
- 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)
- Fix: Incorrect usage of string commands in the base language [FS#6037] (r26642, r26640, r26639, r26632)
- 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)
1.4.1 (2014-06-02)
------------------------------------------------------------------------
- Fix: First send packages about new company, then clients joining it to admin port [FS#6025] (r26616)
1.4.1-RC2 (2014-05-18)
------------------------------------------------------------------------
- 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)
- 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)
1.4.1-RC1 (2014-05-04)
------------------------------------------------------------------------
- Change: Remove demand calculation based on tiles (r26484)
- Change: Use pkg-config for libpng as well (r26435, r26433, r26432)
- Change: Use better distance metric for link graph [FS#5941] (r26411)
- 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)
- 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)
- Fix: Allow single-vehicle consists to station-refit in a meaningful way (r26483)
- 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)
- Fix: Avoid division by 0 when scaling flow values [FS#5970] (r26448)
- Fix: Draw links to match _settings_game.vehicle.road_side [FS#5961] (r26445)
- Fix: Load button for heightmap list was missing [FS#5953] (r26428)
- 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)
1.4.0 (2014-04-01)
------------------------------------------------------------------------
(None)
1.4.0-RC1 (2014-03-18)
------------------------------------------------------------------------
- Feature: [Script] APIs to get cargo waiting from/via other station (r26396)
- Fix: Do not explain "symmetric" cargodist mode when the setting does not allow it [FS#5939] (r26394)
- Fix: Update distances between link graph nodes when station sign is moved (r26393)
- Fix: No need to call OnFocus twice [FS#5933] (r26392)
- Fix: Select a specific font size when freetype fails to select one automatically [FS#5885] (r26389)
- Fix: Return correct values from ICU iterators in case of leading or trailing whitespace [FS#5924] (r26384)
- Fix: All goal commands invalidated the goal list of company 0 [FS#5932] (r26382)
1.4.0-beta5 (2014-02-25)
------------------------------------------------------------------------
- Feature: Warn the user about empty setting search results, and about missing setting search results due to filtering (r26322, r26321)

View File

@@ -1441,6 +1441,7 @@ make_cflags_and_ldflags() {
make_compiler_cflags "$cc_host" "CFLAGS" "CXXFLAGS" "LDFLAGS" "FEATURES"
CFLAGS="$CFLAGS -D$os"
CFLAGS_BUILD="$CFLAGS_BUILD -D$os"
if [ "$enable_debug" = "0" ]; then
# No debug, add default stuff
@@ -1450,7 +1451,11 @@ make_cflags_and_ldflags() {
LDFLAGS="$LDFLAGS -noixemul"
fi
CFLAGS="-O2 -fomit-frame-pointer $CFLAGS"
if [ "$enable_profiling" = "0" ]; then
# -fomit-frame-pointer and -pg do not go well together (gcc errors they are incompatible)
CFLAGS="-fomit-frame-pointer $CFLAGS"
fi
CFLAGS="-O2 $CFLAGS"
else
OBJS_SUBDIR="debug"
@@ -1494,7 +1499,7 @@ make_cflags_and_ldflags() {
fi
if [ "$enable_profiling" != "0" ]; then
CFLAGS="$CFLAGS -p"
CFLAGS="$CFLAGS -pg"
LDFLAGS="$LDFLAGS -pg"
fi
@@ -1700,17 +1705,18 @@ make_cflags_and_ldflags() {
if [ -n "$png_config" ]; then
CFLAGS="$CFLAGS -DWITH_PNG"
CFLAGS="$CFLAGS `$png_config --cppflags --I_opts | tr '\n\r' ' '`"
CFLAGS="$CFLAGS `$png_config --cflags | tr '\n\r' ' '`"
# The extra flags are unneeded for latest libpng-config, but some versions are so broken...
if [ "$enable_static" != "0" ]; then
if [ "$os" = "OSX" ]; then
LIBS="$LIBS `$png_config --prefix`/lib/libpng.a"
# fontconfig_config goes via pkg-config on all systems, which doesn't know --prefix
# Also, despite the reason we link to the .a file ourself (because we can't use -static), we do need to ask pkg-config about possible other deps
LIBS="$LIBS `$png_config --variable=prefix`/lib/libpng.a `$png_config --libs --static | sed s@-lpng[0-9]*@@`"
else
LIBS="$LIBS `$png_config --static --ldflags | tr '\n\r' ' '`"
LIBS="$LIBS `$png_config --libs --static | tr '\n\r' ' '`"
fi
else
LIBS="$LIBS `$png_config --ldflags | tr '\n\r' ' '`"
LIBS="$LIBS `$png_config --libs | tr '\n\r' ' '`"
fi
fi
@@ -2715,80 +2721,64 @@ detect_libtimidity() {
detect_library "$with_libtimidity" "libtimidity" "libtimidity.a" "" "timidity.h"
}
detect_lzma() {
# 0 means no, 1 is auto-detect, 2 is force
if [ "$with_lzma" = "0" ]; then
log 1 "checking liblzma... disabled"
detect_pkg_config() {
# $1 - config-param ($with_lzma value)
# $2 - package name ('liblzma')
# $3 - config name ('lzma_config', sets $lzma_config)
# $4 - minimum module version ('2.3')
lzma_config=""
# 0 means no, 1 is auto-detect, 2 is force
if [ "$1" = "0" ]; then
log 1 "checking $2... disabled"
eval "$3=\"\""
return 0
fi
if [ "$with_lzma" = "1" ] || [ "$with_lzma" = "" ] || [ "$with_lzma" = "2" ]; then
lzma_config="pkg-config liblzma"
log 2 "detecting $2"
if [ "$1" = "1" ] || [ "$1" = "" ] || [ "$1" = "2" ]; then
pkg_config_call="pkg-config $2"
else
lzma_config="$with_lzma"
pkg_config_call="$1"
fi
version=`$lzma_config --modversion 2>/dev/null`
version=`$pkg_config_call --modversion 2>/dev/null`
ret=$?
log 2 "executing $lzma_config --modversion"
check_version "$4" "$version"
version_ok=$?
log 2 "executing $pkg_config_call --modversion"
log 2 " returned $version"
log 2 " exit code $ret"
if [ -z "$version" ] || [ "$ret" != "0" ]; then
log 1 "checking liblzma... not found"
if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version_ok" != "1" ]; then
if [ -n "$version" ] && [ "$version_ok" != "1" ]; then
log 1 "checking $2... needs at least version $4, $2 NOT enabled"
else
log 1 "checking $2... not found"
fi
# It was forced, so it should be found.
if [ "$with_lzma" != "1" ]; then
log 1 "configure: error: pkg-config liblzma couldn't be found"
log 1 "configure: error: you supplied '$with_lzma', but it seems invalid"
if [ "$1" != "1" ]; then
log 1 "configure: error: pkg-config $2 couldn't be found"
log 1 "configure: error: you supplied '$1', but it seems invalid"
exit 1
fi
lzma_config=""
eval "$3=\"\""
return 0
fi
log 1 "checking liblzma... found"
eval "$3=\"$pkg_config_call\""
log 1 "checking $2... found"
}
detect_lzma() {
detect_pkg_config "$with_lzma" "liblzma" "lzma_config" "5.0"
}
detect_xdg_basedir() {
# 0 means no, 1 is auto-detect, 2 is force
if [ "$with_xdg_basedir" = "0" ]; then
log 1 "checking libxdg_basedir... disabled"
xdg_basedir_config=""
return 0
fi
if [ "$with_xdg_basedir" = "1" ] || [ "$with_xdg_basedir" = "" ] || [ "$with_xdg_basedir" = "2" ]; then
xdg_basedir_config="pkg-config libxdg-basedir"
else
xdg_basedir_config="$with_xdg_basedir"
fi
version=`$xdg_basedir_config --modversion 2>/dev/null`
ret=$?
log 2 "executing $xdg_basedir_config --modversion"
log 2 " returned $version"
log 2 " exit code $ret"
if [ -z "$version" ] || [ "$ret" != "0" ]; then
log 1 "checking libxdg_basedir... not found"
# It was forced, so it should be found.
if [ "$with_xdg_basedir" != "1" ]; then
log 1 "configure: error: pkg-config libxdg_basedir couldn't be found"
log 1 "configure: error: you supplied '$with_xdg_basedir', but it seems invalid"
exit 1
fi
xdg_basedir_config=""
return 0
fi
log 1 "checking libxdg_basedir... found"
detect_pkg_config "$with_xdg_basedir" "libxdg-basedir" "xdg_basedir_config" "1.2"
}
detect_png() {
@@ -2815,33 +2805,7 @@ detect_png() {
return 0
fi
if [ "$with_png" = "1" ] || [ "$with_png" = "" ] || [ "$with_png" = "2" ]; then
png_config="libpng-config"
else
png_config="$with_png"
fi
version=`$png_config --version 2>/dev/null`
ret=$?
log 2 "executing $png_config --version"
log 2 " returned $version"
log 2 " exit code $ret"
if [ -z "$version" ] || [ "$ret" != "0" ]; then
log 1 "checking libpng... not found"
# It was forced, so it should be found.
if [ "$with_png" != "1" ]; then
log 1 "configure: error: libpng-config couldn't be found"
log 1 "configure: error: you supplied '$with_png', but it seems invalid"
exit 1
fi
png_config=""
return 0
fi
log 1 "checking libpng... found"
detect_pkg_config "$with_png" "libpng" "png_config" "1.2"
}
detect_freetype() {
@@ -2936,39 +2900,7 @@ detect_fontconfig() {
return 0
fi
if [ "$with_fontconfig" = "1" ] || [ "$with_fontconfig" = "" ] || [ "$with_fontconfig" = "2" ]; then
fontconfig_config="pkg-config fontconfig"
else
fontconfig_config="$with_fontconfig"
fi
version=`$fontconfig_config --modversion 2>/dev/null`
ret=$?
check_version '2.3' "$version"
version_ok=$?
log 2 "executing $fontconfig_config --modversion"
log 2 " returned $version"
log 2 " exit code $ret"
if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version_ok" != "1" ]; then
if [ -n "$version" ] && [ "$version_ok" != "1" ]; then
log 1 "checking libfontconfig... needs at least version 2.3.0, fontconfig NOT enabled"
else
log 1 "checking libfontconfig... not found"
fi
# It was forced, so it should be found.
if [ "$with_fontconfig" != "1" ]; then
log 1 "configure: error: fontconfig-config couldn't be found"
log 1 "configure: error: you supplied '$with_fontconfig', but it seems invalid"
exit 1
fi
fontconfig_config=""
return 0
fi
log 1 "checking libfontconfig... found"
detect_pkg_config "$with_fontconfig" "fontconfig" "fontconfig_config" "2.3"
}
detect_icu() {

View File

@@ -539,6 +539,7 @@
</tr>
</table>
</li>
<li>m3 bits 7..4: <a href="#OwnershipInfo">owner</a> of road type 1 (tram); OWNER_NONE (<tt>10</tt>) is stored as OWNER_TOWN (<tt>0F</tt>)
<li>m5 bits 7 clear: road or level-crossing
<ul>
<li>m6 bits 5..3:
@@ -573,7 +574,6 @@
</tr>
</table>
</li>
<li>m3 bits 7..4: <a href="#OwnershipInfo">owner</a> of road type 1 (tram); OWNER_NONE (<tt>10</tt>) is stored as OWNER_TOWN (<tt>0F</tt>)
<li>m5 bit 6 clear: road
<ul>
<li>m1 bits 4..0: <a href="#OwnershipInfo">owner</a> of the road type 0 (normal road)</li>
@@ -663,6 +663,7 @@
</tr>
</table>
</li>
<li>m7 bits 4..0: <a href="#OwnershipInfo">owner</a> of the road type 0 (normal road)</li>
</ul>
</li>
<li>m6 bits 7..6 : Possibility of a bridge above, in the <a href="#bridge_direction">direction specified</a></li>

View File

@@ -147,11 +147,11 @@ 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"><span class="free">OOOO 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">XX<span class="free">OO OO</span>XX</td>
<td class="bits">XX<span class="free">OO OO</span>XX</td>
<td class="bits">XXX<span class="free">O OOOO</span></td>
<td class="bits">XXX<span class="free">O</span> XXXX</td>
</tr>
<tr>
<td>3</td>

View File

@@ -1,6 +1,6 @@
OpenTTD's known bugs
Last updated: 2014-02-25
Release version: 1.4.0-beta5
Last updated: 2014-10-08
Release version: 1.4.4-RC1
------------------------------------------------------------------------
@@ -33,12 +33,13 @@ No suitable AI can be found
If you have no AIs and an AI is started the so-called 'dummy' AI will
be loaded. This AI does nothing but writing a message on the AI debug
window and showing a red warning. There are basically two solutions
for this problem: you must change the settings so no AI is started,
this is done in the difficulty settings window. The other solution is
acquiring (downloading) some AI. The easiest way to do this is via
the "Check Online Content" button in the main (intro) menu or via
"AI Settings" -> "Select AI" -> "Check Online Content" which is also
accessed via the main menu.
for this problem: Either you set the number of AI players to 0 so that
no AI is started. You find that setting at the top of the window in the
"AI / Game Scripts Settings" window.
The other solution is acquiring (downloading) some AI. The easiest way
to do this is via the "Check Online Content" button in the main (intro)
menu or directly in the "AI / Game Scripts Settings" dialogue via the
"Check Online Content" button.
After a while of playing, colours get corrupted
In Windows 7 the background slideshow corrupts the colour mapping of

View File

@@ -0,0 +1,32 @@
# $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/>.
BEGIN {
# Very basic variant function; barely any error checking.
# Just use the first argument as the file to start from when assembling everything
path = ARGV[1];
gsub("[^/\\\\]*$", "", path);
assemble(ARGV[1]);
}
# Recursive function for assembling by means of resolving the #includes.
function assemble(filename) {
while ((getline < filename) > 0) {
if (NF == 2 && $1 == "#include" ) {
# Remove the quotes.
gsub("[\"'<>]", "", $2);
assemble(path $2);
} else {
print $0;
}
}
if (close(filename) < 0) {
print "Could not open " filename > "/dev/stderr";
exit -1;
}
}

View File

@@ -1,3 +1,75 @@
openttd (1.4.4~RC1-0) unstable; urgency=low
* New upstream release 1.4.4-RC1
-- OpenTTD <info@openttd.org> Wed, 08 Oct 2014 19:00:00 +0200
openttd (1.4.3-0) unstable; urgency=low
* New upstream release 1.4.3
-- OpenTTD <info@openttd.org> Tue, 23 Sep 2014 21:00:00 +0200
openttd (1.4.3~RC2-0) unstable; urgency=low
* New upstream release 1.4.3-RC2
-- OpenTTD <info@openttd.org> Sun, 14 Sep 2014 19:00:00 +0200
openttd (1.4.3~RC1-0) unstable; urgency=low
* New upstream release 1.4.3-RC1
-- OpenTTD <info@openttd.org> Sun, 07 Sep 2014 19:00:00 +0200
openttd (1.4.2-0) unstable; urgency=low
* New upstream release 1.4.2
-- OpenTTD <info@openttd.org> Sat, 16 Aug 2014 21:00:00 +0200
openttd (1.4.2~RC2-0) unstable; urgency=low
* New upstream release 1.4.2-RC2
-- OpenTTD <info@openttd.org> Sun, 03 Aug 2014 18:00:00 +0200
openttd (1.4.2~RC1-0) unstable; urgency=low
* New upstream release 1.4.2-RC1
-- OpenTTD <info@openttd.org> Thu, 03 Jul 2014 21:00:00 +0200
openttd (1.4.1-0) unstable; urgency=low
* New upstream release 1.4.1
-- OpenTTD <info@openttd.org> Mon, 02 Jun 2014 21:00:00 +0200
openttd (1.4.1~RC2-0) unstable; urgency=low
* New upstream release 1.4.1-RC2
-- OpenTTD <info@openttd.org> Sun, 18 May 2014 21:00:00 +0200
openttd (1.4.1~RC1-0) unstable; urgency=low
* New upstream release 1.4.1-RC1
-- OpenTTD <info@openttd.org> Sun, 04 May 2014 21:00:00 +0200
openttd (1.4.0-0) unstable; urgency=low
* New upstream release 1.4.0
-- OpenTTD <info@openttd.org> Tue, 01 Apr 2014 21:00:00 +0200
openttd (1.4.0~RC1-0) unstable; urgency=low
* New upstream release 1.4.0-RC1
-- OpenTTD <info@openttd.org> Tue, 17 Mar 2014 21:00:00 +0100
openttd (1.4.0~beta5-0) unstable; urgency=low
* New upstream release 1.4.0-beta5

View File

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

View File

@@ -950,13 +950,7 @@
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqpcheader.h" />
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqstate.h" />
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdaux.h" />
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdblob.h" />
<ClInclude Include="..\src\3rdparty\squirrel\sqstdlib\sqstdblobimpl.h" />
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdio.h" />
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdmath.h" />
<ClInclude Include="..\src\3rdparty\squirrel\sqstdlib\sqstdstream.h" />
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdstring.h" />
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdsystem.h" />
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqstring.h" />
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqtable.h" />
<ClInclude Include="..\src\3rdparty\squirrel\include\squirrel.h" />

View File

@@ -2079,27 +2079,9 @@
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdaux.h">
<Filter>Squirrel headers</Filter>
</ClInclude>
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdblob.h">
<Filter>Squirrel headers</Filter>
</ClInclude>
<ClInclude Include="..\src\3rdparty\squirrel\sqstdlib\sqstdblobimpl.h">
<Filter>Squirrel headers</Filter>
</ClInclude>
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdio.h">
<Filter>Squirrel headers</Filter>
</ClInclude>
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdmath.h">
<Filter>Squirrel headers</Filter>
</ClInclude>
<ClInclude Include="..\src\3rdparty\squirrel\sqstdlib\sqstdstream.h">
<Filter>Squirrel headers</Filter>
</ClInclude>
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdstring.h">
<Filter>Squirrel headers</Filter>
</ClInclude>
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdsystem.h">
<Filter>Squirrel headers</Filter>
</ClInclude>
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqstring.h">
<Filter>Squirrel headers</Filter>
</ClInclude>

View File

@@ -3114,34 +3114,10 @@
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdaux.h"
>
</File>
<File
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdblob.h"
>
</File>
<File
RelativePath=".\..\src\3rdparty\squirrel\sqstdlib\sqstdblobimpl.h"
>
</File>
<File
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdio.h"
>
</File>
<File
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdmath.h"
>
</File>
<File
RelativePath=".\..\src\3rdparty\squirrel\sqstdlib\sqstdstream.h"
>
</File>
<File
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdstring.h"
>
</File>
<File
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdsystem.h"
>
</File>
<File
RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqstring.h"
>

View File

@@ -3111,34 +3111,10 @@
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdaux.h"
>
</File>
<File
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdblob.h"
>
</File>
<File
RelativePath=".\..\src\3rdparty\squirrel\sqstdlib\sqstdblobimpl.h"
>
</File>
<File
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdio.h"
>
</File>
<File
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdmath.h"
>
</File>
<File
RelativePath=".\..\src\3rdparty\squirrel\sqstdlib\sqstdstream.h"
>
</File>
<File
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdstring.h"
>
</File>
<File
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdsystem.h"
>
</File>
<File
RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqstring.h"
>

View File

@@ -1,5 +1,5 @@
Last updated: 2014-02-25
Release version: 1.4.0-beta5
Last updated: 2014-10-08
Release version: 1.4.4-RC1
------------------------------------------------------------------------
@@ -674,46 +674,47 @@ http://homer.rice.edu/~sandmann/cwsdpmi/csdpmi5s.zip
X.X) Credits
---- -------
The OpenTTD team (in alphabetical order):
Albert Hofkamp (Alberth) - GUI expert
Jean-François Claeys (Belugas) - GUI, newindustries and more
Matthijs Kooijman (blathijs) - Pathfinder-guru, pool rework
Ulf Hermann (fonsinchen) - Cargo Distribution
Christoph Elsenhans (frosch) - General coding
Loïc Guilloux (glx) - Windows Expert
Michael Lutz (michi_cc) - Path based signals
Owen Rudge (orudge) - Forum host, OS/2 port
Peter Nelson (peter1138) - Spiritual descendant from newGRF gods
Ingo von Borstel (planetmaker) - Support
Remko Bijker (Rubidium) - Lead coder and way more
Zdeněk Sojka (SmatZ) - Bug finder and fixer
José Soler (Terkhen) - General coding
Thijs Marinussen (Yexo) - AI Framework
Leif Linse (Zuu) - AI/Game Script
Albert Hofkamp (Alberth) - GUI expert (since 0.7)
Matthijs Kooijman (blathijs) - Pathfinder-guru, Debian port (since 0.3)
Ulf Hermann (fonsinchen) - Cargo Distribution (since 1.3)
Christoph Elsenhans (frosch) - General coding (since 0.6)
Loïc Guilloux (glx) - Windows Expert (since 0.4.5)
Michael Lutz (michi_cc) - Path based signals (since 0.7)
Owen Rudge (orudge) - Forum host, OS/2 port (since 0.1)
Peter Nelson (peter1138) - Spiritual descendant from newGRF gods (since 0.4.5)
Ingo von Borstel (planetmaker) - General coding, Support (since 1.1)
Remko Bijker (Rubidium) - Lead coder and way more (since 0.4.5)
José Soler (Terkhen) - General coding (since 1.0)
Leif Linse (Zuu) - AI/Game Script (since 1.2)
Inactive Developers:
Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles
Victor Fischer (Celestar) - Programming everywhere you need him to
Tamás Faragó (Darkvater) - Ex-Lead coder
Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;)
Jonathan Coome (Maedhros) - High priest of the NewGRF Temple
Attila Bán (MiHaMiX) - WebTranslator 1 and 2
Christoph Mallon (Tron) - Programmer, code correctness police
Jean-François Claeys (Belugas) - GUI, newindustries and more (0.4.5 - 1.0)
Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles (0.3 - 0.7)
Victor Fischer (Celestar) - Programming everywhere you need him to (0.3 - 0.6)
Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;) (0.4.5 - 0.6)
Jonathan Coome (Maedhros) - High priest of the NewGRF Temple (0.5 - 0.6)
Attila Bán (MiHaMiX) - WebTranslator 1 and 2 (0.3 - 0.5)
Zdeněk Sojka (SmatZ) - Bug finder and fixer (0.6 - 1.3)
Christoph Mallon (Tron) - Programmer, code correctness police (0.3 - 0.5)
Patric Stout (TrueBrain) - NoProgrammer (0.3 - 1.2), sys op (active)
Thijs Marinussen (Yexo) - AI Framework, General (0.6 - 1.3)
Retired Developers:
Ludvig Strigeus (ludde) - OpenTTD author, main coder (0.1 - 0.3.3)
Serge Paquet (vurlix) - Assistant project manager, coder (0.1 - 0.3.3)
Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3.0 - 0.3.6)
Benedikt Brüggemeier (skidd13) - Bug fixer and code reworker
Patric Stout (TrueBrain) - NoProgrammer (0.3 - 1.2), sys op (active)
Tamás Faragó (Darkvater) - Ex-Lead coder (0.3 - 0.5)
Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3 - 0.3)
Emil Djupfeld (egladil) - MacOSX port (0.4 - 0.6)
Simon Sasburg (HackyKid) - Bug fixer (0.4 - 0.4.5)
Ludvig Strigeus (ludde) - Original author of OpenTTD, main coder (0.1 - 0.3)
Cian Duffy (MYOB) - BeOS port / manual writing (0.1 - 0.3)
Petr Baudiš (pasky) - Many patches, newgrf support, etc. (0.3 - 0.3)
Benedikt Brüggemeier (skidd13) - Bug fixer and code reworker (0.6 - 0.7)
Serge Paquet (vurlix) - 2nd contributor after ludde (0.1 - 0.3)
Thanks to:
Josef Drexler - For his great work on TTDPatch.
Marcin Grzegorczyk - For his TTDPatch work and documentation of Transport Tycoon Deluxe internals and track foundations
Petr Baudiš (pasky) - Many patches, newgrf support, etc.
Simon Sasburg (HackyKid) - For the many bugfixes he has blessed us with
Stefan Meißner (sign_de) - For his work on the console
Mike Ragsdale - OpenTTD installer
Cian Duffy (MYOB) - BeOS port / manual writing
Christian Rosentreter (tokai) - MorphOS / AmigaOS port
Richard Kempton (RichK67) - Additional airports, initial TGP implementation
Alberto Demichelis - Squirrel scripting language
@@ -722,6 +723,7 @@ Thanks to:
George - Canal graphics
Andrew Parkhouse (andythenorth) - River graphics
David Dallaston (Pikka) - Tram tracks
Fleashosio - Titlegame
All Translators - For their support to make OpenTTD a truly international game
Bug Reporters - Thanks for all bug reports
Chris Sawyer - For an amazing game!

View File

@@ -720,13 +720,7 @@ script/squirrel_std.hpp
3rdparty/squirrel/squirrel/sqpcheader.h
3rdparty/squirrel/squirrel/sqstate.h
3rdparty/squirrel/include/sqstdaux.h
3rdparty/squirrel/include/sqstdblob.h
3rdparty/squirrel/sqstdlib/sqstdblobimpl.h
3rdparty/squirrel/include/sqstdio.h
3rdparty/squirrel/include/sqstdmath.h
3rdparty/squirrel/sqstdlib/sqstdstream.h
3rdparty/squirrel/include/sqstdstring.h
3rdparty/squirrel/include/sqstdsystem.h
3rdparty/squirrel/squirrel/sqstring.h
3rdparty/squirrel/squirrel/sqtable.h
3rdparty/squirrel/include/squirrel.h

View File

@@ -1,41 +0,0 @@
Squirrel 2.2.4 stable
--------------------------------------------------------
What is in this distribution?
squirrel
static library implementing the compiler and interpreter of the language
sqstdlib
the standard utility libraries
sq
stand alone interpreter
doc
The manual
etc
a minimalistic embedding sample
samples
samples programs
HOW TO COMPILE
---------------------------------------------------------
GCC USERS
.........................................................
There is a very simple makefile that compiles all libraries and exes
from the root of the project run 'make'
for 32 bits systems
$ make
for 64 bits systems
$ make sq64
VISUAL C++ USERS
.........................................................
Open squirrel.dsw from the root project directory and build(dho!)

View File

@@ -1,357 +0,0 @@
***version 2.2.5 stable***
-sq_getsize() now returns userdatasize for classes and instances
-added parameter 'isstatic' to _newmember metamethod(thx G.Meyer)
-now array.sort() is implemented with heapsort
-added SQUIRREL_VERSION_NUMBER preprocessor definition
-now floats in scientific notation also accept numbers with no '.' (eg. 1e+6 or 1e6)
-fixed some compiler warning
-fixed a minor compiler bug
-fixed some bugs when SQUSEDOUBLE is used in 32bits systems
-fixed bug in GC
***2009-11-15 ***
***version 2.2.4 stable***
-fixed bug in functions with default parameters
***2009-06-30 ***
***version 2.2.3 stable***
-added sq_getfunctioninfo
-added compile time flag SQUSEDOUBLE to use double precision floats
-added global slot _floatsize_ int the base lib to recognize single precision and double precision builds
-sq_wakeupvm can now resume the vm with an exception
-added sqstd_format
-generators can now be instantiated by calling sq_call() or closure.call()
-fixed a bug in sqstd_printcallstack(thx takayuki_h)
-fixed modulo by zero(thx jup)
-fixed negative enums and constants
-fixed generator crash bug if invoked as tail call (thx Mr.Accident)
-fixed some minor bug
***2008-09-24 ***
***version 2.2.2 stable***
-fixed some behaviour inconsistencies in thread.call() and thread.wakeup() (thx Mr.Accident)
-fixed coroutine error propagation
-fixed lingering return value from native function (thx Tom Leonard)
-fixed a bug if array.sort() is given a bad sort function (thx Tom Leonard)
-fixed some minor api bug
-added sq_arrayremove() and sq_arrayinsert()
***2008-05-16 ***
***version 2.2.1 stable***
-fixed a tailcall bug
***2008-02-17 ***
***version 2.2 stable ***
-added _newslot metamethod in classes
-added enums added constants
-added sq_pushconsttable, sq_setconsttable
-added default param
-added octal literals(thx Dinosaur)
-fixed debug hook, 'calls' and 'returns' are properly notified in the same number.
-fixed a coroutine bug
***2007-07-29 ***
***version 2.1.2 stable***
-new behaviour for generators iteration using foreach
now when a generator is iterated by foreach the value returned by a 'return val' statement
will terminate the iteration but will not be returned as foreach iteration
-added sq_setclassudsize()
-added sq_clear()
-added table.clear(), array.clear()
-fixed sq_cmp() (thx jyuill)
-fixed minor bugs
***2006-08-21 ***
***version 2.1.1 stable***
-vm refactoring
-optimized internal function memory layout
-new global symbol _version_ (is the version string)
-code size optimization for float literals(on 32bits float builts)
-now the raw ref API(sq_addref etc...) is fully reentrant.
-fixed a bug in sq_getdelegate() now pushes null if the object doesn't have a delegate(thx MatzeB)
-improved C reference performances in NO_GARBAGE_COLLECTOR builds
-sq_getlocal() now enumerates also outer values.
-fixed regexp library for GCC users.
***2006-03-19 ***
***version 2.1 stable***
-added static class fields, new keyword static
-added 64bits architecture support
-added global slot _intsize_ int the base lib to recognize 32bits and 64bits builds
-added functions with fixed environment, closure.bindenv() built-in function
-all types except userdata and null implement the tostring() method
-string concatenation now invokes metamethod _tostring
-new metamethods for class objects _newmember and _inherited
-sq_call() sq_resume() sq_wakeupvm() have a new signature
-new C referencing implementation(scales more with the amount of references)
-refactored hash table
-new api functions sq_newslot(),sq_tobool(),sq_getbase(), sq_instanceof(), sq_bindenv()
-the api func sq_createslot was deprecated but still supported in form of C macro on top of sq_newslot
-sq_setreleasehook() now also works for classes
-stream.readstr() and stream.writestr() have been deprecated(this affects file and blob)
-fixed squirrel.h undeclared api calls
-fixed few minor bugs
-SQChar is now defined as wchar_t
-removed warning when building with -Wall -pedantic for GCC users
-added new std io function writeclosuretofile()
-added new std string functions strip(),rstrip(),lstrip() and split()
-regular expressions operators (+,*) now have more POSIX greedyness behaviour
-class constructors are now invoked as normal functions
***2005-10-02 ***
***version 2.0.5 stable***
-fixed some 64bits incompatibilities (thx sarge)
-fixed minor bug in the stdlib format() function (thx Rick)
-fixed a bug in dofile() that was preventing to compile empty files
-added new API sq_poptop() & sq_getfreevariable()
-some performance improvements
***2005-08-14 ***
***version 2.0.4 stable***
-weak references and related API calls
-added sq_objtobool()
-class instances memory policies improved(1 mem allocation for the whole instance)
-typetags are now declared as SQUserPointer instead of unsigned int
-first pass for 64bits compatibility
-fixed minor bug in the stdio stream
-fixed a bug in format()
-fixed bug in string.tointeger() and string.tofloat()
***2005-06-24 ***
***version 2.0.3 stable***
-dofile() and loadfile() in the iolib now can decode ASCII, UTF8 files UCS2 big-endian and little-endian
-sq_setparamscheck() : now typemesk can check for null
-added string escape sequence \xhhhh
-fixed some C++ standard incompatibilities
***2005-05-15 ***
***version 2.0.2 stable***
-performances improvements (expecially for GCC users)
-removed all dependencies from C++ exception handling
-various bugfixes
***2005-04-12 ***
***version 2.0.1 stable***
-various bugfixes
-sq_setparamscheck() now allows spaces in the typemask
***2005-04-03 ***
***version 2.0 stable***
-added API sq_gettypetag()
-added built-in function to the bool type(tointeger, tostring etc...)
***2005-02-27 ***
***version 2.0 release candidate 1(RC 1)***
-added API sq_reseterror()
-modified sq_release()
-now class instances can be cloned
-various bufixes
***2005-01-26 ***
***version 2.0 beta 1***
-added bool type
-class properties can be redefined in a derived class
-added ops *= /= and %=
-new syntax for class attributes declaration </ and /> instead of ( and )
-increased the max number of literals per function from 65535 to 16777215
-now free variables have proper lexical scoping
-added API sq_createinstance(), sq_pushbool(), sq_getbool()
-added built-in function type()
-added built-in function obj.rawin(key) in table,class and instance
-sq_rawget() and sq_rawset() now work also on classes and instances
-the VM no longer uses C++ exception handling (more suitable for embedded devices)
-various bufixes
***2004-12-21 ***
***version 2.0 alpha 2***
-globals scoping changed, now if :: is omitted the VM automatically falls back on the root table
-various bufixes
-added class level attributes
***2004-12-12 ***
***version 2.0 alpha 1***
-codebase branch from version 1.x
-added classes
-added functions with variable number of parameters(vargc & vargv and the ...)
-0 and 0.0 are now considered 'false' by all conditional statements(if,while,for,?,do-while)
-added new api functions sq_newclass() sq_setinstanceup() sq_getinstanceup() sq_getattributes() sq_setattributes()
-modified api sq_settypetag()
***2004-11-01 ***
***version 1.0 stable***
-fixed some minor bug
-improoved operator 'delete' performances
-added scientific notation for float numbers( eg. 2.e16 or 2.e-2)
***2004-08-30 ***
***version 1.0 release candidate 2(RC 2)***
-fixed bug in the vm(thx Pierre Renaux)
-fixed bug in the optimizer(thx Pierre Renaux)
-fixed some bug in the documentation(thx JD)
-added new api functions for raw object handling
-removed nested multiline comments
-reduced memory footprint in C references
***2004-08-23 ***
***version 1.0 release candidate 1(RC 1)***
-fixed division by zero
-the 'in' operator and obj.rawget() do not query the default delegate anymore
-added function sq_getprintfunc()
-added new standard library 'auxlib'(implements default error handlers)
***2004-07-12 ***
***version 1.0 beta 4***
-fixed a bug in the integer.tochar() built-in method
-fixed unary minus operator
-fixed bug in dofile()
-fixed inconsistency between != and == operators(on float/integer comparison)
-added javascript style unsigned right shift operator '>>>'
-added array(size) constructor built-in function
-array.resize(size,[fill]) built-in function accepts an optional 'fill' value
-improved debug API, added sq_getclosureinfo() and sq_setnativeclosurename()
***2004-05-23 ***
***version 1.0 beta 3***
-minor vm bug fixes
-string allocation is now faster
-tables and array memory usage is now less conservative(they shrink)
-added regular expression routines in the standard library
-The 'c' expression now accepts only 1 character(thx irbrian)
-multiline strings <[ ]> have been substituted with C# style verbatim strings (eg. @"string")
-added new keyword 'parent' for accessing the delegate of tables and unserdata
-The metamethod '_clone' has been renamed '_cloned'
-the _delslot metamethod's behaviour and prototype have been changed
-new default function in the integer and float object 'tochar()'
-the built-in function chcode2string has been removed
-the default method [table].getdelegate() has been removed
-new api sq_rawdeleteslot()
-new table built-in method rawdelete(key)
-the dynamic mudule loading has been removed from the standard distribution
-some optimizations in the VM
***2004-04-21 ***
***version 1.0 beta 2***
-minor compiler/parser bug fixes
-sq_newclosure has a different prototype, the "paramscheck" of paramter has been moved to the new function sq_setparamscheck()
-sq_setparamscheck allows to add automatic parameters type checking in native closures
-sq_compile() lost the lineinfo parameter
-new api sq_enabledebuginfo() globally sets compiler's debug info generation
-added consistency check on bytecode serialization
-fixed += operator, now works on strings like +
-added global slot in the base lib _charsize_ to recognize unicode builds from ascii builds runtime
-added registry table
-new api call sq_pushregistrytable()
-added type tag to the userdata type sq_settypetag()
-sq_getuserdata now queries the userdata typetag
-the built in function collect_garbage() as been renamed collectgarbage() for consistency reasons
-new standard libraries(sqlibs are now obsolete)
***2004-02-20 ***
***version 1.0 beta 1***
-fixed a bug in the compiler (thanks Martin Kofler)
-fixed bug in the switch case statement
-fixed the _unm metamethod
-fixed minor bugs in the API
-fixed automatic stack resizing
-first beta version
first pass code clean up in the VM and base lib
first pass code coverege test has been done on VM and built-in lib
-new VM creation API sq_open() sq_close() (sq_newvm and sq_releasevm are now obsolete)
-new api allows to specifiy a "print" function to output text(sq_printfunc)
-added some small optimizations
-new cooperative multi-threading capabilities in the base library(coroutines), VMs are now a built in type("thread")
-new built in functions have been added for manipulating the new "thread" type
-friend virtual machines share the same root table, error handler and debug hook by default
-new compile time options
***2004-01-19 ***
***version 0.9 alpha***
-fixed a garbage collection bug
-fixed some API bugs(thanks to Joshua Jensen)
-fixed tail calls (in the version 0.8 the tail call optimization was erroneously disabled)
-new function parameters semantic, now passing a wrong number of parameters generates an exception
-native closures have now a built in parameter number checking
-sq_rawget and sq_rawset now work also on arrays
-sq_getsize now woks also on userdata
-the userdata release hook prototype is changed(now passes the size of the userdata)
-the lexer reader function now returns an integer instead of a char that allows better error checking on the input(thx Joshua Jensen)
-faster compiler
-try/catch blocks do not cause any runtime memory allocation anymore
***2003-12-06 ***
***version 0.8 alpha***
-fixed a bug that was preventing to have callable userdata throught the metamethod _call
-fixed a garbage collection bug
-fixed == operator now can compare correctly different types
-new built in method getstackinfos(level)
-improoved line informations precision for the debug hook
-new api call sq_compilebuffer()
-new built-in api function compilestring()
-new syntactic sugar for function declarations inside tables
-the debug API has been finalized
***2003-11-17 ***
***version 0.7 alpha***
-fixed critical bug SQInteger the tail call system
-fixed bug in the continue statement code generation
-fixed func call param issue(thanks to Rewoonenco Andrew)
-added _delslot metamethod(thanks to Rewoonenco Andrew)
-new multiline string expression ( delimited by <[ and ]> )
-normal strings ("") do not allow embedded new line anymore
-reduced vm memory footprint(C refs are shared between friend VMs)
-new api method sq_deleteslot()
-new debug hook event 'r' is triggered when a function returns
***2003-11-04 ***
***version 0.6 alpha***
-fixed switch statement(was executing the default case after a break)
-sq_call() doesn't pop the closure (just the params)
-the vm execution can be suspended from the C API anytime (micro-threads)
-new api calls sq_suspendvm() sq_wakeupvm() sq_getvmstate() and sq_reservestack()
***2003-10-13 ***
***version 0.5 alpha***
-fixed some minor bug
-tested with non ASCII identifiers in unicode mode(I've tried chinese chars)
-added built-in function string.find()
-the built-in function array.sort() optionally accepts a cmp(a,b) function
-the debug hook function now has a new prototype debug_hook(event_type,sourcefile,line,functionname)
-fixed some debug info imprecision
***2003-10-01 ***
***version 0.4 alpha***
-faster VM
-sq_call will pop arguments and closure also in case of failure
-fixed a bug in sq_remove
-now the VM detects delegation cycles(and throws an exception)
-new operators ++ and --
-new operator ',' comma operator
-fixed some expression precedence issue
-fixed bug in sq_arraypop
***2003-09-15 ***
***version 0.3 alpha***
-fixed a bug in array::insert()
-optional Unicode core(define SQUNICODE or _UNICODE on Win32)
-sq_compiler uses a new reader function SQLEXREADFUNC
-the debug hook passes 'l' instead of 'line' for line callbacks
and 'c' instead of 'call' for call callbacks
-new array.extend() bulit-in function
-new API sq_clone()
***2003-09-10 ***
***version 0.2 pre-alpha***
-new completely reentrant VM (sq_open and sq_close are now obsolete)
-sq_newvm() has a new prototype
-allocators are now global and linked in the VM
-_newslot meta method added
-rawset creates a slot if doesn't exists
-the compiler error callback pass the vm handle(thanks Pierre Renaux)
-sq_setforeignptr() sq_getforeingptr() are now public
-sq_resume() now is possible to resume generators from C
-sq_getlasterror() retrieve the last thrown error
-improved docs
***2003-09-06 ***
***version 0.1 pre-alpha***
first release

View File

@@ -1,23 +0,0 @@
SQUIRREL=.
MAKE=make
sq32:
cd squirrel; $(MAKE)
cd sqstdlib; $(MAKE)
cd sq; $(MAKE)
sqprof:
cd squirrel; $(MAKE) sqprof
cd sqstdlib; $(MAKE) sqprof
cd sq; $(MAKE) sqprof
sq64:
cd squirrel; $(MAKE) sq64
cd sqstdlib; $(MAKE) sq64
cd sq; $(MAKE) sq64
clean:
$(MAKE) -C squirrel clean
$(MAKE) -C sqstdlib clean
$(MAKE) -C sq clean

View File

@@ -1,22 +0,0 @@
The programming language SQUIRREL 2.2.5 stable
--------------------------------------------------
The project has been compiled and run on Windows(Windows XP/2000 on Intel x86 Windows XP Pro on AMD x64) and
Linux(Slackware 9.0 on Intel x86, Fedora Core 4 on AMD x64).
Has been tested with the following compilers:
MS Visual C++ 6.0,7.0,7.1 and 8.0 (32 and 64bits)
MinGW gcc 3.2 (mingw special 20020817-1)
Cygnus gcc 3.2
Linux gcc 3.2.3
Linux gcc 4.0.0 (x86 64bits)
Feedback and suggestions are appreciated
project page - http://www.squirrel-lang.org
community forums - http://www.squirrel-lang.org/Forums
wiki - http://wiki.squirrel-lang.org
author - alberto@demichelis.net
END OF README

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -1,63 +0,0 @@
#include <stdarg.h>
#include <stdio.h>
#include <squirrel.h>
#include <sqstdio.h>
#include <sqstdaux.h>
#ifdef _MSC_VER
#pragma comment (lib ,"squirrel.lib")
#pragma comment (lib ,"sqstdlib.lib")
#endif
#ifdef SQUNICODE
#define scvprintf vwprintf
#else
#define scvprintf vprintf
#endif
void printfunc(HSQUIRRELVM v, const SQChar *s, ...)
{
va_list arglist;
va_start(arglist, s);
scvprintf(s, arglist);
va_end(arglist);
}
void call_foo(HSQUIRRELVM v, int n,float f,const SQChar *s)
{
SQInteger top = sq_gettop(v); //saves the stack size before the call
sq_pushroottable(v); //pushes the global table
sq_pushstring(v,_SC("foo"),-1);
if(SQ_SUCCEEDED(sq_get(v,-2))) { //gets the field 'foo' from the global table
sq_pushroottable(v); //push the 'this' (in this case is the global table)
sq_pushinteger(v,n);
sq_pushfloat(v,f);
sq_pushstring(v,s,-1);
sq_call(v,4,SQFalse,SQTrue); //calls the function
}
sq_settop(v,top); //restores the original stack size
}
int main(int argc, char* argv[])
{
HSQUIRRELVM v;
v = sq_open(1024); // creates a VM with initial stack size 1024
//sq_pushroottable(v); //push the root table were to register the lib function
//sqstd_register_iolib(v);
sqstd_seterrorhandlers(v); //registers the default error handlers
sq_setprintfunc(v, printfunc); //sets the print function
sq_pushroottable(v); //push the root table(were the globals of the script will be stored)
if(SQ_SUCCEEDED(sqstd_dofile(v, _SC("test.nut"), SQFalse, SQTrue))) // also prints syntax errors if any
{
call_foo(v,1,2.5,_SC("teststring"));
}
sq_pop(v,1); //pops the root table
sq_close(v);
return 0;
}

View File

@@ -1,4 +0,0 @@
function foo(i, f, s)
{
print("Called foo(), i="+i+", f="+f+", s='"+s+"'\n");
}

View File

@@ -1,20 +0,0 @@
/* see copyright notice in squirrel.h */
#ifndef _SQSTDBLOB_H_
#define _SQSTDBLOB_H_
#ifdef __cplusplus
extern "C" {
#endif
SQUIRREL_API SQUserPointer sqstd_createblob(HSQUIRRELVM v, SQInteger size);
SQUIRREL_API SQRESULT sqstd_getblob(HSQUIRRELVM v,SQInteger idx,SQUserPointer *ptr);
SQUIRREL_API SQInteger sqstd_getblobsize(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sqstd_register_bloblib(HSQUIRRELVM v);
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*_SQSTDBLOB_H_*/

View File

@@ -1,54 +0,0 @@
/* see copyright notice in squirrel.h */
#ifndef _SQSTDIO_H_
#define _SQSTDIO_H_
#ifdef __cplusplus
#define SQSTD_STREAM_TYPE_TAG 0x80000000
struct SQStream {
virtual ~SQStream() {}
virtual SQInteger Read(void *buffer, SQInteger size) = 0;
virtual SQInteger Write(void *buffer, SQInteger size) = 0;
virtual SQInteger Flush() = 0;
virtual SQInteger Tell() = 0;
virtual SQInteger Len() = 0;
virtual SQInteger Seek(SQInteger offset, SQInteger origin) = 0;
virtual bool IsValid() = 0;
virtual bool EOS() = 0;
};
extern "C" {
#endif
#define SQ_SEEK_CUR 0
#define SQ_SEEK_END 1
#define SQ_SEEK_SET 2
typedef void* SQFILE;
SQUIRREL_API SQFILE sqstd_fopen(const SQChar *,const SQChar *);
SQUIRREL_API SQInteger sqstd_fread(SQUserPointer, SQInteger, SQInteger, SQFILE);
SQUIRREL_API SQInteger sqstd_fwrite(const SQUserPointer, SQInteger, SQInteger, SQFILE);
SQUIRREL_API SQInteger sqstd_fseek(SQFILE , SQInteger , SQInteger);
SQUIRREL_API SQInteger sqstd_ftell(SQFILE);
SQUIRREL_API SQInteger sqstd_fflush(SQFILE);
SQUIRREL_API SQInteger sqstd_fclose(SQFILE);
SQUIRREL_API SQInteger sqstd_feof(SQFILE);
SQUIRREL_API SQRESULT sqstd_createfile(HSQUIRRELVM v, SQFILE file,SQBool own);
SQUIRREL_API SQRESULT sqstd_getfile(HSQUIRRELVM v, SQInteger idx, SQFILE *file);
//compiler helpers
SQUIRREL_API SQRESULT sqstd_loadfile(HSQUIRRELVM v,const SQChar *filename,SQBool printerror);
SQUIRREL_API SQRESULT sqstd_dofile(HSQUIRRELVM v,const SQChar *filename,SQBool retval,SQBool printerror);
SQUIRREL_API SQRESULT sqstd_writeclosuretofile(HSQUIRRELVM v,const SQChar *filename);
SQUIRREL_API SQRESULT sqstd_register_iolib(HSQUIRRELVM v);
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*_SQSTDIO_H_*/

View File

@@ -1,15 +0,0 @@
/* see copyright notice in squirrel.h */
#ifndef _SQSTD_SYSTEMLIB_H_
#define _SQSTD_SYSTEMLIB_H_
#ifdef __cplusplus
extern "C" {
#endif
SQUIRREL_API SQInteger sqstd_register_systemlib(HSQUIRRELVM v);
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /* _SQSTD_SYSTEMLIB_H_ */

View File

@@ -1,23 +0,0 @@
/*
*
* Original Javascript version by David Hedbor(http://www.bagley.org/~doug/shootout/)
*
*/
function Ack(M, N) {
if (M == 0) return( N + 1 );
if (N == 0) return( Ack(M - 1, 1) );
return( Ack(M - 1, Ack(M, (N - 1))) );
}
local n;
if(ARGS.len()!=0) {
n = ARGS[0].tointeger();
if(n < 1) n = 1;
} else {
n = 1;
}
print("n="+n+"\n");
print("Ack(3,"+ n+ "):"+ Ack(3, n));

View File

@@ -1,28 +0,0 @@
/*
*
* Original Javascript version by David Hedbor(http://www.bagley.org/~doug/shootout/)
*
*/
local n, i, k;
if(ARGS.len()!=0) {
n = ARGS[0].tointeger();
if(n < 1) n = 1;
} else {
n = 1;
}
local x = []; x.resize(n);
local y = []; y.resize(n);
for (i = 0; i < n; i+=1) {
x[i] = i + 1;
y[i] = 0;
}
for (k = 0 ; k < n; k+=1) {
for (i = n-1; i >= 0; i-=1) {
y[i] = y[i]+ x[i];
}
}
print(y[0].tostring()+" "+y[n-1]);

View File

@@ -1,49 +0,0 @@
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
class BaseVector {
constructor(...)
{
if(vargc >= 3) {
x = vargv[0];
y = vargv[1];
z = vargv[2];
}
}
x = 0;
y = 0;
z = 0;
}
class Vector3 extends BaseVector {
function _add(other)
{
if(other instanceof this.getclass())
return ::Vector3(x+other.x,y+other.y,z+other.z);
else
throw "wrong parameter";
}
function Print()
{
::print(x+","+y+","+z+"\n");
}
}
local v0 = Vector3(1,2,3)
local v1 = Vector3(11,12,13)
local v2 = v0 + v1;
v2.Print();
FakeNamespace <- {
Utils = {}
}
class FakeNamespace.Utils.SuperClass {
constructor()
{
::print("FakeNamespace.Utils.SuperClass")
}
}
local testy = FakeNamespace.Utils.SuperClass();

View File

@@ -1,35 +0,0 @@
class Foo {
//constructor
constructor(a)
{
testy = ["stuff",1,2,3];
}
//attributes of PrintTesty
</ test = "freakin attribute"/>
function PrintTesty()
{
foreach(i,val in testy)
{
::print("idx = "+i+" = "+val+" \n");
}
}
//attributes of testy
</ flippy = 10 , second = [1,2,3] />
testy = null;
}
foreach(member,val in Foo)
{
::print(member+"\n");
local attr;
if((attr = Foo.getattributes(member)) != null) {
foreach(i,v in attr)
{
::print("\t"+i+" = "+(typeof v)+"\n");
}
}
else {
::print("\t<no attributes>\n")
}
}

View File

@@ -1,25 +0,0 @@
function coroutine_test(a,b)
{
::print(a+" "+b+"\n");
local ret = ::suspend("suspend 1");
::print("the coroutine says "+ret+"\n");
ret = ::suspend("suspend 2");
::print("the coroutine says "+ret+"\n");
ret = ::suspend("suspend 3");
::print("the coroutine says "+ret+"\n");
return "I'm done"
}
local coro = ::newthread(coroutine_test);
local susparam = coro.call("test","coroutine"); //starts the coroutine
local i = 1;
do
{
::print("suspend passed ["+susparam+"]\n")
susparam = coro.wakeup("ciao "+i);
++i;
}while(coro.getstatus()=="suspended")
::print("return passed ["+susparam+"]\n")

View File

@@ -1,52 +0,0 @@
PEntity <- {
name="noname"
pos={x=0,y=0,z=0}
type="entity"
//methamethod
_typeof=function()
{
return type;
}
}
function PEntity::PrintPos()
{
::print("x="+pos.x+" y="+pos.y+" z="+pos.z+"\n");
}
function PEntity::new(name,pos)
{
local newentity=clone ::PEntity;
if(name)
newentity.name=name;
if(pos)
newentity.pos=pos;
return newentity;
}
PPlayer <- {
model="warrior.mdl"
weapon="fist"
health=100
armor=0
//overrides the parent type
type="player"
}
function PPlayer::new(name,pos)
{
local newplayer=delegate ::PEntity.new(name,pos) : clone ::PPlayer;
return newplayer;
}
local player=PPlayer.new("godzilla",{x=10,y=20,z=30});
::print("PLAYER NAME"+player.name+"\n");
::print("ENTITY TYPE"+typeof player+"\n");
player.PrintPos();
player.pos.x=123;
player.PrintPos();

View File

@@ -1,15 +0,0 @@
/*
*
* Original Javascript version by David Hedbor(http://www.bagley.org/~doug/shootout/)
*
*/
function fib(n)
{
if (n < 2) return 1
return fib(n-2) + fib(n-1)
}
local n = ARGS.len()!=0?ARGS[0].tointeger():1
print(fib(n)+"\n")

View File

@@ -1,33 +0,0 @@
function min(x,y)
return x<y?x:y;
function max(x,y)
return x>y?x:y;
if(min(100,200)>max(50,20))
print("I'm useless statement just to show up the if/else\n");
else
print("squirrel!!\n");
print("\n")
function typy(obj)
{
switch(typeof obj)
{
case "integer":
case "float":
return "is a number";
case "table":
case "array":
return "is a container";
default:
return "is other stuff"
}
}
local a=1,b={},c=function(a,b){return a+b;}
print("a "+typy(a)+"\n");
print("b "+typy(b)+"\n");
print("c "+typy(c)+"\n");

View File

@@ -1,42 +0,0 @@
/*
*Random number function from The Great Computer Language shootout
*converted to a generator func
*/
function gen_random(max) {
local last=42
local IM = 139968;
local IA = 3877;
local IC = 29573;
for(;;){ //loops forever
yield (max * (last = (last * IA + IC) % IM) / IM);
}
}
local randtor=gen_random(100);
print("RAND NUMBERS \n")
for(local i=0;i<10;i+=1)
print(">"+resume randtor+"\n");
print("FIBONACCI \n")
function fiboz(n)
{
local prev=0;
local curr=1;
yield 1;
for(local i=0;i<n-1;i+=1)
{
local res=prev+curr;
prev=curr;
yield curr=res;
}
return prev+curr;
}
foreach(val in fiboz(10))
{
::print(">"+val+"\n");
}

View File

@@ -1 +0,0 @@
print("Hello World!")

View File

@@ -1,39 +0,0 @@
/*translation of the list test from The Great Computer Language Shootout
*/
function compare_arr(a1,a2)
{
foreach(i,val in a1)
if(val!=a2[i])return null;
return 1;
}
function test()
{
local size=10000
local l1=[]; l1.resize(size);
for(local i=0;i<size;i+=1) l1[i]=i;
local l2=clone l1;
local l3=[]
l2.reverse();
while(l2.len()>0)
l3.append(l2.pop());
while(l3.len()>0)
l2.append(l3.pop());
l1.reverse();
if(compare_arr(l1,l2))
return l1.len();
return null;
}
local n = ARGS.len()!=0?ARGS[0].tointeger():1
for(local i=0;i<n;i+=1)
if(!test())
{
print("failed");
return;
}
print("oki doki");

View File

@@ -1,32 +0,0 @@
local arr=["one","two","three"]
::print("FOREACH\n");
foreach(i,val in arr)
{
::print("index ["+i+"]="+val+"\n");
}
::print("FOR\n");
for(local i=0;i<arr.len();i+=1)
{
::print("index ["+i+"]="+arr[i]+"\n");
}
::print("WHILE\n");
local i=0;
while(i<arr.len())
{
::print("index ["+i+"]="+arr[i]+"\n");
i+=1;
}
::print("DO WHILE\n");
local i=0;
do
{
::print("index ["+i+"]="+arr[i]+"\n");
i+=1;
}while(i<arr.len());

View File

@@ -1,44 +0,0 @@
/*
*
* Original Javascript version by David Hedbor(http://www.bagley.org/~doug/shootout/)
*
*/
local SIZE=30;
function mkmatrix(rows, cols) {
local i, j, count = 1;
local m = []; m.resize(rows);
for (i = 0; i < rows; i+=1) {
m[i] = [];m[i].resize(cols)
for (j = 0; j < cols; j+=1) {
m[i][j] = count+=1;
}
}
return m;
}
function mmult(rows, cols, m1, m2, m3) {
local i, j, k, val;
for (i = 0; i < rows; i+=1) {
for (j = 0; j < cols; j+=1) {
val = 0;
for (k = 0; k < cols; k+=1) {
val += m1[i][k] * m2[k][j];
}
m3[i][j] = val;
}
}
return m3;
}
local n = ARGS.len()!=0?ARGS[0].tointeger():1
local m1 = mkmatrix(SIZE, SIZE);
local m2 = mkmatrix(SIZE, SIZE);
local mm = mkmatrix(SIZE, SIZE);
for (local i = 0; i < n; i+=1) {
mmult(SIZE, SIZE, m1, m2, mm);
}
print(mm[0][0]+" "+mm[2][3]+" "+mm[3][2]+" "+mm[4][4]);

View File

@@ -1,115 +0,0 @@
local base_vec={
function _add(n)
{
return {
x=x+n.x,
y=y+n.y,
z=z+n.z,
}
}
function _sub(n)
{
return {
x=x-n.x,
y=y-n.y,
z=z-n.z,
}
}
function _div(n)
{
return {
x=x/n.x,
y=y/n.y,
z=z/n.z,
}
}
function _mul(n)
{
return {
x=x*n.x,
y=y*n.y,
z=z*n.z,
}
}
function _modulo(n)
{
return {
x=x%n,
y=y%n,
z=z%n,
}
}
function _typeof() {return "vector";}
function _get(key)
{
if(key==100)
{
return test_field;
}
},
function _set(key,val)
{
::print("key = "+key+"\n");
::print("val = "+val+"\n")
if(key==100)
{
return test_field=val;
}
}
test_field="nothing"
}
function vector(_x,_y,_z):(base_vec)
{
return delegate base_vec : {x=_x,y=_y,z=_z }
}
////////////////////////////////////////////////////////////
local v1=vector(1.5,2.5,3.5);
local v2=vector(1.5,2.5,3.5);
local r=v1+v2;
foreach(i,val in r)
{
print(i+" = "+val+"\n");
}
r=v1*v2;
foreach(i,val in r)
{
print(i+" = "+val+"\n");
}
r=v1/v2;
foreach(i,val in r)
{
print(i+" = "+val+"\n");
}
r=v1-v2;
foreach(i,val in r)
{
print(i+" = "+val+"\n");
}
r=v1%2;
foreach(i,val in r)
{
print(i+" = "+val+"\n");
}
print(v1[100]+"\n");
v1[100]="set SUCCEEDED";
print(v1[100]+"\n");
if(typeof v1=="vector")
print("<SUCCEEDED>\n");
else
print("<FAILED>\n");

View File

@@ -1,61 +0,0 @@
/*translation of the methcall test from The Great Computer Language Shootout
*/
Toggle <- {
bool=null
}
function Toggle::value() {
return bool;
}
function Toggle::activate() {
bool = !bool;
return this;
}
function Toggle::new(startstate) {
local newo=clone this;
newo.bool = startstate;
return newo;
}
NthToggle <- {
count_max=null
count=0
}
function NthToggle::new(start_state,max_counter)
{
local newo=delegate ::Toggle.new(start_state) : clone this;
newo.count_max <- max_counter
return newo;
}
function NthToggle::activate ()
{
count+=1
if (count >= count_max) {
bool = !bool;
count = 0;
}
return this;
}
local n = ARGS.len()!=0?ARGS[0].tointeger():1
local val = 1;
local toggle = Toggle.new(val);
for (local i=0; i<n; i+=1) {
val = toggle.activate().value();
}
print(toggle.value() ? "true\n" : "false\n");
val = 1;
local ntoggle = NthToggle.new(val, 3);
for (local i=0; i<n; i+=1) {
val = ntoggle.activate().value();
}
print(ntoggle.value() ? "true\n" : "false\n");

View File

@@ -1,24 +0,0 @@
function state1()
{
::suspend("state1");
return state2();
}
function state2()
{
::suspend("state2");
return state3();
}
function state3()
{
::suspend("state3");
return state1();
}
local statethread = ::newthread(state1)
::print(statethread.call()+"\n");
for(local i = 0; i < 10000; i++)
::print(statethread.wakeup()+"\n");

View File

@@ -1,24 +0,0 @@
SQUIRREL= ..
OUT= $(SQUIRREL)/bin/sq
INCZ= -I$(SQUIRREL)/include -I. -I$(SQUIRREL)/sqlibs
LIBZ= -L$(SQUIRREL)/lib
LIB= -lsquirrel -lsqstdlib
OBJS= sq.o
SRCS= sq.c
sq32:
g++ -O2 -fno-rtti -o $(OUT) $(SRCS) $(INCZ) $(LIBZ) $(LIB)
sqprof:
g++ -O2 -pg -fno-rtti -pie -gstabs -g3 -o $(OUT) $(SRCS) $(INCZ) $(LIBZ) $(LIB)
sq64:
g++ -O2 -fno-rtti -D_SQ64 -o $(OUT) $(SRCS) $(INCZ) $(LIBZ) $(LIB)
clean:
rm -f $(OUT)

View File

@@ -1,324 +0,0 @@
/* see copyright notice in squirrel.h */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#if defined(_MSC_VER) && defined(_DEBUG)
#include <crtdbg.h>
#include <conio.h>
#endif
#include <squirrel.h>
#include <sqstdblob.h>
#include <sqstdsystem.h>
#include <sqstdio.h>
#include <sqstdmath.h>
#include <sqstdstring.h>
#include <sqstdaux.h>
#ifdef SQUNICODE
#define scfprintf fwprintf
#define scfopen _wfopen
#define scvprintf vwprintf
#else
#define scfprintf fprintf
#define scfopen fopen
#define scvprintf vprintf
#endif
void PrintVersionInfos();
#if defined(_MSC_VER) && defined(_DEBUG)
int MemAllocHook( int allocType, void *userData, size_t size, int blockType,
long requestNumber, const unsigned char *filename, int lineNumber)
{
// if(requestNumber==585)_asm int 3;
return 1;
}
#endif
SQInteger quit(HSQUIRRELVM v)
{
int *done;
sq_getuserpointer(v,-1,(SQUserPointer*)&done);
*done=1;
return 0;
}
void printfunc(HSQUIRRELVM v,const SQChar *s,...)
{
va_list vl;
va_start(vl, s);
scvprintf( s, vl);
va_end(vl);
}
void PrintVersionInfos()
{
scfprintf(stdout,_SC("%s %s (%d bits)\n"),SQUIRREL_VERSION,SQUIRREL_COPYRIGHT,sizeof(SQInteger)*8);
if(sizeof(SQFloat) != sizeof(float)) {
scfprintf(stdout,_SC("[%d bits floats]\n"),sizeof(SQFloat)*8);
}
}
void PrintUsage()
{
scfprintf(stderr,_SC("usage: sq <options> <scriptpath [args]>.\n")
_SC("Available options are:\n")
_SC(" -c compiles the file to bytecode(default output 'out.cnut')\n")
_SC(" -o specifies output file for the -c option\n")
_SC(" -c compiles only\n")
_SC(" -d generates debug infos\n")
_SC(" -v displays version infos\n")
_SC(" -h prints help\n"));
}
#define _INTERACTIVE 0
#define _DONE 2
//<<FIXME>> this func is a mess
int getargs(HSQUIRRELVM v,int argc, char* argv[])
{
int i;
int compiles_only = 0;
static SQChar temp[500];
const SQChar *ret=NULL;
char * output = NULL;
int lineinfo=0;
if(argc>1)
{
int arg=1,exitloop=0;
while(arg < argc && !exitloop)
{
if(argv[arg][0]=='-')
{
switch(argv[arg][1])
{
case 'd': //DEBUG(debug infos)
sq_enabledebuginfo(v,1);
break;
case 'c':
compiles_only = 1;
break;
case 'o':
if(arg < argc) {
arg++;
output = argv[arg];
}
break;
case 'v':
PrintVersionInfos();
return _DONE;
case 'h':
PrintVersionInfos();
PrintUsage();
return _DONE;
default:
PrintVersionInfos();
scprintf(_SC("unknown prameter '-%c'\n"),argv[arg][1]);
PrintUsage();
return _DONE;
}
}else break;
arg++;
}
// src file
if(arg<argc) {
const SQChar *filename=NULL;
#ifdef SQUNICODE
mbstowcs(temp,argv[arg],strlen(argv[arg]));
filename=temp;
#else
filename=argv[arg];
#endif
arg++;
sq_pushroottable(v);
sq_pushstring(v,_SC("ARGS"),-1);
sq_newarray(v,0);
for(i=arg;i<argc;i++)
{
const SQChar *a;
#ifdef SQUNICODE
int alen=(int)strlen(argv[i]);
a=sq_getscratchpad(v,(int)(alen*sizeof(SQChar)));
mbstowcs(sq_getscratchpad(v,-1),argv[i],alen);
sq_getscratchpad(v,-1)[alen] = _SC('\0');
#else
a=argv[i];
#endif
sq_pushstring(v,a,-1);
sq_arrayappend(v,-2);
}
sq_createslot(v,-3);
sq_pop(v,1);
if(compiles_only) {
if(SQ_SUCCEEDED(sqstd_loadfile(v,filename,SQTrue))){
SQChar *outfile = _SC("out.cnut");
if(output) {
#ifdef SQUNICODE
int len = (int)(strlen(output)+1);
mbstowcs(sq_getscratchpad(v,len*sizeof(SQChar)),output,len);
outfile = sq_getscratchpad(v,-1);
#else
outfile = output;
#endif
}
if(SQ_SUCCEEDED(sqstd_writeclosuretofile(v,outfile)))
return _DONE;
}
}
else {
if(SQ_SUCCEEDED(sqstd_dofile(v,filename,SQFalse,SQTrue))) {
return _DONE;
}
}
//if this point is reached an error occured
{
const SQChar *err;
sq_getlasterror(v);
if(SQ_SUCCEEDED(sq_getstring(v,-1,&err))) {
scprintf(_SC("Error [%s]\n"),err);
return _DONE;
}
}
}
}
return _INTERACTIVE;
}
void Interactive(HSQUIRRELVM v)
{
#define MAXINPUT 1024
SQChar buffer[MAXINPUT];
SQInteger blocks =0;
SQInteger string=0;
SQInteger retval=0;
SQInteger done=0;
PrintVersionInfos();
sq_pushroottable(v);
sq_pushstring(v,_SC("quit"),-1);
sq_pushuserpointer(v,&done);
sq_newclosure(v,quit,1);
sq_setparamscheck(v,1,NULL);
sq_createslot(v,-3);
sq_pop(v,1);
while (!done)
{
SQInteger i = 0;
scprintf(_SC("\nsq>"));
for(;;) {
int c;
if(done)return;
c = getchar();
if (c == _SC('\n')) {
if (i>0 && buffer[i-1] == _SC('\\'))
{
buffer[i-1] = _SC('\n');
}
else if(blocks==0)break;
buffer[i++] = _SC('\n');
}
else if (c==_SC('}')) {blocks--; buffer[i++] = (SQChar)c;}
else if(c==_SC('{') && !string){
blocks++;
buffer[i++] = (SQChar)c;
}
else if(c==_SC('"') || c==_SC('\'')){
string=!string;
buffer[i++] = (SQChar)c;
}
else if (i >= MAXINPUT-1) {
scfprintf(stderr, _SC("sq : input line too long\n"));
break;
}
else{
buffer[i++] = (SQChar)c;
}
}
buffer[i] = _SC('\0');
if(buffer[0]==_SC('=')){
scsprintf(sq_getscratchpad(v,MAXINPUT),_SC("return (%s)"),&buffer[1]);
memcpy(buffer,sq_getscratchpad(v,-1),(scstrlen(sq_getscratchpad(v,-1))+1)*sizeof(SQChar));
retval=1;
}
i=scstrlen(buffer);
if(i>0){
SQInteger oldtop=sq_gettop(v);
if(SQ_SUCCEEDED(sq_compilebuffer(v,buffer,i,_SC("interactive console"),SQTrue))){
sq_pushroottable(v);
if(SQ_SUCCEEDED(sq_call(v,1,retval,SQTrue)) && retval){
scprintf(_SC("\n"));
sq_pushroottable(v);
sq_pushstring(v,_SC("print"),-1);
sq_get(v,-2);
sq_pushroottable(v);
sq_push(v,-4);
sq_call(v,2,SQFalse,SQTrue);
retval=0;
scprintf(_SC("\n"));
}
}
sq_settop(v,oldtop);
}
}
}
int main(int argc, char* argv[])
{
HSQUIRRELVM v;
const SQChar *filename=NULL;
#if defined(_MSC_VER) && defined(_DEBUG)
_CrtSetAllocHook(MemAllocHook);
#endif
v=sq_open(1024);
sq_setprintfunc(v,printfunc);
sq_pushroottable(v);
sqstd_register_bloblib(v);
sqstd_register_iolib(v);
sqstd_register_systemlib(v);
sqstd_register_mathlib(v);
sqstd_register_stringlib(v);
//aux library
//sets error handlers
sqstd_seterrorhandlers(v);
//gets arguments
switch(getargs(v,argc,argv))
{
case _INTERACTIVE:
Interactive(v);
break;
case _DONE:
default:
break;
}
sq_close(v);
#if defined(_MSC_VER) && defined(_DEBUG)
_getch();
_CrtMemDumpAllObjectsSince( NULL );
#endif
return 0;
}

View File

@@ -1,101 +0,0 @@
# Microsoft Developer Studio Project File - Name="sq" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=sq - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "sq.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "sq.mak" CFG="sq - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "sq - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "sq - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_LocalPath ".."
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "sq - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\include" /I "..\sqstdlib" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x410 /d "NDEBUG"
# ADD RSC /l 0x410 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 squirrel.lib sqstdlib.lib /nologo /subsystem:console /machine:I386 /out:"../bin/sq.exe" /libpath:"../lib"
!ELSEIF "$(CFG)" == "sq - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\sqstdlib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x410 /d "_DEBUG"
# ADD RSC /l 0x410 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 squirrel.lib sqstdlib.lib /nologo /subsystem:console /debug /machine:I386 /out:"../bin/sq.exe" /pdbtype:sept /libpath:"../lib"
!ENDIF
# Begin Target
# Name "sq - Win32 Release"
# Name "sq - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\sq.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -1,31 +0,0 @@
SQUIRREL= ..
OUT= $(SQUIRREL)/lib/libsqstdlib.a
INCZ= -I$(SQUIRREL)/include -I. -Iinclude
SRCS= \
sqstdblob.cpp \
sqstdio.cpp \
sqstdstream.cpp \
sqstdmath.cpp \
sqstdsystem.cpp \
sqstdstring.cpp \
sqstdaux.cpp \
sqstdrex.cpp
sq32:
gcc -O2 -fno-rtti -Wall -c $(SRCS) $(INCZ)
ar rc $(OUT) *.o
sqprof:
gcc -O2 -pg -fno-rtti -pie -gstabs -g3 -Wall -c $(SRCS) $(INCZ)
ar rc $(OUT) *.o
sq64:
gcc -O2 -D_SQ64 -fno-rtti -Wall -c $(SRCS) $(INCZ)
ar rc $(OUT) *.o
clean:
rm -f $(OUT) $(SRCS:%.cpp=%.o)

View File

@@ -1,251 +0,0 @@
/* see copyright notice in squirrel.h */
#include <new>
#include <squirrel.h>
#include <sqstdio.h>
#include <string.h>
#include <sqstdblob.h>
#include "sqstdstream.h"
#include "sqstdblobimpl.h"
#define SQSTD_BLOB_TYPE_TAG (SQSTD_STREAM_TYPE_TAG | 0x00000002)
//Blob
#define SETUP_BLOB(v) \
SQBlob *self = NULL; \
{ if(SQ_FAILED(sq_getinstanceup(v,1,(SQUserPointer*)&self,(SQUserPointer)SQSTD_BLOB_TYPE_TAG))) \
return SQ_ERROR; }
static SQInteger _blob_resize(HSQUIRRELVM v)
{
SETUP_BLOB(v);
SQInteger size;
sq_getinteger(v,2,&size);
if(!self->Resize(size))
return sq_throwerror(v,_SC("resize failed"));
return 0;
}
static void __swap_dword(unsigned int *n)
{
*n=(unsigned int)(((*n&0xFF000000)>>24) |
((*n&0x00FF0000)>>8) |
((*n&0x0000FF00)<<8) |
((*n&0x000000FF)<<24));
}
static void __swap_word(unsigned short *n)
{
*n=(unsigned short)((*n>>8)&0x00FF)| ((*n<<8)&0xFF00);
}
static SQInteger _blob_swap4(HSQUIRRELVM v)
{
SETUP_BLOB(v);
SQInteger num=(self->Len()-(self->Len()%4))>>2;
unsigned int *t=(unsigned int *)self->GetBuf();
for(SQInteger i = 0; i < num; i++) {
__swap_dword(&t[i]);
}
return 0;
}
static SQInteger _blob_swap2(HSQUIRRELVM v)
{
SETUP_BLOB(v);
SQInteger num=(self->Len()-(self->Len()%2))>>1;
unsigned short *t = (unsigned short *)self->GetBuf();
for(SQInteger i = 0; i < num; i++) {
__swap_word(&t[i]);
}
return 0;
}
static SQInteger _blob__set(HSQUIRRELVM v)
{
SETUP_BLOB(v);
SQInteger idx,val;
sq_getinteger(v,2,&idx);
sq_getinteger(v,3,&val);
if(idx < 0 || idx >= self->Len())
return sq_throwerror(v,_SC("index out of range"));
((unsigned char *)self->GetBuf())[idx] = (unsigned char) val;
sq_push(v,3);
return 1;
}
static SQInteger _blob__get(HSQUIRRELVM v)
{
SETUP_BLOB(v);
SQInteger idx;
sq_getinteger(v,2,&idx);
if(idx < 0 || idx >= self->Len())
return sq_throwerror(v,_SC("index out of range"));
sq_pushinteger(v,((unsigned char *)self->GetBuf())[idx]);
return 1;
}
static SQInteger _blob__nexti(HSQUIRRELVM v)
{
SETUP_BLOB(v);
if(sq_gettype(v,2) == OT_NULL) {
sq_pushinteger(v, 0);
return 1;
}
SQInteger idx;
if(SQ_SUCCEEDED(sq_getinteger(v, 2, &idx))) {
if(idx+1 < self->Len()) {
sq_pushinteger(v, idx+1);
return 1;
}
sq_pushnull(v);
return 1;
}
return sq_throwerror(v,_SC("internal error (_nexti) wrong argument type"));
}
static SQInteger _blob__typeof(HSQUIRRELVM v)
{
sq_pushstring(v,_SC("blob"),-1);
return 1;
}
static SQInteger _blob_releasehook(SQUserPointer p, SQInteger size)
{
SQBlob *self = (SQBlob*)p;
delete self;
return 1;
}
static SQInteger _blob_constructor(HSQUIRRELVM v)
{
SQInteger nparam = sq_gettop(v);
SQInteger size = 0;
if(nparam == 2) {
sq_getinteger(v, 2, &size);
}
if(size < 0) return sq_throwerror(v, _SC("cannot create blob with negative size"));
SQBlob *b = new SQBlob(size);
if(SQ_FAILED(sq_setinstanceup(v,1,b))) {
delete b;
return sq_throwerror(v, _SC("cannot create blob with negative size"));
}
sq_setreleasehook(v,1,_blob_releasehook);
return 0;
}
#define _DECL_BLOB_FUNC(name,nparams,typecheck) {_SC(#name),_blob_##name,nparams,typecheck}
static SQRegFunction _blob_methods[] = {
_DECL_BLOB_FUNC(constructor,-1,_SC("xn")),
_DECL_BLOB_FUNC(resize,2,_SC("xn")),
_DECL_BLOB_FUNC(swap2,1,_SC("x")),
_DECL_BLOB_FUNC(swap4,1,_SC("x")),
_DECL_BLOB_FUNC(_set,3,_SC("xnn")),
_DECL_BLOB_FUNC(_get,2,_SC("xn")),
_DECL_BLOB_FUNC(_typeof,1,_SC("x")),
_DECL_BLOB_FUNC(_nexti,2,_SC("x")),
{0,0,0,0}
};
//GLOBAL FUNCTIONS
static SQInteger _g_blob_casti2f(HSQUIRRELVM v)
{
SQInteger i;
sq_getinteger(v,2,&i);
sq_pushfloat(v,*((SQFloat *)&i));
return 1;
}
static SQInteger _g_blob_castf2i(HSQUIRRELVM v)
{
SQFloat f;
sq_getfloat(v,2,&f);
sq_pushinteger(v,*((SQInteger *)&f));
return 1;
}
static SQInteger _g_blob_swap2(HSQUIRRELVM v)
{
SQInteger i;
sq_getinteger(v,2,&i);
short s=(short)i;
sq_pushinteger(v,(s<<8)|((s>>8)&0x00FF));
return 1;
}
static SQInteger _g_blob_swap4(HSQUIRRELVM v)
{
SQInteger i;
sq_getinteger(v,2,&i);
unsigned int t4 = (unsigned int)i;
__swap_dword(&t4);
sq_pushinteger(v,(SQInteger)t4);
return 1;
}
static SQInteger _g_blob_swapfloat(HSQUIRRELVM v)
{
SQFloat f;
sq_getfloat(v,2,&f);
__swap_dword((unsigned int *)&f);
sq_pushfloat(v,f);
return 1;
}
#define _DECL_GLOBALBLOB_FUNC(name,nparams,typecheck) {_SC(#name),_g_blob_##name,nparams,typecheck}
static SQRegFunction bloblib_funcs[]={
_DECL_GLOBALBLOB_FUNC(casti2f,2,_SC(".n")),
_DECL_GLOBALBLOB_FUNC(castf2i,2,_SC(".n")),
_DECL_GLOBALBLOB_FUNC(swap2,2,_SC(".n")),
_DECL_GLOBALBLOB_FUNC(swap4,2,_SC(".n")),
_DECL_GLOBALBLOB_FUNC(swapfloat,2,_SC(".n")),
{0,0,0,0}
};
SQRESULT sqstd_getblob(HSQUIRRELVM v,SQInteger idx,SQUserPointer *ptr)
{
SQBlob *blob;
if(SQ_FAILED(sq_getinstanceup(v,idx,(SQUserPointer *)&blob,(SQUserPointer)SQSTD_BLOB_TYPE_TAG)))
return -1;
*ptr = blob->GetBuf();
return SQ_OK;
}
SQInteger sqstd_getblobsize(HSQUIRRELVM v,SQInteger idx)
{
SQBlob *blob;
if(SQ_FAILED(sq_getinstanceup(v,idx,(SQUserPointer *)&blob,(SQUserPointer)SQSTD_BLOB_TYPE_TAG)))
return -1;
return blob->Len();
}
SQUserPointer sqstd_createblob(HSQUIRRELVM v, SQInteger size)
{
SQInteger top = sq_gettop(v);
sq_pushregistrytable(v);
sq_pushstring(v,_SC("std_blob"),-1);
if(SQ_SUCCEEDED(sq_get(v,-2))) {
sq_remove(v,-2); //removes the registry
sq_push(v,1); // push the this
sq_pushinteger(v,size); //size
SQBlob *blob = NULL;
if(SQ_SUCCEEDED(sq_call(v,2,SQTrue,SQFalse))
&& SQ_SUCCEEDED(sq_getinstanceup(v,-1,(SQUserPointer *)&blob,(SQUserPointer)SQSTD_BLOB_TYPE_TAG))) {
sq_remove(v,-2);
return blob->GetBuf();
}
}
sq_settop(v,top);
return NULL;
}
SQRESULT sqstd_register_bloblib(HSQUIRRELVM v)
{
return declare_stream(v,_SC("blob"),(SQUserPointer)SQSTD_BLOB_TYPE_TAG,_SC("std_blob"),_blob_methods,bloblib_funcs);
}

View File

@@ -1,108 +0,0 @@
/* see copyright notice in squirrel.h */
#ifndef _SQSTD_BLOBIMPL_H_
#define _SQSTD_BLOBIMPL_H_
struct SQBlob : public SQStream
{
SQBlob(SQInteger size) {
_size = size;
_allocated = size;
_buf = (unsigned char *)sq_malloc(size);
memset(_buf, 0, _size);
_ptr = 0;
_owns = true;
}
virtual ~SQBlob() {
sq_free(_buf, _allocated);
}
SQInteger Write(void *buffer, SQInteger size) {
if(!CanAdvance(size)) {
GrowBufOf(_ptr + size - _size);
}
memcpy(&_buf[_ptr], buffer, size);
_ptr += size;
return size;
}
SQInteger Read(void *buffer,SQInteger size) {
SQInteger n = size;
if(!CanAdvance(size)) {
if((_size - _ptr) > 0)
n = _size - _ptr;
else return 0;
}
memcpy(buffer, &_buf[_ptr], n);
_ptr += n;
return n;
}
bool Resize(SQInteger n) {
if(!_owns) return false;
if(n != _allocated) {
unsigned char *newbuf = (unsigned char *)sq_malloc(n);
memset(newbuf,0,n);
if(_size > n)
memcpy(newbuf,_buf,n);
else
memcpy(newbuf,_buf,_size);
sq_free(_buf,_allocated);
_buf=newbuf;
_allocated = n;
if(_size > _allocated)
_size = _allocated;
if(_ptr > _allocated)
_ptr = _allocated;
}
return true;
}
bool GrowBufOf(SQInteger n)
{
bool ret = true;
if(_size + n > _allocated) {
if(_size + n > _size * 2)
ret = Resize(_size + n);
else
ret = Resize(_size * 2);
}
_size = _size + n;
return ret;
}
bool CanAdvance(SQInteger n) {
if(_ptr+n>_size)return false;
return true;
}
SQInteger Seek(SQInteger offset, SQInteger origin) {
switch(origin) {
case SQ_SEEK_SET:
if(offset > _size || offset < 0) return -1;
_ptr = offset;
break;
case SQ_SEEK_CUR:
if(_ptr + offset > _size || _ptr + offset < 0) return -1;
_ptr += offset;
break;
case SQ_SEEK_END:
if(_size + offset > _size || _size + offset < 0) return -1;
_ptr = _size + offset;
break;
default: return -1;
}
return 0;
}
bool IsValid() {
return _buf?true:false;
}
bool EOS() {
return _ptr == _size;
}
SQInteger Flush() { return 0; }
SQInteger Tell() { return _ptr; }
SQInteger Len() { return _size; }
SQUserPointer GetBuf(){ return _buf; }
private:
SQInteger _size;
SQInteger _allocated;
SQInteger _ptr;
unsigned char *_buf;
bool _owns;
};
#endif //_SQSTD_BLOBIMPL_H_

View File

@@ -1,410 +0,0 @@
/* see copyright notice in squirrel.h */
#include <stdio.h>
#include <squirrel.h>
#include <new>
#include <sqstdio.h>
#include "sqstdstream.h"
#define SQSTD_FILE_TYPE_TAG (SQSTD_STREAM_TYPE_TAG | 0x00000001)
//basic API
SQFILE sqstd_fopen(const SQChar *filename ,const SQChar *mode)
{
#ifndef SQUNICODE
return (SQFILE)fopen(filename,mode);
#else
return (SQFILE)_wfopen(filename,mode);
#endif
}
SQInteger sqstd_fread(void* buffer, SQInteger size, SQInteger count, SQFILE file)
{
return (SQInteger)fread(buffer,size,count,(FILE *)file);
}
SQInteger sqstd_fwrite(const SQUserPointer buffer, SQInteger size, SQInteger count, SQFILE file)
{
return (SQInteger)fwrite(buffer,size,count,(FILE *)file);
}
SQInteger sqstd_fseek(SQFILE file, SQInteger offset, SQInteger origin)
{
SQInteger realorigin;
switch(origin) {
case SQ_SEEK_CUR: realorigin = SEEK_CUR; break;
case SQ_SEEK_END: realorigin = SEEK_END; break;
case SQ_SEEK_SET: realorigin = SEEK_SET; break;
default: return -1; //failed
}
return fseek((FILE *)file,(long)offset,(int)realorigin);
}
SQInteger sqstd_ftell(SQFILE file)
{
return ftell((FILE *)file);
}
SQInteger sqstd_fflush(SQFILE file)
{
return fflush((FILE *)file);
}
SQInteger sqstd_fclose(SQFILE file)
{
return fclose((FILE *)file);
}
SQInteger sqstd_feof(SQFILE file)
{
return feof((FILE *)file);
}
//File
struct SQFile : public SQStream {
SQFile() { _handle = NULL; _owns = false;}
SQFile(SQFILE file, bool owns) { _handle = file; _owns = owns;}
virtual ~SQFile() { Close(); }
bool Open(const SQChar *filename ,const SQChar *mode) {
Close();
if( (_handle = sqstd_fopen(filename,mode)) ) {
_owns = true;
return true;
}
return false;
}
void Close() {
if(_handle && _owns) {
sqstd_fclose(_handle);
_handle = NULL;
_owns = false;
}
}
SQInteger Read(void *buffer,SQInteger size) {
return sqstd_fread(buffer,1,size,_handle);
}
SQInteger Write(void *buffer,SQInteger size) {
return sqstd_fwrite(buffer,1,size,_handle);
}
SQInteger Flush() {
return sqstd_fflush(_handle);
}
SQInteger Tell() {
return sqstd_ftell(_handle);
}
SQInteger Len() {
SQInteger prevpos=Tell();
Seek(0,SQ_SEEK_END);
SQInteger size=Tell();
Seek(prevpos,SQ_SEEK_SET);
return size;
}
SQInteger Seek(SQInteger offset, SQInteger origin) {
return sqstd_fseek(_handle,offset,origin);
}
bool IsValid() { return _handle?true:false; }
bool EOS() { return Tell()==Len()?true:false;}
SQFILE GetHandle() {return _handle;}
private:
SQFILE _handle;
bool _owns;
};
static SQInteger _file__typeof(HSQUIRRELVM v)
{
sq_pushstring(v,_SC("file"),-1);
return 1;
}
static SQInteger _file_releasehook(SQUserPointer p, SQInteger size)
{
SQFile *self = (SQFile*)p;
delete self;
return 1;
}
static SQInteger _file_constructor(HSQUIRRELVM v)
{
const SQChar *filename,*mode;
bool owns = true;
SQFile *f;
SQFILE newf;
if(sq_gettype(v,2) == OT_STRING && sq_gettype(v,3) == OT_STRING) {
sq_getstring(v, 2, &filename);
sq_getstring(v, 3, &mode);
newf = sqstd_fopen(filename, mode);
if(!newf) return sq_throwerror(v, _SC("cannot open file"));
} else if(sq_gettype(v,2) == OT_USERPOINTER) {
owns = !(sq_gettype(v,3) == OT_NULL);
sq_getuserpointer(v,2,&newf);
} else {
return sq_throwerror(v,_SC("wrong parameter"));
}
f = new SQFile(newf,owns);
if(SQ_FAILED(sq_setinstanceup(v,1,f))) {
delete f;
return sq_throwerror(v, _SC("cannot create blob with negative size"));
}
sq_setreleasehook(v,1,_file_releasehook);
return 0;
}
//bindings
#define _DECL_FILE_FUNC(name,nparams,typecheck) {_SC(#name),_file_##name,nparams,typecheck}
static SQRegFunction _file_methods[] = {
_DECL_FILE_FUNC(constructor,3,_SC("x")),
_DECL_FILE_FUNC(_typeof,1,_SC("x")),
{0,0,0,0},
};
SQRESULT sqstd_createfile(HSQUIRRELVM v, SQFILE file,SQBool own)
{
SQInteger top = sq_gettop(v);
sq_pushregistrytable(v);
sq_pushstring(v,_SC("std_file"),-1);
if(SQ_SUCCEEDED(sq_get(v,-2))) {
sq_remove(v,-2); //removes the registry
sq_pushroottable(v); // push the this
sq_pushuserpointer(v,file); //file
if(own){
sq_pushinteger(v,1); //true
}
else{
sq_pushnull(v); //false
}
if(SQ_SUCCEEDED( sq_call(v,3,SQTrue,SQFalse) )) {
sq_remove(v,-2);
return SQ_OK;
}
}
sq_settop(v,top);
return SQ_OK;
}
SQRESULT sqstd_getfile(HSQUIRRELVM v, SQInteger idx, SQFILE *file)
{
SQFile *fileobj = NULL;
if(SQ_SUCCEEDED(sq_getinstanceup(v,idx,(SQUserPointer*)&fileobj,(SQUserPointer)SQSTD_FILE_TYPE_TAG))) {
*file = fileobj->GetHandle();
return SQ_OK;
}
return sq_throwerror(v,_SC("not a file"));
}
static SQInteger _io_file_lexfeed_ASCII(SQUserPointer file)
{
SQInteger ret;
char c;
if( ( ret=sqstd_fread(&c,sizeof(c),1,(FILE *)file )>0) )
return c;
return 0;
}
static SQInteger _io_file_lexfeed_UTF8(SQUserPointer file)
{
#define READ() \
if(sqstd_fread(&inchar,sizeof(inchar),1,(FILE *)file) != 1) \
return 0;
static const SQInteger utf8_lengths[16] =
{
1,1,1,1,1,1,1,1, /* 0000 to 0111 : 1 byte (plain ASCII) */
0,0,0,0, /* 1000 to 1011 : not valid */
2,2, /* 1100, 1101 : 2 bytes */
3, /* 1110 : 3 bytes */
4 /* 1111 :4 bytes */
};
static unsigned char byte_masks[5] = {0,0,0x1f,0x0f,0x07};
unsigned char inchar;
SQInteger c = 0;
READ();
c = inchar;
//
if(c >= 0x80) {
SQInteger tmp;
SQInteger codelen = utf8_lengths[c>>4];
if(codelen == 0)
return 0;
//"invalid UTF-8 stream";
tmp = c&byte_masks[codelen];
for(SQInteger n = 0; n < codelen-1; n++) {
tmp<<=6;
READ();
tmp |= inchar & 0x3F;
}
c = tmp;
}
return c;
}
static SQInteger _io_file_lexfeed_UCS2_LE(SQUserPointer file)
{
SQInteger ret;
wchar_t c;
if( ( ret=sqstd_fread(&c,sizeof(c),1,(FILE *)file )>0) )
return (SQChar)c;
return 0;
}
static SQInteger _io_file_lexfeed_UCS2_BE(SQUserPointer file)
{
SQInteger ret;
unsigned short c;
if( ( ret=sqstd_fread(&c,sizeof(c),1,(FILE *)file )>0) ) {
c = ((c>>8)&0x00FF)| ((c<<8)&0xFF00);
return (SQChar)c;
}
return 0;
}
SQInteger file_read(SQUserPointer file,SQUserPointer buf,SQInteger size)
{
SQInteger ret;
if( ( ret = sqstd_fread(buf,1,size,(SQFILE)file ))!=0 )return ret;
return -1;
}
SQInteger file_write(SQUserPointer file,SQUserPointer p,SQInteger size)
{
return sqstd_fwrite(p,1,size,(SQFILE)file);
}
SQRESULT sqstd_loadfile(HSQUIRRELVM v,const SQChar *filename,SQBool printerror)
{
SQFILE file = sqstd_fopen(filename,_SC("rb"));
SQInteger ret;
unsigned short us;
unsigned char uc;
SQLEXREADFUNC func = _io_file_lexfeed_ASCII;
if(file){
ret = sqstd_fread(&us,1,2,file);
if(ret != 2) {
//probably an empty file
us = 0;
}
if(us == SQ_BYTECODE_STREAM_TAG) { //BYTECODE
sqstd_fseek(file,0,SQ_SEEK_SET);
if(SQ_SUCCEEDED(sq_readclosure(v,file_read,file))) {
sqstd_fclose(file);
return SQ_OK;
}
}
else { //SCRIPT
switch(us)
{
//gotta swap the next 2 lines on BIG endian machines
case 0xFFFE: func = _io_file_lexfeed_UCS2_BE; break;//UTF-16 little endian;
case 0xFEFF: func = _io_file_lexfeed_UCS2_LE; break;//UTF-16 big endian;
case 0xBBEF:
if(sqstd_fread(&uc,1,sizeof(uc),file) == 0) {
sqstd_fclose(file);
return sq_throwerror(v,_SC("io error"));
}
if(uc != 0xBF) {
sqstd_fclose(file);
return sq_throwerror(v,_SC("Unrecognozed ecoding"));
}
func = _io_file_lexfeed_UTF8;
break;//UTF-8 ;
default: sqstd_fseek(file,0,SQ_SEEK_SET); break; // ascii
}
if(SQ_SUCCEEDED(sq_compile(v,func,file,filename,printerror))){
sqstd_fclose(file);
return SQ_OK;
}
}
sqstd_fclose(file);
return SQ_ERROR;
}
return sq_throwerror(v,_SC("cannot open the file"));
}
SQRESULT sqstd_dofile(HSQUIRRELVM v,const SQChar *filename,SQBool retval,SQBool printerror)
{
if(SQ_SUCCEEDED(sqstd_loadfile(v,filename,printerror))) {
sq_push(v,-2);
if(SQ_SUCCEEDED(sq_call(v,1,retval,SQTrue))) {
sq_remove(v,retval?-2:-1); //removes the closure
return 1;
}
sq_pop(v,1); //removes the closure
}
return SQ_ERROR;
}
SQRESULT sqstd_writeclosuretofile(HSQUIRRELVM v,const SQChar *filename)
{
SQFILE file = sqstd_fopen(filename,_SC("wb+"));
if(!file) return sq_throwerror(v,_SC("cannot open the file"));
if(SQ_SUCCEEDED(sq_writeclosure(v,file_write,file))) {
sqstd_fclose(file);
return SQ_OK;
}
sqstd_fclose(file);
return SQ_ERROR; //forward the error
}
SQInteger _g_io_loadfile(HSQUIRRELVM v)
{
const SQChar *filename;
SQBool printerror = SQFalse;
sq_getstring(v,2,&filename);
if(sq_gettop(v) >= 3) {
sq_getbool(v,3,&printerror);
}
if(SQ_SUCCEEDED(sqstd_loadfile(v,filename,printerror)))
return 1;
return SQ_ERROR; //propagates the error
}
SQInteger _g_io_writeclosuretofile(HSQUIRRELVM v)
{
const SQChar *filename;
sq_getstring(v,2,&filename);
if(SQ_SUCCEEDED(sqstd_writeclosuretofile(v,filename)))
return 1;
return SQ_ERROR; //propagates the error
}
SQInteger _g_io_dofile(HSQUIRRELVM v)
{
const SQChar *filename;
SQBool printerror = SQFalse;
sq_getstring(v,2,&filename);
if(sq_gettop(v) >= 3) {
sq_getbool(v,3,&printerror);
}
sq_push(v,1); //repush the this
if(SQ_SUCCEEDED(sqstd_dofile(v,filename,SQTrue,printerror)))
return 1;
return SQ_ERROR; //propagates the error
}
#define _DECL_GLOBALIO_FUNC(name,nparams,typecheck) {_SC(#name),_g_io_##name,nparams,typecheck}
static SQRegFunction iolib_funcs[]={
_DECL_GLOBALIO_FUNC(loadfile,-2,_SC(".sb")),
_DECL_GLOBALIO_FUNC(dofile,-2,_SC(".sb")),
_DECL_GLOBALIO_FUNC(writeclosuretofile,3,_SC(".sc")),
{0,0,0,0}
};
SQRESULT sqstd_register_iolib(HSQUIRRELVM v)
{
SQInteger top = sq_gettop(v);
//create delegate
declare_stream(v,_SC("file"),(SQUserPointer)SQSTD_FILE_TYPE_TAG,_SC("std_file"),_file_methods,iolib_funcs);
sq_pushstring(v,_SC("stdout"),-1);
sqstd_createfile(v,stdout,SQFalse);
sq_createslot(v,-3);
sq_pushstring(v,_SC("stdin"),-1);
sqstd_createfile(v,stdin,SQFalse);
sq_createslot(v,-3);
sq_pushstring(v,_SC("stderr"),-1);
sqstd_createfile(v,stderr,SQFalse);
sq_createslot(v,-3);
sq_settop(v,top);
return SQ_OK;
}

View File

@@ -1,131 +0,0 @@
# Microsoft Developer Studio Project File - Name="sqstdlib" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=sqstdlib - Win32 Release
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "sqstdlib.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "sqstdlib.mak" CFG="sqstdlib - Win32 Release"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "sqstdlib - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "sqstdlib - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_LocalPath ".."
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "sqstdlib - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD BASE RSC /l 0x410 /d "NDEBUG"
# ADD RSC /l 0x410 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\lib\sqstdlib.lib"
!ELSEIF "$(CFG)" == "sqstdlib - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD BASE RSC /l 0x410 /d "_DEBUG"
# ADD RSC /l 0x410 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\lib\sqstdlib.lib"
!ENDIF
# Begin Target
# Name "sqstdlib - Win32 Release"
# Name "sqstdlib - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\sqstdblob.cpp
# End Source File
# Begin Source File
SOURCE=.\sqstdio.cpp
# End Source File
# Begin Source File
SOURCE=.\sqstdmath.cpp
# End Source File
# Begin Source File
SOURCE=.\sqstdrex.cpp
# End Source File
# Begin Source File
SOURCE=.\sqstdstream.cpp
# End Source File
# Begin Source File
SOURCE=.\sqstdstring.cpp
# End Source File
# Begin Source File
SOURCE=.\sqstdaux.cpp
# End Source File
# Begin Source File
SOURCE=.\sqstdsystem.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\sqstdblobimpl.h
# End Source File
# Begin Source File
SOURCE=.\sqstdstream.h
# End Source File
# End Group
# End Target
# End Project

View File

@@ -1,330 +0,0 @@
/* see copyright notice in squirrel.h */
#include <stdio.h>
#include <new>
#include <stdlib.h>
#include <string.h>
#include <squirrel.h>
#include <sqstdio.h>
#include <sqstdblob.h>
#include "sqstdstream.h"
#include "sqstdblobimpl.h"
#define SETUP_STREAM(v) \
SQStream *self = NULL; \
if(SQ_FAILED(sq_getinstanceup(v,1,(SQUserPointer*)&self,(SQUserPointer)SQSTD_STREAM_TYPE_TAG))) \
return sq_throwerror(v,_SC("invalid type tag")); \
if(!self->IsValid()) \
return sq_throwerror(v,_SC("the stream is invalid"));
SQInteger _stream_readblob(HSQUIRRELVM v)
{
SETUP_STREAM(v);
SQUserPointer data,blobp;
SQInteger size,res;
sq_getinteger(v,2,&size);
if(size > self->Len()) {
size = self->Len();
}
data = sq_getscratchpad(v,size);
res = self->Read(data,size);
if(res <= 0)
return sq_throwerror(v,_SC("no data left to read"));
blobp = sqstd_createblob(v,res);
memcpy(blobp,data,res);
return 1;
}
#define SAFE_READN(ptr,len) { \
if(self->Read(ptr,len) != len) return sq_throwerror(v,_SC("io error")); \
}
SQInteger _stream_readn(HSQUIRRELVM v)
{
SETUP_STREAM(v);
SQInteger format;
sq_getinteger(v, 2, &format);
switch(format) {
case 'l': {
SQInteger i;
SAFE_READN(&i, sizeof(i));
sq_pushinteger(v, i);
}
break;
case 'i': {
SQInt32 i;
SAFE_READN(&i, sizeof(i));
sq_pushinteger(v, i);
}
break;
case 's': {
short s;
SAFE_READN(&s, sizeof(short));
sq_pushinteger(v, s);
}
break;
case 'w': {
unsigned short w;
SAFE_READN(&w, sizeof(unsigned short));
sq_pushinteger(v, w);
}
break;
case 'c': {
char c;
SAFE_READN(&c, sizeof(char));
sq_pushinteger(v, c);
}
break;
case 'b': {
unsigned char c;
SAFE_READN(&c, sizeof(unsigned char));
sq_pushinteger(v, c);
}
break;
case 'f': {
float f;
SAFE_READN(&f, sizeof(float));
sq_pushfloat(v, f);
}
break;
case 'd': {
double d;
SAFE_READN(&d, sizeof(double));
sq_pushfloat(v, (SQFloat)d);
}
break;
default:
return sq_throwerror(v, _SC("invalid format"));
}
return 1;
}
SQInteger _stream_writeblob(HSQUIRRELVM v)
{
SQUserPointer data;
SQInteger size;
SETUP_STREAM(v);
if(SQ_FAILED(sqstd_getblob(v,2,&data)))
return sq_throwerror(v,_SC("invalid parameter"));
size = sqstd_getblobsize(v,2);
if(self->Write(data,size) != size)
return sq_throwerror(v,_SC("io error"));
sq_pushinteger(v,size);
return 1;
}
SQInteger _stream_writen(HSQUIRRELVM v)
{
SETUP_STREAM(v);
SQInteger format, ti;
SQFloat tf;
sq_getinteger(v, 3, &format);
switch(format) {
case 'l': {
SQInteger i;
sq_getinteger(v, 2, &ti);
i = ti;
self->Write(&i, sizeof(SQInteger));
}
break;
case 'i': {
SQInt32 i;
sq_getinteger(v, 2, &ti);
i = (SQInt32)ti;
self->Write(&i, sizeof(SQInt32));
}
break;
case 's': {
short s;
sq_getinteger(v, 2, &ti);
s = (short)ti;
self->Write(&s, sizeof(short));
}
break;
case 'w': {
unsigned short w;
sq_getinteger(v, 2, &ti);
w = (unsigned short)ti;
self->Write(&w, sizeof(unsigned short));
}
break;
case 'c': {
char c;
sq_getinteger(v, 2, &ti);
c = (char)ti;
self->Write(&c, sizeof(char));
}
break;
case 'b': {
unsigned char b;
sq_getinteger(v, 2, &ti);
b = (unsigned char)ti;
self->Write(&b, sizeof(unsigned char));
}
break;
case 'f': {
float f;
sq_getfloat(v, 2, &tf);
f = (float)tf;
self->Write(&f, sizeof(float));
}
break;
case 'd': {
double d;
sq_getfloat(v, 2, &tf);
d = tf;
self->Write(&d, sizeof(double));
}
break;
default:
return sq_throwerror(v, _SC("invalid format"));
}
return 0;
}
SQInteger _stream_seek(HSQUIRRELVM v)
{
SETUP_STREAM(v);
SQInteger offset, origin = SQ_SEEK_SET;
sq_getinteger(v, 2, &offset);
if(sq_gettop(v) > 2) {
SQInteger t;
sq_getinteger(v, 3, &t);
switch(t) {
case 'b': origin = SQ_SEEK_SET; break;
case 'c': origin = SQ_SEEK_CUR; break;
case 'e': origin = SQ_SEEK_END; break;
default: return sq_throwerror(v,_SC("invalid origin"));
}
}
sq_pushinteger(v, self->Seek(offset, origin));
return 1;
}
SQInteger _stream_tell(HSQUIRRELVM v)
{
SETUP_STREAM(v);
sq_pushinteger(v, self->Tell());
return 1;
}
SQInteger _stream_len(HSQUIRRELVM v)
{
SETUP_STREAM(v);
sq_pushinteger(v, self->Len());
return 1;
}
SQInteger _stream_flush(HSQUIRRELVM v)
{
SETUP_STREAM(v);
if(!self->Flush())
sq_pushinteger(v, 1);
else
sq_pushnull(v);
return 1;
}
SQInteger _stream_eos(HSQUIRRELVM v)
{
SETUP_STREAM(v);
if(self->EOS())
sq_pushinteger(v, 1);
else
sq_pushnull(v);
return 1;
}
static SQRegFunction _stream_methods[] = {
_DECL_STREAM_FUNC(readblob,2,_SC("xn")),
_DECL_STREAM_FUNC(readn,2,_SC("xn")),
_DECL_STREAM_FUNC(writeblob,-2,_SC("xx")),
_DECL_STREAM_FUNC(writen,3,_SC("xnn")),
_DECL_STREAM_FUNC(seek,-2,_SC("xnn")),
_DECL_STREAM_FUNC(tell,1,_SC("x")),
_DECL_STREAM_FUNC(len,1,_SC("x")),
_DECL_STREAM_FUNC(eos,1,_SC("x")),
_DECL_STREAM_FUNC(flush,1,_SC("x")),
{0,0,0,0}
};
void init_streamclass(HSQUIRRELVM v)
{
sq_pushregistrytable(v);
sq_pushstring(v,_SC("std_stream"),-1);
if(SQ_FAILED(sq_get(v,-2))) {
sq_pushstring(v,_SC("std_stream"),-1);
sq_newclass(v,SQFalse);
sq_settypetag(v,-1,(SQUserPointer)SQSTD_STREAM_TYPE_TAG);
SQInteger i = 0;
while(_stream_methods[i].name != 0) {
SQRegFunction &f = _stream_methods[i];
sq_pushstring(v,f.name,-1);
sq_newclosure(v,f.f,0);
sq_setparamscheck(v,f.nparamscheck,f.typemask);
sq_createslot(v,-3);
i++;
}
sq_createslot(v,-3);
sq_pushroottable(v);
sq_pushstring(v,_SC("stream"),-1);
sq_pushstring(v,_SC("std_stream"),-1);
sq_get(v,-4);
sq_createslot(v,-3);
sq_pop(v,1);
}
else {
sq_pop(v,1); //result
}
sq_pop(v,1);
}
SQRESULT declare_stream(HSQUIRRELVM v,const SQChar* name,SQUserPointer typetag,const SQChar* reg_name,SQRegFunction *methods,SQRegFunction *globals)
{
if(sq_gettype(v,-1) != OT_TABLE)
return sq_throwerror(v,_SC("table expected"));
SQInteger top = sq_gettop(v);
//create delegate
init_streamclass(v);
sq_pushregistrytable(v);
sq_pushstring(v,reg_name,-1);
sq_pushstring(v,_SC("std_stream"),-1);
if(SQ_SUCCEEDED(sq_get(v,-3))) {
sq_newclass(v,SQTrue);
sq_settypetag(v,-1,typetag);
SQInteger i = 0;
while(methods[i].name != 0) {
SQRegFunction &f = methods[i];
sq_pushstring(v,f.name,-1);
sq_newclosure(v,f.f,0);
sq_setparamscheck(v,f.nparamscheck,f.typemask);
sq_setnativeclosurename(v,-1,f.name);
sq_createslot(v,-3);
i++;
}
sq_createslot(v,-3);
sq_pop(v,1);
i = 0;
while(globals[i].name!=0)
{
SQRegFunction &f = globals[i];
sq_pushstring(v,f.name,-1);
sq_newclosure(v,f.f,0);
sq_setparamscheck(v,f.nparamscheck,f.typemask);
sq_setnativeclosurename(v,-1,f.name);
sq_createslot(v,-3);
i++;
}
//register the class in the target table
sq_pushstring(v,name,-1);
sq_pushregistrytable(v);
sq_pushstring(v,reg_name,-1);
sq_get(v,-2);
sq_remove(v,-2);
sq_createslot(v,-3);
sq_settop(v,top);
return SQ_OK;
}
sq_settop(v,top);
return SQ_ERROR;
}

View File

@@ -1,18 +0,0 @@
/* see copyright notice in squirrel.h */
#ifndef _SQSTD_STREAM_H_
#define _SQSTD_STREAM_H_
SQInteger _stream_readblob(HSQUIRRELVM v);
SQInteger _stream_readline(HSQUIRRELVM v);
SQInteger _stream_readn(HSQUIRRELVM v);
SQInteger _stream_writeblob(HSQUIRRELVM v);
SQInteger _stream_writen(HSQUIRRELVM v);
SQInteger _stream_seek(HSQUIRRELVM v);
SQInteger _stream_tell(HSQUIRRELVM v);
SQInteger _stream_len(HSQUIRRELVM v);
SQInteger _stream_eos(HSQUIRRELVM v);
SQInteger _stream_flush(HSQUIRRELVM v);
#define _DECL_STREAM_FUNC(name,nparams,typecheck) {_SC(#name),_stream_##name,nparams,typecheck}
SQRESULT declare_stream(HSQUIRRELVM v,const SQChar* name,SQUserPointer typetag,const SQChar* reg_name,SQRegFunction *methods,SQRegFunction *globals);
#endif /*_SQSTD_STREAM_H_*/

View File

@@ -1,147 +0,0 @@
/* see copyright notice in squirrel.h */
#include <squirrel.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <sqstdsystem.h>
#ifdef SQUNICODE
#include <wchar.h>
#define scgetenv _wgetenv
#define scsystem _wsystem
#define scasctime _wasctime
#define scremove _wremove
#define screname _wrename
#else
#define scgetenv getenv
#define scsystem system
#define scasctime asctime
#define scremove remove
#define screname rename
#endif
static SQInteger _system_getenv(HSQUIRRELVM v)
{
const SQChar *s;
if(SQ_SUCCEEDED(sq_getstring(v,2,&s))){
sq_pushstring(v,scgetenv(s),-1);
return 1;
}
return 0;
}
static SQInteger _system_system(HSQUIRRELVM v)
{
const SQChar *s;
if(SQ_SUCCEEDED(sq_getstring(v,2,&s))){
sq_pushinteger(v,scsystem(s));
return 1;
}
return sq_throwerror(v,_SC("wrong param"));
}
static SQInteger _system_clock(HSQUIRRELVM v)
{
sq_pushfloat(v,((SQFloat)clock())/(SQFloat)CLOCKS_PER_SEC);
return 1;
}
static SQInteger _system_time(HSQUIRRELVM v)
{
time_t t;
time(&t);
sq_pushinteger(v,*((SQInteger *)&t));
return 1;
}
static SQInteger _system_remove(HSQUIRRELVM v)
{
const SQChar *s;
sq_getstring(v,2,&s);
if(scremove(s)==-1)
return sq_throwerror(v,_SC("remove() failed"));
return 0;
}
static SQInteger _system_rename(HSQUIRRELVM v)
{
const SQChar *oldn,*newn;
sq_getstring(v,2,&oldn);
sq_getstring(v,3,&newn);
if(screname(oldn,newn)==-1)
return sq_throwerror(v,_SC("rename() failed"));
return 0;
}
static void _set_integer_slot(HSQUIRRELVM v,const SQChar *name,SQInteger val)
{
sq_pushstring(v,name,-1);
sq_pushinteger(v,val);
sq_rawset(v,-3);
}
static SQInteger _system_date(HSQUIRRELVM v)
{
time_t t;
SQInteger it;
SQInteger format = 'l';
if(sq_gettop(v) > 1) {
sq_getinteger(v,2,&it);
t = it;
if(sq_gettop(v) > 2) {
sq_getinteger(v,3,(SQInteger*)&format);
}
}
else {
time(&t);
}
tm *date;
if(format == 'u')
date = gmtime(&t);
else
date = localtime(&t);
if(!date)
return sq_throwerror(v,_SC("crt api failure"));
sq_newtable(v);
_set_integer_slot(v, _SC("sec"), date->tm_sec);
_set_integer_slot(v, _SC("min"), date->tm_min);
_set_integer_slot(v, _SC("hour"), date->tm_hour);
_set_integer_slot(v, _SC("day"), date->tm_mday);
_set_integer_slot(v, _SC("month"), date->tm_mon);
_set_integer_slot(v, _SC("year"), date->tm_year+1900);
_set_integer_slot(v, _SC("wday"), date->tm_wday);
_set_integer_slot(v, _SC("yday"), date->tm_yday);
return 1;
}
#define _DECL_FUNC(name,nparams,pmask) {_SC(#name),_system_##name,nparams,pmask}
static SQRegFunction systemlib_funcs[]={
_DECL_FUNC(getenv,2,_SC(".s")),
_DECL_FUNC(system,2,_SC(".s")),
_DECL_FUNC(clock,1,NULL),
_DECL_FUNC(time,1,NULL),
_DECL_FUNC(date,-1,_SC(".nn")),
_DECL_FUNC(remove,2,_SC(".s")),
_DECL_FUNC(rename,3,_SC(".ss")),
{0,0,0,0}
};
SQInteger sqstd_register_systemlib(HSQUIRRELVM v)
{
SQInteger i=0;
while(systemlib_funcs[i].name!=0)
{
sq_pushstring(v,systemlib_funcs[i].name,-1);
sq_newclosure(v,systemlib_funcs[i].f,0);
sq_setparamscheck(v,systemlib_funcs[i].nparamscheck,systemlib_funcs[i].typemask);
sq_setnativeclosurename(v,-1,systemlib_funcs[i].name);
sq_createslot(v,-3);
i++;
}
return 1;
}

View File

@@ -1,77 +0,0 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "sq"=.\sq\sq.dsp - Package Owner=<4>
Package=<5>
{{{
begin source code control
.
end source code control
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name sqlibs
End Project Dependency
Begin Project Dependency
Project_Dep_Name squirrel
End Project Dependency
Begin Project Dependency
Project_Dep_Name sqstdlib
End Project Dependency
}}}
###############################################################################
Project: "sqstdlib"=.\sqstdlib\sqstdlib.dsp - Package Owner=<4>
Package=<5>
{{{
begin source code control
"$/squirrel", HAAAAAAA
.
end source code control
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "squirrel"=.\squirrel\squirrel.dsp - Package Owner=<4>
Package=<5>
{{{
begin source code control
"$/squirrel", HAAAAAAA
.
end source code control
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
begin source code control
"$/squirrel", HAAAAAAA
.
end source code control
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -1,52 +0,0 @@
SQUIRREL= ..
OUT= $(SQUIRREL)/lib/libsquirrel.a
INCZ= -I$(SQUIRREL)/include -I. -Iinclude
DEFS=
LIB=
OBJS= \
sqapi.o \
sqbaselib.o \
sqcompiler.o \
sqdebug.o \
sqlexer.o \
sqobject.o \
sqparser.o \
sqstate.o \
sqtable.o \
sqvm.o \
sqmem.o \
sqclass.o
SRCS= \
sqapi.cpp \
sqbaselib.cpp \
sqfuncstate.cpp \
sqdebug.cpp \
sqlexer.cpp \
sqobject.cpp \
sqcompiler.cpp \
sqstate.cpp \
sqtable.cpp \
sqmem.cpp \
sqvm.cpp \
sqclass.cpp
sq32:
gcc -O2 -fno-rtti -Wall -c $(SRCS) $(INCZ) $(DEFS)
ar rc $(OUT) *.o
sqprof:
gcc -O2 -pg -fno-rtti -pie -gstabs -g3 -Wall -c $(SRCS) $(INCZ) $(DEFS)
ar rc $(OUT) *.o
sq64:
gcc -O2 -D_SQ64 -fno-rtti -Wall -c $(SRCS) $(INCZ) $(DEFS)
ar rc $(OUT) *.o
clean:
rm -f $(OUT) $(SRCS:%.cpp=%.o)

View File

@@ -66,7 +66,7 @@ public:
static SQChar temp[256];
va_list vl;
va_start(vl, s);
scvsprintf(temp, s, vl);
scvsnprintf(temp, sizeof(temp), s, vl);
va_end(vl);
throw temp;
}

View File

@@ -1,302 +0,0 @@
# Microsoft Developer Studio Project File - Name="squirrel" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=squirrel - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "squirrel.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "squirrel.mak" CFG="squirrel - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "squirrel - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "squirrel - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_LocalPath ".."
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "squirrel - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "GARBAGE_COLLECTOR" /YX /FD /c
# ADD BASE RSC /l 0x410 /d "NDEBUG"
# ADD RSC /l 0x410 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\lib\squirrel.lib"
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "GARBAGE_COLLECTOR" /YX /FD /GZ /c
# ADD BASE RSC /l 0x410 /d "_DEBUG"
# ADD RSC /l 0x410 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\lib\squirrel.lib"
!ENDIF
# Begin Target
# Name "squirrel - Win32 Release"
# Name "squirrel - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\sqapi.cpp
!IF "$(CFG)" == "squirrel - Win32 Release"
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
# ADD CPP /YX"stdafx.h"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\sqbaselib.cpp
!IF "$(CFG)" == "squirrel - Win32 Release"
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
# ADD CPP /YX"stdafx.h"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\sqcompiler.cpp
!IF "$(CFG)" == "squirrel - Win32 Release"
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
# ADD CPP /YX"stdafx.h"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\sqdebug.cpp
!IF "$(CFG)" == "squirrel - Win32 Release"
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
# ADD CPP /YX"stdafx.h"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\sqfuncstate.cpp
!IF "$(CFG)" == "squirrel - Win32 Release"
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
# ADD CPP /YX"stdafx.h"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\sqlexer.cpp
!IF "$(CFG)" == "squirrel - Win32 Release"
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
# ADD CPP /YX"stdafx.h"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\sqmem.cpp
# End Source File
# Begin Source File
SOURCE=.\sqobject.cpp
!IF "$(CFG)" == "squirrel - Win32 Release"
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
# ADD CPP /YX"stdafx.h"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\sqstate.cpp
!IF "$(CFG)" == "squirrel - Win32 Release"
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
# ADD CPP /YX"stdafx.h"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\sqtable.cpp
!IF "$(CFG)" == "squirrel - Win32 Release"
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
# ADD CPP /YX"stdafx.h"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\sqclass.cpp
!IF "$(CFG)" == "squirrel - Win32 Release"
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
# ADD CPP /YX"stdafx.h"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\sqvm.cpp
!IF "$(CFG)" == "squirrel - Win32 Release"
!ELSEIF "$(CFG)" == "squirrel - Win32 Debug"
# ADD CPP /YX"stdafx.h"
!ENDIF
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\sqarray.h
# End Source File
# Begin Source File
SOURCE=.\sqclosure.h
# End Source File
# Begin Source File
SOURCE=.\sqcompiler.h
# End Source File
# Begin Source File
SOURCE=.\sqfuncproto.h
# End Source File
# Begin Source File
SOURCE=.\sqfuncstate.h
# End Source File
# Begin Source File
SOURCE=.\sqlexer.h
# End Source File
# Begin Source File
SOURCE=.\sqobject.h
# End Source File
# Begin Source File
SOURCE=.\sqopcodes.h
# End Source File
# Begin Source File
SOURCE=.\sqpcheader.h
# End Source File
# Begin Source File
SOURCE=.\sqstate.h
# End Source File
# Begin Source File
SOURCE=.\sqstring.h
# End Source File
# Begin Source File
SOURCE=.\sqtable.h
# End Source File
# Begin Source File
SOURCE=.\squserdata.h
# End Source File
# Begin Source File
SOURCE=.\squtils.h
# End Source File
# Begin Source File
SOURCE=.\sqclass.h
# End Source File
# Begin Source File
SOURCE=.\sqvm.h
# End Source File
# End Group
# End Target
# End Project

View File

@@ -853,7 +853,7 @@ struct AIConfigWindow : public Window {
case WID_AIC_GAMELIST: {
this->selected_slot = OWNER_DEITY;
this->InvalidateData();
if (click_count > 1 && this->selected_slot != INVALID_COMPANY) ShowAIListWindow((CompanyID)this->selected_slot);
if (click_count > 1 && this->selected_slot != INVALID_COMPANY && _game_mode != GM_NORMAL) ShowAIListWindow((CompanyID)this->selected_slot);
break;
}

View File

@@ -44,7 +44,7 @@ void CcBuildAirport(const CommandCost &result, TileIndex tile, uint32 p1, uint32
{
if (result.Failed()) return;
if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_SPLAT, tile);
if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_SPLAT_OTHER, tile);
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
}
@@ -226,8 +226,27 @@ public:
this->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
this->OnInvalidateData();
this->vscroll->SetCount(AirportClass::Get(_selected_airport_class)->GetSpecCount());
this->SelectFirstAvailableAirport(true);
/* Ensure airport class is valid (changing NewGRFs). */
_selected_airport_class = Clamp(_selected_airport_class, APC_BEGIN, (AirportClassID)(AirportClass::GetClassCount() - 1));
const AirportClass *ac = AirportClass::Get(_selected_airport_class);
this->vscroll->SetCount(ac->GetSpecCount());
/* Ensure the airport index is valid for this class (changing NewGRFs). */
_selected_airport_index = Clamp(_selected_airport_index, -1, ac->GetSpecCount() - 1);
/* Only when no valid airport was selected, we want to select the first airport. */
bool selectFirstAirport = true;
if (_selected_airport_index != -1) {
const AirportSpec *as = ac->GetSpec(_selected_airport_index);
if (as->IsAvailable()) {
/* Ensure the airport layout is valid. */
_selected_airport_layout = Clamp(_selected_airport_layout, 0, as->num_table - 1);
selectFirstAirport = false;
this->UpdateSelectSize();
}
}
if (selectFirstAirport) this->SelectFirstAvailableAirport(true);
}
virtual ~BuildAirportWindow()

View File

@@ -160,6 +160,41 @@ CargoArray GetCapacityOfArticulatedParts(EngineID engine)
return capacity;
}
/**
* Get the default cargoes and refits of an articulated vehicle.
* The refits are linked to a cargo rather than an articulated part to prevent a long list of parts.
* @param engine Model to investigate.
* @param[out] cargoes Total amount of units that can be transported, summed by cargo.
* @param[out] refits Whether a (possibly partial) refit for each cargo is possible.
*/
void GetArticulatedVehicleCargoesAndRefits(EngineID engine, CargoArray *cargoes, uint32 *refits)
{
cargoes->Clear();
*refits = 0;
const Engine *e = Engine::Get(engine);
CargoID cargo_type;
uint16 cargo_capacity = GetVehicleDefaultCapacity(engine, &cargo_type);
if (cargo_type < NUM_CARGO && cargo_capacity > 0) {
(*cargoes)[cargo_type] += cargo_capacity;
if (IsEngineRefittable(engine)) SetBit(*refits, cargo_type);
}
if (!e->IsGroundVehicle() || !HasBit(e->info.callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return;
for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) {
EngineID artic_engine = GetNextArticulatedPart(i, engine);
if (artic_engine == INVALID_ENGINE) break;
cargo_capacity = GetVehicleDefaultCapacity(artic_engine, &cargo_type);
if (cargo_type < NUM_CARGO && cargo_capacity > 0) {
(*cargoes)[cargo_type] += cargo_capacity;
if (IsEngineRefittable(artic_engine)) SetBit(*refits, cargo_type);
}
}
}
/**
* Checks whether any of the articulated parts is refittable
* @param engine the first part

View File

@@ -276,10 +276,8 @@ public:
}
case WID_RV_INFO_TAB: {
SetDParam(0, STR_REPLACE_NOT_REPLACING);
Dimension d = GetStringBoundingBox(STR_BLACK_STRING);
SetDParam(0, STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED);
d = maxdim(d, GetStringBoundingBox(STR_BLACK_STRING));
Dimension d = GetStringBoundingBox(STR_REPLACE_NOT_REPLACING);
d = maxdim(d, GetStringBoundingBox(STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED));
d.width += WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT;
d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
*size = maxdim(*size, d);
@@ -351,20 +349,21 @@ public:
switch (widget) {
case WID_RV_INFO_TAB: {
const Company *c = Company::Get(_local_company);
StringID str;
if (this->sel_engine[0] != INVALID_ENGINE) {
if (!EngineHasReplacementForCompany(c, this->sel_engine[0], this->sel_group)) {
SetDParam(0, STR_REPLACE_NOT_REPLACING);
str = STR_REPLACE_NOT_REPLACING;
} else {
bool when_old = false;
EngineID e = EngineReplacementForCompany(c, this->sel_engine[0], this->sel_group, &when_old);
SetDParam(0, when_old ? STR_REPLACE_REPLACING_WHEN_OLD : STR_ENGINE_NAME);
SetDParam(1, e);
str = when_old ? STR_REPLACE_REPLACING_WHEN_OLD : STR_ENGINE_NAME;
SetDParam(0, e);
}
} else {
SetDParam(0, STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED);
str = STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED;
}
DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, r.top + WD_FRAMERECT_TOP, STR_BLACK_STRING, TC_FROMSTRING, SA_HOR_CENTER);
DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, r.top + WD_FRAMERECT_TOP, str, TC_BLACK, SA_HOR_CENTER);
break;
}

View File

@@ -100,7 +100,7 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
/* Then find the MD5 checksum */
item = md5s->GetItem(filename, false);
if (item == NULL) {
if (item == NULL || item->value == NULL) {
DEBUG(grf, 0, "No MD5 checksum specified for: %s (in %s)", filename, full_filename);
return false;
}

View File

@@ -133,6 +133,46 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
}
break;
case BM_CRASH_REMAP:
if (src_px->a == 255) {
do {
uint m = *src_n;
if (m == 0) {
uint8 g = MakeDark(src_px->r, src_px->g, src_px->b);
*dst = ComposeColourRGBA(g, g, g, src_px->a, *dst);
*anim = 0;
} else {
uint r = remap[GB(m, 0, 8)];
*anim = r | (m & 0xFF00);
if (r != 0) *dst = this->AdjustBrightness(this->LookupColourInPalette(r), GB(m, 8, 8));
}
anim++;
dst++;
src_px++;
src_n++;
} while (--n != 0);
} else {
do {
uint m = *src_n;
if (m == 0) {
if (src_px->a != 0) {
uint8 g = MakeDark(src_px->r, src_px->g, src_px->b);
*dst = ComposeColourRGBA(g, g, g, src_px->a, *dst);
*anim = 0;
}
} else {
uint r = remap[GB(m, 0, 8)];
*anim = 0;
if (r != 0) *dst = ComposeColourPANoCheck(this->AdjustBrightness(this->LookupColourInPalette(r), GB(m, 8, 8)), src_px->a, *dst);
}
anim++;
dst++;
src_px++;
src_n++;
} while (--n != 0);
}
break;
case BM_TRANSPARENT:
/* TODO -- We make an assumption here that the remap in fact is transparency, not some colour.
* This is never a problem with the code we produce, but newgrfs can make it fail... or at least:
@@ -208,6 +248,7 @@ void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomL
case BM_NORMAL: Draw<BM_NORMAL> (bp, zoom); return;
case BM_COLOUR_REMAP: Draw<BM_COLOUR_REMAP>(bp, zoom); return;
case BM_TRANSPARENT: Draw<BM_TRANSPARENT> (bp, zoom); return;
case BM_CRASH_REMAP: Draw<BM_CRASH_REMAP> (bp, zoom); return;
}
}
@@ -439,7 +480,7 @@ void Blitter_32bppAnim::PaletteAnimate(const Palette &palette)
}
/* Make sure the backend redraws the whole screen */
_video_driver->MakeDirty(0, 0, _screen.width, _screen.height);
VideoDriver::GetInstance()->MakeDirty(0, 0, _screen.width, _screen.height);
}
Blitter::PaletteAnimation Blitter_32bppAnim::UsePaletteAnimation()

View File

@@ -313,6 +313,25 @@ bmcr_alpha_blend_single:
if (src[0].a) anim[0] = 0;
}
break;
case BM_CRASH_REMAP:
for (uint x = (uint) bp->width; x > 0; x--) {
if (src_mv->m == 0) {
if (src->a != 0) {
uint8 g = MakeDark(src->r, src->g, src->b);
*dst = ComposeColourRGBA(g, g, g, src->a, *dst);
*anim = 0;
}
} else {
uint r = remap[src_mv->m];
if (r != 0) *dst = ComposeColourPANoCheck(this->AdjustBrightness(this->LookupColourInPalette(r), src_mv->v), src->a, *dst);
}
src_mv++;
dst++;
src++;
anim++;
}
break;
}
next_line:
@@ -373,6 +392,7 @@ bm_normal:
}
break;
case BM_TRANSPARENT: Draw<BM_TRANSPARENT, RM_NONE, BT_NONE, true, true>(bp, zoom); return;
case BM_CRASH_REMAP: Draw<BM_CRASH_REMAP, RM_NONE, BT_NONE, true, true>(bp, zoom); return;
}
}

View File

@@ -112,6 +112,19 @@ public:
return Colour(r * nom / denom, g * nom / denom, b * nom / denom);
}
/**
* Make a colour dark grey, for specialized 32bpp remapping.
* @param r red component
* @param g green component
* @param b blue component
* @return the brightness value of the new colour, now dark grey.
*/
static inline uint8 MakeDark(uint8 r, uint8 g, uint8 b)
{
/* Magic-numbers are ~66% of those used in MakeGrey() */
return ((r * 13063) + (g * 25647) + (b * 4981)) / 65536;
}
/**
* Make a colour grey - based.
* @param colour the colour to make grey.

View File

@@ -141,6 +141,40 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
}
break;
case BM_CRASH_REMAP:
if (src_px->a == 255) {
do {
uint m = *src_n;
if (m == 0) {
uint8 g = MakeDark(src_px->r, src_px->g, src_px->b);
*dst = ComposeColourRGBA(g, g, g, src_px->a, *dst);
} else {
uint r = remap[GB(m, 0, 8)];
if (r != 0) *dst = this->AdjustBrightness(this->LookupColourInPalette(r), GB(m, 8, 8));
}
dst++;
src_px++;
src_n++;
} while (--n != 0);
} else {
do {
uint m = *src_n;
if (m == 0) {
if (src_px->a != 0) {
uint8 g = MakeDark(src_px->r, src_px->g, src_px->b);
*dst = ComposeColourRGBA(g, g, g, src_px->a, *dst);
}
} else {
uint r = remap[GB(m, 0, 8)];
if (r != 0) *dst = ComposeColourPANoCheck(this->AdjustBrightness(this->LookupColourInPalette(r), GB(m, 8, 8)), src_px->a, *dst);
}
dst++;
src_px++;
src_n++;
} while (--n != 0);
}
break;
case BM_TRANSPARENT:
/* TODO -- We make an assumption here that the remap in fact is transparency, not some colour.
* This is never a problem with the code we produce, but newgrfs can make it fail... or at least:
@@ -204,6 +238,7 @@ void Blitter_32bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode,
case BM_NORMAL: Draw<BM_NORMAL> (bp, zoom); return;
case BM_COLOUR_REMAP: Draw<BM_COLOUR_REMAP>(bp, zoom); return;
case BM_TRANSPARENT: Draw<BM_TRANSPARENT> (bp, zoom); return;
case BM_CRASH_REMAP: Draw<BM_CRASH_REMAP> (bp, zoom); return;
}
}

View File

@@ -45,6 +45,17 @@ void Blitter_32bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoo
}
break;
case BM_CRASH_REMAP:
if (src->m == 0) {
if (src->a != 0) {
uint8 g = MakeDark(src->r, src->g, src->b);
*dst = ComposeColourRGBA(g, g, g, src->a, *dst);
}
} else {
if (bp->remap[src->m] != 0) *dst = ComposeColourPA(this->AdjustBrightness(this->LookupColourInPalette(bp->remap[src->m]), src->v), src->a, *dst);
}
break;
case BM_TRANSPARENT:
/* TODO -- We make an assumption here that the remap in fact is transparency, not some colour.
* This is never a problem with the code we produce, but newgrfs can make it fail... or at least:

View File

@@ -36,6 +36,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::Sprite *sprite, Alloca
/* Calculate sizes and allocate. */
SpriteData sd;
memset(&sd, 0, sizeof(sd));
uint all_sprites_size = 0;
for (ZoomLevel z = zoom_min; z <= zoom_max; z++) {
const SpriteLoader::Sprite *src_sprite = &sprite[z];

View File

@@ -238,13 +238,13 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel
for (int y = bp->height; y != 0; y--) {
Colour *dst = dst_line;
const Colour *src = src_rgba_line + META_LENGTH;
if (mode == BM_COLOUR_REMAP) src_mv = src_mv_line;
if (mode == BM_COLOUR_REMAP || mode == BM_CRASH_REMAP) src_mv = src_mv_line;
if (read_mode == RM_WITH_MARGIN) {
assert(bt_last == BT_NONE); // or you must ensure block type is preserved
src += src_rgba_line[0].data;
dst += src_rgba_line[0].data;
if (mode == BM_COLOUR_REMAP) src_mv += src_rgba_line[0].data;
if (mode == BM_COLOUR_REMAP || mode == BM_CRASH_REMAP) src_mv += src_rgba_line[0].data;
const int width_diff = si->sprite_width - bp->width;
effective_width = bp->width - (int) src_rgba_line[0].data;
const int delta_diff = (int) src_rgba_line[1].data - width_diff;
@@ -377,10 +377,27 @@ bmcr_alpha_blend_single:
dst->data = _mm_cvtsi128_si32(DarkenTwoPixels(srcABCD, dstABCD, DARKEN_PARAM_1, DARKEN_PARAM_2));
}
break;
case BM_CRASH_REMAP:
for (uint x = (uint) bp->width; x > 0; x--) {
if (src_mv->m == 0) {
if (src->a != 0) {
uint8 g = MakeDark(src->r, src->g, src->b);
*dst = ComposeColourRGBA(g, g, g, src->a, *dst);
}
} else {
uint r = remap[src_mv->m];
if (r != 0) *dst = ComposeColourPANoCheck(this->AdjustBrightness(this->LookupColourInPalette(r), src_mv->v), src->a, *dst);
}
src_mv++;
dst++;
src++;
}
break;
}
next_line:
if (mode == BM_COLOUR_REMAP) src_mv_line += si->sprite_width;
if (mode == BM_COLOUR_REMAP || mode == BM_CRASH_REMAP) src_mv_line += si->sprite_width;
src_rgba_line = (const Colour*) ((const byte*) src_rgba_line + si->sprite_line_size);
dst_line += bp->pitch;
}
@@ -429,6 +446,7 @@ bm_normal:
Draw<BM_COLOUR_REMAP, RM_WITH_MARGIN, BT_NONE, true>(bp, zoom); return;
}
case BM_TRANSPARENT: Draw<BM_TRANSPARENT, RM_NONE, BT_NONE, true>(bp, zoom); return;
case BM_CRASH_REMAP: Draw<BM_CRASH_REMAP, RM_NONE, BT_NONE, true>(bp, zoom); return;
}
}
#endif /* FULL_ANIMATION */

View File

@@ -83,7 +83,8 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z
width -= pixels;
switch (mode) {
case BM_COLOUR_REMAP: {
case BM_COLOUR_REMAP:
case BM_CRASH_REMAP: {
const uint8 *remap = bp->remap;
do {
uint m = remap[*src];

View File

@@ -37,6 +37,7 @@ void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoom
switch (mode) {
case BM_COLOUR_REMAP:
case BM_CRASH_REMAP:
colour = bp->remap[*src];
break;

View File

@@ -20,6 +20,7 @@ enum BlitterMode {
BM_NORMAL, ///< Perform the simple blitting.
BM_COLOUR_REMAP, ///< Perform a colour remapping.
BM_TRANSPARENT, ///< Perform transparency colour remapping.
BM_CRASH_REMAP, ///< Perform a crash remapping.
};
/**

View File

@@ -244,7 +244,7 @@ bool HandleBootstrap()
new BootstrapAskForDownloadWindow();
/* Process the user events. */
_video_driver->MainLoop();
VideoDriver::GetInstance()->MainLoop();
/* _exit_game is used to get out of the video driver's main loop.
* In case GM_BOOTSTRAP is still set we did not exit it via the

View File

@@ -526,21 +526,20 @@ static GUIEngineList::FilterFunction * const _filter_funcs[] = {
&CargoFilter,
};
static int DrawCargoCapacityInfo(int left, int right, int y, EngineID engine, bool refittable)
static int DrawCargoCapacityInfo(int left, int right, int y, EngineID engine)
{
CargoArray cap = GetCapacityOfArticulatedParts(engine);
CargoArray cap;
uint32 refits;
GetArticulatedVehicleCargoesAndRefits(engine, &cap, &refits);
for (CargoID c = 0; c < NUM_CARGO; c++) {
if (cap[c] == 0) continue;
SetDParam(0, c);
SetDParam(1, cap[c]);
SetDParam(2, refittable ? STR_PURCHASE_INFO_REFITTABLE : STR_EMPTY);
SetDParam(2, HasBit(refits, c) ? STR_PURCHASE_INFO_REFITTABLE : STR_EMPTY);
DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
y += FONT_HEIGHT_NORMAL;
/* Only show as refittable once */
refittable = false;
}
return y;
@@ -825,7 +824,7 @@ int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number)
if (articulated_cargo) {
/* Cargo type + capacity, or N/A */
int new_y = DrawCargoCapacityInfo(left, right, y, engine_number, refittable);
int new_y = DrawCargoCapacityInfo(left, right, y, engine_number);
if (new_y == y) {
SetDParam(0, CT_INVALID);

View File

@@ -67,7 +67,7 @@ void ClearCargoDeliveryMonitoring(CompanyID company)
* @param keep_monitoring After returning from this call, continue monitoring.
* @return Amount collected since last query/activation for the monitored combination.
*/
static uint32 GetAmount(CargoMonitorMap &monitor_map, CargoMonitorID monitor, bool keep_monitoring)
static int32 GetAmount(CargoMonitorMap &monitor_map, CargoMonitorID monitor, bool keep_monitoring)
{
CargoMonitorMap::iterator iter = monitor_map.find(monitor);
if (iter == monitor_map.end()) {
@@ -77,7 +77,7 @@ static uint32 GetAmount(CargoMonitorMap &monitor_map, CargoMonitorID monitor, bo
}
return 0;
} else {
uint32 result = iter->second;
int32 result = iter->second;
iter->second = 0;
if (!keep_monitoring) monitor_map.erase(iter);
return result;
@@ -90,7 +90,7 @@ static uint32 GetAmount(CargoMonitorMap &monitor_map, CargoMonitorID monitor, bo
* @param keep_monitoring After returning from this call, continue monitoring.
* @return Amount of delivered cargo for the monitored combination.
*/
uint32 GetDeliveryAmount(CargoMonitorID monitor, bool keep_monitoring)
int32 GetDeliveryAmount(CargoMonitorID monitor, bool keep_monitoring)
{
return GetAmount(_cargo_deliveries, monitor, keep_monitoring);
}
@@ -102,7 +102,7 @@ uint32 GetDeliveryAmount(CargoMonitorID monitor, bool keep_monitoring)
* @return Amount of picked up cargo for the monitored combination.
* @note Cargo pick up is counted on final delivery, to prevent users getting credit for picking up cargo without delivering it.
*/
uint32 GetPickupAmount(CargoMonitorID monitor, bool keep_monitoring)
int32 GetPickupAmount(CargoMonitorID monitor, bool keep_monitoring)
{
return GetAmount(_cargo_pickups, monitor, keep_monitoring);
}

View File

@@ -16,6 +16,7 @@
#include "company_func.h"
#include "industry.h"
#include "town.h"
#include "core/overflowsafe_type.hpp"
#include <map>
struct Station;
@@ -31,7 +32,7 @@ struct Station;
typedef uint32 CargoMonitorID; ///< Type of the cargo monitor number.
/** Map type for storing and updating active cargo monitor numbers and their amounts. */
typedef std::map<CargoMonitorID, uint32> CargoMonitorMap;
typedef std::map<CargoMonitorID, OverflowSafeInt32> CargoMonitorMap;
extern CargoMonitorMap _cargo_pickups;
extern CargoMonitorMap _cargo_deliveries;
@@ -141,8 +142,8 @@ static inline TownID DecodeMonitorTown(CargoMonitorID num)
void ClearCargoPickupMonitoring(CompanyID company = INVALID_OWNER);
void ClearCargoDeliveryMonitoring(CompanyID company = INVALID_OWNER);
uint32 GetDeliveryAmount(CargoMonitorID monitor, bool keep_monitoring);
uint32 GetPickupAmount(CargoMonitorID monitor, bool keep_monitoring);
int32 GetDeliveryAmount(CargoMonitorID monitor, bool keep_monitoring);
int32 GetPickupAmount(CargoMonitorID monitor, bool keep_monitoring);
void AddCargoDelivery(CargoID cargo_type, CompanyID company, uint32 amount, SourceType src_type, SourceID src, const Station *st);
#endif /* CARGOMONITOR_H */

View File

@@ -157,7 +157,7 @@ public:
* Gets the ID of the station where the cargo was loaded for the first time.
* @return StationID.
*/
inline SourceID SourceStation() const
inline StationID SourceStation() const
{
return this->source;
}

View File

@@ -246,7 +246,7 @@ static const Command _command_proc_table[] = {
DEF_CMD(CmdForceTrainProceed, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_FORCE_TRAIN_PROCEED
DEF_CMD(CmdReverseTrainDirection, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_REVERSE_TRAIN_DIRECTION
DEF_CMD(CmdClearOrderBackup, CMD_CLIENT_ID, CMDT_ROUTE_MANAGEMENT ), // CMD_CLEAR_ORDER_BACKUP
DEF_CMD(CmdClearOrderBackup, CMD_CLIENT_ID, CMDT_SERVER_SETTING ), // CMD_CLEAR_ORDER_BACKUP
DEF_CMD(CmdModifyOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_MODIFY_ORDER
DEF_CMD(CmdSkipToOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SKIP_TO_ORDER
DEF_CMD(CmdDeleteOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_DELETE_ORDER

View File

@@ -853,59 +853,21 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
MarkWholeScreenDirty();
}
if (_network_server) {
if (ci != NULL) {
/* ci is only NULL when replaying.
* When replaying no client is actually in need of an update. */
ci->client_playas = c->index;
NetworkUpdateClientInfo(ci->client_id);
}
if (Company::IsValidID(c->index)) {
_network_company_states[c->index].months_empty = 0;
_network_company_states[c->index].password[0] = '\0';
NetworkServerUpdateCompanyPassworded(c->index, false);
/* XXX - When a client joins, we automatically set its name to the
* client's name (for some reason). As it stands now only the server
* knows the client's name, so it needs to send out a "broadcast" to
* do this. To achieve this we send a network command. However, it
* uses _local_company to execute the command as. To prevent abuse
* (eg. only yourself can change your name/company), we 'cheat' by
* impersonation _local_company as the server. Not the best solution;
* but it works.
* TODO: Perhaps this could be improved by when the client is ready
* with joining to let it send itself the command, and not the server?
* For example in network_client.c:534? */
if (ci != NULL) {
/* ci is only NULL when replaying.
* When replaying, the command to rename the president will
* automatically be ran, so this is not even needed to get
* the exact same state. */
NetworkSendCommand(0, 0, 0, CMD_RENAME_PRESIDENT, NULL, ci->client_name, c->index);
}
}
/* Announce new company on network. */
NetworkAdminCompanyInfo(c, true);
if (ci != NULL) {
/* ci is only NULL when replaying.
* When replaying, the message that someone started a new company
* is not interesting at all. */
NetworkServerSendChat(NETWORK_ACTION_COMPANY_NEW, DESTTYPE_BROADCAST, 0, "", ci->client_id, c->index + 1);
}
}
NetworkServerNewCompany(c, ci);
#endif /* ENABLE_NETWORK */
break;
}
case 1: // Make a new AI company
case 1: { // Make a new AI company
if (!(flags & DC_EXEC)) return CommandCost();
if (company_id != INVALID_COMPANY && (company_id >= MAX_COMPANIES || Company::IsValidID(company_id))) return CMD_ERROR;
DoStartupNewCompany(true, company_id);
Company *c = DoStartupNewCompany(true, company_id);
#ifdef ENABLE_NETWORK
if (c != NULL) NetworkServerNewCompany(c, NULL);
#endif /* ENABLE_NETWORK */
break;
}
case 2: { // Delete a company
CompanyRemoveReason reason = (CompanyRemoveReason)GB(p2, 0, 2);

View File

@@ -2013,7 +2013,7 @@ struct CompanyWindow : Window
NWidgetStacked *wi = this->GetWidget<NWidgetStacked>(WID_C_SELECT_BUTTONS);
if (plane != wi->shown_plane) {
wi->SetDisplayedPlane(plane);
this->SetDirty();
this->InvalidateData();
return;
}

View File

@@ -185,7 +185,7 @@ struct IConsoleWindow : Window
~IConsoleWindow()
{
_iconsole_mode = ICONSOLE_CLOSED;
_video_driver->EditBoxLostFocus();
VideoDriver::GetInstance()->EditBoxLostFocus();
}
/**
@@ -374,7 +374,7 @@ struct IConsoleWindow : Window
virtual void OnFocusLost()
{
_video_driver->EditBoxLostFocus();
VideoDriver::GetInstance()->EditBoxLostFocus();
}
};

View File

@@ -12,6 +12,7 @@
#ifndef OVERFLOWSAFE_TYPE_HPP
#define OVERFLOWSAFE_TYPE_HPP
#include "math_func.hpp"
/**
* Overflow safe template for integers, i.e. integers that will never overflow
@@ -151,5 +152,6 @@ template <class T, int64 T_MAX, int64 T_MIN> inline OverflowSafeInt<T, T_MAX, T_
template <class T, int64 T_MAX, int64 T_MIN> inline OverflowSafeInt<T, T_MAX, T_MIN> operator / (byte a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return (OverflowSafeInt<T, T_MAX, T_MIN>)a / (int)b; }
typedef OverflowSafeInt<int64, INT64_MAX, INT64_MIN> OverflowSafeInt64;
typedef OverflowSafeInt<int32, INT32_MAX, INT32_MIN> OverflowSafeInt32;
#endif /* OVERFLOWSAFE_TYPE_HPP */

View File

@@ -138,14 +138,14 @@ char *CrashLog::LogConfiguration(char *buffer, const char *last) const
BaseGraphics::GetUsedSet() == NULL ? "none" : BaseGraphics::GetUsedSet()->name,
BaseGraphics::GetUsedSet() == NULL ? UINT32_MAX : BaseGraphics::GetUsedSet()->version,
_current_language == NULL ? "none" : _current_language->file,
_music_driver == NULL ? "none" : _music_driver->GetName(),
MusicDriver::GetInstance() == NULL ? "none" : MusicDriver::GetInstance()->GetName(),
BaseMusic::GetUsedSet() == NULL ? "none" : BaseMusic::GetUsedSet()->name,
BaseMusic::GetUsedSet() == NULL ? UINT32_MAX : BaseMusic::GetUsedSet()->version,
_networking ? (_network_server ? "server" : "client") : "no",
_sound_driver == NULL ? "none" : _sound_driver->GetName(),
SoundDriver::GetInstance() == NULL ? "none" : SoundDriver::GetInstance()->GetName(),
BaseSounds::GetUsedSet() == NULL ? "none" : BaseSounds::GetUsedSet()->name,
BaseSounds::GetUsedSet() == NULL ? UINT32_MAX : BaseSounds::GetUsedSet()->version,
_video_driver == NULL ? "none" : _video_driver->GetName()
VideoDriver::GetInstance() == NULL ? "none" : VideoDriver::GetInstance()->GetName()
);
buffer += seprintf(buffer, last,
@@ -482,7 +482,7 @@ bool CrashLog::MakeCrashLog() const
*/
/* static */ void CrashLog::AfterCrashLogCleanup()
{
if (_music_driver != NULL) _music_driver->Stop();
if (_sound_driver != NULL) _sound_driver->Stop();
if (_video_driver != NULL) _video_driver->Stop();
if (MusicDriver::GetInstance() != NULL) MusicDriver::GetInstance()->Stop();
if (SoundDriver::GetInstance() != NULL) SoundDriver::GetInstance()->Stop();
if (VideoDriver::GetInstance() != NULL) VideoDriver::GetInstance()->Stop();
}

View File

@@ -73,7 +73,7 @@ struct SetDateWindow : Window {
case WID_SD_DAY:
for (uint i = 0; i < 31; i++) {
*list->Append() = new DropDownListStringItem(STR_ORDINAL_NUMBER_1ST + i, i + 1, false);
*list->Append() = new DropDownListStringItem(STR_DAY_NUMBER_1ST + i, i + 1, false);
}
selected = this->date.day;
break;
@@ -106,7 +106,7 @@ struct SetDateWindow : Window {
case WID_SD_DAY:
for (uint i = 0; i < 31; i++) {
d = maxdim(d, GetStringBoundingBox(STR_ORDINAL_NUMBER_1ST + i));
d = maxdim(d, GetStringBoundingBox(STR_DAY_NUMBER_1ST + i));
}
break;
@@ -130,7 +130,7 @@ struct SetDateWindow : Window {
virtual void SetStringParameters(int widget) const
{
switch (widget) {
case WID_SD_DAY: SetDParam(0, this->date.day - 1 + STR_ORDINAL_NUMBER_1ST); break;
case WID_SD_DAY: SetDParam(0, this->date.day - 1 + STR_DAY_NUMBER_1ST); break;
case WID_SD_MONTH: SetDParam(0, this->date.month + STR_MONTH_JAN); break;
case WID_SD_YEAR: SetDParam(0, this->date.year); break;
}

View File

@@ -41,13 +41,13 @@ void CcBuildDocks(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p
{
if (result.Failed()) return;
if (_settings_client.sound.confirm) SndPlayTileFx(SND_02_SPLAT, tile);
if (_settings_client.sound.confirm) SndPlayTileFx(SND_02_SPLAT_WATER, tile);
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
}
void CcBuildCanal(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_02_SPLAT, tile);
if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_02_SPLAT_WATER, tile);
}

View File

@@ -16,17 +16,14 @@
#include "video/video_driver.hpp"
#include "string_func.h"
VideoDriver *_video_driver; ///< The currently active video driver.
char *_ini_videodriver; ///< The video driver a stored in the configuration file.
int _num_resolutions; ///< The number of resolutions.
Dimension _resolutions[32]; ///< List of resolutions.
Dimension _cur_resolution; ///< The current resolution.
bool _rightclick_emulate; ///< Whether right clicking is emulated.
SoundDriver *_sound_driver; ///< The currently active sound driver.
char *_ini_sounddriver; ///< The sound driver a stored in the configuration file.
MusicDriver *_music_driver; ///< The currently active music driver.
char *_ini_musicdriver; ///< The music driver a stored in the configuration file.
char *_ini_blitter; ///< The blitter as stored in the configuration file.
@@ -86,9 +83,25 @@ int GetDriverParamInt(const char * const *parm, const char *name, int def)
* @param type the type of driver to select
* @post Sets the driver so GetCurrentDriver() returns it too.
*/
Driver *DriverFactoryBase::SelectDriver(const char *name, Driver::Type type)
void DriverFactoryBase::SelectDriver(const char *name, Driver::Type type)
{
if (GetDrivers().size() == 0) return NULL;
if (!DriverFactoryBase::SelectDriverImpl(name, type)) {
StrEmpty(name) ?
usererror("Failed to autoprobe %s driver", GetDriverTypeName(type)) :
usererror("Failed to select requested %s driver '%s'", GetDriverTypeName(type), name);
}
}
/**
* Find the requested driver and return its class.
* @param name the driver to select.
* @param type the type of driver to select
* @post Sets the driver so GetCurrentDriver() returns it too.
* @return True upon success, otherwise false.
*/
bool DriverFactoryBase::SelectDriverImpl(const char *name, Driver::Type type)
{
if (GetDrivers().size() == 0) return false;
if (StrEmpty(name)) {
/* Probe for this driver, but do not fall back to dedicated/null! */
@@ -101,15 +114,18 @@ Driver *DriverFactoryBase::SelectDriver(const char *name, Driver::Type type)
if (d->type != type) continue;
if (d->priority != priority) continue;
Driver *oldd = *GetActiveDriver(type);
Driver *newd = d->CreateInstance();
*GetActiveDriver(type) = newd;
const char *err = newd->Start(NULL);
if (err == NULL) {
DEBUG(driver, 1, "Successfully probed %s driver '%s'", GetDriverTypeName(type), d->name);
delete *GetActiveDriver(type);
*GetActiveDriver(type) = newd;
return newd;
delete oldd;
return true;
}
*GetActiveDriver(type) = oldd;
DEBUG(driver, 1, "Probing %s driver '%s' failed with error: %s", GetDriverTypeName(type), d->name, err);
delete newd;
}
@@ -158,7 +174,7 @@ Driver *DriverFactoryBase::SelectDriver(const char *name, Driver::Type type)
DEBUG(driver, 1, "Successfully loaded %s driver '%s'", GetDriverTypeName(type), d->name);
delete *GetActiveDriver(type);
*GetActiveDriver(type) = newd;
return newd;
return true;
}
usererror("No such %s driver: %s\n", GetDriverTypeName(type), buffer);
}

View File

@@ -59,6 +59,10 @@ DECLARE_POSTFIX_INCREMENT(Driver::Type)
/** Base for all driver factories. */
class DriverFactoryBase {
private:
friend class MusicDriver;
friend class SoundDriver;
friend class VideoDriver;
Driver::Type type; ///< The type of driver.
int priority; ///< The priority of this factory.
const char *name; ///< The name of the drivers of this factory.
@@ -97,6 +101,8 @@ private:
return driver_type_name[type];
}
static bool SelectDriverImpl(const char *name, Driver::Type type);
protected:
DriverFactoryBase(Driver::Type type, int priority, const char *name, const char *description);
@@ -114,7 +120,7 @@ public:
}
}
static Driver *SelectDriver(const char *name, Driver::Type type);
static void SelectDriver(const char *name, Driver::Type type);
static char *GetDriversInfo(char *p, const char *last);
/**

View File

@@ -19,6 +19,7 @@
#include "network/network_func.h"
#include "ai/ai.hpp"
#include "aircraft.h"
#include "train.h"
#include "newgrf_engine.h"
#include "engine_base.h"
#include "ground_vehicle.hpp"
@@ -1066,9 +1067,9 @@ static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, Ti
/* Update station statistics */
if (accepted > 0) {
SetBit(st->goods[cargo_type].acceptance_pickup, GoodsEntry::GES_EVER_ACCEPTED);
SetBit(st->goods[cargo_type].acceptance_pickup, GoodsEntry::GES_CURRENT_MONTH);
SetBit(st->goods[cargo_type].acceptance_pickup, GoodsEntry::GES_ACCEPTED_BIGTICK);
SetBit(st->goods[cargo_type].status, GoodsEntry::GES_EVER_ACCEPTED);
SetBit(st->goods[cargo_type].status, GoodsEntry::GES_CURRENT_MONTH);
SetBit(st->goods[cargo_type].status, GoodsEntry::GES_ACCEPTED_BIGTICK);
}
/* Update company statistics */
@@ -1240,7 +1241,7 @@ void PrepareUnload(Vehicle *front_v)
const GoodsEntry *ge = &st->goods[v->cargo_type];
if (v->cargo_cap > 0 && v->cargo.TotalCount() > 0) {
v->cargo.Stage(
HasBit(ge->acceptance_pickup, GoodsEntry::GES_ACCEPTANCE),
HasBit(ge->status, GoodsEntry::GES_ACCEPTANCE),
front_v->last_station_visited, next_station,
front_v->current_order.GetUnloadType(), ge,
front_v->cargo_payment);
@@ -1338,21 +1339,135 @@ static void ReserveConsist(Station *st, Vehicle *u, CargoArray *consist_capleft,
}
/**
* Checks whether an articulated vehicle is empty.
* @param v Vehicle
* @return true if all parts are empty.
* Iterate the articulated parts of a vehicle, also considering the special cases of "normal"
* aircraft and double headed trains. Apply an action to each vehicle and immediately return false
* if that action does so. Otherwise return true.
* @tparam Taction Class of action to be applied. Must implement bool operator()([const] Vehicle *).
* @param v First articulated part.
* @param action Instance of Taction.
* @return false if any of the action invocations returned false, true otherwise.
*/
static bool IsArticulatedVehicleEmpty(Vehicle *v)
template<class Taction>
bool IterateVehicleParts(Vehicle *v, Taction action)
{
v = v->GetFirstEnginePart();
for (; v != NULL; v = v->HasArticulatedPart() ? v->GetNextArticulatedPart() : NULL) {
if (v->cargo.StoredCount() != 0) return false;
for (Vehicle *w = v; w != NULL;
w = w->HasArticulatedPart() ? w->GetNextArticulatedPart() : NULL) {
if (!action(w)) return false;
if (w->type == VEH_TRAIN) {
Train *train = Train::From(w);
if (train->IsMultiheaded() && !action(train->other_multiheaded_part)) return false;
}
}
if (v->type == VEH_AIRCRAFT && Aircraft::From(v)->IsNormalAircraft()) return action(v->Next());
return true;
}
/**
* Action to check if a vehicle has no stored cargo.
*/
struct IsEmptyAction
{
/**
* Checks if the vehicle has stored cargo.
* @param v Vehicle to be checked.
* @return true if v is either empty or has only reserved cargo, false otherwise.
*/
bool operator()(const Vehicle *v)
{
return v->cargo.StoredCount() == 0;
}
};
/**
* Refit preparation action.
*/
struct PrepareRefitAction
{
CargoArray &consist_capleft; ///< Capacities left in the consist.
uint32 &refit_mask; ///< Bitmask of possible refit cargoes.
/**
* Create a refit preparation action.
* @param consist_capleft Capacities left in consist, to be updated here.
* @param refit_mask Refit mask to be constructed from refit information of vehicles.
*/
PrepareRefitAction(CargoArray &consist_capleft, uint32 &refit_mask) :
consist_capleft(consist_capleft), refit_mask(refit_mask) {}
/**
* Prepares for refitting of a vehicle, subtracting its free capacity from consist_capleft and
* adding the cargoes it can refit to to the refit mask.
* @param v The vehicle to be refitted.
* @return true.
*/
bool operator()(const Vehicle *v)
{
this->consist_capleft[v->cargo_type] -= v->cargo_cap - v->cargo.ReservedCount();
this->refit_mask |= EngInfo(v->engine_type)->refit_mask;
return true;
}
};
/**
* Action for returning reserved cargo.
*/
struct ReturnCargoAction
{
Station *st; ///< Station to give the returned cargo to.
StationID next_hop; ///< Next hop the cargo should be assigned to.
/**
* Construct a cargo return action.
* @param st Station to give the returned cargo to.
* @param next_one Next hop the cargo should be assigned to.
*/
ReturnCargoAction(Station *st, StationID next_one) : st(st), next_hop(next_one) {}
/**
* Return all reserved cargo from a vehicle.
* @param v Vehicle to return cargo from.
* @return true.
*/
bool operator()(Vehicle *v)
{
v->cargo.Return(UINT_MAX, &this->st->goods[v->cargo_type].cargo, this->next_hop);
return true;
}
};
/**
* Action for finalizing a refit.
*/
struct FinalizeRefitAction
{
CargoArray &consist_capleft; ///< Capacities left in the consist.
Station *st; ///< Station to reserve cargo from.
StationIDStack &next_station; ///< Next hops to reserve cargo for.
/**
* Create a finalizing action.
* @param consist_capleft Capacities left in the consist.
* @param st Station to reserve cargo from.
* @param next_station Next hops to reserve cargo for.
*/
FinalizeRefitAction(CargoArray &consist_capleft, Station *st, StationIDStack &next_station) :
consist_capleft(consist_capleft), st(st), next_station(next_station) {}
/**
* Reserve cargo from the station and update the remaining consist capacities with the
* vehicle's remaining free capacity.
* @param v Vehicle to be finalized.
* @return true.
*/
bool operator()(Vehicle *v)
{
this->st->goods[v->cargo_type].cargo.Reserve(v->cargo_cap - v->cargo.RemainingCount(),
&v->cargo, st->xy, next_station);
this->consist_capleft[v->cargo_type] += v->cargo_cap - v->cargo.RemainingCount();
return true;
}
};
/**
* Refit a vehicle in a station.
* @param v Vehicle to be refitted.
@@ -1363,32 +1478,15 @@ static bool IsArticulatedVehicleEmpty(Vehicle *v)
*/
static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station *st, StationIDStack next_station, CargoID new_cid)
{
if (v->type == VEH_AIRCRAFT && (!Aircraft::From(v)->IsNormalAircraft() || v->Next()->cargo.StoredCount() > 0)) {
return;
}
bool is_normal_aircraft = (v->type == VEH_AIRCRAFT && Aircraft::From(v)->IsNormalAircraft());
Vehicle *v_start = v->GetFirstEnginePart();
/* Remove old capacity from consist capacity */
consist_capleft[v_start->cargo_type] -= (v_start->cargo_cap - v_start->cargo.ReservedCount());
for (Vehicle *w = v_start; w->HasArticulatedPart(); ) {
w = w->GetNextArticulatedPart();
consist_capleft[w->cargo_type] -= (w->cargo_cap - w->cargo.ReservedCount());
}
if (is_normal_aircraft) {
consist_capleft[v->Next()->cargo_type] -= (v->Next()->cargo_cap - v->Next()->cargo.ReservedCount());
}
if (!IterateVehicleParts(v_start, IsEmptyAction())) return;
Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
/* Check if all articulated parts are empty and collect refit mask. */
uint32 refit_mask = v->GetEngine()->info.refit_mask;
Vehicle *w = v_start;
while (w->HasArticulatedPart()) {
w = w->GetNextArticulatedPart();
refit_mask |= EngInfo(w->engine_type)->refit_mask;
}
/* Remove old capacity from consist capacity and collect refit mask. */
IterateVehicleParts(v_start, PrepareRefitAction(consist_capleft, refit_mask));
if (new_cid == CT_AUTO_REFIT) {
/* Get a refittable cargo type with waiting cargo for next_station or INVALID_STATION. */
@@ -1401,8 +1499,13 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station
DoCommand(v_start->tile, v_start->index, cid | 1U << 6 | 0xFF << 8 | 1U << 16, DC_QUERY_COST, GetCmdRefitVeh(v_start)); // Auto-refit and only this vehicle including artic parts.
/* Try to balance different loadable cargoes between parts of the consist, so that
* all of them can be loaded. Avoid a situation where all vehicles suddenly switch
* to the first loadable cargo for which there is only one packet. */
if (_returned_refit_capacity > 0 && consist_capleft[cid] < consist_capleft[new_cid]) {
* to the first loadable cargo for which there is only one packet. If the capacities
* are equal refit to the cargo of which most is available. This is important for
* consists of only a single vehicle as those will generally have a consist_capleft
* of 0 for all cargoes. */
if (_returned_refit_capacity > 0 && (consist_capleft[cid] < consist_capleft[new_cid] ||
(consist_capleft[cid] == consist_capleft[new_cid] &&
st->goods[cid].cargo.AvailableCount() > st->goods[new_cid].cargo.AvailableCount()))) {
new_cid = cid;
}
}
@@ -1411,31 +1514,17 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station
/* Refit if given a valid cargo. */
if (new_cid < NUM_CARGO && new_cid != v_start->cargo_type) {
StationID next_one = StationIDStack(next_station).Pop();
v_start->cargo.Return(UINT_MAX, &st->goods[v_start->cargo_type].cargo, next_one);
for (w = v_start; w->HasArticulatedPart();) {
w = w->GetNextArticulatedPart();
w->cargo.Return(UINT_MAX, &st->goods[w->cargo_type].cargo, next_one);
}
if (is_normal_aircraft) {
v->Next()->cargo.Return(UINT_MAX, &st->goods[v->Next()->cargo_type].cargo, next_one);
}
/* INVALID_STATION because in the DT_MANUAL case that's correct and in the DT_(A)SYMMETRIC
* cases the next hop of the vehicle doesn't really tell us anything if the cargo had been
* "via any station" before reserving. We rather produce some more "any station" cargo than
* misrouting it. */
IterateVehicleParts(v_start, ReturnCargoAction(st, INVALID_STATION));
CommandCost cost = DoCommand(v_start->tile, v_start->index, new_cid | 1U << 6 | 0xFF << 8 | 1U << 16, DC_EXEC, GetCmdRefitVeh(v_start)); // Auto-refit and only this vehicle including artic parts.
if (cost.Succeeded()) v->First()->profit_this_year -= cost.GetCost() << 8;
}
/* Add new capacity to consist capacity and reserve cargo */
w = v_start;
do {
st->goods[w->cargo_type].cargo.Reserve(w->cargo_cap - w->cargo.RemainingCount(), &w->cargo, st->xy, next_station);
consist_capleft[w->cargo_type] += w->cargo_cap - w->cargo.RemainingCount();
w = w->HasArticulatedPart() ? w->GetNextArticulatedPart() : NULL;
} while (w != NULL);
if (is_normal_aircraft) {
w = v->Next();
st->goods[w->cargo_type].cargo.Reserve(w->cargo_cap - w->cargo.RemainingCount(), &w->cargo, st->xy, next_station);
consist_capleft[w->cargo_type] += w->cargo_cap - w->cargo.RemainingCount();
}
IterateVehicleParts(v_start, FinalizeRefitAction(consist_capleft, st, next_station));
cur_company.Restore();
}
@@ -1505,7 +1594,7 @@ static void LoadUnloadVehicle(Vehicle *front)
payment->SetCargo(v->cargo_type);
if (!HasBit(ge->acceptance_pickup, GoodsEntry::GES_ACCEPTANCE) && v->cargo.ActionCount(VehicleCargoList::MTA_DELIVER) > 0) {
if (!HasBit(ge->status, GoodsEntry::GES_ACCEPTANCE) && v->cargo.ActionCount(VehicleCargoList::MTA_DELIVER) > 0) {
/* The station does not accept our goods anymore. */
if (front->current_order.GetUnloadType() & (OUFB_TRANSFER | OUFB_UNLOAD)) {
/* Transfer instead of delivering. */
@@ -1530,8 +1619,18 @@ static void LoadUnloadVehicle(Vehicle *front)
}
}
/* Mark the station dirty if we transfer, but not if we only deliver. */
dirty_station = v->cargo.ActionCount(VehicleCargoList::MTA_TRANSFER) > 0;
if (v->cargo.ActionCount(VehicleCargoList::MTA_TRANSFER) > 0) {
/* Mark the station dirty if we transfer, but not if we only deliver. */
dirty_station = true;
if (!ge->HasRating()) {
/* Upon transfering cargo, make sure the station has a rating. Fake a pickup for the
* first unload to prevent the cargo from quickly decaying after the initial drop. */
ge->time_since_pickup = 0;
SetBit(ge->status, GoodsEntry::GES_RATING);
}
}
amount_unloaded = v->cargo.Unload(amount_unloaded, &ge->cargo, payment);
remaining = v->cargo.UnloadCount() > 0;
if (amount_unloaded > 0) {
@@ -1557,7 +1656,7 @@ static void LoadUnloadVehicle(Vehicle *front)
if (front->current_order.GetLoadType() & OLFB_NO_LOAD || HasBit(front->vehicle_flags, VF_STOP_LOADING)) continue;
/* This order has a refit, if this is the first vehicle part carrying cargo and the whole vehicle is empty, try refitting. */
if (front->current_order.IsRefit() && artic_part == 1 && IsArticulatedVehicleEmpty(v)) {
if (front->current_order.IsRefit() && artic_part == 1) {
HandleStationRefit(v, consist_capleft, st, next_station, front->current_order.GetRefitCargo());
ge = &st->goods[v->cargo_type];
}
@@ -1740,6 +1839,7 @@ static void LoadUnloadVehicle(Vehicle *front)
if (dirty_station) {
st->MarkTilesDirty(true);
SetWindowDirty(WC_STATION_VIEW, last_visited);
InvalidateWindowData(WC_STATION_LIST, last_visited);
}
}

View File

@@ -26,6 +26,7 @@ extern const uint8 _engine_offsets[4];
bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company);
bool IsEngineRefittable(EngineID engine);
void GetArticulatedVehicleCargoesAndRefits(EngineID engine, CargoArray *cargoes, uint32 *refits);
void SetYearEngineAgingStops();
void StartupOneEngine(Engine *e, Date aging_date);

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