Merge branch 'lua53' of github.com:ennorehling/eressea into lua53

This commit is contained in:
Enno Rehling 2020-05-03 17:05:17 +02:00
commit c5dae48615
60 changed files with 135 additions and 125 deletions

View File

@ -48,7 +48,9 @@ endif()
find_package(EXPAT REQUIRED)
find_package (ToLua REQUIRED)
if (TOLUA_FOUND)
if (${TOLUA_VERSION_STRING} VERSION_EQUAL "5.2")
if (${TOLUA_VERSION_STRING} VERSION_EQUAL "5.3")
find_package (Lua 5.3 REQUIRED)
elseif (${TOLUA_VERSION_STRING} VERSION_EQUAL "5.2")
find_package (Lua 5.2 REQUIRED)
elseif (${TOLUA_VERSION_STRING} VERSION_EQUAL "5.3")
find_package ( Lua 5.3 REQUIRED)

View File

@ -78,17 +78,16 @@ DEST=$(dirname $ROOT)/server
LUA_VERSION="5.2"
LUA_INCLUDE=/usr/include
LUA_DIR=/usr
if [ -d /usr/include/lua5.1 ]; then
LUA_VERSION="5.1"
LUA_INCLUDE=/usr/include/lua5.1
elif [ -d /usr/include/lua5.3 ]; then
export LUA_DIR=/usr
if [ -d /usr/local/include/lua5.3 ]; then
LUA_VERSION="5.3"
LUA_INCLUDE=/usr/include/lua5.3
LUA_INCLUDE=/usr/local/include/lua5.3
elif [ -d /usr/include/lua5.2 ]; then
export LUA_DIR=/usr
LUA_VERSION="5.2"
LUA_INCLUDE=/usr/include/lua5.2
elif [ -d /usr/include/lua5.1 ]; then
LUA_VERSION="5.1"
LUA_INCLUDE=/usr/include/lua5.1
elif [ -d /usr/local/include/lua5.1 ]; then
export LUA_DIR=/usr/local
LUA_VERSION="5.1"

View File

@ -2,7 +2,10 @@
-- Tests are under scripts/test/e2 and all files must be in scripts/test/e2/init.lua
lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
module = lunit.module
end
path = 'scripts'
if config.install then
path = config.install .. '/' .. path
@ -11,7 +14,6 @@ package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
config.rules = 'e2'
lunit = require 'lunit'
require 'eressea'
require 'eressea.xmlconf'
require 'eressea.path'

View File

@ -2,7 +2,9 @@
-- Tests are under scripts/test/e3 and all files must be in scripts/test/e3/init.lua
lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
module = lunit.module
end
path = 'scripts'
if config.install then
@ -12,7 +14,6 @@ package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
config.rules = 'e3'
lunit = require 'lunit'
require 'eressea'
require 'eressea.path'
require 'eressea.xmlconf'

View File

@ -1,18 +1,19 @@
-- Basic test without loading XML Config. Test care about needed settings.
-- Tests are under scripts/test/ and all files must be in scripts/test/init.lua
lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
module = lunit.module
end
path = 'scripts'
if config.install then
path = config.install .. '/' .. path
end
package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
lunit = require 'lunit'
require 'eressea'
require 'eressea.path'
lunit = require('lunit')
module = lunit.module
require 'tests'
result = lunit.main()
return result.errors + result.failed

View File

@ -1,9 +1,9 @@
local tcname = 'tests.bindings'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
local _G = _G

View File

@ -1,9 +1,9 @@
local tcname = 'tests.shared.common'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
local function _test_create_ship(r)

View File

@ -1,9 +1,9 @@
local tcname = 'tests.shared.config'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.adamantium'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.allies'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.astral'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.buildings'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.carts'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.destroy'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.features'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.guard'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.insects'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.items'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.movement'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.production'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.quit'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function test_quit_faction()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.shiplanding'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.ships'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.spells'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.stealth'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
local f

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.trees'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.trolls'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e2.undead'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e3.buildings'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e3.items'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e3.morale'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e3.parser'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e3.production'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e3.rules'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
local settings

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e3.e2spells'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
local r, f, u

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e3.spells'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.e3.stealth'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
local f

View File

@ -1,9 +1,9 @@
local tcname = 'tests.shared.economy'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,8 +1,9 @@
local lunit = require("lunit")
local tcname = 'tests.faction'
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module("tests.faction", 'seeall')
_ENV = module(tcname, 'seeall')
else
module("tests.faction", 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
local f

View File

@ -1,9 +1,9 @@
local tcname = 'tests.hunger'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -3,7 +3,7 @@ local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,8 +1,9 @@
local lunit = require("lunit")
local tcname = 'tests.laws'
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module("tests.laws", 'seeall')
_ENV = module(tcname, 'seeall')
else
module("tests.laws", 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,8 +1,9 @@
local lunit = require("lunit")
local tcname = 'tests.locale'
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module("tests.locale", 'seeall')
_ENV = module(tcname, 'seeall')
else
module("tests.locale", 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.shared.magicbag'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
local u

View File

@ -1,8 +1,9 @@
local tcname = 'tests.movement'
local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module("tests.movement", 'seeall')
_ENV = module(tcname , 'seeall')
else
module("tests.movement", 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -3,7 +3,7 @@ local lunit = require("lunit")
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname , 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
local _G = _G

View File

@ -1,9 +1,9 @@
local tcname = 'tests.shared.parser'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,8 +1,9 @@
local lunit = require("lunit")
local tcname = 'tests.pool'
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module("tests.pool", 'seeall')
_ENV = module(tcname, 'seeall')
else
module("tests.pool", 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.shared.process'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
local u, r, f

View File

@ -1,9 +1,9 @@
local tcname = 'tests.shared.production'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.shared.recruit'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.regions'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.shared.report'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.settings'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.shared.spells'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.shared.storage'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.study'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.shared.undead'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -1,9 +1,9 @@
local tcname = 'tests.shared.xmas'
local lunit = require("lunit")
local lunit = require('lunit')
if _VERSION >= 'Lua 5.2' then
_ENV = module(tcname, 'seeall')
else
module(tcname, 'seeall')
module(tcname, lunit.testcase, package.seeall)
end
function setup()

View File

@ -684,7 +684,7 @@ growing_trees(region * r, const season_t current_season, const season_t last_wee
a->data.sa[0] = (short)cap_int(rtrees(r, 0), 0, SHRT_MAX);
a->data.sa[1] = (short)cap_int(rtrees(r, 1), 0, SHRT_MAX);
}
else if (a->data.sa[0] < 0 || a->data.sa[1] << 0) {
else if (a->data.sa[0] < 0 || a->data.sa[1] < 0) {
a->data.sa[0] = (short)cap_int(a->data.sa[0], 0, SHRT_MAX);
a->data.sa[1] = (short)cap_int(a->data.sa[1], 0, SHRT_MAX);
}