summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorMatthew Cline <zelgadis@sourceforge.net>2009-10-20 09:04:22 -0700
committerMatthew Cline <zelgadis@sourceforge.net>2009-10-20 09:04:22 -0700
commitbd3a484b40403e4c7f07e7f6c43e5a1331235461 (patch)
tree8a465b3cd061eccc5ec9bb2c33e73200be2abec1 /crawl-ref/source
parent01df4fd74ab47950bfb907adf8a68dd783971e83 (diff)
parenta99ad56b2d84c930ee7c0ff4628c96eed1d200dc (diff)
downloadcrawl-ref-bd3a484b40403e4c7f07e7f6c43e5a1331235461.tar.gz
crawl-ref-bd3a484b40403e4c7f07e7f6c43e5a1331235461.zip
Merge branch 'master' of ssh://zelgadis@crawl-ref.git.sourceforge.net/gitroot/crawl-ref/crawl-ref
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/Crawl.xcodeproj/project.pbxproj451
-rw-r--r--crawl-ref/source/clua.cc903
-rw-r--r--crawl-ref/source/clua.h4
m---------crawl-ref/source/contrib/sdl0
m---------crawl-ref/source/contrib/sdl-image0
-rw-r--r--crawl-ref/source/dlua.cc25
-rw-r--r--crawl-ref/source/dlua.h23
-rw-r--r--crawl-ref/source/enum.h2
-rw-r--r--crawl-ref/source/l_crawl.cc619
-rw-r--r--crawl-ref/source/l_debug.cc82
-rw-r--r--crawl-ref/source/l_dgn.cc952
-rw-r--r--crawl-ref/source/l_dgn_bf.cc4
-rw-r--r--crawl-ref/source/l_dgnbld.cc365
-rw-r--r--crawl-ref/source/l_dgnevt.cc6
-rw-r--r--crawl-ref/source/l_dgngrd.cc245
-rw-r--r--crawl-ref/source/l_dgnit.cc2
-rw-r--r--crawl-ref/source/l_dgnlvl.cc160
-rw-r--r--crawl-ref/source/l_dgnmon.cc2
-rw-r--r--crawl-ref/source/l_dgntil.cc159
-rw-r--r--crawl-ref/source/l_file.cc2
-rw-r--r--crawl-ref/source/l_libs.h88
-rw-r--r--crawl-ref/source/l_los.cc7
-rw-r--r--crawl-ref/source/l_mapgrd.cc109
-rw-r--r--crawl-ref/source/l_mapmrk.cc4
-rw-r--r--crawl-ref/source/l_you.cc265
-rw-r--r--crawl-ref/source/makefile.obj6
-rw-r--r--crawl-ref/source/mon-data.h2
-rw-r--r--crawl-ref/source/rltiles/makefile.unix21
-rw-r--r--crawl-ref/source/rltiles/tilegen-Info.plist28
-rw-r--r--crawl-ref/source/test/findray.lua10
-rw-r--r--crawl-ref/source/test/los_csc.lua8
-rw-r--r--crawl-ref/source/test/los_symm.lua8
32 files changed, 2538 insertions, 2024 deletions
diff --git a/crawl-ref/source/Crawl.xcodeproj/project.pbxproj b/crawl-ref/source/Crawl.xcodeproj/project.pbxproj
index a5f4b39d0c..4d501227aa 100644
--- a/crawl-ref/source/Crawl.xcodeproj/project.pbxproj
+++ b/crawl-ref/source/Crawl.xcodeproj/project.pbxproj
@@ -234,8 +234,6 @@
7BF855680C9C914D00B7C520 /* mapmark.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7BF855660C9C914D00B7C520 /* mapmark.h */; };
7BF8556B0C9C916800B7C520 /* dgnevent.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BF855690C9C916800B7C520 /* dgnevent.cc */; };
7BF8556C0C9C916800B7C520 /* dgnevent.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7BF8556A0C9C916800B7C520 /* dgnevent.h */; };
- 7BF855700C9C919100B7C520 /* luadgn.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BF8556E0C9C919100B7C520 /* luadgn.cc */; };
- 7BF855710C9C919100B7C520 /* luadgn.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7BF8556F0C9C919100B7C520 /* luadgn.h */; };
93B134650F25595F007DB230 /* version.cc in Sources */ = {isa = PBXBuildFile; fileRef = 93B134610F255926007DB230 /* version.cc */; };
93B134C30F256113007DB230 /* arena.cc in Sources */ = {isa = PBXBuildFile; fileRef = 93B134C20F256113007DB230 /* arena.cc */; };
B032D686106C02070002D70D /* liblua.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B0EFD420BD12E9200002671 /* liblua.a */; };
@@ -332,7 +330,6 @@
B032D6E5106C02150002D70D /* cio.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BF855600C9C912B00B7C520 /* cio.cc */; };
B032D6E6106C02150002D70D /* mapmark.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BF855650C9C914D00B7C520 /* mapmark.cc */; };
B032D6E7106C02150002D70D /* dgnevent.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BF855690C9C916800B7C520 /* dgnevent.cc */; };
- B032D6E8106C02150002D70D /* luadgn.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BF8556E0C9C919100B7C520 /* luadgn.cc */; };
B032D6E9106C02150002D70D /* place.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7B6164250C9CA8E80054B3D9 /* place.cc */; };
B032D6EA106C02150002D70D /* terrain.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7B6164290C9CA8E80054B3D9 /* terrain.cc */; };
B032D6EB106C02150002D70D /* traps.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7B61642B0C9CA8E80054B3D9 /* traps.cc */; };
@@ -361,16 +358,57 @@
B06FC50E1081D287008347BD /* bitary.cc in Sources */ = {isa = PBXBuildFile; fileRef = B06FC50C1081D287008347BD /* bitary.cc */; };
B07818DE1075D979008C3B64 /* sqldbm.cc in Sources */ = {isa = PBXBuildFile; fileRef = B07818DC1075D979008C3B64 /* sqldbm.cc */; };
B07818DF1075D979008C3B64 /* sqldbm.cc in Sources */ = {isa = PBXBuildFile; fileRef = B07818DC1075D979008C3B64 /* sqldbm.cc */; };
- B082657810731AB5006EEC5A /* sqlite3.c in Sources */ = {isa = PBXBuildFile; fileRef = B082657610731AB5006EEC5A /* sqlite3.c */; };
B082657910731B5B006EEC5A /* sqlite3.c in Sources */ = {isa = PBXBuildFile; fileRef = B082657610731AB5006EEC5A /* sqlite3.c */; };
B090C2F210671F8900AE855D /* dngn.png in Copy Dungeon Tiles */ = {isa = PBXBuildFile; fileRef = B090C2EE10671F8900AE855D /* dngn.png */; };
B090C2F310671F8900AE855D /* gui.png in Copy Dungeon Tiles */ = {isa = PBXBuildFile; fileRef = B090C2EF10671F8900AE855D /* gui.png */; };
B090C2F410671F8900AE855D /* main.png in Copy Dungeon Tiles */ = {isa = PBXBuildFile; fileRef = B090C2F010671F8900AE855D /* main.png */; };
B090C2F510671F8900AE855D /* player.png in Copy Dungeon Tiles */ = {isa = PBXBuildFile; fileRef = B090C2F110671F8900AE855D /* player.png */; };
- B09CCE3110830F1A00623CFA /* Crawl-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B09CCE3010830F1A00623CFA /* Crawl-Info.plist */; };
B09CCE671083159100623CFA /* settings in Resources */ = {isa = PBXBuildFile; fileRef = B09CCE5A1083159100623CFA /* settings */; };
B09CCE6C108315B300623CFA /* settings in Resources */ = {isa = PBXBuildFile; fileRef = B09CCE5A1083159100623CFA /* settings */; };
+ B0C9CF51108DF1F900E7FA35 /* main.cc in Sources */ = {isa = PBXBuildFile; fileRef = D25C91860FF0368E00D9E8AD /* main.cc */; };
+ B0C9CF52108DF1F900E7FA35 /* tile.cc in Sources */ = {isa = PBXBuildFile; fileRef = D25C91870FF0368E00D9E8AD /* tile.cc */; };
+ B0C9CF53108DF1F900E7FA35 /* tile_colour.cc in Sources */ = {isa = PBXBuildFile; fileRef = D25C91890FF0368E00D9E8AD /* tile_colour.cc */; };
+ B0C9CF56108DF1F900E7FA35 /* tile_page.cc in Sources */ = {isa = PBXBuildFile; fileRef = D25C918E0FF0368E00D9E8AD /* tile_page.cc */; };
+ B0C9CF57108DF20100E7FA35 /* tile_list_processor.cc in Sources */ = {isa = PBXBuildFile; fileRef = D25C918C0FF0368E00D9E8AD /* tile_list_processor.cc */; };
+ B0C9CF58108DF20F00E7FA35 /* libpng.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0F7DFEE1086F4EA008FFA70 /* libpng.framework */; };
+ B0C9CF59108DF21300E7FA35 /* SDL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0F7DF091086EE7A008FFA70 /* SDL.framework */; };
+ B0C9CF5A108DF21700E7FA35 /* SDL_image.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0F7DF861086F0CB008FFA70 /* SDL_image.framework */; };
+ B0C9CF5E108DF23400E7FA35 /* libpng.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = B0F7DFEE1086F4EA008FFA70 /* libpng.framework */; };
+ B0C9CF5F108DF23700E7FA35 /* SDL_image.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = B0F7DF861086F0CB008FFA70 /* SDL_image.framework */; };
+ B0C9CF60108DF23900E7FA35 /* SDL.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = B0F7DF091086EE7A008FFA70 /* SDL.framework */; };
+ B0C9CF87108DF38200E7FA35 /* SDLMain.m in Sources */ = {isa = PBXBuildFile; fileRef = B02C576010670ED2006AC96D /* SDLMain.m */; };
+ B0C9CFE0108E014800E7FA35 /* libSQLite.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B082656F10731A95006EEC5A /* libSQLite.a */; };
B0CFB315106DF67F005F9CC3 /* ctest.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0CFB313106DF67F005F9CC3 /* ctest.cc */; };
+ B0F01D31108DDEBF00A53656 /* dlua.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D20108DDEBF00A53656 /* dlua.cc */; };
+ B0F01D32108DDEBF00A53656 /* l_crawl.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D22108DDEBF00A53656 /* l_crawl.cc */; };
+ B0F01D33108DDEBF00A53656 /* l_debug.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D23108DDEBF00A53656 /* l_debug.cc */; };
+ B0F01D34108DDEBF00A53656 /* l_dgn_bf.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D24108DDEBF00A53656 /* l_dgn_bf.cc */; };
+ B0F01D35108DDEBF00A53656 /* l_dgn.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D25108DDEBF00A53656 /* l_dgn.cc */; };
+ B0F01D36108DDEBF00A53656 /* l_dgnbld.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D26108DDEBF00A53656 /* l_dgnbld.cc */; };
+ B0F01D37108DDEBF00A53656 /* l_dgnevt.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D27108DDEBF00A53656 /* l_dgnevt.cc */; };
+ B0F01D38108DDEBF00A53656 /* l_dgngrd.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D28108DDEBF00A53656 /* l_dgngrd.cc */; };
+ B0F01D39108DDEBF00A53656 /* l_dgnit.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D29108DDEBF00A53656 /* l_dgnit.cc */; };
+ B0F01D3A108DDEBF00A53656 /* l_dgnlvl.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D2A108DDEBF00A53656 /* l_dgnlvl.cc */; };
+ B0F01D3B108DDEBF00A53656 /* l_dgnmon.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D2B108DDEBF00A53656 /* l_dgnmon.cc */; };
+ B0F01D3C108DDEBF00A53656 /* l_dgntil.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D2C108DDEBF00A53656 /* l_dgntil.cc */; };
+ B0F01D3D108DDEBF00A53656 /* l_file.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D2D108DDEBF00A53656 /* l_file.cc */; };
+ B0F01D3E108DDEBF00A53656 /* l_mapmrk.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D2F108DDEBF00A53656 /* l_mapmrk.cc */; };
+ B0F01D3F108DDEBF00A53656 /* l_you.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D30108DDEBF00A53656 /* l_you.cc */; };
+ B0F01D40108DDEBF00A53656 /* dlua.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D20108DDEBF00A53656 /* dlua.cc */; };
+ B0F01D41108DDEBF00A53656 /* l_crawl.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D22108DDEBF00A53656 /* l_crawl.cc */; };
+ B0F01D42108DDEBF00A53656 /* l_debug.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D23108DDEBF00A53656 /* l_debug.cc */; };
+ B0F01D43108DDEBF00A53656 /* l_dgn_bf.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D24108DDEBF00A53656 /* l_dgn_bf.cc */; };
+ B0F01D44108DDEBF00A53656 /* l_dgn.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D25108DDEBF00A53656 /* l_dgn.cc */; };
+ B0F01D45108DDEBF00A53656 /* l_dgnbld.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D26108DDEBF00A53656 /* l_dgnbld.cc */; };
+ B0F01D46108DDEBF00A53656 /* l_dgnevt.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D27108DDEBF00A53656 /* l_dgnevt.cc */; };
+ B0F01D47108DDEBF00A53656 /* l_dgngrd.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D28108DDEBF00A53656 /* l_dgngrd.cc */; };
+ B0F01D48108DDEBF00A53656 /* l_dgnit.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D29108DDEBF00A53656 /* l_dgnit.cc */; };
+ B0F01D49108DDEBF00A53656 /* l_dgnlvl.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D2A108DDEBF00A53656 /* l_dgnlvl.cc */; };
+ B0F01D4A108DDEBF00A53656 /* l_dgnmon.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D2B108DDEBF00A53656 /* l_dgnmon.cc */; };
+ B0F01D4B108DDEBF00A53656 /* l_dgntil.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D2C108DDEBF00A53656 /* l_dgntil.cc */; };
+ B0F01D4C108DDEBF00A53656 /* l_file.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D2D108DDEBF00A53656 /* l_file.cc */; };
+ B0F01D4D108DDEBF00A53656 /* l_mapmrk.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D2F108DDEBF00A53656 /* l_mapmrk.cc */; };
+ B0F01D4E108DDEBF00A53656 /* l_you.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0F01D30108DDEBF00A53656 /* l_you.cc */; };
B0F7DEF81086EDFE008FFA70 /* Freetype2.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = B0F7DEF51086EDE5008FFA70 /* Freetype2.framework */; };
B0F7DF181086EEBC008FFA70 /* SDL.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = B0F7DF091086EE7A008FFA70 /* SDL.framework */; };
B0F7DF191086EEC6008FFA70 /* SDL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0F7DF091086EE7A008FFA70 /* SDL.framework */; };
@@ -390,11 +428,9 @@
E1424F74107FAE1100E2A9CD /* ctest.cc in Sources */ = {isa = PBXBuildFile; fileRef = B0CFB313106DF67F005F9CC3 /* ctest.cc */; };
E1424F75107FAE4900E2A9CD /* los.cc in Sources */ = {isa = PBXBuildFile; fileRef = E14D930A107FA77200E3F5FE /* los.cc */; };
E1424F7E107FAEC700E2A9CD /* losparam.cc in Sources */ = {isa = PBXBuildFile; fileRef = E14D930B107FA77200E3F5FE /* losparam.cc */; };
- E1424F7F107FAEC700E2A9CD /* mon-los.cc in Sources */ = {isa = PBXBuildFile; fileRef = E14D930C107FA77200E3F5FE /* mon-los.cc */; };
E1424F80107FAEC700E2A9CD /* ray.cc in Sources */ = {isa = PBXBuildFile; fileRef = E14D930D107FA77200E3F5FE /* ray.cc */; };
E14D930F107FA77200E3F5FE /* los.cc in Sources */ = {isa = PBXBuildFile; fileRef = E14D930A107FA77200E3F5FE /* los.cc */; };
E14D9310107FA77200E3F5FE /* losparam.cc in Sources */ = {isa = PBXBuildFile; fileRef = E14D930B107FA77200E3F5FE /* losparam.cc */; };
- E14D9311107FA77200E3F5FE /* mon-los.cc in Sources */ = {isa = PBXBuildFile; fileRef = E14D930C107FA77200E3F5FE /* mon-los.cc */; };
E14D9312107FA77200E3F5FE /* ray.cc in Sources */ = {isa = PBXBuildFile; fileRef = E14D930D107FA77200E3F5FE /* ray.cc */; };
E14D9313107FA77200E3F5FE /* sha256.cc in Sources */ = {isa = PBXBuildFile; fileRef = E14D930E107FA77200E3F5FE /* sha256.cc */; };
/* End PBXBuildFile section */
@@ -435,6 +471,34 @@
remoteGlobalIDString = B082656E10731A95006EEC5A;
remoteInfo = SQLite;
};
+ B0C9CF63108DF24C00E7FA35 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = B0F7DEF91086EE79008FFA70 /* SDL.xcodeproj */;
+ proxyType = 1;
+ remoteGlobalIDString = BECDF5FE0761BA81005FE872 /* Framework */;
+ remoteInfo = Framework;
+ };
+ B0C9CF65108DF24C00E7FA35 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = B0F7DFE61086F4EA008FFA70 /* libpng.xcodeproj */;
+ proxyType = 1;
+ remoteGlobalIDString = 8D07F2BC0486CC7A007CD1D0 /* libpng */;
+ remoteInfo = libpng;
+ };
+ B0C9CF67108DF24C00E7FA35 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = B0F7DF7B1086F0CB008FFA70 /* SDL_image.xcodeproj */;
+ proxyType = 1;
+ remoteGlobalIDString = BE1FA71807AF4C44004B6283 /* Framework */;
+ remoteInfo = Framework;
+ };
+ B0C9CF69108DF26100E7FA35 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = B0C9CF45108DF1AF00E7FA35 /* tilegen */;
+ remoteInfo = tilegen;
+ };
B0F7DEF21086EDE5008FFA70 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = B0F7DEEA1086EDE4008FFA70 /* Freetype2.xcodeproj */;
@@ -491,20 +555,6 @@
remoteGlobalIDString = BECDF6C30761BA81005FE872;
remoteInfo = "Developer Extras Package";
};
- B0F7DF121086EE7A008FFA70 /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = B0F7DEF91086EE79008FFA70 /* SDL.xcodeproj */;
- proxyType = 2;
- remoteGlobalIDString = 0014B9A809C0E585003A99D5;
- remoteInfo = "Framework Without X11 Stuff (for those who didn't install the X11 headers with Xcode)";
- };
- B0F7DF141086EE7A008FFA70 /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = B0F7DEF91086EE79008FFA70 /* SDL.xcodeproj */;
- proxyType = 2;
- remoteGlobalIDString = 002F327609CA02D800EBEB88;
- remoteInfo = "Static Library Without X11 Stuff (for those who didn't install the X11 headers with Xcode)";
- };
B0F7DF161086EEB0008FFA70 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = B0F7DEF91086EE79008FFA70 /* SDL.xcodeproj */;
@@ -646,7 +696,6 @@
7BF855630C9C912B00B7C520 /* cio.h in CopyFiles */,
7BF855680C9C914D00B7C520 /* mapmark.h in CopyFiles */,
7BF8556C0C9C916800B7C520 /* dgnevent.h in CopyFiles */,
- 7BF855710C9C919100B7C520 /* luadgn.h in CopyFiles */,
7B61642D0C9CA8E80054B3D9 /* mpr.h in CopyFiles */,
7B61642F0C9CA8E80054B3D9 /* place.h in CopyFiles */,
7B6164300C9CA8E80054B3D9 /* ray.h in CopyFiles */,
@@ -709,6 +758,19 @@
name = "Copy Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
+ B0C9CF7A108DF28700E7FA35 /* Copy Frameworks */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = "";
+ dstSubfolderSpec = 10;
+ files = (
+ B0C9CF5E108DF23400E7FA35 /* libpng.framework in Copy Frameworks */,
+ B0C9CF5F108DF23700E7FA35 /* SDL_image.framework in Copy Frameworks */,
+ B0C9CF60108DF23900E7FA35 /* SDL.framework in Copy Frameworks */,
+ );
+ name = "Copy Frameworks";
+ runOnlyForDeploymentPostprocessing = 0;
+ };
D2AE25F30DA262B100E15489 /* Copy Wrapper Script */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 12;
@@ -955,8 +1017,6 @@
7BF855660C9C914D00B7C520 /* mapmark.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = mapmark.h; sourceTree = SOURCE_ROOT; };
7BF855690C9C916800B7C520 /* dgnevent.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = dgnevent.cc; sourceTree = SOURCE_ROOT; };
7BF8556A0C9C916800B7C520 /* dgnevent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = dgnevent.h; sourceTree = SOURCE_ROOT; };
- 7BF8556E0C9C919100B7C520 /* luadgn.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = luadgn.cc; sourceTree = SOURCE_ROOT; };
- 7BF8556F0C9C919100B7C520 /* luadgn.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = luadgn.h; sourceTree = SOURCE_ROOT; };
8DD76FB20486AB0100D96B5E /* crawl */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = crawl; sourceTree = BUILT_PRODUCTS_DIR; };
93B134610F255926007DB230 /* version.cc */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; path = version.cc; sourceTree = SOURCE_ROOT; };
93B134C20F256113007DB230 /* arena.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = arena.cc; sourceTree = "<group>"; };
@@ -1002,20 +1062,37 @@
B0B5DFDA1066FA240020B21F /* tiledef-player.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "tiledef-player.h"; path = "rltiles/tiledef-player.h"; sourceTree = "<group>"; };
B0B5DFDB1066FA240020B21F /* tiledef-unrand.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "tiledef-unrand.cc"; path = "rltiles/tiledef-unrand.cc"; sourceTree = "<group>"; };
B0B5DFDC1066FA240020B21F /* tiledef-unrand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "tiledef-unrand.h"; path = "rltiles/tiledef-unrand.h"; sourceTree = "<group>"; };
+ B0C9CF46108DF1AF00E7FA35 /* tilegen.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = tilegen.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ B0C9CFD6108DFF0F00E7FA35 /* tilegen-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "tilegen-Info.plist"; path = "rltiles/tilegen-Info.plist"; sourceTree = "<group>"; };
B0CFB313106DF67F005F9CC3 /* ctest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ctest.cc; sourceTree = "<group>"; };
B0CFB314106DF67F005F9CC3 /* ctest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ctest.h; sourceTree = "<group>"; };
+ B0F01D20108DDEBF00A53656 /* dlua.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = dlua.cc; sourceTree = "<group>"; };
+ B0F01D21108DDEBF00A53656 /* dlua.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dlua.h; sourceTree = "<group>"; };
+ B0F01D22108DDEBF00A53656 /* l_crawl.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = l_crawl.cc; sourceTree = "<group>"; };
+ B0F01D23108DDEBF00A53656 /* l_debug.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = l_debug.cc; sourceTree = "<group>"; };
+ B0F01D24108DDEBF00A53656 /* l_dgn_bf.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = l_dgn_bf.cc; sourceTree = "<group>"; };
+ B0F01D25108DDEBF00A53656 /* l_dgn.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = l_dgn.cc; sourceTree = "<group>"; };
+ B0F01D26108DDEBF00A53656 /* l_dgnbld.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = l_dgnbld.cc; sourceTree = "<group>"; };
+ B0F01D27108DDEBF00A53656 /* l_dgnevt.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = l_dgnevt.cc; sourceTree = "<group>"; };
+ B0F01D28108DDEBF00A53656 /* l_dgngrd.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = l_dgngrd.cc; sourceTree = "<group>"; };
+ B0F01D29108DDEBF00A53656 /* l_dgnit.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = l_dgnit.cc; sourceTree = "<group>"; };
+ B0F01D2A108DDEBF00A53656 /* l_dgnlvl.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = l_dgnlvl.cc; sourceTree = "<group>"; };
+ B0F01D2B108DDEBF00A53656 /* l_dgnmon.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = l_dgnmon.cc; sourceTree = "<group>"; };
+ B0F01D2C108DDEBF00A53656 /* l_dgntil.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = l_dgntil.cc; sourceTree = "<group>"; };
+ B0F01D2D108DDEBF00A53656 /* l_file.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = l_file.cc; sourceTree = "<group>"; };
+ B0F01D2E108DDEBF00A53656 /* l_libs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = l_libs.h; sourceTree = "<group>"; };
+ B0F01D2F108DDEBF00A53656 /* l_mapmrk.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = l_mapmrk.cc; sourceTree = "<group>"; };
+ B0F01D30108DDEBF00A53656 /* l_you.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = l_you.cc; sourceTree = "<group>"; };
B0F7DEEA1086EDE4008FFA70 /* Freetype2.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Freetype2.xcodeproj; path = contrib/freetype/builds/mac/Xcode/Freetype2.xcodeproj; sourceTree = "<group>"; };
B0F7DEF91086EE79008FFA70 /* SDL.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SDL.xcodeproj; path = contrib/sdl/Xcode/SDL/SDL.xcodeproj; sourceTree = "<group>"; };
B0F7DF7B1086F0CB008FFA70 /* SDL_image.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SDL_image.xcodeproj; path = "contrib/sdl-image/Xcode/SDL_image.xcodeproj"; sourceTree = "<group>"; };
B0F7DFE61086F4EA008FFA70 /* libpng.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = libpng.xcodeproj; path = contrib/libpng/projects/xcode/libpng.xcodeproj; sourceTree = "<group>"; };
B0F7E17710876503008FFA70 /* l_los.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = l_los.cc; sourceTree = "<group>"; };
- B0F7E17810876503008FFA70 /* l_los.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = l_los.h; sourceTree = "<group>"; };
D25C91860FF0368E00D9E8AD /* main.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cc; path = rltiles/tool/main.cc; sourceTree = "<group>"; };
D25C91870FF0368E00D9E8AD /* tile.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tile.cc; path = rltiles/tool/tile.cc; sourceTree = "<group>"; };
D25C91880FF0368E00D9E8AD /* tile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tile.h; path = rltiles/tool/tile.h; sourceTree = "<group>"; };
D25C91890FF0368E00D9E8AD /* tile_colour.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tile_colour.cc; path = rltiles/tool/tile_colour.cc; sourceTree = "<group>"; };
D25C918A0FF0368E00D9E8AD /* tile_colour.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tile_colour.h; path = rltiles/tool/tile_colour.h; sourceTree = "<group>"; };
- D25C918B0FF0368E00D9E8AD /* tile_convert.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tile_convert.cc; path = rltiles/tool/tile_convert.cc; sourceTree = "<group>"; };
D25C918C0FF0368E00D9E8AD /* tile_list_processor.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tile_list_processor.cc; path = rltiles/tool/tile_list_processor.cc; sourceTree = "<group>"; };
D25C918D0FF0368E00D9E8AD /* tile_list_processor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tile_list_processor.h; path = rltiles/tool/tile_list_processor.h; sourceTree = "<group>"; };
D25C918E0FF0368E00D9E8AD /* tile_page.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tile_page.cc; path = rltiles/tool/tile_page.cc; sourceTree = "<group>"; };
@@ -1051,7 +1128,6 @@
D2F2723F0DA1C61600445FE9 /* docs */ = {isa = PBXFileReference; lastKnownFileType = folder; name = docs; path = ../docs; sourceTree = SOURCE_ROOT; };
E14D930A107FA77200E3F5FE /* los.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = los.cc; sourceTree = "<group>"; };
E14D930B107FA77200E3F5FE /* losparam.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = losparam.cc; sourceTree = "<group>"; };
- E14D930C107FA77200E3F5FE /* mon-los.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "mon-los.cc"; sourceTree = "<group>"; };
E14D930D107FA77200E3F5FE /* ray.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ray.cc; sourceTree = "<group>"; };
E14D930E107FA77200E3F5FE /* sha256.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sha256.cc; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -1078,6 +1154,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ B0C9CFE0108E014800E7FA35 /* libSQLite.a in Frameworks */,
B032D68E106C02070002D70D /* AppKit.framework in Frameworks */,
B032D686106C02070002D70D /* liblua.a in Frameworks */,
B032D688106C02070002D70D /* libncurses.dylib in Frameworks */,
@@ -1097,6 +1174,16 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ B0C9CF44108DF1AF00E7FA35 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ B0C9CF5A108DF21700E7FA35 /* SDL_image.framework in Frameworks */,
+ B0C9CF59108DF21300E7FA35 /* SDL.framework in Frameworks */,
+ B0C9CF58108DF20F00E7FA35 /* libpng.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
@@ -1121,12 +1208,12 @@
08FB7795FE84155DC02AAC07 /* Source */ = {
isa = PBXGroup;
children = (
- B082657410731AA1006EEC5A /* SQLite */,
7B352EF00B001F5B00CABB32 /* Crawl */,
7B352E950B0017CF00CABB32 /* Levcomp */,
7B0EFD4B0BD12EEA00002671 /* Lua */,
- 7B352EF30B001FA700CABB32 /* Shared */,
D25C917A0FF035D100D9E8AD /* rltiles */,
+ 7B352EF30B001FA700CABB32 /* Shared */,
+ B082657410731AA1006EEC5A /* SQLite */,
D25C91790FF035AF00D9E8AD /* Tiles */,
);
name = Source;
@@ -1140,6 +1227,7 @@
D2F271F60DA1C58C00445FE9 /* Dungeon Crawl Stone Soup - ASCII.app */,
B032D527106C01AF0002D70D /* Dungeon Crawl Stone Soup.app */,
B082656F10731A95006EEC5A /* libSQLite.a */,
+ B0C9CF46108DF1AF00E7FA35 /* tilegen.app */,
);
name = Products;
sourceTree = "<group>";
@@ -1264,6 +1352,8 @@
7BF8556A0C9C916800B7C520 /* dgnevent.h */,
7B237E0F0A8EC9D000580F30 /* directn.cc */,
7B237E1B0A8EC9D000580F30 /* directn.h */,
+ B0F01D20108DDEBF00A53656 /* dlua.cc */,
+ B0F01D21108DDEBF00A53656 /* dlua.h */,
7B237E670A8EC9D000580F30 /* dungeon.cc */,
7B237E100A8EC9D000580F30 /* dungeon.h */,
7B237E520A8EC9D000580F30 /* effects.cc */,
@@ -1300,8 +1390,22 @@
7B237DF80A8EC9D000580F30 /* items.h */,
7B237E4F0A8EC9D000580F30 /* kills.cc */,
7B237E4E0A8EC9D000580F30 /* kills.h */,
+ B0F01D22108DDEBF00A53656 /* l_crawl.cc */,
+ B0F01D23108DDEBF00A53656 /* l_debug.cc */,
+ B0F01D25108DDEBF00A53656 /* l_dgn.cc */,
+ B0F01D24108DDEBF00A53656 /* l_dgn_bf.cc */,
+ B0F01D26108DDEBF00A53656 /* l_dgnbld.cc */,
+ B0F01D27108DDEBF00A53656 /* l_dgnevt.cc */,
+ B0F01D28108DDEBF00A53656 /* l_dgngrd.cc */,
+ B0F01D29108DDEBF00A53656 /* l_dgnit.cc */,
+ B0F01D2A108DDEBF00A53656 /* l_dgnlvl.cc */,
+ B0F01D2B108DDEBF00A53656 /* l_dgnmon.cc */,
+ B0F01D2C108DDEBF00A53656 /* l_dgntil.cc */,
+ B0F01D2D108DDEBF00A53656 /* l_file.cc */,
+ B0F01D2E108DDEBF00A53656 /* l_libs.h */,
B0F7E17710876503008FFA70 /* l_los.cc */,
- B0F7E17810876503008FFA70 /* l_los.h */,
+ B0F01D2F108DDEBF00A53656 /* l_mapmrk.cc */,
+ B0F01D30108DDEBF00A53656 /* l_you.cc */,
7B237DF70A8EC9D000580F30 /* lev-pand.cc */,
7B237DF60A8EC9D000580F30 /* lev-pand.h */,
7B237E640A8EC9D000580F30 /* libunix.cc */,
@@ -1312,8 +1416,6 @@
B06FC5151081D2C0008347BD /* los.h */,
E14D930B107FA77200E3F5FE /* losparam.cc */,
B06FC5161081D2C0008347BD /* losparam.h */,
- 7BF8556E0C9C919100B7C520 /* luadgn.cc */,
- 7BF8556F0C9C919100B7C520 /* luadgn.h */,
7B237E380A8EC9D000580F30 /* macro.cc */,
7B237E190A8EC9D000580F30 /* macro.h */,
7B9740050BE3AC8000AAE35B /* makeitem.cc */,
@@ -1330,7 +1432,6 @@
7B4896610CD3A5D2004A5F43 /* mgrow.h */,
7B237DFC0A8EC9D000580F30 /* misc.cc */,
7B237DE90A8EC9D000580F30 /* misc.h */,
- E14D930C107FA77200E3F5FE /* mon-los.cc */,
7B237DE80A8EC9D000580F30 /* mon-pick.cc */,
7B237DE70A8EC9D000580F30 /* mon-pick.h */,
7B237DFF0A8EC9D000580F30 /* mon-util.cc */,
@@ -1485,8 +1586,6 @@
B0F7DF0D1086EE7A008FFA70 /* libSDLmain.a */,
B0F7DF0F1086EE7A008FFA70 /* Standard DMG */,
B0F7DF111086EE7A008FFA70 /* Developer Extras Package */,
- B0F7DF131086EE7A008FFA70 /* SDL.framework */,
- B0F7DF151086EE7A008FFA70 /* libSDL.a */,
);
name = Products;
sourceTree = "<group>";
@@ -1567,12 +1666,12 @@
D25C91840FF0366F00D9E8AD /* tool */ = {
isa = PBXGroup;
children = (
+ B0C9CFD6108DFF0F00E7FA35 /* tilegen-Info.plist */,
D25C91860FF0368E00D9E8AD /* main.cc */,
D25C91870FF0368E00D9E8AD /* tile.cc */,
D25C91880FF0368E00D9E8AD /* tile.h */,
D25C91890FF0368E00D9E8AD /* tile_colour.cc */,
D25C918A0FF0368E00D9E8AD /* tile_colour.h */,
- D25C918B0FF0368E00D9E8AD /* tile_convert.cc */,
D25C918C0FF0368E00D9E8AD /* tile_list_processor.cc */,
D25C918D0FF0368E00D9E8AD /* tile_list_processor.h */,
D25C918E0FF0368E00D9E8AD /* tile_page.cc */,
@@ -1677,7 +1776,7 @@
isa = PBXNativeTarget;
buildConfigurationList = B032D52E106C01AF0002D70D /* Build configuration list for PBXNativeTarget "Crawl Tiles" */;
buildPhases = (
- B032D532106C01F10002D70D /* Generate Tiles */,
+ B0C9CFB4108DFA1200E7FA35 /* Generate Headers */,
B032D523106C01AF0002D70D /* Resources */,
B032D70E106C03000002D70D /* Copy Dungeon Tiles */,
B032D524106C01AF0002D70D /* Sources */,
@@ -1693,6 +1792,7 @@
B0F7DF171086EEB0008FFA70 /* PBXTargetDependency */,
B0F7DF9D1086F107008FFA70 /* PBXTargetDependency */,
B0F7E171108764C7008FFA70 /* PBXTargetDependency */,
+ B0C9CF6A108DF26100E7FA35 /* PBXTargetDependency */,
);
name = "Crawl Tiles";
productName = "Crawl Tiles";
@@ -1715,6 +1815,27 @@
productReference = B082656F10731A95006EEC5A /* libSQLite.a */;
productType = "com.apple.product-type.library.static";
};
+ B0C9CF45108DF1AF00E7FA35 /* tilegen */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = B0C9CF4D108DF1B000E7FA35 /* Build configuration list for PBXNativeTarget "tilegen" */;
+ buildPhases = (
+ B0C9CF43108DF1AF00E7FA35 /* Sources */,
+ B0C9CF44108DF1AF00E7FA35 /* Frameworks */,
+ B0C9CF7A108DF28700E7FA35 /* Copy Frameworks */,
+ B0C9CF6C108DF27000E7FA35 /* ShellScript */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ B0C9CF64108DF24C00E7FA35 /* PBXTargetDependency */,
+ B0C9CF66108DF24C00E7FA35 /* PBXTargetDependency */,
+ B0C9CF68108DF24C00E7FA35 /* PBXTargetDependency */,
+ );
+ name = tilegen;
+ productName = tilegen;
+ productReference = B0C9CF46108DF1AF00E7FA35 /* tilegen.app */;
+ productType = "com.apple.product-type.application";
+ };
D2F271F50DA1C58C00445FE9 /* Crawl ASCII */ = {
isa = PBXNativeTarget;
buildConfigurationList = D2F271FD0DA1C58C00445FE9 /* Build configuration list for PBXNativeTarget "Crawl ASCII" */;
@@ -1768,6 +1889,7 @@
targets = (
B032D526106C01AF0002D70D /* Crawl Tiles */,
D2F271F50DA1C58C00445FE9 /* Crawl ASCII */,
+ B0C9CF45108DF1AF00E7FA35 /* tilegen */,
8DD76FA90486AB0100D96B5E /* Crawl-cmd */,
7B0EFD410BD12E9200002671 /* Lua */,
B082656E10731A95006EEC5A /* SQLite */,
@@ -1825,20 +1947,6 @@
remoteRef = B0F7DF101086EE7A008FFA70 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
- B0F7DF131086EE7A008FFA70 /* SDL.framework */ = {
- isa = PBXReferenceProxy;
- fileType = wrapper.framework;
- path = SDL.framework;
- remoteRef = B0F7DF121086EE7A008FFA70 /* PBXContainerItemProxy */;
- sourceTree = BUILT_PRODUCTS_DIR;
- };
- B0F7DF151086EE7A008FFA70 /* libSDL.a */ = {
- isa = PBXReferenceProxy;
- fileType = archive.ar;
- path = libSDL.a;
- remoteRef = B0F7DF141086EE7A008FFA70 /* PBXContainerItemProxy */;
- sourceTree = BUILT_PRODUCTS_DIR;
- };
B0F7DF861086F0CB008FFA70 /* SDL_image.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
@@ -1874,7 +1982,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- B09CCE3110830F1A00623CFA /* Crawl-Info.plist in Resources */,
B032D6FD106C02540002D70D /* Crawl.icns in Resources */,
B032D6FB106C02540002D70D /* dat in Resources */,
B032D6FC106C02540002D70D /* docs in Resources */,
@@ -1896,33 +2003,46 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
- B032D532106C01F10002D70D /* Generate Tiles */ = {
+ B090C2DB10671E3200AE855D /* Copy Crawl Executable */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
- name = "Generate Tiles";
+ name = "Copy Crawl Executable";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "cd \"$PROJECT_DIR/rltiles\"\nmake -f makefile.unix -j2 APPLE_GCC=y\n";
+ shellScript = "cp \"$BUILT_PRODUCTS_DIR/crawl\" \"$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/\"";
};
- B090C2DB10671E3200AE855D /* Copy Crawl Executable */ = {
+ B0C9CF6C108DF27000E7FA35 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
- name = "Copy Crawl Executable";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "cp \"$BUILT_PRODUCTS_DIR/crawl\" \"$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/\"";
+ shellScript = "cd \"$PROJECT_DIR/rltiles\"\nfor a in main dngn player gui; do\n\t\"$CONFIGURATION_BUILD_DIR/$FULL_PRODUCT_NAME/Contents/MacOS/$PRODUCT_NAME\" dc-$a.txt\ndone";
+ };
+ B0C9CFB4108DFA1200E7FA35 /* Generate Headers */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "Generate Headers";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "export PATH=\"/opt/git/bin:/opt/local/bin:/usr/local/bin:/usr/bin:/bin:$PATH\"\ncd \"$PROJECT_DIR\"\nutil/gen_ver.pl build.h\nutil/gen-cflg.pl compflag.h \"<unavailable>\" \"<unavailable>\" \"<unavailable>\"";
};
/* End PBXShellScriptBuildPhase section */
@@ -1989,6 +2109,7 @@
7B237ED10A8EC9D000580F30 /* describe.cc in Sources */,
7BF8556B0C9C916800B7C520 /* dgnevent.cc in Sources */,
7B237E960A8EC9D000580F30 /* directn.cc in Sources */,
+ B0F01D40108DDEBF00A53656 /* dlua.cc in Sources */,
7B237EEE0A8EC9D000580F30 /* dungeon.cc in Sources */,
7B237ED90A8EC9D000580F30 /* effects.cc in Sources */,
7B237EDA0A8EC9D000580F30 /* fight.cc in Sources */,
@@ -2006,6 +2127,20 @@
7BC222E70ABBB286003A7D9A /* itemprop.cc in Sources */,
7B237EE10A8EC9D000580F30 /* items.cc in Sources */,
7B237ED60A8EC9D000580F30 /* kills.cc in Sources */,
+ B0F01D41108DDEBF00A53656 /* l_crawl.cc in Sources */,
+ B0F01D42108DDEBF00A53656 /* l_debug.cc in Sources */,
+ B0F01D44108DDEBF00A53656 /* l_dgn.cc in Sources */,
+ B0F01D43108DDEBF00A53656 /* l_dgn_bf.cc in Sources */,
+ B0F01D45108DDEBF00A53656 /* l_dgnbld.cc in Sources */,
+ B0F01D46108DDEBF00A53656 /* l_dgnevt.cc in Sources */,
+ B0F01D47108DDEBF00A53656 /* l_dgngrd.cc in Sources */,
+ B0F01D48108DDEBF00A53656 /* l_dgnit.cc in Sources */,
+ B0F01D49108DDEBF00A53656 /* l_dgnlvl.cc in Sources */,
+ B0F01D4A108DDEBF00A53656 /* l_dgnmon.cc in Sources */,
+ B0F01D4B108DDEBF00A53656 /* l_dgntil.cc in Sources */,
+ B0F01D4C108DDEBF00A53656 /* l_file.cc in Sources */,
+ B0F01D4D108DDEBF00A53656 /* l_mapmrk.cc in Sources */,
+ B0F01D4E108DDEBF00A53656 /* l_you.cc in Sources */,
7B237E7E0A8EC9D000580F30 /* lev-pand.cc in Sources */,
7BBC4A070B0F783C00F27D45 /* levcomp.lpp in Sources */,
7BBC4A080B0F783C00F27D45 /* levcomp.ypp in Sources */,
@@ -2013,7 +2148,6 @@
7B237EE90A8EC9D000580F30 /* libutil.cc in Sources */,
E14D930F107FA77200E3F5FE /* los.cc in Sources */,
E14D9310107FA77200E3F5FE /* losparam.cc in Sources */,
- 7BF855700C9C919100B7C520 /* luadgn.cc in Sources */,
7B237EBF0A8EC9D000580F30 /* macro.cc in Sources */,
7B9740070BE3AC8000AAE35B /* makeitem.cc in Sources */,
7B352EA00B00183400CABB32 /* mapdef.cc in Sources */,
@@ -2023,7 +2157,6 @@
7B237EBC0A8EC9D000580F30 /* message.cc in Sources */,
7B4896620CD3A5D2004A5F43 /* mgrow.cc in Sources */,
7B237E830A8EC9D000580F30 /* misc.cc in Sources */,
- E14D9311107FA77200E3F5FE /* mon-los.cc in Sources */,
7B237E6F0A8EC9D000580F30 /* mon-pick.cc in Sources */,
7B237E860A8EC9D000580F30 /* mon-util.cc in Sources */,
7B237ED40A8EC9D000580F30 /* monplace.cc in Sources */,
@@ -2098,6 +2231,7 @@
B032D6C8106C02150002D70D /* describe.cc in Sources */,
B032D6E7106C02150002D70D /* dgnevent.cc in Sources */,
B032D6AC106C02150002D70D /* directn.cc in Sources */,
+ B0F01D31108DDEBF00A53656 /* dlua.cc in Sources */,
B032D6D7106C02150002D70D /* dungeon.cc in Sources */,
B032D6CC106C02150002D70D /* effects.cc in Sources */,
B032D6CD106C02150002D70D /* fight.cc in Sources */,
@@ -2115,6 +2249,21 @@
B032D6DA106C02150002D70D /* itemprop.cc in Sources */,
B032D6D1106C02150002D70D /* items.cc in Sources */,
B032D6CB106C02150002D70D /* kills.cc in Sources */,
+ B0F01D32108DDEBF00A53656 /* l_crawl.cc in Sources */,
+ B0F01D33108DDEBF00A53656 /* l_debug.cc in Sources */,
+ B0F01D35108DDEBF00A53656 /* l_dgn.cc in Sources */,
+ B0F01D34108DDEBF00A53656 /* l_dgn_bf.cc in Sources */,
+ B0F01D36108DDEBF00A53656 /* l_dgnbld.cc in Sources */,
+ B0F01D37108DDEBF00A53656 /* l_dgnevt.cc in Sources */,
+ B0F01D38108DDEBF00A53656 /* l_dgngrd.cc in Sources */,
+ B0F01D39108DDEBF00A53656 /* l_dgnit.cc in Sources */,
+ B0F01D3A108DDEBF00A53656 /* l_dgnlvl.cc in Sources */,
+ B0F01D3B108DDEBF00A53656 /* l_dgnmon.cc in Sources */,
+ B0F01D3C108DDEBF00A53656 /* l_dgntil.cc in Sources */,
+ B0F01D3D108DDEBF00A53656 /* l_file.cc in Sources */,
+ B0F7E17910876503008FFA70 /* l_los.cc in Sources */,
+ B0F01D3E108DDEBF00A53656 /* l_mapmrk.cc in Sources */,
+ B0F01D3F108DDEBF00A53656 /* l_you.cc in Sources */,
B032D6A0106C02150002D70D /* lev-pand.cc in Sources */,
B032D690106C02150002D70D /* levcomp.lpp in Sources */,
B032D68F106C02150002D70D /* levcomp.ypp in Sources */,
@@ -2122,7 +2271,6 @@
B032D6D5106C02150002D70D /* libutil.cc in Sources */,
E1424F75107FAE4900E2A9CD /* los.cc in Sources */,
E1424F7E107FAEC700E2A9CD /* losparam.cc in Sources */,
- B032D6E8106C02150002D70D /* luadgn.cc in Sources */,
B032D6BE106C02150002D70D /* macro.cc in Sources */,
B032D6E3106C02150002D70D /* makeitem.cc in Sources */,
B032D6DC106C02150002D70D /* mapdef.cc in Sources */,
@@ -2132,7 +2280,6 @@
B032D6BC106C02150002D70D /* message.cc in Sources */,
B032D6EE106C02150002D70D /* mgrow.cc in Sources */,
B032D6A3106C02150002D70D /* misc.cc in Sources */,
- E1424F7F107FAEC700E2A9CD /* mon-los.cc in Sources */,
B032D69B106C02150002D70D /* mon-pick.cc in Sources */,
B032D6A4106C02150002D70D /* mon-util.cc in Sources */,
B032D6CA106C02150002D70D /* monplace.cc in Sources */,
@@ -2165,7 +2312,6 @@
B032D6F2106C02150002D70D /* spl-mis.cc in Sources */,
B032D6A8106C02150002D70D /* spl-util.cc in Sources */,
B07818DE1075D979008C3B64 /* sqldbm.cc in Sources */,
- B082657810731AB5006EEC5A /* sqlite3.c in Sources */,
B032D6B1106C02150002D70D /* stash.cc in Sources */,
B032D6EC106C02150002D70D /* state.cc in Sources */,
B032D6ED106C02150002D70D /* store.cc in Sources */,
@@ -2192,7 +2338,6 @@
B032D6F0106C02150002D70D /* version.cc in Sources */,
B032D6AD106C02150002D70D /* view.cc in Sources */,
B032D6E4106C02150002D70D /* xom.cc in Sources */,
- B0F7E17910876503008FFA70 /* l_los.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2204,6 +2349,19 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ B0C9CF43108DF1AF00E7FA35 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ B0C9CF87108DF38200E7FA35 /* SDLMain.m in Sources */,
+ B0C9CF51108DF1F900E7FA35 /* main.cc in Sources */,
+ B0C9CF52108DF1F900E7FA35 /* tile.cc in Sources */,
+ B0C9CF53108DF1F900E7FA35 /* tile_colour.cc in Sources */,
+ B0C9CF57108DF20100E7FA35 /* tile_list_processor.cc in Sources */,
+ B0C9CF56108DF1F900E7FA35 /* tile_page.cc in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
@@ -2232,6 +2390,26 @@
target = B082656E10731A95006EEC5A /* SQLite */;
targetProxy = B082658710731C22006EEC5A /* PBXContainerItemProxy */;
};
+ B0C9CF64108DF24C00E7FA35 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ name = Framework;
+ targetProxy = B0C9CF63108DF24C00E7FA35 /* PBXContainerItemProxy */;
+ };
+ B0C9CF66108DF24C00E7FA35 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ name = libpng;
+ targetProxy = B0C9CF65108DF24C00E7FA35 /* PBXContainerItemProxy */;
+ };
+ B0C9CF68108DF24C00E7FA35 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ name = Framework;
+ targetProxy = B0C9CF67108DF24C00E7FA35 /* PBXContainerItemProxy */;
+ };
+ B0C9CF6A108DF26100E7FA35 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = B0C9CF45108DF1AF00E7FA35 /* tilegen */;
+ targetProxy = B0C9CF69108DF26100E7FA35 /* PBXContainerItemProxy */;
+ };
B0F7DEF71086EDF2008FFA70 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = Framework;
@@ -2301,7 +2479,6 @@
GCC_VERSION_ppc = 4.0;
GCC_VERSION_x86_64 = 4.2;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
- GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_CHECK_SWITCH_STATEMENTS = YES;
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
@@ -2430,7 +2607,6 @@
GCC_VERSION_ppc = 4.0;
GCC_VERSION_x86_64 = 4.2;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
- GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_CHECK_SWITCH_STATEMENTS = YES;
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
@@ -2497,7 +2673,6 @@
GCC_VERSION_ppc = 4.0;
GCC_VERSION_x86_64 = 4.2;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
- GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_CHECK_SWITCH_STATEMENTS = YES;
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
@@ -2550,8 +2725,8 @@
7B97C0270A8ED34400CE8936 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1)";
- ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386";
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)";
+ ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = "x86_64 i386 ppc";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_OPTIMIZATION_LEVEL = 2;
GCC_PREPROCESSOR_DEFINITIONS = OSX;
@@ -2559,7 +2734,6 @@
GCC_VERSION_ppc = 4.0;
GCC_VERSION_x86_64 = 4.2;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
- GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_CHECK_SWITCH_STATEMENTS = YES;
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
@@ -2897,6 +3071,132 @@
};
name = Wizard;
};
+ B0C9CF49108DF1AF00E7FA35 /* Profile */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_MODEL_TUNING = G5;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ HEADER_SEARCH_PATHS = (
+ "$(PROJECT_DIR)/contrib/Frameworks/Release/Freetype2.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Release/SDL.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Release/SDL_image.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Release/libpng.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Debug/Freetype2.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Debug/SDL.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Debug/SDL_image.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Debug/libpng.framework/Headers",
+ );
+ INFOPLIST_FILE = "rltiles/tilegen-Info.plist";
+ INSTALL_PATH = "$(HOME)/Applications";
+ OTHER_LDFLAGS = (
+ "-framework",
+ Foundation,
+ "-framework",
+ AppKit,
+ );
+ PREBINDING = NO;
+ PRODUCT_NAME = tilegen;
+ };
+ name = Profile;
+ };
+ B0C9CF4A108DF1AF00E7FA35 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ COPY_PHASE_STRIP = YES;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ GCC_ENABLE_FIX_AND_CONTINUE = NO;
+ GCC_MODEL_TUNING = G5;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ HEADER_SEARCH_PATHS = (
+ "$(PROJECT_DIR)/contrib/Frameworks/Release/Freetype2.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Release/SDL.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Release/SDL_image.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Release/libpng.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Debug/Freetype2.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Debug/SDL.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Debug/SDL_image.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Debug/libpng.framework/Headers",
+ );
+ INFOPLIST_FILE = "rltiles/tilegen-Info.plist";
+ INSTALL_PATH = "$(HOME)/Applications";
+ OTHER_LDFLAGS = (
+ "-framework",
+ Foundation,
+ "-framework",
+ AppKit,
+ );
+ PREBINDING = NO;
+ PRODUCT_NAME = tilegen;
+ ZERO_LINK = NO;
+ };
+ name = Release;
+ };
+ B0C9CF4B108DF1AF00E7FA35 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ COPY_PHASE_STRIP = NO;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_MODEL_TUNING = G5;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ HEADER_SEARCH_PATHS = (
+ "$(PROJECT_DIR)/contrib/Frameworks/Release/Freetype2.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Release/SDL.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Release/SDL_image.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Release/libpng.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Debug/Freetype2.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Debug/SDL.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Debug/SDL_image.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Debug/libpng.framework/Headers",
+ );
+ INFOPLIST_FILE = "rltiles/tilegen-Info.plist";
+ INSTALL_PATH = "$(HOME)/Applications";
+ OTHER_LDFLAGS = (
+ "-framework",
+ Foundation,
+ "-framework",
+ AppKit,
+ );
+ PREBINDING = NO;
+ PRODUCT_NAME = tilegen;
+ };
+ name = Debug;
+ };
+ B0C9CF4C108DF1AF00E7FA35 /* Wizard */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_MODEL_TUNING = G5;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ HEADER_SEARCH_PATHS = (
+ "$(PROJECT_DIR)/contrib/Frameworks/Release/Freetype2.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Release/SDL.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Release/SDL_image.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Release/libpng.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Debug/Freetype2.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Debug/SDL.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Debug/SDL_image.framework/Headers",
+ "$(PROJECT_DIR)/contrib/Frameworks/Debug/libpng.framework/Headers",
+ );
+ INFOPLIST_FILE = "rltiles/tilegen-Info.plist";
+ INSTALL_PATH = "$(HOME)/Applications";
+ OTHER_LDFLAGS = (
+ "-framework",
+ Foundation,
+ "-framework",
+ AppKit,
+ );
+ PREBINDING = NO;
+ PRODUCT_NAME = tilegen;
+ };
+ name = Wizard;
+ };
D2F271F90DA1C58C00445FE9 /* Profile */ = {
isa = XCBuildConfiguration;
buildSettings = {
@@ -3031,6 +3331,17 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Profile;
};
+ B0C9CF4D108DF1B000E7FA35 /* Build configuration list for PBXNativeTarget "tilegen" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ B0C9CF49108DF1AF00E7FA35 /* Profile */,
+ B0C9CF4A108DF1AF00E7FA35 /* Release */,
+ B0C9CF4B108DF1AF00E7FA35 /* Debug */,
+ B0C9CF4C108DF1AF00E7FA35 /* Wizard */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Profile;
+ };
D2F271FD0DA1C58C00445FE9 /* Build configuration list for PBXNativeTarget "Crawl ASCII" */ = {
isa = XCConfigurationList;
buildConfigurations = (
diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc
index 44f4cd0393..da9cc20ecf 100644
--- a/crawl-ref/source/clua.cc
+++ b/crawl-ref/source/clua.cc
@@ -9,6 +9,7 @@
#include <sstream>
#include "clua.h"
+#include "l_libs.h"
#include "abl-show.h"
#include "artefact.h"
@@ -590,14 +591,11 @@ bool CLua::callfn(const char *fn, int nargs, int nret)
// structs
extern void luaopen_kills(lua_State *ls);
-void luaopen_you(lua_State *ls);
void luaopen_item(lua_State *ls);
void luaopen_food(lua_State *ls);
-void luaopen_crawl(lua_State *ls);
void luaopen_file(lua_State *ls);
void luaopen_options(lua_State *ls);
void luaopen_monsters(lua_State *ls);
-void luaopen_grd(lua_State *ls);
void luaopen_globals(lua_State *ls);
void CLua::init_lua()
@@ -620,14 +618,13 @@ void CLua::init_lua()
// Open Crawl bindings
luaopen_kills(_state);
- luaopen_you(_state);
+ cluaopen_you(_state);
luaopen_item(_state);
luaopen_food(_state);
- luaopen_crawl(_state);
+ cluaopen_crawl(_state);
luaopen_file(_state);
luaopen_options(_state);
luaopen_monsters(_state);
- luaopen_grd(_state);
luaopen_globals(_state);
@@ -728,230 +725,6 @@ void clua_register_metatable(lua_State *ls, const char *tn,
}
/////////////////////////////////////////////////////////////////////
-// Bindings to get information on the player
-//
-
-static const char *transform_name()
-{
- switch (you.attribute[ATTR_TRANSFORMATION])
- {
- case TRAN_SPIDER:
- return "spider";
- case TRAN_BAT:
- return "bat";
- case TRAN_BLADE_HANDS:
- return "blade";
- case TRAN_STATUE:
- return "statue";
- case TRAN_ICE_BEAST:
- return "ice";
- case TRAN_DRAGON:
- return "dragon";
- case TRAN_LICH:
- return "lich";
- case TRAN_PIG:
- return "pig";
- default:
- return "";
- }
-}
-
-LUARET1(you_turn_is_over, boolean, you.turn_is_over)
-LUARET1(you_name, string, you.your_name)
-LUARET1(you_race, string,
- species_name(you.species, you.experience_level).c_str())
-LUARET1(you_class, string, get_class_name(you.char_class))
-LUARET1(you_god, string, god_name(you.religion).c_str())
-LUARET1(you_good_god, boolean,
- lua_isstring(ls, 1) ? is_good_god(str_to_god(lua_tostring(ls, 1)))
- : is_good_god(you.religion))
-LUARET1(you_evil_god, boolean,
- lua_isstring(ls, 1) ? is_evil_god(str_to_god(lua_tostring(ls, 1)))
- : is_evil_god(you.religion))
-LUARET1(you_god_likes_fresh_corpses, boolean,
- lua_isstring(ls, 1) ?
- god_likes_fresh_corpses(str_to_god(lua_tostring(ls, 1))) :
- god_likes_fresh_corpses(you.religion))
-LUARET1(you_god_likes_butchery, boolean,
- lua_isstring(ls, 1) ?
- god_likes_butchery(str_to_god(lua_tostring(ls, 1))) :
- god_likes_butchery(you.religion))
-LUARET2(you_hp, number, you.hp, you.hp_max)
-LUARET2(you_mp, number, you.magic_points, you.max_magic_points)
-LUARET2(you_pos, number, you.pos().x, you.pos().y)
-LUARET1(you_hunger, string, hunger_level())
-LUARET2(you_strength, number, you.strength, you.max_strength)
-LUARET2(you_intelligence, number, you.intel, you.max_intel)
-LUARET2(you_dexterity, number, you.dex, you.max_dex)
-LUARET1(you_exp, number, you.experience_level)
-LUARET1(you_exp_points, number, you.experience)
-LUARET1(you_skill, number,
- lua_isstring(ls, 1) ? you.skills[str_to_skill(lua_tostring(ls, 1))]
- : 0)
-LUARET1(you_res_poison, number, player_res_poison(false))
-LUARET1(you_res_fire, number, player_res_fire(false))
-LUARET1(you_res_cold, number, player_res_cold(false))
-LUARET1(you_res_draining, number, player_prot_life(false))
-LUARET1(you_res_shock, number, player_res_electricity(false))
-LUARET1(you_res_statdrain, number, player_sust_abil(false))
-LUARET1(you_res_mutation, number, wearing_amulet(AMU_RESIST_MUTATION, false))
-LUARET1(you_res_slowing, number, wearing_amulet(AMU_RESIST_SLOW, false))
-LUARET1(you_gourmand, boolean, wearing_amulet(AMU_THE_GOURMAND, false))
-LUARET1(you_saprovorous, number, player_mutation_level(MUT_SAPROVOROUS))
-LUARET1(you_levitating, boolean, you.flight_mode() == FL_LEVITATE)
-LUARET1(you_flying, boolean, you.flight_mode() == FL_FLY)
-LUARET1(you_transform, string, transform_name())
-LUARET1(you_where, string, level_id::current().describe().c_str())
-LUARET1(you_branch, string, level_id::current().describe(false, false).c_str())
-LUARET1(you_subdepth, number, level_id::current().depth)
-// Increase by 1 because check happens on old level.
-LUARET1(you_absdepth, number, you.your_level + 1)
-LUAWRAP(you_stop_activity, interrupt_activity(AI_FORCE_INTERRUPT))
-LUARET1(you_taking_stairs, boolean,
- current_delay_action() == DELAY_ASCENDING_STAIRS
- || current_delay_action() == DELAY_DESCENDING_STAIRS)
-LUARET1(you_turns, number, you.num_turns)
-LUARET1(you_can_smell, boolean, player_can_smell())
-LUARET1(you_has_claws, number, you.has_claws(false))
-
-static int _you_uniques(lua_State *ls)
-{
- ASSERT_DLUA;
-
- bool unique_found = false;
-
- if (lua_gettop(ls) >= 1 && lua_isstring(ls, 1))
- unique_found = you.unique_creatures[get_monster_by_name(lua_tostring(ls, 1))];
-
- lua_pushboolean(ls, unique_found);
- return (1);
-}
-
-static int _you_gold(lua_State *ls)
-{
- if (lua_gettop(ls) >= 1)
- {
- ASSERT_DLUA;
- const int new_gold = luaL_checkint(ls, 1);
- const int old_gold = you.gold;
- you.gold = std::max(new_gold, 0);
- if (new_gold > old_gold)
- you.attribute[ATTR_GOLD_FOUND] += new_gold - old_gold;
- else if (old_gold > new_gold)
- you.attribute[ATTR_MISC_SPENDING] += old_gold - new_gold;
- }
- PLUARET(number, you.gold);
-}
-
-void lua_push_floor_items(lua_State *ls);
-static int you_floor_items(lua_State *ls)
-{
- lua_push_floor_items(ls);
- return (1);
-}
-
-static int l_you_spells(lua_State *ls)
-{
- lua_newtable(ls);
- int index = 0;
- for (int i = 0; i < 52; ++i)
- {
- const spell_type spell = get_spell_by_letter( index_to_letter(i) );
- if (spell == SPELL_NO_SPELL)
- continue;
-
- lua_pushstring(ls, spell_title(spell));
- lua_rawseti(ls, -2, ++index);
- }
- return (1);
-}
-
-static int l_you_abils(lua_State *ls)
-{
- lua_newtable(ls);
-
- std::vector<const char *>abils = get_ability_names();
- for (int i = 0, size = abils.size(); i < size; ++i)
- {
- lua_pushstring(ls, abils[i]);
- lua_rawseti(ls, -2, i + 1);
- }
- return (1);
-}
-
-static int you_can_consume_corpses(lua_State *ls)
-{
- lua_pushboolean(ls,
- can_ingest(OBJ_FOOD, FOOD_CHUNK, true, false, false)
- || can_ingest(OBJ_CORPSES, CORPSE_BODY, true, false, false)
- );
- return (1);
-}
-
-static const struct luaL_reg you_lib[] =
-{
- { "turn_is_over", you_turn_is_over },
- { "turns" , you_turns },
- { "spells" , l_you_spells },
- { "abilities" , l_you_abils },
- { "name" , you_name },
- { "race" , you_race },
- { "class" , you_class },
- { "god" , you_god },
- { "gold" , _you_gold },
- { "good_god" , you_good_god },
- { "evil_god" , you_evil_god },
- { "hp" , you_hp },
- { "mp" , you_mp },
- { "pos" , you_pos },
- { "hunger" , you_hunger },
- { "strength" , you_strength },
- { "intelligence", you_intelligence },
- { "dexterity" , you_dexterity },
- { "skill" , you_skill },
- { "uniques" , _you_uniques },
- { "xl" , you_exp },
- { "exp" , you_exp_points },
- { "res_poison" , you_res_poison },
- { "res_fire" , you_res_fire },
- { "res_cold" , you_res_cold },
- { "res_draining", you_res_draining },
- { "res_shock" , you_res_shock },
- { "res_statdrain", you_res_statdrain },
- { "res_mutation", you_res_mutation },
- { "res_slowing", you_res_slowing },
- { "saprovorous", you_saprovorous },
- { "gourmand", you_gourmand },
- { "levitating", you_levitating },
- { "flying", you_flying },
- { "transform", you_transform },
-
- { "god_likes_fresh_corpses", you_god_likes_fresh_corpses },
- { "god_likes_butchery", you_god_likes_butchery },
- { "can_consume_corpses", you_can_consume_corpses },
-
- { "stop_activity", you_stop_activity },
- { "taking_stairs", you_taking_stairs },
-
- { "floor_items", you_floor_items },
-
- { "where", you_where },
- { "branch", you_branch },
- { "subdepth", you_subdepth },
- { "absdepth", you_absdepth },
-
- { "can_smell", you_can_smell },
- { "has_claws", you_has_claws },
-
- { NULL, NULL },
-};
-
-void luaopen_you(lua_State *ls)
-{
- luaL_openlib(ls, "you", you_lib, 0);
-}
-
-/////////////////////////////////////////////////////////////////////
// Bindings to get information on items. We must be extremely careful
// to only hand out information the player already has.
//
@@ -1784,573 +1557,6 @@ void luaopen_food(lua_State *ls)
luaL_openlib(ls, "food", food_lib, 0);
}
-/////////////////////////////////////////////////////////////////////
-// General game bindings.
-//
-
-static int crawl_mpr(lua_State *ls)
-{
- if (!crawl_state.io_inited)
- return (0);
-
- const char *message = luaL_checkstring(ls, 1);
- if (!message)
- return (0);
-
- int ch = MSGCH_PLAIN;
- if (lua_isnumber(ls, 2))
- ch = luaL_checkint(ls, 2);
- else
- {
- const char *channel = lua_tostring(ls, 2);
- if (channel)
- ch = str_to_channel(channel);
- }
-
- if (ch < 0 || ch >= NUM_MESSAGE_CHANNELS)
- ch = MSGCH_PLAIN;
-
- mpr(message, static_cast<msg_channel_type>(ch));
- return (0);
-}
-
-static int crawl_formatted_mpr(lua_State *ls)
-{
- if (!crawl_state.io_inited)
- return (0);
-
- const char *message = luaL_checkstring(ls, 1);
- if (!message)
- return (0);
-
- int ch = MSGCH_PLAIN;
- if (lua_isnumber(ls, 2))
- ch = luaL_checkint(ls, 2);
- else
- {
- const char *channel = lua_tostring(ls, 2);
- if (channel)
- ch = str_to_channel(channel);
- }
-
- if (ch < 0 || ch >= NUM_MESSAGE_CHANNELS)
- ch = MSGCH_PLAIN;
-
- formatted_mpr(formatted_string::parse_string(message),
- static_cast<msg_channel_type>(ch));
- return (0);
-}
-
-LUAWRAP(crawl_more, more())
-LUAWRAP(crawl_mesclr, mesclr())
-LUAWRAP(crawl_redraw_screen, redraw_screen())
-
-static int crawl_input_line(lua_State *ls)
-{
- // This is arbitrary, but anybody entering so many characters is psychotic.
- char linebuf[500];
-
- get_input_line(linebuf, sizeof linebuf);
- lua_pushstring(ls, linebuf);
- return (1);
-}
-
-static int crawl_c_input_line(lua_State *ls)
-{
- char linebuf[500];
-
- bool valid = !cancelable_get_line(linebuf, sizeof linebuf);
- if (valid)
- lua_pushstring(ls, linebuf);
- else
- lua_pushnil(ls);
- return (1);
-}
-
-LUARET1(crawl_getch, number, getch())
-LUARET1(crawl_kbhit, number, kbhit())
-LUAWRAP(crawl_flush_input, flush_input_buffer(FLUSH_LUA))
-
-static char _lua_char(lua_State *ls, int ndx, char defval = 0)
-{
- return (lua_isnone(ls, ndx) || !lua_isstring(ls, ndx)? defval
- : lua_tostring(ls, ndx)[0]);
-}
-
-static int crawl_yesno(lua_State *ls)
-{
- const char *prompt = luaL_checkstring(ls, 1);
- const bool safe = lua_toboolean(ls, 2);
- const int safeanswer = _lua_char(ls, 3);
- const bool clear_after =
- lua_isnone(ls, 4) ? true : lua_toboolean(ls, 4);
- const bool interrupt_delays =
- lua_isnone(ls, 5) ? true : lua_toboolean(ls, 5);
- const bool noprompt =
- lua_isnone(ls, 6) ? false : lua_toboolean(ls, 6);
-
- cursor_control con(true);
- lua_pushboolean(ls, yesno(prompt, safe, safeanswer, clear_after,
- interrupt_delays, noprompt));
- return (1);
-}
-
-static int crawl_yesnoquit(lua_State *ls)
-{
- const char *prompt = luaL_checkstring(ls, 1);
- const bool safe = lua_toboolean(ls, 2);
- const int safeanswer = _lua_char(ls, 3);
- const bool allow_all =
- lua_isnone(ls, 4) ? false : lua_toboolean(ls, 4);
- const bool clear_after =
- lua_isnone(ls, 5) ? true : lua_toboolean(ls, 5);
-
- // Skipping the other params until somebody needs them.
-
- cursor_control con(true);
- lua_pushnumber(ls, yesnoquit(prompt, safe, safeanswer, allow_all,
- clear_after));
- return (1);
-}
-
-static void crawl_sendkeys_proc(lua_State *ls, int argi)
-{
- if (lua_isstring(ls, argi))
- {
- const char *keys = luaL_checkstring(ls, argi);
- if (!keys)
- return;
-
- for ( ; *keys; ++keys)
- macro_buf_add(*keys);
- }
- else if (lua_istable(ls, argi))
- {
- for (int i = 1; ; ++i)
- {
- lua_rawgeti(ls, argi, i);
- if (lua_isnil(ls, -1))
- {
- lua_pop(ls, 1);
- return;
- }
-
- crawl_sendkeys_proc(ls, lua_gettop(ls));
- lua_pop(ls, 1);
- }
- }
- else if (lua_isnumber(ls, argi))
- {
- int key = luaL_checkint(ls, argi);
- macro_buf_add(key);
- }
-}
-
-static int crawl_sendkeys(lua_State *ls)
-{
- int top = lua_gettop(ls);
- for (int i = 1; i <= top; ++i)
- crawl_sendkeys_proc(ls, i);
- return (0);
-}
-
-// Tell Crawl to process one command.
-static int crawl_process_command(lua_State *ls)
-{
- const bool will_process =
- current_delay_action() == DELAY_MACRO || !you_are_delayed();
-
- if (will_process)
- {
- // This should only be called from a macro delay, but run_macro
- // may not have started the macro delay; do so now.
- if (!you_are_delayed())
- start_delay(DELAY_MACRO, 1);
- start_delay(DELAY_MACRO_PROCESS_KEY, 1);
- }
-
- lua_pushboolean(ls, will_process);
- return (1);
-}
-
-static int crawl_playsound(lua_State *ls)
-{
- const char *sf = luaL_checkstring(ls, 1);
- if (!sf)
- return (0);
- play_sound(sf);
- return (0);
-}
-
-static int crawl_runmacro(lua_State *ls)
-{
- const char *macroname = luaL_checkstring(ls, 1);
- if (!macroname)
- return (0);
- run_macro(macroname);
- return (0);
-}
-
-static int crawl_setopt(lua_State *ls)
-{
- if (!lua_isstring(ls, 1))
- return (0);
-
- const char *s = lua_tostring(ls, 1);
- if (s)
- {
- // Note that the conditional script can contain nested Lua[ ]Lua code.
- read_options(s, true);
- }
-
- return (0);
-}
-
-static int crawl_read_options(lua_State *ls)
-{
- if (!lua_isstring(ls, 1))
- return (0);
-
- const char* filename = lua_tostring(ls, 1);
- Options.include(filename, true, true);
- return (0);
-}
-
-static int crawl_bindkey(lua_State *ls)
-{
- const char *s = NULL;
- if (lua_isstring(ls, 1))
- {
- s = lua_tostring(ls, 1);
- }
-
- if (!s || !lua_isfunction(ls, 2) || lua_gettop(ls) != 2)
- return (0);
-
- lua_pushvalue(ls, 2);
- std::string name = clua.setuniqregistry();
- if (lua_gettop(ls) != 2)
- {
- fprintf(stderr, "Stack top has changed!\n");
- lua_settop(ls, 2);
- }
- macro_userfn(s, name.c_str());
- return (0);
-}
-
-static int crawl_msgch_num(lua_State *ls)
-{
- const char *s = luaL_checkstring(ls, 1);
- if (!s)
- return (0);
- int ch = str_to_channel(s);
- if (ch == -1)
- return (0);
-
- lua_pushnumber(ls, ch);
- return (1);
-}
-
-static int crawl_msgch_name(lua_State *ls)
-{
- int num = luaL_checkint(ls, 1);
- std::string name = channel_to_str(num);
- lua_pushstring(ls, name.c_str());
- return (1);
-}
-
-static int crawl_take_note(lua_State *ls)
-{
- const char* msg = luaL_checkstring(ls, 1);
- take_note(Note(NOTE_MESSAGE, 0, 0, msg));
- return (0);
-}
-
-#define REGEX_METATABLE "crawl.regex"
-#define MESSF_METATABLE "crawl.messf"
-
-static int crawl_regex(lua_State *ls)
-{
- const char *s = luaL_checkstring(ls, 1);
- if (!s)
- return (0);
-
-
- text_pattern **tpudata =
- clua_new_userdata< text_pattern* >(ls, REGEX_METATABLE);
- if (tpudata)
- {
- *tpudata = new text_pattern(s);
- return (1);
- }
- return (0);
-}
-
-static int crawl_regex_find(lua_State *ls)
-{
- text_pattern **pattern =
- clua_get_userdata< text_pattern* >(ls, REGEX_METATABLE);
- if (!pattern)
- return (0);
-
- const char *text = luaL_checkstring(ls, -1);
- if (!text)
- return (0);
-
- lua_pushboolean(ls, (*pattern)->matches(text));
- return (1);
-}
-
-static const luaL_reg crawl_regex_ops[] =
-{
- { "matches", crawl_regex_find },
- { NULL, NULL }
-};
-
-static int crawl_message_filter(lua_State *ls)
-{
- const char *pattern = luaL_checkstring(ls, 1);
- if (!pattern)
- return (0);
-
- int num = lua_isnumber(ls, 2)? luaL_checkint(ls, 2) : -1;
- message_filter **mf =
- clua_new_userdata< message_filter* >( ls, MESSF_METATABLE );
- if (mf)
- {
- *mf = new message_filter( num, pattern );
- return (1);
- }
- return (0);
-}
-
-static int crawl_messf_matches(lua_State *ls)
-{
- message_filter **mf =
- clua_get_userdata< message_filter* >(ls, MESSF_METATABLE);
- if (!mf)
- return (0);
-
- const char *pattern = luaL_checkstring(ls, 2);
- int ch = luaL_checkint(ls, 3);
- if (pattern)
- {
- bool filt = (*mf)->is_filtered(ch, pattern);
- lua_pushboolean(ls, filt);
- return (1);
- }
- return (0);
-}
-
-static const luaL_reg crawl_messf_ops[] =
-{
- { "matches", crawl_messf_matches },
- { NULL, NULL }
-};
-
-static int crawl_trim(lua_State *ls)
-{
- const char *s = luaL_checkstring(ls, 1);
- if (!s)
- return (0);
- std::string text = s;
- trim_string(text);
- lua_pushstring(ls, text.c_str());
- return (1);
-}
-
-static int crawl_split(lua_State *ls)
-{
- const char *s = luaL_checkstring(ls, 1),
- *token = luaL_checkstring(ls, 2);
- if (!s || !token)
- return (0);
-
- std::vector<std::string> segs = split_string(token, s);
- lua_newtable(ls);
- for (int i = 0, count = segs.size(); i < count; ++i)
- {
- lua_pushstring(ls, segs[i].c_str());
- lua_rawseti(ls, -2, i + 1);
- }
- return (1);
-}
-
-static int _crawl_grammar(lua_State *ls)
-{
- description_level_type ndesc = DESC_PLAIN;
- if (lua_isstring(ls, 2))
- ndesc = description_type_by_name(lua_tostring(ls, 2));
- PLUARET(string,
- thing_do_grammar(ndesc, false,
- false, luaL_checkstring(ls, 1)).c_str());
-}
-
-static int crawl_article_a(lua_State *ls)
-{
- const char *s = luaL_checkstring(ls, 1);
-
- bool lowercase = true;
- if (lua_isboolean(ls, 2))
- lowercase = lua_toboolean(ls, 2);
-
- lua_pushstring(ls, article_a(s, lowercase).c_str());
-
- return (1);
-}
-
-LUARET1(crawl_game_started, boolean, crawl_state.need_save)
-LUARET1(crawl_random2, number, random2( luaL_checkint(ls, 1) ))
-LUARET1(crawl_one_chance_in, boolean, one_chance_in( luaL_checkint(ls, 1) ))
-LUARET1(crawl_random2avg, number,
- random2avg( luaL_checkint(ls, 1), luaL_checkint(ls, 2) ))
-LUARET1(crawl_random_range, number,
- random_range( luaL_checkint(ls, 1), luaL_checkint(ls, 2),
- lua_isnumber(ls, 3)? luaL_checkint(ls, 3) : 1 ))
-LUARET1(crawl_coinflip, boolean, coinflip())
-LUARET1(crawl_roll_dice, number,
- lua_gettop(ls) == 1
- ? roll_dice( 1, luaL_checkint(ls, 1) )
- : roll_dice( luaL_checkint(ls, 1), luaL_checkint(ls, 2) ))
-
-static int crawl_random_element(lua_State *ls)
-{
- const int table_idx = 1;
- const int value_idx = 2;
-
- if (lua_gettop(ls) == 0)
- {
- lua_pushnil(ls);
- return 1;
- }
-
- // Only the first arg does anything now. Maybe this should
- // select from a variable number of table args?
- lua_pop(ls, lua_gettop(ls) - 1);
-
- // Keep max value on the stack, as it could be any type of value.
- lua_pushnil(ls);
- int rollsize = 0;
-
- lua_pushnil(ls);
- while (lua_next(ls, table_idx) != 0)
- {
- const int weight_idx = -1;
- const int key_idx = -2;
-
- int this_weight = lua_isnil(ls, weight_idx) ?
- 1 : (int)lua_tonumber(ls, weight_idx);
-
- if (rollsize > 0)
- {
- rollsize += this_weight;
- if (x_chance_in_y(this_weight, rollsize))
- {
- lua_pushvalue(ls, key_idx);
- lua_replace(ls, value_idx);
- }
- }
- else
- {
- lua_pushvalue(ls, key_idx);
- lua_replace(ls, value_idx);
- rollsize = this_weight;
- }
-
- lua_pop(ls, 1);
- }
-
- lua_pushvalue(ls, value_idx);
-
- return 1;
-}
-
-static int crawl_err_trace(lua_State *ls)
-{
- const int nargs = lua_gettop(ls);
- const int err = lua_pcall(ls, nargs - 1, LUA_MULTRET, 0);
-
- if (err)
- {
- // This code from lua.c:traceback() (mostly)
- const char *errs = lua_tostring(ls, 1);
- std::string errstr = errs? errs : "";
- lua_getfield(ls, LUA_GLOBALSINDEX, "debug");
- if (!lua_istable(ls, -1))
- {
- lua_pop(ls, 1);
- return lua_error(ls);
- }
- lua_getfield(ls, -1, "traceback");
- if (!lua_isfunction(ls, -1))
- {
- lua_pop(ls, 2);
- return lua_error(ls);
- }
- lua_pushvalue(ls, 1);
- lua_pushinteger(ls, 2); // Skip crawl_err_trace and traceback.
- lua_call(ls, 2, 1);
-
- // What's on top should be the error.
- lua_error(ls);
- }
-
- return (lua_gettop(ls));
-}
-
-static const struct luaL_reg crawl_lib[] =
-{
- { "mpr", crawl_mpr },
- { "formatted_mpr", crawl_formatted_mpr },
- { "more", crawl_more },
- { "mesclr", crawl_mesclr },
- { "random2", crawl_random2 },
- { "one_chance_in", crawl_one_chance_in },
- { "random2avg" , crawl_random2avg },
- { "coinflip", crawl_coinflip },
- { "roll_dice", crawl_roll_dice },
- { "random_range", crawl_random_range },
- { "random_element", crawl_random_element },
- { "redraw_screen", crawl_redraw_screen },
- { "input_line", crawl_input_line },
- { "c_input_line", crawl_c_input_line},
- { "getch", crawl_getch },
- { "yesno", crawl_yesno },
- { "yesnoquit", crawl_yesnoquit },
- { "kbhit", crawl_kbhit },
- { "flush_input", crawl_flush_input },
- { "sendkeys", crawl_sendkeys },
- { "process_command", crawl_process_command },
- { "playsound", crawl_playsound },
- { "runmacro", crawl_runmacro },
- { "bindkey", crawl_bindkey },
- { "setopt", crawl_setopt },
- { "read_options", crawl_read_options },
- { "msgch_num", crawl_msgch_num },
- { "msgch_name", crawl_msgch_name },
- { "take_note", crawl_take_note },
-
- { "regex", crawl_regex },
- { "message_filter", crawl_message_filter },
- { "trim", crawl_trim },
- { "split", crawl_split },
- { "grammar", _crawl_grammar },
- { "article_a", crawl_article_a },
- { "game_started", crawl_game_started },
- { "err_trace", crawl_err_trace },
-
- { NULL, NULL },
-};
-
-void luaopen_crawl(lua_State *ls)
-{
- clua_register_metatable(ls, REGEX_METATABLE, crawl_regex_ops,
- lua_object_gc<text_pattern>);
- clua_register_metatable(ls, MESSF_METATABLE, crawl_messf_ops,
- lua_object_gc<message_filter>);
-
- luaL_openlib(ls, "crawl", crawl_lib, 0);
-}
///////////////////////////////////////////////////////////
// File operations
@@ -2790,109 +1996,6 @@ void luaopen_monsters(lua_State *ls)
luaL_openlib(ls, "mons", mons_lib, 0);
}
-/////////////////////////////////////////////////////////////////////
-// grd and grd_col handling (i.e. map_lines in a metatable)
-
-struct mapcolumn
-{
- map_def* map;
- int col;
-};
-
-static int grd_get(lua_State *ls)
-{
- // Return a metatable for this column in the map grid.
- map_def *map = *(map_def **) luaL_checkudata(ls, 1, GRD_METATABLE);
-
- int column = luaL_checkint(ls, 2);
-
- mapcolumn *mapref = clua_new_userdata<mapcolumn>(ls, GRD_COL_METATABLE);
- mapref->map = map;
- mapref->col = column;
-
- return (1);
-}
-
-static int grd_set(lua_State *ls)
-{
- return (luaL_error(ls, "%s", "Cannot assign to read-only table."));
-}
-
-static char* grd_glyph(lua_State *ls, int &col, int &row)
-{
- mapcolumn *mapc = (mapcolumn *)luaL_checkudata(ls, 1, GRD_COL_METATABLE);
- row = luaL_checkint(ls, 2);
- col = mapc->col;
-
- map_lines &lines = mapc->map->map;
- if (row < 1 || col < 1 || col > lines.width() || row > lines.height())
- {
- return (NULL);
- }
-
- coord_def mc(col - 1, row - 1);
- return (&lines(mc));
-}
-
-static int grd_col_get(lua_State *ls)
-{
- int col, row;
- char *gly = grd_glyph(ls, col, row);
- if (!gly)
- return (luaL_error(ls, "Invalid coords: %d, %d", col, row));
-
- char buf[2];
- buf[0] = *gly;
- buf[1] = '\0';
-
- lua_pushstring(ls, buf);
-
- return (1);
-}
-
-static int grd_col_set(lua_State *ls)
-{
- int col, row;
- char *gly = grd_glyph(ls, col, row);
- if (!gly)
- return (luaL_error(ls, "Invalid coords: %d, %d", col, row));
-
- const char *str = luaL_checkstring(ls, 3);
- if (!str[0] || str[1])
- return (luaL_error(ls, "%s", "grd must be set to a single char."));
-
- (*gly) = str[0];
-
- return (0);
-}
-
-void luaopen_grd(lua_State *ls)
-{
- // grd table
- luaL_newmetatable(ls, GRD_METATABLE);
- lua_pushstring(ls, "__index");
- lua_pushcfunction(ls, grd_get);
- lua_settable(ls, -3);
-
- lua_pushstring(ls, "__newindex");
- lua_pushcfunction(ls, grd_set);
- lua_settable(ls, -3);
-
- lua_pop(ls, 1);
-
- // grd col table
- luaL_newmetatable(ls, GRD_COL_METATABLE);
- lua_pushstring(ls, "__index");
- lua_pushcfunction(ls, grd_col_get);
- lua_settable(ls, -3);
-
- lua_pushstring(ls, "__newindex");
- lua_pushcfunction(ls, grd_col_set);
- lua_settable(ls, -3);
-
- lua_pop(ls, 1);
-}
-
//////////////////////////////////////////////////////////////////////
// Miscellaneous globals
diff --git a/crawl-ref/source/clua.h b/crawl-ref/source/clua.h
index f98e80076f..bc723c0d90 100644
--- a/crawl-ref/source/clua.h
+++ b/crawl-ref/source/clua.h
@@ -320,7 +320,7 @@ void print_clua_stack();
#define MAP_METATABLE "dgn.mtmap"
#define DEVENT_METATABLE "dgn.devent"
#define MAPMARK_METATABLE "dgn.mapmark"
-#define GRD_METATABLE "dgn.grd"
-#define GRD_COL_METATABLE "dgn.grdcol"
+#define MAPGRD_METATABLE "dgn.mapgrd"
+#define MAPGRD_COL_METATABLE "dgn.mapgrdcol"
#endif
diff --git a/crawl-ref/source/contrib/sdl b/crawl-ref/source/contrib/sdl
-Subproject 3ad98c3ccb3b986a5ac954424edd64412d0557e
+Subproject 678edf28dba5f646f102ff2e35af52817ce12f7
diff --git a/crawl-ref/source/contrib/sdl-image b/crawl-ref/source/contrib/sdl-image
-Subproject 98d5c63aa3178c1704663000b57b8f1f31360f9
+Subproject d8ee43c7258bde2a76d54366939932e4cb42d88
diff --git a/crawl-ref/source/dlua.cc b/crawl-ref/source/dlua.cc
index a14b88937e..dc800406ca 100644
--- a/crawl-ref/source/dlua.cc
+++ b/crawl-ref/source/dlua.cc
@@ -306,15 +306,22 @@ void init_dungeon_lua()
{
lua_stack_cleaner clean(dlua);
- luaL_openlib(dlua, "dgn", dgn_lib, 0);
- luaL_openlib(dlua, "dgn", dgn_event_lib, 0);
- luaL_openlib(dlua, "dgn", dgn_item_lib, 0);
- luaL_openlib(dlua, "dgn", dgn_mons_lib, 0);
- // Add additional function to the Crawl module.
- luaL_openlib(dlua, "crawl", crawl_lib, 0);
- luaL_openlib(dlua, "file", file_lib, 0);
- luaL_openlib(dlua, "you", you_lib, 0);
- luaL_openlib(dlua, "los", los_lib, 0);
+ dluaopen_crawl(dlua);
+ dluaopen_mapgrd(dlua);
+ dluaopen_you(dlua);
+
+ luaL_openlib(dlua, "dgn", dgn_dlib, 0);
+ luaL_openlib(dlua, "dgn", dgn_build_dlib, 0);
+ luaL_openlib(dlua, "dgn", dgn_event_dlib, 0);
+ luaL_openlib(dlua, "dgn", dgn_grid_dlib, 0);
+ luaL_openlib(dlua, "dgn", dgn_item_dlib, 0);
+ luaL_openlib(dlua, "dgn", dgn_level_dlib, 0);
+ luaL_openlib(dlua, "dgn", dgn_mons_dlib, 0);
+ luaL_openlib(dlua, "dgn", dgn_tile_dlib, 0);
+
+ luaL_openlib(dlua, "debug", debug_dlib, 0);
+ luaL_openlib(dlua, "file", file_dlib, 0);
+ luaL_openlib(dlua, "los", los_dlib, 0);
dlua.execfile("clua/dungeon.lua", true, true);
dlua.execfile("clua/luamark.lua", true, true);
diff --git a/crawl-ref/source/dlua.h b/crawl-ref/source/dlua.h
index ebb90398f8..dc6a30f531 100644
--- a/crawl-ref/source/dlua.h
+++ b/crawl-ref/source/dlua.h
@@ -96,7 +96,6 @@ static void dlua_push_object_type(lua_State *ls, const char *meta, const T &data
void print_dlua_stack();
-
void luaopen_setmeta(lua_State *ls,
const char *global,
const luaL_reg *lua_lib,
@@ -104,28 +103,6 @@ void luaopen_setmeta(lua_State *ls,
#define LUAFN(name) static int name(lua_State *ls)
-#define GETCOORD(c, p1, p2, boundfn) \
- coord_def c; \
- c.x = luaL_checkint(ls, p1); \
- c.y = luaL_checkint(ls, p2); \
- if (!boundfn(c)) \
- luaL_error( \
- ls, \
- make_stringf("Point (%d,%d) is out of bounds", \
- c.x, c.y).c_str()); \
- else ;
-
-
-#define COORDS(c, p1, p2) \
- GETCOORD(c, p1, p2, in_bounds)
-
-#define MAP(ls, n, var) \
-map_def *var = *(map_def **) luaL_checkudata(ls, n, MAP_METATABLE)
-#define DEVENT(ls, n, var) \
-dgn_event *var = *(dgn_event **) luaL_checkudata(ls, n, DEVENT_METATABLE)
-#define MAPMARKER(ls, n, var) \
-map_marker *var = *(map_marker **) luaL_checkudata(ls, n, MAPMARK_METATABLE)
-
//////////////////////////////////////////////////////////////////////////
#endif
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index 9db5a63bbd..22e0b6e10d 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -983,7 +983,7 @@ enum dungeon_char_type
// vault_grid() for the feature, if you want vault maps to
// be able to use it. If you do, also update
// docs/level_design.txt with the new symbol.
-// * Any: edit luadgn.cc and add the feature's name to the dngn_feature_names
+// * Any: edit l_dgngrd.cc and add the feature's name to the dngn_feature_names
// array, if you want vault map Lua code to be able to use the
// feature, and/or you want to be able to create the feature
// using the "create feature by name" wizard command.
diff --git a/crawl-ref/source/l_crawl.cc b/crawl-ref/source/l_crawl.cc
index d3bf402d9d..5f248e8dc8 100644
--- a/crawl-ref/source/l_crawl.cc
+++ b/crawl-ref/source/l_crawl.cc
@@ -1,8 +1,25 @@
+/*
+ * File: l_crawl.cc
+ * Summary: General game bindings.
+ */
+
#include "AppHdr.h"
+#include "clua.h"
#include "dlua.h"
#include "l_libs.h"
+
+#include "cio.h"
+#include "delay.h"
+#include "directn.h"
+#include "format.h"
#include "initfile.h"
+#include "itemname.h"
+#include "macro.h"
+#include "message.h"
+#include "notes.h"
+#include "player.h"
+#include "stuff.h"
#include "view.h"
#ifdef UNIX
@@ -10,6 +27,578 @@
#include <time.h>
#endif
+/////////////////////////////////////////////////////////////////////
+// User accessible
+//
+
+static int crawl_mpr(lua_State *ls)
+{
+ if (!crawl_state.io_inited)
+ return (0);
+
+ const char *message = luaL_checkstring(ls, 1);
+ if (!message)
+ return (0);
+
+ int ch = MSGCH_PLAIN;
+ if (lua_isnumber(ls, 2))
+ ch = luaL_checkint(ls, 2);
+ else
+ {
+ const char *channel = lua_tostring(ls, 2);
+ if (channel)
+ ch = str_to_channel(channel);
+ }
+
+ if (ch < 0 || ch >= NUM_MESSAGE_CHANNELS)
+ ch = MSGCH_PLAIN;
+
+ mpr(message, static_cast<msg_channel_type>(ch));
+ return (0);
+}
+
+static int crawl_formatted_mpr(lua_State *ls)
+{
+ if (!crawl_state.io_inited)
+ return (0);
+
+ const char *message = luaL_checkstring(ls, 1);
+ if (!message)
+ return (0);
+
+ int ch = MSGCH_PLAIN;
+ if (lua_isnumber(ls, 2))
+ ch = luaL_checkint(ls, 2);
+ else
+ {
+ const char *channel = lua_tostring(ls, 2);
+ if (channel)
+ ch = str_to_channel(channel);
+ }
+
+ if (ch < 0 || ch >= NUM_MESSAGE_CHANNELS)
+ ch = MSGCH_PLAIN;
+
+ formatted_mpr(formatted_string::parse_string(message),
+ static_cast<msg_channel_type>(ch));
+ return (0);
+}
+
+LUAWRAP(crawl_more, more())
+LUAWRAP(crawl_mesclr, mesclr())
+LUAWRAP(crawl_redraw_screen, redraw_screen())
+
+static int crawl_input_line(lua_State *ls)
+{
+ // This is arbitrary, but anybody entering so many characters is psychotic.
+ char linebuf[500];
+
+ get_input_line(linebuf, sizeof linebuf);
+ lua_pushstring(ls, linebuf);
+ return (1);
+}
+
+static int crawl_c_input_line(lua_State *ls)
+{
+ char linebuf[500];
+
+ bool valid = !cancelable_get_line(linebuf, sizeof linebuf);
+ if (valid)
+ lua_pushstring(ls, linebuf);
+ else
+ lua_pushnil(ls);
+ return (1);
+}
+
+LUARET1(crawl_getch, number, getch())
+LUARET1(crawl_kbhit, number, kbhit())
+LUAWRAP(crawl_flush_input, flush_input_buffer(FLUSH_LUA))
+
+static char _lua_char(lua_State *ls, int ndx, char defval = 0)
+{
+ return (lua_isnone(ls, ndx) || !lua_isstring(ls, ndx)? defval
+ : lua_tostring(ls, ndx)[0]);
+}
+
+static int crawl_yesno(lua_State *ls)
+{
+ const char *prompt = luaL_checkstring(ls, 1);
+ const bool safe = lua_toboolean(ls, 2);
+ const int safeanswer = _lua_char(ls, 3);
+ const bool clear_after =
+ lua_isnone(ls, 4) ? true : lua_toboolean(ls, 4);
+ const bool interrupt_delays =
+ lua_isnone(ls, 5) ? true : lua_toboolean(ls, 5);
+ const bool noprompt =
+ lua_isnone(ls, 6) ? false : lua_toboolean(ls, 6);
+
+ cursor_control con(true);
+ lua_pushboolean(ls, yesno(prompt, safe, safeanswer, clear_after,
+ interrupt_delays, noprompt));
+ return (1);
+}
+
+static int crawl_yesnoquit(lua_State *ls)
+{
+ const char *prompt = luaL_checkstring(ls, 1);
+ const bool safe = lua_toboolean(ls, 2);
+ const int safeanswer = _lua_char(ls, 3);
+ const bool allow_all =
+ lua_isnone(ls, 4) ? false : lua_toboolean(ls, 4);
+ const bool clear_after =
+ lua_isnone(ls, 5) ? true : lua_toboolean(ls, 5);
+
+ // Skipping the other params until somebody needs them.
+
+ cursor_control con(true);
+ lua_pushnumber(ls, yesnoquit(prompt, safe, safeanswer, allow_all,
+ clear_after));
+ return (1);
+}
+
+static void crawl_sendkeys_proc(lua_State *ls, int argi)
+{
+ if (lua_isstring(ls, argi))
+ {
+ const char *keys = luaL_checkstring(ls, argi);
+ if (!keys)
+ return;
+
+ for ( ; *keys; ++keys)
+ macro_buf_add(*keys);
+ }
+ else if (lua_istable(ls, argi))
+ {
+ for (int i = 1; ; ++i)
+ {
+ lua_rawgeti(ls, argi, i);
+ if (lua_isnil(ls, -1))
+ {
+ lua_pop(ls, 1);
+ return;
+ }
+
+ crawl_sendkeys_proc(ls, lua_gettop(ls));
+ lua_pop(ls, 1);
+ }
+ }
+ else if (lua_isnumber(ls, argi))
+ {
+ int key = luaL_checkint(ls, argi);
+ macro_buf_add(key);
+ }
+}
+
+static int crawl_sendkeys(lua_State *ls)
+{
+ int top = lua_gettop(ls);
+ for (int i = 1; i <= top; ++i)
+ crawl_sendkeys_proc(ls, i);
+ return (0);
+}
+
+// Tell Crawl to process one command.
+static int crawl_process_command(lua_State *ls)
+{
+ const bool will_process =
+ current_delay_action() == DELAY_MACRO || !you_are_delayed();
+
+ if (will_process)
+ {
+ // This should only be called from a macro delay, but run_macro
+ // may not have started the macro delay; do so now.
+ if (!you_are_delayed())
+ start_delay(DELAY_MACRO, 1);
+ start_delay(DELAY_MACRO_PROCESS_KEY, 1);
+ }
+
+ lua_pushboolean(ls, will_process);
+ return (1);
+}
+
+static int crawl_playsound(lua_State *ls)
+{
+ const char *sf = luaL_checkstring(ls, 1);
+ if (!sf)
+ return (0);
+ play_sound(sf);
+ return (0);
+}
+
+static int crawl_runmacro(lua_State *ls)
+{
+ const char *macroname = luaL_checkstring(ls, 1);
+ if (!macroname)
+ return (0);
+ run_macro(macroname);
+ return (0);
+}
+
+static int crawl_setopt(lua_State *ls)
+{
+ if (!lua_isstring(ls, 1))
+ return (0);
+
+ const char *s = lua_tostring(ls, 1);
+ if (s)
+ {
+ // Note that the conditional script can contain nested Lua[ ]Lua code.
+ read_options(s, true);
+ }
+
+ return (0);
+}
+
+static int crawl_read_options(lua_State *ls)
+{
+ if (!lua_isstring(ls, 1))
+ return (0);
+
+ const char* filename = lua_tostring(ls, 1);
+ Options.include(filename, true, true);
+ return (0);
+}
+
+static int crawl_bindkey(lua_State *ls)
+{
+ const char *s = NULL;
+ if (lua_isstring(ls, 1))
+ {
+ s = lua_tostring(ls, 1);
+ }
+
+ if (!s || !lua_isfunction(ls, 2) || lua_gettop(ls) != 2)
+ return (0);
+
+ lua_pushvalue(ls, 2);
+ std::string name = clua.setuniqregistry();
+ if (lua_gettop(ls) != 2)
+ {
+ fprintf(stderr, "Stack top has changed!\n");
+ lua_settop(ls, 2);
+ }
+ macro_userfn(s, name.c_str());
+ return (0);
+}
+
+static int crawl_msgch_num(lua_State *ls)
+{
+ const char *s = luaL_checkstring(ls, 1);
+ if (!s)
+ return (0);
+ int ch = str_to_channel(s);
+ if (ch == -1)
+ return (0);
+
+ lua_pushnumber(ls, ch);
+ return (1);
+}
+
+static int crawl_msgch_name(lua_State *ls)
+{
+ int num = luaL_checkint(ls, 1);
+ std::string name = channel_to_str(num);
+ lua_pushstring(ls, name.c_str());
+ return (1);
+}
+
+static int crawl_take_note(lua_State *ls)
+{
+ const char* msg = luaL_checkstring(ls, 1);
+ take_note(Note(NOTE_MESSAGE, 0, 0, msg));
+ return (0);
+}
+
+#define REGEX_METATABLE "crawl.regex"
+#define MESSF_METATABLE "crawl.messf"
+
+static int crawl_regex(lua_State *ls)
+{
+ const char *s = luaL_checkstring(ls, 1);
+ if (!s)
+ return (0);
+
+
+ text_pattern **tpudata =
+ clua_new_userdata< text_pattern* >(ls, REGEX_METATABLE);
+ if (tpudata)
+ {
+ *tpudata = new text_pattern(s);
+ return (1);
+ }
+ return (0);
+}
+
+static int crawl_regex_find(lua_State *ls)
+{
+ text_pattern **pattern =
+ clua_get_userdata< text_pattern* >(ls, REGEX_METATABLE);
+ if (!pattern)
+ return (0);
+
+ const char *text = luaL_checkstring(ls, -1);
+ if (!text)
+ return (0);
+
+ lua_pushboolean(ls, (*pattern)->matches(text));
+ return (1);
+}
+
+static const luaL_reg crawl_regex_ops[] =
+{
+ { "matches", crawl_regex_find },
+ { NULL, NULL }
+};
+
+static int crawl_message_filter(lua_State *ls)
+{
+ const char *pattern = luaL_checkstring(ls, 1);
+ if (!pattern)
+ return (0);
+
+ int num = lua_isnumber(ls, 2)? luaL_checkint(ls, 2) : -1;
+ message_filter **mf =
+ clua_new_userdata< message_filter* >( ls, MESSF_METATABLE );
+ if (mf)
+ {
+ *mf = new message_filter( num, pattern );
+ return (1);
+ }
+ return (0);
+}
+
+static int crawl_messf_matches(lua_State *ls)
+{
+ message_filter **mf =
+ clua_get_userdata< message_filter* >(ls, MESSF_METATABLE);
+ if (!mf)
+ return (0);
+
+ const char *pattern = luaL_checkstring(ls, 2);
+ int ch = luaL_checkint(ls, 3);
+ if (pattern)
+ {
+ bool filt = (*mf)->is_filtered(ch, pattern);
+ lua_pushboolean(ls, filt);
+ return (1);
+ }
+ return (0);
+}
+
+static const luaL_reg crawl_messf_ops[] =
+{
+ { "matches", crawl_messf_matches },
+ { NULL, NULL }
+};
+
+static int crawl_trim(lua_State *ls)
+{
+ const char *s = luaL_checkstring(ls, 1);
+ if (!s)
+ return (0);
+ std::string text = s;
+ trim_string(text);
+ lua_pushstring(ls, text.c_str());
+ return (1);
+}
+
+static int crawl_split(lua_State *ls)
+{
+ const char *s = luaL_checkstring(ls, 1),
+ *token = luaL_checkstring(ls, 2);
+ if (!s || !token)
+ return (0);
+
+ std::vector<std::string> segs = split_string(token, s);
+ lua_newtable(ls);
+ for (int i = 0, count = segs.size(); i < count; ++i)
+ {
+ lua_pushstring(ls, segs[i].c_str());
+ lua_rawseti(ls, -2, i + 1);
+ }
+ return (1);
+}
+
+static int _crawl_grammar(lua_State *ls)
+{
+ description_level_type ndesc = DESC_PLAIN;
+ if (lua_isstring(ls, 2))
+ ndesc = description_type_by_name(lua_tostring(ls, 2));
+ PLUARET(string,
+ thing_do_grammar(ndesc, false,
+ false, luaL_checkstring(ls, 1)).c_str());
+}
+
+static int crawl_article_a(lua_State *ls)
+{
+ const char *s = luaL_checkstring(ls, 1);
+
+ bool lowercase = true;
+ if (lua_isboolean(ls, 2))
+ lowercase = lua_toboolean(ls, 2);
+
+ lua_pushstring(ls, article_a(s, lowercase).c_str());
+
+ return (1);
+}
+
+LUARET1(crawl_game_started, boolean, crawl_state.need_save)
+LUARET1(crawl_random2, number, random2( luaL_checkint(ls, 1) ))
+LUARET1(crawl_one_chance_in, boolean, one_chance_in( luaL_checkint(ls, 1) ))
+LUARET1(crawl_random2avg, number,
+ random2avg( luaL_checkint(ls, 1), luaL_checkint(ls, 2) ))
+LUARET1(crawl_random_range, number,
+ random_range( luaL_checkint(ls, 1), luaL_checkint(ls, 2),
+ lua_isnumber(ls, 3)? luaL_checkint(ls, 3) : 1 ))
+LUARET1(crawl_coinflip, boolean, coinflip())
+LUARET1(crawl_roll_dice, number,
+ lua_gettop(ls) == 1
+ ? roll_dice( 1, luaL_checkint(ls, 1) )
+ : roll_dice( luaL_checkint(ls, 1), luaL_checkint(ls, 2) ))
+
+static int crawl_random_element(lua_State *ls)
+{
+ const int table_idx = 1;
+ const int value_idx = 2;
+
+ if (lua_gettop(ls) == 0)
+ {
+ lua_pushnil(ls);
+ return 1;
+ }
+
+ // Only the first arg does anything now. Maybe this should
+ // select from a variable number of table args?
+ lua_pop(ls, lua_gettop(ls) - 1);
+
+ // Keep max value on the stack, as it could be any type of value.
+ lua_pushnil(ls);
+ int rollsize = 0;
+
+ lua_pushnil(ls);
+ while (lua_next(ls, table_idx) != 0)
+ {
+ const int weight_idx = -1;
+ const int key_idx = -2;
+
+ int this_weight = lua_isnil(ls, weight_idx) ?
+ 1 : (int)lua_tonumber(ls, weight_idx);
+
+ if (rollsize > 0)
+ {
+ rollsize += this_weight;
+ if (x_chance_in_y(this_weight, rollsize))
+ {
+ lua_pushvalue(ls, key_idx);
+ lua_replace(ls, value_idx);
+ }
+ }
+ else
+ {
+ lua_pushvalue(ls, key_idx);
+ lua_replace(ls, value_idx);
+ rollsize = this_weight;
+ }
+
+ lua_pop(ls, 1);
+ }
+
+ lua_pushvalue(ls, value_idx);
+
+ return 1;
+}
+
+static int crawl_err_trace(lua_State *ls)
+{
+ const int nargs = lua_gettop(ls);
+ const int err = lua_pcall(ls, nargs - 1, LUA_MULTRET, 0);
+
+ if (err)
+ {
+ // This code from lua.c:traceback() (mostly)
+ const char *errs = lua_tostring(ls, 1);
+ std::string errstr = errs? errs : "";
+ lua_getfield(ls, LUA_GLOBALSINDEX, "debug");
+ if (!lua_istable(ls, -1))
+ {
+ lua_pop(ls, 1);
+ return lua_error(ls);
+ }
+ lua_getfield(ls, -1, "traceback");
+ if (!lua_isfunction(ls, -1))
+ {
+ lua_pop(ls, 2);
+ return lua_error(ls);
+ }
+ lua_pushvalue(ls, 1);
+ lua_pushinteger(ls, 2); // Skip crawl_err_trace and traceback.
+ lua_call(ls, 2, 1);
+
+ // What's on top should be the error.
+ lua_error(ls);
+ }
+
+ return (lua_gettop(ls));
+}
+
+static const struct luaL_reg crawl_clib[] =
+{
+ { "mpr", crawl_mpr },
+ { "formatted_mpr", crawl_formatted_mpr },
+ { "more", crawl_more },
+ { "mesclr", crawl_mesclr },
+ { "random2", crawl_random2 },
+ { "one_chance_in", crawl_one_chance_in },
+ { "random2avg" , crawl_random2avg },
+ { "coinflip", crawl_coinflip },
+ { "roll_dice", crawl_roll_dice },
+ { "random_range", crawl_random_range },
+ { "random_element", crawl_random_element },
+ { "redraw_screen", crawl_redraw_screen },
+ { "input_line", crawl_input_line },
+ { "c_input_line", crawl_c_input_line},
+ { "getch", crawl_getch },
+ { "yesno", crawl_yesno },
+ { "yesnoquit", crawl_yesnoquit },
+ { "kbhit", crawl_kbhit },
+ { "flush_input", crawl_flush_input },
+ { "sendkeys", crawl_sendkeys },
+ { "process_command", crawl_process_command },
+ { "playsound", crawl_playsound },
+ { "runmacro", crawl_runmacro },
+ { "bindkey", crawl_bindkey },
+ { "setopt", crawl_setopt },
+ { "read_options", crawl_read_options },
+ { "msgch_num", crawl_msgch_num },
+ { "msgch_name", crawl_msgch_name },
+ { "take_note", crawl_take_note },
+
+ { "regex", crawl_regex },
+ { "message_filter", crawl_message_filter },
+ { "trim", crawl_trim },
+ { "split", crawl_split },
+ { "grammar", _crawl_grammar },
+ { "article_a", crawl_article_a },
+ { "game_started", crawl_game_started },
+ { "err_trace", crawl_err_trace },
+
+ { NULL, NULL },
+};
+
+void cluaopen_crawl(lua_State *ls)
+{
+ clua_register_metatable(ls, REGEX_METATABLE, crawl_regex_ops,
+ lua_object_gc<text_pattern>);
+ clua_register_metatable(ls, MESSF_METATABLE, crawl_messf_ops,
+ lua_object_gc<message_filter>);
+
+ luaL_openlib(ls, "crawl", crawl_clib, 0);
+}
+
+/////////////////////////////////////////////////////////////////////
+// Non-user-accessible bindings (dlua).
+//
+
LUAFN(_crawl_args)
{
return dlua_stringtable(ls, SysEnv.cmd_args);
@@ -45,7 +634,30 @@ LUAFN(_crawl_millis)
}
#endif
-const struct luaL_reg crawl_lib[] =
+std::string _crawl_make_name(lua_State *ls)
+{
+ // A quick wrapper around itemname:make_name. Seed is random_int().
+ // Possible parameters: all caps, max length, char start. By default
+ // these are false, -1, and 0 as per make_name.
+ bool all_caps = false;
+ int maxlen = -1;
+ char start = 0;
+ if (lua_gettop(ls) >= 1 && lua_isboolean(ls, 1))
+ all_caps = lua_toboolean(ls, 1);
+ if (lua_gettop(ls) >= 2 && lua_isnumber(ls, 2))
+ maxlen = luaL_checkint(ls, 2);
+ if (lua_gettop(ls) >= 3 && lua_isstring(ls, 3))
+ {
+ const char* s = luaL_checkstring(ls, 3);
+ if (s && *s)
+ start = *s;
+ }
+ return make_name(random_int(), all_caps, maxlen, start);
+}
+
+LUARET1(crawl_make_name, string, _crawl_make_name(ls).c_str())
+
+static const struct luaL_reg crawl_dlib[] =
{
{ "args", _crawl_args },
{ "mark_milestone", _crawl_milestone },
@@ -53,6 +665,11 @@ const struct luaL_reg crawl_lib[] =
#ifdef UNIX
{ "millis", _crawl_millis },
#endif
+{ "make_name", crawl_make_name },
{ NULL, NULL }
};
+void dluaopen_crawl(lua_State *ls)
+{
+ luaL_openlib(ls, "crawl", crawl_dlib, 0);
+}
diff --git a/crawl-ref/source/l_debug.cc b/crawl-ref/source/l_debug.cc
new file mode 100644
index 0000000000..ac7ca63654
--- /dev/null
+++ b/crawl-ref/source/l_debug.cc
@@ -0,0 +1,82 @@
+/*
+ * File: l_debug.cc
+ * Summary: Various debugging bindings.
+ */
+
+#include "AppHdr.h"
+
+#include "dlua.h"
+#include "l_libs.h"
+
+#include "chardump.h"
+#include "dungeon.h"
+#include "message.h"
+#include "place.h"
+
+// WARNING: This is a very low-level call.
+LUAFN(debug_goto_place)
+{
+ try
+ {
+ const level_id id = level_id::parse_level_id(luaL_checkstring(ls, 1));
+ you.level_type = id.level_type;
+ if (id.level_type == LEVEL_DUNGEON)
+ {
+ you.where_are_you = static_cast<branch_type>(id.branch);
+ you.your_level = absdungeon_depth(id.branch, id.depth);
+ }
+ }
+ catch (const std::string &err)
+ {
+ luaL_error(ls, err.c_str());
+ }
+ return (0);
+}
+
+LUAFN(debug_flush_map_memory)
+{
+ dgn_flush_map_memory();
+ init_level_connectivity();
+ return (0);
+}
+
+LUAFN(debug_generate_level)
+{
+ no_messages mx;
+ env.show.init(0);
+ env.map.init(map_cell());
+#ifdef USE_TILE
+ tile_init_default_flavour();
+ tile_clear_flavour();
+ TileNewLevel(true);
+#endif
+ builder(you.your_level, you.level_type);
+ return (0);
+}
+
+LUAFN(debug_dump_map)
+{
+ const int pos = lua_isuserdata(ls, 1) ? 2 : 1;
+ if (lua_isstring(ls, pos))
+ dump_map(lua_tostring(ls, pos), true);
+ return (0);
+}
+
+LUAFN(_debug_test_explore)
+{
+#ifdef WIZARD
+ debug_test_explore();
+#endif
+ return (0);
+}
+
+const struct luaL_reg debug_dlib[] =
+{
+{ "goto_place", debug_goto_place },
+{ "flush_map_memory", debug_flush_map_memory },
+{ "generate_level", debug_generate_level },
+{ "dump_map", debug_dump_map },
+{ "test_explore", _debug_test_explore },
+
+{ NULL, NULL }
+};
diff --git a/crawl-ref/source/l_dgn.cc b/crawl-ref/source/l_dgn.cc
index e7792fe32f..e640177406 100644
--- a/crawl-ref/source/l_dgn.cc
+++ b/crawl-ref/source/l_dgn.cc
@@ -6,48 +6,21 @@
#include <cmath>
#include "branch.h"
-#include "chardump.h"
#include "cloud.h"
#include "initfile.h"
#include "mapmark.h"
#include "maps.h"
-#include "message.h"
-#include "place.h"
#include "spl-util.h"
#include "view.h"
///////////////////////////////////////////////////////////////////////////
// Lua dungeon bindings (in the dgn table).
-static dungeon_feature_type _get_lua_feature(lua_State *ls, int idx)
-{
- dungeon_feature_type feat = (dungeon_feature_type)0;
- if (lua_isnumber(ls, idx))
- feat = (dungeon_feature_type)luaL_checkint(ls, idx);
- else if (lua_isstring(ls, idx))
- feat = dungeon_feature_by_name(luaL_checkstring(ls, idx));
- else
- luaL_argerror(ls, idx, "Feature must be a string or a feature index.");
-
- return feat;
-}
-
-static dungeon_feature_type _check_lua_feature(lua_State *ls, int idx)
-{
- const dungeon_feature_type f = _get_lua_feature(ls, idx);
- if (!f)
- luaL_argerror(ls, idx, "Invalid dungeon feature");
- return (f);
-}
-
static inline bool _lua_boolean(lua_State *ls, int ndx, bool defval)
{
return lua_isnone(ls, ndx)? defval : lua_toboolean(ls, ndx);
}
-#define FEAT(f, pos) \
-dungeon_feature_type f = _check_lua_feature(ls, pos)
-
void dgn_reset_default_depth()
{
lc_default_depths.clear();
@@ -124,47 +97,6 @@ static int dgn_depth(lua_State *ls)
return dgn_depth_proc(ls, map->depths, 2);
}
-// WARNING: This is a very low-level call.
-LUAFN(dgn_dbg_goto_place)
-{
- try
- {
- const level_id id = level_id::parse_level_id(luaL_checkstring(ls, 1));
- you.level_type = id.level_type;
- if (id.level_type == LEVEL_DUNGEON)
- {
- you.where_are_you = static_cast<branch_type>(id.branch);
- you.your_level = absdungeon_depth(id.branch, id.depth);
- }
- }
- catch (const std::string &err)
- {
- luaL_error(ls, err.c_str());
- }
- return (0);
-}
-
-LUAFN(dgn_dbg_flush_map_memory)
-{
- dgn_flush_map_memory();
- init_level_connectivity();
- return (0);
-}
-
-LUAFN(dgn_dbg_generate_level)
-{
- no_messages mx;
- env.show.init(0);
- env.map.init(map_cell());
-#ifdef USE_TILE
- tile_init_default_flavour();
- tile_clear_flavour();
- TileNewLevel(true);
-#endif
- builder(you.your_level, you.level_type);
- return (0);
-}
-
static int dgn_place(lua_State *ls)
{
MAP(ls, 1, map);
@@ -363,9 +295,8 @@ static int dgn_orient(lua_State *ls)
PLUARET(string, map_section_name(map->orient));
}
-static int dgn_map_add_transform(
- lua_State *ls,
- std::string (map_lines::*add)(const std::string &s))
+int dgn_map_add_transform(lua_State *ls,
+ std::string (map_lines::*add)(const std::string &s))
{
MAP(ls, 1, map);
if (lua_gettop(ls) == 1)
@@ -640,29 +571,6 @@ static int dgn_welcome(lua_State *ls)
return (0);
}
-static int dgn_grid(lua_State *ls)
-{
- GETCOORD(c, 1, 2, map_bounds);
-
- if (!lua_isnone(ls, 3))
- {
- const dungeon_feature_type feat = _get_lua_feature(ls, 3);
- if (feat)
- grd(c) = feat;
- }
- PLUARET(number, grd(c));
-}
-
-LUARET1(_dgn_is_wall, boolean,
- feat_is_wall(static_cast<dungeon_feature_type>(luaL_checkint(ls, 1))))
-
-static int dgn_max_bounds(lua_State *ls)
-{
- lua_pushnumber(ls, GXM);
- lua_pushnumber(ls, GYM);
- return (2);
-}
-
typedef
flood_find<map_def::map_feature_finder, map_def::map_bounds_check>
map_flood_finder;
@@ -886,105 +794,6 @@ static int dgn_colour_at(lua_State *ls)
PLUARET(string, colour_to_str(env.grid_colours(c)).c_str());
}
-const char *dngn_feature_names[] =
-{
-"unseen", "closed_door", "detected_secret_door", "secret_door",
-"wax_wall", "metal_wall", "green_crystal_wall", "rock_wall", "stone_wall",
-"permarock_wall",
-"clear_rock_wall", "clear_stone_wall", "clear_permarock_wall", "trees",
-"open_sea", "orcish_idol", "", "", "", "", "",
-"granite_statue", "statue_reserved_1", "statue_reserved_2",
-"", "", "", "", "", "", "", "",
-"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
-"", "", "", "", "", "", "", "", "", "", "", "", "", "lava",
-"deep_water", "", "", "shallow_water", "water_stuck", "floor",
-"floor_special", "floor_reserved", "exit_hell", "enter_hell",
-"open_door", "", "", "trap_mechanical", "trap_magical", "trap_natural",
-"undiscovered_trap", "", "enter_shop", "enter_labyrinth",
-"stone_stairs_down_i", "stone_stairs_down_ii",
-"stone_stairs_down_iii", "escape_hatch_down", "stone_stairs_up_i",
-"stone_stairs_up_ii", "stone_stairs_up_iii", "escape_hatch_up", "",
-"", "enter_dis", "enter_gehenna", "enter_cocytus",
-"enter_tartarus", "enter_abyss", "exit_abyss", "stone_arch",
-"enter_pandemonium", "exit_pandemonium", "transit_pandemonium",
-"", "", "", "builder_special_wall", "builder_special_floor", "",
-"", "", "enter_orcish_mines", "enter_hive", "enter_lair",
-"enter_slime_pits", "enter_vaults", "enter_crypt",
-"enter_hall_of_blades", "enter_zot", "enter_temple",
-"enter_snake_pit", "enter_elven_halls", "enter_tomb",
-"enter_swamp", "enter_shoals", "enter_reserved_2",
-"enter_reserved_3", "enter_reserved_4", "", "", "",
-"return_from_orcish_mines", "return_from_hive",
-"return_from_lair", "return_from_slime_pits",
-"return_from_vaults", "return_from_crypt",
-"return_from_hall_of_blades", "return_from_zot",
-"return_from_temple", "return_from_snake_pit",
-"return_from_elven_halls", "return_from_tomb",
-"return_from_swamp", "return_from_shoals", "return_reserved_2",
-"return_reserved_3", "return_reserved_4", "", "", "", "", "", "",
-"", "", "", "", "", "", "", "enter_portal_vault", "exit_portal_vault",
-"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
-"", "", "altar_zin", "altar_shining_one", "altar_kikubaaqudgha",
-"altar_yredelemnul", "altar_xom", "altar_vehumet",
-"altar_okawaru", "altar_makhleb", "altar_sif_muna", "altar_trog",
-"altar_nemelex_xobeh", "altar_elyvilon", "altar_lugonu",
-"altar_beogh", "altar_jiyva", "altar_feawn", "", "", "", "",
-"fountain_blue", "fountain_sparkling", "fountain_blood",
-"dry_fountain_blue", "dry_fountain_sparkling", "dry_fountain_blood",
-"permadry_fountain", "abandoned_shop"
-};
-
-dungeon_feature_type dungeon_feature_by_name(const std::string &name)
-{
- COMPILE_CHECK(ARRAYSZ(dngn_feature_names) == NUM_REAL_FEATURES, c1);
- if (name.empty())
- return (DNGN_UNSEEN);
-
- for (unsigned i = 0; i < ARRAYSZ(dngn_feature_names); ++i)
- if (dngn_feature_names[i] == name)
- return static_cast<dungeon_feature_type>(i);
-
- return (DNGN_UNSEEN);
-}
-
-std::vector<std::string> dungeon_feature_matches(const std::string &name)
-{
- std::vector<std::string> matches;
-
- COMPILE_CHECK(ARRAYSZ(dngn_feature_names) == NUM_REAL_FEATURES, c1);
- if (name.empty())
- return (matches);
-
- for (unsigned i = 0; i < ARRAYSZ(dngn_feature_names); ++i)
- if (strstr(dngn_feature_names[i], name.c_str()))
- matches.push_back(dngn_feature_names[i]);
-
- return (matches);
-}
-
-const char *dungeon_feature_name(dungeon_feature_type rfeat)
-{
- const unsigned feat = rfeat;
-
- if (feat >= ARRAYSZ(dngn_feature_names))
- return (NULL);
-
- return dngn_feature_names[feat];
-}
-
-static int dgn_feature_number(lua_State *ls)
-{
- const std::string &name = luaL_checkstring(ls, 1);
- PLUARET(number, dungeon_feature_by_name(name));
-}
-
-static int dgn_feature_name(lua_State *ls)
-{
- const unsigned feat = luaL_checkint(ls, 1);
- PLUARET(string,
- dungeon_feature_name(static_cast<dungeon_feature_type>(feat)));
-}
-
static int dgn_register_listener(lua_State *ls)
{
unsigned mask = luaL_checkint(ls, 1);
@@ -1040,68 +849,6 @@ static int dgn_num_matching_markers(lua_State *ls)
PLUARET(number, markers.size());
}
-static int dgn_feature_desc(lua_State *ls)
-{
- const dungeon_feature_type feat =
- static_cast<dungeon_feature_type>(luaL_checkint(ls, 1));
- const description_level_type dtype =
- lua_isnumber(ls, 2)?
- static_cast<description_level_type>(luaL_checkint(ls, 2)) :
- description_type_by_name(lua_tostring(ls, 2));
- const bool need_stop = lua_isboolean(ls, 3)? lua_toboolean(ls, 3) : false;
- const std::string s =
- feature_description(feat, NUM_TRAPS, false, dtype, need_stop);
- lua_pushstring(ls, s.c_str());
- return (1);
-}
-
-static int dgn_feature_desc_at(lua_State *ls)
-{
- const description_level_type dtype =
- lua_isnumber(ls, 3)?
- static_cast<description_level_type>(luaL_checkint(ls, 3)) :
- description_type_by_name(lua_tostring(ls, 3));
- const bool need_stop = lua_isboolean(ls, 4)? lua_toboolean(ls, 4) : false;
- const std::string s =
- feature_description(coord_def(luaL_checkint(ls, 1),
- luaL_checkint(ls, 2)),
- false, dtype, need_stop);
- lua_pushstring(ls, s.c_str());
- return (1);
-}
-
-static int dgn_set_feature_desc_short(lua_State *ls)
-{
- const std::string base_name = luaL_checkstring(ls, 1);
- const std::string desc = luaL_checkstring(ls, 2);
-
- if (base_name.empty())
- {
- luaL_argerror(ls, 1, "Base name can't be empty");
- return (0);
- }
-
- set_feature_desc_short(base_name, desc);
-
- return (0);
-}
-
-static int dgn_set_feature_desc_long(lua_State *ls)
-{
- const std::string raw_name = luaL_checkstring(ls, 1);
- const std::string desc = luaL_checkstring(ls, 2);
-
- if (raw_name.empty())
- {
- luaL_argerror(ls, 1, "Raw name can't be empty");
- return (0);
- }
-
- set_feature_desc_long(raw_name, desc);
-
- return (0);
-}
-
static int dgn_terrain_changed(lua_State *ls)
{
dungeon_feature_type type = DNGN_UNSEEN;
@@ -1167,9 +914,7 @@ static int dgn_fixup_stairs(lua_State *ls)
if (new_feat != DNGN_UNSEEN)
{
grd[x][y] = new_feat;
- env.markers.add(
- new map_feature_marker(
- coord_def(x, y),
+ env.markers.add(new map_feature_marker(coord_def(x, y),
new_feat));
}
}
@@ -1179,31 +924,6 @@ static int dgn_fixup_stairs(lua_State *ls)
return (0);
}
-#ifdef USE_TILE
-static unsigned int _get_tile_idx(lua_State *ls, int arg)
-{
- if (!lua_isstring(ls, arg))
- {
- luaL_argerror(ls, arg, "Expected string for tile name");
- return 0;
- }
-
- const char *tile_name = luaL_checkstring(ls, arg);
-
- unsigned int idx;
- if (!tile_dngn_index(tile_name, idx))
- {
- std::string error = "Couldn't find tile '";
- error += tile_name;
- error += "'";
- luaL_argerror(ls, arg, error.c_str());
- return 0;
- }
-
- return idx;
-}
-#endif
-
static int dgn_floor_halo(lua_State *ls)
{
std::string error = "";
@@ -1261,7 +981,7 @@ static int dgn_floor_halo(lua_State *ls)
}
#ifdef USE_TILE
- unsigned int tile = _get_tile_idx(ls, 3);
+ unsigned int tile = get_tile_idx(ls, 3);
if (!tile)
return (0);
if (tile_dngn_count(tile) != 9)
@@ -1483,339 +1203,6 @@ static int dgn_apply_area_cloud(lua_State *ls)
return (0);
}
-static void _clamp_to_bounds(int &x, int &y, bool edge_ok = false)
-{
- const int edge_offset = edge_ok ? 0 : 1;
- x = std::min(std::max(x, X_BOUND_1 + edge_offset), X_BOUND_2 - edge_offset);
- y = std::min(std::max(y, Y_BOUND_1 + edge_offset), Y_BOUND_2 - edge_offset);
-}
-
-// Return a metatable for a point on the map_lines grid.
-static int dgn_grd_table(lua_State *ls)
-{
- MAP(ls, 1, map);
-
- map_def **mapref = clua_new_userdata<map_def *>(ls, GRD_METATABLE);
- *mapref = map;
-
- return (1);
-}
-
-static int dgn_width(lua_State *ls)
-{
- MAP(ls, 1, map);
-
- lua_pushnumber(ls, map->map.width());
- return (1);
-}
-
-static int dgn_height(lua_State *ls)
-{
- MAP(ls, 1, map);
-
- lua_pushnumber(ls, map->map.height());
- return (1);
-}
-
-static int dgn_fill_area(lua_State *ls)
-{
- int x1 = luaL_checkint(ls, 1);
- int y1 = luaL_checkint(ls, 2);
- int x2 = luaL_checkint(ls, 3);
- int y2 = luaL_checkint(ls, 4);
- dungeon_feature_type feat = _check_lua_feature(ls, 5);
-
- _clamp_to_bounds(x1, y1);
- _clamp_to_bounds(x2, y2);
- if (x2 < x1)
- std::swap(x1, x2);
- if (y2 < y1)
- std::swap(y1, y2);
-
- for (int y = y1; y <= y2; y++)
- for (int x = x1; x <= x2; x++)
- grd[x][y] = feat;
-
- return 0;
-}
-
-static int dgn_replace_area(lua_State *ls)
-{
- int x1 = luaL_checkint(ls, 1);
- int y1 = luaL_checkint(ls, 2);
- int x2 = luaL_checkint(ls, 3);
- int y2 = luaL_checkint(ls, 4);
- dungeon_feature_type search = _check_lua_feature(ls, 5);
- dungeon_feature_type replace = _check_lua_feature(ls, 6);
-
- // gracefully handle out of bound areas by truncating them.
- _clamp_to_bounds(x1, y1);
- _clamp_to_bounds(x2, y2);
- if (x2 < x1)
- std::swap(x1, x2);
- if (y2 < y1)
- std::swap(y1, y2);
-
- for (int y = y1; y <= y2; y++)
- for (int x = x1; x <= x2; x++)
- if (grd[x][y] == search)
- grd[x][y] = replace;
-
- return 0;
-}
-
-static int dgn_octa_room(lua_State *ls)
-{
- int x1 = luaL_checkint(ls, 1);
- int y1 = luaL_checkint(ls, 2);
- int x2 = luaL_checkint(ls, 3);
- int y2 = luaL_checkint(ls, 4);
- int oblique = luaL_checkint(ls, 5);
- dungeon_feature_type fill = _check_lua_feature(ls, 6);
-
- spec_room sr;
- sr.tl.x = x1;
- sr.br.x = x2;
- sr.tl.y = y1;
- sr.br.y = y2;
-
- octa_room(sr, oblique, fill);
-
- return 0;
-}
-
-static int dgn_make_pillars(lua_State *ls)
-{
- int center_x = luaL_checkint(ls, 1);
- int center_y = luaL_checkint(ls, 2);
- int num = luaL_checkint(ls, 3);
- int scale_x = luaL_checkint(ls, 4);
- int big_radius = luaL_checkint(ls, 5);
- int pillar_radius = luaL_checkint(ls, 6);
- dungeon_feature_type fill = _check_lua_feature(ls, 8);
-
- // [enne] The underscore is for DJGPP's brain damage.
- const float _PI = 3.14159265f;
- for (int n = 0; n < num; n++)
- {
- float angle = n * 2 * _PI / (float)num;
- int x = (int)std::floor(std::cos(angle) * big_radius * scale_x + 0.5f);
- int y = (int)std::floor(std::sin(angle) * big_radius + 0.5f);
-
- lua_pushvalue(ls, 7);
- lua_pushnumber(ls, center_x + x);
- lua_pushnumber(ls, center_y + y);
- lua_pushnumber(ls, pillar_radius);
- lua_pushnumber(ls, fill);
-
- lua_call(ls, 4, 0);
- }
-
- return 0;
-}
-
-static int dgn_make_square(lua_State *ls)
-{
- int center_x = luaL_checkint(ls, 1);
- int center_y = luaL_checkint(ls, 2);
- int radius = std::abs(luaL_checkint(ls, 3));
- dungeon_feature_type fill = _check_lua_feature(ls, 4);
-
- for (int x = -radius; x <= radius; x++)
- for (int y = -radius; y <= radius; y++)
- grd[center_x + x][center_y + y] = fill;
-
- return 0;
-}
-
-static int dgn_make_rounded_square(lua_State *ls)
-{
- int center_x = luaL_checkint(ls, 1);
- int center_y = luaL_checkint(ls, 2);
- int radius = std::abs(luaL_checkint(ls, 3));
- dungeon_feature_type fill = _check_lua_feature(ls, 4);
-
- for (int x = -radius; x <= radius; x++)
- for (int y = -radius; y <= radius; y++)
- if (std::abs(x) != radius || std::abs(y) != radius)
- grd[center_x + x][center_y + y] = fill;
-
- return 0;
-}
-
-static int dgn_make_circle(lua_State *ls)
-{
- int center_x = luaL_checkint(ls, 1);
- int center_y = luaL_checkint(ls, 2);
- int radius = std::abs(luaL_checkint(ls, 3));
- dungeon_feature_type fill = _check_lua_feature(ls, 4);
-
- for (int x = -radius; x <= radius; x++)
- for (int y = -radius; y <= radius; y++)
- if (x * x + y * y < radius * radius)
- grd[center_x + x][center_y + y] = fill;
-
- return 0;
-}
-
-static int dgn_in_bounds(lua_State *ls)
-{
- int x = luaL_checkint(ls, 1);
- int y = luaL_checkint(ls, 2);
-
- lua_pushboolean(ls, in_bounds(x, y));
- return 1;
-}
-
-static int dgn_replace_first(lua_State *ls)
-{
- int x = luaL_checkint(ls, 1);
- int y = luaL_checkint(ls, 2);
- int dx = luaL_checkint(ls, 3);
- int dy = luaL_checkint(ls, 4);
- dungeon_feature_type search = _check_lua_feature(ls, 5);
- dungeon_feature_type replace = _check_lua_feature(ls, 6);
-
- _clamp_to_bounds(x, y);
- bool found = false;
- while (in_bounds(x, y))
- {
- if (grd[x][y] == search)
- {
- grd[x][y] = replace;
- found = true;
- break;
- }
-
- x += dx;
- y += dy;
- }
-
- lua_pushboolean(ls, found);
- return 1;
-}
-
-static int dgn_replace_random(lua_State *ls)
-{
- dungeon_feature_type search = _check_lua_feature(ls, 1);
- dungeon_feature_type replace = _check_lua_feature(ls, 2);
-
- int x, y;
- do
- {
- x = random2(GXM);
- y = random2(GYM);
- }
- while (grd[x][y] != search);
-
- grd[x][y] = replace;
-
- return 0;
-}
-
-static int dgn_spotty_level(lua_State *ls)
-{
- bool seeded = lua_toboolean(ls, 1);
- int iterations = luaL_checkint(ls, 2);
- bool boxy = lua_toboolean(ls, 3);
-
- spotty_level(seeded, iterations, boxy);
- return 0;
-}
-
-static int dgn_smear_feature(lua_State *ls)
-{
- int iterations = luaL_checkint(ls, 1);
- bool boxy = lua_toboolean(ls, 2);
- dungeon_feature_type feat = _check_lua_feature(ls, 3);
-
- int x1 = luaL_checkint(ls, 4);
- int y1 = luaL_checkint(ls, 5);
- int x2 = luaL_checkint(ls, 6);
- int y2 = luaL_checkint(ls, 7);
-
- _clamp_to_bounds(x1, y1, true);
- _clamp_to_bounds(x2, y2, true);
-
- smear_feature(iterations, boxy, feat, x1, y1, x2, y2);
-
- return 0;
-}
-
-static int dgn_count_feature_in_box(lua_State *ls)
-{
- int x1 = luaL_checkint(ls, 1);
- int y1 = luaL_checkint(ls, 2);
- int x2 = luaL_checkint(ls, 3);
- int y2 = luaL_checkint(ls, 4);
- dungeon_feature_type feat = _check_lua_feature(ls, 5);
-
- lua_pushnumber(ls, count_feature_in_box(x1, y1, x2, y2, feat));
- return 1;
-}
-
-static int dgn_count_antifeature_in_box(lua_State *ls)
-{
- int x1 = luaL_checkint(ls, 1);
- int y1 = luaL_checkint(ls, 2);
- int x2 = luaL_checkint(ls, 3);
- int y2 = luaL_checkint(ls, 4);
- dungeon_feature_type feat = _check_lua_feature(ls, 5);
-
- lua_pushnumber(ls, count_antifeature_in_box(x1, y1, x2, y2, feat));
- return 1;
-}
-
-static int dgn_count_neighbours(lua_State *ls)
-{
- int x = luaL_checkint(ls, 1);
- int y = luaL_checkint(ls, 2);
- dungeon_feature_type feat = _check_lua_feature(ls, 3);
-
- lua_pushnumber(ls, count_neighbours(x, y, feat));
- return 1;
-}
-
-static int dgn_join_the_dots(lua_State *ls)
-{
- int from_x = luaL_checkint(ls, 1);
- int from_y = luaL_checkint(ls, 2);
- int to_x = luaL_checkint(ls, 3);
- int to_y = luaL_checkint(ls, 4);
- // TODO enne - push map masks to lua?
- unsigned map_mask = MMT_VAULT;
- bool early_exit = lua_toboolean(ls, 5);
-
- coord_def from(from_x, from_y);
- coord_def to(to_x, to_y);
-
- bool ret = join_the_dots(from, to, map_mask, early_exit);
- lua_pushboolean(ls, ret);
-
- return 1;
-}
-
-static int dgn_fill_disconnected_zones(lua_State *ls)
-{
- int from_x = luaL_checkint(ls, 1);
- int from_y = luaL_checkint(ls, 2);
- int to_x = luaL_checkint(ls, 3);
- int to_y = luaL_checkint(ls, 4);
-
- dungeon_feature_type feat = _check_lua_feature(ls, 5);
-
- process_disconnected_zones(from_x, from_y, to_x, to_y, true, feat);
-
- return 0;
-}
-
-LUAFN(_dgn_is_opaque)
-{
- COORDS(c, 1, 2);
- lua_pushboolean(ls, feat_is_opaque(grd(c)));
- return (1);
-}
-
static int _dgn_is_passable(lua_State *ls)
{
COORDS(c, 1, 2);
@@ -1942,147 +1329,6 @@ LUAFN(dgn_with_map_anchors)
return (1);
}
-#define BRANCH(br, pos) \
-const char *branch_name = luaL_checkstring(ls, pos); \
-branch_type req_branch_type = str_to_branch(branch_name); \
-if (req_branch_type == NUM_BRANCHES) \
-luaL_error(ls, "Expected branch name"); \
-Branch &br = branches[req_branch_type]
-
-#define BRANCHFN(name, type, expr) \
-LUAFN(dgn_br_##name) { \
-BRANCH(br, 1); \
-PLUARET(type, expr); \
-}
-
-BRANCHFN(floorcol, number, br.floor_colour)
-BRANCHFN(rockcol, number, br.rock_colour)
-BRANCHFN(has_shops, boolean, br.has_shops)
-BRANCHFN(has_uniques, boolean, br.has_uniques)
-BRANCHFN(parent_branch, string,
- br.parent_branch == NUM_BRANCHES ? ""
- : branches[br.parent_branch].abbrevname)
-
-#define LEVEL(lev, br, pos) \
-const char *level_name = luaL_checkstring(ls, pos); \
-level_area_type lev = str_to_level_area_type(level_name); \
-if (lev == NUM_LEVEL_AREA_TYPES) \
-luaL_error(ls, "Expected level name"); \
-const char *branch_name = luaL_checkstring(ls, pos); \
-branch_type br = str_to_branch(branch_name); \
-if (lev == LEVEL_DUNGEON && br == NUM_BRANCHES) \
-luaL_error(ls, "Expected branch name");
-
-static void push_level_id(lua_State *ls, const level_id &lid)
-{
- // We're skipping the constructor; naughty, but level_id has no
- // virtual methods and no dynamically allocated memory.
- level_id *nlev =
- static_cast<level_id*>(lua_newuserdata(ls, sizeof(level_id)));
- *nlev = lid;
-}
-
-static level_id _lua_level_id(lua_State *ls, int ndx)
-{
- if (lua_isstring(ls, ndx))
- {
- const char *s = lua_tostring(ls, 1);
- try
- {
- return level_id::parse_level_id(s);
- }
- catch (const std::string &err)
- {
- luaL_error(ls, err.c_str());
- }
- }
- else if (lua_isuserdata(ls, ndx))
- {
- const level_id *lid = static_cast<level_id*>(lua_touserdata(ls, ndx));
- return (*lid);
- }
-
- luaL_argerror(ls, ndx, "Expected level_id");
- // Never gets here.
- return level_id();
-}
-
-LUAFN(dgn_level_id)
-{
- const int nargs = lua_gettop(ls);
- if (!nargs)
- push_level_id(ls, level_id::current());
- else if (nargs == 1)
- push_level_id(ls, _lua_level_id(ls, 1));
- return (1);
-}
-
-LUAFN(dgn_level_name)
-{
- const level_id lid(_lua_level_id(ls, 1));
- lua_pushstring(ls, lid.describe().c_str());
- return (1);
-}
-
-LUAFN(dgn_set_level_type_name)
-{
- if (you.level_type != LEVEL_PORTAL_VAULT)
- {
- luaL_error(ls, "Can only set level type name on portal vaults");
- return(0);
- }
-
- if (!lua_isstring(ls, 1))
- {
- luaL_argerror(ls, 1, "Expected string for level type name");
- return(0);
- }
-
- you.level_type_name = luaL_checkstring(ls, 1);
-
- return(0);
-}
-
-LUAFN(dgn_set_level_type_name_abbrev)
-{
- if (you.level_type != LEVEL_PORTAL_VAULT)
- {
- luaL_error(ls, "Can only set level type name abbreviation on "
- "portal vaults");
- return(0);
- }
-
- if (!lua_isstring(ls, 1))
- {
- luaL_argerror(ls, 1, "Expected string for level type name "
- "abbreviation");
- return(0);
- }
-
- you.level_type_name_abbrev = luaL_checkstring(ls, 1);
-
- return(0);
-}
-
-LUAFN(dgn_set_level_type_origin)
-{
- if (you.level_type != LEVEL_PORTAL_VAULT)
- {
- luaL_error(ls, "Can only set level type origin on portal vaults");
- return(0);
- }
-
- if (!lua_isstring(ls, 1))
- {
- luaL_argerror(ls, 1, "Expected string for level type origin");
- return(0);
- }
-
- you.level_type_origin = luaL_checkstring(ls, 1);
-
- return(0);
-}
-
static int _lua_push_map(lua_State *ls, const map_def *map)
{
if (map)
@@ -2104,17 +1350,17 @@ LUAFN(dgn_map_by_tag)
LUAFN(dgn_map_in_depth)
{
- const level_id lid = _lua_level_id(ls, 1);
+ const level_id lid = dlua_level_id(ls, 1);
const bool mini = _lua_boolean(ls, 2, true);
return _lua_push_map(ls, random_map_in_depth(lid, mini));
}
LUAFN(dgn_map_by_place)
{
- const level_id lid = _lua_level_id(ls, 1);
+ const level_id lid = dlua_level_id(ls, 1);
const bool mini = _lua_boolean(ls, 2, false);
return _lua_push_map(ls, random_map_for_place(lid, mini));
-}
+}
LUAFN(_dgn_place_map)
{
@@ -2243,140 +1489,10 @@ LUAFN(_dgn_reuse_map)
return (0);
}
-LUAFN(dgn_lev_floortile)
-{
-#ifdef USE_TILE
- LEVEL(lev, br, 1);
-
- tile_flavour flv;
- tile_default_flv(lev, br, flv);
-
- const char *tile_name = tile_dngn_name(flv.floor);
- PLUARET(string, tile_name);
-#else
- PLUARET(string, "invalid");
-#endif
-}
-
-LUAFN(dgn_lev_rocktile)
-{
-#ifdef USE_TILE
- LEVEL(lev, br, 1);
-
- tile_flavour flv;
- tile_default_flv(lev, br, flv);
-
- const char *tile_name = tile_dngn_name(flv.wall);
- PLUARET(string, tile_name);
-#else
- PLUARET(string, "invalid");
-#endif
-}
-
-LUAFN(dgn_lrocktile)
-{
- MAP(ls, 1, map);
-
-#ifdef USE_TILE
- unsigned short tile = _get_tile_idx(ls, 2);
- map->rock_tile = tile;
-
- const char *tile_name = tile_dngn_name(tile);
- PLUARET(string, tile_name);
-#else
- UNUSED(map);
- PLUARET(string, "invalid");
-#endif
-}
-
-LUAFN(dgn_lfloortile)
-{
- MAP(ls, 1, map);
-
-#ifdef USE_TILE
- unsigned short tile = _get_tile_idx(ls, 2);
- map->floor_tile = tile;
-
- const char *tile_name = tile_dngn_name(tile);
- PLUARET(string, tile_name);
-#else
- UNUSED(map);
- PLUARET(string, "invalid");
-#endif
-}
-
-LUAFN(dgn_change_rock_tile)
-{
-#ifdef USE_TILE
- unsigned short tile = _get_tile_idx(ls, 1);
- if (tile)
- env.tile_default.wall = tile;
-
- const char *tile_name = tile_dngn_name(tile);
- PLUARET(string, tile_name);
-#else
- PLUARET(string, "invalid");
-#endif
-}
-
-LUAFN(dgn_change_floor_tile)
-{
-#ifdef USE_TILE
- unsigned short tile = _get_tile_idx(ls, 1);
- if (tile)
- env.tile_default.floor = tile;
-
- const char *tile_name = tile_dngn_name(tile);
- PLUARET(string, tile_name);
-#else
- PLUARET(string, "invalid");
-#endif
-}
-
-LUAFN(dgn_ftile)
-{
-#ifdef USE_TILE
- return dgn_map_add_transform(ls, &map_lines::add_floortile);
-#else
- return 0;
-#endif
-}
-
-LUAFN(dgn_rtile)
-{
-#ifdef USE_TILE
- return dgn_map_add_transform(ls, &map_lines::add_rocktile);
-#else
- return 0;
-#endif
-}
-
-LUAFN(dgn_dbg_dump_map)
-{
- const int pos = lua_isuserdata(ls, 1) ? 2 : 1;
- if (lua_isstring(ls, pos))
- dump_map(lua_tostring(ls, pos), true);
- return (0);
-}
-
-LUAFN(dgn_dbg_test_explore)
-{
-#ifdef WIZARD
- debug_test_explore();
-#endif
- return (0);
-}
-
LUAWRAP(_dgn_reset_level, dgn_reset_level())
-const struct luaL_reg dgn_lib[] =
+const struct luaL_reg dgn_dlib[] =
{
-{ "dbg_goto_place", dgn_dbg_goto_place },
-{ "dbg_flush_map_memory", dgn_dbg_flush_map_memory },
-{ "dbg_generate_level", dgn_dbg_generate_level },
-{ "dbg_dump_map", dgn_dbg_dump_map },
-{ "dbg_test_explore", dgn_dbg_test_explore },
-
{ "reset_level", _dgn_reset_level },
{ "default_depth", dgn_default_depth },
@@ -2409,9 +1525,6 @@ const struct luaL_reg dgn_lib[] =
{ "kmask", dgn_kmask },
{ "mapsize", dgn_map_size },
-{ "grid", dgn_grid },
-{ "is_wall", _dgn_is_wall },
-{ "max_bounds", dgn_max_bounds },
{ "colour_at", dgn_colour_at },
{ "terrain_changed", dgn_terrain_changed },
@@ -2422,16 +1535,10 @@ const struct luaL_reg dgn_lib[] =
{ "gly_points", dgn_gly_points },
{ "original_map", dgn_original_map },
{ "load_des_file", dgn_load_des_file },
-{ "feature_number", dgn_feature_number },
-{ "feature_name", dgn_feature_name },
{ "register_listener", dgn_register_listener },
{ "remove_listener", dgn_remove_listener },
{ "remove_marker", dgn_remove_marker },
{ "num_matching_markers", dgn_num_matching_markers },
-{ "feature_desc", dgn_feature_desc },
-{ "feature_desc_at", dgn_feature_desc_at },
-{ "set_feature_desc_short", dgn_set_feature_desc_short },
-{ "set_feature_desc_long", dgn_set_feature_desc_long },
{ "change_level_flags", dgn_change_level_flags },
{ "change_branch_flags", dgn_change_branch_flags },
{ "get_floor_colour", dgn_get_floor_colour },
@@ -2444,29 +1551,6 @@ const struct luaL_reg dgn_lib[] =
{ "random_walk", dgn_random_walk },
{ "apply_area_cloud", dgn_apply_area_cloud },
-// building routines
-{ "grd_table", dgn_grd_table },
-{ "width", dgn_width },
-{ "height", dgn_height },
-{ "fill_area", dgn_fill_area },
-{ "replace_area", dgn_replace_area },
-{ "octa_room", dgn_octa_room },
-{ "make_pillars", dgn_make_pillars },
-{ "make_square", dgn_make_square },
-{ "make_rounded_square", dgn_make_rounded_square },
-{ "make_circle", dgn_make_circle },
-{ "in_bounds", dgn_in_bounds },
-{ "replace_first", dgn_replace_first },
-{ "replace_random", dgn_replace_random },
-{ "spotty_level", dgn_spotty_level },
-{ "smear_feature", dgn_smear_feature },
-{ "count_feature_in_box", dgn_count_feature_in_box },
-{ "count_antifeature_in_box", dgn_count_antifeature_in_box },
-{ "count_neighbours", dgn_count_neighbours },
-{ "join_the_dots", dgn_join_the_dots },
-{ "fill_disconnected_zones", dgn_fill_disconnected_zones },
-
-{ "is_opaque", _dgn_is_opaque },
{ "is_passable", _dgn_is_passable },
{ "register_feature_marker", dgn_register_feature_marker },
@@ -2475,17 +1559,6 @@ const struct luaL_reg dgn_lib[] =
{ "with_map_bounds_fn", dgn_with_map_bounds_fn },
{ "with_map_anchors", dgn_with_map_anchors },
-{ "br_floorcol", dgn_br_floorcol },
-{ "br_rockcol", dgn_br_rockcol },
-{ "br_has_shops", dgn_br_has_shops },
-{ "br_has_uniques", dgn_br_has_uniques },
-{ "br_parent_branch", dgn_br_parent_branch },
-
-{ "level_id", dgn_level_id },
-{ "level_name", dgn_level_name },
-{ "set_level_type_name", dgn_set_level_type_name },
-{ "set_level_type_name_abbrev", dgn_set_level_type_name_abbrev },
-{ "set_level_type_origin", dgn_set_level_type_origin },
{ "map_by_tag", dgn_map_by_tag },
{ "map_in_depth", dgn_map_in_depth },
{ "map_by_place", dgn_map_by_place },
@@ -2498,14 +1571,5 @@ const struct luaL_reg dgn_lib[] =
{ "get_special_room_info", dgn_get_special_room_info },
-{ "lrocktile", dgn_lrocktile },
-{ "lfloortile", dgn_lfloortile },
-{ "rtile", dgn_rtile },
-{ "ftile", dgn_ftile },
-{ "change_rock_tile", dgn_change_rock_tile },
-{ "change_floor_tile", dgn_change_floor_tile },
-{ "lev_floortile", dgn_lev_floortile },
-{ "lev_rocktile", dgn_lev_rocktile },
-
{ NULL, NULL }
};
diff --git a/crawl-ref/source/l_dgn_bf.cc b/crawl-ref/source/l_dgn_bf.cc
index ac7fd04a42..e79e6799e6 100644
--- a/crawl-ref/source/l_dgn_bf.cc
+++ b/crawl-ref/source/l_dgn_bf.cc
@@ -1,5 +1,5 @@
/*
- * File: l_dgnbf.cc
+ * File: l_dgn_bf.cc
* Summary: Dungeon lua builder functions.
*/
@@ -20,7 +20,7 @@ static int _table_int(lua_State *ls, int idx, const char *name, int defval)
bool valid = lua_isnumber(ls, idx);
if (!nil && !valid)
luaL_error(ls, "'%s' in table, but not an int.", name);
- int ret = (!nil && valid ? lua_tonumber(ls, idx) : defval);
+ int ret = (!nil && valid ? luaL_checkint(ls, idx) : defval);
lua_pop(ls, 1);
return (ret);
}
diff --git a/crawl-ref/source/l_dgnbld.cc b/crawl-ref/source/l_dgnbld.cc
new file mode 100644
index 0000000000..2f3fd0816e
--- /dev/null
+++ b/crawl-ref/source/l_dgnbld.cc
@@ -0,0 +1,365 @@
+/*
+ * File: l_dgnbld.cc
+ * Summary: Building routines (library "dgn").
+ */
+
+#include "AppHdr.h"
+
+#include <cmath>
+
+#include "dlua.h"
+#include "l_libs.h"
+
+#include "dungeon.h"
+
+// Return a metatable for a point on the map_lines grid.
+static int dgn_grd_table(lua_State *ls)
+{
+ MAP(ls, 1, map);
+
+ map_def **mapref = clua_new_userdata<map_def *>(ls, MAPGRD_METATABLE);
+ *mapref = map;
+
+ return (1);
+}
+
+static int dgn_width(lua_State *ls)
+{
+ MAP(ls, 1, map);
+
+ lua_pushnumber(ls, map->map.width());
+ return (1);
+}
+
+static int dgn_height(lua_State *ls)
+{
+ MAP(ls, 1, map);
+
+ lua_pushnumber(ls, map->map.height());
+ return (1);
+}
+
+static void _clamp_to_bounds(int &x, int &y, bool edge_ok = false)
+{
+ const int edge_offset = edge_ok ? 0 : 1;
+ x = std::min(std::max(x, X_BOUND_1 + edge_offset), X_BOUND_2 - edge_offset);
+ y = std::min(std::max(y, Y_BOUND_1 + edge_offset), Y_BOUND_2 - edge_offset);
+}
+
+static int dgn_fill_area(lua_State *ls)
+{
+ int x1 = luaL_checkint(ls, 1);
+ int y1 = luaL_checkint(ls, 2);
+ int x2 = luaL_checkint(ls, 3);
+ int y2 = luaL_checkint(ls, 4);
+ dungeon_feature_type feat = check_lua_feature(ls, 5);
+
+ _clamp_to_bounds(x1, y1);
+ _clamp_to_bounds(x2, y2);
+ if (x2 < x1)
+ std::swap(x1, x2);
+ if (y2 < y1)
+ std::swap(y1, y2);
+
+ for (int y = y1; y <= y2; y++)
+ for (int x = x1; x <= x2; x++)
+ grd[x][y] = feat;
+
+ return 0;
+}
+
+static int dgn_replace_area(lua_State *ls)
+{
+ int x1 = luaL_checkint(ls, 1);
+ int y1 = luaL_checkint(ls, 2);
+ int x2 = luaL_checkint(ls, 3);
+ int y2 = luaL_checkint(ls, 4);
+ dungeon_feature_type search = check_lua_feature(ls, 5);
+ dungeon_feature_type replace = check_lua_feature(ls, 6);
+
+ // gracefully handle out of bound areas by truncating them.
+ _clamp_to_bounds(x1, y1);
+ _clamp_to_bounds(x2, y2);
+ if (x2 < x1)
+ std::swap(x1, x2);
+ if (y2 < y1)
+ std::swap(y1, y2);
+
+ for (int y = y1; y <= y2; y++)
+ for (int x = x1; x <= x2; x++)
+ if (grd[x][y] == search)
+ grd[x][y] = replace;
+
+ return 0;
+}
+
+static int dgn_octa_room(lua_State *ls)
+{
+ int x1 = luaL_checkint(ls, 1);
+ int y1 = luaL_checkint(ls, 2);
+ int x2 = luaL_checkint(ls, 3);
+ int y2 = luaL_checkint(ls, 4);
+ int oblique = luaL_checkint(ls, 5);
+ dungeon_feature_type fill = check_lua_feature(ls, 6);
+
+ spec_room sr;
+ sr.tl.x = x1;
+ sr.br.x = x2;
+ sr.tl.y = y1;
+ sr.br.y = y2;
+
+ octa_room(sr, oblique, fill);
+
+ return 0;
+}
+
+static int dgn_make_pillars(lua_State *ls)
+{
+ int center_x = luaL_checkint(ls, 1);
+ int center_y = luaL_checkint(ls, 2);
+ int num = luaL_checkint(ls, 3);
+ int scale_x = luaL_checkint(ls, 4);
+ int big_radius = luaL_checkint(ls, 5);
+ int pillar_radius = luaL_checkint(ls, 6);
+ dungeon_feature_type fill = check_lua_feature(ls, 8);
+
+ // [enne] The underscore is for DJGPP's brain damage.
+ const float _PI = 3.14159265f;
+ for (int n = 0; n < num; n++)
+ {
+ float angle = n * 2 * _PI / (float)num;
+ int x = (int)std::floor(std::cos(angle) * big_radius * scale_x + 0.5f);
+ int y = (int)std::floor(std::sin(angle) * big_radius + 0.5f);
+
+ lua_pushvalue(ls, 7);
+ lua_pushnumber(ls, center_x + x);
+ lua_pushnumber(ls, center_y + y);
+ lua_pushnumber(ls, pillar_radius);
+ lua_pushnumber(ls, fill);
+
+ lua_call(ls, 4, 0);
+ }
+
+ return 0;
+}
+
+static int dgn_make_square(lua_State *ls)
+{
+ int center_x = luaL_checkint(ls, 1);
+ int center_y = luaL_checkint(ls, 2);
+ int radius = std::abs(luaL_checkint(ls, 3));
+ dungeon_feature_type fill = check_lua_feature(ls, 4);
+
+ for (int x = -radius; x <= radius; x++)
+ for (int y = -radius; y <= radius; y++)
+ grd[center_x + x][center_y + y] = fill;
+
+ return 0;
+}
+
+static int dgn_make_rounded_square(lua_State *ls)
+{
+ int center_x = luaL_checkint(ls, 1);
+ int center_y = luaL_checkint(ls, 2);
+ int radius = std::abs(luaL_checkint(ls, 3));
+ dungeon_feature_type fill = check_lua_feature(ls, 4);
+
+ for (int x = -radius; x <= radius; x++)
+ for (int y = -radius; y <= radius; y++)
+ if (std::abs(x) != radius || std::abs(y) != radius)
+ grd[center_x + x][center_y + y] = fill;
+
+ return 0;
+}
+
+static int dgn_make_circle(lua_State *ls)
+{
+ int center_x = luaL_checkint(ls, 1);
+ int center_y = luaL_checkint(ls, 2);
+ int radius = std::abs(luaL_checkint(ls, 3));
+ dungeon_feature_type fill = check_lua_feature(ls, 4);
+
+ for (int x = -radius; x <= radius; x++)
+ for (int y = -radius; y <= radius; y++)
+ if (x * x + y * y < radius * radius)
+ grd[center_x + x][center_y + y] = fill;
+
+ return 0;
+}
+
+static int dgn_in_bounds(lua_State *ls)
+{
+ int x = luaL_checkint(ls, 1);
+ int y = luaL_checkint(ls, 2);
+
+ lua_pushboolean(ls, in_bounds(x, y));
+ return 1;
+}
+
+static int dgn_replace_first(lua_State *ls)
+{
+ int x = luaL_checkint(ls, 1);
+ int y = luaL_checkint(ls, 2);
+ int dx = luaL_checkint(ls, 3);
+ int dy = luaL_checkint(ls, 4);
+ dungeon_feature_type search = check_lua_feature(ls, 5);
+ dungeon_feature_type replace = check_lua_feature(ls, 6);
+
+ _clamp_to_bounds(x, y);
+ bool found = false;
+ while (in_bounds(x, y))
+ {
+ if (grd[x][y] == search)
+ {
+ grd[x][y] = replace;
+ found = true;
+ break;
+ }
+
+ x += dx;
+ y += dy;
+ }
+
+ lua_pushboolean(ls, found);
+ return 1;
+}
+
+static int dgn_replace_random(lua_State *ls)
+{
+ dungeon_feature_type search = check_lua_feature(ls, 1);
+ dungeon_feature_type replace = check_lua_feature(ls, 2);
+
+ int x, y;
+ do
+ {
+ x = random2(GXM);
+ y = random2(GYM);
+ }
+ while (grd[x][y] != search);
+
+ grd[x][y] = replace;
+
+ return 0;
+}
+
+static int dgn_spotty_level(lua_State *ls)
+{
+ bool seeded = lua_toboolean(ls, 1);
+ int iterations = luaL_checkint(ls, 2);
+ bool boxy = lua_toboolean(ls, 3);
+
+ spotty_level(seeded, iterations, boxy);
+ return 0;
+}
+
+static int dgn_smear_feature(lua_State *ls)
+{
+ int iterations = luaL_checkint(ls, 1);
+ bool boxy = lua_toboolean(ls, 2);
+ dungeon_feature_type feat = check_lua_feature(ls, 3);
+
+ int x1 = luaL_checkint(ls, 4);
+ int y1 = luaL_checkint(ls, 5);
+ int x2 = luaL_checkint(ls, 6);
+ int y2 = luaL_checkint(ls, 7);
+
+ _clamp_to_bounds(x1, y1, true);
+ _clamp_to_bounds(x2, y2, true);
+
+ smear_feature(iterations, boxy, feat, x1, y1, x2, y2);
+
+ return 0;
+}
+
+static int dgn_count_feature_in_box(lua_State *ls)
+{
+ int x1 = luaL_checkint(ls, 1);
+ int y1 = luaL_checkint(ls, 2);
+ int x2 = luaL_checkint(ls, 3);
+ int y2 = luaL_checkint(ls, 4);
+ dungeon_feature_type feat = check_lua_feature(ls, 5);
+
+ lua_pushnumber(ls, count_feature_in_box(x1, y1, x2, y2, feat));
+ return 1;
+}
+
+static int dgn_count_antifeature_in_box(lua_State *ls)
+{
+ int x1 = luaL_checkint(ls, 1);
+ int y1 = luaL_checkint(ls, 2);
+ int x2 = luaL_checkint(ls, 3);
+ int y2 = luaL_checkint(ls, 4);
+ dungeon_feature_type feat = check_lua_feature(ls, 5);
+
+ lua_pushnumber(ls, count_antifeature_in_box(x1, y1, x2, y2, feat));
+ return 1;
+}
+
+static int dgn_count_neighbours(lua_State *ls)
+{
+ int x = luaL_checkint(ls, 1);
+ int y = luaL_checkint(ls, 2);
+ dungeon_feature_type feat = check_lua_feature(ls, 3);
+
+ lua_pushnumber(ls, count_neighbours(x, y, feat));
+ return 1;
+}
+
+static int dgn_join_the_dots(lua_State *ls)
+{
+ int from_x = luaL_checkint(ls, 1);
+ int from_y = luaL_checkint(ls, 2);
+ int to_x = luaL_checkint(ls, 3);
+ int to_y = luaL_checkint(ls, 4);
+ // TODO enne - push map masks to lua?
+ unsigned map_mask = MMT_VAULT;
+ bool early_exit = lua_toboolean(ls, 5);
+
+ coord_def from(from_x, from_y);
+ coord_def to(to_x, to_y);
+
+ bool ret = join_the_dots(from, to, map_mask, early_exit);
+ lua_pushboolean(ls, ret);
+
+ return 1;
+}
+
+static int dgn_fill_disconnected_zones(lua_State *ls)
+{
+ int from_x = luaL_checkint(ls, 1);
+ int from_y = luaL_checkint(ls, 2);
+ int to_x = luaL_checkint(ls, 3);
+ int to_y = luaL_checkint(ls, 4);
+
+ dungeon_feature_type feat = check_lua_feature(ls, 5);
+
+ process_disconnected_zones(from_x, from_y, to_x, to_y, true, feat);
+
+ return 0;
+}
+
+const struct luaL_reg dgn_build_dlib[] =
+{
+{ "grd_table", dgn_grd_table },
+{ "width", dgn_width },
+{ "height", dgn_height },
+{ "fill_area", dgn_fill_area },
+{ "replace_area", dgn_replace_area },
+{ "octa_room", dgn_octa_room },
+{ "make_pillars", dgn_make_pillars },
+{ "make_square", dgn_make_square },
+{ "make_rounded_square", dgn_make_rounded_square },
+{ "make_circle", dgn_make_circle },
+{ "in_bounds", dgn_in_bounds },
+{ "replace_first", dgn_replace_first },
+{ "replace_random", dgn_replace_random },
+{ "spotty_level", dgn_spotty_level },
+{ "smear_feature", dgn_smear_feature },
+{ "count_feature_in_box", dgn_count_feature_in_box },
+{ "count_antifeature_in_box", dgn_count_antifeature_in_box },
+{ "count_neighbours", dgn_count_neighbours },
+{ "join_the_dots", dgn_join_the_dots },
+{ "fill_disconnected_zones", dgn_fill_disconnected_zones },
+
+{ NULL, NULL }
+};
diff --git a/crawl-ref/source/l_dgnevt.cc b/crawl-ref/source/l_dgnevt.cc
index 73574309fe..f776f5c402 100644
--- a/crawl-ref/source/l_dgnevt.cc
+++ b/crawl-ref/source/l_dgnevt.cc
@@ -49,7 +49,7 @@ static int dgnevent_arg2(lua_State *ls)
PLUARET(number, dev->arg2);
}
-static const struct luaL_reg dgnevent_lib[] =
+static const struct luaL_reg dgnevent_dlib[] =
{
{ "type", dgnevent_type },
{ "pos", dgnevent_place },
@@ -62,7 +62,7 @@ static const struct luaL_reg dgnevent_lib[] =
void luaopen_dgnevent(lua_State *ls)
{
- luaopen_setmeta(ls, "dgnevent", dgnevent_lib, DEVENT_METATABLE);
+ luaopen_setmeta(ls, "dgnevent", dgnevent_dlib, DEVENT_METATABLE);
}
/*
@@ -119,7 +119,7 @@ static int dgn_dgn_event(lua_State *ls)
return (retvals);
}
-const struct luaL_reg dgn_event_lib[] =
+const struct luaL_reg dgn_event_dlib[] =
{
{ "dgn_event_type", dgn_dgn_event },
diff --git a/crawl-ref/source/l_dgngrd.cc b/crawl-ref/source/l_dgngrd.cc
new file mode 100644
index 0000000000..bedac0fde3
--- /dev/null
+++ b/crawl-ref/source/l_dgngrd.cc
@@ -0,0 +1,245 @@
+/*
+ * File: l_dgngrd.cc
+ * Summary: Grid and dungeon_feature_type-related bindings.
+ */
+
+#include "AppHdr.h"
+
+#include "dlua.h"
+#include "l_libs.h"
+
+#include "directn.h"
+#include "terrain.h"
+
+const char *dngn_feature_names[] =
+{
+"unseen", "closed_door", "detected_secret_door", "secret_door",
+"wax_wall", "metal_wall", "green_crystal_wall", "rock_wall", "stone_wall",
+"permarock_wall",
+"clear_rock_wall", "clear_stone_wall", "clear_permarock_wall", "trees",
+"open_sea", "orcish_idol", "", "", "", "", "",
+"granite_statue", "statue_reserved_1", "statue_reserved_2",
+"", "", "", "", "", "", "", "",
+"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
+"", "", "", "", "", "", "", "", "", "", "", "", "", "lava",
+"deep_water", "", "", "shallow_water", "water_stuck", "floor",
+"floor_special", "floor_reserved", "exit_hell", "enter_hell",
+"open_door", "", "", "trap_mechanical", "trap_magical", "trap_natural",
+"undiscovered_trap", "", "enter_shop", "enter_labyrinth",
+"stone_stairs_down_i", "stone_stairs_down_ii",
+"stone_stairs_down_iii", "escape_hatch_down", "stone_stairs_up_i",
+"stone_stairs_up_ii", "stone_stairs_up_iii", "escape_hatch_up", "",
+"", "enter_dis", "enter_gehenna", "enter_cocytus",
+"enter_tartarus", "enter_abyss", "exit_abyss", "stone_arch",
+"enter_pandemonium", "exit_pandemonium", "transit_pandemonium",
+"", "", "", "builder_special_wall", "builder_special_floor", "",
+"", "", "enter_orcish_mines", "enter_hive", "enter_lair",
+"enter_slime_pits", "enter_vaults", "enter_crypt",
+"enter_hall_of_blades", "enter_zot", "enter_temple",
+"enter_snake_pit", "enter_elven_halls", "enter_tomb",
+"enter_swamp", "enter_shoals", "enter_reserved_2",
+"enter_reserved_3", "enter_reserved_4", "", "", "",
+"return_from_orcish_mines", "return_from_hive",
+"return_from_lair", "return_from_slime_pits",
+"return_from_vaults", "return_from_crypt",
+"return_from_hall_of_blades", "return_from_zot",
+"return_from_temple", "return_from_snake_pit",
+"return_from_elven_halls", "return_from_tomb",
+"return_from_swamp", "return_from_shoals", "return_reserved_2",
+"return_reserved_3", "return_reserved_4", "", "", "", "", "", "",
+"", "", "", "", "", "", "", "enter_portal_vault", "exit_portal_vault",
+"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
+"", "", "altar_zin", "altar_shining_one", "altar_kikubaaqudgha",
+"altar_yredelemnul", "altar_xom", "altar_vehumet",
+"altar_okawaru", "altar_makhleb", "altar_sif_muna", "altar_trog",
+"altar_nemelex_xobeh", "altar_elyvilon", "altar_lugonu",
+"altar_beogh", "altar_jiyva", "altar_feawn", "", "", "", "",
+"fountain_blue", "fountain_sparkling", "fountain_blood",
+"dry_fountain_blue", "dry_fountain_sparkling", "dry_fountain_blood",
+"permadry_fountain", "abandoned_shop"
+};
+
+dungeon_feature_type dungeon_feature_by_name(const std::string &name)
+{
+ COMPILE_CHECK(ARRAYSZ(dngn_feature_names) == NUM_REAL_FEATURES, c1);
+ if (name.empty())
+ return (DNGN_UNSEEN);
+
+ for (unsigned i = 0; i < ARRAYSZ(dngn_feature_names); ++i)
+ if (dngn_feature_names[i] == name)
+ return static_cast<dungeon_feature_type>(i);
+
+ return (DNGN_UNSEEN);
+}
+
+std::vector<std::string> dungeon_feature_matches(const std::string &name)
+{
+ std::vector<std::string> matches;
+
+ COMPILE_CHECK(ARRAYSZ(dngn_feature_names) == NUM_REAL_FEATURES, c1);
+ if (name.empty())
+ return (matches);
+
+ for (unsigned i = 0; i < ARRAYSZ(dngn_feature_names); ++i)
+ if (strstr(dngn_feature_names[i], name.c_str()))
+ matches.push_back(dngn_feature_names[i]);
+
+ return (matches);
+}
+
+const char *dungeon_feature_name(dungeon_feature_type rfeat)
+{
+ const unsigned feat = rfeat;
+
+ if (feat >= ARRAYSZ(dngn_feature_names))
+ return (NULL);
+
+ return dngn_feature_names[feat];
+}
+
+static int dgn_feature_number(lua_State *ls)
+{
+ const std::string &name = luaL_checkstring(ls, 1);
+ PLUARET(number, dungeon_feature_by_name(name));
+}
+
+static int dgn_feature_name(lua_State *ls)
+{
+ const unsigned feat = luaL_checkint(ls, 1);
+ PLUARET(string,
+ dungeon_feature_name(static_cast<dungeon_feature_type>(feat)));
+}
+
+static dungeon_feature_type _get_lua_feature(lua_State *ls, int idx)
+{
+ dungeon_feature_type feat = (dungeon_feature_type)0;
+ if (lua_isnumber(ls, idx))
+ feat = (dungeon_feature_type)luaL_checkint(ls, idx);
+ else if (lua_isstring(ls, idx))
+ feat = dungeon_feature_by_name(luaL_checkstring(ls, idx));
+ else
+ luaL_argerror(ls, idx, "Feature must be a string or a feature index.");
+
+ return feat;
+}
+
+dungeon_feature_type check_lua_feature(lua_State *ls, int idx)
+{
+ const dungeon_feature_type f = _get_lua_feature(ls, idx);
+ if (!f)
+ luaL_argerror(ls, idx, "Invalid dungeon feature");
+ return (f);
+}
+
+#define FEAT(f, pos) \
+dungeon_feature_type f = check_lua_feature(ls, pos)
+
+static int dgn_feature_desc(lua_State *ls)
+{
+ const dungeon_feature_type feat =
+ static_cast<dungeon_feature_type>(luaL_checkint(ls, 1));
+ const description_level_type dtype =
+ lua_isnumber(ls, 2)?
+ static_cast<description_level_type>(luaL_checkint(ls, 2)) :
+ description_type_by_name(lua_tostring(ls, 2));
+ const bool need_stop = lua_isboolean(ls, 3)? lua_toboolean(ls, 3) : false;
+ const std::string s =
+ feature_description(feat, NUM_TRAPS, false, dtype, need_stop);
+ lua_pushstring(ls, s.c_str());
+ return (1);
+}
+
+static int dgn_feature_desc_at(lua_State *ls)
+{
+ const description_level_type dtype =
+ lua_isnumber(ls, 3)?
+ static_cast<description_level_type>(luaL_checkint(ls, 3)) :
+ description_type_by_name(lua_tostring(ls, 3));
+ const bool need_stop = lua_isboolean(ls, 4)? lua_toboolean(ls, 4) : false;
+ const std::string s =
+ feature_description(coord_def(luaL_checkint(ls, 1),
+ luaL_checkint(ls, 2)),
+ false, dtype, need_stop);
+ lua_pushstring(ls, s.c_str());
+ return (1);
+}
+
+static int dgn_set_feature_desc_short(lua_State *ls)
+{
+ const std::string base_name = luaL_checkstring(ls, 1);
+ const std::string desc = luaL_checkstring(ls, 2);
+
+ if (base_name.empty())
+ {
+ luaL_argerror(ls, 1, "Base name can't be empty");
+ return (0);
+ }
+
+ set_feature_desc_short(base_name, desc);
+
+ return (0);
+}
+
+static int dgn_set_feature_desc_long(lua_State *ls)
+{
+ const std::string raw_name = luaL_checkstring(ls, 1);
+ const std::string desc = luaL_checkstring(ls, 2);
+
+ if (raw_name.empty())
+ {
+ luaL_argerror(ls, 1, "Raw name can't be empty");
+ return (0);
+ }
+
+ set_feature_desc_long(raw_name, desc);
+
+ return (0);
+}
+
+static int dgn_max_bounds(lua_State *ls)
+{
+ lua_pushnumber(ls, GXM);
+ lua_pushnumber(ls, GYM);
+ return (2);
+}
+
+static int dgn_grid(lua_State *ls)
+{
+ GETCOORD(c, 1, 2, map_bounds);
+
+ if (!lua_isnone(ls, 3))
+ {
+ const dungeon_feature_type feat = _get_lua_feature(ls, 3);
+ if (feat)
+ grd(c) = feat;
+ }
+ PLUARET(number, grd(c));
+}
+
+// XXX: these two shouldn't be so different.
+LUARET1(_dgn_is_wall, boolean,
+ feat_is_wall(static_cast<dungeon_feature_type>(luaL_checkint(ls, 1))))
+
+LUAFN(_dgn_is_opaque)
+{
+ COORDS(c, 1, 2);
+ lua_pushboolean(ls, feat_is_opaque(grd(c)));
+ return (1);
+}
+
+const struct luaL_reg dgn_grid_dlib[] =
+{
+{ "feature_number", dgn_feature_number },
+{ "feature_name", dgn_feature_name },
+{ "feature_desc", dgn_feature_desc },
+{ "feature_desc_at", dgn_feature_desc_at },
+{ "set_feature_desc_short", dgn_set_feature_desc_short },
+{ "set_feature_desc_long", dgn_set_feature_desc_long },
+
+{ "grid", dgn_grid },
+{ "is_opaque", _dgn_is_opaque },
+{ "is_wall", _dgn_is_wall },
+{ "max_bounds", dgn_max_bounds },
+
+{ NULL, NULL }
+};
diff --git a/crawl-ref/source/l_dgnit.cc b/crawl-ref/source/l_dgnit.cc
index 4fb101d4e3..4f9cebd86c 100644
--- a/crawl-ref/source/l_dgnit.cc
+++ b/crawl-ref/source/l_dgnit.cc
@@ -86,7 +86,7 @@ static int dgn_create_item(lua_State *ls)
return (0);
}
-const struct luaL_reg dgn_item_lib[] =
+const struct luaL_reg dgn_item_dlib[] =
{
{ "item_from_index", dgn_item_from_index },
{ "items_at", dgn_items_at },
diff --git a/crawl-ref/source/l_dgnlvl.cc b/crawl-ref/source/l_dgnlvl.cc
new file mode 100644
index 0000000000..a5237096f1
--- /dev/null
+++ b/crawl-ref/source/l_dgnlvl.cc
@@ -0,0 +1,160 @@
+/*
+ * File: l_dgnlvl.cc
+ * Summary: Level and branch bindings (library "dgn").
+ */
+
+#include "AppHdr.h"
+
+#include "dlua.h"
+#include "l_libs.h"
+
+#include "branch.h"
+
+#define BRANCH(br, pos) \
+const char *branch_name = luaL_checkstring(ls, pos); \
+branch_type req_branch_type = str_to_branch(branch_name); \
+if (req_branch_type == NUM_BRANCHES) \
+luaL_error(ls, "Expected branch name"); \
+Branch &br = branches[req_branch_type]
+
+#define BRANCHFN(name, type, expr) \
+LUAFN(dgn_br_##name) { \
+BRANCH(br, 1); \
+PLUARET(type, expr); \
+}
+
+BRANCHFN(floorcol, number, br.floor_colour)
+BRANCHFN(rockcol, number, br.rock_colour)
+BRANCHFN(has_shops, boolean, br.has_shops)
+BRANCHFN(has_uniques, boolean, br.has_uniques)
+BRANCHFN(parent_branch, string,
+ br.parent_branch == NUM_BRANCHES
+ ? ""
+ : branches[br.parent_branch].abbrevname)
+
+static void _push_level_id(lua_State *ls, const level_id &lid)
+{
+ // We're skipping the constructor; naughty, but level_id has no
+ // virtual methods and no dynamically allocated memory.
+ level_id *nlev =
+ static_cast<level_id*>(lua_newuserdata(ls, sizeof(level_id)));
+ *nlev = lid;
+}
+
+level_id dlua_level_id(lua_State *ls, int ndx)
+{
+ if (lua_isstring(ls, ndx))
+ {
+ const char *s = lua_tostring(ls, 1);
+ try
+ {
+ return level_id::parse_level_id(s);
+ }
+ catch (const std::string &err)
+ {
+ luaL_error(ls, err.c_str());
+ }
+ }
+ else if (lua_isuserdata(ls, ndx))
+ {
+ const level_id *lid = static_cast<level_id*>(lua_touserdata(ls, ndx));
+ return (*lid);
+ }
+
+ luaL_argerror(ls, ndx, "Expected level_id");
+ // Never gets here.
+ return level_id();
+}
+
+LUAFN(dgn_level_id)
+{
+ const int nargs = lua_gettop(ls);
+ if (!nargs)
+ _push_level_id(ls, level_id::current());
+ else if (nargs == 1)
+ _push_level_id(ls, dlua_level_id(ls, 1));
+ return (1);
+}
+
+LUAFN(dgn_level_name)
+{
+ const level_id lid(dlua_level_id(ls, 1));
+ lua_pushstring(ls, lid.describe().c_str());
+ return (1);
+}
+
+LUAFN(dgn_set_level_type_name)
+{
+ if (you.level_type != LEVEL_PORTAL_VAULT)
+ {
+ luaL_error(ls, "Can only set level type name on portal vaults");
+ return(0);
+ }
+
+ if (!lua_isstring(ls, 1))
+ {
+ luaL_argerror(ls, 1, "Expected string for level type name");
+ return(0);
+ }
+
+ you.level_type_name = luaL_checkstring(ls, 1);
+
+ return(0);
+}
+
+LUAFN(dgn_set_level_type_name_abbrev)
+{
+ if (you.level_type != LEVEL_PORTAL_VAULT)
+ {
+ luaL_error(ls, "Can only set level type name abbreviation on "
+ "portal vaults");
+ return(0);
+ }
+
+ if (!lua_isstring(ls, 1))
+ {
+ luaL_argerror(ls, 1, "Expected string for level type name "
+ "abbreviation");
+ return(0);
+ }
+
+ you.level_type_name_abbrev = luaL_checkstring(ls, 1);
+
+ return(0);
+}
+
+LUAFN(dgn_set_level_type_origin)
+{
+ if (you.level_type != LEVEL_PORTAL_VAULT)
+ {
+ luaL_error(ls, "Can only set level type origin on portal vaults");
+ return(0);
+ }
+
+ if (!lua_isstring(ls, 1))
+ {
+ luaL_argerror(ls, 1, "Expected string for level type origin");
+ return(0);
+ }
+
+ you.level_type_origin = luaL_checkstring(ls, 1);
+
+ return(0);
+}
+
+const struct luaL_reg dgn_level_dlib[] =
+{
+{ "br_floorcol", dgn_br_floorcol },
+{ "br_rockcol", dgn_br_rockcol },
+{ "br_has_shops", dgn_br_has_shops },
+{ "br_has_uniques", dgn_br_has_uniques },
+{ "br_parent_branch", dgn_br_parent_branch },
+
+{ "level_id", dgn_level_id },
+{ "level_name", dgn_level_name },
+{ "set_level_type_name", dgn_set_level_type_name },
+{ "set_level_type_name_abbrev", dgn_set_level_type_name_abbrev },
+{ "set_level_type_origin", dgn_set_level_type_origin },
+
+{ NULL, NULL }
+};
diff --git a/crawl-ref/source/l_dgnmon.cc b/crawl-ref/source/l_dgnmon.cc
index a464a4fb50..ca1eef82a5 100644
--- a/crawl-ref/source/l_dgnmon.cc
+++ b/crawl-ref/source/l_dgnmon.cc
@@ -253,7 +253,7 @@ LUAFN(dgn_dismiss_monsters)
luaL_checkstring(ls, 1)));
}
-const struct luaL_reg dgn_mons_lib[] =
+const struct luaL_reg dgn_mons_dlib[] =
{
{ "set_random_mon_list", dgn_set_random_mon_list },
{ "mons_from_index", dgn_mons_from_index },
diff --git a/crawl-ref/source/l_dgntil.cc b/crawl-ref/source/l_dgntil.cc
new file mode 100644
index 0000000000..2a47a333bc
--- /dev/null
+++ b/crawl-ref/source/l_dgntil.cc
@@ -0,0 +1,159 @@
+/*
+ * File: l_dgntile.cc
+ * Summary: Tiles-specific dungeon builder functions.
+ */
+
+#include "AppHdr.h"
+
+#include "dlua.h"
+#include "l_libs.h"
+
+#include "branch.h"
+#include "mapdef.h"
+
+#ifdef USE_TILE
+unsigned int get_tile_idx(lua_State *ls, int arg)
+{
+ if (!lua_isstring(ls, arg))
+ {
+ luaL_argerror(ls, arg, "Expected string for tile name");
+ return 0;
+ }
+
+ const char *tile_name = luaL_checkstring(ls, arg);
+
+ unsigned int idx;
+ if (!tile_dngn_index(tile_name, idx))
+ {
+ std::string error = "Couldn't find tile '";
+ error += tile_name;
+ error += "'";
+ luaL_argerror(ls, arg, error.c_str());
+ return 0;
+ }
+
+ return idx;
+}
+#endif
+
+LUAFN(dgn_lev_floortile)
+{
+#ifdef USE_TILE
+ LEVEL(lev, br, 1);
+
+ tile_flavour flv;
+ tile_default_flv(lev, br, flv);
+
+ const char *tile_name = tile_dngn_name(flv.floor);
+ PLUARET(string, tile_name);
+#else
+ PLUARET(string, "invalid");
+#endif
+}
+
+LUAFN(dgn_lev_rocktile)
+{
+#ifdef USE_TILE
+ LEVEL(lev, br, 1);
+
+ tile_flavour flv;
+ tile_default_flv(lev, br, flv);
+
+ const char *tile_name = tile_dngn_name(flv.wall);
+ PLUARET(string, tile_name);
+#else
+ PLUARET(string, "invalid");
+#endif
+}
+
+LUAFN(dgn_lrocktile)
+{
+ MAP(ls, 1, map);
+
+#ifdef USE_TILE
+ unsigned short tile = get_tile_idx(ls, 2);
+ map->rock_tile = tile;
+
+ const char *tile_name = tile_dngn_name(tile);
+ PLUARET(string, tile_name);
+#else
+ UNUSED(map);
+ PLUARET(string, "invalid");
+#endif
+}
+
+LUAFN(dgn_lfloortile)
+{
+ MAP(ls, 1, map);
+
+#ifdef USE_TILE
+ unsigned short tile = get_tile_idx(ls, 2);
+ map->floor_tile = tile;
+
+ const char *tile_name = tile_dngn_name(tile);
+ PLUARET(string, tile_name);
+#else
+ UNUSED(map);
+ PLUARET(string, "invalid");
+#endif
+}
+
+LUAFN(dgn_change_rock_tile)
+{
+#ifdef USE_TILE
+ unsigned short tile = get_tile_idx(ls, 1);
+ if (tile)
+ env.tile_default.wall = tile;
+
+ const char *tile_name = tile_dngn_name(tile);
+ PLUARET(string, tile_name);
+#else
+ PLUARET(string, "invalid");
+#endif
+}
+
+LUAFN(dgn_change_floor_tile)
+{
+#ifdef USE_TILE
+ unsigned short tile = get_tile_idx(ls, 1);
+ if (tile)
+ env.tile_default.floor = tile;
+
+ const char *tile_name = tile_dngn_name(tile);
+ PLUARET(string, tile_name);
+#else
+ PLUARET(string, "invalid");
+#endif
+}
+
+LUAFN(dgn_ftile)
+{
+#ifdef USE_TILE
+ return dgn_map_add_transform(ls, &map_lines::add_floortile);
+#else
+ return 0;
+#endif
+}
+
+LUAFN(dgn_rtile)
+{
+#ifdef USE_TILE
+ return dgn_map_add_transform(ls, &map_lines::add_rocktile);
+#else
+ return 0;
+#endif
+}
+
+const struct luaL_reg dgn_tile_dlib[] =
+{
+{ "lrocktile", dgn_lrocktile },
+{ "lfloortile", dgn_lfloortile },
+{ "rtile", dgn_rtile },
+{ "ftile", dgn_ftile },
+{ "change_rock_tile", dgn_change_rock_tile },
+{ "change_floor_tile", dgn_change_floor_tile },
+{ "lev_floortile", dgn_lev_floortile },
+{ "lev_rocktile", dgn_lev_rocktile },
+
+{ NULL, NULL }
+};
diff --git a/crawl-ref/source/l_file.cc b/crawl-ref/source/l_file.cc
index 5e204dbceb..78eb10f289 100644
--- a/crawl-ref/source/l_file.cc
+++ b/crawl-ref/source/l_file.cc
@@ -126,7 +126,7 @@ static int file_unmarshall_meta(lua_State *ls)
return (0);
}
-const struct luaL_reg file_lib[] =
+const struct luaL_reg file_dlib[] =
{
{ "marshall", file_marshall },
{ "marshall_meta", file_marshall_meta },
diff --git a/crawl-ref/source/l_libs.h b/crawl-ref/source/l_libs.h
index f6903f5118..9fe6d97eb3 100644
--- a/crawl-ref/source/l_libs.h
+++ b/crawl-ref/source/l_libs.h
@@ -8,15 +8,29 @@
#include "clua.h"
-extern const struct luaL_reg crawl_lib[];
-extern const struct luaL_reg dgn_lib[];
-extern const struct luaL_reg dgn_event_lib[];
-extern const struct luaL_reg dgn_item_lib[];
-extern const struct luaL_reg dgn_mons_lib[];
-extern const struct luaL_reg file_lib[];
-extern const struct luaL_reg los_lib[];
-extern const struct luaL_reg mapmarker_lib[];
-extern const struct luaL_reg you_lib[];
+/*
+ * Loaders for clua.
+ */
+
+void cluaopen_crawl(lua_State *ls);
+void cluaopen_you(lua_State *ls);
+
+/*
+ * Libraries and loaders, accessed from init_dungeon_lua().
+ */
+
+extern const struct luaL_reg debug_dlib[];
+extern const struct luaL_reg dgn_dlib[];
+extern const struct luaL_reg dgn_build_dlib[];
+extern const struct luaL_reg dgn_event_dlib[];
+extern const struct luaL_reg dgn_grid_dlib[];
+extern const struct luaL_reg dgn_item_dlib[];
+extern const struct luaL_reg dgn_level_dlib[];
+extern const struct luaL_reg dgn_mons_dlib[];
+extern const struct luaL_reg dgn_tile_dlib[];
+extern const struct luaL_reg file_dlib[];
+extern const struct luaL_reg los_dlib[];
+extern const struct luaL_reg mapmarker_dlib[];
void luaopen_dgnevent(lua_State *ls);
void luaopen_mapmarker(lua_State *ls);
@@ -25,6 +39,58 @@ void luaopen_ray(lua_State *ls);
void register_monslist(lua_State *ls);
void register_itemlist(lua_State *ls);
void register_builder_funcs(lua_State *ls);
-
-#endif
+void dluaopen_crawl(lua_State *ls);
+void dluaopen_mapgrd(lua_State *ls);
+void dluaopen_you(lua_State *ls);
+
+/*
+ * Macros for processing object arguments.
+ */
+#define GETCOORD(c, p1, p2, boundfn) \
+ coord_def c; \
+ c.x = luaL_checkint(ls, p1); \
+ c.y = luaL_checkint(ls, p2); \
+ if (!boundfn(c)) \
+ luaL_error( \
+ ls, \
+ make_stringf("Point (%d,%d) is out of bounds", \
+ c.x, c.y).c_str()); \
+ else ;
+
+
+#define COORDS(c, p1, p2) \
+ GETCOORD(c, p1, p2, in_bounds)
+
+#define FEAT(f, pos) \
+dungeon_feature_type f = check_lua_feature(ls, pos)
+
+#define LEVEL(lev, br, pos) \
+const char *level_name = luaL_checkstring(ls, pos); \
+level_area_type lev = str_to_level_area_type(level_name); \
+if (lev == NUM_LEVEL_AREA_TYPES) \
+luaL_error(ls, "Expected level name"); \
+const char *branch_name = luaL_checkstring(ls, pos); \
+branch_type br = str_to_branch(branch_name); \
+if (lev == LEVEL_DUNGEON && br == NUM_BRANCHES) \
+luaL_error(ls, "Expected branch name");
+
+#define MAP(ls, n, var) \
+map_def *var = *(map_def **) luaL_checkudata(ls, n, MAP_METATABLE)
+#define DEVENT(ls, n, var) \
+dgn_event *var = *(dgn_event **) luaL_checkudata(ls, n, DEVENT_METATABLE)
+#define MAPMARKER(ls, n, var) \
+map_marker *var = *(map_marker **) luaL_checkudata(ls, n, MAPMARK_METATABLE)
+
+
+/*
+ * Some shared helper functions.
+ */
+class map_lines;
+int dgn_map_add_transform(lua_State *ls,
+ std::string (map_lines::*add)(const std::string &s));
+unsigned int get_tile_idx(lua_State *ls, int arg);
+level_id dlua_level_id(lua_State *ls, int ndx);
+dungeon_feature_type check_lua_feature(lua_State *ls, int idx);
+
+#endif
diff --git a/crawl-ref/source/l_los.cc b/crawl-ref/source/l_los.cc
index b4d0f86fa1..e83c9358c7 100644
--- a/crawl-ref/source/l_los.cc
+++ b/crawl-ref/source/l_los.cc
@@ -41,7 +41,7 @@ LUAFN(los_cell_see_cell)
PLUARET(number, cell_see_cell(p, q));
}
-const struct luaL_reg los_lib[] =
+const struct luaL_reg los_dlib[] =
{
{ "findray", los_find_ray },
{ "cell_see_cell", los_cell_see_cell },
@@ -88,7 +88,7 @@ LUAFN(ray_pos)
return (2);
}
-static const struct luaL_reg ray_lib[] =
+static const struct luaL_reg ray_dlib[] =
{
{ "accx", ray_accx },
{ "accy", ray_accy },
@@ -100,6 +100,5 @@ static const struct luaL_reg ray_lib[] =
void luaopen_ray(lua_State *ls)
{
-// luaopen_setmeta(ls, "ray", ray_lib, RAY_METATABLE);
- clua_register_metatable(ls, RAY_METATABLE, ray_lib, lua_object_gc<ray_def>);
+ clua_register_metatable(ls, RAY_METATABLE, ray_dlib, lua_object_gc<ray_def>);
}
diff --git a/crawl-ref/source/l_mapgrd.cc b/crawl-ref/source/l_mapgrd.cc
new file mode 100644
index 0000000000..0c63238c79
--- /dev/null
+++ b/crawl-ref/source/l_mapgrd.cc
@@ -0,0 +1,109 @@
+#include "AppHdr.h"
+
+#include "dlua.h"
+#include "l_libs.h"
+
+#include "mapdef.h"
+
+/////////////////////////////////////////////////////////////////////
+// grd and grd_col handling (i.e. map_lines in a metatable)
+
+struct mapcolumn
+{
+ map_def* map;
+ int col;
+};
+
+static int grd_get(lua_State *ls)
+{
+ // Return a metatable for this column in the map grid.
+ map_def *map = *(map_def **) luaL_checkudata(ls, 1, MAPGRD_METATABLE);
+
+ int column = luaL_checkint(ls, 2);
+
+ mapcolumn *mapref = clua_new_userdata<mapcolumn>(ls, MAPGRD_COL_METATABLE);
+ mapref->map = map;
+ mapref->col = column;
+
+ return (1);
+}
+
+static int grd_set(lua_State *ls)
+{
+ return (luaL_error(ls, "%s", "Cannot assign to read-only table."));
+}
+
+static char* grd_glyph(lua_State *ls, int &col, int &row)
+{
+ mapcolumn *mapc = (mapcolumn *)luaL_checkudata(ls, 1, MAPGRD_COL_METATABLE);
+ row = luaL_checkint(ls, 2);
+ col = mapc->col;
+
+ map_lines &lines = mapc->map->map;
+ if (row < 1 || col < 1 || col > lines.width() || row > lines.height())
+ {
+ return (NULL);
+ }
+
+ coord_def mc(col - 1, row - 1);
+ return (&lines(mc));
+}
+
+static int grd_col_get(lua_State *ls)
+{
+ int col, row;
+ char *gly = grd_glyph(ls, col, row);
+ if (!gly)
+ return (luaL_error(ls, "Invalid coords: %d, %d", col, row));
+
+ char buf[2];
+ buf[0] = *gly;
+ buf[1] = '\0';
+
+ lua_pushstring(ls, buf);
+
+ return (1);
+}
+
+static int grd_col_set(lua_State *ls)
+{
+ int col, row;
+ char *gly = grd_glyph(ls, col, row);
+ if (!gly)
+ return (luaL_error(ls, "Invalid coords: %d, %d", col, row));
+
+ const char *str = luaL_checkstring(ls, 3);
+ if (!str[0] || str[1])
+ return (luaL_error(ls, "%s", "grd must be set to a single char."));
+
+ (*gly) = str[0];
+
+ return (0);
+}
+
+void dluaopen_mapgrd(lua_State *ls)
+{
+ // grd table
+ luaL_newmetatable(ls, MAPGRD_METATABLE);
+ lua_pushstring(ls, "__index");
+ lua_pushcfunction(ls, grd_get);
+ lua_settable(ls, -3);
+
+ lua_pushstring(ls, "__newindex");
+ lua_pushcfunction(ls, grd_set);
+ lua_settable(ls, -3);
+
+ lua_pop(ls, 1);
+
+ // grd col table
+ luaL_newmetatable(ls, MAPGRD_COL_METATABLE);
+ lua_pushstring(ls, "__index");
+ lua_pushcfunction(ls, grd_col_get);
+ lua_settable(ls, -3);
+
+ lua_pushstring(ls, "__newindex");
+ lua_pushcfunction(ls, grd_col_set);
+ lua_settable(ls, -3);
+
+ lua_pop(ls, 1);
+}
diff --git a/crawl-ref/source/l_mapmrk.cc b/crawl-ref/source/l_mapmrk.cc
index 98c2323546..2e25a2ff2b 100644
--- a/crawl-ref/source/l_mapmrk.cc
+++ b/crawl-ref/source/l_mapmrk.cc
@@ -21,7 +21,7 @@ static int mapmarker_move(lua_State *ls)
return (0);
}
-const struct luaL_reg mapmarker_lib[] =
+const struct luaL_reg mapmarker_dlib[] =
{
{ "pos", mapmarker_pos },
{ "move", mapmarker_move },
@@ -30,5 +30,5 @@ const struct luaL_reg mapmarker_lib[] =
void luaopen_mapmarker(lua_State *ls)
{
- luaopen_setmeta(ls, "mapmarker", mapmarker_lib, MAPMARK_METATABLE);
+ luaopen_setmeta(ls, "mapmarker", mapmarker_dlib, MAPMARK_METATABLE);
}
diff --git a/crawl-ref/source/l_you.cc b/crawl-ref/source/l_you.cc
index 4ecf0ef0cc..4e9809094d 100644
--- a/crawl-ref/source/l_you.cc
+++ b/crawl-ref/source/l_you.cc
@@ -3,8 +3,215 @@
#include "dlua.h"
#include "l_libs.h"
+#include "abl-show.h"
+#include "chardump.h"
+#include "delay.h"
+#include "food.h"
+#include "initfile.h"
#include "los.h"
+#include "mon-util.h"
+#include "newgame.h"
+#include "player.h"
+#include "religion.h"
+#include "skills2.h"
#include "spells3.h"
+#include "spl-util.h"
+#include "transfor.h"
+
+/////////////////////////////////////////////////////////////////////
+// Bindings to get information on the player (clua).
+//
+
+static const char *transform_name()
+{
+ switch (you.attribute[ATTR_TRANSFORMATION])
+ {
+ case TRAN_SPIDER:
+ return "spider";
+ case TRAN_BAT:
+ return "bat";
+ case TRAN_BLADE_HANDS:
+ return "blade";
+ case TRAN_STATUE:
+ return "statue";
+ case TRAN_ICE_BEAST:
+ return "ice";
+ case TRAN_DRAGON:
+ return "dragon";
+ case TRAN_LICH:
+ return "lich";
+ case TRAN_PIG:
+ return "pig";
+ default:
+ return "";
+ }
+}
+
+LUARET1(you_turn_is_over, boolean, you.turn_is_over)
+LUARET1(you_name, string, you.your_name)
+LUARET1(you_race, string,
+ species_name(you.species, you.experience_level).c_str())
+LUARET1(you_class, string, get_class_name(you.char_class))
+LUARET1(you_god, string, god_name(you.religion).c_str())
+LUARET1(you_good_god, boolean,
+ lua_isstring(ls, 1) ? is_good_god(str_to_god(lua_tostring(ls, 1)))
+ : is_good_god(you.religion))
+LUARET1(you_evil_god, boolean,
+ lua_isstring(ls, 1) ? is_evil_god(str_to_god(lua_tostring(ls, 1)))
+ : is_evil_god(you.religion))
+LUARET1(you_god_likes_fresh_corpses, boolean,
+ lua_isstring(ls, 1) ?
+ god_likes_fresh_corpses(str_to_god(lua_tostring(ls, 1))) :
+ god_likes_fresh_corpses(you.religion))
+LUARET1(you_god_likes_butchery, boolean,
+ lua_isstring(ls, 1) ?
+ god_likes_butchery(str_to_god(lua_tostring(ls, 1))) :
+ god_likes_butchery(you.religion))
+LUARET2(you_hp, number, you.hp, you.hp_max)
+LUARET2(you_mp, number, you.magic_points, you.max_magic_points)
+LUARET1(you_hunger, string, hunger_level())
+LUARET2(you_strength, number, you.strength, you.max_strength)
+LUARET2(you_intelligence, number, you.intel, you.max_intel)
+LUARET2(you_dexterity, number, you.dex, you.max_dex)
+LUARET1(you_exp, number, you.experience_level)
+LUARET1(you_exp_points, number, you.experience)
+LUARET1(you_skill, number,
+ lua_isstring(ls, 1) ? you.skills[str_to_skill(lua_tostring(ls, 1))]
+ : 0)
+LUARET1(you_res_poison, number, player_res_poison(false))
+LUARET1(you_res_fire, number, player_res_fire(false))
+LUARET1(you_res_cold, number, player_res_cold(false))
+LUARET1(you_res_draining, number, player_prot_life(false))
+LUARET1(you_res_shock, number, player_res_electricity(false))
+LUARET1(you_res_statdrain, number, player_sust_abil(false))
+LUARET1(you_res_mutation, number, wearing_amulet(AMU_RESIST_MUTATION, false))
+LUARET1(you_res_slowing, number, wearing_amulet(AMU_RESIST_SLOW, false))
+LUARET1(you_gourmand, boolean, wearing_amulet(AMU_THE_GOURMAND, false))
+LUARET1(you_saprovorous, number, player_mutation_level(MUT_SAPROVOROUS))
+LUARET1(you_levitating, boolean, you.flight_mode() == FL_LEVITATE)
+LUARET1(you_flying, boolean, you.flight_mode() == FL_FLY)
+LUARET1(you_transform, string, transform_name())
+LUARET1(you_where, string, level_id::current().describe().c_str())
+LUARET1(you_branch, string, level_id::current().describe(false, false).c_str())
+LUARET1(you_subdepth, number, level_id::current().depth)
+// Increase by 1 because check happens on old level.
+LUARET1(you_absdepth, number, you.your_level + 1)
+LUAWRAP(you_stop_activity, interrupt_activity(AI_FORCE_INTERRUPT))
+LUARET1(you_taking_stairs, boolean,
+ current_delay_action() == DELAY_ASCENDING_STAIRS
+ || current_delay_action() == DELAY_DESCENDING_STAIRS)
+LUARET1(you_turns, number, you.num_turns)
+LUARET1(you_can_smell, boolean, player_can_smell())
+LUARET1(you_has_claws, number, you.has_claws(false))
+
+void lua_push_floor_items(lua_State *ls);
+static int you_floor_items(lua_State *ls)
+{
+ lua_push_floor_items(ls);
+ return (1);
+}
+
+static int l_you_spells(lua_State *ls)
+{
+ lua_newtable(ls);
+ int index = 0;
+ for (int i = 0; i < 52; ++i)
+ {
+ const spell_type spell = get_spell_by_letter( index_to_letter(i) );
+ if (spell == SPELL_NO_SPELL)
+ continue;
+
+ lua_pushstring(ls, spell_title(spell));
+ lua_rawseti(ls, -2, ++index);
+ }
+ return (1);
+}
+
+static int l_you_abils(lua_State *ls)
+{
+ lua_newtable(ls);
+
+ std::vector<const char *>abils = get_ability_names();
+ for (int i = 0, size = abils.size(); i < size; ++i)
+ {
+ lua_pushstring(ls, abils[i]);
+ lua_rawseti(ls, -2, i + 1);
+ }
+ return (1);
+}
+
+static int you_can_consume_corpses(lua_State *ls)
+{
+ lua_pushboolean(ls,
+ can_ingest(OBJ_FOOD, FOOD_CHUNK, true, false, false)
+ || can_ingest(OBJ_CORPSES, CORPSE_BODY, true, false, false)
+ );
+ return (1);
+}
+
+static const struct luaL_reg you_clib[] =
+{
+ { "turn_is_over", you_turn_is_over },
+ { "turns" , you_turns },
+ { "spells" , l_you_spells },
+ { "abilities" , l_you_abils },
+ { "name" , you_name },
+ { "race" , you_race },
+ { "class" , you_class },
+ { "god" , you_god },
+ { "good_god" , you_good_god },
+ { "evil_god" , you_evil_god },
+ { "hp" , you_hp },
+ { "mp" , you_mp },
+ { "hunger" , you_hunger },
+ { "strength" , you_strength },
+ { "intelligence", you_intelligence },
+ { "dexterity" , you_dexterity },
+ { "skill" , you_skill },
+ { "xl" , you_exp },
+ { "exp" , you_exp_points },
+ { "res_poison" , you_res_poison },
+ { "res_fire" , you_res_fire },
+ { "res_cold" , you_res_cold },
+ { "res_draining", you_res_draining },
+ { "res_shock" , you_res_shock },
+ { "res_statdrain", you_res_statdrain },
+ { "res_mutation", you_res_mutation },
+ { "res_slowing", you_res_slowing },
+ { "saprovorous", you_saprovorous },
+ { "gourmand", you_gourmand },
+ { "levitating", you_levitating },
+ { "flying", you_flying },
+ { "transform", you_transform },
+
+ { "god_likes_fresh_corpses", you_god_likes_fresh_corpses },
+ { "god_likes_butchery", you_god_likes_butchery },
+ { "can_consume_corpses", you_can_consume_corpses },
+
+ { "stop_activity", you_stop_activity },
+ { "taking_stairs", you_taking_stairs },
+
+ { "floor_items", you_floor_items },
+
+ { "where", you_where },
+ { "branch", you_branch },
+ { "subdepth", you_subdepth },
+ { "absdepth", you_absdepth },
+
+ { "can_smell", you_can_smell },
+ { "has_claws", you_has_claws },
+
+ { NULL, NULL },
+};
+
+void cluaopen_you(lua_State *ls)
+{
+ luaL_openlib(ls, "you", you_clib, 0);
+}
+
+/////////////////////////////////////////////////////////////////////
+// Player information (dlua). Grid coordinates etc.
+//
LUARET1(you_can_hear_pos, boolean,
player_can_hear(coord_def(luaL_checkint(ls,1), luaL_checkint(ls, 2))))
@@ -12,10 +219,6 @@ LUARET1(you_x_pos, number, you.pos().x)
LUARET1(you_y_pos, number, you.pos().y)
LUARET2(you_pos, number, you.pos().x, you.pos().y)
-// see_cell should not be exposed to user scripts. The game should
-// never disclose grid coordinates to the player. Therefore we load it
-// only into the core Lua interpreter (dlua), never into the user
-// script interpreter (clua).
LUARET1(you_see_cell, boolean,
see_cell(luaL_checkint(ls, 1), luaL_checkint(ls, 2)))
LUARET1(you_see_cell_no_trans, boolean,
@@ -41,16 +244,50 @@ LUAFN(you_losight)
return (0);
}
-const struct luaL_reg you_lib[] =
+static int _you_uniques(lua_State *ls)
+{
+ bool unique_found = false;
+
+ if (lua_gettop(ls) >= 1 && lua_isstring(ls, 1))
+ unique_found = you.unique_creatures[get_monster_by_name(lua_tostring(ls, 1))];
+
+ lua_pushboolean(ls, unique_found);
+ return (1);
+}
+
+static int _you_gold(lua_State *ls)
{
-{ "hear_pos", you_can_hear_pos },
-{ "x_pos", you_x_pos },
-{ "y_pos", you_y_pos },
-{ "pos", you_pos },
-{ "moveto", you_moveto },
-{ "see_cell", you_see_cell },
-{ "see_cell_no_trans", you_see_cell_no_trans },
-{ "random_teleport", you_random_teleport },
-{ "losight", you_losight },
+ if (lua_gettop(ls) >= 1)
+ {
+ const int new_gold = luaL_checkint(ls, 1);
+ const int old_gold = you.gold;
+ you.gold = std::max(new_gold, 0);
+ if (new_gold > old_gold)
+ you.attribute[ATTR_GOLD_FOUND] += new_gold - old_gold;
+ else if (old_gold > new_gold)
+ you.attribute[ATTR_MISC_SPENDING] += old_gold - new_gold;
+ }
+ PLUARET(number, you.gold);
+}
+
+static const struct luaL_reg you_dlib[] =
+{
+{ "hear_pos", you_can_hear_pos },
+{ "x_pos", you_x_pos },
+{ "y_pos", you_y_pos },
+{ "pos", you_pos },
+{ "moveto", you_moveto },
+{ "see_cell", you_see_cell },
+{ "see_cell_no_trans", you_see_cell_no_trans },
+{ "random_teleport", you_random_teleport },
+{ "losight", you_losight },
+{ "gold", _you_gold },
+{ "uniques", _you_uniques },
+
{ NULL, NULL }
};
+
+void dluaopen_you(lua_State *ls)
+{
+ luaL_openlib(ls, "you", you_dlib, 0);
+}
diff --git a/crawl-ref/source/makefile.obj b/crawl-ref/source/makefile.obj
index 5ecacbcfc3..4bf1217c60 100644
--- a/crawl-ref/source/makefile.obj
+++ b/crawl-ref/source/makefile.obj
@@ -39,13 +39,19 @@ items.o \
lev-pand.o \
libutil.o \
l_crawl.o \
+l_debug.o \
l_dgn.o \
+l_dgnbld.o \
l_dgnevt.o \
+l_dgngrd.o \
l_dgnit.o \
+l_dgnlvl.o \
l_dgnmon.o \
+l_dgntil.o \
l_dgn_bf.o \
l_file.o \
l_los.o \
+l_mapgrd.o \
l_mapmrk.o \
l_you.o \
los.o \
diff --git a/crawl-ref/source/mon-data.h b/crawl-ref/source/mon-data.h
index 5ca1d0308b..73177f6ec0 100644
--- a/crawl-ref/source/mon-data.h
+++ b/crawl-ref/source/mon-data.h
@@ -4571,7 +4571,7 @@ static monsterentry mondata[] = {
},
{
- MONS_MAURICE, '@', DARKGREY, "Maurice",
+ MONS_MAURICE, '@', GREEN, "Maurice",
M_UNIQUE | M_SPELLCASTER | M_ACTUAL_SPELLS | M_WARM_BLOOD | M_SPEAKS,
MR_NO_FLAGS,
550, 20, MONS_HUMAN, MONS_HUMAN, MH_NATURAL, -4,
diff --git a/crawl-ref/source/rltiles/makefile.unix b/crawl-ref/source/rltiles/makefile.unix
index a310afc4ce..85ecf07f4d 100644
--- a/crawl-ref/source/rltiles/makefile.unix
+++ b/crawl-ref/source/rltiles/makefile.unix
@@ -1,23 +1,4 @@
-ifeq ($(OSNAME),MacOS)
-APPLE_GCC=y
-else
-APPLE_GCC=n
-endif
-
-ifneq ($(APPLE_GCC),n)
-
-SDL_CFLAGS := -I/Library/Frameworks/SDL.framework/Headers -I/Library/Frameworks/SDL_image.framework/Headers
-SDL_LDFLAGS := -framework SDL -framework SDL_image
-
-PNG_CFLAGS := -I/Library/Frameworks/libpng.framework/Headers
-PNG_LDFLAGS := -framework libpng
-
-CFLAGS := -F/Library/Frameworks $(SDL_CFLAGS) $(PNG_CFLAGS)
-LDFLAGS := -F/Library/Frameworks $(SDL_LDFLAGS) $(PNG_LDFLAGS)
-
-else
-
SDLCONFIG := $(shell which sdl-config 2> /dev/null)
ifeq ($(SDLCONFIG),)
SDLCONFIG := $(shell pwd)/../contrib/install/bin/sdl-config
@@ -32,8 +13,6 @@ PNG_LIB := $(shell pkg-config libpng --libs 2> /dev/null || echo "-lpng -lz")
CFLAGS := $(SDL_CFLAGS) $(PNG_INCLUDE)
LDFLAGS := $(SDL_LDFLAGS) -lSDL_image $(PNG_LIB)
-endif
-
# Attempt to use a full compiler name, to make
# distcc builds work nicely.
LMACH := $(shell gcc -dumpmachine)-
diff --git a/crawl-ref/source/rltiles/tilegen-Info.plist b/crawl-ref/source/rltiles/tilegen-Info.plist
new file mode 100644
index 0000000000..3ba93b5fd3
--- /dev/null
+++ b/crawl-ref/source/rltiles/tilegen-Info.plist
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>${MACOSX_DEPLOYMENT_TARGET}</string>
+ <key>NSMainNibFile</key>
+ <string>MainMenu</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+</dict>
+</plist>
diff --git a/crawl-ref/source/test/findray.lua b/crawl-ref/source/test/findray.lua
index 1b0248494b..9f66461d4e 100644
--- a/crawl-ref/source/test/findray.lua
+++ b/crawl-ref/source/test/findray.lua
@@ -36,7 +36,7 @@ local function test_findray()
local ray = los.findray(you_x, you_y, x, y)
if not ray then
dgn.grid(x, y, "floor_special")
- dgn.dbg_dump_map(FAILMAP)
+ debug.dump_map(FAILMAP)
assert(false, "Can't find ray to " .. p ..
" although it's in unobstructed view. (#" ..
checks .. ")")
@@ -52,7 +52,7 @@ local function test_findray()
while(ray_p ~= p) do
if dgn.is_opaque(rx, ry) then
dgn.grid(x, y, "floor_special")
- dgn.dbg_dump_map(FAILMAP)
+ debug.dump_map(FAILMAP)
assert(false,
"Ray from " .. you_p .. " to " .. p ..
" passes through opaque cell " .. ray_p
@@ -68,11 +68,11 @@ end
local function run_findray_tests(depth, nlevels, tests_per_level)
local place = "D:" .. depth
crawl.mpr("Running find_ray tests on " .. place)
- dgn.dbg_goto_place(place)
+ debug.goto_place(place)
for lev_i = 1, nlevels do
- dgn.dbg_flush_map_memory()
- dgn.dbg_generate_level()
+ debug.flush_map_memory()
+ debug.generate_level()
for t_i = 1, tests_per_level do
test_findray()
end
diff --git a/crawl-ref/source/test/los_csc.lua b/crawl-ref/source/test/los_csc.lua
index b54d251d8f..04a1ac2aeb 100644
--- a/crawl-ref/source/test/los_csc.lua
+++ b/crawl-ref/source/test/los_csc.lua
@@ -30,7 +30,7 @@ local function test_cellseecell_symmetry()
end
if (forward and backward) or (not forward and not backward) then
dgn.grid(other_p.x, other_p.y, "floor_special")
- dgn.dbg_dump_map(FAILMAP)
+ debug.dump_map(FAILMAP)
assert(false,
"cell_see_cell asymmetry detected (iter #" .. checks .. "): "
.. this_p .. " sees " .. other_p .. ", but not vice versa."
@@ -44,11 +44,11 @@ end
local function run_los_tests(depth, nlevels, tests_per_level)
local place = "D:" .. depth
crawl.mpr("Running LOS tests on " .. place)
- dgn.dbg_goto_place(place)
+ debug.goto_place(place)
for lev_i = 1, nlevels do
- dgn.dbg_flush_map_memory()
- dgn.dbg_generate_level()
+ debug.flush_map_memory()
+ debug.generate_level()
for t_i = 1, tests_per_level do
test_cellseecell_symmetry()
end
diff --git a/crawl-ref/source/test/los_symm.lua b/crawl-ref/source/test/los_symm.lua
index eac1db7577..400c4a2356 100644
--- a/crawl-ref/source/test/los_symm.lua
+++ b/crawl-ref/source/test/los_symm.lua
@@ -39,7 +39,7 @@ local function test_losight_symmetry()
local this_p = dgn.point(x, y)
local you_p = dgn.point(you_x, you_y)
dgn.grid(you_x, you_y, "floor_special")
- dgn.dbg_dump_map(FAILMAP)
+ debug.dump_map(FAILMAP)
assert(false,
"LOS asymmetry detected (iter #" .. checks .. "): " .. you_p ..
" sees " .. this_p .. ", but not vice versa." ..
@@ -51,11 +51,11 @@ end
local function run_los_tests(depth, nlevels, tests_per_level)
local place = "D:" .. depth
crawl.mpr("Running LOS tests on " .. place)
- dgn.dbg_goto_place(place)
+ debug.goto_place(place)
for lev_i = 1, nlevels do
- dgn.dbg_flush_map_memory()
- dgn.dbg_generate_level()
+ debug.flush_map_memory()
+ debug.generate_level()
for t_i = 1, tests_per_level do
test_losight_symmetry()
end