Merge branch 'hotfix-3-6-2'

Conflicts:
	.travis.yml
This commit is contained in:
Enno Rehling 2015-09-06 09:57:15 +02:00
commit fd3ff16723
237 changed files with 5999 additions and 5421 deletions

4
.gitignore vendored
View file

@ -1,3 +1,4 @@
*.orig
eressea.ini
Debug
Release
@ -37,3 +38,6 @@ game-e3/reports/
tags
Thumbs.db
.gdb_history
*.cfg
*.cmd
tmp/

9
.gitmodules vendored
View file

@ -19,13 +19,16 @@
[submodule "cutest"]
path = cutest
url = git://github.com/ennorehling/cutest.git
[submodule "cJSON"]
path = cJSON
url = git://github.com/ennorehling/cJSON.git
[submodule "iniparser"]
path = iniparser
url = git://github.com/ennorehling/iniparser.git
[submodule "cJSON"]
path = cJSON
url = git://github.com/ennorehling/cJSON.git
[submodule "storage"]
path = storage
url = git://github.com/ennorehling/storage.git
branch = master
[submodule "tolua"]
path = tolua
url = git://github.com/ennorehling/tolua.git

View file

@ -1,11 +1,17 @@
sudo: false
language: c
compiler:
- gcc
- clang
script: s/travis-build
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq libtolua-dev liblua5.1-dev libncurses5-dev libsqlite3-dev libxml2-dev
addons:
apt:
packages:
- liblua5.2-dev
- libncurses5-dev
- libsqlite3-dev
- libxml2-dev
- valgrind
os:
- linux
notifications:

View file

@ -8,6 +8,11 @@ project (eressea-server C)
enable_testing()
find_package (LibXml2)
find_package (SQLite3)
find_package (Curses)
find_package (Lua REQUIRED)
find_package (ToLua REQUIRED)
INCLUDE (CheckIncludeFiles)
INCLUDE (CheckSymbolExists)
@ -57,13 +62,6 @@ CONFIGURE_FILE (
INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/include)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_AUTOCONF")
find_package (LibXml2)
find_package (SQLite3)
find_package (Curses)
find_package (Lua REQUIRED)
find_package (ToLua REQUIRED)
add_subdirectory (cutest)
add_subdirectory (crypto)
add_subdirectory (cJSON)
@ -75,4 +73,4 @@ add_subdirectory (src eressea)
install(DIRECTORY res conf DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.xml")
install(DIRECTORY res conf DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.json")
install(DIRECTORY scripts DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.lua")
install(DIRECTORY share DESTINATION ${CMAKE_INSTALL_PREFIX})

View file

@ -1,5 +1,9 @@
all:
@echo "Please use the cmake build system by running configure"
s/build
test:
s/runtests
clean:
@rm -f *.log.*
@find . -name "*~" | xargs rm -f

View file

@ -1,6 +1,6 @@
# What is this?
This repository contains an the source code for the Play-by-Mail strategy game [Eressea](http://www.eressea.de/).
This repository contains the source code for the Play-by-Mail strategy game [Eressea](http://www.eressea.de/).
# Prerequisites

View file

@ -5,12 +5,12 @@
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteURI
uriStartString="config:///core/"
uriStartString="config://core/"
rewritePrefix="../../res/core/" />
<rewriteURI
uriStartString="config:///game/"
uriStartString="config://game/"
rewritePrefix="../../res/eressea/" />
<rewriteURI
uriStartString="config:///default/"
uriStartString="config://default/"
rewritePrefix="../../res/" />
</catalog>

View file

@ -1,56 +1,60 @@
<?xml version="1.0"?>
<eressea xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="config:///core/messages.xml"/>
<xi:include href="config://core/messages.xml"/>
<!-- Localization -->
<xi:include href="config:///core/de/strings.xml"/>
<xi:include href="config:///core/en/strings.xml"/>
<xi:include href="config:///game/spellinfo.xml" />
<xi:include href="config://core/de/strings.xml"/>
<xi:include href="config://core/en/strings.xml"/>
<xi:include href="config://game/spellinfo.xml" />
<xi:include href="config:///core/common/items.xml" />
<xi:include href="config:///core/common/armor.xml" />
<xi:include href="config:///core/common/weapons.xml" />
<xi:include href="config:///core/common/resources.xml" />
<xi:include href="config:///core/common/luxuries.xml" />
<xi:include href="config:///core/common/herbs.xml" />
<xi:include href="config:///core/common/potions.xml" />
<xi:include href="config:///core/spoils.xml"/>
<xi:include href="config:///game/races.xml"/>
<xi:include href="config:///core/prefixes.xml"/>
<xi:include href="config:///core/ships.xml"/>
<xi:include href="config:///core/common/buildings.xml"/>
<xi:include href="config:///game/familiars.xml"/>
<xi:include href="config:///core/terrains.xml"/>
<xi:include href="config:///game/terrains.xml"/>
<xi:include href="config:///game/artrewards.xml"/>
<xi:include href="config:///game/buildings.xml"/>
<xi:include href="config:///core/calendar.xml"/>
<xi:include href="config://core/common/items.xml" />
<xi:include href="config://core/common/armor.xml" />
<xi:include href="config://core/common/weapons.xml" />
<xi:include href="config://core/common/resources.xml" />
<xi:include href="config://core/common/luxuries.xml" />
<xi:include href="config://core/common/herbs.xml" />
<xi:include href="config://core/common/potions.xml" />
<xi:include href="config://core/spoils.xml"/>
<xi:include href="config://game/races.xml"/>
<xi:include href="config://core/prefixes.xml"/>
<xi:include href="config://core/ships.xml"/>
<xi:include href="config://core/common/buildings.xml"/>
<xi:include href="config://game/familiars.xml"/>
<xi:include href="config://core/terrains.xml"/>
<xi:include href="config://game/terrains.xml"/>
<xi:include href="config://game/artrewards.xml"/>
<xi:include href="config://game/buildings.xml"/>
<xi:include href="config://core/calendar.xml"/>
<calendar name="secondage" newyear="month_1" start="184"/>
<xi:include href="config:///game/equipment.xml"/>
<xi:include href="config:///game/items.xml"/>
<xi:include href="config:///game/spells.xml"/>
<xi:include href="config:///game/strings.xml"/>
<xi:include href="config:///default/adamantium.xml"/>
<xi:include href="config://game/equipment.xml"/>
<xi:include href="config://game/items.xml"/>
<xi:include href="config://game/spells.xml"/>
<xi:include href="config://game/strings.xml"/>
<xi:include href="config://default/adamantium.xml"/>
<equipment>
<set name="first_unit">
<item name="log" amount="50"/>
<item name="stone" amount="50"/>
<item name="iron" amount="50"/>
<item name="laen" amount="10"/>
<item name="sword" amount="1"/>
<item name="mallorn" amount="10"/>
<item name="skillpotion" amount="5"/>
<item name="p2" amount="5"/>
<item name="money" amount="20000"/>
<skill name="perception" level="30"/>
<skill name="melee" level="1"/>
</set>
<set name="new_faction">
<item name="adamantium" amount="1"/>
</set>
</equipment>
<xi:include href="config:///default/names-undead.xml"/>
<xi:include href="config:///default/names-skeletons.xml"/>
<xi:include href="config:///default/names-zombies.xml"/>
<xi:include href="config:///default/names-ghouls.xml"/>
<xi:include href="config:///default/names-dragons.xml"/>
<xi:include href="config://default/names-undead.xml"/>
<xi:include href="config://default/names-skeletons.xml"/>
<xi:include href="config://default/names-zombies.xml"/>
<xi:include href="config://default/names-ghouls.xml"/>
<xi:include href="config://default/names-dragons.xml"/>
<game name="Eressea">
<!-- Game specific settings -->
@ -96,6 +100,7 @@
<param name="GiveRestriction" value="3"/>
<param name="hunger.long" value="1"/>
<param name="init_spells" value="0"/>
<param name="rules.ship.damage_drift" value="0.00"/> <!-- percent damage from drifting-->
<param name="rules.reserve.twophase" value="1"/>
<param name="rules.give.max_men" value="-1"/>
<param name="rules.check_overload" value="0"/>
@ -110,6 +115,7 @@
<param name="rules.economy.repopulate_maximum" value="500"/>
<param name="game.id" value="2"/>
<param name="game.name" value="Eressea"/>
<param name="world.era" value="2"/>
</game>
<strings>
<string name="mailto">

View file

@ -5,12 +5,12 @@
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteURI
uriStartString="config:///core/"
uriStartString="config://core/"
rewritePrefix="../../res/core/" />
<rewriteURI
uriStartString="config:///game/"
uriStartString="config://game/"
rewritePrefix="../../res/e3a/" />
<rewriteURI
uriStartString="config:///default/"
uriStartString="config://default/"
rewritePrefix="../../res/" />
</catalog>

View file

@ -1,32 +1,32 @@
<?xml version="1.0"?>
<eressea xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="config:///core/messages.xml"/>
<xi:include href="config:///core/de/strings.xml"/>
<xi:include href="config:///core/en/strings.xml"/>
<xi:include href="config:///core/common/items.xml"/>
<xi:include href="config:///core/common/herbs.xml" />
<xi:include href="config:///core/spoils.xml"/>
<xi:include href="config:///core/prefixes.xml"/>
<xi:include href="config:///core/common/buildings.xml"/>
<xi:include href="config:///game/familiars.xml"/>
<xi:include href="config://core/messages.xml"/>
<xi:include href="config://core/de/strings.xml"/>
<xi:include href="config://core/en/strings.xml"/>
<xi:include href="config://core/common/items.xml"/>
<xi:include href="config://core/common/herbs.xml" />
<xi:include href="config://core/spoils.xml"/>
<xi:include href="config://core/prefixes.xml"/>
<xi:include href="config://core/common/buildings.xml"/>
<xi:include href="config://game/familiars.xml"/>
<xi:include href="config:///default/adamantium.xml" />
<xi:include href="config://default/adamantium.xml" />
<xi:include href="config:///game/ships.xml"/>
<xi:include href="config:///game/shipnames.xml"/>
<xi:include href="config:///game/terrains.xml"/>
<xi:include href="config:///core/calendar.xml"/>
<xi:include href="config:///game/items.xml" />
<xi:include href="config:///game/strings.xml"/>
<xi:include href="config:///game/messages.xml"/>
<xi:include href="config:///game/races.xml"/>
<xi:include href="config:///game/buildings.xml"/>
<xi:include href="config:///game/equipment.xml"/>
<xi:include href="config:///game/spells.xml"/>
<xi:include href="config:///game/luxuries.xml" />
<xi:include href="config:///game/weapons.xml" />
<xi:include href="config:///game/armor.xml" />
<xi:include href="config:///game/resources.xml" />
<xi:include href="config://game/ships.xml"/>
<xi:include href="config://game/shipnames.xml"/>
<xi:include href="config://game/terrains.xml"/>
<xi:include href="config://core/calendar.xml"/>
<xi:include href="config://game/items.xml" />
<xi:include href="config://game/strings.xml"/>
<xi:include href="config://game/messages.xml"/>
<xi:include href="config://game/races.xml"/>
<xi:include href="config://game/buildings.xml"/>
<xi:include href="config://game/equipment.xml"/>
<xi:include href="config://game/spells.xml"/>
<xi:include href="config://game/luxuries.xml" />
<xi:include href="config://game/weapons.xml" />
<xi:include href="config://game/armor.xml" />
<xi:include href="config://game/resources.xml" />
<calendar name="thirdage" newyear="month_1" start="1"/>
@ -38,11 +38,11 @@
</set>
</equipment>
<xi:include href="config:///default/names-undead.xml"/>
<xi:include href="config:///default/names-skeletons.xml"/>
<xi:include href="config:///default/names-zombies.xml"/>
<xi:include href="config:///default/names-ghouls.xml"/>
<xi:include href="config:///default/names-dragons.xml"/>
<xi:include href="config://default/names-undead.xml"/>
<xi:include href="config://default/names-skeletons.xml"/>
<xi:include href="config://default/names-zombies.xml"/>
<xi:include href="config://default/names-ghouls.xml"/>
<xi:include href="config://default/names-dragons.xml"/>
<game name="E3">
<!-- Game specific settings -->
@ -115,8 +115,11 @@
<param name="study.expensivemigrants" value="1"/>
<param name="study.speedup" value="2"/>
<param name="world.era" value="3"/>
<param name="seed.population.min" value="8"/>
<param name="seed.population.max" value="8"/>
<param name="rules.migrants" value="0"/>
<param name="rules.reserve.twophase" value="1"/>
<param name="rules.owners.force_leave" value="0"/>
<param name="rules.monsters.attack_chance" value="0.0"/>
<param name="rules.transfermen" value="0"/>
<param name="rules.stealth.faction" value="1"/>

View file

@ -5,12 +5,12 @@
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteURI
uriStartString="config:///core/"
uriStartString="config://core/"
rewritePrefix="../../res/core/" />
<rewriteURI
uriStartString="config:///game/"
uriStartString="config://game/"
rewritePrefix="../../res/e3a/" />
<rewriteURI
uriStartString="config:///default/"
uriStartString="config://default/"
rewritePrefix="../../res/" />
</catalog>

View file

@ -1,32 +1,32 @@
<?xml version="1.0"?>
<eressea xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="config:///core/messages.xml"/>
<xi:include href="config:///core/de/strings.xml"/>
<xi:include href="config:///core/en/strings.xml"/>
<xi:include href="config:///core/common/items.xml"/>
<xi:include href="config:///core/common/herbs.xml" />
<xi:include href="config:///core/spoils.xml"/>
<xi:include href="config:///core/prefixes.xml"/>
<xi:include href="config:///core/common/buildings.xml"/>
<xi:include href="config:///game/familiars.xml"/>
<xi:include href="config://core/messages.xml"/>
<xi:include href="config://core/de/strings.xml"/>
<xi:include href="config://core/en/strings.xml"/>
<xi:include href="config://core/common/items.xml"/>
<xi:include href="config://core/common/herbs.xml" />
<xi:include href="config://core/spoils.xml"/>
<xi:include href="config://core/prefixes.xml"/>
<xi:include href="config://core/common/buildings.xml"/>
<xi:include href="config://game/familiars.xml"/>
<xi:include href="config:///default/adamantium.xml" />
<xi:include href="config://default/adamantium.xml" />
<xi:include href="config:///game/ships.xml"/>
<xi:include href="config:///game/shipnames.xml"/>
<xi:include href="config:///game/terrains.xml"/>
<xi:include href="config:///core/calendar.xml"/>
<xi:include href="config:///game/items.xml" />
<xi:include href="config:///game/strings.xml"/>
<xi:include href="config:///game/messages.xml"/>
<xi:include href="config:///game/races.xml"/>
<xi:include href="config:///game/buildings.xml"/>
<xi:include href="config:///game/equipment.xml"/>
<xi:include href="config:///game/spells.xml"/>
<xi:include href="config:///game/luxuries.xml" />
<xi:include href="config:///game/weapons.xml" />
<xi:include href="config:///game/armor.xml" />
<xi:include href="config:///game/resources.xml" />
<xi:include href="config://game/ships.xml"/>
<xi:include href="config://game/shipnames.xml"/>
<xi:include href="config://game/terrains.xml"/>
<xi:include href="config://core/calendar.xml"/>
<xi:include href="config://game/items.xml" />
<xi:include href="config://game/strings.xml"/>
<xi:include href="config://game/messages.xml"/>
<xi:include href="config://game/races.xml"/>
<xi:include href="config://game/buildings.xml"/>
<xi:include href="config://game/equipment.xml"/>
<xi:include href="config://game/spells.xml"/>
<xi:include href="config://game/luxuries.xml" />
<xi:include href="config://game/weapons.xml" />
<xi:include href="config://game/armor.xml" />
<xi:include href="config://game/resources.xml" />
<calendar name="thirdage" newyear="month_1" start="1"/>
@ -38,11 +38,11 @@
</set>
</equipment>
<xi:include href="config:///default/names-undead.xml"/>
<xi:include href="config:///default/names-skeletons.xml"/>
<xi:include href="config:///default/names-zombies.xml"/>
<xi:include href="config:///default/names-ghouls.xml"/>
<xi:include href="config:///default/names-dragons.xml"/>
<xi:include href="config://default/names-undead.xml"/>
<xi:include href="config://default/names-skeletons.xml"/>
<xi:include href="config://default/names-zombies.xml"/>
<xi:include href="config://default/names-ghouls.xml"/>
<xi:include href="config://default/names-dragons.xml"/>
<game name="Deveron">
<!-- Game specific settings -->
@ -57,7 +57,6 @@
<order name="tax" disable="yes"/>
<order name="entertain" disable="yes"/>
<order name="sell" disable="yes"/>
<order name="origin" disable="yes"/>
<skill name="armorer" enable="true"/>
<skill name="bow" enable="true"/>
@ -118,6 +117,7 @@
<param name="world.era" value="3"/>
<param name="rules.migrants" value="0"/>
<param name="rules.reserve.twophase" value="1"/>
<param name="rules.owners.force_leave" value="0"/>
<param name="rules.transfermen" value="0"/>
<param name="rules.stealth.faction" value="1"/>
<param name="rules.stealth.anon_battle" value="0"/>

View file

@ -2,12 +2,12 @@
<resources xmlns:xi="http://www.w3.org/2001/XInclude">
<!-- this file contains a lot of armor -->
<xi:include href="eressea:///core/armor/plate.xml"/>
<xi:include href="eressea:///core/armor/chainmail.xml"/>
<xi:include href="eressea:///core/armor/laenmail.xml"/>
<xi:include href="eressea:///core/armor/laenshield.xml"/>
<xi:include href="eressea:///core/armor/rustychainmail.xml"/>
<xi:include href="eressea:///core/armor/rustyshield.xml"/>
<xi:include href="eressea:///core/armor/shield.xml"/>
<xi:include href="eressea://core/armor/plate.xml"/>
<xi:include href="eressea://core/armor/chainmail.xml"/>
<xi:include href="eressea://core/armor/laenmail.xml"/>
<xi:include href="eressea://core/armor/laenshield.xml"/>
<xi:include href="eressea://core/armor/rustychainmail.xml"/>
<xi:include href="eressea://core/armor/rustyshield.xml"/>
<xi:include href="eressea://core/armor/shield.xml"/>
</resources>

View file

@ -275,11 +275,6 @@
</string>
</namespace>
<string name="Tresen">
<text locale="de">Tresen</text>
<text locale="en">counter</text>
</string>
<string name="wenige">
<text locale="de">wenige</text>
<text locale="en">few</text>
@ -2217,12 +2212,6 @@
<text locale="de">Schaden</text>
</string>
<!--report newbie info -->
<string name="nr_nmr">
<text locale="de">Deine Partei hat letzte Runde keinen Zug
abgegeben!</text>
</string>
<namespace name="race">
<string name="snowman">
<text locale="de">Schneemann</text>
@ -3933,7 +3922,7 @@
<text locale="de">Gesang des Lebens analysieren</text>
<text locale="en">Analyze Song of Life</text>
</string>
<string name="cerrdorfumbleshield">
<string name="cerddorfumbleshield">
<text locale="de">Bannlied</text>
<text locale="en">Countersong</text>
</string>
@ -4335,7 +4324,7 @@
<text locale="de">Kraft der Natur</text>
<text locale="en">force of nature</text>
</string>
<string name="wdwpyramid_cerrdor">
<string name="wdwpyramid_cerddor">
<text locale="de">Gesang der Götter</text>
<text locale="en">Song of the Gods</text>
</string>
@ -5137,7 +5126,7 @@
able to decipher all enchantments or spells, which
aren't disguised beyond your capability.</text>
</string>
<string name="cerrdorfumbleshield">
<string name="cerddorfumbleshield">
<text locale="de">Dieser schrille Gesang hallt über das
ganze Schlachtfeld. Die besonderen Dissonanzen in den
Melodien machen es Magiern fast unmöglich, sich auf ihre
@ -5865,11 +5854,10 @@
das 50fache und auch im Kampf werden sich die
erhöhte Kraft und die trollisch zähe Haut
positiv auswirken.</text>
<text locale="en">This artifact gives the one wearing it
<text locale="en">This artifact gives the wearer
the strength of a cavetroll. He will be able to
carry fifty times as much as normal and also in
combat his enhanced strength and tough troll
skin will serve him well.</text>
carry fifty times his normal load, as well as
gain strength and tough troll skin in combat.</text>
</string>
<string name="auraleak">
<text locale="de">Der Schwarzmagier kann mit diesem
@ -5879,7 +5867,7 @@
Region werden einen Großteil ihrer Aura
verlieren.</text>
<text locale="en">With this dark ritual the
chaossorcerer causes a deep rift to appear in
chaos sorcerer causes a deep rift to appear in
the astral balance that will tear all magical
power from a region. All spellcasters in that
region will lose most of their aura.</text>
@ -6959,14 +6947,9 @@
<text locale="en">is helping</text>
</string>
<string name="has_moved_one">
<text locale="de">hat die Region durchquert.</text>
<text locale="en">passed through the region.</text>
</string>
<string name="has_moved_many">
<text locale="de">haben die Region durchquert.</text>
<text locale="en">passed through the region.</text>
<string name="travelthru_header">
<text locale="de">Die Region wurde durchquert von </text>
<text locale="en">The region was crossed by </text>
</string>
<string name="see_travel">

View file

@ -1660,10 +1660,6 @@
</string>
</namespace>
<string name="nr_nmr">
<text locale="en">No orders were received for your faction!</text>
</string>
<!-- resources -->
<string name="mistletoe">
<text locale="de">Mistelzweig</text>

View file

@ -2051,7 +2051,4 @@
<text locale="fr">côte ouest</text>
</string>
</namespace>
<string name="nr_nmr">
<text locale="fr">Aucun ordre reçu pour votre faction !</text>
</string>
</strings>

View file

@ -390,8 +390,17 @@
<text locale="de">"Die Ausrüstung von $unit($unit) scheint unsichtbar. ($int36($id))"</text>
<text locale="en">"$unit($unit)'s equipment is invisible. ($int36($id))"</text>
</message>
<message name="curseinfo::magicresistance" section="events">
<message name="curseinfo::magicresistance_unit" section="events">
<type>
<arg name="unit" type="unit"/>
<arg name="id" type="int"/>
</type>
<text locale="de">"Die natürliche Widerstandskraft gegen Verzauberung ist gestärkt. ($int36($id))"</text>
<text locale="en">"The magical resistance has been strengthened. ($int36($id))"</text>
</message>
<message name="curseinfo::magicresistance_building" section="events">
<type>
<arg name="building" type="building"/>
<arg name="id" type="int"/>
</type>
<text locale="de">"Die natürliche Widerstandskraft gegen Verzauberung ist gestärkt. ($int36($id))"</text>
@ -413,6 +422,7 @@
</message>
<message name="curseinfo::magicwalls" section="events">
<type>
<arg name="building" type="building"/>
<arg name="id" type="int"/>
</type>
<text locale="de">"Diese Mauern wirken, als wären sie direkt aus der Erde gewachsen und nicht erbaut. ($int36($id))"</text>
@ -420,6 +430,7 @@
</message>
<message name="curseinfo::buildingunknown" section="events">
<type>
<arg name="building" type="building"/>
<arg name="id" type="int"/>
</type>
<text locale="de">"Ein magischer Schimmer liegt auf diesen Mauern. ($int36($id))"</text>
@ -540,6 +551,7 @@
<message name="curseinfo::nocostbuilding" section="events">
<type>
<arg name="id" type="int"/>
<arg name="building" type="building"/>
</type>
<text locale="de">"Der Zahn der Zeit kann diesen Mauern nichts anhaben. ($int36($id))"</text>
<text locale="en">"Time cannot touch these walls. ($int36($id))"</text>
@ -902,7 +914,7 @@
<arg name="transparent" type="int"/>
<arg name="object" type="string"/>
</type>
<text locale="de">"$if($transparent," befindet sich"," versperrt") ${object} $if($transparent,""," die Sicht")."</text>
<text locale="de">"$if($transparent," befindet sich"," versperrt") ${object}$if($transparent,""," die Sicht")."</text>
<text locale="en">"$if($transparent," there is"," sight is blocked by ") ${object}."</text>
</message>
<message name="nr_building_besieged" section="nr">
@ -1182,7 +1194,25 @@
<text locale="en">"$unit($unit) drowns in $region($region)."</text>
</message>
<message name="drown_amphibian_dead" section="events">
<message name="poison_damage" section="events">
<type>
<arg name="unit" type="unit"/>
<arg name="region" type="region"/>
</type>
<text locale="de">"$unit($unit) nimmt Schaden durch den Giftelementar in $region($region)."</text>
<text locale="en">"$unit($unit) is taking poison damage in $region($region)."</text>
</message>
<message name="poison_death" section="events">
<type>
<arg name="unit" type="unit"/>
<arg name="region" type="region"/>
</type>
<text locale="de">"$unit($unit) stirbt am Schaden durch den Giftelementar in $region($region)."</text>
<text locale="en">"$unit($unit) dies from poison damage taken in $region($region)."</text>
</message>
<message name="drown_amphibian_dead" section="events">
<type>
<arg name="amount" type="int"/>
<arg name="unit" type="unit"/>
@ -2800,17 +2830,6 @@
<text locale="de">"$unit($unit) in $region($region) produziert $int($amount)$if($eq($wanted,$amount),""," von $int($wanted)") $resource($resource,$wanted)."</text>
<text locale="en">"$unit($unit) in $region($region) produces $int($amount)$if($eq($wanted,$amount),""," of $int($wanted)") $resource($resource,$amount)."</text>
</message>
<message name="manufacture" section="production">
<type>
<arg name="unit" type="unit"/>
<arg name="region" type="region"/>
<arg name="amount" type="int"/>
<arg name="wanted" type="int"/>
<arg name="resource" type="resource"/>
</type>
<text locale="de">"$unit($unit) in $region($region) produziert $int($amount)$if($eq($wanted,$amount),""," von $int($wanted)") $resource($resource,$wanted)."</text>
<text locale="en">"$unit($unit) in $region($region) produces $int($amount)$if($eq($wanted,$amount),""," of $int($wanted)") $resource($resource,$amount)."</text>
</message>
<message name="buildbuilding" section="production">
<type>
<arg name="unit" type="unit"/>
@ -7100,9 +7119,16 @@
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - Your faction must be at least $int($turns) weeks old to give something to another faction."</text>
</message>
<message name="turnreminder" section="errors">
<type>
</type>
<message name="nmr_warning" section="errors">
<type/>
<text locale="de">Deine Partei hat letzte Runde keinen Zug
abgegeben!</text>
<text locale="en">No orders were received for your faction!</text>
<text locale="fr">Aucun ordre reçu pour votre faction !</text>
</message>
<message name="nmr_warning_final" section="errors">
<type/>
<text locale="de">"Bitte sende die Befehle nächste Runde ein, wenn du weiterspielen möchtest."</text>
<text locale="en">"Please send in orders for the next turn if you want to continue playing."</text>
</message>

View file

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<resource name="cart" big="true">
<item capacity="14000" weight="4000" score="60" vehicle="yes">
<resource name="cart">
<item capacity="14000" weight="4000" score="60" vehicle="yes" big="yes">
<construction skill="cartmaking" minskill="1" reqsize="1">
<requirement type="log" quantity="5"/>
</construction>

View file

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<resource name="catapult">
<item weight="10000">
<item weight="10000" big="yes">
<construction skill="cartmaking" minskill="5" reqsize="1">
<requirement type="log" quantity="10"/>
</construction>

View file

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<buildings xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="config:///default/buildings/castle-2.xml" />
<xi:include href="config://default/buildings/castle-2.xml" />
<building name="watch" capacity="1" maxsize="10">
<function name="name" value="fort_name"/>

View file

@ -3,10 +3,10 @@
<!-- begin main races -->
<xi:include href="config:///default/races/goblin-3.xml"/>
<xi:include href="config:///default/races/wyrm.xml"/>
<xi:include href="config:///default/races/dragon.xml"/>
<xi:include href="config:///default/races/youngdragon.xml"/>
<xi:include href="config://default/races/goblin-3.xml"/>
<xi:include href="config://default/races/wyrm.xml"/>
<xi:include href="config://default/races/dragon.xml"/>
<xi:include href="config://default/races/youngdragon.xml"/>
<race name="lynx" magres="0.000000" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="1.0" hp="20" damage="2d3" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="5" walk="yes" teach="no" getitem="yes">
<ai splitsize="99999"/>

View file

@ -2,13 +2,13 @@
<resources xmlns:xi="http://www.w3.org/2001/XInclude">
<!-- this file contains resources that can be mined in some way (anything with a resourcelimit) -->
<xi:include href="config:///core/resources/cart.xml"/>
<xi:include href="config:///core/resources/horse.xml"/>
<xi:include href="config:///core/resources/hp.xml"/>
<xi:include href="config:///core/resources/laen.xml"/>
<xi:include href="config:///core/resources/log.xml"/>
<xi:include href="config:///core/resources/mallorn.xml"/>
<xi:include href="config:///core/resources/peasant.xml"/>
<xi:include href="config://core/resources/cart.xml"/>
<xi:include href="config://core/resources/horse.xml"/>
<xi:include href="config://core/resources/hp.xml"/>
<xi:include href="config://core/resources/laen.xml"/>
<xi:include href="config://core/resources/log.xml"/>
<xi:include href="config://core/resources/mallorn.xml"/>
<xi:include href="config://core/resources/peasant.xml"/>
<xi:include href="resources/iron.xml"/>
<xi:include href="resources/mallornseed.xml"/>
<xi:include href="resources/seed.xml"/>

View file

@ -37,7 +37,7 @@
<entry spell="summon_familiar" level="9" />
<entry spell="draigfumbleshield" level="9" />
<entry spell="gwyrrdfumbleshield" level="5" />
<entry spell="cerrdorfumbleshield" level="5" />
<entry spell="cerddorfumbleshield" level="5" />
<entry spell="tybiedfumbleshield" level="2" />
<entry spell="concealing_aura" level="1" />
<entry spell="shockwave" level="5" />

View file

@ -22,7 +22,7 @@
<entry spell="calm_monster" level="6" />
<entry spell="calm_riot" level="14" />
<entry spell="cerddor_destroymagic" level="8" />
<entry spell="cerrdorfumbleshield" level="5" />
<entry spell="cerddorfumbleshield" level="5" />
<entry spell="chaosrow" level="8" />
<entry spell="clone" level="9" />
<entry spell="coldfront" level="8" />

View file

@ -619,7 +619,7 @@
<spell name="gwyrrdfumbleshield" rank="2" index="144" variable="true" combat="1">
<resource name="aura" amount="5" cost="level"/>
</spell>
<spell name="cerrdorfumbleshield" rank="2" index="145" variable="true" combat="1">
<spell name="cerddorfumbleshield" rank="2" index="145" variable="true" combat="1">
<resource name="aura" amount="5" cost="level"/>
</spell>
<spell name="tybiedfumbleshield" rank="2" index="146" variable="true" combat="1">

View file

@ -206,7 +206,18 @@
</string>
</namespace>
<namespace name="spellinfo">
<namespace name="spellinfo">
<string name="concealing_aura">
<text locale="de">Dieser Zauber wird die gesamte Ausrüstung der
Zieleinheit für
einige Zeit vor den Blicken anderer verschleiern. Der
Zauber
schützt nicht vor Dieben und Spionen.</text>
<text locale="en">This spell will hide the whole equipment of a target
unit from the
looks of others. It will not protect against thieves or
spies.</text>
</string>
<string name="raindance">
<text locale="de">Durch dieses uralte Tanzritual ruft der Zauberkundige
die Kräfte des Lebens und der Fruchtbarkeit an. Die darauf folgenden

View file

@ -1,25 +1,25 @@
<?xml version="1.0"?>
<resources xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="config:///core/weapons/axe.xml"/>
<xi:include href="config:///core/weapons/bow.xml"/>
<xi:include href="config:///core/weapons/catapult.xml"/>
<xi:include href="config:///core/weapons/lance.xml"/>
<xi:include href="config:///core/weapons/mallornbow.xml"/>
<xi:include href="config:///core/weapons/mallornspear.xml"/>
<xi:include href="config:///core/weapons/rep_crossbow.xml"/>
<xi:include href="config:///core/weapons/runesword.xml"/>
<xi:include href="config:///core/weapons/rustyaxe.xml"/>
<xi:include href="config:///core/weapons/rustysword.xml"/>
<xi:include href="config:///core/weapons/spear.xml"/>
<xi:include href="config:///core/weapons/sword.xml"/>
<xi:include href="config:///core/weapons/firesword.xml"/>
<xi:include href="config:///game/weapons/crossbow.xml"/>
<xi:include href="config:///game/weapons/greatbow.xml"/>
<xi:include href="config:///game/weapons/greatsword.xml"/>
<xi:include href="config:///game/weapons/halberd.xml"/>
<xi:include href="config:///game/weapons/laensword.xml"/>
<xi:include href="config:///game/weapons/mallorncrossbow.xml"/>
<xi:include href="config:///game/weapons/mallornlance.xml"/>
<xi:include href="config:///game/weapons/rustygreatsword.xml"/>
<xi:include href="config:///game/weapons/rustyhalberd.xml"/>
<xi:include href="config://core/weapons/axe.xml"/>
<xi:include href="config://core/weapons/bow.xml"/>
<xi:include href="config://core/weapons/catapult.xml"/>
<xi:include href="config://core/weapons/lance.xml"/>
<xi:include href="config://core/weapons/mallornbow.xml"/>
<xi:include href="config://core/weapons/mallornspear.xml"/>
<xi:include href="config://core/weapons/rep_crossbow.xml"/>
<xi:include href="config://core/weapons/runesword.xml"/>
<xi:include href="config://core/weapons/rustyaxe.xml"/>
<xi:include href="config://core/weapons/rustysword.xml"/>
<xi:include href="config://core/weapons/spear.xml"/>
<xi:include href="config://core/weapons/sword.xml"/>
<xi:include href="config://core/weapons/firesword.xml"/>
<xi:include href="config://game/weapons/crossbow.xml"/>
<xi:include href="config://game/weapons/greatbow.xml"/>
<xi:include href="config://game/weapons/greatsword.xml"/>
<xi:include href="config://game/weapons/halberd.xml"/>
<xi:include href="config://game/weapons/laensword.xml"/>
<xi:include href="config://game/weapons/mallorncrossbow.xml"/>
<xi:include href="config://game/weapons/mallornlance.xml"/>
<xi:include href="config://game/weapons/rustygreatsword.xml"/>
<xi:include href="config://game/weapons/rustyhalberd.xml"/>
</resources>

View file

@ -27,7 +27,7 @@
<entry spell="summon_familiar" level="9" />
<entry spell="song_of_slavery" level="13" />
<entry spell="cerddor_destroymagic" level="8" />
<entry spell="cerrdorfumbleshield" level="5" />
<entry spell="cerddorfumbleshield" level="5" />
<entry spell="big_recruit" level="14" />
<entry spell="raindance" level="3" />
<entry spell="create_roi" level="6" />

View file

@ -26,7 +26,7 @@
<entry spell="calm_monster" level="6" />
<entry spell="calm_riot" level="15" />
<entry spell="cerddor_destroymagic" level="8" />
<entry spell="cerrdorfumbleshield" level="5" />
<entry spell="cerddorfumbleshield" level="5" />
<entry spell="chaosrow" level="8" />
<entry spell="chaossuction" level="14" />
<entry spell="clone" level="9" />

View file

@ -304,6 +304,9 @@
<spell name="wolfhowl" rank="5" index="94" variable="true" combat="1">
<resource name="aura" amount="2" cost="level"/>
</spell>
<spell name="igjarjuk" rank="5" index="94" variable="true" combat="1">
<function name="cast" value="igjarjuk"/>
</spell>
<spell name="resist_magic" rank="2" index="97" parameters="u+" los="true" ship="true" variable="true">
<resource name="aura" amount="5" cost="level"/>
</spell>
@ -402,7 +405,7 @@
<spell name="gwyrrdfumbleshield" rank="2" index="144" variable="true" combat="1">
<resource name="aura" amount="5" cost="level"/>
</spell>
<spell name="cerrdorfumbleshield" rank="2" index="145" variable="true" combat="1">
<spell name="cerddorfumbleshield" rank="2" index="145" variable="true" combat="1">
<resource name="aura" amount="5" cost="level"/>
</spell>
<spell name="tybiedfumbleshield" rank="2" index="146" variable="true" combat="1">

View file

@ -1,17 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<strings>
<namespace name="spellinfo">
<string name="concealing_aura">
<text locale="de">Dieser Zauber wird die gesamte Ausrüstung der
Zieleinheit für
einige Zeit vor den Blicken anderer verschleiern. Der
Zauber
schützt nicht vor Dieben und Spionen.</text>
<text locale="en">This spell will hide the whole equipment of a target
unit from the
looks of others. It will not protect against thieves or
spies.</text>
</string>
<string name="headache">
<text locale="de">
Aufzeichung des Vortrags von Selen Ard'Ragorn in Bar'Glingal:

View file

@ -1,25 +1,25 @@
<?xml version="1.0"?>
<resources xmlns:xi="http://www.w3.org/2001/XInclude">
<!-- this file contains a lot of weapons -->
<xi:include href="eressea:///core/weapons/axe.xml"/>
<xi:include href="eressea:///core/weapons/bow.xml"/>
<xi:include href="eressea:///core/weapons/catapult.xml"/>
<xi:include href="eressea:///core/weapons/crossbow.xml"/>
<xi:include href="eressea:///core/weapons/firesword.xml"/>
<xi:include href="eressea:///core/weapons/greatbow.xml"/>
<xi:include href="eressea:///core/weapons/greatsword.xml"/>
<xi:include href="eressea:///core/weapons/halberd.xml"/>
<xi:include href="eressea:///core/weapons/laensword.xml"/>
<xi:include href="eressea:///core/weapons/lance.xml"/>
<xi:include href="eressea:///core/weapons/mallornbow.xml"/>
<xi:include href="eressea:///core/weapons/mallorncrossbow.xml"/>
<xi:include href="eressea:///core/weapons/mallornlance.xml"/>
<xi:include href="eressea:///core/weapons/mallornspear.xml"/>
<xi:include href="eressea:///core/weapons/runesword.xml"/>
<xi:include href="eressea:///core/weapons/rustyaxe.xml"/>
<xi:include href="eressea:///core/weapons/rustygreatsword.xml"/>
<xi:include href="eressea:///core/weapons/rustyhalberd.xml"/>
<xi:include href="eressea:///core/weapons/rustysword.xml"/>
<xi:include href="eressea:///core/weapons/spear.xml"/>
<xi:include href="eressea:///core/weapons/sword.xml"/>
<xi:include href="eressea://core/weapons/axe.xml"/>
<xi:include href="eressea://core/weapons/bow.xml"/>
<xi:include href="eressea://core/weapons/catapult.xml"/>
<xi:include href="eressea://core/weapons/crossbow.xml"/>
<xi:include href="eressea://core/weapons/firesword.xml"/>
<xi:include href="eressea://core/weapons/greatbow.xml"/>
<xi:include href="eressea://core/weapons/greatsword.xml"/>
<xi:include href="eressea://core/weapons/halberd.xml"/>
<xi:include href="eressea://core/weapons/laensword.xml"/>
<xi:include href="eressea://core/weapons/lance.xml"/>
<xi:include href="eressea://core/weapons/mallornbow.xml"/>
<xi:include href="eressea://core/weapons/mallorncrossbow.xml"/>
<xi:include href="eressea://core/weapons/mallornlance.xml"/>
<xi:include href="eressea://core/weapons/mallornspear.xml"/>
<xi:include href="eressea://core/weapons/runesword.xml"/>
<xi:include href="eressea://core/weapons/rustyaxe.xml"/>
<xi:include href="eressea://core/weapons/rustygreatsword.xml"/>
<xi:include href="eressea://core/weapons/rustyhalberd.xml"/>
<xi:include href="eressea://core/weapons/rustysword.xml"/>
<xi:include href="eressea://core/weapons/spear.xml"/>
<xi:include href="eressea://core/weapons/sword.xml"/>
</resources>

24
s/build
View file

@ -4,13 +4,8 @@ while [ ! -d $ROOT/.git ]; do
ROOT=`dirname $ROOT`
done
[ -z $BUILD ] && BUILD=Debug
MACHINE=`uname -m`
[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang"
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"
[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc"
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"
BIN_DIR="build-$MACHINE-$CC-$BUILD"
[ -z "$CC" ] && CC=clang
[ -z "$BUILD" ] && BUILD=Debug
[ -z "$JOBS" ] && [ "" != "which nproc" ] && JOBS=`nproc`
DISTCC=`which distcc`
@ -23,14 +18,21 @@ CC="$DISTCC $CC"
MAKEOPTS=-j$JOBS
fi
fi
echo "Building with $CC and $JOBS jobs"
echo "Building with CC=$CC and $JOBS jobs"
if [ ! -d $ROOT/$BIN_DIR ]; then
echo "cannot find build directory $BIN_DIR in $ROOT. did you run cmake-init?"
if [ ! -d $ROOT/$BUILD ]; then
echo "cannot find build directory $BUILD in $ROOT. did you run cmake-init?"
exit
fi
git submodule update
cd $ROOT/$BIN_DIR
if [ -z `which tolua` ]; then
echo "build tolua"
cd $ROOT/tolua ; make
fi
echo "build eressea"
cd $ROOT/$BUILD
make $MAKEOPTS && make test
cd $OLDPWD

View file

@ -10,14 +10,13 @@ done
[ -z $BUILD ] && BUILD=Debug
MACHINE=`uname -m`
[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang"
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="clang"
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"
[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc"
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"
BIN_DIR="build-$MACHINE-$CC-$BUILD"
BIN_DIR="$ROOT/build-$MACHINE-$CC-$BUILD"
mkdir -p $BIN_DIR
ln -sf $BIN_DIR $BUILD
cd $BIN_DIR
MACHINE=$(gcc -dumpmachine)
rm -f CMakeCache.txt
@ -34,12 +33,26 @@ if [ -d $HOME/usr ]; then
PREFIX_PATH=$HOME/usr:$HOME/usr/local:$PREFIX_PATH
fi
cmake .. \
-DCMAKE_MODULE_PATH=$PWD/../cmake/Modules \
ARGS=" -DCMAKE_MODULE_PATH=$ROOT/cmake/Modules \
-DCMAKE_BUILD_TYPE=$BUILD \
-DCMAKE_LIBRARY_PATH=$LIBRARY_PATH \
-DCMAKE_INCLUDE_PATH=$INCLUDE_PATH \
-DCMAKE_PREFIX_PATH=$PREFIX_PATH \
-DCMAKE_INSTALL_PREFIX=$HOME/eressea/server $*
-DCMAKE_INSTALL_PREFIX=$HOME/eressea/server"
path="$(which tolua)"
if [ "$HAVE_TOLUA" = "0" ] || [ -z $path ] ; then
echo "tolua is not installed, building from source"
cd $ROOT/tolua ; make
ARGS="$ARGS -DPC_TOLUA_DIR=$ROOT/tolua"
else
echo "tolua is $path"
fi
unset path
set -e
cd $BIN_DIR
cmake .. $ARGS $*
cd $OLDPWD

View file

@ -2,7 +2,7 @@
ROOT=$(pwd)
while [ ! -d $ROOT/.git ]; do
ROOT=$(dirname $ROOT)
if [ "$ROOT" == "/" ; then
if [ "/" = "$ROOT" ]; then
echo "could not find root, are you in the git repository?"
exit
fi
@ -25,4 +25,8 @@ programs="create-orders backup-eressea run-turn"
for prg in ${programs} ; do
install -v $ROOT/process/$prg $DEST/bin/
done
crontab $ROOT/process/cron/crontab
# install crontab, but only on the eressea server:
HOST=`hostname`
[ "gruenbaer" = "$HOST" ] && crontab $ROOT/process/cron/crontab

View file

@ -81,10 +81,11 @@ ln -f $LIVE/data/$turn.dat data/
rm -rf reports
mkdir -p reports
SERVER="$SOURCE/build-x86_64-gcc-Debug/eressea/eressea"
SUPP="$SOURCE/share/ubuntu-12_04.supp"
SERVER="$SOURCE/Debug/eressea/eressea"
VALGRIND=$(which valgrind)
if [ ! -z $VALGRIND ]; then
SERVER="$VALGRIND --leak-check=no $SERVER"
SERVER="$VALGRIND --suppressions=$SUPP --error-exitcode=1 --leak-check=no $SERVER"
fi
$SERVER -v$verbose -t$turn -re$game $SOURCE/scripts/run-turn.lua
let turn=$turn+1
@ -148,7 +149,7 @@ case "$1" in
;;
"run")
if [ $turn -eq 0 ]; then
[ -f $LIVE/turn ] || abort "missing turn file, and no turn specified"
[ -f $LIVE/turn ] || abort "missing turn file in $LIVE, and no turn specified"
let turn=$(cat $LIVE/turn)-1
fi
run

View file

@ -6,22 +6,18 @@ while [ ! -d $ROOT/.git ]; do
ROOT=$(dirname $ROOT)
done
MACHINE=`uname -m`
[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang"
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"
[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc"
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"
BIN_DIR="build-$MACHINE-$CC-Debug"
[ -z $BUILD ] && BUILD=Debug ; export BUILD
if [ ! -d $ROOT/$BIN_DIR ]; then
echo "cannot find build directory $BIN_DIR in $ROOT. did you run cmake-init?"
if [ ! -e $ROOT/$BUILD ]; then
echo "cannot find build directory $BUILD in $ROOT. did you run cmake-init?"
exit
fi
$ROOT/$BIN_DIR/eressea/test_eressea
$ROOT/$BUILD/eressea/test_eressea
cd $ROOT
[ -e eressea.ini ] || ln -sf conf/eressea.ini
$ROOT/$BIN_DIR/eressea/eressea -v0 scripts/run-tests.lua
$ROOT/$BIN_DIR/eressea/eressea -v0 scripts/run-tests-e2.lua
$ROOT/$BIN_DIR/eressea/eressea -v0 scripts/run-tests-e3.lua
$ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests.lua
$ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests-e2.lua
$ROOT/$BUILD/eressea/eressea -v0 scripts/run-tests-e3.lua
cd $OLDWPD

View file

@ -1,18 +1,21 @@
#!/bin/sh
ROOT=`pwd`
inifile() {
cd $ROOT
if [ ! -e eressea.ini ]; then
cp conf/eressea.ini .
build/iniparser/inifile eressea.ini add lua:paths lunit:scripts
$BUILD/iniparser/inifile eressea.ini add lua:paths lunit:scripts
fi
}
[ -d build ] || mkdir build
cd build && cmake .. \
-DCMAKE_MODULE_PATH=$PWD/../cmake/Modules \
-DCMAKE_BUILD_TYPE=Debug .. && \
make && cd .. && inifile &&
build/eressea/test_eressea &&
build/eressea/eressea -v0 scripts/run-tests-basic.lua
build/eressea/eressea -v0 scripts/run-tests-e2.lua
build/eressea/eressea -v0 scripts/run-tests-e3.lua
set -e
[ -z $BUILD ] && BUILD=Debug ; export BUILD
s/cmake-init
s/build
cd $ROOT
inifile
s/runtests
cd tests
./write-reports.sh

View file

@ -0,0 +1,31 @@
local function bitset(flags, bit)
-- TODO: use bit32 when we no longer have to consider lua 5.1 compatibility
local x = flags % (bit*2)
return x >= bit
end
local function curse(file)
for line in file:lines() do
f = get_faction(line)
if not f then
print("no such faction: " .. line)
elseif bitset(f.flags, 16) then
print("cursing " .. tostring(f))
f.flags = f.flags + 16
else
print("already cursed: " .. tostring(f))
end
end
end
local cursed = {}
function cursed.init()
local f = io.open("cursed.txt", "r")
if f then
print("found cursed.txt")
curse(f)
end
end
return cursed

View file

@ -14,5 +14,6 @@ return {
require('eressea.astral'),
require('eressea.locales'),
require('eressea.jsreport'),
require('eressea.ents')
require('eressea.ents'),
require('eressea.cursed')
}

View file

@ -25,7 +25,10 @@ function embassy.init()
end
function embassy.update()
-- Muschelplateau
-- Muschelplateau
if home==nil then
return
end
eressea.log.debug("updating embassies in " .. tostring(home))
local u
for u in home.units do

View file

@ -16,7 +16,7 @@ end
local function repair_ents(r)
for u in r.units do
if u.faction.id==666 and u.race == "undead" and u.name == "Wütende Ents" then
print("ent repair", u)
eressea.log.info("ent repair: " .. tostring(u))
u.race = "ent"
end
end

View file

@ -1,7 +1,5 @@
local pkg = {}
print("loading jsreport module")
function pkg.init()
eressea.settings.set("feature.jsreport.enable", "1")
end
@ -14,7 +12,7 @@ function pkg.update()
local o = f.options
local bit = (math.floor(o / 8) % 2)
if bit==0 then
eressea.log.warning("enable JSON report for " .. tostring(f))
eressea.log.info("enable JSON report for " .. tostring(f))
f.options = o + 8
end
end

View file

@ -1,53 +0,0 @@
require "lunit"
module("tests.eressea.attrib", package.seeall, lunit.testcase)
function has_attrib(u, value)
for a in u.attribs do
if (a.data==value) then return true end
end
return false
end
function test_attrib_global()
a = attrib.create('global', {})
eressea.write_game('attrib.dat')
eressea.free_game()
eressea.read_game('attrib.dat')
end
function test_attrib()
local r = region.create(0,0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
local u2 = unit.create(f, r, 1)
data = { arr = { 'a', 'b', 'c' }, name = 'familiar', events = { die = 'familiar_died' }, data = { mage = u2 } }
a = { 'a' }
b = { 'a' }
uno = u.id
u2no = u2.id
a = attrib.create(u, 12)
a = attrib.create(u, "enno")
a = attrib.create(u, u2)
a = attrib.create(u, data)
eressea.write_game("attrib.dat")
eressea.free_game()
eressea.read_game("attrib.dat")
u = get_unit(uno)
u2 = get_unit(u2no)
assert_false(has_attrib(u, 42))
assert_true(has_attrib(u, "enno"))
assert_true(has_attrib(u, 12))
for a in u.attribs do
x = a.data
if (type(x)=="table") then
assert_equal('a', x.arr[1])
assert_equal('familiar', x.name)
assert_equal('familiar_died', x.events.die)
assert_equal(u2, x.data.mage)
break
end
end
end

View file

@ -1,65 +0,0 @@
require "lunit"
module("tests.eressea.bson", package.seeall, lunit.testcase)
function setup()
eressea.free_game()
end
function test_bson_create()
local a = attrib.create("global", 12)
assert_not_equal(nil, a)
for a in attrib.get("global") do
assert_equal(a.data, 12)
end
end
function test_illegal_arg()
local a = attrib.create(nil, 42)
assert_equal(nil, a)
a = attrib.create("fred", 42)
assert_equal(nil, a)
end
function test_bson_readwrite()
local i, r = region.create(0, 0, "mountain")
attrib.create(r, 42)
i = eressea.write_game("test_read_write.dat")
assert_equal(0, i)
eressea.free_game()
r = get_region(0, 0)
assert_equal(nil, r)
i = eressea.read_game("test_read_write.dat")
assert_equal(0, i)
r = get_region(0, 0)
assert_not_equal(nil, r)
for a in attrib.get(r) do
assert_equal(a.data, 42)
end
end
function test_bson()
local r = region.create(0, 0, "mountain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
assert_not_equal(nil, u)
assert_not_equal(nil, r)
assert_not_equal(nil, f)
attrib.create(r, 1)
assert_equal(attrib.get(r)().data, 1)
attrib.create(u, 3)
assert_equal(attrib.get(u)().data, 3)
attrib.create(f, 5)
assert_equal(attrib.get(f)().data, 5)
end
function test_bson_with_multiple_attribs()
local r = region.create(0, 0, "mountain")
attrib.create(r, { a=1})
attrib.create(r, { a=5})
local total = 0
for a in attrib.get(r) do
total = total + a.data.a;
end
assert_equal(6, total)
end

View file

@ -1,27 +0,0 @@
require "lunit"
module('tests.eressea.castles', package.seeall, lunit.testcase )
function setup()
eressea.free_game()
end
function test_small_castles()
local r = region.create(0, 0, "plain")
local f1 = faction.create("noreply@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 1)
local f2 = faction.create("noreply@eressea.de", "halfling", "de")
local u2 = unit.create(f2, r, 1)
u1:add_item("money", 10000)
local b = building.create(r, "castle")
u2.building = b
u1.building = b
b.owner = u2
assert_equal("site", b:get_typename(7))
assert_equal("fortification", b:get_typename(8))
b.owner = u1
assert_equal("site", b:get_typename(9))
assert_equal("fortification", b:get_typename(10))
end

View file

@ -1,39 +0,0 @@
require "lunit"
module("tests.eressea.config", package.seeall, lunit.testcase )
function setup()
eressea.free_game()
end
function test_read_race()
local f
eressea.free_game()
f = faction.create("orc@example.com", "orc", "en")
assert_equal(nil, f)
assert_not_nil(eressea.config)
eressea.config.parse('{ "races": { "orc" : {}}}')
f = faction.create("orc@example.com", "orc", "en")
assert_not_nil(f)
end
function test_read_ship()
local s
eressea.free_game()
s = ship.create(nil, "boat")
assert_equal(nil, s)
assert_not_nil(eressea.config)
conf = [[{
"ships": {
"boat" : {
"construction" : {
"maxsize" : 20
}
}
}
}]]
eressea.config.parse(conf);
s = ship.create(nil, "boat")
assert_not_nil(s)
end

View file

@ -1,735 +0,0 @@
require "lunit"
module("tests.e3.e3features", package.seeall, lunit.testcase)
function setup()
eressea.free_game()
eressea.settings.set("rules.economy.food", "4")
end
function test_no_stealth()
local r = region.create(0,0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:set_skill("stealth", 1)
assert_equal(-1, u:get_skill("stealth"))
u:clear_orders()
u:add_order("LERNEN TARNUNG")
process_orders()
assert_equal(-1, u:get_skill("stealth"))
end
--[[
function test_analyze_magic()
local r1 = region.create(0,0, "plain")
local r2 = region.create(1,0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r2, 1)
u.race = "elf"
u:set_skill("magic", 6)
u.magic = "gwyrrd"
u.aura = 60
u:add_spell("analyze_magic")
u:clear_orders()
u:add_order("Zaubere stufe 2 'Magie analysieren' REGION 1,0")
process_orders()
end
]]--
function test_seecast()
local r = region.create(0,0, "plain")
for i = 1,10 do
-- this prevents storms (only high seas have storms)
region.create(i, 1, "plain")
end
for i = 1,10 do
region.create(i, 0, "ocean")
end
local f = faction.create("noreply@eressea.de", "human", "de")
local s1 = ship.create(r, "cutter")
local u1 = unit.create(f, r, 2)
u1:set_skill("sailing", 3)
u1:add_item("money", 1000)
u1.ship = s1
local u2 = unit.create(f, r, 1)
u2.race = "elf"
u2:set_skill("magic", 6)
u2.magic = "gwyrrd"
u2.aura = 60
u2.ship = s1
u2:add_spell("stormwinds")
update_owners()
u2:clear_orders()
u2:add_order("Zaubere stufe 2 'Beschwoere einen Sturmelementar' " .. itoa36(s1.id))
u1:clear_orders()
u1:add_order("NACH O O O O")
process_orders()
assert_equal(4, u2.region.x)
u2:clear_orders()
u2:add_order("Zaubere stufe 2 'Beschwoere einen Sturmelementar' " .. itoa36(s1.id))
u1:clear_orders()
u1:add_order("NACH O O O O")
process_orders()
assert_equal(8, u2.region.x)
end
local function use_tree(terrain)
local r = region.create(0,0, terrain)
local f = faction.create("noreply@eressea.de", "human", "de")
local u1 = unit.create(f, r, 5)
r:set_resource("tree", 0)
u1:add_item("xmastree", 1)
u1:clear_orders()
u1:add_order("BENUTZEN 1 Weihnachtsbaum")
process_orders()
return r
end
function test_xmas2009()
local r = region.create(0,0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u1 = unit.create(f, r, 1)
process_orders()
xmas2009()
assert_equal("xmastree", f.items())
end
function test_xmastree()
local r
r = use_tree("ocean")
assert_equal(0, r:get_resource("tree"))
eressea.free_game()
r = use_tree("plain")
assert_equal(10, r:get_resource("tree"))
end
function test_fishing()
eressea.settings.set("rules.economy.food", "0")
local r = region.create(0,0, "ocean")
local r2 = region.create(1,0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local s1 = ship.create(r, "cutter")
local u1 = unit.create(f, r, 3)
u1.ship = s1
u1:set_skill("sailing", 10)
u1:add_item("money", 100)
u1:clear_orders()
u1:add_order("NACH O")
update_owners()
process_orders()
assert_equal(r2, u1.region)
assert_equal(90, u1:get_item("money"))
u1:clear_orders()
u1:add_order("NACH W")
process_orders()
assert_equal(r, u1.region)
assert_equal(60, u1:get_item("money"))
end
function test_ship_capacity()
eressea.settings.set("rules.ship.drifting", "0")
eressea.settings.set("rules.ship.storms", "0")
local r = region.create(0,0, "ocean")
region.create(1,0, "ocean")
local r2 = region.create(2,0, "ocean")
local f = faction.create("noreply@eressea.de", "human", "de")
local f2 = faction.create("noreply@eressea.de", "goblin", "de")
-- u1 is at the limit and moves
local s1 = ship.create(r, "cutter")
local u1 = unit.create(f, r, 5)
u1.ship = s1
u1:set_skill("sailing", 10)
u1:add_item("sword", 55)
u1:clear_orders()
u1:add_order("NACH O O")
-- u2 has too many people
local s2 = ship.create(r, "cutter")
local u2 = unit.create(f, r, 6)
u2.ship = s2
u2:set_skill("sailing", 10)
u2:clear_orders()
u2:add_order("NACH O O")
-- u3 has goblins, they weigh 40% less
local s3 = ship.create(r, "cutter")
local u3 = unit.create(f2, r, 8)
u3.ship = s3
u3:set_skill("sailing", 10)
u3:add_item("sword", 55)
u3:clear_orders()
u3:add_order("NACH O O")
-- u4 has too much stuff
local s4 = ship.create(r, "cutter")
local u4 = unit.create(f, r, 5)
u4.ship = s4
u4:set_skill("sailing", 10)
u4:add_item("sword", 56)
u4:clear_orders()
u4:add_order("NACH O O")
update_owners()
process_orders()
if r2~=u1.region then
print(get_turn(), u1, u1.faction)
write_reports()
end
assert_equal(r2, u1.region)
assert_not_equal(r2.id, u2.region.id)
if r2~=u3.region then
print(get_turn(), u3, u3.faction)
write_reports()
end
assert_equal(r2, u3.region)
assert_not_equal(r2.id, u4.region.id)
end
function test_owners()
local r = region.create(0, 0, "plain")
local f1 = faction.create("noreply@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 1)
local f2 = faction.create("noreply@eressea.de", "human", "de")
local u2 = unit.create(f2, r, 1)
local u3 = unit.create(f2, r, 1)
local b3 = building.create(r, "castle")
b3.size = 2
u3.building = b3
local b1 = building.create(r, "castle")
b1.size = 1
u1.building = b1
local b2 = building.create(r, "castle")
b2.size = 2
u2.building = b2
update_owners()
assert(r.owner==u3.faction)
b1.size=3
b2.size=3
update_owners()
assert(r.owner==u2.faction)
b1.size=4
update_owners()
assert(r.owner==u1.faction)
end
function test_taxes()
local r = region.create(0, 0, "plain")
r:set_resource("peasant", 1000)
r:set_resource("money", 5000)
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:clear_orders()
u:add_order("LERNE Holzfaellen") -- do not work
local b = building.create(r, "watch")
b.size = 10
u.building = b
update_owners()
assert_equal(1, r.morale)
process_orders()
assert_equal(1, r.morale)
assert_equal(25, u:get_item("money"))
end
function test_region_owner_cannot_leave_castle()
eressea.settings.set("rules.move.owner_leave", "1")
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
f.id = 42
local b1 = building.create(r, "castle")
b1.size = 10
local b2 = building.create(r, "lighthouse")
b2.size = 10
local u = unit.create(f, r, 1)
u.building = b1
u:add_item("money", u.number * 100)
u:clear_orders()
u:add_order("BETRETE BURG " .. itoa36(b2.id))
process_orders()
init_reports()
write_report(u.faction)
assert_equal(b1, u.building, "region owner has left the building") -- region owners may not leave
end
function test_market()
-- if i am the only trader around, i should be getting all the herbs from all 7 regions
local herb_multi = 500 -- from rc_herb_trade()
local r, idx
local herbnames = { 'h0', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7', 'h8' }
idx = 1
for x = -1, 1 do for y = -1, 1 do
r = region.create(x, y, "plain")
r:set_resource("peasant", herb_multi * 9 + 50) -- 10 herbs per region
r.herb = herbnames[idx]
idx = idx+1
end end
r = get_region(0, 0)
local b = building.create(r, "market")
b.size = 10
local f = faction.create("noreply@eressea.de", "human", "de")
f.id = 42
local u = unit.create(f, r, 1)
u.building = b
u:add_item("money", u.number * 10000)
for i = 0, 5 do
local rn = r:next(i)
end
b.working = true
eressea.process.markets()
u:add_item("money", -u:get_item("money")) -- now we only have herbs
local len = 0
for i in u.items do
len = len + 1
end
assert_not_equal(0, len, "trader did not get any herbs")
for idx, name in pairs(herbnames) do
local n = u:get_item(name)
if n>0 then
assert_equal(10, n, 'trader did not get exaxtly 10 herbs')
end
end
end
function test_market_gives_items()
local r
for x = -1, 1 do for y = -1, 1 do
r = region.create(x, y, "plain")
r:set_resource("peasant", 5000)
end end
r = get_region(0, 0)
local b = building.create(r, "market")
b.size = 10
local f = faction.create("noreply@eressea.de", "human", "de")
f.id = 42
local u = unit.create(f, r, 1)
u.building = b
u:add_item("money", u.number * 10000)
for i = 0, 5 do
local rn = r:next(i)
end
process_orders()
local len = 0
for i in u.items do
len = len + 1
end
assert(len>1)
end
function test_spells()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u.race = "elf"
u:clear_orders()
u:add_item("money", 10000)
u:set_skill("magic", 5)
u:add_order("LERNE MAGIE Illaun")
process_orders()
local sp
local nums = 0
if f.spells~=nil then
for sp in f.spells do
nums = nums + 1
end
assert(nums>0)
for sp in u.spells do
nums = nums - 1
end
assert(nums==0)
elseif u.spells~=nil then
for sp in u.spells do
nums = nums + 1
end
assert(nums>0)
end
end
function test_alliance()
local r = region.create(0, 0, "plain")
local f1 = faction.create("noreply@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 1)
u1:add_item("money", u1.number * 100)
local f2 = faction.create("info@eressea.de", "human", "de")
local u2 = unit.create(f2, r, 1)
u2:add_item("money", u2.number * 100)
assert(f1.alliance==nil)
assert(f2.alliance==nil)
u1:clear_orders()
u2:clear_orders()
u1:add_order("ALLIANZ NEU pink")
u1:add_order("ALLIANZ EINLADEN " .. itoa36(f2.id))
u2:add_order("ALLIANZ BEITRETEN pink")
process_orders()
assert(f1.alliance~=nil)
assert(f2.alliance~=nil)
assert(f2.alliance==f1.alliance)
u1:clear_orders()
u2:clear_orders()
u1:add_order("ALLIANZ KOMMANDO " .. itoa36(f2.id))
process_orders()
assert(f1.alliance~=nil)
assert(f2.alliance~=nil)
assert(f2.alliance==f1.alliance)
for f in f1.alliance.factions do
assert_true(f.id==f1.id or f.id==f2.id)
end
u1:clear_orders()
u2:clear_orders()
u2:add_order("ALLIANZ AUSSTOSSEN " .. itoa36(f1.id))
process_orders()
assert(f1.alliance==nil)
assert(f2.alliance~=nil)
u1:clear_orders()
u2:clear_orders()
u2:add_order("ALLIANZ NEU zing")
u1:add_order("ALLIANZ BEITRETEN zing") -- no invite!
process_orders()
assert(f1.alliance==nil)
assert(f2.alliance~=nil)
u1:clear_orders()
u2:clear_orders()
u1:add_order("ALLIANZ NEU zack")
u1:add_order("ALLIANZ EINLADEN " .. itoa36(f2.id))
u2:add_order("ALLIANZ BEITRETEN zack")
process_orders()
assert(f1.alliance==f2.alliance)
assert(f2.alliance~=nil)
end
function test_canoe_passes_through_land()
local f = faction.create("noreply@eressea.de", "human", "de")
local src = region.create(0, 0, "ocean")
local land = region.create(1, 0, "plain")
region.create(2, 0, "ocean")
local dst = region.create(3, 0, "ocean")
local sh = ship.create(src, "canoe")
local u1 = unit.create(f, src, 1)
local u2 = unit.create(f, src, 1)
u1.ship = sh
u2.ship = sh
u1:set_skill("sailing", 10)
u1:clear_orders()
u1:add_order("NACH O O O")
process_orders()
assert_equal(land, u2.region, "canoe did not stop at coast")
u1:add_order("NACH O O O")
process_orders()
assert_equal(dst, sh.region, "canoe could not leave coast")
assert_equal(dst, u1.region, "canoe could not leave coast")
assert_equal(dst, u2.region, "canoe could not leave coast")
end
function test_give_50_percent_of_money()
local r = region.create(0, 0, "plain")
local u1 = unit.create(faction.create("noreply@eressea.de", "human", "de"), r, 1)
local u2 = unit.create(faction.create("noreply@eressea.de", "orc", "de"), r, 1)
u1.faction.age = 10
u2.faction.age = 10
u1:add_item("money", 500)
u2:add_item("money", 500)
local m1, m2 = u1:get_item("money"), u2:get_item("money")
u1:clear_orders()
u1:add_order("GIB " .. itoa36(u2.id) .. " 221 Silber")
u2:clear_orders()
u2:add_order("LERNEN Hiebwaffen")
process_orders()
assert_equal(m1, u1:get_item("money"))
assert_equal(m2, u2:get_item("money"))
m1, m2 = u1:get_item("money"), u2:get_item("money")
u1:clear_orders()
u1:add_order("GIB " .. itoa36(u2.id) .. " 221 Silber")
u2:clear_orders()
u2:add_order("HELFEN " .. itoa36(u1.faction.id) .. " GIB")
u2:add_item("horse", 100)
u2:add_order("GIB 0 ALLES PFERD")
local h = r:get_resource("horse")
process_orders()
assert_true(r:get_resource("horse")>=h+100)
assert_equal(m1-221, u1:get_item("money"))
assert_equal(m2+110, u2:get_item("money"))
end
function test_give_100_percent_of_items()
r = region.create(0, 0, "plain")
local u1 = unit.create(faction.create("noreply@eressea.de", "human", "de"), r, 1)
local u2 = unit.create(faction.create("noreply@eressea.de", "orc", "de"), r, 1)
u1.faction.age = 10
u2.faction.age = 10
u1:add_item("money", 500)
u1:add_item("log", 500)
local m1, m2 = u1:get_item("log"), u2:get_item("log")
u1:clear_orders()
u1:add_order("GIB " .. itoa36(u2.id) .. " 332 Holz")
u2:clear_orders()
u2:add_order("LERNEN Hiebwaffen")
u2:add_order("HELFEN " .. itoa36(u1.faction.id) .. " GIB")
process_orders()
assert_equal(m1-332, u1:get_item("log"))
assert_equal(m2+332, u2:get_item("log"))
end
function test_cannot_give_person()
local r = region.create(0, 0, "plain")
local f1 = faction.create("noreply@eressea.de", "human", "de")
local f2 = faction.create("noreply@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 10)
local u2 = unit.create(f2, r, 10)
u1.faction.age = 10
u2.faction.age = 10
u1:add_item("money", 500)
u2:add_item("money", 500)
u2:clear_orders()
u2:add_order("GIB ".. itoa36(u1.id) .. " 1 PERSON")
u2:add_order("HELFE ".. itoa36(f1.id) .. " GIB")
u1:add_order("HELFE ".. itoa36(f2.id) .. " GIB")
process_orders()
assert_equal(10, u2.number)
assert_equal(10, u1.number)
end
function test_cannot_give_unit()
local r = region.create(0, 0, "plain")
local f1 = faction.create("noreply@eressea.de", "human", "de")
local f2 = faction.create("noreply@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 10)
local u2 = unit.create(f2, r, 10)
u1.faction.age = 10
u2.faction.age = 10
u1:add_item("money", 500)
u2:add_item("money", 500)
u2:clear_orders()
u2:add_order("GIB ".. itoa36(u1.id) .. " EINHEIT")
u2:add_order("HELFE ".. itoa36(f1.id) .. " GIB")
u1:add_order("HELFE ".. itoa36(f2.id) .. " GIB")
process_orders()
assert_not_equal(u2.faction.id, u1.faction.id)
end
function test_guard_by_owners()
-- http://bugs.eressea.de/view.php?id=1756
local r = region.create(0,0, "mountain")
local f1 = faction.create("noreply@eressea.de", "human", "de")
f1.age=20
local f2 = faction.create("noreply@eressea.de", "human", "de")
f2.age=20
local u1 = unit.create(f1, r, 1)
local b = building.create(r, "castle")
b.size = 10
u1.building = b
u1:add_item("money", 100)
local u2 = unit.create(f2, r, 1)
u2:add_item("money", 100)
u2:set_skill("mining", 3)
u2:clear_orders()
u2:add_order("MACHEN EISEN")
process_orders()
local iron = u2:get_item("iron")
process_orders()
assert_equal(iron, u2:get_item("iron"))
end
function test_market_action()
local f = faction.create("noreply@eressea.de", "human", "de")
local x, y, r
for x=0,2 do
for y=0,2 do
r = region.create(x, y, "plain")
r.luxury = "balm"
r.herb = "h2"
r:set_resource("peasant", 5000)
end
end
r = get_region(1, 1)
local u = unit.create(f, r, 1)
b = building.create(r, "market")
b.size = 10
u.building = b
update_owners()
for r in regions() do
market_action(r)
end
assert_equal(35, u:get_item("balm"))
assert_equal(70, u:get_item("h2"))
end
local function setup_packice(x, onfoot)
local f = faction.create("noreply@eressea.de", "human", "de")
local plain = region.create(0,0, "plain")
local ice = region.create(1,0, "packice")
local ocean = region.create(2,0, "ocean")
local u = unit.create(f, get_region(x, 0), 2)
if not onfoot then
local s = ship.create(u.region, "cutter")
u:set_skill("sailing", 3)
u.ship = s
end
u:add_item("money", 400)
return u
end
function test_no_sailing_through_packice()
local u = setup_packice(0)
u:clear_orders()
u:add_order("NACH O O")
process_orders()
assert_equal(0, u.region.x)
end
function test_can_sail_from_packice_to_ocean()
local u = setup_packice(1)
u:clear_orders()
u:add_order("NACH W")
process_orders()
assert_equal(1, u.region.x)
u:clear_orders()
u:add_order("NACH O")
process_orders()
assert_equal(2, u.region.x)
end
function test_can_sail_into_packice()
local u = setup_packice(2)
u:clear_orders()
u:add_order("NACH W W")
process_orders()
assert_equal(1, u.region.x)
end
function test_can_walk_into_packice()
local u = setup_packice(0, true)
u:clear_orders()
u:add_order("NACH O")
process_orders()
assert_equal(1, u.region.x)
end
function test_cannot_walk_into_ocean()
local u = setup_packice(1, true)
u:clear_orders()
u:add_order("NACH O")
process_orders()
assert_equal(1, u.region.x)
end
function test_p2()
local f = faction.create("noreply@eressea.de", "human", "de")
local r = region.create(0, 0, "plain")
local u = unit.create(f, r, 1)
r:set_resource("tree", 0)
u:clear_orders()
u:add_order("BENUTZE 'Wasser des Lebens'")
u:add_item("p2", 1)
u:add_item("log", 10)
u:add_item("mallorn", 10)
process_orders()
assert_equal(5, r:get_resource("tree"))
assert_equal(0, u:get_item("p2"))
assert_equal(15, u:get_item("log") + u:get_item("mallorn"))
end
function test_p2_move()
-- http://bugs.eressea.de/view.php?id=1855
local f = faction.create("noreply@eressea.de", "human", "de")
local r = region.create(0, 0, "plain")
region.create(1, 0, "plain")
local u = unit.create(f, r, 1)
r:set_resource("tree", 0)
u:clear_orders()
u:add_order("BENUTZE 'Wasser des Lebens'")
u:add_order("NACH OST")
u:add_item("horse", 1)
u:add_item("p2", 1)
u:add_item("log", 1)
u:add_item("mallorn", 1)
process_orders()
assert_equal(1, u.region.x)
assert_equal(1, r:get_resource("tree"))
end
function disabled_test_bug_1738_build_castle_e3()
local r = region.create(0, 0, "plain")
local f = faction.create("bug_1738@eressea.de", "human", "de")
local c = building.create(r, "castle")
c.size = 228
local u1 = unit.create(f, r, 1)
u1:set_skill("building", 5)
u1:add_item("stone", 10000)
local u2 = unit.create(f, r, 32)
u2:set_skill("building", 3)
u2:add_item("stone", 10000)
u1:clear_orders()
u1:add_order("MACHE BURG " .. itoa36(c.id))
-- castle now has size 229.
u2:clear_orders()
u2:add_order("MACHE BURG " .. itoa36(c.id))
-- 32 * 3 makes 96 skill points.
-- from size 229 to size 250 needs 21 * 3 = 63 points, rest 33.
-- 33/4 makes 8 points, resulting size is 258.
process_orders()
--[[
init_reports()
write_report(f)
]]--
-- resulting size should be 250 because unit 2
-- does not have the needed minimum skill.
assert_equal(c.size, 250)
end
function test_golem_use_four_iron()
local r0 = region.create(0, 0, "plain")
local f1 = faction.create("noreply@eressea.de", "halfling", "de")
local u1 = unit.create(f1, r0, 3)
u1.race = "irongolem"
u1:set_skill("weaponsmithing", 1)
u1:set_skill("armorer", 1)
u1:clear_orders()
u1:add_order("Mache 4 Turmschild")
process_orders()
assert_equal(2, u1.number)
assert_equal(4, u1:get_item("towershield"))
end
function test_building_owner_can_enter_ship()
local r1 = region.create(1, 2, "plain")
local f1 = faction.create("noreply@tteessttiinngg.de", "human", "de")
local b1 = building.create(r1, "castle")
b1.size = 10
local s1 = ship.create(r1, "cutter")
local u1 = unit.create(f1, r1, 10)
u1.building = b1
u1:add_item("money", u1.number * 100)
u1:clear_orders()
u1:add_order("VERLASSEN")
u1:add_order("BETRETE SCHIFF " .. itoa36(s1.id))
local u2 = unit.create(f1, r1, 10)
u2.ship = s1
u2:add_item("money", u1.number * 100)
u2:clear_orders()
process_orders()
assert_equal(s1, u1.ship)
assert_equal(null, u1.building, "owner of the building can not go into a ship")
end

View file

@ -1,360 +0,0 @@
require "lunit"
module("tests.e3.e2features", package.seeall, lunit.testcase )
local function one_unit(r, f)
local u = unit.create(f, r, 1)
u:add_item("money", u.number * 100)
u:clear_orders()
return u
end
local function two_factions()
local f1 = faction.create("one@eressea.de", "human", "de")
local f2 = faction.create("two@eressea.de", "human", "de")
return f1, f2
end
local function two_units(r, f1, f2)
return one_unit(r, f1), one_unit(r, f2)
end
function setup()
eressea.free_game()
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("rules.economy.food", "4")
end
function test_learn()
eressea.settings.set("study.random_progress", "0")
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
f.age = 20
local u = unit.create(f, r)
u:clear_orders()
u:add_order("@LERNEN Reiten")
process_orders()
assert_equal(1, u:get_skill("riding"))
process_orders()
process_orders()
assert_equal(2, u:get_skill("riding"))
process_orders()
process_orders()
process_orders()
assert_equal(3, u:get_skill("riding"))
end
function test_teach()
eressea.settings.set("study.random_progress", "0")
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
f.age = 20
local u = unit.create(f, r, 10)
local u2 = unit.create(f, r)
u:clear_orders()
u:add_order("@LERNEN reiten")
u2:clear_orders()
u2:add_order("LEHREN " .. itoa36(u.id))
u2:set_skill("riding", 4)
process_orders()
assert_equal(1, u:get_skill("riding"))
process_orders()
assert_equal(2, u:get_skill("riding"))
end
function test_rename()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r)
u:add_item("aoh", 1)
assert_equal(u:get_item("ao_healing"), 1)
end
function DISABLE_test_alp()
local r = region.create(0,0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
local u2 = unit.create(f, r, 1)
u.race = "elf"
u:set_skill("magic", 10)
u:add_item("money", 3010)
u.magic = "illaun"
u.aura = 200
u.ship = s1
u:add_spell("summon_alp")
u:clear_orders()
u:add_order("ZAUBERE 'Alp' " .. itoa36(u2.id))
process_orders()
print(get_turn(), f)
write_reports()
end
function test_unit_limit_is_1500()
local r = region.create(0,0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
for i = 1,1500 do
unit.create(f, r, 1)
end
local u = unit.create(f, r, 0)
u:add_item("money", 20000)
u:clear_orders()
u:add_order("REKRUTIEREN 1")
process_orders()
assert_equal(1, u.number)
end
function test_ship_capacity()
local r = region.create(0,0, "ocean")
region.create(1,0, "ocean")
local r2 = region.create(2,0, "ocean")
local f = faction.create("noreply@eressea.de", "human", "de")
-- u1 is at the limit and moves
local s1 = ship.create(r, "boat")
local u1 = unit.create(f, r, 5)
u1.ship = s1
u1:set_skill("sailing", 10)
u1:clear_orders()
u1:add_order("NACH O O")
-- u2 has too many people
local s2 = ship.create(r, "boat")
local u2 = unit.create(f, r, 6)
u2.ship = s2
u2:set_skill("sailing", 10)
u2:clear_orders()
u2:add_order("NACH O O")
-- u4 has too much stuff
local s4 = ship.create(r, "boat")
local u4 = unit.create(f, r, 5)
u4.ship = s4
u4:set_skill("sailing", 10)
u4:add_item("sword", 1)
u4:clear_orders()
u4:add_order("NACH O O")
process_orders()
-- print(s.region, u.region, r2)
assert_equal(r2, u1.region, "boat with 5 humans did not move")
assert_not_equal(r2, u2.region, "boat with too many people has moved")
assert_not_equal(r2, u4.region, "boat with too much cargo has moved")
end
function test_levitate()
local r = region.create(0,0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 2)
local s = ship.create(r, "boat")
u.ship = s
u.age = 20
u:set_skill("sailing", 5)
u:add_item("money", 100)
u:clear_orders()
u:add_order("ARBEITE")
levitate_ship(u.ship, u, 2, 1)
assert_equal(32, u.ship.flags)
process_orders()
assert_equal(0, u.ship.flags)
end
function test_terrains()
local terrains = { "hell", "wall1", "corridor1" }
for k,v in ipairs(terrains) do
local r = region.create(k, k, v)
assert_not_equal(nil, r)
end
end
function test_races()
local races = { "wolf", "orc", "human", "demon" }
for k,v in ipairs(races) do
local f = faction.create("noreply@eressea.de", "human", "de")
assert_not_equal(nil, f)
end
end
function test_can_give_person()
local r = region.create(0, 0, "plain")
local f1 = faction.create("noreply@eressea.de", "human", "de")
local f2 = faction.create("noreply@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 10)
local u2 = unit.create(f2, r, 10)
u1.faction.age = 10
u2.faction.age = 10
u1:add_item("money", 500)
u2:add_item("money", 500)
u2:clear_orders()
u2:add_order("GIB ".. itoa36(u1.id) .. " 1 PERSON")
u2:add_order("HELFE ".. itoa36(f1.id) .. " GIB")
u1:add_order("HELFE ".. itoa36(f2.id) .. " GIB")
u1:add_order("KONTAKTIERE ".. itoa36(u2.id))
process_orders()
assert_equal(9, u2.number)
assert_equal(11, u1.number)
end
function test_no_uruk()
local f1 = faction.create("noreply@eressea.de", "uruk", "de")
assert_equal(f1.race, "orc")
end
function test_snowman()
local r = region.create(0, 0, "glacier")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:add_item("snowman", 1)
u:clear_orders()
u:add_order("BENUTZEN 1 Schneemann")
process_orders()
for u2 in r.units do
if u2.id~=u.id then
assert_equal(u2.race, "snowman")
u = nil
break
end
end
assert_equal(nil, u)
end
function test_block_movement()
eressea.settings.set("rules.guard.base_stop_prob", "0.3")
eressea.settings.set("rules.guard.amulet_stop_prob", "0.0")
eressea.settings.set("rules.guard.skill_stop_prob", "0.1")
local r0 = region.create(0, 0, "plain")
local r1 = region.create(1, 0, "plain")
local r2 = region.create(2, 0, "plain")
local f1, f2 = two_factions()
f1.age=20
f2.age=20
local u11 = one_unit(r1, f1)
local u2 = { }
for i = 1, 20 do
u2[i] = one_unit(r0, f2)
end
u11:add_item("sword", 1)
u11:add_item("money", 1)
u11:set_skill("melee", 1)
u11:set_skill("perception", 7)
u11:clear_orders()
u11:add_order("BEWACHEN")
process_orders()
for i, u in ipairs(u2) do
u:add_item("horse", 1)
u:set_skill("riding", 1)
u:clear_orders()
u:add_order("NACH o o")
end
u2[1]:set_skill("stealth", 8)
process_orders()
assert_equal(r2, u2[1].region, "nobody should see me")
for i, u in ipairs(u2) do
if i > 1 then
assert_equal(r1, u.region, "perception +7 should always stop me")
end
end
end
function test_block_movement_aots()
eressea.settings.set("rules.guard.base_stop_prob", "0.0")
eressea.settings.set("rules.guard.skill_stop_prob", "1.0")
eressea.settings.set("rules.guard.amulet_stop_prob", "1.1")
local r0 = region.create(0, 0, "plain")
local r1 = region.create(1, 0, "plain")
local r2 = region.create(2, 0, "plain")
local f1, f2 = two_factions()
f1.age=20
f2.age=20
local u11, u12 = two_units(r1, f1, f1)
local u21, u22 = two_units(r0, f2, f2)
for i, u in ipairs ({ u11, u12 }) do
u:add_item("sword", 1)
u:add_item("money", 1)
u:set_skill("melee", 1)
u:clear_orders()
u:add_order("BEWACHEN")
end
process_orders()
for i, u in ipairs ({ u21, u22 }) do
u:add_item("horse", 1)
u:set_skill("riding", 1)
u:clear_orders()
u:add_order("NACH o o")
end
u12:add_item("aots", 10)
u22:set_skill("stealth", 1)
process_orders()
assert_equal(r1, u21.region, "unit with amulet should stop me")
assert_equal(r2, u22.region, "nobody should see me")
end
function test_stonegolems()
local r0 = region.create(0, 0, "plain")
local f1 = faction.create("noreply@eressea.de", "stonegolem", "de")
local u1 = unit.create(f1, r0, 1)
local u2 = unit.create(f1, r0, 2)
local c1 = building.create(r0, "castle")
c1.size = 226
u1:set_skill("building", 1)
u2:set_skill("building", 1)
-- test that no server crash occur
u1:clear_orders()
u1:add_order("Mache Burg")
process_orders()
assert_equal(0 ,u1.number, "There shoud be no Stone Golems")
-- end test server crash
-- test that Stone Golems build for four stones
u2:clear_orders()
u2:add_order("MACHE 4 BURG " .. itoa36(c1.id))
process_orders()
assert_equal(230, c1.size, "resulting size should be 230")
assert_equal(1 ,u2.number, "There shoud be one Stone Golems")
-- end test Stone Golems four stones
end
function test_only_building_owner_can_set_not_paid()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u1 = unit.create(f, r, 1)
local u2 = unit.create(f, r, 1)
local mine = building.create(r, "mine")
mine.size = 2
u1:add_item("money", 500)
u1.building = mine
u2.building = mine
u1:clear_orders()
u2:clear_orders()
-- Test that Bezahle nicht is working
u1:add_order("Bezahle nicht")
process_orders()
assert_equal(500, u1:get_item("money"))
u1:clear_orders()
-- Test that bug fix 0001976 is working
-- Bezahle nicht is not working
u2:add_order("Bezahle nicht")
process_orders()
assert_equal(0, u1:get_item("money"))
end

View file

@ -1,16 +0,0 @@
-- require 'eressea.tests.spells'
require 'eressea.tests.common'
require 'eressea.tests.stealth'
-- require 'eressea.tests.spells-e3'
-- require 'eressea.tests.spells-e2'
require 'eressea.tests.settings'
-- require 'eressea.tests.morale'
-- require 'eressea.tests.orders'
-- require 'eressea.tests.eressea'
-- require 'eressea.tests.e3a'
-- require 'eressea.tests.config'
-- require 'eressea.tests.common'
require 'eressea.tests.castles'
require 'eressea.tests.bindings'
-- require 'eressea.tests.bson'
-- require 'eressea.tests.attrib'

View file

@ -1,179 +0,0 @@
require "lunit"
module("tests.eressea.morale", package.seeall, lunit.testcase )
function setup()
eressea.game.reset()
eressea.settings.set('rules.region_owners', '1')
end
function test_when_owner_returns_morale_drops_only_2()
local r = region.create(0, 0, "plain")
assert_equal(1, r.morale)
local f1 = faction.create("noreply@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 1)
u1:add_item("money", 10000)
local b = building.create(r, "castle")
b.size = 50
set_turn(get_turn()+10)
f1.lastturn=get_turn()
u1.building = b
update_owners()
r.morale = 6
u1.building = nil
process_orders()
assert_equal(5, r.morale) -- no owner, fall by 1
u1.building = b
update_owners()
set_key("test", 42)
process_orders()
assert_equal(3, r.morale) -- new owner, fall by 2
end
function test_morale_alliance()
local r = region.create(0, 0, "plain")
assert_equal(1, r.morale)
local f1 = faction.create("noreply@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 1)
u1:add_item("money", 10000)
local f2 = faction.create("noreply@eressea.de", "human", "de")
local u2 = unit.create(f2, r, 1)
u2:add_item("money", 10000)
local f3 = faction.create("noreply@eressea.de", "human", "de")
local u3 = unit.create(f3, r, 1)
u3:add_item("money", 10000)
local al = alliance.create(42, "Die Antwoord")
f1.alliance = al;
f2.alliance = al;
local b = building.create(r, "castle")
b.size = 50
u1.building = b
u2.building = b
u3.building = b
update_owners()
r.morale = 6
local function run_a_turn()
process_orders()
f1.lastturn=get_turn()
f2.lastturn=get_turn()
f3.lastturn=get_turn()
end
-- just checking everything's okay after setup.
run_a_turn()
assert_equal(6, r.morale)
-- change owner, new owner is in the same alliance
u1.building = nil
run_a_turn()
assert_equal(4, r.morale)
-- change owner, new owner is not in the same alliance
u2.building = nil
run_a_turn()
assert_equal(0, r.morale)
end
function test_morale_change()
local r = region.create(0, 0, "plain")
assert_equal(1, r.morale)
local f1 = faction.create("noreply@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 1)
u1:add_item("money", 10000)
local f2 = faction.create("noreply@eressea.de", "human", "de")
local u2 = unit.create(f2, r, 1)
u2:add_item("money", 10000)
local AVG_STEP = 6
local b = building.create(r, "castle")
b.size = 10
u1.building = b
local function run_a_turn()
process_orders()
f1.lastturn=get_turn()
f2.lastturn=get_turn()
end
-- reinhardt-regel: nach 2*AVG_STEP ist moral mindestens einmal gestiegen.
update_owners()
assert_not_equal(r.owner, nil)
for i=1,AVG_STEP*2 do
run_a_turn()
assert_not_equal(r.owner, nil)
end
assert_not_equal(1, r.morale)
-- regel: moral ist nie hoeher als 2 punkte ueber burgen-max.
for i=1,AVG_STEP*4 do
run_a_turn()
end
assert_equal(4, r.morale)
-- auch mit herrscher faellt moral um 1 pro woche, wenn moral > burgstufe
r.morale = 6
run_a_turn()
assert_equal(5, r.morale)
run_a_turn()
assert_equal(4, r.morale)
run_a_turn()
assert_equal(4, r.morale)
-- regel: ohne herrscher fällt die moral jede woche um 1 punkt, bis sie 1 erreicht
u1.building = nil
update_owners()
run_a_turn()
assert_equal(3, r.morale)
run_a_turn()
assert_equal(2, r.morale)
run_a_turn()
assert_equal(1, r.morale)
run_a_turn()
assert_equal(1, r.morale)
-- ohne herrscher ändert sich auch beschissene Moral nicht:
r.morale = 0
run_a_turn()
assert_equal(0, r.morale)
end
function test_morale_old()
local r = region.create(0, 0, "plain")
assert_equal(1, r.morale)
local f1 = faction.create("first@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 1)
local f2 = faction.create("second@eressea.de", "human", "de")
local u2 = unit.create(f2, r, 1)
local b = building.create(r, "castle")
b.size = 10
u1.building = b
u2.building = b
update_owners()
assert_equal(1, r.morale)
r.morale = 5
assert_equal(u1.faction, r.owner)
u1:clear_orders()
u1:add_order("GIB " .. itoa36(u2.id) .. " KOMMANDO")
process_orders()
u1:clear_orders()
assert_equal(r.owner, u2.faction)
assert_equal(3, r.morale) -- 5-MORALE_TRANSFER
for u in r.units do
if u.faction.id==u2.faction.id then
u.building = nil
end
end
update_owners()
assert_equal(r.owner, u1.faction)
assert_equal(0, r.morale)
end
function test_no_uruk()
local f1 = faction.create("noreply@eressea.de", "uruk", "de")
assert_equal(f1.race, "orc")
end

View file

@ -1,13 +0,0 @@
require "lunit"
module("tests.eressea.settings", package.seeall, lunit.testcase )
function setup()
eressea.free_game()
end
function test_settings()
assert_equal(nil, eressea.settings.get("foo"))
eressea.settings.set("foo", "bar")
assert_equal("bar", eressea.settings.get("foo"))
end

View file

@ -1,47 +0,0 @@
require "lunit"
module("eressea.tests.spells.e3", package.seeall, lunit.testcase)
function setup()
eressea.free_game()
eressea.settings.set("magic.fumble.enable", "0")
eressea.settings.set("nmr.removenewbie", "0")
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("rules.peasants.growth", "0")
end
function test_blessedharvest_lasts_n_turn()
eressea.free_game()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "halfling", "de")
local u = unit.create(f, r)
local err = 0
r:set_resource("peasant", 100)
r:set_resource("money", 0)
u:add_item("money", 1000)
u.magic = "gwyrrd"
u.race = "dwarf"
u:set_skill("magic", 20)
u.aura = 200
err = err + u:add_spell("raindance")
err = err + u:add_spell("blessedharvest")
assert_equal(0, err)
u:clear_orders()
u:add_order("ZAUBERE STUFE 3 Regentanz")
assert_equal(0, r:get_resource("money"), 0)
local m = 0
local p = 100
process_orders()
assert_equal(200, r:get_resource("money"))
u:clear_orders()
u:add_order("ARBEITEN")
process_orders()
process_orders()
process_orders()
assert_equal(800, r:get_resource("money"))
process_orders()
assert_equal(900, r:get_resource("money"))
end

View file

@ -2,9 +2,8 @@ local confdir = 'conf/'
if config.install then
confdir = config.install .. '/' .. confdir
end
rules=''
if config.rules then
rules = config.rules .. '/'
read_xml(confdir .. rules .. 'config.xml', confdir .. rules .. 'catalog.xml')
eressea.config.read(rules .. 'config.json', confdir)
local rules = config.rules .. '/'
assert(0 == read_xml(confdir .. rules .. 'config.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?")
assert(0 == eressea.config.read(rules .. 'config.json', confdir), "could not read JSON data")
end

View file

@ -9,7 +9,9 @@ local function read_players()
local str = input:read("*line")
if str==nil then break end
local email, race, lang = str:match("([^ ]*) ([^ ]*) ([^ ]*)")
table.insert(players, { race = race, lang = lang, email = email })
if string.char(string.byte(email, 1))~='#' then
table.insert(players, { race = race, lang = lang, email = email })
end
end
return players
end
@ -20,9 +22,9 @@ local function seed(r, email, race, lang)
equip_unit(u, "new_faction")
equip_unit(u, "first_unit")
equip_unit(u, "first_" .. race, 7) -- disable old callbacks
u:set_skill("perception", 30)
unit.create(f, r, 5):set_skill("mining", 30)
unit.create(f, r, 5):set_skill("quarrying", 30)
f:set_origin(r)
return f
end
@ -41,12 +43,13 @@ local function dump_selection(sel)
end
players = read_players()
local limit = 30000
local peasants = 20000
local trees = 1000
local turn = get_turn()
local sel
if #players > 0 then
eressea.read_game(("%d.dat"):format(turn))
sel = p.select(regions(), limit)
sel = p.select(regions(), peasants, trees)
if #sel > 0 then
local best = dump_selection(sel)
print("finest region, " .. best.score .. " points: " .. tostring(best.r))
@ -64,7 +67,6 @@ for _, p in ipairs(players) do
local index = math.random(#sel)
start = sel[index]
end
create_curse(nil, r, 'holyground', 1, 52)
num_seeded = 0
end
local dupe = false

View file

@ -13,12 +13,11 @@ local function score(r, res)
return peas
end
local function select(regions, limit)
local function select(regions, peasants, trees)
local sel = {}
for r in regions do
if not r.plane and r.terrain~="ocean" and not r.units() then
s = score(r)
if s >= limit then
if score(r, "peasant") >= peasants and score(r, "tree") >= trees then
table.insert(sel, r)
end
end

View file

@ -19,4 +19,4 @@ require 'lunit'
rules = require('eressea.' .. config.rules)
result = lunit.main()
return result.errors
return result.errors + result.failed

View file

@ -20,4 +20,4 @@ require 'lunit'
eressea.settings.set("rules.alliances", "0")
rules = require('eressea.' .. config.rules)
result = lunit.main()
return result.errors
return result.errors + result.failed

View file

@ -14,4 +14,4 @@ require 'eressea.path'
require 'tests'
require 'lunit'
result = lunit.main()
return result.errors
return result.errors + result.failed

View file

@ -142,6 +142,7 @@ function process(rules, orders)
callbacks(rules, 'update')
write_files(config.locales)
dbupdate()
file = '' .. get_turn() .. '.dat'
if eressea.write_game(file)~=0 then
@ -161,9 +162,6 @@ function run_turn(rules)
orderfile = orderfile or config.basepath .. '/orders.' .. turn
eressea.log.debug("executing turn " .. get_turn() .. " with " .. orderfile .. " with rules=" .. config.rules)
local result = process(rules, orderfile)
if result==0 then
dbupdate()
end
return result
end

View file

@ -22,7 +22,7 @@ local function two_factions()
return f1, f2
end
module("tests.eressea.common", package.seeall, lunit.testcase)
module("tests.common", package.seeall, lunit.testcase)
function setup()
eressea.free_game()
@ -31,6 +31,7 @@ function setup()
eressea.settings.set("rules.economy.food", "4")
eressea.settings.set("rules.encounters", "0")
eressea.settings.set("rules.peasants.growth", "1")
eressea.settings.set("study.random_progress", "0")
end
function test_flags()
@ -38,7 +39,7 @@ function test_flags()
local f = faction.create("flags@eressea.de", "halfling", "de")
local u = unit.create(f, r, 1)
local no = itoa36(f.id)
local flags = 587203585
local flags = 50332673
f.flags = flags
eressea.write_game("test.dat")
@ -510,140 +511,118 @@ function test_herbalism()
end
function test_mallorn()
local r = region.create(0, 0, "plain")
r:set_flag(1, false) -- not mallorn
r:set_resource("tree", 100)
assert(r:get_resource("tree")==100)
local m = region.create(0, 0, "plain")
m:set_flag(1, true) -- mallorn
m:set_resource("tree", 100)
assert(m:get_resource("tree")==100)
local f = faction.create("noreply13@eressea.de", "human", "de")
local r = region.create(0, 0, "plain")
r:set_flag(1, false) -- not mallorn
r:set_resource("tree", 100)
assert(r:get_resource("tree")==100)
local m = region.create(0, 0, "plain")
m:set_flag(1, true) -- mallorn
m:set_resource("tree", 100)
assert(m:get_resource("tree")==100)
local u1 = unit.create(f, r, 1)
u1:add_item("money", u1.number * 100)
u1:set_skill("forestry", 2)
u1:clear_orders()
u1:add_order("MACHE HOLZ")
local f = faction.create("noreply13@eressea.de", "human", "de")
local u2 = unit.create(f, m, 1)
u2:add_item("money", u2.number * 100)
u2:set_skill("forestry", 2)
u2:clear_orders()
u2:add_order("MACHE HOLZ")
local u1 = unit.create(f, r, 1)
u1:add_item("money", u1.number * 100)
u1:set_skill("forestry", 2)
u1:clear_orders()
u1:add_order("MACHE HOLZ")
local u3 = unit.create(f, m, 1)
u3:add_item("money", u3.number * 100)
u3:set_skill("forestry", 2)
u3:clear_orders()
u3:add_order("MACHE Mallorn")
process_orders()
assert_equal(2, u1:get_item("log"))
assert_equal(2, u2:get_item("log"))
local mallorn_cfg = config.get_resource("mallorn")
if mallorn_cfg then
assert_equal(1, u3:get_item("mallorn"))
else
assert_equal(-1, u3:get_item("mallorn"))
assert_equal(0, u3:get_item("log"))
end
local u2 = unit.create(f, m, 1)
u2:add_item("money", u2.number * 100)
u2:set_skill("forestry", 2)
u2:clear_orders()
u2:add_order("MACHE HOLZ")
local u3 = unit.create(f, m, 1)
u3:add_item("money", u3.number * 100)
u3:set_skill("forestry", 2)
u3:clear_orders()
u3:add_order("MACHE Mallorn")
process_orders()
assert_equal(2, u1:get_item("log"))
assert_equal(2, u2:get_item("log"))
local mallorn_cfg = config.get_resource("mallorn")
if mallorn_cfg then
assert_equal(1, u3:get_item("mallorn"))
else
assert_equal(-1, u3:get_item("mallorn"))
assert_equal(0, u3:get_item("log"))
end
end
function test_coordinate_translation()
local pl = plane.create(1, 500, 500, 1001, 1001) -- astralraum
local pe = plane.create(1, -8761, 3620, 23, 23) -- eternath
local r = region.create(1000, 1000, "plain")
local f = faction.create("noreply14@eressea.de", "human", "de")
assert_not_equal(nil, r)
assert_equal(r.x, 1000)
assert_equal(r.y, 1000)
local nx, ny = plane.normalize(pl, r.x, r.y)
assert_equal(nx, 1000)
assert_equal(ny, 1000)
local r1 = region.create(500, 500, "plain")
f:set_origin(r1)
nx, ny = f:normalize(r1)
assert_equal(0, nx)
assert_equal(0, ny)
local r0 = region.create(0, 0, "plain")
nx, ny = f:normalize(r0)
assert_equal(0, nx)
assert_equal(0, ny)
nx, ny = f:normalize(r)
assert_equal(500, nx)
assert_equal(500, ny)
local rn = region.create(1010, 1010, "plain")
nx, ny = f:normalize(rn)
assert_equal(-491, nx)
assert_equal(-491, ny)
local pl = plane.create(1, 500, 500, 1001, 1001) -- astralraum
local pe = plane.create(1, -8761, 3620, 23, 23) -- eternath
local r = region.create(1000, 1000, "plain")
local f = faction.create("noreply14@eressea.de", "human", "de")
assert_not_equal(nil, r)
assert_equal(r.x, 1000)
assert_equal(r.y, 1000)
local nx, ny = plane.normalize(pl, r.x, r.y)
assert_equal(nx, 1000)
assert_equal(ny, 1000)
local r1 = region.create(500, 500, "plain")
f:set_origin(r1)
nx, ny = f:normalize(r1)
assert_equal(0, nx)
assert_equal(0, ny)
local r0 = region.create(0, 0, "plain")
nx, ny = f:normalize(r0)
assert_equal(0, nx)
assert_equal(0, ny)
nx, ny = f:normalize(r)
assert_equal(500, nx)
assert_equal(500, ny)
local rn = region.create(1010, 1010, "plain")
nx, ny = f:normalize(rn)
assert_equal(-491, nx)
assert_equal(-491, ny)
local re = region.create(-8760, 3541, "plain") -- eternath
nx, ny = f:normalize(rn)
assert_equal(-491, nx)
assert_equal(-491, ny)
local re = region.create(-8760, 3541, "plain") -- eternath
nx, ny = f:normalize(rn)
assert_equal(-491, nx)
assert_equal(-491, ny)
end
function test_control()
local u1, u2 = two_units(region.create(0, 0, "plain"), two_factions())
local r = u1.region
local b = building.create(r, "castle")
u1.building = b
u2.building = b
assert_equal(u1, b.owner)
u1:clear_orders()
u1:add_order("GIB " .. itoa36(u2.id) .. " KOMMANDO")
u1:add_order("VERLASSE")
process_orders()
assert_equal(u2, b.owner)
end
function test_store_unit()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply15@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
local fid = f.id
u:add_item("money", u.number * 100)
local filename = config.basepath .. "/data/test.dat"
store = storage.create(filename, "wb")
assert_not_equal(store, nil)
store:write_unit(u)
store:close()
eressea.free_game()
-- recreate world:
r = region.create(0, 0, "plain")
f = faction.create("noreply16@eressea.de", "human", "de")
f.id = fid
store = storage.create(filename, "rb")
assert_not_nil(store)
u = store:read_unit()
store:close()
assert(u)
assert(u:get_item("money") == u.number * 100)
local u1, u2 = two_units(region.create(0, 0, "plain"), two_factions())
local r = u1.region
local b = building.create(r, "castle")
u1.building = b
u2.building = b
assert_equal(u1, b.owner)
u1:clear_orders()
u1:add_order("GIB " .. itoa36(u2.id) .. " KOMMANDO")
u1:add_order("VERLASSE")
process_orders()
assert_equal(u2, b.owner)
end
function test_building_other()
local r = region.create(0,0, "plain")
local f1 = faction.create("noreply17@eressea.de", "human", "de")
local f2 = faction.create("noreply18@eressea.de", "human", "de")
local b = building.create(r, "castle")
b.size = 10
local u1 = unit.create(f1, r, 3)
u1.building = b
u1:add_item("money", 100)
local r = region.create(0,0, "plain")
local f1 = faction.create("noreply17@eressea.de", "human", "de")
local f2 = faction.create("noreply18@eressea.de", "human", "de")
local b = building.create(r, "castle")
b.size = 10
local u1 = unit.create(f1, r, 3)
u1.building = b
u1:add_item("money", 100)
local u2 = unit.create(f2, r, 3)
u2:set_skill("building", 10)
u2:add_item("money", 100)
u2:add_item("stone", 100)
u2:clear_orders()
u2:add_order("MACHEN BURG " .. itoa36(b.id))
process_orders()
assert_not_equal(10, b.size)
local u2 = unit.create(f2, r, 3)
u2:set_skill("building", 10)
u2:add_item("money", 100)
u2:add_item("stone", 100)
u2:clear_orders()
u2:add_order("MACHEN BURG " .. itoa36(b.id))
process_orders()
assert_not_equal(10, b.size)
end
-- segfault above
function test_config()
assert_not_equal(nil, config.basepath)
assert_not_equal(nil, config.locales)
@ -789,6 +768,7 @@ function test_expensive_skills_cost_money()
u:add_item("money", 10000)
u:clear_orders()
u:add_order("LERNEN MAGIE Gwyrrd")
assert_equal(0, u:get_skill("magic"))
process_orders()
assert_equal(9900, u:get_item("money"))
assert_equal(1, u:get_skill("magic"))
@ -993,7 +973,6 @@ local function find_in_report(f, pattern, extension)
report:close()
local start, _ = string.find(t, pattern)
-- posix.unlink(filename)
return start~=nil
end
@ -1050,6 +1029,7 @@ function test_coordinates_noname_plane()
end
function test_lighthouse()
eressea.free_game()
local r = region.create(0, 0, "mountain")
local f = faction.create("noreply@eressea.de", "human", "de")
region.create(1, 0, "mountain")
@ -1090,7 +1070,7 @@ function test_parser()
local r = region.create(0, 0, "mountain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
local filename = config.basepath .. "/data/orders.txt"
local filename = "orders.txt"
local file = io.open(filename, "w")
assert_not_nil(file)

View file

@ -36,4 +36,3 @@ function test_read_ship()
s = ship.create(nil, "boat")
assert_not_nil(s)
end

View file

@ -0,0 +1,49 @@
require "lunit"
module("tests.e2.destroy", package.seeall, lunit.testcase)
function setup()
eressea.free_game()
eressea.settings.set("NewbieImmunity", "0")
end
function disabled_test_dont_move_after_destroy()
local r1 = region.create(0, 0, "plain")
local r2 = region.create(1, 0, "plain")
local f = faction.create("test@example.com", "human", "de")
local u = unit.create(f, r1, 1)
u.building = building.create(u.region, "castle")
u:clear_orders()
u:add_order("NACH O")
u:add_order("ZERSTOERE " .. itoa36(u.building.id))
process_orders()
if not u.region then
print("shit happened ", u.number)
end
assert_equal(r1, u.region)
assert_equal(nil, u.building)
end
function test_dont_destroy_after_attack()
local r1 = region.create(0, 0, "plain")
local u = unit.create(faction.create("one@example.com", "human", "de"), r1, 10)
local u2 = unit.create(faction.create("two@example.com", "human", "de"), r1, 1)
u.building = building.create(u.region, "castle")
u:clear_orders()
u:add_order("ATTACKIERE " .. itoa36(u2.id))
u:add_order("ZERSTOERE " .. itoa36(u.building.id))
process_orders()
assert_not_nil(u.building)
end
function test_destroy_is_long()
local r1 = region.create(0, 0, "plain")
local u = unit.create(faction.create("one@example.com", "human", "de"), r1, 10)
u.building = building.create(u.region, "castle")
u:clear_orders()
u:add_order("LERNE Unterhaltung")
u:add_order("ZERSTOERE " .. itoa36(u.building.id))
process_orders()
assert_equal(0, u:get_skill("entertainment"))
assert_equal(nil, u.building)
end

View file

@ -23,6 +23,7 @@ function setup()
eressea.free_game()
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("rules.economy.food", "4")
eressea.settings.set("rules.ship.storms", "0")
end
function test_learn()
@ -107,7 +108,7 @@ function test_ship_capacity()
local r = region.create(0,0, "ocean")
region.create(1,0, "ocean")
local r2 = region.create(2,0, "ocean")
local f = faction.create("noreply@eressea.de", "human", "de")
local f = faction.create("capacity@eressea.de", "human", "de")
-- u1 is at the limit and moves
local s1 = ship.create(r, "boat")

View file

@ -1,4 +1,13 @@
require 'tests.e2.undead'
require 'tests.e2.shiplanding'
require 'tests.e2.e2features'
require 'tests.e2.movement'
require 'tests.e2.destroy'
require 'tests.e2.guard'
require 'tests.e2.spells'
require 'tests.e2.stealth'
require 'tests.orders'
require 'tests.common'
require 'tests.storage'
require 'tests.magicbag'
require 'tests.process'

View file

@ -0,0 +1,42 @@
require "lunit"
module("tests.e2.ships", package.seeall, lunit.testcase)
function setup()
eressea.settings.set("rules.ship.damage.nocrewocean", "0")
eressea.settings.set("rules.ship.damage.nocrew", "0")
eressea.settings.set("rules.ship.drifting", "0")
end
function test_ship_requires_skill()
local r1 = region.create(0, 0, "ocean")
local r2 = region.create(1, 0, "ocean")
local f = faction.create("fake@eressea.de", "human", "de")
local u1 = unit.create(f, r1, 1)
u1.name = "fake"
u1.ship = ship.create(r1, "longboat")
u1:clear_orders()
u1:add_order("NACH O")
process_orders()
assert_equal(r1, u1.ship.region)
assert_equal(r1, u1.region)
end
function no_test_ship_happy_case()
local r1 = region.create(0, 0, "ocean")
local r2 = region.create(1, 0, "ocean")
local f = faction.create("hodor@eressea.de", "human", "de")
local u1 = unit.create(f, r1, 1)
local u2 = unit.create(f, r1, 1)
u1.ship = ship.create(r1, "longboat")
u2.ship = u1.ship
u1:clear_orders()
u1:add_order("NACH O")
u1:set_skill("sailing", 1) -- cptskill = 1
u2:set_skill("sailing", 9) -- sumskill = 10
process_orders()
assert_equal(r2, u1.ship.region)
assert_equal(r2, u1.region)
assert_equal(r2, u2.region)
end

View file

@ -0,0 +1,28 @@
require "lunit"
module("tests.e2.spells", package.seeall, lunit.testcase)
function setup()
eressea.free_game()
eressea.settings.set("nmr.removenewbie", "0")
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("NewbieImmunity", "0")
eressea.settings.set("rules.economy.food", "4")
end
function test_shapeshift()
local r = region.create(42, 0, "plain")
local f = faction.create("noreply@eressea.de", "demon", "de")
local u1 = unit.create(f, r, 1)
local u2 = unit.create(f, r, 1)
u1:clear_orders()
u1.magic = "gray"
u1:set_skill("magic", 2)
u1.aura = 1
u1:add_spell("shapeshift")
u1:add_order("ZAUBERE STUFE 1 Gestaltwandlung " .. itoa36(u2.id) .. " Goblin")
process_orders()
assert_equal(f.race, u2.race)
s = u2:show()
assert_equal("1 Goblin", string.sub(s, string.find(s, "1 Goblin")))
end

View file

@ -1,11 +1,11 @@
require "lunit"
module('eressea.tests.stealth', package.seeall, lunit.testcase)
module('tests.e2.stealth', package.seeall, lunit.testcase)
local f
local u
local settings
local settings = {}
local function set_rule(key, value)
if value==nil then

View file

@ -0,0 +1,31 @@
require "lunit"
module("tests.e2.undead", package.seeall, lunit.testcase)
function setup()
eressea.free_game()
end
function test_undead_give_item()
local r1 = region.create(0, 0, "plain")
local f1 = faction.create("hodor@eressea.de", "human", "de")
local u1 = unit.create(f1, r1, 1)
u1.race = "undead"
u1:clear_orders()
u1:add_item("log", 1)
u1:add_order("GIB 0 1 Holz")
process_orders()
assert_equal(0, u1:get_item("log"))
end
function test_undead_dont_give_person()
local r1 = region.create(0, 0, "plain")
local f1 = faction.create("hodor@eressea.de", "human", "de")
local u1 = unit.create(f1, r1, 2)
u1.race = "undead"
u1:clear_orders()
u1:add_item("log", 1)
u1:add_order("GIB 0 1 Person")
process_orders()
assert_equal(2, u1.number)
end

View file

@ -25,3 +25,28 @@ function test_small_castles()
assert_equal("site", b:get_typename(9))
assert_equal("fortification", b:get_typename(10))
end
function test_build_normal()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:clear_orders()
u:add_item("stone", 10)
u:set_skill("building", 10)
u:add_order("MACHE BURG")
process_orders()
assert_not_nil(u.building)
assert_equal(10, u.building.size)
end
function test_build_packice()
local r = region.create(0, 0, "packice")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:clear_orders()
u:add_item("stone", 10)
u:set_skill("building", 10)
u:add_order("MACHE BURG")
process_orders()
assert_equal(nil, u.building)
end

View file

@ -3,3 +3,8 @@ require 'tests.e3.stealth'
require 'tests.e3.spells'
require 'tests.e3.rules'
require 'tests.e3.parser'
require 'tests.e3.morale'
require 'tests.orders'
require 'tests.common'
require 'tests.magicbag'
require 'tests.process'

View file

@ -3,7 +3,7 @@ require "lunit"
module("tests.e3.morale", package.seeall, lunit.testcase )
function setup()
eressea.free_game()
eressea.game.reset()
end
function test_when_owner_returns_morale_drops_only_2()

View file

@ -76,9 +76,7 @@ function disable_test_market_action()
b.size = 10
u.building = b
update_owners()
for r in regions() do
market_action(r)
end
process.markets()
assert_equal(35, u:get_item("balm"))
assert_equal(70, u:get_item("h2"))
end
@ -148,25 +146,6 @@ function test_no_stealth()
assert_equal(-1, u:get_skill("stealth"))
end
--[[
function test_analyze_magic()
local r1 = region.create(0,0, "plain")
local r2 = region.create(1,0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r2, 1)
u.race = "elf"
u:set_skill("magic", 6)
u.magic = "gwyrrd"
u.aura = 60
u:add_spell("analyze_magic")
u:clear_orders()
u:add_order("Zaubere stufe 2 'Magie analysieren' REGION 1,0")
process_orders()
end
]]--
function test_seecast()
local r = region.create(0,0, "plain")
for i = 1,10 do
@ -481,7 +460,6 @@ function test_canoe_passes_through_land()
u1:add_order("NACH O O O")
process_orders()
assert_equal(land, u2.region, "canoe did not stop at coast")
u1:add_order("NACH O O O")
process_orders()
assert_equal(dst, sh.region, "canoe could not leave coast")
assert_equal(dst, u1.region, "canoe could not leave coast")

View file

@ -58,7 +58,6 @@ function test_magic()
u:add_spell("protective_runes")
u:add_spell("analyze_magic")
u:clear_orders()
u:add_order("ZAUBERE \"Runen des Schutzes\" BURG " .. itoa36(b.id));
u.building = b
u:add_order("ZAUBERE \"Magie analysieren\" BURG " .. itoa36(b.id));
process_orders()

View file

@ -7,3 +7,5 @@ require 'tests.pool'
require 'tests.regions'
require 'tests.settings'
require 'tests.study'
require 'tests.laws'
require 'tests.bindings'

114
scripts/tests/laws.lua Normal file
View file

@ -0,0 +1,114 @@
require "lunit"
module("tests.laws", package.seeall, lunit.testcase)
function setup()
eressea.free_game()
conf = [[{
"races": {
"human" : {}
},
"terrains" : {
"plain": { "flags" : [ "land", "walk", "sail" ] }
},
"keywords" : {
"de": {
"attack" : "ATTACKIERE",
"maketemp" : "MACHETEMP",
"end" : "ENDE",
"recruit" : "REKRUTIERE"
}
},
"buildings" : {
"castle" : {}
}
}]]
eressea.config.reset()
eressea.config.parse(conf)
end
function test_force_leave_on()
local r = region.create(0, 0, "plain")
local f1 = faction.create("owner@eressea.de")
local f2 = faction.create("guest@eressea.de")
local u1 = unit.create(f1, r, 1)
local u2 = unit.create(f2, r, 1)
local b1 = building.create(r, "castle")
u1.building = b1
u2.building = b1
eressea.settings.set("rules.owners.force_leave", "2")
process_orders()
assert_equal(b1, u1.building)
assert_equal(nil, u2.building)
end
function test_force_leave_off()
local r = region.create(0, 0, "plain")
local f1 = faction.create("owner@eressea.de")
local f2 = faction.create("guest@eressea.de")
local u1 = unit.create(f1, r, 1)
local u2 = unit.create(f2, r, 1)
local b1 = building.create(r, "castle")
u1.building = b1
u2.building = b1
eressea.settings.set("rules.owners.force_leave", "0")
process_orders()
assert_equal(b1, u1.building)
assert_equal(b1, u2.building)
end
function test_make_temp()
local r = region.create(0, 0, "plain")
local f1 = faction.create("owner@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 10)
local u, u2
u1.building = building.create(r, "castle")
u1.status = 1
u1:clear_orders()
u1:add_order("MACHETEMP 1 Hodor")
u1:add_order("REKRUTIERE 1")
u1:add_order("ENDE")
process_orders()
for u in r.units do
if u~=u1 then
u2 = u
break
end
end
assert_not_equal(nil, u2)
assert_not_equal(nil, u2.building)
assert_equal(1, u2.number)
assert_equal(1, u2.status)
assert_equal("Hodor", u2.name)
end
function test_force_leave_postcombat()
local r = region.create(0, 0, "plain")
local f1 = faction.create("owner@eressea.de", "human", "de")
local f2 = faction.create("guest@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 10)
local u2 = unit.create(f2, r, 10)
local u, u3
local b1 = building.create(r, "castle")
u1.building = b1
u2.building = b1
eressea.settings.set("rules.owners.force_leave", "1")
u1:clear_orders()
u1:add_order("ATTACKIERE " .. itoa36(u2.id))
u2:clear_orders()
u2:add_order("MACHETEMP 2 Hodor")
u2:add_order("REKRUTIERE 1")
u2:add_order("ENDE")
process_orders()
for u in r.units do
if u~=u1 and u~=u2 then
u3 = u
break
end
end
assert_not_equal(nil, u3)
assert_equal(nil, u3.building)
assert_equal(1, u3.number)
end

View file

@ -0,0 +1,58 @@
require "lunit"
module("tests.magicbag", package.seeall, lunit.testcase)
local u
function setup()
eressea.free_game()
u = unit.create(faction.create("test@example.com", "human", "de"), region.create(0, 0, "plain"), 1)
end
function test_magicbag_weight()
assert_equal(1000, u.weight)
u:add_item("log", 10)
assert_equal(6000, u.weight)
u:add_item("magicbag", 1)
assert_equal(1100, u.weight)
end
function test_magicbag_no_stone()
assert_equal(1000, u.weight)
u:add_item("stone", 1)
assert_equal(7000, u.weight)
u:add_item("magicbag", 1)
assert_equal(7100, u.weight)
end
function test_magicbag_limit_200ge()
assert_equal(1000, u.weight)
u:add_item("log", 100)
assert_equal(51000, u.weight)
u:add_item("magicbag", 1)
assert_equal(31100, u.weight)
end
function test_magicbag_no_carts()
assert_equal(1000, u.weight)
u:add_item("cart", 1)
assert_equal(5000, u.weight)
u:add_item("magicbag", 1)
assert_equal(5100, u.weight)
end
function test_magicbag_no_catapult()
assert_equal(1000, u.weight)
u:add_item("catapult", 1)
assert_equal(11000, u.weight)
u:add_item("magicbag", 1)
assert_equal(11100, u.weight)
end
function test_magicbag_no_horses()
assert_equal(1000, u.weight)
u:add_item("horse", 1)
assert_equal(6000, u.weight)
u:add_item("magicbag", 1)
assert_equal(6100, u.weight)
end

View file

@ -116,27 +116,6 @@ function test_process_make()
assert_equal(1, u:get_item('log'))
end
function test_process_study()
u:add_order("LERNEN Holzfaellen")
eressea.process.update_long_order()
eressea.process.study()
x, y = u.faction:get_origin()
assert_equal(1, u:get_skill('forestry'))
end
function test_process_teach()
eressea.settings.set("study.random_progress", "0")
u:set_skill('forestry', 3)
u2 = _G.unit.create(f, r, 10)
u2:clear_orders()
u2:set_skill('forestry', 1)
u2:add_order("LERNEN Holzfaellen")
u:add_order("LEHREN " .. _G.itoa36(u2.id))
eressea.process.update_long_order()
eressea.process.study()
assert_equal(2, u2:get_skill('forestry'))
end
function test_process_move()
r2 = _G.region.create(1, 0, 'plain')
u:add_order('NACH O')

43
scripts/tests/process.lua Normal file
View file

@ -0,0 +1,43 @@
require "lunit"
module("tests.process", package.seeall, lunit.testcase)
local u, r, f,turn
function setup()
eressea.free_game()
r = region.create(0, 0, "plain")
f = faction.create("bernd@eressea.de", "human", "de")
u = unit.create(f, r, 1)
u:add_item("money", 10)
turn = get_turn()
end
local function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
local function assert_file(filename)
assert_equal(true, file_exists(filename))
os.remove(filename)
end
function test_process_turn()
u:add_order("NUMMER PARTEI 777")
process_orders()
assert_equal(0, init_reports())
assert_equal(0, write_reports())
assert_equal(0, eressea.write_game("test.dat"))
assert_file("data/test.dat")
assert_file("reports/" .. get_turn() .. "-ii.nr")
assert_file("reports/" .. get_turn() .. "-ii.cr")
assert_file("reports/" .. get_turn() .. "-ii.txt")
assert_file("reports/" .. get_turn() .. "-777.nr")
assert_file("reports/" .. get_turn() .. "-777.cr")
assert_file("reports/" .. get_turn() .. "-777.txt")
assert_file("reports/reports.txt")
os.remove("reports")
os.remove("data")
assert_equal(turn+1, get_turn())
end

31
scripts/tests/storage.lua Normal file
View file

@ -0,0 +1,31 @@
require "lunit"
module("tests.storage", package.seeall, lunit.testcase)
function setup()
eressea.free_game()
end
function test_store_unit()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply15@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
local fid = f.id
u:add_item("money", u.number * 100)
local filename = config.basepath .. "/data/test.dat"
store = storage.create(filename, "wb")
assert_not_equal(store, nil)
store:write_unit(u)
store:close()
eressea.free_game()
-- recreate world:
r = region.create(0, 0, "plain")
f = faction.create("noreply16@eressea.de", "human", "de")
f.id = fid
store = storage.create(filename, "rb")
assert_not_nil(store)
u = store:read_unit()
store:close()
assert_not_nil(u)
assert_equal(u:get_item("money"), u.number * 100)
end

View file

@ -6,13 +6,19 @@ function setup()
conf = [[{
"races" : { "human" : {} },
"terrains" : { "plain" : { "flags" : [ "land" ] } },
"keywords" : { "de" : { "study": "LERNEN" } },
"skills" : { "de": { "alchemy" : "Alchemie", "crossbow" : "Armbrust" } },
"keywords" : { "de" : { "study": "LERNEN", "teach": "LEHREN" } },
"skills" : { "de": {
"tactics" : "Taktik",
"alchemy" : "Alchemie",
"crossbow" : "Armbrust"
} },
"spells" : { "fireball" : { "syntax" : "u+" } }
}]]
eressea.game.reset()
eressea.config.reset();
eressea.settings.set('rules.magic.playerschools', '')
eressea.settings.set("rules.economy.food", "4")
eressea.settings.set('study.random_progress', '0')
eressea.config.parse(conf)
end
@ -51,3 +57,62 @@ function test_unit_spells()
assert_equal("fireball", sp.name)
assert_equal(2, sp.level)
end
local function make_teacher(student, f, skill)
f = f or student.faction
local u = unit.create(f, student.region, 1)
u:clear_orders()
u:add_order("LEHRE " .. itoa36(student.id))
u:set_skill(skill or "crossbow", 10)
return u
end
local function make_student(f, r, num, skill)
local u = unit.create(f, r, num or 1)
u:clear_orders()
u:add_order("LERNE " .. (skill or "Armbrust"))
return u
end
function test_study_no_teacher()
local r = region.create(0, 0, "plain")
local f = faction.create("test@example.com", "human", "de")
local u1 = make_student(f, r, 1)
u1:set_skill("crossbow", 1)
process_orders()
assert_equal(1, u1:get_skill("crossbow"))
end
function test_study_with_teacher()
local r = region.create(0, 0, "plain")
local f = faction.create("test@example.com", "human", "de")
local u1 = make_student(f, r, 1)
make_teacher(u1)
u1:set_skill("crossbow", 1)
process_orders()
assert_equal(2, u1:get_skill("crossbow"))
end
function test_study_too_many_students()
local r = region.create(0, 0, "plain")
local f = faction.create("test@example.com", "human", "de")
local u1 = make_student(f, r, 20, "Taktik")
u1.name = "Student"
u1:add_item("money", 201*u1.number)
make_teacher(u1, f, "tactics")
process_orders()
assert_equal(u1.number, u1:get_item("money"))
end
function test_study_multiple_teachers()
local r = region.create(0, 0, "plain")
local f = faction.create("test@example.com", "human", "de")
local u1 = make_student(f, r, 20, "Taktik")
u1.name = "Student"
u1:add_item("money", 201*u1.number)
make_teacher(u1, f, "tactics")
make_teacher(u1, f, "tactics")
process_orders()
assert_equal(u1.number, u1:get_item("money"))
end

View file

@ -513,7 +513,6 @@
<F N="../src/items/speedsail.h"/>
<F N="../src/kernel/spell.h"/>
<F N="../src/kernel/spellbook.h"/>
<F N="../src/kernel/spellid.h"/>
<F N="../src/spells/spells.h"/>
<F N="../src/spy.h"/>
<F N="../src/stdafx.h"/>

37
share/ubuntu-12_04.supp Normal file
View file

@ -0,0 +1,37 @@
# old zlib version
{
zlib1g-dev-1:1.2.3.4.dfsg
Memcheck:Cond
fun:inflateReset2
fun:inflateInit2_
obj:/usr/lib/x86_64-linux-gnu/libxml2.so.2.8.0
fun:__libxml2_xzread
obj:/usr/lib/x86_64-linux-gnu/libxml2.so.2.8.0
fun:xmlParserInputBufferGrow
fun:xmlParserInputGrow
obj:/usr/lib/x86_64-linux-gnu/libxml2.so.2.8.0
fun:xmlParseDocument
obj:/usr/lib/x86_64-linux-gnu/libxml2.so.2.8.0
fun:read_xml
fun:init_data
}
# https://sourceware.org/bugzilla/show_bug.cgi?id=14404
{
glibc-bug-14404-1
Memcheck:Addr8
fun:__GI___strncasecmp_l
fun:____strtod_l_internal
}
{
glibc-bug-14404-2
Memcheck:Cond
fun:__GI___strncasecmp_l
fun:____strtod_l_internal
}
{
glibc-bug-14404-3
Memcheck:Value8
fun:__GI___strncasecmp_l
fun:____strtod_l_internal
}

View file

@ -9,21 +9,35 @@ include_directories (${CRYPTO_INCLUDE_DIR})
include_directories (${QUICKLIST_INCLUDE_DIR})
include_directories (${CUTEST_INCLUDE_DIR})
include_directories (${LUA_INCLUDE_DIR})
include_directories (${TOLUA_INCLUDE_DIR})
include_directories (${BSON_INCLUDE_DIR})
include_directories (${INIPARSER_INCLUDE_DIR})
IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long")
IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wsign-compare -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -DHAVE__BOOL")
elseif(MSVC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4 /WX /MP")
ELSEIF(MSVC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wall /WX /MP")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG
"${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrt.lib")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE
"${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib")
ELSE(CMAKE_COMPILER_IS_GNUCC)
MESSAGE(STATUS "Unknown compiler ${CMAKE_C_COMPILER_ID}")
ENDIF(CMAKE_COMPILER_IS_GNUCC)
ELSE()
MESSAGE(STATUS "unknown compiler ${CMAKE_C_COMPILER_ID}")
ENDIF()
IF(CMAKE_COMPILER_IS_CLANG)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wtautological-compare -Weverything")
MESSAGE(STATUS "compiler is clang: ${CMAKE_C_COMPILER_ID}")
ELSEIF(CMAKE_COMPILER_IS_GCC)
EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
IF (GCC_VERSION VERSION_GREATER 4.9)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wfloat-conversion")
ENDIF()
ENDIF(CMAKE_COMPILER_IS_CLANG)
add_subdirectory(util)
add_subdirectory(kernel)
@ -94,6 +108,7 @@ set (ERESSEA_SRC
spy.c
study.c
summary.c
travelthru.c
monsters.c
wormhole.c
${SPELLS_SRC}
@ -166,6 +181,7 @@ set(TESTS_SRC
vortex.test.c
tests.test.c
reports.test.c
travelthru.test.c
callback.test.c
direction.test.c
economy.test.c
@ -179,7 +195,9 @@ set(TESTS_SRC
skill.test.c
spells.test.c
spy.test.c
study.test.c
upkeep.test.c
spells/magicresistance.test.c
${ATTRIBUTES_TESTS}
${UTIL_TESTS}
${KERNEL_TESTS}

View file

@ -25,6 +25,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <storage.h>
#include <limits.h>
#include <assert.h>
static void
write_movement(const attrib * a, const void *owner, struct storage *store)
{
@ -65,7 +68,9 @@ void set_movement(attrib ** alist, int type)
static int age_speedup(attrib * a)
{
if (a->data.sa[0] > 0) {
a->data.sa[0] = a->data.sa[0] - a->data.sa[1];
assert(a->data.sa[0] - a->data.sa[1] >= SHRT_MIN);
assert(a->data.sa[0] - a->data.sa[1] <= SHRT_MAX);
a->data.sa[0] = (short)(a->data.sa[0] - a->data.sa[1]);
}
return (a->data.sa[0] > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE;
}

View file

@ -194,6 +194,7 @@ static void message_faction(battle * b, faction * f, struct message *m)
{
region *r = b->region;
assert(f);
if (f->battles == NULL || f->battles->r != r) {
struct bmsg *bm = (struct bmsg *)calloc(1, sizeof(struct bmsg));
bm->next = f->battles;
@ -210,6 +211,7 @@ void message_all(battle * b, message * m)
watcher *w;
for (bf = b->factions; bf; bf = bf->next) {
assert(bf->faction);
message_faction(b, bf->faction, m);
}
if (p)
@ -307,7 +309,7 @@ fighter *select_corpse(battle * b, fighter * af)
maxcasualties += s->casualties;
}
}
di = rng_int() % maxcasualties;
di = (int)(rng_int() % maxcasualties);
for (s = b->sides; s != b->sides + b->nsides; ++s) {
for (df = s->fighters; df; df = df->next) {
/* Geflohene haben auch 0 hp, dürfen hier aber nicht ausgewählt
@ -431,7 +433,7 @@ static int get_row(const side * s, int row, const side * vs)
return result;
}
int get_unitrow(const fighter * af, const side * vs)
static int get_unitrow(const fighter * af, const side * vs)
{
int row = statusrow(af->status);
if (vs == NULL) {
@ -487,7 +489,7 @@ contest_classic(int skilldiff, const armor_type * ar, const armor_type * sh)
vw = (int)(100 - ((100 - vw) * mod));
do {
p = rng_int() % 100;
p = (int)(rng_int() % 100);
vw -= p;
} while (vw >= 0 && p >= 90);
return (vw <= 0);
@ -901,7 +903,9 @@ static void rmtroop(troop dt)
rmfighter(df, 1);
assert(dt.index >= 0 && dt.index < df->unit->number);
df->person[dt.index] = df->person[df->alive - df->removed];
if (dt.index!=df->alive-df->removed) {
df->person[dt.index] = df->person[df->alive - df->removed];
}
if (df->removed) {
df->person[df->alive - df->removed] = df->person[df->alive];
}
@ -1019,7 +1023,8 @@ static int natural_armor(unit * du)
static int *bonus = 0;
int an = u_race(du)->armor;
if (bonus == 0) {
bonus = calloc(sizeof(int), num_races);
assert(num_races > 0);
bonus = calloc((size_t)num_races, sizeof(int));
}
if (bonus[u_race(du)->index] == 0) {
bonus[u_race(du)->index] =
@ -1506,7 +1511,7 @@ troop select_enemy(fighter * af, int minrow, int maxrow, int select)
if (enemies <= 0)
return no_troop;
selected = rng_int() % enemies;
selected = (int)(rng_int() % enemies);
for (si = 0; as->enemies[si]; ++si) {
side *ds = as->enemies[si];
fighter *df;
@ -1674,6 +1679,12 @@ static void report_failed_spell(struct battle * b, struct unit * mage, const str
msg_release(m);
}
static castorder * create_castorder_combat(castorder *co, fighter *fig, const spell * sp, int level, double force) {
co = create_castorder(co, fig->unit, 0, sp, fig->unit->region, level, force, 0, 0, 0);
co->magician.fig = fig;
return co;
}
void do_combatmagic(battle * b, combatmagic_t was)
{
side *s;
@ -1684,6 +1695,42 @@ void do_combatmagic(battle * b, combatmagic_t was)
memset(spellranks, 0, sizeof(spellranks));
#ifdef FFL_CURSED
if (was == DO_PRECOMBATSPELL) {
for (s = b->sides; s != b->sides + b->nsides; ++s) {
fighter *fig = 0;
if (s->bf->attacker) {
spell *sp = find_spell("igjarjuk");
if (sp && fval(s->faction, FFL_CURSED)) {
int si;
for (si = 0; s->enemies[si]; ++si) {
side *se = s->enemies[si];
if (se && !fval(se->faction, FFL_NPC)) {
fighter *fi;
for (fi = se->fighters; fi; fi = fi->next) {
if (fi && (!fig || fig->unit->number > fi->unit->number)) {
fig = fi;
if (fig->unit->number == 1) {
break;
}
}
}
if (fig && fig->unit->number == 1) {
break;
}
}
}
if (fig) {
co = create_castorder_combat(0, fig, sp, 10, 10);
co->magician.fig = fig;
add_castorder(&spellranks[sp->rank], co);
break;
}
}
}
}
}
#endif
for (s = b->sides; s != b->sides + b->nsides; ++s) {
fighter *fig;
for (fig = s->fighters; fig; fig = fig->next) {
@ -1694,7 +1741,7 @@ void do_combatmagic(battle * b, combatmagic_t was)
level = eff_skill(mage, SK_MAGIC, r);
if (level > 0) {
float power;
double power;
const spell *sp;
const struct locale *lang = mage->faction->locale;
order *ord;
@ -1741,8 +1788,7 @@ void do_combatmagic(battle * b, combatmagic_t was)
pay_spell(mage, sp, level, 1);
}
else {
co = create_castorder(0, fig->unit, 0, sp, r, level, power, 0, 0, 0);
co->magician.fig = fig;
co = create_castorder_combat(0, fig, sp, level, power);
add_castorder(&spellranks[sp->rank], co);
}
}
@ -1770,12 +1816,11 @@ void do_combatmagic(battle * b, combatmagic_t was)
}
}
static int cast_combatspell(troop at, const spell * sp, int level, float force)
static int cast_combatspell(troop at, const spell * sp, int level, double force)
{
castorder co;
create_castorder(&co, at.fighter->unit, 0, sp, at.fighter->unit->region, level, force, 0, 0, 0);
co.magician.fig = at.fighter;
create_castorder_combat(&co, at.fighter, sp, level, force);
level = sp->cast(&co);
free_castorder(&co);
if (level > 0) {
@ -1793,7 +1838,7 @@ static void do_combatspell(troop at)
region *r = b->region;
quicklist *ql;
int level, qi;
float power;
double power;
int fumblechance = 0;
order *ord;
int sl;
@ -1866,9 +1911,8 @@ static void do_extra_spell(troop at, const att * a)
log_error("spell '%s' has no function.\n", sp->sname);
}
else {
int level = a->level;
assert(a->level > 0);
cast_combatspell(at, sp, level, level * MagicPower());
cast_combatspell(at, sp, a->level, a->level);
}
}
@ -2294,7 +2338,6 @@ void do_attack(fighter * af)
/* Wir suchen eine beliebige Feind-Einheit aus. An der können
* wir feststellen, ob noch jemand da ist. */
int apr, attacks = attacks_per_round(ta);
assert(attacks <= RACE_ATTACKS);
if (!count_enemies(b, af, FIGHT_ROW, LAST_ROW, SELECT_FIND))
break;
@ -2337,8 +2380,9 @@ void do_regenerate(fighter * af)
ta.index = af->fighting;
while (ta.index--) {
af->person[ta.index].hp += effskill(au, SK_STAMINA);
af->person[ta.index].hp = _min(unit_max_hp(au), af->person[ta.index].hp);
struct person *p = af->person + ta.index;
p->hp += effskill(au, SK_STAMINA);
p->hp = _min(unit_max_hp(au), p->hp);
}
}
@ -2468,7 +2512,7 @@ troop select_ally(fighter * af, int minrow, int maxrow, int allytype)
if (!allies) {
return no_troop;
}
allies = rng_int() % allies;
allies = (int)(rng_int() % allies);
for (ds = b->sides; ds != b->sides + b->nsides; ++ds) {
if ((allytype == ALLY_ANY && helping(as, ds)) || (allytype == ALLY_SELF
@ -2496,7 +2540,7 @@ troop select_ally(fighter * af, int minrow, int maxrow, int allytype)
static int loot_quota(const unit * src, const unit * dst,
const item_type * type, int n)
{
static float divisor = -1;
static double divisor = -1;
if (dst && src && src->faction != dst->faction) {
if (divisor < 0) {
divisor = get_param_flt(global.parameters, "rules.items.loot_divisor", 1);
@ -2527,8 +2571,8 @@ static void loot_items(fighter * corpse)
return;
while (itm) {
float lootfactor = dead / (float)u->number; /* only loot the dead! */
int maxloot = (int)(itm->number * lootfactor);
float lootfactor = (float)dead / (float)u->number; /* only loot the dead! */
int maxloot = (int)((float)itm->number * lootfactor);
if (maxloot > 0) {
int i = _min(10, maxloot);
for (; i != 0; --i) {
@ -2863,7 +2907,7 @@ static void aftermath(battle * b)
float dmg =
get_param_flt(global.parameters, "rules.ship.damage.battleround",
0.05F);
damage_ship(sh, dmg * n);
damage_ship(sh, dmg * (float)n);
freset(sh, SF_DAMAGED);
}
}
@ -2964,21 +3008,16 @@ static void print_header(battle * b)
side *s;
char *bufp = zText;
size_t size = sizeof(zText) - 1;
int bytes;
for (s = b->sides; s != b->sides + b->nsides; ++s) {
fighter *df;
for (df = s->fighters; df; df = df->next) {
if (is_attacker(df)) {
if (first) {
bytes = (int)strlcpy(bufp, ", ", size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bufp = STRLCPY(bufp, ", ", size);
}
if (lastf) {
bytes = (int)strlcpy(bufp, (const char *)lastf, size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bufp = STRLCPY(bufp, lastf, size);
first = true;
}
if (seematrix(f, s))
@ -2990,20 +3029,12 @@ static void print_header(battle * b)
}
}
if (first) {
bytes = (int)strlcpy(bufp, " ", size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bytes = (int)strlcpy(bufp, (const char *)LOC(f->locale, "and"), size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bytes = (int)strlcpy(bufp, " ", size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bufp = STRLCPY(bufp, " ", size);
bufp = STRLCPY(bufp, LOC(f->locale, "and"), size);
bufp = STRLCPY(bufp, " ", size);
}
if (lastf) {
bytes = (int)strlcpy(bufp, (const char *)lastf, size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bufp = STRLCPY(bufp, lastf, size);
}
m = msg_message("battle::starters", "factions", zText);
@ -3176,7 +3207,7 @@ side * get_side(battle * b, const struct unit * u)
return 0;
}
side * find_side(battle * b, const faction * f, const group * g, int flags, const faction * stealthfaction)
side * find_side(battle * b, const faction * f, const group * g, unsigned int flags, const faction * stealthfaction)
{
side * s;
static int rule_anon_battle = -1;
@ -3186,8 +3217,8 @@ side * find_side(battle * b, const faction * f, const group * g, int flags, cons
}
for (s = b->sides; s != b->sides + b->nsides; ++s) {
if (s->faction == f && s->group == g) {
int s1flags = flags | SIDE_HASGUARDS;
int s2flags = s->flags | SIDE_HASGUARDS;
unsigned int s1flags = flags | SIDE_HASGUARDS;
unsigned int s2flags = s->flags | SIDE_HASGUARDS;
if (rule_anon_battle && s->stealthfaction != stealthfaction) {
continue;
}
@ -3205,7 +3236,6 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
weapon weapons[WMAX];
int owp[WMAX];
int dwp[WMAX];
int w = 0;
region *r = b->region;
item *itm;
fighter *fig = NULL;
@ -3230,7 +3260,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
}
/* Illusionen und Zauber kaempfen nicht */
if (fval(u_race(u), RCF_ILLUSIONARY) || idle(u->faction) || u->number == 0) {
if (fval(u_race(u), RCF_ILLUSIONARY) || u->number == 0) {
return NULL;
}
if (s1 == NULL) {
@ -3271,7 +3301,8 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
fig->catmsg = -1;
/* Freigeben nicht vergessen! */
fig->person = (struct person*)calloc(fig->alive, sizeof(struct person));
assert(fig->alive > 0);
fig->person = (struct person*)calloc((size_t)fig->alive, sizeof(struct person));
h = u->hp / u->number;
assert(h);
@ -3330,7 +3361,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
/* Für alle Waffengattungen wird bestimmt, wie viele der Personen mit
* ihr kämpfen könnten, und was ihr Wert darin ist. */
if (u_race(u)->battle_flags & BF_EQUIPMENT) {
int oi = 0, di = 0;
int oi = 0, di = 0, w = 0;
for (itm = u->items; itm && w != WMAX; itm = itm->next) {
const weapon_type *wtype = resource2weapon(itm->type->rtype);
if (wtype == NULL || itm->number == 0)
@ -3345,8 +3376,9 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
}
assert(w != WMAX);
}
fig->weapons = (weapon *)calloc(sizeof(weapon), w + 1);
memcpy(fig->weapons, weapons, w * sizeof(weapon));
assert(w >= 0);
fig->weapons = (weapon *)calloc(sizeof(weapon), (size_t)(w + 1));
memcpy(fig->weapons, weapons, (size_t)w * sizeof(weapon));
for (i = 0; i != w; ++i) {
int j, o = 0, d = 0;
@ -3485,7 +3517,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
int rnd;
do {
rnd = rng_int() % 100;
rnd = (int)(rng_int() % 100);
if (rnd >= 40 && rnd <= 69)
p_bonus += 1;
else if (rnd <= 89)
@ -3659,6 +3691,24 @@ static void free_fighter(fighter * fig)
}
static void battle_free(battle * b) {
side *s;
assert(b);
for (s = b->sides; s != b->sides + b->nsides; ++s) {
fighter *fnext = s->fighters;
while (fnext) {
fighter *fig = fnext;
fnext = fig->next;
free_fighter(fig);
free(fig);
}
free_side(s);
}
free(b);
}
void free_battle(battle * b)
{
int max_fac_no = 0;
@ -3715,7 +3765,6 @@ static int battle_report(battle * b)
faction *fac = bf->faction;
char buf[32 * MAXSIDES];
char *bufp = buf;
int bytes;
size_t size = sizeof(buf) - 1;
message *m;
@ -3738,34 +3787,24 @@ static int battle_report(battle * b)
char buffer[32];
if (komma) {
bytes = (int)strlcpy(bufp, ", ", size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bufp = STRLCPY(bufp, ", ", size);
}
slprintf(buffer, sizeof(buffer), "%s %2d(%s): ",
loc_army, army_index(s), abbrev);
bytes = (int)strlcpy(bufp, buffer, size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bufp = STRLCPY(bufp, buffer, size);
for (r = FIGHT_ROW; r != NUMROWS; ++r) {
if (alive[r]) {
if (l != FIGHT_ROW) {
bytes = (int)strlcpy(bufp, "+", size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bufp = STRLCPY(bufp, "+", size);
}
while (k--) {
bytes = (int)strlcpy(bufp, "0+", size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bufp = STRLCPY(bufp, "0+", size);
}
sprintf(buffer, "%d", alive[r]);
bytes = (int)strlcpy(bufp, buffer, size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bufp = STRLCPY(bufp, buffer, size);
k = 0;
l = r + 1;
@ -3924,7 +3963,6 @@ static bool start_battle(region * r, battle ** bp)
unit *u;
bool fighting = false;
/* list_foreach geht nicht, wegen flucht */
for (u = r->units; u != NULL; u = u->next) {
if (fval(u, UFL_LONGACTION))
continue;
@ -4186,8 +4224,6 @@ static void battle_flee(battle * b)
default:
if ((fig->person[dt.index].flags & FL_HIT) == 0)
continue;
if (b->turn <= 1)
continue;
if (fig->person[dt.index].hp <= runhp)
break;
if (fig->person[dt.index].flags & FL_PANICED) {
@ -4214,6 +4250,52 @@ static void battle_flee(battle * b)
}
}
static bool is_enemy(battle *b, unit *u1, unit *u2) {
if (u1->faction != u2->faction) {
if (b) {
side *es, *s1 = 0, *s2 = 0;
for (es = b->sides; es != b->sides + b->nsides; ++es) {
if (!s1 && es->faction == u1->faction) s1 = es;
else if (!s2 && es->faction == u2->faction) s2 = es;
if (s1 && s2) break;
}
return enemy(s1, s2);
}
else {
return !help_enter(u1, u2);
}
}
return false;
}
void force_leave(region *r, battle *b) {
unit *u;
for (u = r->units; u; u = u->next) {
unit *uo = NULL;
if (u->building) {
uo = building_owner(u->building);
}
if (u->ship && r->land) {
uo = ship_owner(u->ship);
}
if (uo && is_enemy(b, uo, u)) {
message *msg = NULL;
if (u->building) {
msg = msg_message("force_leave_building", "unit owner building", u, uo, u->building);
}
else {
msg = msg_message("force_leave_ship", "unit owner ship", u, uo, u->ship);
}
if (msg) {
ADDMSG(&u->faction->msgs, msg);
}
leave(u, false);
}
}
}
void do_battle(region * r)
{
battle *b = NULL;
@ -4285,6 +4367,9 @@ void do_battle(region * r)
/* Auswirkungen berechnen: */
aftermath(b);
if (rule_force_leave(FORCE_LEAVE_POSTCOMBAT)) {
force_leave(b->region, b);
}
/* Hier ist das Gefecht beendet, und wir können die
* Hilfsstrukturen * wieder löschen: */
@ -4293,21 +4378,3 @@ void do_battle(region * r)
}
}
void battle_free(battle * b) {
side *s;
assert(b);
for (s = b->sides; s != b->sides + b->nsides; ++s) {
fighter *fnext = s->fighters;
while (fnext) {
fighter *fig = fnext;
fnext = fig->next;
free_fighter(fig);
free(fig);
}
free_side(s);
}
free(b);
}

View file

@ -130,13 +130,13 @@ extern "C" {
} weapon;
/*** fighter::person::flags ***/
#define FL_TIRED 1
#define FL_TIRED 1
#define FL_DAZZLED 2 /* durch Untote oder Dämonen eingeschüchtert */
#define FL_PANICED 4
#define FL_COURAGE 8 /* Helden fliehen nie */
#define FL_SLEEPING 16
#define FL_STUNNED 32 /* eine Runde keinen Angriff */
#define FL_HIT 64 /* the person at attacked */
#define FL_STUNNED 32 /* eine Runde keinen Angriff */
#define FL_HIT 64 /* the person at attacked */
typedef struct troop {
struct fighter *fighter;
@ -225,9 +225,7 @@ extern "C" {
extern const troop no_troop;
/* BEGIN battle interface */
void battle_init(battle * b);
void battle_free(battle * b);
side * find_side(battle * b, const struct faction * f, const struct group * g, int flags, const struct faction * stealthfaction);
side * find_side(battle * b, const struct faction * f, const struct group * g, unsigned int flags, const struct faction * stealthfaction);
side * get_side(battle * b, const struct unit * u);
fighter * get_fighter(battle * b, const struct unit * u);
/* END battle interface */
@ -251,11 +249,10 @@ extern "C" {
extern int hits(troop at, troop dt, weapon * awp);
extern void damage_building(struct battle *b, struct building *bldg,
int damage_abs);
extern struct quicklist *fighters(struct battle *b, const struct side *vs,
struct quicklist *fighters(struct battle *b, const struct side *vs,
int minrow, int maxrow, int mask);
extern int count_allies(const struct side *as, int minrow, int maxrow,
int count_allies(const struct side *as, int minrow, int maxrow,
int select, int allytype);
extern int get_unitrow(const struct fighter *af, const struct side *vs);
extern bool helping(const struct side *as, const struct side *ds);
extern void rmfighter(fighter * df, int i);
extern struct fighter *select_corpse(struct battle *b, struct fighter *af);
@ -273,6 +270,7 @@ extern "C" {
const struct group * g, unsigned int flags,
const struct faction * stealthfaction);
int skilldiff(troop at, troop dt, int dist);
void force_leave(struct region *r, struct battle *b);
#ifdef __cplusplus
}

View file

@ -1,4 +1,4 @@
/*
/*
+-------------------+
| | Enno Rehling <enno@eressea.de>
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
@ -20,6 +20,7 @@ without prior permission by the authors of Eressea.
#include <kernel/building.h>
#include <kernel/region.h>
#include <util/log.h>
#include <util/language.h>
#include <tolua.h>
@ -114,7 +115,7 @@ static int tolua_building_set_name(lua_State * L)
static int tolua_building_get_size(lua_State * L)
{
building *self = (building *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, self->size);
lua_pushinteger(L, self->size);
return 1;
}
@ -145,7 +146,7 @@ static int tolua_building_get_units(lua_State * L)
static int tolua_building_get_id(lua_State * L)
{
building *self = (building *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->no);
lua_pushinteger(L, self->no);
return 1;
}
@ -190,6 +191,12 @@ static int tolua_building_create(lua_State * L)
{
region *r = (region *)tolua_tousertype(L, 1, 0);
const char *bname = tolua_tostring(L, 2, 0);
if (!r) {
log_error("building.create expects a region as argument 1");
}
if (!bname) {
log_error("building.create expects a name as argument 2");
}
if (bname) {
const building_type *btype = bt_find(bname);
if (btype) {

View file

@ -47,7 +47,7 @@ static int tolua_dict_get(lua_State * L)
lua_pushnil(L);
break;
case TINTEGER:
lua_pushnumber(L, (lua_Number)val.i);
lua_pushinteger(L, val.i);
break;
case TREAL:
lua_pushnumber(L, (lua_Number)val.f);

View file

@ -77,35 +77,35 @@ int tolua_faction_add_item(lua_State * L)
result = i ? i->number : 0;
} /* if (itype!=NULL) */
}
lua_pushnumber(L, result);
lua_pushinteger(L, result);
return 1;
}
static int tolua_faction_get_maxheroes(lua_State * L)
{
faction *self = (faction *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)maxheroes(self));
lua_pushinteger(L, maxheroes(self));
return 1;
}
static int tolua_faction_get_heroes(lua_State * L)
{
faction *self = (faction *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)countheroes(self));
lua_pushinteger(L, countheroes(self));
return 1;
}
static int tolua_faction_get_score(lua_State * L)
{
faction *self = (faction *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->score);
lua_pushinteger(L, self->score);
return 1;
}
static int tolua_faction_get_id(lua_State * L)
{
faction *self = (faction *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->no);
lua_pushinteger(L, self->no);
return 1;
}
@ -148,7 +148,7 @@ static int tolua_faction_set_magic(lua_State * L)
static int tolua_faction_get_age(lua_State * L)
{
faction *self = (faction *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->age);
lua_pushinteger(L, self->age);
return 1;
}
@ -163,7 +163,7 @@ static int tolua_faction_set_age(lua_State * L)
static int tolua_faction_get_flags(lua_State * L)
{
faction *self = (faction *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->flags);
lua_pushinteger(L, self->flags);
return 1;
}
@ -178,7 +178,7 @@ static int tolua_faction_set_flags(lua_State * L)
static int tolua_faction_get_options(lua_State * L)
{
faction *self = (faction *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->options);
lua_pushinteger(L, self->options);
return 1;
}
@ -193,7 +193,7 @@ static int tolua_faction_set_options(lua_State * L)
static int tolua_faction_get_lastturn(lua_State * L)
{
faction *self = (faction *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->lastorders);
lua_pushinteger(L, self->lastorders);
return 1;
}
@ -245,7 +245,7 @@ static int tolua_faction_get_policy(lua_State * L)
}
}
tolua_pushnumber(L, (lua_Number)result);
lua_pushinteger(L, result);
return 1;
}
@ -282,9 +282,9 @@ static int tolua_faction_normalize(lua_State * L)
plane *pl = rplane(r);
int nx = r->x, ny = r->y;
pnormalize(&nx, &ny, pl);
adjust_coordinates(f, &nx, &ny, pl, r);
tolua_pushnumber(L, (lua_Number)nx);
tolua_pushnumber(L, (lua_Number)ny);
adjust_coordinates(f, &nx, &ny, pl);
lua_pushinteger(L, nx);
lua_pushinteger(L, ny);
return 2;
}
return 0;
@ -297,7 +297,7 @@ static int tolua_faction_set_origin(lua_State * L)
plane *pl = rplane(r);
int id = pl ? pl->id : 0;
set_origin(f, id, r->x - plane_center_x(pl), r->y - plane_center_y(pl));
faction_setorigin(f, id, r->x - plane_center_x(pl), r->y - plane_center_y(pl));
return 0;
}
@ -319,8 +319,8 @@ static int tolua_faction_get_origin(lua_State * L)
y = 0;
}
tolua_pushnumber(L, (lua_Number)x);
tolua_pushnumber(L, (lua_Number)y);
lua_pushinteger(L, x);
lua_pushinteger(L, y);
return 2;
}
@ -443,7 +443,7 @@ static int tolua_faction_set_name(lua_State * L)
static int tolua_faction_get_uid(lua_State * L)
{
faction *f = (faction *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, f->subscription);
lua_pushinteger(L, f->subscription);
return 1;
}

View file

@ -152,8 +152,8 @@ static int tolua_make_island(lua_State * L)
int s = (int)tolua_tonumber(L, 3, 0);
int n = (int)tolua_tonumber(L, 4, s / 3);
n = build_island_e3(x, y, n, s);
tolua_pushnumber(L, n);
n = build_island_e3(NULL, x, y, n, s);
lua_pushinteger(L, n);
return 1;
}
@ -166,8 +166,8 @@ static void lua_paint_info(struct window *wnd, const struct state *st)
int nx = st->cursor.x, ny = st->cursor.y;
pnormalize(&nx, &ny, st->cursor.pl);
lua_rawgeti(L, LUA_REGISTRYINDEX, paint_handle);
tolua_pushnumber(L, nx);
tolua_pushnumber(L, ny);
lua_pushinteger(L, nx);
lua_pushinteger(L, ny);
if (lua_pcall(L, 2, 1, 0) != 0) {
const char *error = lua_tostring(L, -1);
log_error("paint function failed: %s\n", error);

View file

@ -214,7 +214,7 @@ static int tolua_msg_set_string(lua_State * L)
const char *param = tolua_tostring(L, 2, 0);
const char *value = tolua_tostring(L, 3, 0);
int result = msg_set_string(lmsg, param, value);
tolua_pushnumber(L, (lua_Number)result);
lua_pushinteger(L, result);
return 1;
}
@ -224,7 +224,7 @@ static int tolua_msg_set_int(lua_State * L)
const char *param = tolua_tostring(L, 2, 0);
int value = (int)tolua_tonumber(L, 3, 0);
int result = msg_set_int(lmsg, param, value);
tolua_pushnumber(L, (lua_Number)result);
lua_pushinteger(L, result);
return 1;
}
@ -234,7 +234,7 @@ static int tolua_msg_set_resource(lua_State * L)
const char *param = tolua_tostring(L, 2, 0);
const char *value = tolua_tostring(L, 3, 0);
int result = msg_set_resource(lmsg, param, value);
tolua_pushnumber(L, (lua_Number)result);
lua_pushinteger(L, result);
return 1;
}
@ -244,7 +244,7 @@ static int tolua_msg_set_unit(lua_State * L)
const char *param = tolua_tostring(L, 2, 0);
unit *value = (unit *)tolua_tousertype(L, 3, 0);
int result = msg_set_unit(lmsg, param, value);
tolua_pushnumber(L, (lua_Number)result);
lua_pushinteger(L, result);
return 1;
}
@ -254,7 +254,7 @@ static int tolua_msg_set_region(lua_State * L)
const char *param = tolua_tostring(L, 2, 0);
region *value = (region *)tolua_tousertype(L, 3, 0);
int result = msg_set_region(lmsg, param, value);
tolua_pushnumber(L, (lua_Number)result);
lua_pushinteger(L, result);
return 1;
}
@ -270,7 +270,7 @@ static int tolua_msg_set(lua_State * L)
else if (tolua_isusertype(L, 3, TOLUA_CAST "unit", 0, &err)) {
return tolua_msg_set_unit(L);
}
tolua_pushnumber(L, (lua_Number)-1);
lua_pushinteger(L, -1);
return 1;
}
@ -279,7 +279,7 @@ static int tolua_msg_send_region(lua_State * L)
lua_message *lmsg = (lua_message *)tolua_tousertype(L, 1, 0);
region *r = (region *)tolua_tousertype(L, 2, 0);
int result = msg_send_region(lmsg, r);
tolua_pushnumber(L, (lua_Number)result);
lua_pushinteger(L, result);
return 1;
}
@ -293,7 +293,7 @@ static int tolua_msg_report_action(lua_State * L)
lmsg->msg = msg_create(lmsg->mtype, lmsg->args);
}
result = report_action(r, u, lmsg->msg, flags);
tolua_pushnumber(L, (lua_Number)result);
lua_pushinteger(L, result);
return 1;
}
@ -303,7 +303,7 @@ static int tolua_msg_send_faction(lua_State * L)
faction *f = (faction *)tolua_tousertype(L, 2, 0);
if (f && lmsg) {
int result = msg_send_faction(lmsg, f);
tolua_pushnumber(L, (lua_Number)result);
lua_pushinteger(L, result);
return 1;
}
return 0;

View file

@ -21,7 +21,7 @@ static int tolua_levitate_ship(lua_State * L)
float power = (float)tolua_tonumber(L, 3, 0);
int duration = (int)tolua_tonumber(L, 4, 0);
int cno = levitate_ship(sh, mage, power, duration);
tolua_pushnumber(L, (lua_Number)cno);
lua_pushinteger(L, cno);
return 1;
}

View file

@ -159,7 +159,7 @@ void process_quit(void) {
void process_study(void) {
process_cmd(K_TEACH, teach_cmd, PROC_LONG_ORDER);
process_cmd(K_STUDY, learn_cmd, PROC_LONG_ORDER);
process_cmd(K_STUDY, study_cmd, PROC_LONG_ORDER);
}
void process_movement(void) {

View file

@ -62,7 +62,7 @@ int tolua_regionlist_next(lua_State * L)
static int tolua_region_get_id(lua_State * L)
{
region *self = (region *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->uid);
lua_pushinteger(L, self->uid);
return 1;
}
@ -85,14 +85,14 @@ static int tolua_region_set_blocked(lua_State * L)
static int tolua_region_get_x(lua_State * L)
{
region *self = (region *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->x);
lua_pushinteger(L, self->x);
return 1;
}
static int tolua_region_get_y(lua_State * L)
{
region *self = (region *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->y);
lua_pushinteger(L, self->y);
return 1;
}
@ -199,7 +199,7 @@ static int tolua_region_set_name(lua_State * L)
static int tolua_region_get_morale(lua_State * L)
{
region *r = (region *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, region_get_morale(r));
lua_pushinteger(L, region_get_morale(r));
return 1;
}
@ -323,7 +323,7 @@ static int tolua_region_get_resourcelevel(lua_State * L)
const rawmaterial *rm;
for (rm = r->resources; rm; rm = rm->next) {
if (rm->type->rtype == rtype) {
tolua_pushnumber(L, (lua_Number)rm->level);
lua_pushinteger(L, rm->level);
return 1;
}
}
@ -389,7 +389,7 @@ static int tolua_region_get_resource(lua_State * L)
}
}
tolua_pushnumber(L, (lua_Number)result);
lua_pushinteger(L, result);
return 1;
}
@ -524,7 +524,7 @@ static int tolua_region_get_age(lua_State * L)
region *self = (region *)tolua_tousertype(L, 1, 0);
if (self) {
lua_pushnumber(L, self->age);
lua_pushinteger(L, self->age);
return 1;
}
return 0;
@ -613,7 +613,7 @@ static int tolua_plane_set_name(lua_State * L)
static int tolua_plane_get_id(lua_State * L)
{
plane *self = (plane *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->id);
lua_pushinteger(L, self->id);
return 1;
}
@ -623,8 +623,8 @@ static int tolua_plane_normalize(lua_State * L)
int x = (int)tolua_tonumber(L, 2, 0);
int y = (int)tolua_tonumber(L, 3, 0);
pnormalize(&x, &y, self);
tolua_pushnumber(L, (lua_Number)x);
tolua_pushnumber(L, (lua_Number)y);
lua_pushinteger(L, x);
lua_pushinteger(L, y);
return 2;
}
@ -638,8 +638,8 @@ static int tolua_plane_tostring(lua_State * L)
static int tolua_plane_get_size(lua_State * L)
{
plane *pl = (plane *)tolua_tousertype(L, 1, 0);
lua_pushnumber(L, plane_width(pl));
lua_pushnumber(L, plane_height(pl));
lua_pushinteger(L, plane_width(pl));
lua_pushinteger(L, plane_height(pl));
return 2;
}
@ -657,7 +657,7 @@ static int tolua_distance(lua_State * L)
pnormalize(&x1, &y1, pl);
pnormalize(&x2, &y2, pl);
result = koor_distance(x1, y1, x2, y2);
lua_pushnumber(L, result);
lua_pushinteger(L, result);
return 1;
}

View file

@ -45,7 +45,7 @@ int tolua_shiplist_next(lua_State * L)
static int tolua_ship_get_id(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->no);
lua_pushinteger(L, self->no);
return 1;
}
@ -152,7 +152,7 @@ tolua_ship_tostring(lua_State * L)
static int tolua_ship_get_flags(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number)self->flags);
lua_pushinteger(L, self->flags);
return 1;
}
@ -179,7 +179,7 @@ static int tolua_ship_get_coast(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, 0);
if (self->coast) {
tolua_pushnumber(L, self->coast);
lua_pushinteger(L, self->coast);
return 1;
}
return 0;

View file

@ -44,7 +44,7 @@ static int tolua_db_execute(lua_State * L)
int res = sqlite3_exec(db, sql, 0, 0, 0);
tolua_pushnumber(L, (LUA_NUMBER)res);
lua_pushinteger(L, res);
return 1;
}

View file

@ -77,7 +77,7 @@ static int tolua_storage_read_float(lua_State * L)
gamedata *data = (gamedata *)tolua_tousertype(L, 1, 0);
float num;
READ_FLT(data->store, &num);
tolua_pushnumber(L, (lua_Number)num);
lua_pushnumber(L, num);
return 1;
}
@ -86,7 +86,7 @@ static int tolua_storage_read_int(lua_State * L)
gamedata *data = (gamedata *)tolua_tousertype(L, 1, 0);
int num;
READ_INT(data->store, &num);
tolua_pushnumber(L, (lua_Number)num);
lua_pushinteger(L, num);
return 1;
}

View file

@ -14,12 +14,10 @@ without prior permission by the authors of Eressea.
#include "bind_unit.h"
#include "bind_dict.h"
#ifdef BSON_ATTRIB
# include "bind_attrib.h"
#endif
#include "alchemy.h"
#include "bindings.h"
#include "move.h"
#include "reports.h"
/* attributes includes */
#include <attributes/racename.h>
@ -57,6 +55,17 @@ without prior permission by the authors of Eressea.
#include <stdlib.h>
#include <limits.h>
static int tolua_bufunit(lua_State * L) {
char buf[8192];
unit *self = (unit *)tolua_tousertype(L, 1, 0);
int mode = (int)tolua_tonumber(L, 2, see_unit);
if (!self) return 0;
bufunit(self->faction, self, 0, mode, buf, sizeof(buf));
tolua_pushstring(L, buf);
return 1;
}
static int tolua_unit_get_objects(lua_State * L)
{
unit *self = (unit *)tolua_tousertype(L, 1, 0);
@ -64,23 +73,6 @@ static int tolua_unit_get_objects(lua_State * L)
return 1;
}
#ifdef BSON_ATTRIB
static int tolua_unit_get_attribs(lua_State * L)
{
unit *self = (unit *) tolua_tousertype(L, 1, 0);
attrib **attrib_ptr = (attrib **) lua_newuserdata(L, sizeof(attrib *));
attrib *a = tolua_get_lua_ext(self->attribs);
luaL_getmetatable(L, "attrib");
lua_setmetatable(L, -2);
*attrib_ptr = a;
lua_pushcclosure(L, tolua_attriblist_next, 1);
return 1;
}
#endif
int tolua_unitlist_nextf(lua_State * L)
{
unit **unit_ptr = (unit **)lua_touserdata(L, lua_upvalueindex(1));
@ -160,7 +152,7 @@ static int tolua_unit_set_group(lua_State * L)
{
unit *self = (unit *)tolua_tousertype(L, 1, 0);
int result = join_group(self, tolua_tostring(L, 2, 0));
tolua_pushnumber(L, result);
lua_pushinteger(L, result);
return 1;
}
@ -533,7 +525,7 @@ static void unit_castspell(unit * u, const char *name, int level)
}
else {
castorder co;
create_castorder(&co, u, 0, sp, u->region, level, level * MagicPower(), 0, 0, 0);
create_castorder(&co, u, 0, sp, u->region, level, (double)level, 0, 0, 0);
sp->cast(&co);
free_castorder(&co);
}
@ -1054,9 +1046,7 @@ void tolua_unit_open(lua_State * L)
tolua_variable(L, TOLUA_CAST "hp_max", &tolua_unit_get_hpmax, 0);
tolua_variable(L, TOLUA_CAST "objects", &tolua_unit_get_objects, 0);
#ifdef BSON_ATTRIB
tolua_variable(L, TOLUA_CAST "attribs", &tolua_unit_get_attribs, 0);
#endif
tolua_function(L, TOLUA_CAST "show", &tolua_bufunit);
}
tolua_endmodule(L);
}

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