mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-16 11:09:11 +00:00
Compare commits
149 Commits
1.4.0-beta
...
1.4.4-RC1
Author | SHA1 | Date | |
---|---|---|---|
|
46ba435529 | ||
|
7fcd735ebc | ||
|
28bc11a9f1 | ||
|
2147c81162 | ||
|
ee3f8c3ef2 | ||
|
628b52921f | ||
|
cac97612ac | ||
|
4bd5dcb3b4 | ||
|
c37b98b58b | ||
|
b0425dbdc5 | ||
|
9d34dbf080 | ||
|
57f6cb970b | ||
|
6043b839af | ||
|
45bb3caba2 | ||
|
126b11db63 | ||
|
2134c2e905 | ||
|
8e36fb0ada | ||
|
12c3ba3095 | ||
|
0db873d6da | ||
|
17507b217c | ||
|
48bd683010 | ||
|
3614c4447f | ||
|
3630a2cc4e | ||
|
26ed360ccd | ||
|
8dc0522434 | ||
|
13378995d9 | ||
|
1708243e51 | ||
|
324e17d827 | ||
|
bcfc0ec957 | ||
|
5702b3951c | ||
|
491b3e3efc | ||
|
2759e32451 | ||
|
d3c41a9d0e | ||
|
3cd96a459b | ||
|
1d18ef48a4 | ||
|
a6e95ace5c | ||
|
c57b316570 | ||
|
b720a16a1c | ||
|
7a0b2bff18 | ||
|
34bff06d8a | ||
|
be4eae9456 | ||
|
f8b956bc2c | ||
|
42c7cb38fa | ||
|
9d2f06c42c | ||
|
0c2be35fa1 | ||
|
80a3b5e78f | ||
|
8ca5334562 | ||
|
d470955e40 | ||
|
c18ccfe0de | ||
|
2e7230dc2b | ||
|
a7f5ff3f73 | ||
|
7ff5066904 | ||
|
2febdda8df | ||
|
e73cd7e81d | ||
|
e031a86d69 | ||
|
ae23f519f7 | ||
|
51501be48f | ||
|
d0356725f6 | ||
|
5d3fcce725 | ||
|
aee9444c1b | ||
|
7a126a20ea | ||
|
72f6c1b4bf | ||
|
b816e07742 | ||
|
6b61c4608f | ||
|
b935cb8415 | ||
|
363d5e8205 | ||
|
2b0863d2b0 | ||
|
d0aa98ef7d | ||
|
8e8cf213bd | ||
|
20970da24a | ||
|
34cd77dcf5 | ||
|
fc818d1373 | ||
|
33206425c0 | ||
|
2b3d87d7e6 | ||
|
90892cb66f | ||
|
a9acaf7a5e | ||
|
62b22bfd2b | ||
|
408b5a70af | ||
|
440168cfb2 | ||
|
a32d18cbb9 | ||
|
c6ce57e8a7 | ||
|
e9f7103ad7 | ||
|
5fa2a6faec | ||
|
e15446bc58 | ||
|
d8eda06a5a | ||
|
b4a015a4bd | ||
|
2b10ee1891 | ||
|
98539bd2c3 | ||
|
90fef59f80 | ||
|
7bdd67e701 | ||
|
aaa6d0f9ae | ||
|
9b9a21f044 | ||
|
cbacd70aa9 | ||
|
9479963b3b | ||
|
f7ba7f34f2 | ||
|
1fcb3bd1f1 | ||
|
ce1719e722 | ||
|
ac2cd315ef | ||
|
3e78c4dc7b | ||
|
27eede06c9 | ||
|
fe03ab06e5 | ||
|
7ac18c0f22 | ||
|
b2ca2e2979 | ||
|
cc77d40336 | ||
|
55502341ac | ||
|
20785c79fc | ||
|
40f61eaf15 | ||
|
46590e112e | ||
|
dc0f89b7e9 | ||
|
2945e76269 | ||
|
997b2634c5 | ||
|
7d56fd5382 | ||
|
4055397915 | ||
|
4a00552a09 | ||
|
4c11bddb3a | ||
|
bd54155cb6 | ||
|
cb7544ea39 | ||
|
858e80f3dd | ||
|
470bd0ce24 | ||
|
e37656f2e5 | ||
|
82ece7db12 | ||
|
4f24e33548 | ||
|
03169121c2 | ||
|
88787412b6 | ||
|
a4941e759c | ||
|
20737a3462 | ||
|
83a202ea46 | ||
|
e4c7c8876b | ||
|
77e62f0b98 | ||
|
202f21f262 | ||
|
75504d24bf | ||
|
4cbab4f744 | ||
|
2925a9005b | ||
|
41b7a04a68 | ||
|
50c6b2486b | ||
|
2e598be48f | ||
|
167f232623 | ||
|
9f6b8aea49 | ||
|
c7629735a3 | ||
|
d05ff6e77b | ||
|
fcb122124b | ||
|
f99d380583 | ||
|
30a95966ec | ||
|
9603014102 | ||
|
1dbd59e6ab | ||
|
57a88c9de2 | ||
|
14d99c6961 | ||
|
5165be2698 | ||
|
ebcc8462b7 |
@@ -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 $< >$@
|
$(Q) awk -v langfiles='$(OBJS_DIR)/langfiles.tmp' -f $(BASESET_DIR)/translations.awk $< >$@
|
||||||
|
|
||||||
# Compile extra grf
|
# 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'
|
$(E) '$(STAGE) Assembling openttd.nfo'
|
||||||
$(Q)-cp $(PNG_FILES) $(OBJS_DIR)/sprites 2> /dev/null
|
$(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
|
$(Q) $(NFORENUM) -s $(OBJS_DIR)/sprites/openttd.nfo
|
||||||
$(E) '$(STAGE) Compiling openttd.grf'
|
$(E) '$(STAGE) Compiling openttd.grf'
|
||||||
$(Q) $(GRFCODEC) -n -s -e -p1 $(OBJS_DIR)/openttd.grf
|
$(Q) $(GRFCODEC) -n -s -e -p1 $(OBJS_DIR)/openttd.grf
|
||||||
|
@@ -10,7 +10,7 @@ fallback = true
|
|||||||
description = A music pack without actual music.
|
description = A music pack without actual music.
|
||||||
description.af_ZA = 'n Musiek stel sonder enige musiek.
|
description.af_ZA = 'n Musiek stel sonder enige musiek.
|
||||||
description.ar_EG = مجموعة موسيقى بدون موسيقى
|
description.ar_EG = مجموعة موسيقى بدون موسيقى
|
||||||
description.be_BY = "Пусты" набор музычнага афармлення, не змяшчаючы ніякай музыкі.
|
description.be_BY = "Пусты" набор музычнага афармлення, які не зьмяшчае ніякай музыкі.
|
||||||
description.bg_BG = Празен музикален пакет.
|
description.bg_BG = Празен музикален пакет.
|
||||||
description.ca_ES = Un joc de música sense cap música.
|
description.ca_ES = Un joc de música sense cap música.
|
||||||
description.cs_CZ = Prázná hudební sada.
|
description.cs_CZ = Prázná hudební sada.
|
||||||
|
@@ -10,7 +10,7 @@ fallback = true
|
|||||||
description = A sound pack without any sounds.
|
description = A sound pack without any sounds.
|
||||||
description.af_ZA = 'n Klank stel sonder enige klanke.
|
description.af_ZA = 'n Klank stel sonder enige klanke.
|
||||||
description.ar_EG = مجموعة صوت بدوت اصوات مضافة
|
description.ar_EG = مجموعة صوت بدوت اصوات مضافة
|
||||||
description.be_BY = "Пусты" набор гукавога афармленьня, не змяшчаючы ніякіх гукаў.
|
description.be_BY = "Пусты" набор гукавога афармленьня, які не зьмяшчае ніякіх гукаў.
|
||||||
description.bg_BG = Празен звуков пакет.
|
description.bg_BG = Празен звуков пакет.
|
||||||
description.ca_ES = Un joc de sons sense cap so.
|
description.ca_ES = Un joc de sons sense cap so.
|
||||||
description.cs_CZ = Prázdná sada zvuků.
|
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.en_US = A sound pack without any sounds.
|
||||||
description.es_ES = Un conjunto de sonidos vacío.
|
description.es_ES = Un conjunto de sonidos vacío.
|
||||||
description.et_EE = Helikogu ilma helideta.
|
description.et_EE = Helikogu ilma helideta.
|
||||||
|
description.eu_ES = Soinurik gabeko soinu pakete bat
|
||||||
description.fi_FI = Äänipaketti, jossa ei ole ääniä.
|
description.fi_FI = Äänipaketti, jossa ei ole ääniä.
|
||||||
description.fr_FR = Un pack de sons sans sons.
|
description.fr_FR = Un pack de sons sans sons.
|
||||||
description.gd_GB = Pacaid fhuaimean anns nach eil fuaim sam bith.
|
description.gd_GB = Pacaid fhuaimean anns nach eil fuaim sam bith.
|
||||||
|
Binary file not shown.
@@ -11,7 +11,7 @@ palette = DOS
|
|||||||
description = Original Transport Tycoon Deluxe DOS edition graphics.
|
description = Original Transport Tycoon Deluxe DOS edition graphics.
|
||||||
description.af_ZA = Oorspronklike Transport Tycoon Deluxe DOS uitgawe grafieke.
|
description.af_ZA = Oorspronklike Transport Tycoon Deluxe DOS uitgawe grafieke.
|
||||||
description.ar_EG = النسخة الاصلية من ترانسبورت تايكون ديلوكس الرسومية نسخة الدوس
|
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.bg_BG = Оригинални графики на Transport Tycoon Deluxe за DOS.
|
||||||
description.ca_ES = Gràfics originals de Transport Tycoon Deluxe per a 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).
|
description.cs_CZ = Původní sada grafik Transport Tycoon Deluxe (verze pro DOS).
|
||||||
|
@@ -10,7 +10,7 @@ version = 0
|
|||||||
description = Original Transport Tycoon Deluxe DOS edition sounds.
|
description = Original Transport Tycoon Deluxe DOS edition sounds.
|
||||||
description.af_ZA = Oorspronklike Transport Tycoon Deluxe DOS uitgawe klanke.
|
description.af_ZA = Oorspronklike Transport Tycoon Deluxe DOS uitgawe klanke.
|
||||||
description.ar_EG = النسخة الاصلية من ترانسبورت تايكون ديلوكس الصوتية نسخة الدوس
|
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.bg_BG = Оригинални звуци на Transport Tycoon Deluxe за DOS.
|
||||||
description.ca_ES = Sons originals de Transport Tycoon Deluxe per a 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).
|
description.cs_CZ = Původní sada zvuků Transport Tycoon Deluxe (verze pro DOS).
|
||||||
|
@@ -11,7 +11,7 @@ palette = DOS
|
|||||||
description = Original Transport Tycoon Deluxe DOS (German) edition graphics.
|
description = Original Transport Tycoon Deluxe DOS (German) edition graphics.
|
||||||
description.af_ZA = Oorspronklike Transport Tycoon Deluxe DOS (German) uitgawe grafieke.
|
description.af_ZA = Oorspronklike Transport Tycoon Deluxe DOS (German) uitgawe grafieke.
|
||||||
description.ar_EG = النسخة الاصلية من ترانسبورت تايكون ديلوكس الالمانية نسخة الدوس
|
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.bg_BG = Оригинални графики на Transport Tycoon Deluxe за DOS (немски) .
|
||||||
description.ca_ES = Gràfics originals de Transport Tycoon Deluxe per a DOS (Alemany).
|
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).
|
description.cs_CZ = Původní sada grafik Transport Tycoon Deluxe (německá verze pro DOS).
|
||||||
|
@@ -11,7 +11,7 @@ palette = Windows
|
|||||||
description = Original Transport Tycoon Deluxe Windows edition graphics.
|
description = Original Transport Tycoon Deluxe Windows edition graphics.
|
||||||
description.af_ZA = Oorspronklike Transport Tycoon Deluxe Windows uitgawe grafieke.
|
description.af_ZA = Oorspronklike Transport Tycoon Deluxe Windows uitgawe grafieke.
|
||||||
description.ar_EG = النسخة الاصلية من ترانسبورت تايكون ديلوكس الرسومية نسخة وندوز
|
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.bg_BG = Оригинални графики на Transport Tycoon Deluxe за Windows.
|
||||||
description.ca_ES = Gràfics originals de Transport Tycoon Deluxe per a 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).
|
description.cs_CZ = Původní sada grafik Transport Tycoon Deluxe (verze pro Windows).
|
||||||
@@ -33,7 +33,7 @@ description.id_ID = Grafik orisinil Transport Tycoon Deluxe versi Windows.
|
|||||||
description.is_IS = Upprunalega grafíkin úr Transport Tycoon Deluxe Windows útgáfunni.
|
description.is_IS = Upprunalega grafíkin úr Transport Tycoon Deluxe Windows útgáfunni.
|
||||||
description.it_IT = Grafica originale di Transport Tycoon Deluxe, edizione Windows.
|
description.it_IT = Grafica originale di Transport Tycoon Deluxe, edizione Windows.
|
||||||
description.ja_JP = Transport Tycoon Deluxe オリジナル版 グラフィック (Windows)
|
description.ja_JP = Transport Tycoon Deluxe オリジナル版 グラフィック (Windows)
|
||||||
description.ko_KR = 오리지널 트랜스포트 타이쿤 디럭스 윈도우 에디션의 그래픽입니다.
|
description.ko_KR = 오리지널 트랜스포트 타이쿤 디럭스 윈도 에디션의 그래픽입니다.
|
||||||
description.lb_LU = Original Transport Tycoon Deluxe Windows Editioun Grafik.
|
description.lb_LU = Original Transport Tycoon Deluxe Windows Editioun Grafik.
|
||||||
description.lt_LT = Originali Transport Tycoon Deluxe Windows leidimo grafika.
|
description.lt_LT = Originali Transport Tycoon Deluxe Windows leidimo grafika.
|
||||||
description.nb_NO = Original grafikk fra Transport Tycoon Deluxe for Windows.
|
description.nb_NO = Original grafikk fra Transport Tycoon Deluxe for Windows.
|
||||||
|
@@ -10,7 +10,7 @@ version = 1
|
|||||||
description = Original Transport Tycoon Deluxe Windows edition music.
|
description = Original Transport Tycoon Deluxe Windows edition music.
|
||||||
description.af_ZA = Oorspronklike Transport Tycoon Deluxe Windows uitgawe musiek.
|
description.af_ZA = Oorspronklike Transport Tycoon Deluxe Windows uitgawe musiek.
|
||||||
description.ar_EG = النسخة الاصلية من ترانسبورت تايكون ديلوكس الموسيقية نسخة وندوز
|
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.bg_BG = Оригинална музика на Transport Tycoon Deluxe за Windows.
|
||||||
description.ca_ES = Música Original de Transport Tycoon Deluxe per a 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).
|
description.cs_CZ = Původní hudba Transport Tycoon Deluxe (verze pro Windows).
|
||||||
@@ -32,7 +32,7 @@ description.id_ID = Musik pengiring orisinil Transport Tycoon Deluxe versi Windo
|
|||||||
description.is_IS = Upprunalega tónlistin úr Transport Tycoon Deluxe Windows útgáfunni.
|
description.is_IS = Upprunalega tónlistin úr Transport Tycoon Deluxe Windows útgáfunni.
|
||||||
description.it_IT = Musica originale di Transport Tycoon Deluxe, edizione Windows.
|
description.it_IT = Musica originale di Transport Tycoon Deluxe, edizione Windows.
|
||||||
description.ja_JP = Transport Tycoon Deluxe オリジナル版 音楽 (Windows)
|
description.ja_JP = Transport Tycoon Deluxe オリジナル版 音楽 (Windows)
|
||||||
description.ko_KR = 오리지널 트랜스포트 타이쿤 디럭스 윈도우 에디션의 음악입니다.
|
description.ko_KR = 오리지널 트랜스포트 타이쿤 디럭스 윈도 에디션의 음악입니다.
|
||||||
description.lb_LU = Original Transport Tycoon Deluxe Windows Editioun Music.
|
description.lb_LU = Original Transport Tycoon Deluxe Windows Editioun Music.
|
||||||
description.lt_LT = Originali Transport Tycoon Deluxe Windows leidimo muzika.
|
description.lt_LT = Originali Transport Tycoon Deluxe Windows leidimo muzika.
|
||||||
description.lv_LV = Oriģinālā Transport Tycoon Deluxe Windows izdevuma mūzika.
|
description.lv_LV = Oriģinālā Transport Tycoon Deluxe Windows izdevuma mūzika.
|
||||||
|
@@ -10,7 +10,7 @@ version = 0
|
|||||||
description = Original Transport Tycoon Deluxe Windows edition sounds.
|
description = Original Transport Tycoon Deluxe Windows edition sounds.
|
||||||
description.af_ZA = Oorspronklike Transport Tycoon Deluxe Windows uitgawe klanke.
|
description.af_ZA = Oorspronklike Transport Tycoon Deluxe Windows uitgawe klanke.
|
||||||
description.ar_EG = النسخة الاصلية من ترانسبورت تايكون ديلوكس الصوتية نسخة وندوز
|
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.bg_BG = Оригинални звуци на Transport Tycoon Deluxe за Windows.
|
||||||
description.ca_ES = Sons originals de Transport Tycoon Deluxe per a 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).
|
description.cs_CZ = Původní sada zvuků Transport Tycoon Deluxe (verze pro Windows).
|
||||||
@@ -32,7 +32,7 @@ description.id_ID = Efek suara orisinil Transport Tycoon Deluxe versi Windows.
|
|||||||
description.is_IS = Upprunalega hljóðið úr Transport Tycoon Deluxe Windows útgáfunni.
|
description.is_IS = Upprunalega hljóðið úr Transport Tycoon Deluxe Windows útgáfunni.
|
||||||
description.it_IT = Suoni originali di Transport Tycoon Deluxe, edizione Windows.
|
description.it_IT = Suoni originali di Transport Tycoon Deluxe, edizione Windows.
|
||||||
description.ja_JP = Transport Tycoon Deluxe オリジナル版 効果音 (Windows)
|
description.ja_JP = Transport Tycoon Deluxe オリジナル版 効果音 (Windows)
|
||||||
description.ko_KR = 오리지널 트랜스포트 타이쿤 디럭스 윈도우 에디션의 효과음입니다.
|
description.ko_KR = 오리지널 트랜스포트 타이쿤 디럭스 윈도 에디션의 효과음입니다.
|
||||||
description.lb_LU = Original Transport Tycoon Deluxe Windows Editioun Sound.
|
description.lb_LU = Original Transport Tycoon Deluxe Windows Editioun Sound.
|
||||||
description.lt_LT = Originalūs Transport Tycoon Deluxe Windows leidimo garsai.
|
description.lt_LT = Originalūs Transport Tycoon Deluxe Windows leidimo garsai.
|
||||||
description.nb_NO = Originale lyder fra Transport Tycoon Deluxe for Windows.
|
description.nb_NO = Originale lyder fra Transport Tycoon Deluxe for Windows.
|
||||||
|
584
changelog.txt
584
changelog.txt
File diff suppressed because it is too large
Load Diff
170
config.lib
170
config.lib
@@ -1441,6 +1441,7 @@ make_cflags_and_ldflags() {
|
|||||||
make_compiler_cflags "$cc_host" "CFLAGS" "CXXFLAGS" "LDFLAGS" "FEATURES"
|
make_compiler_cflags "$cc_host" "CFLAGS" "CXXFLAGS" "LDFLAGS" "FEATURES"
|
||||||
|
|
||||||
CFLAGS="$CFLAGS -D$os"
|
CFLAGS="$CFLAGS -D$os"
|
||||||
|
CFLAGS_BUILD="$CFLAGS_BUILD -D$os"
|
||||||
|
|
||||||
if [ "$enable_debug" = "0" ]; then
|
if [ "$enable_debug" = "0" ]; then
|
||||||
# No debug, add default stuff
|
# No debug, add default stuff
|
||||||
@@ -1450,7 +1451,11 @@ make_cflags_and_ldflags() {
|
|||||||
LDFLAGS="$LDFLAGS -noixemul"
|
LDFLAGS="$LDFLAGS -noixemul"
|
||||||
fi
|
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
|
else
|
||||||
OBJS_SUBDIR="debug"
|
OBJS_SUBDIR="debug"
|
||||||
|
|
||||||
@@ -1494,7 +1499,7 @@ make_cflags_and_ldflags() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$enable_profiling" != "0" ]; then
|
if [ "$enable_profiling" != "0" ]; then
|
||||||
CFLAGS="$CFLAGS -p"
|
CFLAGS="$CFLAGS -pg"
|
||||||
LDFLAGS="$LDFLAGS -pg"
|
LDFLAGS="$LDFLAGS -pg"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -1700,17 +1705,18 @@ make_cflags_and_ldflags() {
|
|||||||
|
|
||||||
if [ -n "$png_config" ]; then
|
if [ -n "$png_config" ]; then
|
||||||
CFLAGS="$CFLAGS -DWITH_PNG"
|
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 [ "$enable_static" != "0" ]; then
|
||||||
if [ "$os" = "OSX" ]; 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
|
else
|
||||||
LIBS="$LIBS `$png_config --static --ldflags | tr '\n\r' ' '`"
|
LIBS="$LIBS `$png_config --libs --static | tr '\n\r' ' '`"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
LIBS="$LIBS `$png_config --ldflags | tr '\n\r' ' '`"
|
LIBS="$LIBS `$png_config --libs | tr '\n\r' ' '`"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -2715,80 +2721,64 @@ detect_libtimidity() {
|
|||||||
detect_library "$with_libtimidity" "libtimidity" "libtimidity.a" "" "timidity.h"
|
detect_library "$with_libtimidity" "libtimidity" "libtimidity.a" "" "timidity.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
detect_lzma() {
|
detect_pkg_config() {
|
||||||
# 0 means no, 1 is auto-detect, 2 is force
|
# $1 - config-param ($with_lzma value)
|
||||||
if [ "$with_lzma" = "0" ]; then
|
# $2 - package name ('liblzma')
|
||||||
log 1 "checking liblzma... disabled"
|
# $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
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$with_lzma" = "1" ] || [ "$with_lzma" = "" ] || [ "$with_lzma" = "2" ]; then
|
log 2 "detecting $2"
|
||||||
lzma_config="pkg-config liblzma"
|
|
||||||
|
if [ "$1" = "1" ] || [ "$1" = "" ] || [ "$1" = "2" ]; then
|
||||||
|
pkg_config_call="pkg-config $2"
|
||||||
else
|
else
|
||||||
lzma_config="$with_lzma"
|
pkg_config_call="$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
version=`$lzma_config --modversion 2>/dev/null`
|
version=`$pkg_config_call --modversion 2>/dev/null`
|
||||||
ret=$?
|
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 " returned $version"
|
||||||
log 2 " exit code $ret"
|
log 2 " exit code $ret"
|
||||||
|
|
||||||
if [ -z "$version" ] || [ "$ret" != "0" ]; then
|
if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version_ok" != "1" ]; then
|
||||||
log 1 "checking liblzma... not found"
|
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.
|
# It was forced, so it should be found.
|
||||||
if [ "$with_lzma" != "1" ]; then
|
if [ "$1" != "1" ]; then
|
||||||
log 1 "configure: error: pkg-config liblzma couldn't be found"
|
log 1 "configure: error: pkg-config $2 couldn't be found"
|
||||||
log 1 "configure: error: you supplied '$with_lzma', but it seems invalid"
|
log 1 "configure: error: you supplied '$1', but it seems invalid"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
lzma_config=""
|
eval "$3=\"\""
|
||||||
return 0
|
return 0
|
||||||
fi
|
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() {
|
detect_xdg_basedir() {
|
||||||
# 0 means no, 1 is auto-detect, 2 is force
|
detect_pkg_config "$with_xdg_basedir" "libxdg-basedir" "xdg_basedir_config" "1.2"
|
||||||
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_png() {
|
detect_png() {
|
||||||
@@ -2815,33 +2805,7 @@ detect_png() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$with_png" = "1" ] || [ "$with_png" = "" ] || [ "$with_png" = "2" ]; then
|
detect_pkg_config "$with_png" "libpng" "png_config" "1.2"
|
||||||
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_freetype() {
|
detect_freetype() {
|
||||||
@@ -2936,39 +2900,7 @@ detect_fontconfig() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$with_fontconfig" = "1" ] || [ "$with_fontconfig" = "" ] || [ "$with_fontconfig" = "2" ]; then
|
detect_pkg_config "$with_fontconfig" "fontconfig" "fontconfig_config" "2.3"
|
||||||
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_icu() {
|
detect_icu() {
|
||||||
|
262
docs/desync.txt
Normal file
262
docs/desync.txt
Normal file
@@ -0,0 +1,262 @@
|
|||||||
|
Some explanations about Desyncs
|
||||||
|
Last updated: 2014-02-23
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
Table of contents
|
||||||
|
-----------------
|
||||||
|
1.0) Desync theory
|
||||||
|
* 1.1) OpenTTD multiplayer architecture
|
||||||
|
* 1.2) What is a Desync and how is it detected
|
||||||
|
* 1.3) Typical causes of Desyncs
|
||||||
|
2.0) What to do in case of a Desync
|
||||||
|
* 2.1) Cache debugging
|
||||||
|
* 2.2) Desync recording
|
||||||
|
3.0) Evaluating the Desync records
|
||||||
|
* 3.1) Replaying
|
||||||
|
* 3.2) Evaluation the replay
|
||||||
|
* 3.3) Comparing savegames
|
||||||
|
|
||||||
|
|
||||||
|
1.1) OpenTTD multiplayer architecture
|
||||||
|
---- --------------------------------
|
||||||
|
OpenTTD has a huge gamestate, which changes all of the time.
|
||||||
|
The savegame contains the complete gamestate at a specific point
|
||||||
|
in time. But this state changes completely each tick: Vehicles move
|
||||||
|
and trees grow.
|
||||||
|
|
||||||
|
However, most of these changes in the gamestate are deterministic:
|
||||||
|
Without a player interfering a vehicle follows its orders always
|
||||||
|
in the same way, and trees always grow the same.
|
||||||
|
|
||||||
|
In OpenTTD multiplayer synchronisation works by creating a savegame
|
||||||
|
when clients join, and then transfering that savegame to the client,
|
||||||
|
so it has the complete gamestate at a fixed point in time.
|
||||||
|
|
||||||
|
Afterwards clients only receive 'commands', that is: Stuff which is
|
||||||
|
not predictable, like
|
||||||
|
- player actions
|
||||||
|
- AI actions
|
||||||
|
- GameScript actions
|
||||||
|
- Admin Port command
|
||||||
|
- rcon commands
|
||||||
|
- ...
|
||||||
|
|
||||||
|
These commands contain the information on how to execute the command,
|
||||||
|
and when to execute it. Time is measured in 'network frames'.
|
||||||
|
Mind that network frames to not match ingame time. Network frames
|
||||||
|
also run while the game is paused, to give a defined behaviour to
|
||||||
|
stuff that is executing while the game is paused.
|
||||||
|
|
||||||
|
The deterministic part of the gamestate is run by the clients on
|
||||||
|
their own. All they get from the server is the instruction to
|
||||||
|
run the gamestate up to a certain network time, which basically
|
||||||
|
says that there are no commands scheduled in that time.
|
||||||
|
|
||||||
|
When a client (which includes the server itself) wants to execute
|
||||||
|
a command (i.e. a non-predictable action), it does this by
|
||||||
|
- calling DoCommandP resp. DoCommandPInternal
|
||||||
|
- These functions first do a local test-run of the command to
|
||||||
|
check simple preconditions. (Just to give the client an
|
||||||
|
immediate response without bothering the server and waiting for
|
||||||
|
the response.) The test-run may not actually change the
|
||||||
|
gamestate, all changes must be discarded.
|
||||||
|
- If the local test-run succeeds the command is sent to the server.
|
||||||
|
- The server inserts the command into the command queue, which
|
||||||
|
assigns a network frame to the commands, i.e. when it shall be
|
||||||
|
executed on all clients.
|
||||||
|
- Enhanced with this specific timestamp, the command is send to all
|
||||||
|
clients, which execute the command simultaneously in the same
|
||||||
|
network frame in the same order.
|
||||||
|
|
||||||
|
1.2) What is a Desync and how is it detected
|
||||||
|
---- ---------------------------------------
|
||||||
|
In the ideal case all clients have the same gamestate as the server
|
||||||
|
and run in sync. That is, vehicle movement is the same on all
|
||||||
|
clients, and commands are executed the same everywhere and
|
||||||
|
have the same results.
|
||||||
|
|
||||||
|
When a Desync happens, it means that the gamestates on the clients
|
||||||
|
(including the server) are no longer the same. Just imagine
|
||||||
|
that a vehicle picks the left line instead of the right line at
|
||||||
|
a junction on one client.
|
||||||
|
|
||||||
|
The important thing here is, that noone notices when a Desync
|
||||||
|
occurs. The desync client will continue to simulate the gamestate
|
||||||
|
and execute commands from the server. Once the gamestate differs
|
||||||
|
it will increasingly spiral out of control: If a vehicle picks a
|
||||||
|
different route, it will arrive at a different time at a station,
|
||||||
|
which will load different cargo, which causes other vehicles to
|
||||||
|
load other stuff, which causes industries to notice different
|
||||||
|
servicing, which causes industries to change production, ...
|
||||||
|
the client could run all day in a different universe.
|
||||||
|
|
||||||
|
To limit how long a Desync can remain unnoticed, the server
|
||||||
|
transfers some checksums every now and then for the gamestate.
|
||||||
|
Currently this checksum is the state of the random number
|
||||||
|
generator of the game logic. A lot of things in OpenTTD depend
|
||||||
|
on the RNG, and if the gamestate differs, it is likely that the
|
||||||
|
RNG is called at different times, and the state differs when
|
||||||
|
checked.
|
||||||
|
|
||||||
|
The clients compare this 'checksum' with the checksum of their
|
||||||
|
own gamestate at the specific network frame. If they differ,
|
||||||
|
the client disconnects with a Desync error.
|
||||||
|
|
||||||
|
The important thing here is: The detection of the Desync is
|
||||||
|
only an ultimate failure detection. It does not give any
|
||||||
|
indication on when the Desync happened. The Desync may after
|
||||||
|
all have occured long ago, and just did not affect the checksum
|
||||||
|
up to now. The checksum may have matched 10 times or more
|
||||||
|
since the Desync happend, and only now the Desync has spiraled
|
||||||
|
enough to finally affect the checksum. (There was once a desync
|
||||||
|
which was only noticed by the checksum after 20 game years.)
|
||||||
|
|
||||||
|
1.3) Typical causes of Desyncs
|
||||||
|
---- -------------------------
|
||||||
|
Desyncs can be caused by the following scenarios:
|
||||||
|
- The savegame does not describe the complete gamestate.
|
||||||
|
- Some information which affects the progression of the
|
||||||
|
gamestate is not saved in the savegame.
|
||||||
|
- Some information which affects the progression of the
|
||||||
|
gamestate is not loaded from the savegame.
|
||||||
|
This includes the case that something is not completely
|
||||||
|
reset before loading the savegame, so data from the
|
||||||
|
previous game is carried over to the new one.
|
||||||
|
- The gamestate does not behave deterministic.
|
||||||
|
- Cache mismatch: The game logic depends on some cached
|
||||||
|
values, which are not invalidated properly. This is
|
||||||
|
the usual case for NewGRF-specific Desyncs.
|
||||||
|
- Undefined behaviour: The game logic performs multiple
|
||||||
|
things in an undefined order or with an undefined
|
||||||
|
result. E.g. when sorting something with a key while
|
||||||
|
some keys are equal. Or some computation that depends
|
||||||
|
on the CPU architecture (32/64 bit, little/big endian).
|
||||||
|
- The gamestate is modified when it shall not be modified.
|
||||||
|
- The test-run of a command alters the gamestate.
|
||||||
|
- The gamestate is altered by a player or script without
|
||||||
|
using commands.
|
||||||
|
|
||||||
|
|
||||||
|
2.1) Cache debugging
|
||||||
|
---- ---------------
|
||||||
|
Desyncs which are caused by inproper cache validation can
|
||||||
|
often be found by enabling cache validation:
|
||||||
|
- Start OpenTTD with '-d desync=2'.
|
||||||
|
- This will enable validation of caches every tick.
|
||||||
|
That is, cached values are recomputed every tick and compared
|
||||||
|
to the cached value.
|
||||||
|
- Differences are logged to 'commands-out.log' in the autosave
|
||||||
|
folder.
|
||||||
|
|
||||||
|
Mind that this type of debugging can also be done in singleplayer.
|
||||||
|
|
||||||
|
2.2) Desync recording
|
||||||
|
---- ----------------
|
||||||
|
If you have a server, which happens to encounter Desyncs often,
|
||||||
|
you can enable recording of the gamestate alterations. This
|
||||||
|
will later allow the replay the gamestate and locate the Desync
|
||||||
|
cause.
|
||||||
|
|
||||||
|
There are two levels of Desync recording, which are enabled
|
||||||
|
via '-d desync=2' resp. '-d desync=3'. Both will record all
|
||||||
|
commands to a file 'commands-out.log' in the autosave folder.
|
||||||
|
|
||||||
|
If you have the savegame from the start of the server, and
|
||||||
|
this command log you can replay the whole game. (see Section 3.1)
|
||||||
|
|
||||||
|
If you do not start the server from a savegame, there will
|
||||||
|
also be a savegame created just after a map has been generated.
|
||||||
|
The savegame will be named 'dmp_cmds_*.sav' and be put into
|
||||||
|
the autosave folder.
|
||||||
|
|
||||||
|
In addition to that '-d desync=3' also creates regular savegames
|
||||||
|
at defined spots in network time. (more defined than regular
|
||||||
|
autosaves). These will be created in the autosave folder
|
||||||
|
and will also be named 'dmp_cmds_*.sav'.
|
||||||
|
|
||||||
|
These saves allow comparing the gamestate with the original
|
||||||
|
gamestate during replaying, and thus greatly help debugging.
|
||||||
|
However, they also take a lot of disk space.
|
||||||
|
|
||||||
|
|
||||||
|
3.1) Replaying
|
||||||
|
---- ---------
|
||||||
|
To replay a Desync recording, you need these files:
|
||||||
|
- The savegame from when the server was started, resp.
|
||||||
|
the automatically created savegame from when the map
|
||||||
|
was generated.
|
||||||
|
- The 'commands-out.log' file.
|
||||||
|
- Optionally the 'dmp_cmds_*.sav'.
|
||||||
|
Put these files into a safe spot. (Not your autosave folder!)
|
||||||
|
|
||||||
|
Next, prepare your OpenTTD for replaying:
|
||||||
|
- Get the same version of OpenTTD as the original server was running.
|
||||||
|
- Uncomment/enable the define 'DEBUG_DUMP_COMMANDS' in
|
||||||
|
'src/network/network_func.h'.
|
||||||
|
- Put the 'commands-out.log' into the root save folder, and rename
|
||||||
|
it to 'commands.log'.
|
||||||
|
- Run 'openttd -D -d desync=3 -g startsavegame.sav'.
|
||||||
|
This replays the server log and creates new 'commands-out.log'
|
||||||
|
and 'dmp_cmds_*.sav' in your autosave folder.
|
||||||
|
|
||||||
|
3.2) Evaluation the replay
|
||||||
|
---- ---------------------
|
||||||
|
The replaying will also compare the checksums which are part of
|
||||||
|
the 'commands-out.log' with the replayed gamestate.
|
||||||
|
If they differ, it will trigger a 'NOT_REACHED'.
|
||||||
|
|
||||||
|
If the replay succeeds without mismatch, that is the replay reproduces
|
||||||
|
the original server state:
|
||||||
|
- Repeat the replay starting from incrementally later 'dmp_cmds_*.sav'
|
||||||
|
while truncating the 'commands.log' at the beginning appropriately.
|
||||||
|
The 'dmp_cmds_*.sav' can be your own ones from the first reply, or
|
||||||
|
the ones from the original server (if you have them).
|
||||||
|
(This simulates the view of joining clients during the game.)
|
||||||
|
- If one of those replays fails, you have located the Desync between
|
||||||
|
the last dmp_cmds that reproduces the replay and the first one
|
||||||
|
that fails.
|
||||||
|
|
||||||
|
If you have the original 'dmp_cmds_*.sav', you can also compare those
|
||||||
|
savegames with your own ones from the replay. You can also comment/disable
|
||||||
|
the 'NOT_REACHED' mentioned above, to get another 'dmp_cmds_*.sav' from
|
||||||
|
the replay after the mismatch has already been detected.
|
||||||
|
See Section 3.2 on how to compare savegames.
|
||||||
|
If the saves differ you have located the Desync between the last dmp_cmds
|
||||||
|
that match and the first one that does not. The difference of the saves
|
||||||
|
may point you in the direction of what causes it.
|
||||||
|
|
||||||
|
If the replay succeeds without mismatch, and you do not have any
|
||||||
|
'dmp_cmd_*.sav' from the original server, it is a lost case.
|
||||||
|
Enable creation of the 'dmp_cmd_*.sav' on the server, and wait for the
|
||||||
|
next Desync.
|
||||||
|
|
||||||
|
Finally, you can also compare the 'commands-out.log' from the original
|
||||||
|
server with the one from the replay. They will differ in stuff like
|
||||||
|
dates, and the original log will contain the chat, but otherwise they
|
||||||
|
should match.
|
||||||
|
|
||||||
|
3.2) Comparing savegames
|
||||||
|
---- -------------------
|
||||||
|
The binary form of the savegames from the original server and from
|
||||||
|
your replay will always differ:
|
||||||
|
- The savegame contains paths to used NewGRF files.
|
||||||
|
- The gamelog will log your loading of the savegame.
|
||||||
|
- The savegame data of AIs and the Gamescript will differ.
|
||||||
|
Scripts are not run during the replay, only their recorded commands
|
||||||
|
are replayed. Their internal state will thus not change in the
|
||||||
|
replay and will differ.
|
||||||
|
|
||||||
|
To compare savegame more semantically, there exist some ugly hackish
|
||||||
|
tools at:
|
||||||
|
http://devs.openttd.org/~frosch/texts/zpipe.c
|
||||||
|
http://devs.openttd.org/~frosch/texts/printhunk.c
|
||||||
|
|
||||||
|
The first one decompresses OpenTTD savegames. The second one creates
|
||||||
|
a textual representation of an uncompressed savegame, by parsing hunks
|
||||||
|
and arrays and such. With both tools you need to be a bit careful
|
||||||
|
since they work on stdin and stdout, which may not deal well with
|
||||||
|
binary data.
|
||||||
|
|
||||||
|
If you have the textual representation of the savegames, you can
|
||||||
|
compare them with regular diff tools.
|
@@ -539,6 +539,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</li>
|
</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
|
<li>m5 bits 7 clear: road or level-crossing
|
||||||
<ul>
|
<ul>
|
||||||
<li>m6 bits 5..3:
|
<li>m6 bits 5..3:
|
||||||
@@ -573,7 +574,6 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</li>
|
</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
|
<li>m5 bit 6 clear: road
|
||||||
<ul>
|
<ul>
|
||||||
<li>m1 bits 4..0: <a href="#OwnershipInfo">owner</a> of the road type 0 (normal road)</li>
|
<li>m1 bits 4..0: <a href="#OwnershipInfo">owner</a> of the road type 0 (normal road)</li>
|
||||||
@@ -663,6 +663,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</li>
|
</li>
|
||||||
|
<li>m7 bits 4..0: <a href="#OwnershipInfo">owner</a> of the road type 0 (normal road)</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>m6 bits 7..6 : Possibility of a bridge above, in the <a href="#bridge_direction">direction specified</a></li>
|
<li>m6 bits 7..6 : Possibility of a bridge above, in the <a href="#bridge_direction">direction specified</a></li>
|
||||||
|
@@ -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">-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"><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">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>
|
||||||
<tr>
|
<tr>
|
||||||
<td>3</td>
|
<td>3</td>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
OpenTTD's known bugs
|
OpenTTD's known bugs
|
||||||
Last updated: 2014-02-06
|
Last updated: 2014-10-08
|
||||||
Release version: 1.4.0-beta4
|
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
|
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
|
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
|
window and showing a red warning. There are basically two solutions
|
||||||
for this problem: you must change the settings so no AI is started,
|
for this problem: Either you set the number of AI players to 0 so that
|
||||||
this is done in the difficulty settings window. The other solution is
|
no AI is started. You find that setting at the top of the window in the
|
||||||
acquiring (downloading) some AI. The easiest way to do this is via
|
"AI / Game Scripts Settings" window.
|
||||||
the "Check Online Content" button in the main (intro) menu or via
|
The other solution is acquiring (downloading) some AI. The easiest way
|
||||||
"AI Settings" -> "Select AI" -> "Check Online Content" which is also
|
to do this is via the "Check Online Content" button in the main (intro)
|
||||||
accessed via the main menu.
|
menu or directly in the "AI / Game Scripts Settings" dialogue via the
|
||||||
|
"Check Online Content" button.
|
||||||
|
|
||||||
After a while of playing, colours get corrupted
|
After a while of playing, colours get corrupted
|
||||||
In Windows 7 the background slideshow corrupts the colour mapping of
|
In Windows 7 the background slideshow corrupts the colour mapping of
|
||||||
|
32
media/extra_grf/assemble_nfo.awk
Normal file
32
media/extra_grf/assemble_nfo.awk
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
@@ -1,3 +1,81 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
-- OpenTTD <info@openttd.org> Tue, 25 Feb 2014 10:15:00 +0100
|
||||||
|
|
||||||
openttd (1.4.0~beta4-0) unstable; urgency=low
|
openttd (1.4.0~beta4-0) unstable; urgency=low
|
||||||
|
|
||||||
* New upstream release 1.4.0-beta4
|
* New upstream release 1.4.0-beta4
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
# Version numbers to update
|
# Version numbers to update
|
||||||
!define APPV_MAJOR 1
|
!define APPV_MAJOR 1
|
||||||
!define APPV_MINOR 4
|
!define APPV_MINOR 4
|
||||||
!define APPV_MAINT 0
|
!define APPV_MAINT 4
|
||||||
!define APPV_BUILD 3
|
!define APPV_BUILD 0
|
||||||
!define APPV_EXTRA "-beta4"
|
!define APPV_EXTRA "-RC1"
|
||||||
|
|
||||||
!define APPNAME "OpenTTD" ; Define application name
|
!define APPNAME "OpenTTD" ; Define application name
|
||||||
!define APPVERSION "${APPV_MAJOR}.${APPV_MINOR}.${APPV_MAINT}${APPV_EXTRA}" ; Define application version
|
!define APPVERSION "${APPV_MAJOR}.${APPV_MINOR}.${APPV_MAINT}${APPV_EXTRA}" ; Define application version
|
||||||
|
@@ -950,13 +950,7 @@
|
|||||||
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqpcheader.h" />
|
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqpcheader.h" />
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqstate.h" />
|
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqstate.h" />
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdaux.h" />
|
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdaux.h" />
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\include\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\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\sqstring.h" />
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqtable.h" />
|
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqtable.h" />
|
||||||
<ClInclude Include="..\src\3rdparty\squirrel\include\squirrel.h" />
|
<ClInclude Include="..\src\3rdparty\squirrel\include\squirrel.h" />
|
||||||
@@ -1036,6 +1030,8 @@
|
|||||||
<ClInclude Include="..\src\script\api\script_station.hpp" />
|
<ClInclude Include="..\src\script\api\script_station.hpp" />
|
||||||
<ClInclude Include="..\src\script\api\script_stationlist.hpp" />
|
<ClInclude Include="..\src\script\api\script_stationlist.hpp" />
|
||||||
<ClInclude Include="..\src\script\api\script_story_page.hpp" />
|
<ClInclude Include="..\src\script\api\script_story_page.hpp" />
|
||||||
|
<ClInclude Include="..\src\script\api\script_storypagelist.hpp" />
|
||||||
|
<ClInclude Include="..\src\script\api\script_storypageelementlist.hpp" />
|
||||||
<ClInclude Include="..\src\script\api\script_subsidy.hpp" />
|
<ClInclude Include="..\src\script\api\script_subsidy.hpp" />
|
||||||
<ClInclude Include="..\src\script\api\script_subsidylist.hpp" />
|
<ClInclude Include="..\src\script\api\script_subsidylist.hpp" />
|
||||||
<ClInclude Include="..\src\script\api\script_testmode.hpp" />
|
<ClInclude Include="..\src\script\api\script_testmode.hpp" />
|
||||||
@@ -1098,6 +1094,8 @@
|
|||||||
<ClCompile Include="..\src\script\api\script_station.cpp" />
|
<ClCompile Include="..\src\script\api\script_station.cpp" />
|
||||||
<ClCompile Include="..\src\script\api\script_stationlist.cpp" />
|
<ClCompile Include="..\src\script\api\script_stationlist.cpp" />
|
||||||
<ClCompile Include="..\src\script\api\script_story_page.cpp" />
|
<ClCompile Include="..\src\script\api\script_story_page.cpp" />
|
||||||
|
<ClCompile Include="..\src\script\api\script_storypagelist.cpp" />
|
||||||
|
<ClCompile Include="..\src\script\api\script_storypageelementlist.cpp" />
|
||||||
<ClCompile Include="..\src\script\api\script_subsidy.cpp" />
|
<ClCompile Include="..\src\script\api\script_subsidy.cpp" />
|
||||||
<ClCompile Include="..\src\script\api\script_subsidylist.cpp" />
|
<ClCompile Include="..\src\script\api\script_subsidylist.cpp" />
|
||||||
<ClCompile Include="..\src\script\api\script_testmode.cpp" />
|
<ClCompile Include="..\src\script\api\script_testmode.cpp" />
|
||||||
|
@@ -2079,27 +2079,9 @@
|
|||||||
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdaux.h">
|
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdaux.h">
|
||||||
<Filter>Squirrel headers</Filter>
|
<Filter>Squirrel headers</Filter>
|
||||||
</ClInclude>
|
</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">
|
<ClInclude Include="..\src\3rdparty\squirrel\include\sqstdmath.h">
|
||||||
<Filter>Squirrel headers</Filter>
|
<Filter>Squirrel headers</Filter>
|
||||||
</ClInclude>
|
</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">
|
<ClInclude Include="..\src\3rdparty\squirrel\squirrel\sqstring.h">
|
||||||
<Filter>Squirrel headers</Filter>
|
<Filter>Squirrel headers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -2337,6 +2319,12 @@
|
|||||||
<ClInclude Include="..\src\script\api\script_story_page.hpp">
|
<ClInclude Include="..\src\script\api\script_story_page.hpp">
|
||||||
<Filter>Script API</Filter>
|
<Filter>Script API</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\src\script\api\script_storypagelist.hpp">
|
||||||
|
<Filter>Script API</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\src\script\api\script_storypageelementlist.hpp">
|
||||||
|
<Filter>Script API</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\src\script\api\script_subsidy.hpp">
|
<ClInclude Include="..\src\script\api\script_subsidy.hpp">
|
||||||
<Filter>Script API</Filter>
|
<Filter>Script API</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -2523,6 +2511,12 @@
|
|||||||
<ClCompile Include="..\src\script\api\script_story_page.cpp">
|
<ClCompile Include="..\src\script\api\script_story_page.cpp">
|
||||||
<Filter>Script API Implementation</Filter>
|
<Filter>Script API Implementation</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\src\script\api\script_storypagelist.cpp">
|
||||||
|
<Filter>Script API Implementation</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\src\script\api\script_storypageelementlist.cpp">
|
||||||
|
<Filter>Script API Implementation</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\src\script\api\script_subsidy.cpp">
|
<ClCompile Include="..\src\script\api\script_subsidy.cpp">
|
||||||
<Filter>Script API Implementation</Filter>
|
<Filter>Script API Implementation</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@@ -3114,34 +3114,10 @@
|
|||||||
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdaux.h"
|
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdaux.h"
|
||||||
>
|
>
|
||||||
</File>
|
</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
|
<File
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdmath.h"
|
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdmath.h"
|
||||||
>
|
>
|
||||||
</File>
|
</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
|
<File
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqstring.h"
|
RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqstring.h"
|
||||||
>
|
>
|
||||||
@@ -3478,6 +3454,14 @@
|
|||||||
RelativePath=".\..\src\script\api\script_story_page.hpp"
|
RelativePath=".\..\src\script\api\script_story_page.hpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\script\api\script_storypagelist.hpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\script\api\script_storypageelementlist.hpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\script\api\script_subsidy.hpp"
|
RelativePath=".\..\src\script\api\script_subsidy.hpp"
|
||||||
>
|
>
|
||||||
@@ -3730,6 +3714,14 @@
|
|||||||
RelativePath=".\..\src\script\api\script_story_page.cpp"
|
RelativePath=".\..\src\script\api\script_story_page.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\script\api\script_storypagelist.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\script\api\script_storypageelementlist.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\script\api\script_subsidy.cpp"
|
RelativePath=".\..\src\script\api\script_subsidy.cpp"
|
||||||
>
|
>
|
||||||
|
@@ -3111,34 +3111,10 @@
|
|||||||
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdaux.h"
|
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdaux.h"
|
||||||
>
|
>
|
||||||
</File>
|
</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
|
<File
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdmath.h"
|
RelativePath=".\..\src\3rdparty\squirrel\include\sqstdmath.h"
|
||||||
>
|
>
|
||||||
</File>
|
</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
|
<File
|
||||||
RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqstring.h"
|
RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqstring.h"
|
||||||
>
|
>
|
||||||
@@ -3475,6 +3451,14 @@
|
|||||||
RelativePath=".\..\src\script\api\script_story_page.hpp"
|
RelativePath=".\..\src\script\api\script_story_page.hpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\script\api\script_storypagelist.hpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\script\api\script_storypageelementlist.hpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\script\api\script_subsidy.hpp"
|
RelativePath=".\..\src\script\api\script_subsidy.hpp"
|
||||||
>
|
>
|
||||||
@@ -3727,6 +3711,14 @@
|
|||||||
RelativePath=".\..\src\script\api\script_story_page.cpp"
|
RelativePath=".\..\src\script\api\script_story_page.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\script\api\script_storypagelist.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\script\api\script_storypageelementlist.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\script\api\script_subsidy.cpp"
|
RelativePath=".\..\src\script\api\script_subsidy.cpp"
|
||||||
>
|
>
|
||||||
|
66
readme.txt
66
readme.txt
@@ -1,5 +1,5 @@
|
|||||||
Last updated: 2014-02-06
|
Last updated: 2014-10-08
|
||||||
Release version: 1.4.0-beta4
|
Release version: 1.4.4-RC1
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
@@ -674,46 +674,47 @@ http://homer.rice.edu/~sandmann/cwsdpmi/csdpmi5s.zip
|
|||||||
X.X) Credits
|
X.X) Credits
|
||||||
---- -------
|
---- -------
|
||||||
The OpenTTD team (in alphabetical order):
|
The OpenTTD team (in alphabetical order):
|
||||||
Albert Hofkamp (Alberth) - GUI expert
|
Albert Hofkamp (Alberth) - GUI expert (since 0.7)
|
||||||
Jean-François Claeys (Belugas) - GUI, newindustries and more
|
Matthijs Kooijman (blathijs) - Pathfinder-guru, Debian port (since 0.3)
|
||||||
Matthijs Kooijman (blathijs) - Pathfinder-guru, pool rework
|
Ulf Hermann (fonsinchen) - Cargo Distribution (since 1.3)
|
||||||
Ulf Hermann (fonsinchen) - Cargo Distribution
|
Christoph Elsenhans (frosch) - General coding (since 0.6)
|
||||||
Christoph Elsenhans (frosch) - General coding
|
Loïc Guilloux (glx) - Windows Expert (since 0.4.5)
|
||||||
Loïc Guilloux (glx) - Windows Expert
|
Michael Lutz (michi_cc) - Path based signals (since 0.7)
|
||||||
Michael Lutz (michi_cc) - Path based signals
|
Owen Rudge (orudge) - Forum host, OS/2 port (since 0.1)
|
||||||
Owen Rudge (orudge) - Forum host, OS/2 port
|
Peter Nelson (peter1138) - Spiritual descendant from newGRF gods (since 0.4.5)
|
||||||
Peter Nelson (peter1138) - Spiritual descendant from newGRF gods
|
Ingo von Borstel (planetmaker) - General coding, Support (since 1.1)
|
||||||
Ingo von Borstel (planetmaker) - Support
|
Remko Bijker (Rubidium) - Lead coder and way more (since 0.4.5)
|
||||||
Remko Bijker (Rubidium) - Lead coder and way more
|
José Soler (Terkhen) - General coding (since 1.0)
|
||||||
Zdeněk Sojka (SmatZ) - Bug finder and fixer
|
Leif Linse (Zuu) - AI/Game Script (since 1.2)
|
||||||
José Soler (Terkhen) - General coding
|
|
||||||
Thijs Marinussen (Yexo) - AI Framework
|
|
||||||
Leif Linse (Zuu) - AI/Game Script
|
|
||||||
|
|
||||||
Inactive Developers:
|
Inactive Developers:
|
||||||
Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles
|
Jean-François Claeys (Belugas) - GUI, newindustries and more (0.4.5 - 1.0)
|
||||||
Victor Fischer (Celestar) - Programming everywhere you need him to
|
Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles (0.3 - 0.7)
|
||||||
Tamás Faragó (Darkvater) - Ex-Lead coder
|
Victor Fischer (Celestar) - Programming everywhere you need him to (0.3 - 0.6)
|
||||||
Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;)
|
Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;) (0.4.5 - 0.6)
|
||||||
Jonathan Coome (Maedhros) - High priest of the NewGRF Temple
|
Jonathan Coome (Maedhros) - High priest of the NewGRF Temple (0.5 - 0.6)
|
||||||
Attila Bán (MiHaMiX) - WebTranslator 1 and 2
|
Attila Bán (MiHaMiX) - WebTranslator 1 and 2 (0.3 - 0.5)
|
||||||
Christoph Mallon (Tron) - Programmer, code correctness police
|
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:
|
Retired Developers:
|
||||||
Ludvig Strigeus (ludde) - OpenTTD author, main coder (0.1 - 0.3.3)
|
Tamás Faragó (Darkvater) - Ex-Lead coder (0.3 - 0.5)
|
||||||
Serge Paquet (vurlix) - Assistant project manager, coder (0.1 - 0.3.3)
|
Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3 - 0.3)
|
||||||
Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3.0 - 0.3.6)
|
Emil Djupfeld (egladil) - MacOSX port (0.4 - 0.6)
|
||||||
Benedikt Brüggemeier (skidd13) - Bug fixer and code reworker
|
Simon Sasburg (HackyKid) - Bug fixer (0.4 - 0.4.5)
|
||||||
Patric Stout (TrueBrain) - NoProgrammer (0.3 - 1.2), sys op (active)
|
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:
|
Thanks to:
|
||||||
Josef Drexler - For his great work on TTDPatch.
|
Josef Drexler - For his great work on TTDPatch.
|
||||||
Marcin Grzegorczyk - For his TTDPatch work and documentation of Transport Tycoon Deluxe internals and track foundations
|
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
|
Stefan Meißner (sign_de) - For his work on the console
|
||||||
Mike Ragsdale - OpenTTD installer
|
Mike Ragsdale - OpenTTD installer
|
||||||
Cian Duffy (MYOB) - BeOS port / manual writing
|
|
||||||
Christian Rosentreter (tokai) - MorphOS / AmigaOS port
|
Christian Rosentreter (tokai) - MorphOS / AmigaOS port
|
||||||
Richard Kempton (RichK67) - Additional airports, initial TGP implementation
|
Richard Kempton (RichK67) - Additional airports, initial TGP implementation
|
||||||
Alberto Demichelis - Squirrel scripting language
|
Alberto Demichelis - Squirrel scripting language
|
||||||
@@ -722,6 +723,7 @@ Thanks to:
|
|||||||
George - Canal graphics
|
George - Canal graphics
|
||||||
Andrew Parkhouse (andythenorth) - River graphics
|
Andrew Parkhouse (andythenorth) - River graphics
|
||||||
David Dallaston (Pikka) - Tram tracks
|
David Dallaston (Pikka) - Tram tracks
|
||||||
|
Fleashosio - Titlegame
|
||||||
All Translators - For their support to make OpenTTD a truly international game
|
All Translators - For their support to make OpenTTD a truly international game
|
||||||
Bug Reporters - Thanks for all bug reports
|
Bug Reporters - Thanks for all bug reports
|
||||||
Chris Sawyer - For an amazing game!
|
Chris Sawyer - For an amazing game!
|
||||||
|
10
source.list
10
source.list
@@ -720,13 +720,7 @@ script/squirrel_std.hpp
|
|||||||
3rdparty/squirrel/squirrel/sqpcheader.h
|
3rdparty/squirrel/squirrel/sqpcheader.h
|
||||||
3rdparty/squirrel/squirrel/sqstate.h
|
3rdparty/squirrel/squirrel/sqstate.h
|
||||||
3rdparty/squirrel/include/sqstdaux.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/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/sqstring.h
|
||||||
3rdparty/squirrel/squirrel/sqtable.h
|
3rdparty/squirrel/squirrel/sqtable.h
|
||||||
3rdparty/squirrel/include/squirrel.h
|
3rdparty/squirrel/include/squirrel.h
|
||||||
@@ -816,6 +810,8 @@ script/api/script_signlist.hpp
|
|||||||
script/api/script_station.hpp
|
script/api/script_station.hpp
|
||||||
script/api/script_stationlist.hpp
|
script/api/script_stationlist.hpp
|
||||||
script/api/script_story_page.hpp
|
script/api/script_story_page.hpp
|
||||||
|
script/api/script_storypagelist.hpp
|
||||||
|
script/api/script_storypageelementlist.hpp
|
||||||
script/api/script_subsidy.hpp
|
script/api/script_subsidy.hpp
|
||||||
script/api/script_subsidylist.hpp
|
script/api/script_subsidylist.hpp
|
||||||
script/api/script_testmode.hpp
|
script/api/script_testmode.hpp
|
||||||
@@ -880,6 +876,8 @@ script/api/script_signlist.cpp
|
|||||||
script/api/script_station.cpp
|
script/api/script_station.cpp
|
||||||
script/api/script_stationlist.cpp
|
script/api/script_stationlist.cpp
|
||||||
script/api/script_story_page.cpp
|
script/api/script_story_page.cpp
|
||||||
|
script/api/script_storypagelist.cpp
|
||||||
|
script/api/script_storypageelementlist.cpp
|
||||||
script/api/script_subsidy.cpp
|
script/api/script_subsidy.cpp
|
||||||
script/api/script_subsidylist.cpp
|
script/api/script_subsidylist.cpp
|
||||||
script/api/script_testmode.cpp
|
script/api/script_testmode.cpp
|
||||||
|
41
src/3rdparty/squirrel/COMPILE
vendored
41
src/3rdparty/squirrel/COMPILE
vendored
@@ -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!)
|
|
357
src/3rdparty/squirrel/HISTORY
vendored
357
src/3rdparty/squirrel/HISTORY
vendored
@@ -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
|
|
23
src/3rdparty/squirrel/Makefile
vendored
23
src/3rdparty/squirrel/Makefile
vendored
@@ -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
|
|
22
src/3rdparty/squirrel/README
vendored
22
src/3rdparty/squirrel/README
vendored
@@ -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
|
|
||||||
|
|
BIN
src/3rdparty/squirrel/doc/sqstdlib2.chm
vendored
BIN
src/3rdparty/squirrel/doc/sqstdlib2.chm
vendored
Binary file not shown.
1714
src/3rdparty/squirrel/doc/sqstdlib2.pdf
vendored
1714
src/3rdparty/squirrel/doc/sqstdlib2.pdf
vendored
File diff suppressed because it is too large
Load Diff
BIN
src/3rdparty/squirrel/doc/squirrel2.chm
vendored
BIN
src/3rdparty/squirrel/doc/squirrel2.chm
vendored
Binary file not shown.
6426
src/3rdparty/squirrel/doc/squirrel2.pdf
vendored
6426
src/3rdparty/squirrel/doc/squirrel2.pdf
vendored
File diff suppressed because it is too large
Load Diff
63
src/3rdparty/squirrel/etc/minimal.c
vendored
63
src/3rdparty/squirrel/etc/minimal.c
vendored
@@ -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;
|
|
||||||
}
|
|
4
src/3rdparty/squirrel/etc/test.nut
vendored
4
src/3rdparty/squirrel/etc/test.nut
vendored
@@ -1,4 +0,0 @@
|
|||||||
function foo(i, f, s)
|
|
||||||
{
|
|
||||||
print("Called foo(), i="+i+", f="+f+", s='"+s+"'\n");
|
|
||||||
}
|
|
20
src/3rdparty/squirrel/include/sqstdblob.h
vendored
20
src/3rdparty/squirrel/include/sqstdblob.h
vendored
@@ -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_*/
|
|
||||||
|
|
54
src/3rdparty/squirrel/include/sqstdio.h
vendored
54
src/3rdparty/squirrel/include/sqstdio.h
vendored
@@ -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_*/
|
|
||||||
|
|
15
src/3rdparty/squirrel/include/sqstdsystem.h
vendored
15
src/3rdparty/squirrel/include/sqstdsystem.h
vendored
@@ -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_ */
|
|
23
src/3rdparty/squirrel/samples/ackermann.nut
vendored
23
src/3rdparty/squirrel/samples/ackermann.nut
vendored
@@ -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));
|
|
||||||
|
|
28
src/3rdparty/squirrel/samples/array.nut
vendored
28
src/3rdparty/squirrel/samples/array.nut
vendored
@@ -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]);
|
|
49
src/3rdparty/squirrel/samples/class.nut
vendored
49
src/3rdparty/squirrel/samples/class.nut
vendored
@@ -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();
|
|
@@ -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")
|
|
||||||
}
|
|
||||||
}
|
|
25
src/3rdparty/squirrel/samples/coroutines.nut
vendored
25
src/3rdparty/squirrel/samples/coroutines.nut
vendored
@@ -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")
|
|
52
src/3rdparty/squirrel/samples/delegation.nut
vendored
52
src/3rdparty/squirrel/samples/delegation.nut
vendored
@@ -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();
|
|
15
src/3rdparty/squirrel/samples/fibonacci.nut
vendored
15
src/3rdparty/squirrel/samples/fibonacci.nut
vendored
@@ -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")
|
|
33
src/3rdparty/squirrel/samples/flow.nut
vendored
33
src/3rdparty/squirrel/samples/flow.nut
vendored
@@ -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");
|
|
42
src/3rdparty/squirrel/samples/generators.nut
vendored
42
src/3rdparty/squirrel/samples/generators.nut
vendored
@@ -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");
|
|
||||||
}
|
|
1
src/3rdparty/squirrel/samples/hello.nut
vendored
1
src/3rdparty/squirrel/samples/hello.nut
vendored
@@ -1 +0,0 @@
|
|||||||
print("Hello World!")
|
|
39
src/3rdparty/squirrel/samples/list.nut
vendored
39
src/3rdparty/squirrel/samples/list.nut
vendored
@@ -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");
|
|
32
src/3rdparty/squirrel/samples/loops.nut
vendored
32
src/3rdparty/squirrel/samples/loops.nut
vendored
@@ -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());
|
|
44
src/3rdparty/squirrel/samples/matrix.nut
vendored
44
src/3rdparty/squirrel/samples/matrix.nut
vendored
@@ -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]);
|
|
115
src/3rdparty/squirrel/samples/metamethods.nut
vendored
115
src/3rdparty/squirrel/samples/metamethods.nut
vendored
@@ -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");
|
|
61
src/3rdparty/squirrel/samples/methcall.nut
vendored
61
src/3rdparty/squirrel/samples/methcall.nut
vendored
@@ -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");
|
|
24
src/3rdparty/squirrel/samples/tailstate.nut
vendored
24
src/3rdparty/squirrel/samples/tailstate.nut
vendored
@@ -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");
|
|
24
src/3rdparty/squirrel/sq/Makefile
vendored
24
src/3rdparty/squirrel/sq/Makefile
vendored
@@ -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)
|
|
324
src/3rdparty/squirrel/sq/sq.c
vendored
324
src/3rdparty/squirrel/sq/sq.c
vendored
@@ -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;
|
|
||||||
}
|
|
||||||
|
|
101
src/3rdparty/squirrel/sq/sq.dsp
vendored
101
src/3rdparty/squirrel/sq/sq.dsp
vendored
@@ -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
|
|
31
src/3rdparty/squirrel/sqstdlib/Makefile
vendored
31
src/3rdparty/squirrel/sqstdlib/Makefile
vendored
@@ -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)
|
|
251
src/3rdparty/squirrel/sqstdlib/sqstdblob.cpp
vendored
251
src/3rdparty/squirrel/sqstdlib/sqstdblob.cpp
vendored
@@ -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);
|
|
||||||
}
|
|
||||||
|
|
108
src/3rdparty/squirrel/sqstdlib/sqstdblobimpl.h
vendored
108
src/3rdparty/squirrel/sqstdlib/sqstdblobimpl.h
vendored
@@ -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_
|
|
410
src/3rdparty/squirrel/sqstdlib/sqstdio.cpp
vendored
410
src/3rdparty/squirrel/sqstdlib/sqstdio.cpp
vendored
@@ -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;
|
|
||||||
}
|
|
131
src/3rdparty/squirrel/sqstdlib/sqstdlib.dsp
vendored
131
src/3rdparty/squirrel/sqstdlib/sqstdlib.dsp
vendored
@@ -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
|
|
330
src/3rdparty/squirrel/sqstdlib/sqstdstream.cpp
vendored
330
src/3rdparty/squirrel/sqstdlib/sqstdstream.cpp
vendored
@@ -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;
|
|
||||||
}
|
|
18
src/3rdparty/squirrel/sqstdlib/sqstdstream.h
vendored
18
src/3rdparty/squirrel/sqstdlib/sqstdstream.h
vendored
@@ -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_*/
|
|
147
src/3rdparty/squirrel/sqstdlib/sqstdsystem.cpp
vendored
147
src/3rdparty/squirrel/sqstdlib/sqstdsystem.cpp
vendored
@@ -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;
|
|
||||||
}
|
|
77
src/3rdparty/squirrel/squirrel.dsw
vendored
77
src/3rdparty/squirrel/squirrel.dsw
vendored
@@ -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>
|
|
||||||
{{{
|
|
||||||
}}}
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
52
src/3rdparty/squirrel/squirrel/Makefile
vendored
52
src/3rdparty/squirrel/squirrel/Makefile
vendored
@@ -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)
|
|
@@ -66,7 +66,7 @@ public:
|
|||||||
static SQChar temp[256];
|
static SQChar temp[256];
|
||||||
va_list vl;
|
va_list vl;
|
||||||
va_start(vl, s);
|
va_start(vl, s);
|
||||||
scvsprintf(temp, s, vl);
|
scvsnprintf(temp, sizeof(temp), s, vl);
|
||||||
va_end(vl);
|
va_end(vl);
|
||||||
throw temp;
|
throw temp;
|
||||||
}
|
}
|
||||||
|
302
src/3rdparty/squirrel/squirrel/squirrel.dsp
vendored
302
src/3rdparty/squirrel/squirrel/squirrel.dsp
vendored
@@ -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
|
|
@@ -853,7 +853,7 @@ struct AIConfigWindow : public Window {
|
|||||||
case WID_AIC_GAMELIST: {
|
case WID_AIC_GAMELIST: {
|
||||||
this->selected_slot = OWNER_DEITY;
|
this->selected_slot = OWNER_DEITY;
|
||||||
this->InvalidateData();
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -44,7 +44,7 @@ void CcBuildAirport(const CommandCost &result, TileIndex tile, uint32 p1, uint32
|
|||||||
{
|
{
|
||||||
if (result.Failed()) return;
|
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();
|
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->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
|
||||||
this->OnInvalidateData();
|
this->OnInvalidateData();
|
||||||
|
|
||||||
this->vscroll->SetCount(AirportClass::Get(_selected_airport_class)->GetSpecCount());
|
/* Ensure airport class is valid (changing NewGRFs). */
|
||||||
this->SelectFirstAvailableAirport(true);
|
_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()
|
virtual ~BuildAirportWindow()
|
||||||
|
@@ -160,6 +160,41 @@ CargoArray GetCapacityOfArticulatedParts(EngineID engine)
|
|||||||
return capacity;
|
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
|
* Checks whether any of the articulated parts is refittable
|
||||||
* @param engine the first part
|
* @param engine the first part
|
||||||
|
@@ -160,7 +160,7 @@ static void TransferCargo(Vehicle *old_veh, Vehicle *new_head, bool part_of_chai
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Update train weight etc., the old vehicle will be sold anyway */
|
/* Update train weight etc., the old vehicle will be sold anyway */
|
||||||
if (part_of_chain && new_head->type == VEH_TRAIN) Train::From(new_head)->ConsistChanged(true);
|
if (part_of_chain && new_head->type == VEH_TRAIN) Train::From(new_head)->ConsistChanged(CCF_LOADUNLOAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -276,10 +276,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WID_RV_INFO_TAB: {
|
case WID_RV_INFO_TAB: {
|
||||||
SetDParam(0, STR_REPLACE_NOT_REPLACING);
|
Dimension d = GetStringBoundingBox(STR_REPLACE_NOT_REPLACING);
|
||||||
Dimension d = GetStringBoundingBox(STR_BLACK_STRING);
|
d = maxdim(d, GetStringBoundingBox(STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED));
|
||||||
SetDParam(0, STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED);
|
|
||||||
d = maxdim(d, GetStringBoundingBox(STR_BLACK_STRING));
|
|
||||||
d.width += WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT;
|
d.width += WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT;
|
||||||
d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||||
*size = maxdim(*size, d);
|
*size = maxdim(*size, d);
|
||||||
@@ -351,20 +349,21 @@ public:
|
|||||||
switch (widget) {
|
switch (widget) {
|
||||||
case WID_RV_INFO_TAB: {
|
case WID_RV_INFO_TAB: {
|
||||||
const Company *c = Company::Get(_local_company);
|
const Company *c = Company::Get(_local_company);
|
||||||
|
StringID str;
|
||||||
if (this->sel_engine[0] != INVALID_ENGINE) {
|
if (this->sel_engine[0] != INVALID_ENGINE) {
|
||||||
if (!EngineHasReplacementForCompany(c, this->sel_engine[0], this->sel_group)) {
|
if (!EngineHasReplacementForCompany(c, this->sel_engine[0], this->sel_group)) {
|
||||||
SetDParam(0, STR_REPLACE_NOT_REPLACING);
|
str = STR_REPLACE_NOT_REPLACING;
|
||||||
} else {
|
} else {
|
||||||
bool when_old = false;
|
bool when_old = false;
|
||||||
EngineID e = EngineReplacementForCompany(c, this->sel_engine[0], this->sel_group, &when_old);
|
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);
|
str = when_old ? STR_REPLACE_REPLACING_WHEN_OLD : STR_ENGINE_NAME;
|
||||||
SetDParam(1, e);
|
SetDParam(0, e);
|
||||||
}
|
}
|
||||||
} else {
|
} 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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -100,7 +100,7 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
|
|||||||
|
|
||||||
/* Then find the MD5 checksum */
|
/* Then find the MD5 checksum */
|
||||||
item = md5s->GetItem(filename, false);
|
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);
|
DEBUG(grf, 0, "No MD5 checksum specified for: %s (in %s)", filename, full_filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -133,6 +133,46 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
|||||||
}
|
}
|
||||||
break;
|
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:
|
case BM_TRANSPARENT:
|
||||||
/* TODO -- We make an assumption here that the remap in fact is transparency, not some colour.
|
/* 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:
|
* 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_NORMAL: Draw<BM_NORMAL> (bp, zoom); return;
|
||||||
case BM_COLOUR_REMAP: Draw<BM_COLOUR_REMAP>(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_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 */
|
/* 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()
|
Blitter::PaletteAnimation Blitter_32bppAnim::UsePaletteAnimation()
|
||||||
|
@@ -313,6 +313,25 @@ bmcr_alpha_blend_single:
|
|||||||
if (src[0].a) anim[0] = 0;
|
if (src[0].a) anim[0] = 0;
|
||||||
}
|
}
|
||||||
break;
|
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:
|
next_line:
|
||||||
@@ -373,6 +392,7 @@ bm_normal:
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BM_TRANSPARENT: Draw<BM_TRANSPARENT, RM_NONE, BT_NONE, true, true>(bp, zoom); return;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -112,6 +112,19 @@ public:
|
|||||||
return Colour(r * nom / denom, g * nom / denom, b * nom / denom);
|
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.
|
* Make a colour grey - based.
|
||||||
* @param colour the colour to make grey.
|
* @param colour the colour to make grey.
|
||||||
|
@@ -141,6 +141,40 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
|
|||||||
}
|
}
|
||||||
break;
|
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:
|
case BM_TRANSPARENT:
|
||||||
/* TODO -- We make an assumption here that the remap in fact is transparency, not some colour.
|
/* 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:
|
* 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_NORMAL: Draw<BM_NORMAL> (bp, zoom); return;
|
||||||
case BM_COLOUR_REMAP: Draw<BM_COLOUR_REMAP>(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_TRANSPARENT: Draw<BM_TRANSPARENT> (bp, zoom); return;
|
||||||
|
case BM_CRASH_REMAP: Draw<BM_CRASH_REMAP> (bp, zoom); return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,6 +45,17 @@ void Blitter_32bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoo
|
|||||||
}
|
}
|
||||||
break;
|
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:
|
case BM_TRANSPARENT:
|
||||||
/* TODO -- We make an assumption here that the remap in fact is transparency, not some colour.
|
/* 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:
|
* This is never a problem with the code we produce, but newgrfs can make it fail... or at least:
|
||||||
|
@@ -36,6 +36,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::Sprite *sprite, Alloca
|
|||||||
|
|
||||||
/* Calculate sizes and allocate. */
|
/* Calculate sizes and allocate. */
|
||||||
SpriteData sd;
|
SpriteData sd;
|
||||||
|
memset(&sd, 0, sizeof(sd));
|
||||||
uint all_sprites_size = 0;
|
uint all_sprites_size = 0;
|
||||||
for (ZoomLevel z = zoom_min; z <= zoom_max; z++) {
|
for (ZoomLevel z = zoom_min; z <= zoom_max; z++) {
|
||||||
const SpriteLoader::Sprite *src_sprite = &sprite[z];
|
const SpriteLoader::Sprite *src_sprite = &sprite[z];
|
||||||
|
@@ -107,10 +107,10 @@ static Colour ReallyAdjustBrightness(Colour colour, uint8 brightness)
|
|||||||
c16 *= brightness;
|
c16 *= brightness;
|
||||||
uint64 c16_ob = c16; // Helps out of order execution.
|
uint64 c16_ob = c16; // Helps out of order execution.
|
||||||
c16 /= Blitter_32bppBase::DEFAULT_BRIGHTNESS;
|
c16 /= Blitter_32bppBase::DEFAULT_BRIGHTNESS;
|
||||||
c16 &= 0x01FF01FF01FF;
|
c16 &= 0x01FF01FF01FFULL;
|
||||||
|
|
||||||
/* Sum overbright (maximum for each rgb is 508, 9 bits, -255 is changed in -256 so we just have to take the 8 lower bits into account). */
|
/* Sum overbright (maximum for each rgb is 508, 9 bits, -255 is changed in -256 so we just have to take the 8 lower bits into account). */
|
||||||
c16_ob = (((c16_ob >> (8 + 7)) & 0x0100010001) * 0xFF) & c16;
|
c16_ob = (((c16_ob >> (8 + 7)) & 0x0100010001ULL) * 0xFF) & c16;
|
||||||
const uint ob = ((uint16) c16_ob + (uint16) (c16_ob >> 16) + (uint16) (c16_ob >> 32)) / 2;
|
const uint ob = ((uint16) c16_ob + (uint16) (c16_ob >> 16) + (uint16) (c16_ob >> 32)) / 2;
|
||||||
|
|
||||||
const uint32 alpha32 = colour.data & 0xFF000000;
|
const uint32 alpha32 = colour.data & 0xFF000000;
|
||||||
@@ -238,13 +238,13 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
|||||||
for (int y = bp->height; y != 0; y--) {
|
for (int y = bp->height; y != 0; y--) {
|
||||||
Colour *dst = dst_line;
|
Colour *dst = dst_line;
|
||||||
const Colour *src = src_rgba_line + META_LENGTH;
|
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) {
|
if (read_mode == RM_WITH_MARGIN) {
|
||||||
assert(bt_last == BT_NONE); // or you must ensure block type is preserved
|
assert(bt_last == BT_NONE); // or you must ensure block type is preserved
|
||||||
src += src_rgba_line[0].data;
|
src += src_rgba_line[0].data;
|
||||||
dst += 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;
|
const int width_diff = si->sprite_width - bp->width;
|
||||||
effective_width = bp->width - (int) src_rgba_line[0].data;
|
effective_width = bp->width - (int) src_rgba_line[0].data;
|
||||||
const int delta_diff = (int) src_rgba_line[1].data - width_diff;
|
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));
|
dst->data = _mm_cvtsi128_si32(DarkenTwoPixels(srcABCD, dstABCD, DARKEN_PARAM_1, DARKEN_PARAM_2));
|
||||||
}
|
}
|
||||||
break;
|
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:
|
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);
|
src_rgba_line = (const Colour*) ((const byte*) src_rgba_line + si->sprite_line_size);
|
||||||
dst_line += bp->pitch;
|
dst_line += bp->pitch;
|
||||||
}
|
}
|
||||||
@@ -429,6 +446,7 @@ bm_normal:
|
|||||||
Draw<BM_COLOUR_REMAP, RM_WITH_MARGIN, BT_NONE, true>(bp, zoom); return;
|
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_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 */
|
#endif /* FULL_ANIMATION */
|
||||||
|
@@ -83,7 +83,8 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z
|
|||||||
width -= pixels;
|
width -= pixels;
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case BM_COLOUR_REMAP: {
|
case BM_COLOUR_REMAP:
|
||||||
|
case BM_CRASH_REMAP: {
|
||||||
const uint8 *remap = bp->remap;
|
const uint8 *remap = bp->remap;
|
||||||
do {
|
do {
|
||||||
uint m = remap[*src];
|
uint m = remap[*src];
|
||||||
|
@@ -37,6 +37,7 @@ void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoom
|
|||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case BM_COLOUR_REMAP:
|
case BM_COLOUR_REMAP:
|
||||||
|
case BM_CRASH_REMAP:
|
||||||
colour = bp->remap[*src];
|
colour = bp->remap[*src];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@ enum BlitterMode {
|
|||||||
BM_NORMAL, ///< Perform the simple blitting.
|
BM_NORMAL, ///< Perform the simple blitting.
|
||||||
BM_COLOUR_REMAP, ///< Perform a colour remapping.
|
BM_COLOUR_REMAP, ///< Perform a colour remapping.
|
||||||
BM_TRANSPARENT, ///< Perform transparency colour remapping.
|
BM_TRANSPARENT, ///< Perform transparency colour remapping.
|
||||||
|
BM_CRASH_REMAP, ///< Perform a crash remapping.
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -244,7 +244,7 @@ bool HandleBootstrap()
|
|||||||
new BootstrapAskForDownloadWindow();
|
new BootstrapAskForDownloadWindow();
|
||||||
|
|
||||||
/* Process the user events. */
|
/* Process the user events. */
|
||||||
_video_driver->MainLoop();
|
VideoDriver::GetInstance()->MainLoop();
|
||||||
|
|
||||||
/* _exit_game is used to get out of the video driver's main loop.
|
/* _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
|
* In case GM_BOOTSTRAP is still set we did not exit it via the
|
||||||
|
@@ -526,21 +526,20 @@ static GUIEngineList::FilterFunction * const _filter_funcs[] = {
|
|||||||
&CargoFilter,
|
&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++) {
|
for (CargoID c = 0; c < NUM_CARGO; c++) {
|
||||||
if (cap[c] == 0) continue;
|
if (cap[c] == 0) continue;
|
||||||
|
|
||||||
SetDParam(0, c);
|
SetDParam(0, c);
|
||||||
SetDParam(1, cap[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);
|
DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
|
||||||
y += FONT_HEIGHT_NORMAL;
|
y += FONT_HEIGHT_NORMAL;
|
||||||
|
|
||||||
/* Only show as refittable once */
|
|
||||||
refittable = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return y;
|
return y;
|
||||||
@@ -825,7 +824,7 @@ int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number)
|
|||||||
|
|
||||||
if (articulated_cargo) {
|
if (articulated_cargo) {
|
||||||
/* Cargo type + capacity, or N/A */
|
/* 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) {
|
if (new_y == y) {
|
||||||
SetDParam(0, CT_INVALID);
|
SetDParam(0, CT_INVALID);
|
||||||
|
@@ -224,8 +224,7 @@ bool VehicleCargoReroute::operator()(CargoPacket *cp)
|
|||||||
}
|
}
|
||||||
if (this->source != this->destination) {
|
if (this->source != this->destination) {
|
||||||
this->source->RemoveFromMeta(cp_new, VehicleCargoList::MTA_TRANSFER, cp_new->Count());
|
this->source->RemoveFromMeta(cp_new, VehicleCargoList::MTA_TRANSFER, cp_new->Count());
|
||||||
this->source->AddToMeta(cp_new, VehicleCargoList::MTA_TRANSFER);
|
this->destination->AddToMeta(cp_new, VehicleCargoList::MTA_TRANSFER);
|
||||||
this->destination->action_counts[VehicleCargoList::MTA_TRANSFER] += cp_new->Count();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Legal, as front pushing doesn't invalidate iterators in std::list. */
|
/* Legal, as front pushing doesn't invalidate iterators in std::list. */
|
||||||
|
@@ -67,7 +67,7 @@ void ClearCargoDeliveryMonitoring(CompanyID company)
|
|||||||
* @param keep_monitoring After returning from this call, continue monitoring.
|
* @param keep_monitoring After returning from this call, continue monitoring.
|
||||||
* @return Amount collected since last query/activation for the monitored combination.
|
* @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);
|
CargoMonitorMap::iterator iter = monitor_map.find(monitor);
|
||||||
if (iter == monitor_map.end()) {
|
if (iter == monitor_map.end()) {
|
||||||
@@ -77,7 +77,7 @@ static uint32 GetAmount(CargoMonitorMap &monitor_map, CargoMonitorID monitor, bo
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
uint32 result = iter->second;
|
int32 result = iter->second;
|
||||||
iter->second = 0;
|
iter->second = 0;
|
||||||
if (!keep_monitoring) monitor_map.erase(iter);
|
if (!keep_monitoring) monitor_map.erase(iter);
|
||||||
return result;
|
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.
|
* @param keep_monitoring After returning from this call, continue monitoring.
|
||||||
* @return Amount of delivered cargo for the monitored combination.
|
* @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);
|
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.
|
* @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.
|
* @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);
|
return GetAmount(_cargo_pickups, monitor, keep_monitoring);
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
#include "company_func.h"
|
#include "company_func.h"
|
||||||
#include "industry.h"
|
#include "industry.h"
|
||||||
#include "town.h"
|
#include "town.h"
|
||||||
|
#include "core/overflowsafe_type.hpp"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
struct Station;
|
struct Station;
|
||||||
@@ -31,7 +32,7 @@ struct Station;
|
|||||||
typedef uint32 CargoMonitorID; ///< Type of the cargo monitor number.
|
typedef uint32 CargoMonitorID; ///< Type of the cargo monitor number.
|
||||||
|
|
||||||
/** Map type for storing and updating active cargo monitor numbers and their amounts. */
|
/** 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_pickups;
|
||||||
extern CargoMonitorMap _cargo_deliveries;
|
extern CargoMonitorMap _cargo_deliveries;
|
||||||
@@ -141,8 +142,8 @@ static inline TownID DecodeMonitorTown(CargoMonitorID num)
|
|||||||
|
|
||||||
void ClearCargoPickupMonitoring(CompanyID company = INVALID_OWNER);
|
void ClearCargoPickupMonitoring(CompanyID company = INVALID_OWNER);
|
||||||
void ClearCargoDeliveryMonitoring(CompanyID company = INVALID_OWNER);
|
void ClearCargoDeliveryMonitoring(CompanyID company = INVALID_OWNER);
|
||||||
uint32 GetDeliveryAmount(CargoMonitorID monitor, bool keep_monitoring);
|
int32 GetDeliveryAmount(CargoMonitorID monitor, bool keep_monitoring);
|
||||||
uint32 GetPickupAmount(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);
|
void AddCargoDelivery(CargoID cargo_type, CompanyID company, uint32 amount, SourceType src_type, SourceID src, const Station *st);
|
||||||
|
|
||||||
#endif /* CARGOMONITOR_H */
|
#endif /* CARGOMONITOR_H */
|
||||||
|
@@ -544,17 +544,54 @@ void VehicleCargoList::InvalidateCache()
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves some cargo from one designation to another. You can only move
|
* Moves some cargo from one designation to another. You can only move
|
||||||
* between adjacent designations. E.g. you can keep cargo that was
|
* between adjacent designations. E.g. you can keep cargo that was previously
|
||||||
* previously reserved (MTA_LOAD) or you can mark cargo to be transferred
|
* reserved (MTA_LOAD), but you can't reserve cargo that's marked as to be
|
||||||
* that was previously marked as to be delivered, but you can't reserve
|
* delivered. Furthermore, as this method doesn't change the actual packets,
|
||||||
* cargo that's marked as to be delivered.
|
* you cannot move cargo from or to MTA_TRANSFER. You need a specialized
|
||||||
|
* template method for that.
|
||||||
|
* @tparam from Previous designation of cargo.
|
||||||
|
* @tparam to New designation of cargo.
|
||||||
|
* @param max_move Maximum amount of cargo to reassign.
|
||||||
|
* @return Amount of cargo actually reassigned.
|
||||||
*/
|
*/
|
||||||
uint VehicleCargoList::Reassign(uint max_move, MoveToAction from, MoveToAction to)
|
template<VehicleCargoList::MoveToAction Tfrom, VehicleCargoList::MoveToAction Tto>
|
||||||
|
uint VehicleCargoList::Reassign(uint max_move, TileOrStationID)
|
||||||
{
|
{
|
||||||
max_move = min(this->action_counts[from], max_move);
|
assert_tcompile(Tfrom != MTA_TRANSFER && Tto != MTA_TRANSFER);
|
||||||
assert(Delta((int)from, (int)to) == 1);
|
assert_tcompile(Tfrom - Tto == 1 || Tto - Tfrom == 1);
|
||||||
this->action_counts[from] -= max_move;
|
max_move = min(this->action_counts[Tfrom], max_move);
|
||||||
this->action_counts[to] += max_move;
|
this->action_counts[Tfrom] -= max_move;
|
||||||
|
this->action_counts[Tto] += max_move;
|
||||||
|
return max_move;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reassign cargo from MTA_DELIVER to MTA_TRANSFER and take care of the next
|
||||||
|
* station the cargo wants to visit.
|
||||||
|
* @param max_move Maximum amount of cargo to reassign.
|
||||||
|
* @param next_station Station to record as next hop in the reassigned packets.
|
||||||
|
* @return Amount of cargo actually reassigned.
|
||||||
|
*/
|
||||||
|
template<>
|
||||||
|
uint VehicleCargoList::Reassign<VehicleCargoList::MTA_DELIVER, VehicleCargoList::MTA_TRANSFER>(uint max_move, TileOrStationID next_station)
|
||||||
|
{
|
||||||
|
max_move = min(this->action_counts[MTA_DELIVER], max_move);
|
||||||
|
|
||||||
|
uint sum = 0;
|
||||||
|
for (Iterator it(this->packets.begin()); sum < this->action_counts[MTA_TRANSFER] + max_move;) {
|
||||||
|
CargoPacket *cp = *it++;
|
||||||
|
sum += cp->Count();
|
||||||
|
if (sum <= this->action_counts[MTA_TRANSFER]) continue;
|
||||||
|
if (sum > this->action_counts[MTA_TRANSFER] + max_move) {
|
||||||
|
CargoPacket *cp_split = cp->Split(sum - this->action_counts[MTA_TRANSFER] + max_move);
|
||||||
|
sum -= cp_split->Count();
|
||||||
|
this->packets.insert(it, cp_split);
|
||||||
|
}
|
||||||
|
cp->next_station = next_station;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->action_counts[MTA_DELIVER] -= max_move;
|
||||||
|
this->action_counts[MTA_TRANSFER] += max_move;
|
||||||
return max_move;
|
return max_move;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -806,7 +843,7 @@ uint StationCargoList::Load(uint max_move, VehicleCargoList *dest, TileIndex loa
|
|||||||
uint move = min(dest->ActionCount(VehicleCargoList::MTA_LOAD), max_move);
|
uint move = min(dest->ActionCount(VehicleCargoList::MTA_LOAD), max_move);
|
||||||
if (move > 0) {
|
if (move > 0) {
|
||||||
this->reserved_count -= move;
|
this->reserved_count -= move;
|
||||||
dest->Reassign(move, VehicleCargoList::MTA_LOAD, VehicleCargoList::MTA_KEEP);
|
dest->Reassign<VehicleCargoList::MTA_LOAD, VehicleCargoList::MTA_KEEP>(move);
|
||||||
return move;
|
return move;
|
||||||
} else {
|
} else {
|
||||||
return this->ShiftCargo(CargoLoad(this, dest, max_move, load_place), next_station, true);
|
return this->ShiftCargo(CargoLoad(this, dest, max_move, load_place), next_station, true);
|
||||||
@@ -831,3 +868,4 @@ uint StationCargoList::Reroute(uint max_move, StationCargoList *dest, StationID
|
|||||||
*/
|
*/
|
||||||
template class CargoList<VehicleCargoList, CargoPacketList>;
|
template class CargoList<VehicleCargoList, CargoPacketList>;
|
||||||
template class CargoList<StationCargoList, StationCargoPacketMap>;
|
template class CargoList<StationCargoList, StationCargoPacketMap>;
|
||||||
|
template uint VehicleCargoList::Reassign<VehicleCargoList::MTA_DELIVER, VehicleCargoList::MTA_KEEP>(uint, TileOrStationID);
|
||||||
|
@@ -157,7 +157,7 @@ public:
|
|||||||
* Gets the ID of the station where the cargo was loaded for the first time.
|
* Gets the ID of the station where the cargo was loaded for the first time.
|
||||||
* @return StationID.
|
* @return StationID.
|
||||||
*/
|
*/
|
||||||
inline SourceID SourceStation() const
|
inline StationID SourceStation() const
|
||||||
{
|
{
|
||||||
return this->source;
|
return this->source;
|
||||||
}
|
}
|
||||||
@@ -429,7 +429,8 @@ public:
|
|||||||
* amount of cargo to be moved. Second parameter is destination (if
|
* amount of cargo to be moved. Second parameter is destination (if
|
||||||
* applicable), return value is amount of cargo actually moved. */
|
* applicable), return value is amount of cargo actually moved. */
|
||||||
|
|
||||||
uint Reassign(uint max_move, MoveToAction from, MoveToAction to);
|
template<MoveToAction Tfrom, MoveToAction Tto>
|
||||||
|
uint Reassign(uint max_move, TileOrStationID update = INVALID_TILE);
|
||||||
uint Return(uint max_move, StationCargoList *dest, StationID next_station);
|
uint Return(uint max_move, StationCargoList *dest, StationID next_station);
|
||||||
uint Unload(uint max_move, StationCargoList *dest, CargoPayment *payment);
|
uint Unload(uint max_move, StationCargoList *dest, CargoPayment *payment);
|
||||||
uint Shift(uint max_move, VehicleCargoList *dest);
|
uint Shift(uint max_move, VehicleCargoList *dest);
|
||||||
|
@@ -160,8 +160,10 @@ CommandProc CmdCreateStoryPage;
|
|||||||
CommandProc CmdCreateStoryPageElement;
|
CommandProc CmdCreateStoryPageElement;
|
||||||
CommandProc CmdUpdateStoryPageElement;
|
CommandProc CmdUpdateStoryPageElement;
|
||||||
CommandProc CmdSetStoryPageTitle;
|
CommandProc CmdSetStoryPageTitle;
|
||||||
|
CommandProc CmdSetStoryPageDate;
|
||||||
CommandProc CmdShowStoryPage;
|
CommandProc CmdShowStoryPage;
|
||||||
CommandProc CmdRemoveStoryPage;
|
CommandProc CmdRemoveStoryPage;
|
||||||
|
CommandProc CmdRemoveStoryPageElement;
|
||||||
|
|
||||||
CommandProc CmdLevelLand;
|
CommandProc CmdLevelLand;
|
||||||
|
|
||||||
@@ -244,7 +246,7 @@ static const Command _command_proc_table[] = {
|
|||||||
DEF_CMD(CmdForceTrainProceed, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_FORCE_TRAIN_PROCEED
|
DEF_CMD(CmdForceTrainProceed, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_FORCE_TRAIN_PROCEED
|
||||||
DEF_CMD(CmdReverseTrainDirection, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_REVERSE_TRAIN_DIRECTION
|
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(CmdModifyOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_MODIFY_ORDER
|
||||||
DEF_CMD(CmdSkipToOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SKIP_TO_ORDER
|
DEF_CMD(CmdSkipToOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SKIP_TO_ORDER
|
||||||
DEF_CMD(CmdDeleteOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_DELETE_ORDER
|
DEF_CMD(CmdDeleteOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_DELETE_ORDER
|
||||||
@@ -312,8 +314,10 @@ static const Command _command_proc_table[] = {
|
|||||||
DEF_CMD(CmdCreateStoryPageElement, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_CREATE_STORY_PAGE_ELEMENT
|
DEF_CMD(CmdCreateStoryPageElement, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_CREATE_STORY_PAGE_ELEMENT
|
||||||
DEF_CMD(CmdUpdateStoryPageElement, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_UPDATE_STORY_PAGE_ELEMENT
|
DEF_CMD(CmdUpdateStoryPageElement, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_UPDATE_STORY_PAGE_ELEMENT
|
||||||
DEF_CMD(CmdSetStoryPageTitle, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_SET_STORY_PAGE_TITLE
|
DEF_CMD(CmdSetStoryPageTitle, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_SET_STORY_PAGE_TITLE
|
||||||
|
DEF_CMD(CmdSetStoryPageDate, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_SET_STORY_PAGE_DATE
|
||||||
DEF_CMD(CmdShowStoryPage, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_SHOW_STORY_PAGE
|
DEF_CMD(CmdShowStoryPage, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_SHOW_STORY_PAGE
|
||||||
DEF_CMD(CmdRemoveStoryPage, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_REMOVE_STORY_PAGE
|
DEF_CMD(CmdRemoveStoryPage, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_REMOVE_STORY_PAGE
|
||||||
|
DEF_CMD(CmdRemoveStoryPageElement, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_REMOVE_STORY_ELEMENT_PAGE
|
||||||
|
|
||||||
DEF_CMD(CmdLevelLand, CMD_ALL_TILES | CMD_NO_TEST | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_LEVEL_LAND; test run might clear tiles multiple times, in execution that only happens once
|
DEF_CMD(CmdLevelLand, CMD_ALL_TILES | CMD_NO_TEST | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_LEVEL_LAND; test run might clear tiles multiple times, in execution that only happens once
|
||||||
|
|
||||||
@@ -597,7 +601,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac
|
|||||||
* @param cmd the command cost to return.
|
* @param cmd the command cost to return.
|
||||||
* @param clear whether to keep the storage changes or not.
|
* @param clear whether to keep the storage changes or not.
|
||||||
*/
|
*/
|
||||||
#define return_dcpi(cmd, clear) { _docommand_recursive = 0; ClearPersistentStorageChanges(clear); return cmd; }
|
#define return_dcpi(cmd) { _docommand_recursive = 0; return cmd; }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Helper function for the toplevel network safe docommand function for the current company.
|
* Helper function for the toplevel network safe docommand function for the current company.
|
||||||
@@ -641,7 +645,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Do not even think about executing out-of-bounds tile-commands */
|
/* Do not even think about executing out-of-bounds tile-commands */
|
||||||
if (tile != 0 && (tile >= MapSize() || (!IsValidTile(tile) && (cmd_flags & CMD_ALL_TILES) == 0))) return_dcpi(CMD_ERROR, false);
|
if (tile != 0 && (tile >= MapSize() || (!IsValidTile(tile) && (cmd_flags & CMD_ALL_TILES) == 0))) return_dcpi(CMD_ERROR);
|
||||||
|
|
||||||
/* Always execute server and spectator commands as spectator */
|
/* Always execute server and spectator commands as spectator */
|
||||||
bool exec_as_spectator = (cmd_flags & (CMD_SPECTATOR | CMD_SERVER)) != 0;
|
bool exec_as_spectator = (cmd_flags & (CMD_SPECTATOR | CMD_SERVER)) != 0;
|
||||||
@@ -650,7 +654,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
|
|||||||
* The server will ditch any server commands a client sends to it, so effectively
|
* The server will ditch any server commands a client sends to it, so effectively
|
||||||
* this guards the server from executing functions for an invalid company. */
|
* this guards the server from executing functions for an invalid company. */
|
||||||
if (_game_mode == GM_NORMAL && !exec_as_spectator && !Company::IsValidID(_current_company) && !(_current_company == OWNER_DEITY && (cmd_flags & CMD_DEITY) != 0)) {
|
if (_game_mode == GM_NORMAL && !exec_as_spectator && !Company::IsValidID(_current_company) && !(_current_company == OWNER_DEITY && (cmd_flags & CMD_DEITY) != 0)) {
|
||||||
return_dcpi(CMD_ERROR, false);
|
return_dcpi(CMD_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
|
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
|
||||||
@@ -661,8 +665,9 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
|
|||||||
/* Test the command. */
|
/* Test the command. */
|
||||||
_cleared_object_areas.Clear();
|
_cleared_object_areas.Clear();
|
||||||
SetTownRatingTestMode(true);
|
SetTownRatingTestMode(true);
|
||||||
ClearPersistentStorageChanges(false);
|
BasePersistentStorageArray::SwitchMode(PSM_ENTER_TESTMODE);
|
||||||
CommandCost res = proc(tile, flags, p1, p2, text);
|
CommandCost res = proc(tile, flags, p1, p2, text);
|
||||||
|
BasePersistentStorageArray::SwitchMode(PSM_LEAVE_TESTMODE);
|
||||||
SetTownRatingTestMode(false);
|
SetTownRatingTestMode(false);
|
||||||
|
|
||||||
/* Make sure we're not messing things up here. */
|
/* Make sure we're not messing things up here. */
|
||||||
@@ -681,7 +686,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
|
|||||||
DEBUG(desync, 1, "cmdf: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
|
DEBUG(desync, 1, "cmdf: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
|
||||||
}
|
}
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
return_dcpi(res, false);
|
return_dcpi(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
@@ -697,7 +702,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
|
|||||||
* This way it's not handled by DoCommand and only the
|
* This way it's not handled by DoCommand and only the
|
||||||
* actual execution of the command causes messages. Also
|
* actual execution of the command causes messages. Also
|
||||||
* reset the storages as we've not executed the command. */
|
* reset the storages as we've not executed the command. */
|
||||||
return_dcpi(CommandCost(), false);
|
return_dcpi(CommandCost());
|
||||||
}
|
}
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
DEBUG(desync, 1, "cmd: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
|
DEBUG(desync, 1, "cmd: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
|
||||||
@@ -705,8 +710,9 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
|
|||||||
/* Actually try and execute the command. If no cost-type is given
|
/* Actually try and execute the command. If no cost-type is given
|
||||||
* use the construction one */
|
* use the construction one */
|
||||||
_cleared_object_areas.Clear();
|
_cleared_object_areas.Clear();
|
||||||
ClearPersistentStorageChanges(false);
|
BasePersistentStorageArray::SwitchMode(PSM_ENTER_COMMAND);
|
||||||
CommandCost res2 = proc(tile, flags | DC_EXEC, p1, p2, text);
|
CommandCost res2 = proc(tile, flags | DC_EXEC, p1, p2, text);
|
||||||
|
BasePersistentStorageArray::SwitchMode(PSM_LEAVE_COMMAND);
|
||||||
|
|
||||||
if (cmd_id == CMD_COMPANY_CTRL) {
|
if (cmd_id == CMD_COMPANY_CTRL) {
|
||||||
cur_company.Trash();
|
cur_company.Trash();
|
||||||
@@ -727,7 +733,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
|
|||||||
if (!test_and_exec_can_differ) {
|
if (!test_and_exec_can_differ) {
|
||||||
assert(res.GetCost() == res2.GetCost() && res.Failed() == res2.Failed()); // sanity check
|
assert(res.GetCost() == res2.GetCost() && res.Failed() == res2.Failed()); // sanity check
|
||||||
} else if (res2.Failed()) {
|
} else if (res2.Failed()) {
|
||||||
return_dcpi(res2, false);
|
return_dcpi(res2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we're needing more money and we haven't done
|
/* If we're needing more money and we haven't done
|
||||||
@@ -737,7 +743,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
|
|||||||
* So make sure the signal buffer is empty even in this case */
|
* So make sure the signal buffer is empty even in this case */
|
||||||
UpdateSignalsInBuffer();
|
UpdateSignalsInBuffer();
|
||||||
SetDParam(0, _additional_cash_required);
|
SetDParam(0, _additional_cash_required);
|
||||||
return_dcpi(CommandCost(STR_ERROR_NOT_ENOUGH_CASH_REQUIRES_CURRENCY), false);
|
return_dcpi(CommandCost(STR_ERROR_NOT_ENOUGH_CASH_REQUIRES_CURRENCY));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update last build coordinate of company. */
|
/* update last build coordinate of company. */
|
||||||
@@ -751,7 +757,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
|
|||||||
/* update signals if needed */
|
/* update signals if needed */
|
||||||
UpdateSignalsInBuffer();
|
UpdateSignalsInBuffer();
|
||||||
|
|
||||||
return_dcpi(res2, true);
|
return_dcpi(res2);
|
||||||
}
|
}
|
||||||
#undef return_dcpi
|
#undef return_dcpi
|
||||||
|
|
||||||
|
@@ -288,8 +288,10 @@ enum Commands {
|
|||||||
CMD_CREATE_STORY_PAGE_ELEMENT, ///< create a new story page element
|
CMD_CREATE_STORY_PAGE_ELEMENT, ///< create a new story page element
|
||||||
CMD_UPDATE_STORY_PAGE_ELEMENT, ///< update a story page element
|
CMD_UPDATE_STORY_PAGE_ELEMENT, ///< update a story page element
|
||||||
CMD_SET_STORY_PAGE_TITLE, ///< update title of a story page
|
CMD_SET_STORY_PAGE_TITLE, ///< update title of a story page
|
||||||
|
CMD_SET_STORY_PAGE_DATE, ///< update date of a story page
|
||||||
CMD_SHOW_STORY_PAGE, ///< show a story page
|
CMD_SHOW_STORY_PAGE, ///< show a story page
|
||||||
CMD_REMOVE_STORY_PAGE, ///< remove a story page
|
CMD_REMOVE_STORY_PAGE, ///< remove a story page
|
||||||
|
CMD_REMOVE_STORY_PAGE_ELEMENT, ///< remove a story page element
|
||||||
CMD_LEVEL_LAND, ///< level land
|
CMD_LEVEL_LAND, ///< level land
|
||||||
|
|
||||||
CMD_BUILD_LOCK, ///< build a lock
|
CMD_BUILD_LOCK, ///< build a lock
|
||||||
|
@@ -853,59 +853,21 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_network_server) {
|
NetworkServerNewCompany(c, ci);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 1: // Make a new AI company
|
case 1: { // Make a new AI company
|
||||||
if (!(flags & DC_EXEC)) return CommandCost();
|
if (!(flags & DC_EXEC)) return CommandCost();
|
||||||
|
|
||||||
if (company_id != INVALID_COMPANY && (company_id >= MAX_COMPANIES || Company::IsValidID(company_id))) return CMD_ERROR;
|
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;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 2: { // Delete a company
|
case 2: { // Delete a company
|
||||||
CompanyRemoveReason reason = (CompanyRemoveReason)GB(p2, 0, 2);
|
CompanyRemoveReason reason = (CompanyRemoveReason)GB(p2, 0, 2);
|
||||||
|
@@ -2013,7 +2013,7 @@ struct CompanyWindow : Window
|
|||||||
NWidgetStacked *wi = this->GetWidget<NWidgetStacked>(WID_C_SELECT_BUTTONS);
|
NWidgetStacked *wi = this->GetWidget<NWidgetStacked>(WID_C_SELECT_BUTTONS);
|
||||||
if (plane != wi->shown_plane) {
|
if (plane != wi->shown_plane) {
|
||||||
wi->SetDisplayedPlane(plane);
|
wi->SetDisplayedPlane(plane);
|
||||||
this->SetDirty();
|
this->InvalidateData();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -185,7 +185,7 @@ struct IConsoleWindow : Window
|
|||||||
~IConsoleWindow()
|
~IConsoleWindow()
|
||||||
{
|
{
|
||||||
_iconsole_mode = ICONSOLE_CLOSED;
|
_iconsole_mode = ICONSOLE_CLOSED;
|
||||||
_video_driver->EditBoxLostFocus();
|
VideoDriver::GetInstance()->EditBoxLostFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -374,7 +374,7 @@ struct IConsoleWindow : Window
|
|||||||
|
|
||||||
virtual void OnFocusLost()
|
virtual void OnFocusLost()
|
||||||
{
|
{
|
||||||
_video_driver->EditBoxLostFocus();
|
VideoDriver::GetInstance()->EditBoxLostFocus();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
#ifndef OVERFLOWSAFE_TYPE_HPP
|
#ifndef OVERFLOWSAFE_TYPE_HPP
|
||||||
#define OVERFLOWSAFE_TYPE_HPP
|
#define OVERFLOWSAFE_TYPE_HPP
|
||||||
|
|
||||||
|
#include "math_func.hpp"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overflow safe template for integers, i.e. integers that will never overflow
|
* 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; }
|
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<int64, INT64_MAX, INT64_MIN> OverflowSafeInt64;
|
||||||
|
typedef OverflowSafeInt<int32, INT32_MAX, INT32_MIN> OverflowSafeInt32;
|
||||||
|
|
||||||
#endif /* OVERFLOWSAFE_TYPE_HPP */
|
#endif /* OVERFLOWSAFE_TYPE_HPP */
|
||||||
|
@@ -81,6 +81,9 @@ private:
|
|||||||
*/
|
*/
|
||||||
template <class Titem, typename Tindex, size_t Tgrowth_step, size_t Tmax_size, PoolType Tpool_type = PT_NORMAL, bool Tcache = false, bool Tzero = true>
|
template <class Titem, typename Tindex, size_t Tgrowth_step, size_t Tmax_size, PoolType Tpool_type = PT_NORMAL, bool Tcache = false, bool Tzero = true>
|
||||||
struct Pool : PoolBase {
|
struct Pool : PoolBase {
|
||||||
|
/* Ensure Tmax_size is within the bounds of Tindex. */
|
||||||
|
assert_compile((uint64)(Tmax_size - 1) >> 8 * sizeof(Tindex) == 0);
|
||||||
|
|
||||||
static const size_t MAX_SIZE = Tmax_size; ///< Make template parameter accessible from outside
|
static const size_t MAX_SIZE = Tmax_size; ///< Make template parameter accessible from outside
|
||||||
|
|
||||||
const char * const name; ///< Name of this pool
|
const char * const name; ///< Name of this pool
|
||||||
|
@@ -12,16 +12,90 @@
|
|||||||
#ifndef SMALLSTACK_TYPE_HPP
|
#ifndef SMALLSTACK_TYPE_HPP
|
||||||
#define SMALLSTACK_TYPE_HPP
|
#define SMALLSTACK_TYPE_HPP
|
||||||
|
|
||||||
#include "pool_type.hpp"
|
#include "smallvec_type.hpp"
|
||||||
#include "pool_func.hpp"
|
#include "../thread/thread.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simplified pool which stores values instead of pointers and doesn't
|
||||||
|
* redefine operator new/delete. It also never zeroes memory and always reuses
|
||||||
|
* it.
|
||||||
|
*/
|
||||||
|
template<typename Titem, typename Tindex, Tindex Tgrowth_step, Tindex Tmax_size>
|
||||||
|
class SimplePool {
|
||||||
|
public:
|
||||||
|
inline SimplePool() : first_unused(0), first_free(0), mutex(ThreadMutex::New()) {}
|
||||||
|
inline ~SimplePool() { delete this->mutex; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the mutex. We don't lock the mutex in the pool methods as the
|
||||||
|
* SmallStack isn't necessarily in a consistent state after each method.
|
||||||
|
* @return Mutex.
|
||||||
|
*/
|
||||||
|
inline ThreadMutex *GetMutex() { return this->mutex; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the item at position index.
|
||||||
|
* @return Item at index.
|
||||||
|
*/
|
||||||
|
inline Titem &Get(Tindex index) { return this->data[index]; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new item and return its index.
|
||||||
|
* @return Index of new item.
|
||||||
|
*/
|
||||||
|
inline Tindex Create()
|
||||||
|
{
|
||||||
|
Tindex index = this->FindFirstFree();
|
||||||
|
if (index < Tmax_size) {
|
||||||
|
this->data[index].valid = true;
|
||||||
|
this->first_free = index + 1;
|
||||||
|
this->first_unused = max(this->first_unused, this->first_free);
|
||||||
|
}
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy (or rather invalidate) the item at the given index.
|
||||||
|
* @param index Index of item to be destroyed.
|
||||||
|
*/
|
||||||
|
inline void Destroy(Tindex index)
|
||||||
|
{
|
||||||
|
this->data[index].valid = false;
|
||||||
|
this->first_free = min(this->first_free, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
inline Tindex FindFirstFree()
|
||||||
|
{
|
||||||
|
Tindex index = this->first_free;
|
||||||
|
for (; index < this->first_unused; index++) {
|
||||||
|
if (!this->data[index].valid) return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index >= this->data.Length() && index < Tmax_size) {
|
||||||
|
this->data.Resize(index + 1);
|
||||||
|
}
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct SimplePoolPoolItem : public Titem {
|
||||||
|
bool valid;
|
||||||
|
};
|
||||||
|
|
||||||
|
Tindex first_unused;
|
||||||
|
Tindex first_free;
|
||||||
|
|
||||||
|
ThreadMutex *mutex;
|
||||||
|
SmallVector<SimplePoolPoolItem, Tgrowth_step> data;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for SmallStack. We cannot add this into SmallStack itself as
|
* Base class for SmallStack. We cannot add this into SmallStack itself as
|
||||||
* certain compilers don't like it.
|
* certain compilers don't like it.
|
||||||
*/
|
*/
|
||||||
template <typename Tindex, typename Titem>
|
template <typename Titem, typename Tindex>
|
||||||
class SmallStackItem {
|
struct SmallStackItem {
|
||||||
protected:
|
|
||||||
Tindex next; ///< Pool index of next item.
|
Tindex next; ///< Pool index of next item.
|
||||||
Titem value; ///< Value of current item.
|
Titem value; ///< Value of current item.
|
||||||
|
|
||||||
@@ -50,30 +124,30 @@ protected:
|
|||||||
* 5. You can choose your own index type, so that you can align it with your
|
* 5. You can choose your own index type, so that you can align it with your
|
||||||
* value type. E.G. value types of 16 bits length like to be combined with
|
* value type. E.G. value types of 16 bits length like to be combined with
|
||||||
* index types of the same length.
|
* index types of the same length.
|
||||||
|
* 6. All accesses to the underlying pool are guarded by a mutex and atomic in
|
||||||
|
* the sense that the mutex stays locked until the pool has reacquired a
|
||||||
|
* consistent state. This means that even though a common data structure is
|
||||||
|
* used the SmallStack is still reentrant.
|
||||||
* @tparam Titem Value type to be used.
|
* @tparam Titem Value type to be used.
|
||||||
* @tparam Tindex Index type to use for the pool.
|
* @tparam Tindex Index type to use for the pool.
|
||||||
* @tparam Tinvalid Invalid item to keep at the bottom of each stack.
|
* @tparam Tinvalid Invalid item to keep at the bottom of each stack.
|
||||||
* @tparam Tgrowth_step Growth step for pool.
|
* @tparam Tgrowth_step Growth step for pool.
|
||||||
* @tparam Tmax_size Maximum size for pool.
|
* @tparam Tmax_size Maximum size for pool.
|
||||||
*/
|
*/
|
||||||
template <typename Titem, typename Tindex, Titem Tinvalid, size_t Tgrowth_step, size_t Tmax_size>
|
template <typename Titem, typename Tindex, Titem Tinvalid, Tindex Tgrowth_step, Tindex Tmax_size>
|
||||||
class SmallStack : public SmallStackItem<Tindex, Titem> {
|
class SmallStack : public SmallStackItem<Titem, Tindex> {
|
||||||
protected:
|
public:
|
||||||
class PooledSmallStack;
|
|
||||||
|
typedef SmallStackItem<Titem, Tindex> Item;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a branch in the pool if necessary.
|
* SmallStack item that can be kept in a pool.
|
||||||
*/
|
*/
|
||||||
void Branch()
|
struct PooledSmallStack : public Item {
|
||||||
{
|
Tindex branch_count; ///< Number of branches in the tree structure this item is parent of
|
||||||
if (PooledSmallStack::IsValidID(this->next)) {
|
};
|
||||||
PooledSmallStack::Get(this->next)->CreateBranch();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
typedef SimplePool<PooledSmallStack, Tindex, Tgrowth_step, Tmax_size> SmallStackPool;
|
||||||
typedef SmallStackItem<Tindex, Titem> Item;
|
|
||||||
typedef Pool<PooledSmallStack, Tindex, Tgrowth_step, Tmax_size, PT_NORMAL, true, false> SmallStackPool;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for a stack with one or two items in it.
|
* Constructor for a stack with one or two items in it.
|
||||||
@@ -86,14 +160,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
inline ~SmallStack()
|
inline ~SmallStack()
|
||||||
{
|
{
|
||||||
if (PooledSmallStack::IsValidID(this->next)) {
|
/* Pop() locks the mutex and after each pop the pool is consistent.*/
|
||||||
PooledSmallStack *item = PooledSmallStack::Get(this->next);
|
while (this->next != Tmax_size) this->Pop();
|
||||||
if (item->NumBranches() == 0) {
|
|
||||||
delete item;
|
|
||||||
} else {
|
|
||||||
item->DeleteBranch();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,23 +178,32 @@ public:
|
|||||||
inline SmallStack &operator=(const SmallStack &other)
|
inline SmallStack &operator=(const SmallStack &other)
|
||||||
{
|
{
|
||||||
if (this == &other) return *this;
|
if (this == &other) return *this;
|
||||||
this->~SmallStack();
|
while (this->next != Tmax_size) this->Pop();
|
||||||
this->next = other.next;
|
this->next = other.next;
|
||||||
this->value = other.value;
|
this->value = other.value;
|
||||||
|
/* Deleting and branching are independent operations, so it's fine to
|
||||||
|
* acquire separate locks for them. */
|
||||||
this->Branch();
|
this->Branch();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Push a new item onto the stack.
|
* Pushes a new item onto the stack if there is still space in the
|
||||||
|
* underlying pool. Otherwise the topmost item's value gets overwritten.
|
||||||
* @param item Item to be pushed.
|
* @param item Item to be pushed.
|
||||||
*/
|
*/
|
||||||
inline void Push(const Titem &item)
|
inline void Push(const Titem &item)
|
||||||
{
|
{
|
||||||
if (this->value != Tinvalid) {
|
if (this->value != Tinvalid) {
|
||||||
assert(PooledSmallStack::CanAllocateItem());
|
ThreadMutexLocker lock(_pool.GetMutex());
|
||||||
PooledSmallStack *next = new PooledSmallStack(this->value, this->next);
|
Tindex new_item = _pool.Create();
|
||||||
this->next = next->index;
|
if (new_item != Tmax_size) {
|
||||||
|
PooledSmallStack &pushed = _pool.Get(new_item);
|
||||||
|
pushed.value = this->value;
|
||||||
|
pushed.next = this->next;
|
||||||
|
pushed.branch_count = 0;
|
||||||
|
this->next = new_item;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this->value = item;
|
this->value = item;
|
||||||
}
|
}
|
||||||
@@ -138,17 +215,26 @@ public:
|
|||||||
inline Titem Pop()
|
inline Titem Pop()
|
||||||
{
|
{
|
||||||
Titem ret = this->value;
|
Titem ret = this->value;
|
||||||
if (!PooledSmallStack::IsValidID(this->next)) {
|
if (this->next == Tmax_size) {
|
||||||
this->value = Tinvalid;
|
this->value = Tinvalid;
|
||||||
} else {
|
} else {
|
||||||
PooledSmallStack *next = PooledSmallStack::Get(this->next);
|
ThreadMutexLocker lock(_pool.GetMutex());
|
||||||
static_cast<Item &>(*this) = *next;
|
PooledSmallStack &popped = _pool.Get(this->next);
|
||||||
if (next->NumBranches() == 0) {
|
this->value = popped.value;
|
||||||
delete next;
|
if (popped.branch_count == 0) {
|
||||||
|
_pool.Destroy(this->next);
|
||||||
} else {
|
} else {
|
||||||
next->DeleteBranch();
|
--popped.branch_count;
|
||||||
this->Branch();
|
/* We can't use Branch() here as we already have the mutex.*/
|
||||||
|
if (popped.next != Tmax_size) {
|
||||||
|
++(_pool.Get(popped.next).branch_count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
/* Accessing popped here is no problem as the pool will only set
|
||||||
|
* the validity flag, not actually delete the item, on Destroy().
|
||||||
|
* It's impossible for another thread to acquire the same item in
|
||||||
|
* the mean time because of the mutex. */
|
||||||
|
this->next = popped.next;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -159,7 +245,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
inline bool IsEmpty() const
|
inline bool IsEmpty() const
|
||||||
{
|
{
|
||||||
return this->value == Tinvalid && !PooledSmallStack::IsValidID(this->next);
|
return this->value == Tinvalid && this->next == Tmax_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -170,11 +256,14 @@ public:
|
|||||||
inline bool Contains(const Titem &item) const
|
inline bool Contains(const Titem &item) const
|
||||||
{
|
{
|
||||||
if (item == Tinvalid || item == this->value) return true;
|
if (item == Tinvalid || item == this->value) return true;
|
||||||
const SmallStack *in_list = this;
|
if (this->next != Tmax_size) {
|
||||||
while (PooledSmallStack::IsValidID(in_list->next)) {
|
ThreadMutexLocker lock(_pool.GetMutex());
|
||||||
in_list = static_cast<const SmallStack *>(
|
const SmallStack *in_list = this;
|
||||||
static_cast<const Item *>(PooledSmallStack::Get(in_list->next)));
|
do {
|
||||||
if (in_list->value == item) return true;
|
in_list = static_cast<const SmallStack *>(
|
||||||
|
static_cast<const Item *>(&_pool.Get(in_list->next)));
|
||||||
|
if (in_list->value == item) return true;
|
||||||
|
} while (in_list->next != Tmax_size);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -183,19 +272,15 @@ protected:
|
|||||||
static SmallStackPool _pool;
|
static SmallStackPool _pool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SmallStack item that can be kept in a pool (by having an index).
|
* Create a branch in the pool if necessary.
|
||||||
*/
|
*/
|
||||||
class PooledSmallStack : public Item, public SmallStackPool::template PoolItem<&SmallStack::_pool> {
|
inline void Branch()
|
||||||
private:
|
{
|
||||||
Tindex branch_count; ///< Number of branches in the tree structure this item is parent of
|
if (this->next != Tmax_size) {
|
||||||
public:
|
ThreadMutexLocker lock(_pool.GetMutex());
|
||||||
PooledSmallStack(Titem value, Tindex next) : Item(value, next), branch_count(0) {}
|
++(_pool.Get(this->next).branch_count);
|
||||||
|
}
|
||||||
inline void CreateBranch() { ++this->branch_count; }
|
}
|
||||||
inline void DeleteBranch() { --this->branch_count; }
|
|
||||||
inline Tindex NumBranches() { return this->branch_count; }
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user