Merge branch 'develop' of https://github.com/DFHack/dfhack into develop

develop
Japa 2015-02-17 22:52:39 +05:30
commit f2461254d4
167 changed files with 6234 additions and 6118 deletions

@ -0,0 +1,6 @@
language: cpp
script:
- python travis/lint.py
- python travis/pr-check-base.py
notifications:
email: false

@ -160,6 +160,13 @@ Snow Leopard Changes
In <dfhack directory>/library/LuaTypes.cpp, change line 467 to
``int len = strlen((char*)ptr);``
Yoesmite Changes
================
If you have issues building after upgrading to Yosemite, try definining the folliwing environment variable:
export MACOSX_DEPLOYMENT_TARGET=10.9
=======
Windows
=======

@ -4,80 +4,93 @@ If you belong here and are missing, please add yourself and send me (peterix) a
The following is a list of people who have contributed to **DFHack**.
- Petr Mrázek <peterix@gmail.com>
- Alexander Gavrilov <angavrilov@gmail.com>
- doomchild <lee.crabtree@gmail.com>
- Quietust <quietust@gmail.com>
- jj <john-git@ofjj.net>
- Warmist <warmist@gmail.com>
- Robert Heinrich <robertheinrich73@googlemail.com>
- simon <simon@banquise.net>
- Kelly Martin <kelly.lynn.martin@gmail.com>
- mizipzor <mizipzor@gmail.com>
- Simon Jackson <sizeak@hotmail.com>
- belal <jimbelal@gmail.com>
- RusAnon <rusanon@dollchan.ru>
- Raoul XQ <raoulxq@gmail.com>
- Matthew Cline <zelgadis@sourceforge.net>
- Mike Stewart <thewonderidiot@gmail.com>
- Timothy Collett <tcollett+github@topazgryphon.org>
- RossM <Ross@Gnome>
- Tom Prince <tom.prince@ualberta.net>
- Jared Adams <jaxad0127@gmail.com>
- expwnent
- Erik Youngren <artanis.00@gmail.com>
- Espen Wiborg <espen.wiborg@telio.no>
- Tim Walberg <twalberg@comcast.net>
- Mikko Juola <mikko.juola@kolumbus.fi>
- rampaging-poet <yrudoingthis@hotmail.com>
- U-glouglou\\simon
- Clayton Hughes <clayton.hughes@gmail.com>
- zilpin <ziLpin@gmail.com>
- Will Rogers <wjrogers@gmail.com>
- NMLittle <nmlittle@gmail.com>
- root
- reverb
- Zhentar <Zhentar@gmail.com>
- Valentin Ochs <a@0au.de>
- Priit Laes <plaes@plaes.org>
- kmartin
- Neil Little
- rout <rout.mail+github@gmail.com>
- rofl0r <retnyg@gmx.net>
- harlanplayford <harlanplayford@gmail.com>
- gsvslto <gsvslto@gmail.com>
- sami
- potato
- playfordh <harlanplayford@gmail.com>
- feng1st <nf_xp@hotmail.com>
- comestible <nickolas.g.russell@gmail.com>
- Rumrusher <Anuleakage@yahoo.com>
- Rinin <RininS@Gmail.com>
- Raoul van Putten
- John Shade <gsvslto@gmail.com>
- John Beisley <greatred@gmail.com>
- Feng <nf_xp@hotmail.com>
- Donald Ruegsegger <druegsegger@gmail.com>
- Caldfir <caldfir@hotmail.com>
- Antalia <tamarakorr@gmail.com>
- Angus Mezick <amezick@gmail.com>
- PeridexisErrant <PeridexisErrant@gmail.com>
- Putnam
- Danaris
- Lethosor
- Eswald
- Ramblurr
- MithrilTuxedo
- AndreasPK
- cdombroski
======================= ==================== ===========================
Name Github Email
======================= ==================== ===========================
Petr Mrázek peterix peterix@gmail.com
Alexander Gavrilov angavrilov angavrilov@gmail.com
doomchild doomchild lee.crabtree@gmail.com
Quietust quietust quietust@gmail.com
jj jjyg john-git@ofjj.net
Warmist warmist warmist@gmail.com
Robert Heinrich rh73 robertheinrich73@googlemail.com
simon simon@banquise.net
Kelly Martin ab9rf kelly.lynn.martin@gmail.com
mizipzor mizipzor mizipzor@gmail.com
Simon Jackson sizeak sizeak@hotmail.com
belal jimhester jimbelal@gmail.com
RusAnon RusAnon rusanon@dollchan.ru
Raoul XQ raoulxq raoulxq@gmail.com
Matthew Cline zelgadis@sourceforge.net
Mike Stewart thewonderidiot thewonderidiot@gmail.com
Timothy Collett danaris tcollett+github@topazgryphon.org
RossM Ross@Gnome
Tom Prince tom.prince@ualberta.net
Jared Adams jaxad0127@gmail.com
expwnent expwnent
Erik Youngren Artanis artanis.00@gmail.com
Espen Wiborg espen.wiborg@telio.no
Tim Walberg twalberg twalberg@comcast.net
Mikko Juola Noeda mikko.juola@kolumbus.fi
rampaging-poet yrudoingthis@hotmail.com
U-glouglou\\simon simon@glouglou
Clayton Hughes clayton.hughes@gmail.com
zilpin zilpin ziLpin@gmail.com
Will Rogers wjrogers wjrogers@gmail.com
NMLittle nmlittle nmlittle@gmail.com
root
reverb
Zhentar Zhentar Zhentar@gmail.com
Valentin Ochs Cat-Ion a@0au.de
Priit Laes plaes plaes@plaes.org
kmartin
Neil Little
rout rout.mail+github@gmail.com
rofl0r rofl0r retnyg@gmx.net
harlanplayford playfordh harlanplayford@gmail.com
John Shade gsvslto gsvslto@gmail.com
sami
potato
feng1st nf_xp@hotmail.com
comestible nickrart nickolas.g.russell@gmail.com
Rumrusher rumrusher Anuleakage@yahoo.com
Rinin Rinin RininS@Gmail.com
Raoul van Putten
John Beisley huin greatred@gmail.com
Feng nf_xp@hotmail.com
Donald Ruegsegger hashaash druegsegger@gmail.com
Caldfir caldfir caldfir@hotmail.com
Antalia tamarakorr tamarakorr@gmail.com
Angus Mezick amezick amezick@gmail.com
Japa JapaMala japa.mala.illo@gmail.com
Putnam Putnam3145
Lethosor lethosor
PeridexisErrant PeridexisErrant PeridexisErrant@gmail.com
Eswald eswald
Ramblurr Ramblurr
MithrilTuxedo MithrilTuxedo
AndreasPK AndreasPK
Chris Dombroski cdombroski
Ben Lubar BenLubar
miffedmap miffedmap
scamtank scamtank
Mason11987 Mason11987
======================= ==================== ===========================
And those are the cool people who made **stonesense**.
And these are the cool people who made **Stonesense**.
- Kris Parker <kaypy>
- Japa <japa.mala.illo@gmail.com>
- Jonas Ask <jonask84@gmail.com>
- Petr Mrázek <peterix@gmail.com>
- Caldfir <aitken.tim@gmail.com>
- 8Z <git8z@ya.ru>
- Alexander Gavrilov <angavrilov@gmail.com>
- Timothy Collett <tcollett+github@topazgryphon.org>
======================= ==================== ===========================
Name Github Email
======================= ==================== ===========================
Kris Parker kaypy
Japa JapaMala japa.mala.illo@gmail.com
Jonas Ask jonask84@gmail.com
Petr Mrázek peterix peterix@gmail.com>
Caldfir caldfir aitken.tim@gmail.com
8Z 8Z git8z@ya.ru
Alexander Gavrilov angavrilov angavrilov@gmail.com
Timothy Collett danaris tcollett+github@topazgryphon.org
Lethosor lethosor
Eswald eswald
PeridexisErrant PeridexisErrant PeridexisErrant@gmail.com
======================= ==================== ===========================

@ -2,6 +2,7 @@ DFHack Future
Internals
Lua scripts will only be reloaded if necessary
Added support for onLoadMap/onUnloadMap.init scripts
Added df2console() wrapper, useful for printing DF (CP437-encoded) text to the console in a portable way
New internal commands:
hide/show: hide and show the console on Windows
sc-script: Allows additional scripts to be run when certain events occur (similar to onLoad*.init scripts)
@ -22,6 +23,8 @@ DFHack Future
tradereq-pet-gender: Displays pet genders on the trade request screen
Removed
Misc Improvements
exportlegends: 'info' and 'all' exports legends_plus xml with more data for legends utilities
remotefortressreader: Exposes more information
DFHack 0.40.24-r2
Internals
@ -71,7 +74,6 @@ DFHack 0.40.24-r2
Removed
Misc Improvements
Multiline commands are now possible inside dfhack.init scripts. See dfhack.init-example for example usage.
exportlegends: 'info' and 'all' exports legends_plus xml with more data for legends utilities
DFHack 0.40.24-r1
Internals

File diff suppressed because it is too large Load Diff

@ -1282,6 +1282,7 @@ static bool isMapLoaded() { return Core::getInstance().isMapLoaded(); }
static std::string df2utf(std::string s) { return DF2UTF(s); }
static std::string utf2df(std::string s) { return UTF2DF(s); }
static std::string df2console(std::string s) { return DF2CONSOLE(s); }
static const LuaWrapper::FunctionReg dfhack_module[] = {
WRAP(getOSType),
@ -1294,6 +1295,7 @@ static const LuaWrapper::FunctionReg dfhack_module[] = {
WRAPM(Translation, TranslateName),
WRAP(df2utf),
WRAP(utf2df),
WRAP(df2console),
{ NULL, NULL }
};

@ -347,3 +347,19 @@ std::string UTF2DF(const std::string &in)
out.resize(pos);
return out;
}
DFHACK_EXPORT std::string DF2CONSOLE(const std::string &in)
{
bool is_utf = false;
#ifdef LINUX_BUILD
std::string locale = "";
if (getenv("LANG"))
locale += getenv("LANG");
if (getenv("LC_CTYPE"))
locale += getenv("LC_CTYPE");
locale = toUpper(locale);
is_utf = (locale.find("UTF-8") != std::string::npos) ||
(locale.find("UTF8") != std::string::npos);
#endif
return is_utf ? DF2UTF(in) : in;
}

@ -348,3 +348,4 @@ DFHACK_EXPORT std::string stl_vsprintf(const char *fmt, va_list args);
// Conversion between CP437 and UTF-8
DFHACK_EXPORT std::string UTF2DF(const std::string &in);
DFHACK_EXPORT std::string DF2UTF(const std::string &in);
DFHACK_EXPORT std::string DF2CONSOLE(const std::string &in);

@ -98,6 +98,7 @@ namespace DFHack
function(function_), interactive(interactive_),
guard(NULL), usage(usage_)
{
fix_usage();
}
PluginCommand(const char * _name,
@ -109,6 +110,13 @@ namespace DFHack
function(function_), interactive(false),
guard(guard_), usage(usage_)
{
fix_usage();
}
void fix_usage()
{
if (usage.size() && usage[usage.size() - 1] != '\n')
usage.push_back('\n');
}
bool isHotkeyCommand() const { return guard != NULL; }

@ -1 +1 @@
Subproject commit e1151e8d6401c286f1d7df45abbd14562bedc7e9
Subproject commit 7ff793882032374e8f9819978aa7a29d5236798c

@ -1 +1 @@
Subproject commit a80abe848e4886a210e7a5123192e9221dc85810
Subproject commit 5b167d2ba89b877d80e0609feae8771aeaef356d

@ -1 +1 @@
Subproject commit 07750ad7f7ce7c2506e5198ffb80ca50a73e9c4e
Subproject commit 85dcde97197bdde1c1e97ccb536f2cc4cab6818f

@ -1 +1 @@
Subproject commit 8270ef2892b640a2e5753844a5e917ba96523fbb
Subproject commit 9e87d3e8dc2a3b897c92fe2ee8cd57249a262779

@ -77,8 +77,8 @@ function export_more_legends_xml()
io.write ("<?xml version=\"1.0\" encoding='UTF-8'?>".."\n")
io.write ("<df_world>".."\n")
io.write ("<name>"..dfhack.TranslateName(df.global.world.world_data.name).."</name>".."\n")
io.write ("<altname>"..dfhack.TranslateName(df.global.world.world_data.name,1).."</altname>".."\n")
io.write ("<name>"..dfhack.df2utf(dfhack.TranslateName(df.global.world.world_data.name)).."</name>".."\n")
io.write ("<altname>"..dfhack.df2utf(dfhack.TranslateName(df.global.world.world_data.name,1)).."</altname>".."\n")
io.write ("<regions>".."\n")
for regionK, regionV in ipairs(df.global.world.world_data.regions) do
@ -120,8 +120,8 @@ function export_more_legends_xml()
io.write ("\t\t\t\t".."<id>"..buildingV.id.."</id>".."\n")
io.write ("\t\t\t\t".."<type>"..df.abstract_building_type[buildingV:getType()]:lower().."</type>".."\n")
if (df.abstract_building_type[buildingV:getType()]:lower() ~= "underworld_spire") then
io.write ("\t\t\t\t".."<name>"..dfhack.TranslateName(buildingV.name, 1).."</name>".."\n")
io.write ("\t\t\t\t".."<name2>"..dfhack.TranslateName(buildingV.name).."</name2>".."\n")
io.write ("\t\t\t\t".."<name>"..dfhack.df2utf(dfhack.TranslateName(buildingV.name, 1)).."</name>".."\n")
io.write ("\t\t\t\t".."<name2>"..dfhack.df2utf(dfhack.TranslateName(buildingV.name)).."</name2>".."\n")
end
io.write ("\t\t\t".."</structure>".."\n")
end
@ -137,7 +137,7 @@ function export_more_legends_xml()
for wcK, wcV in ipairs(df.global.world.world_data.constructions.list) do
io.write ("\t".."<world_construction>".."\n")
io.write ("\t\t".."<id>"..wcV.id.."</id>".."\n")
io.write ("\t\t".."<name>"..dfhack.TranslateName(wcV.name,1).."</name>".."\n")
io.write ("\t\t".."<name>"..dfhack.df2utf(dfhack.TranslateName(wcV.name,1)).."</name>".."\n")
io.write ("\t\t".."<type>"..(df.world_construction_type[wcV:getType()]):lower().."</type>".."\n")
io.write ("\t\t".."<coords>")
for xK, xVal in ipairs(wcV.square_pos.x) do

@ -0,0 +1,122 @@
import re, os, sys
valid_extensions = ['c', 'cpp', 'h', 'hpp', 'mm', 'lua', 'rb', 'proto',
'init', 'init-example']
path_blacklist = [
'library/include/df/',
'plugins/stonesense/allegro',
'plugins/isoworld/allegro',
'plugins/isoworld/agui',
'depends/',
'.git/',
'build',
]
def valid_file(filename):
return len(filter(lambda ext: filename.endswith('.' + ext), valid_extensions)) and \
not len(filter(lambda path: path.replace('\\', '/') in filename.replace('\\', '/'), path_blacklist))
success = True
def error(msg):
global success
success = False
sys.stderr.write(msg + '\n')
class LinterError(Exception): pass
class Linter(object):
def check(self, lines):
failures = []
for i, line in enumerate(lines):
if not self.check_line(line):
failures.append(i + 1)
if len(failures):
raise LinterError('%s: %s' % (self.msg, self.display_lines(failures, len(lines))))
def fix(self, lines):
for i in range(len(lines)):
lines[i] = self.fix_line(lines[i])
def display_lines(self, lines, total):
if len(lines) == total - 1:
return 'entire file'
if not len(lines):
# should never happen
return 'nowhere'
if len(lines) == 1:
return 'line %i' % lines[0]
s = 'lines '
range_start = range_end = lines[0]
for i, line in enumerate(lines):
if line > range_end + 1:
if range_start == range_end:
s += ('%i, ' % range_end)
else:
s += ('%i-%i, ' % (range_start, range_end))
range_start = range_end = line
if i == len(lines) - 1:
s += ('%i' % line)
else:
range_end = line
if i == len(lines) - 1:
s += ('%i-%i, ' % (range_start, range_end))
return s.rstrip(' ').rstrip(',')
class NewlineLinter(Linter):
msg = 'Contains DOS-style newlines'
def check_line(self, line):
return '\r' not in line
def fix_line(self, line):
return line.replace('\r', '')
class TrailingWhitespaceLinter(Linter):
msg = 'Contains trailing whitespace'
def check_line(self, line):
line = line.replace('\r', '')
return not line.endswith(' ') and not line.endswith('\t')
def fix_line(self, line):
return line.rstrip('\t ')
class TabLinter(Linter):
msg = 'Contains tabs'
def check_line(self, line):
return '\t' not in line
def fix_line(self, line):
return line.replace('\t', ' ')
linters = [NewlineLinter(), TrailingWhitespaceLinter(), TabLinter()]
def main():
root_path = os.path.abspath(sys.argv[1] if len(sys.argv) > 1 else '.')
fix = (len(sys.argv) > 2 and sys.argv[2] == '--fix')
global path_blacklist
path_blacklist = map(lambda s: os.path.join(root_path, s), path_blacklist)
for cur, dirnames, filenames in os.walk(root_path):
for filename in filenames:
full_path = os.path.join(cur, filename)
rel_path = full_path.replace(root_path, '.')
if not valid_file(full_path):
continue
lines = []
with open(full_path, 'rb') as f:
lines = f.read().split('\n')
for linter in linters:
try:
linter.check(lines)
except LinterError as e:
error('%s: %s' % (rel_path, e))
if fix:
linter.fix(lines)
contents = '\n'.join(lines)
with open(full_path, 'wb') as f:
f.write(contents)
if success:
print('All linters completed successfully')
sys.exit(0)
else:
sys.exit(1)
if __name__ == '__main__':
main()

@ -0,0 +1,29 @@
import json, os, sys
if sys.version.startswith('2'):
from urllib2 import urlopen, HTTPError
else:
from urllib.request import urlopen
from urllib.error import HTTPError
try:
pr_id = int(os.environ.get('TRAVIS_PULL_REQUEST', 'false'))
except ValueError:
print('Not a pull request')
sys.exit(0)
print('Pull request %i' % pr_id)
res = {}
try:
res = json.loads(urlopen('https://api.github.com/repos/dfhack/dfhack/pulls/%i' % pr_id).read().decode('utf-8'))
except ValueError:
pass
except HTTPError:
print('Failed to retrieve PR information from API')
sys.exit(2)
if 'base' not in res or 'ref' not in res['base']:
print('Invalid JSON returned from API')
sys.exit(2)
if res['base']['ref'] != 'develop':
print('Not based on develop branch')
sys.exit(1)
else:
print('Ok')
sys.exit(0)