forked from github/server
commit
8d36403216
132 changed files with 1857 additions and 1199 deletions
CHANGELOG.mdCMakeLists.txtcJSONclibs
conf
res
scripts
src
CMakeLists.txtacademy.cacademy.hacademy.test.calchemy.test.c
attributes
automate.cautomate.test.cbattle.cbattle.test.cbind_region.cbind_ship.cbind_unit.cbindings.cchecker.ccontact.test.ccreport.ccreport.test.cdonations.test.ceconomy.ceconomy.test.cexparse.cgive.test.cguard.test.citems
kernel
CMakeLists.txtalliance.test.cally.test.cbuild.test.cbuilding.cbuilding.hbuilding.test.ccommand.test.cconfig.hconfig.test.ccurse.test.cdatabase.test.c
laws.claws.test.clighthouse.clighthouse.test.cmagic.test.cmain.cmarket.test.cdb
equipment.test.cfaction.test.cgroup.test.citem.test.cmessages.test.corder.test.cplane.test.cpool.test.crace.test.cregion.cregion.hregion.test.cresources.csave.test.cship.test.cskills.test.cunit.cunit.hunit.test.cversion.cmodules
monsters.cmonsters.test.cmove.cmove.test.cnames.test.corderfile.corderfile.test.cpiracy.test.crenumber.test.creport.creport.test.c
30
CHANGELOG.md
30
CHANGELOG.md
|
@ -1,12 +1,30 @@
|
|||
# Geplante Aenderungen in zukuenftigen Eressea-Versionen
|
||||
|
||||
Als Anhaltspunkt fuer die Empfaenger der woechentlichen Testauswertungnen
|
||||
will ich versuchen, die Liste meiner Aenderungen seit dem letzten Release
|
||||
zu dokumentieren.
|
||||
# 3.26
|
||||
|
||||
## Version 3.12.0
|
||||
- Akademien, Traenke und Verzauberungen wirken auch bei LERNE AUTO
|
||||
- Das lernen in einer Akademie erhoeht die Lernkosten. Koennen diese
|
||||
nicht bezahlt werden, wird ohne deren Bonus gelernt.
|
||||
- Lehrer muessen nicht mehr in der Akademie stehen, damit ihre Schueler
|
||||
den Bonus bekommen
|
||||
- Rohstoffe koennen jetzt bereits gesehen werden, wenn eine Einheit nur
|
||||
die Haelfte des zum Abbau noetigen Talentes hat (statt bisher
|
||||
Talent-1)
|
||||
- Mauern der Ewigkeit und Störe Astrale Integrität brauchen keine
|
||||
Stufenangabe, ihre Kosten sind nicht variabel [2651]
|
||||
|
||||
# 3.25
|
||||
|
||||
- Ab sofort ist es nicht mehr erlaubt, Befehle mit weniger als 3
|
||||
Zeichen abzukürzen.
|
||||
- Leuchttürme entdecken Seeschlangen und Drachen auf dem Ozean [2688]
|
||||
- Magieresistenz von Insekten und Goblins repariert [2685]
|
||||
- Getarnte Einheiten können wieder Eisen abbauen [2679]
|
||||
- Gestaltwandlung kann nur einmal auf die selbe Einheit wirken [2680]
|
||||
- Handel benötigt eine Burg mit Mindestgröße 2 [2678]
|
||||
- Geschützte Leerzeichen in Befehlen werden ignoriert [2670]
|
||||
|
||||
# 3.12
|
||||
|
||||
- [other] optimierte Berechnung der Sichtbarkeit von Leuchttuermen
|
||||
- [bug] Einheitenlimit bei GIB PERSON beachten
|
||||
- [bug] Einheitenlimit bei ALLIANCE JOIN beachten
|
||||
- [rule] Einheiten- und Personenzahl im Report beinhaltet *alle* Einheiten der Partei.
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
cmake_minimum_required(VERSION 2.9)
|
||||
if (WIN32)
|
||||
FILE(TO_CMAKE_PATH "${CMAKE_MODULE_PATH}" CMAKE_MODULE_PATH )
|
||||
FILE(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH )
|
||||
|
|
2
cJSON
2
cJSON
|
@ -1 +1 @@
|
|||
Subproject commit 8df81fb497cc48b089a57fcdc3a9933540ebc7c9
|
||||
Subproject commit 460207f9c09d501a2e302e5313b2f67dca0d6d63
|
2
clibs
2
clibs
|
@ -1 +1 @@
|
|||
Subproject commit 484fbf23e34f6844f1c4e3f685bb6c53cadf5bfe
|
||||
Subproject commit 48ddc013ffc2e7afb33b348bb605443896e55a28
|
|
@ -1,63 +1,63 @@
|
|||
{
|
||||
"include": [
|
||||
"config://conf/keywords.json",
|
||||
"config://conf/calendar.json",
|
||||
"config://conf/prefixes.json",
|
||||
"config://conf/e2/locales.json",
|
||||
"config://conf/e2/terrains.json",
|
||||
"config://conf/e2/items.json",
|
||||
"config://res/core/ships.xml",
|
||||
"config://res/core/common/buildings.xml",
|
||||
"config://res/eressea/buildings.xml",
|
||||
"config://res/buildings/castle.xml",
|
||||
"config://res/eressea/races.xml",
|
||||
"config://res/eressea/artrewards.xml",
|
||||
"config://res/eressea/spells.xml",
|
||||
"config://res/eressea/spellbooks/gray.xml",
|
||||
"config://res/eressea/spellbooks/gwyrrd.xml",
|
||||
"config://res/eressea/spellbooks/draig.xml",
|
||||
"config://res/eressea/spellbooks/illaun.xml",
|
||||
"config://res/eressea/spellbooks/cerddor.xml",
|
||||
"config://res/eressea/spellbooks/tybied.xml"
|
||||
],
|
||||
"disabled": [
|
||||
"jsreport"
|
||||
],
|
||||
"settings": {
|
||||
"game.name" : "Eressea",
|
||||
"game.mailcmd" : "ERESSEA",
|
||||
"game.id" : 2,
|
||||
"orders.default": "work",
|
||||
"NewbieImmunity": 8,
|
||||
"modules.market": false,
|
||||
"modules.astralspace": true,
|
||||
"modules.wormhole": true,
|
||||
"modules.iceberg": true,
|
||||
"modules.volcano": true,
|
||||
"monsters.spawn.chance": 50,
|
||||
"entertain.base": 0,
|
||||
"entertain.perlevel": 20,
|
||||
"taxing.perlevel": 20,
|
||||
"nmr.timeout": 5,
|
||||
"nmr.removenewbie": false,
|
||||
"GiveRestriction": 3,
|
||||
"hunger.long": false,
|
||||
"hunger.damage": "1d8+6",
|
||||
"init_spells": 0,
|
||||
"game.era": 2,
|
||||
"game.start": 184,
|
||||
"rules.reserve.twophase": true,
|
||||
"rules.give.max_men": -1,
|
||||
"rules.check_overload": false,
|
||||
"rules.limit.faction": 2500,
|
||||
"rules.maxskills.magic": 5,
|
||||
"rules.guard.base_stop_prob": 0.30,
|
||||
"rules.guard.skill_stop_prob": 0.05,
|
||||
"rules.guard.amulet_stop_prob": 0.10,
|
||||
"rules.guard.guard_number_stop_prob": 0.001,
|
||||
"rules.guard.castle_stop_prob": 0.05,
|
||||
"rules.guard.region_type_stop_prob": 0.05,
|
||||
"rules.economy.repopulate_maximum": 500,
|
||||
"rules.lighthouse.unit_capacity": true
|
||||
}
|
||||
"settings": {
|
||||
"game.name": "Eressea",
|
||||
"game.mailcmd": "ERESSEA",
|
||||
"game.id": 2,
|
||||
"orders.default": "work",
|
||||
"NewbieImmunity": 8,
|
||||
"modules.market": false,
|
||||
"modules.astralspace": true,
|
||||
"modules.wormhole": true,
|
||||
"modules.iceberg": true,
|
||||
"modules.volcano": true,
|
||||
"monsters.spawn.chance": 50,
|
||||
"entertain.base": 0,
|
||||
"entertain.perlevel": 20,
|
||||
"taxing.perlevel": 20,
|
||||
"nmr.timeout": 5,
|
||||
"nmr.removenewbie": false,
|
||||
"GiveRestriction": 3,
|
||||
"hunger.long": false,
|
||||
"hunger.damage": "1d8+6",
|
||||
"init_spells": 0,
|
||||
"game.era": 2,
|
||||
"game.start": 184,
|
||||
"rules.reserve.twophase": true,
|
||||
"rules.give.max_men": -1,
|
||||
"rules.check_overload": false,
|
||||
"rules.limit.faction": 2500,
|
||||
"rules.maxskills.magic": 5,
|
||||
"rules.guard.base_stop_prob": 0.30,
|
||||
"rules.guard.skill_stop_prob": 0.05,
|
||||
"rules.guard.amulet_stop_prob": 0.10,
|
||||
"rules.guard.guard_number_stop_prob": 0.001,
|
||||
"rules.guard.castle_stop_prob": 0.05,
|
||||
"rules.guard.region_type_stop_prob": 0.05,
|
||||
"rules.economy.repopulate_maximum": 500,
|
||||
"rules.lighthouse.unit_capacity": true
|
||||
},
|
||||
"disabled": [
|
||||
"jsreport"
|
||||
],
|
||||
"include": [
|
||||
"config://conf/keywords.json",
|
||||
"config://conf/calendar.json",
|
||||
"config://conf/prefixes.json",
|
||||
"config://conf/e2/locales.json",
|
||||
"config://conf/e2/terrains.json",
|
||||
"config://conf/e2/items.json",
|
||||
"config://res/core/ships.xml",
|
||||
"config://res/core/common/buildings.xml",
|
||||
"config://res/eressea/buildings.xml",
|
||||
"config://res/buildings/castle.xml",
|
||||
"config://res/eressea/races.xml",
|
||||
"config://res/eressea/artrewards.xml",
|
||||
"config://res/eressea/spells.xml",
|
||||
"config://res/eressea/spellbooks/gray.xml",
|
||||
"config://res/eressea/spellbooks/gwyrrd.xml",
|
||||
"config://res/eressea/spellbooks/draig.xml",
|
||||
"config://res/eressea/spellbooks/illaun.xml",
|
||||
"config://res/eressea/spellbooks/cerddor.xml",
|
||||
"config://res/eressea/spellbooks/tybied.xml"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -67,7 +67,6 @@
|
|||
"init_spells": 0,
|
||||
"recruit.allow_merge": true,
|
||||
"study.expensivemigrants": true,
|
||||
"study.speedup": 2,
|
||||
"game.era": 3,
|
||||
"game.start": 1,
|
||||
"rules.reserve.twophase": true,
|
||||
|
@ -111,6 +110,7 @@
|
|||
"rules.lighthouse.unit_capacity": true,
|
||||
"movement.shipspeed.skillbonus": 6,
|
||||
"alliance.auto": "fight",
|
||||
"alliance.restricted": "fight"
|
||||
"alliance.restricted": "fight",
|
||||
"resource.visibility.rule": 0
|
||||
}
|
||||
}
|
||||
|
|
68
conf/ex/config.json
Normal file
68
conf/ex/config.json
Normal file
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
"include": [
|
||||
"config://conf/keywords.json",
|
||||
"config://conf/calendar.json",
|
||||
"config://conf/prefixes.json",
|
||||
"config://conf/e2/locales.json",
|
||||
"config://conf/e2/terrains.json",
|
||||
"config://conf/e2/items.json",
|
||||
"config://res/core/ships.xml",
|
||||
"config://res/core/common/buildings.xml",
|
||||
"config://res/eressea/buildings.xml",
|
||||
"config://res/buildings/castle.xml",
|
||||
"config://res/eressea/races.xml",
|
||||
"config://res/eressea/artrewards.xml",
|
||||
"config://res/eressea/spells.xml",
|
||||
"config://res/eressea/spellbooks/gray.xml",
|
||||
"config://res/eressea/spellbooks/gwyrrd.xml",
|
||||
"config://res/eressea/spellbooks/draig.xml",
|
||||
"config://res/eressea/spellbooks/illaun.xml",
|
||||
"config://res/eressea/spellbooks/cerddor.xml",
|
||||
"config://res/eressea/spellbooks/tybied.xml"
|
||||
],
|
||||
"disabled": [
|
||||
"destroy",
|
||||
"steal",
|
||||
"number",
|
||||
"jsreport"
|
||||
],
|
||||
"settings": {
|
||||
"game.name" : "Eressea",
|
||||
"game.mailcmd" : "ERESSEA",
|
||||
"game.id" : 2,
|
||||
"orders.default": "work",
|
||||
"NewbieImmunity": 8,
|
||||
"modules.market": false,
|
||||
"modules.astralspace": true,
|
||||
"modules.wormhole": true,
|
||||
"modules.iceberg": true,
|
||||
"modules.volcano": true,
|
||||
"monsters.spawn.chance": 50,
|
||||
"entertain.base": 0,
|
||||
"entertain.perlevel": 20,
|
||||
"taxing.perlevel": 20,
|
||||
"nmr.timeout": 5,
|
||||
"nmr.removenewbie": false,
|
||||
"GiveRestriction": 3,
|
||||
"hunger.long": false,
|
||||
"hunger.damage": "1d8+6",
|
||||
"init_spells": 0,
|
||||
"game.era": 2,
|
||||
"game.start": 184,
|
||||
"rules.reserve.twophase": true,
|
||||
"rules.give.max_men": -1,
|
||||
"rules.check_overload": false,
|
||||
"rules.wage.function": 2,
|
||||
"monsters.spawn.chance" : 0,
|
||||
"rules.limit.faction": 2500,
|
||||
"rules.maxskills.magic": 5,
|
||||
"rules.guard.base_stop_prob": 0.30,
|
||||
"rules.guard.skill_stop_prob": 0.05,
|
||||
"rules.guard.amulet_stop_prob": 0.10,
|
||||
"rules.guard.guard_number_stop_prob": 0.001,
|
||||
"rules.guard.castle_stop_prob": 0.05,
|
||||
"rules.guard.region_type_stop_prob": 0.05,
|
||||
"rules.economy.repopulate_maximum": 500,
|
||||
"rules.lighthouse.unit_capacity": true
|
||||
}
|
||||
}
|
50
conf/ex/items.json
Normal file
50
conf/ex/items.json
Normal file
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
"include": [
|
||||
"config://res/core/spoils.xml",
|
||||
"config://res/core/common/herbs.xml",
|
||||
"config://res/core/common/items.xml",
|
||||
"config://res/core/common/luxuries.xml",
|
||||
"config://res/core/common/potions.xml",
|
||||
"config://res/core/armor/chainmail.xml",
|
||||
"config://res/core/armor/laenmail.xml",
|
||||
"config://res/core/armor/laenshield.xml",
|
||||
"config://res/core/armor/plate.xml",
|
||||
"config://res/core/armor/rustychainmail.xml",
|
||||
"config://res/core/armor/rustyshield.xml",
|
||||
"config://res/core/armor/shield.xml",
|
||||
"config://res/core/resources/cart.xml",
|
||||
"config://res/core/resources/horse.xml",
|
||||
"config://res/core/resources/hp.xml",
|
||||
"config://res/core/resources/iron.xml",
|
||||
"config://res/core/resources/laen.xml",
|
||||
"config://res/core/resources/log.xml",
|
||||
"config://res/core/resources/mallorn.xml",
|
||||
"config://res/core/resources/mallornseed.xml",
|
||||
"config://res/core/resources/seed.xml",
|
||||
"config://res/core/resources/peasant.xml",
|
||||
"config://res/core/resources/stone.xml",
|
||||
"config://res/core/weapons/axe.xml",
|
||||
"config://res/core/weapons/bow.xml",
|
||||
"config://res/core/weapons/catapult.xml",
|
||||
"config://res/core/weapons/crossbow.xml",
|
||||
"config://res/core/weapons/firesword.xml",
|
||||
"config://res/core/weapons/greatbow.xml",
|
||||
"config://res/core/weapons/greatsword.xml",
|
||||
"config://res/core/weapons/halberd.xml",
|
||||
"config://res/core/weapons/laensword.xml",
|
||||
"config://res/core/weapons/lance.xml",
|
||||
"config://res/core/weapons/mallornbow.xml",
|
||||
"config://res/core/weapons/mallorncrossbow.xml",
|
||||
"config://res/core/weapons/mallornlance.xml",
|
||||
"config://res/core/weapons/mallornspear.xml",
|
||||
"config://res/core/weapons/runesword.xml",
|
||||
"config://res/core/weapons/rustyaxe.xml",
|
||||
"config://res/core/weapons/rustygreatsword.xml",
|
||||
"config://res/core/weapons/rustyhalberd.xml",
|
||||
"config://res/core/weapons/rustysword.xml",
|
||||
"config://res/core/weapons/spear.xml",
|
||||
"config://res/core/weapons/sword.xml",
|
||||
"config://res/eressea/items.xml",
|
||||
"config://res/adamantium.xml"
|
||||
]
|
||||
}
|
34
conf/ex/locales.json
Normal file
34
conf/ex/locales.json
Normal file
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"include": [
|
||||
"config://res/translations/strings.de.po",
|
||||
"config://res/translations/strings-e2.de.po",
|
||||
"config://res/translations/strings.en.po",
|
||||
"config://res/translations/strings-e2.en.po",
|
||||
"config://res/translations/messages.de.po",
|
||||
"config://res/translations/messages.en.po",
|
||||
"config://res/core/messages.xml"
|
||||
],
|
||||
"aliases": {
|
||||
"de": {
|
||||
"spell::earthquake": [
|
||||
"Beschwöre einen Erdelementar",
|
||||
"Beschwörung eines Erdelementares"
|
||||
],
|
||||
"spell::goodwinds": [
|
||||
"Beschwörung eines Wasserelementares",
|
||||
"Beschwöre einen Wasserelementar"
|
||||
],
|
||||
"spell::stormwinds": [
|
||||
"Beschwöre einen Sturmelementar",
|
||||
"Beschwörung eines Sturmelementares"
|
||||
],
|
||||
"spell::summonfireelemental": [
|
||||
"Beschwöre einen Hitzeelementar",
|
||||
"Beschwörung eines Hitzeelementares"
|
||||
]
|
||||
},
|
||||
"en": {
|
||||
"spell::migration": "Rit of Acceptance"
|
||||
}
|
||||
}
|
||||
}
|
8
conf/ex/readme.txt
Normal file
8
conf/ex/readme.txt
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Änderungen gegenüber E2
|
||||
|
||||
- ARBEITE produziert nur genug Silber für den Unterhalt der Einheit
|
||||
- NUMMER Befehl abgeschafft.
|
||||
- Ebene und Hochland haben 20%, alle anderen Regionen 10% der Arbeitsplätze von E2.
|
||||
- Keine Zufallsmonster
|
||||
- ZERSTÖRE Befehl abgeschafft.
|
||||
- BEKLAUE Befehl abgeschafft.
|
286
conf/ex/terrains.json
Normal file
286
conf/ex/terrains.json
Normal file
|
@ -0,0 +1,286 @@
|
|||
{
|
||||
"terrains": {
|
||||
"ocean": {
|
||||
"size": 10,
|
||||
"flags": [ "swim", "sea", "sail", "fly" ]
|
||||
},
|
||||
"plain": {
|
||||
"size": 2000,
|
||||
"herbs": [ "h0", "h1", "h2", "h3", "h4", "h5" ],
|
||||
"seed": 3,
|
||||
"road": 50,
|
||||
"flags": [ "forest", "cavalry", "land", "walk", "sail", "fly" ],
|
||||
"production": {
|
||||
"iron": {
|
||||
"chance": 0.1,
|
||||
"base": "5d8",
|
||||
"div": "2d20+10",
|
||||
"level": "2d4-1"
|
||||
},
|
||||
"stone": {
|
||||
"chance": 0.15,
|
||||
"base": "5d8",
|
||||
"div": "2d30+20",
|
||||
"level": "1d4"
|
||||
},
|
||||
"laen": {
|
||||
"chance": 0.01,
|
||||
"base": "1d4",
|
||||
"div": "2d20+50",
|
||||
"level": "1d4"
|
||||
}
|
||||
}
|
||||
},
|
||||
"swamp": {
|
||||
"size": 200,
|
||||
"herbs": [ "h6", "h7", "h8" ],
|
||||
"seed": 2,
|
||||
"road": 75,
|
||||
"flags": [ "land", "walk", "sail", "fly" ],
|
||||
"production": {
|
||||
"iron": {
|
||||
"chance": 0.02,
|
||||
"base": "5d8",
|
||||
"div": "2d20+10",
|
||||
"level": "2d4-1"
|
||||
},
|
||||
"stone": {
|
||||
"chance": 0.02,
|
||||
"base": "5d8",
|
||||
"div": "2d30+20",
|
||||
"level": "1d4"
|
||||
},
|
||||
"laen": {
|
||||
"chance": 0.02,
|
||||
"base": "1d4",
|
||||
"div": "2d20+50",
|
||||
"level": "1d4"
|
||||
}
|
||||
}
|
||||
},
|
||||
"desert": {
|
||||
"size": 50,
|
||||
"herbs": [ "h9", "h10", "h11" ],
|
||||
"seed": 2,
|
||||
"road": 100,
|
||||
"flags": [ "land", "walk", "sail", "fly", "cavalry" ],
|
||||
"production": {
|
||||
"iron": {
|
||||
"chance": 0.15,
|
||||
"base": "5d8",
|
||||
"div": "2d20+10",
|
||||
"level": "2d4-1"
|
||||
},
|
||||
"stone": {
|
||||
"chance": 0.25,
|
||||
"base": "5d8",
|
||||
"div": "2d30+20",
|
||||
"level": "1d4"
|
||||
},
|
||||
"laen": {
|
||||
"chance": 0.025,
|
||||
"base": "1d4",
|
||||
"div": "2d20+50",
|
||||
"level": "1d4"
|
||||
}
|
||||
}
|
||||
},
|
||||
"highland": {
|
||||
"size": 800,
|
||||
"herbs": [ "h12", "h13", "h14" ],
|
||||
"seed": 2,
|
||||
"road": 100,
|
||||
"flags": [ "land", "walk", "sail", "fly", "cavalry" ],
|
||||
"production": {
|
||||
"iron": {
|
||||
"chance": 0.15,
|
||||
"base": "5d8",
|
||||
"div": "2d20+10",
|
||||
"level": "2d4-1"
|
||||
},
|
||||
"stone": {
|
||||
"chance": 0.25,
|
||||
"base": "5d8",
|
||||
"div": "2d30+20",
|
||||
"level": "1d4"
|
||||
},
|
||||
"laen": {
|
||||
"chance": 0.025,
|
||||
"base": "1d4",
|
||||
"div": "2d20+50",
|
||||
"level": "1d4"
|
||||
}
|
||||
}
|
||||
},
|
||||
"mountain": {
|
||||
"size": 100,
|
||||
"herbs": [ "h15", "h16", "h17" ],
|
||||
"seed": 2,
|
||||
"road": 250,
|
||||
"flags": [ "land", "walk", "sail", "fly" ],
|
||||
"production": {
|
||||
"iron": {
|
||||
"chance": 1.0,
|
||||
"base": "50",
|
||||
"div": "50",
|
||||
"level": "1"
|
||||
},
|
||||
"stone": {
|
||||
"chance": 1.0,
|
||||
"base": "100",
|
||||
"div": "100",
|
||||
"level": "1"
|
||||
},
|
||||
"laen": {
|
||||
"chance": 0.05,
|
||||
"base": "4",
|
||||
"div": "100",
|
||||
"level": "1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"glacier": {
|
||||
"size": 10,
|
||||
"herbs": [ "h18", "h19", "h20" ],
|
||||
"seed": 2,
|
||||
"road": 250,
|
||||
"flags": [ "arctic", "land", "walk", "sail", "fly" ],
|
||||
"production": {
|
||||
"iron": {
|
||||
"chance": 1.0,
|
||||
"base": "3",
|
||||
"div": "50",
|
||||
"level": "1"
|
||||
},
|
||||
"stone": {
|
||||
"chance": 1.0,
|
||||
"base": "2",
|
||||
"div": "100",
|
||||
"level": "1"
|
||||
},
|
||||
"laen": {
|
||||
"chance": 0.05,
|
||||
"base": "4",
|
||||
"div": "100",
|
||||
"level": "1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"iceberg": {
|
||||
"size": 10,
|
||||
"herbs": [ "h18", "h19", "h20" ],
|
||||
"flags": [ "arctic", "land", "walk", "sail", "fly" ],
|
||||
"production": {
|
||||
"iron": {
|
||||
"chance": 0.9,
|
||||
"base": "3",
|
||||
"div": "50",
|
||||
"level": "1"
|
||||
},
|
||||
"stone": {
|
||||
"chance": 0.9,
|
||||
"base": "2",
|
||||
"div": "100",
|
||||
"level": "1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"iceberg_sleep": {
|
||||
"size": 10,
|
||||
"herbs": [ "h18", "h19", "h20" ],
|
||||
"flags": [ "arctic", "land", "walk", "sail", "fly" ],
|
||||
"production": {
|
||||
"iron": {
|
||||
"chance": 0.9,
|
||||
"base": "3",
|
||||
"div": "50",
|
||||
"level": "1"
|
||||
},
|
||||
"stone": {
|
||||
"chance": 0.9,
|
||||
"base": "2",
|
||||
"div": "100",
|
||||
"level": "1"
|
||||
},
|
||||
"laen": {
|
||||
"chance": 0.05,
|
||||
"base": "4",
|
||||
"div": "100",
|
||||
"level": "1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"firewall": {
|
||||
"flags": [ "forbidden" ]
|
||||
},
|
||||
"fog": {
|
||||
"flags": [ "walk", "fly" ]
|
||||
},
|
||||
"thickfog": {
|
||||
"flags": [ "forbidden" ]
|
||||
},
|
||||
"volcano": {
|
||||
"size": 50,
|
||||
"road": 250,
|
||||
"seed": 1,
|
||||
"flags": [ "land", "walk", "sail", "fly" ],
|
||||
"production": {
|
||||
"iron": {
|
||||
"chance": 0.5,
|
||||
"level": "1",
|
||||
"base": "50",
|
||||
"div": "50"
|
||||
},
|
||||
"stone": {
|
||||
"chance": 0.5,
|
||||
"level": "1",
|
||||
"base": "100",
|
||||
"div": "100"
|
||||
},
|
||||
"laen": {
|
||||
"chance": 0.075,
|
||||
"level": "1",
|
||||
"base": "4",
|
||||
"div": "100"
|
||||
}
|
||||
}
|
||||
},
|
||||
"activevolcano": {
|
||||
"size": 50,
|
||||
"road": 250,
|
||||
"flags": [ "land", "walk", "sail", "fly" ],
|
||||
"production": {
|
||||
"iron": {
|
||||
"chance": 0.5,
|
||||
"level": "1",
|
||||
"base": "50",
|
||||
"div": "50"
|
||||
},
|
||||
"stone": {
|
||||
"chance": 0.5,
|
||||
"level": "1",
|
||||
"base": "100",
|
||||
"div": "100"
|
||||
},
|
||||
"laen": {
|
||||
"chance": 0.075,
|
||||
"level": "1",
|
||||
"base": "4",
|
||||
"div": "100"
|
||||
}
|
||||
}
|
||||
},
|
||||
"hell": {
|
||||
"flags": [ "walk" ]
|
||||
},
|
||||
"hall1": {
|
||||
"flags": [ "land", "walk", "sail" ]
|
||||
},
|
||||
"corridor1": {
|
||||
"flags": [ "land", "walk", "sail" ]
|
||||
},
|
||||
"wall1": {
|
||||
"flags": [ "forbidden", "land" ]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -595,7 +595,7 @@
|
|||
<spell name="shockwave" rank="5" variable="true" combat="2">
|
||||
<resource name="aura" amount="1" cost="level"/>
|
||||
</spell>
|
||||
<spell name="eternal_walls" rank="5" parameters="b" ship="true" variable="true">
|
||||
<spell name="eternal_walls" rank="5" parameters="b" ship="true">
|
||||
<resource name="aura" amount="50" cost="fixed"/>
|
||||
<resource name="permaura" amount="1" cost="fixed"/>
|
||||
</spell>
|
||||
|
|
|
@ -1161,7 +1161,7 @@ msgid "spyreport_faction"
|
|||
msgstr "\"$unit($target) gehört der Partei $faction($faction) an.\""
|
||||
|
||||
msgid "ship_drift"
|
||||
msgstr "\"Die $ship($ship) treibt nach $direction($dir).\""
|
||||
msgstr "\"Die $ship($ship) hat zu wenig Segler und treibt nach $direction($dir).\""
|
||||
|
||||
msgid "error_max_magicians"
|
||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - Es kann maximal $int($amount) Magier pro Partei geben.\""
|
||||
|
|
|
@ -1161,7 +1161,7 @@ msgid "spyreport_faction"
|
|||
msgstr "\"$unit($target) belongs to $faction($faction).\""
|
||||
|
||||
msgid "ship_drift"
|
||||
msgstr "\"The ship $ship($ship) drifts to the $direction($dir).\""
|
||||
msgstr "\"The ship $ship($ship) needs more sailors and drifts to the $direction($dir).\""
|
||||
|
||||
msgid "error_max_magicians"
|
||||
msgstr "\"$unit($unit) in $region($region): '$order($command)' - There may not be more than $int($amount) magicians in your faction.\""
|
||||
|
|
|
@ -1741,10 +1741,6 @@ msgstr "caravel"
|
|||
msgid "stone_p"
|
||||
msgstr "stones"
|
||||
|
||||
msgctxt "keyword"
|
||||
msgid "locale"
|
||||
msgstr "LOCALE"
|
||||
|
||||
msgctxt "spellinfo"
|
||||
msgid "song_suscept_magic"
|
||||
msgstr "This song, which is woven into the magical essence of the region, weakens the natural resistance against a singular enchantment by 15%. Only the allies of the bard (HELP GUARD) are immune to the effect of the chant."
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
dofile('config.lua')
|
||||
eressea.read_game(get_turn() .. '.dat')
|
||||
init_reports()
|
||||
write_reports()
|
||||
-- do not use write_reports, since it will change passwords
|
||||
for f in factions() do
|
||||
write_report(f)
|
||||
end
|
||||
|
|
|
@ -79,3 +79,66 @@ function test_no_guard_no_move_after_combat() -- bug 1493
|
|||
u1 = get_unit(uid1)
|
||||
assert_equal(r1, u1.region)
|
||||
end
|
||||
|
||||
function test_move_stops_guarding()
|
||||
local r1 = region.create(0, 0, "plain")
|
||||
local r2 = region.create(1, 0, "plain")
|
||||
local f = faction.create("human", "test@example.com", "de")
|
||||
local u = unit.create(f, r1, 1)
|
||||
u:add_item("sword", 1)
|
||||
u:set_skill("melee", 2)
|
||||
u:add_order("NACH O")
|
||||
u:add_order("BEWACHE")
|
||||
u.guard = true
|
||||
process_orders()
|
||||
assert_equal(r2, u.region)
|
||||
assert_false(u.guard)
|
||||
end
|
||||
|
||||
function test_move_to_same_region_stops_guarding()
|
||||
local r1 = region.create(0, 0, "plain")
|
||||
local r2 = region.create(1, 0, "plain")
|
||||
local f = faction.create("human", "test@example.com", "de")
|
||||
local u = unit.create(f, r1, 1)
|
||||
u:add_item("horse", 1)
|
||||
u:add_item("sword", 1)
|
||||
u:set_skill("melee", 2)
|
||||
u:set_skill("riding", 2)
|
||||
u:add_order("NACH O W")
|
||||
u.guard = true
|
||||
process_orders()
|
||||
assert_equal(r1, u.region)
|
||||
assert_false(u.guard)
|
||||
end
|
||||
|
||||
function test_mover_cannot_start_guarding()
|
||||
local r1 = region.create(0, 0, "plain")
|
||||
local r2 = region.create(1, 0, "plain")
|
||||
local f = faction.create("human", "test@example.com", "de")
|
||||
local u = unit.create(f, r1, 1)
|
||||
u:add_item("horse", 1)
|
||||
u:add_item("sword", 1)
|
||||
u:set_skill("melee", 2)
|
||||
u:set_skill("riding", 2)
|
||||
u:add_order("BEWACHE")
|
||||
u:add_order("NACH O")
|
||||
process_orders()
|
||||
assert_equal(r2, u.region)
|
||||
assert_false(u.guard)
|
||||
end
|
||||
|
||||
function test_move_to_same_region_stops_guarding()
|
||||
local r1 = region.create(0, 0, "plain")
|
||||
local r2 = region.create(1, 0, "plain")
|
||||
local f = faction.create("human", "test@example.com", "de")
|
||||
local u = unit.create(f, r1, 1)
|
||||
u:add_item("horse", 1)
|
||||
u:add_item("sword", 1)
|
||||
u:set_skill("melee", 2)
|
||||
u:set_skill("riding", 2)
|
||||
u:add_order("BEWACHE")
|
||||
u:add_order("NACH O W")
|
||||
process_orders()
|
||||
assert_equal(r1, u.region)
|
||||
assert_false(u.guard)
|
||||
end
|
||||
|
|
|
@ -165,3 +165,20 @@ function assert_capacity(text, u, silver, r1, r2, rx)
|
|||
process_orders()
|
||||
assert_equal(rx, u.region, text .. "unit should not move")
|
||||
end
|
||||
|
||||
function test_move_to_same_region_leaves_building()
|
||||
local r1 = region.create(0, 0, "plain")
|
||||
local r2 = region.create(1, 0, "plain")
|
||||
local f = faction.create("human", "test@example.com", "de")
|
||||
local u = unit.create(f, r1, 1)
|
||||
local b = building.create(u.region, "castle")
|
||||
b.size = 2
|
||||
u.building = b
|
||||
assert_not_nil(u.building)
|
||||
u:add_item("horse", 1)
|
||||
u:set_skill("riding", 2)
|
||||
u:add_order("NACH O W")
|
||||
process_orders()
|
||||
assert_equal(r1, u.region)
|
||||
assert_nil(u.building)
|
||||
end
|
||||
|
|
|
@ -519,3 +519,29 @@ function test_build_convoy_max()
|
|||
assert_equal(100, sh.size)
|
||||
assert_equal(25, u:get_item('log'))
|
||||
end
|
||||
|
||||
function test_ship_crew_stops_guarding()
|
||||
local r1 = region.create(0, 0, "plain")
|
||||
local r2 = region.create(1, 0, "ocean")
|
||||
local f = faction.create("human")
|
||||
local u1 = unit.create(f, r1, 1)
|
||||
local u2 = unit.create(f, r1, 1)
|
||||
local sh = ship.create(r1, "longboat")
|
||||
u1.ship = sh
|
||||
u2.ship = sh
|
||||
u1:clear_orders()
|
||||
u1:add_order("NACH O W")
|
||||
u1:set_skill("sailing", 1) -- cptskill = 1
|
||||
u2:set_skill("sailing", 9) -- sumskill = 10
|
||||
u2:add_item("sword", 1)
|
||||
u2:set_skill("melee", 2)
|
||||
u2:add_order("BEWACHE")
|
||||
u2.guard = true
|
||||
process_orders()
|
||||
assert_false(u2.guard)
|
||||
assert_equal(sh, u1.ship)
|
||||
assert_equal(sh, u2.ship)
|
||||
assert_equal(r1, sh.region)
|
||||
assert_equal(r1, u1.region)
|
||||
assert_equal(r1, u2.region)
|
||||
end
|
||||
|
|
|
@ -273,15 +273,64 @@ end
|
|||
function test_astral_disruption()
|
||||
local r = region.create(0, 0, "plain")
|
||||
local r2 = r:get_astral('fog')
|
||||
local r3 = region.create(r2.x+1, r2.y, 'fog')
|
||||
local f = faction.create("human")
|
||||
local u = unit.create(f, r)
|
||||
local uh = unit.create(get_monsters(), r2, 1, "braineater")
|
||||
u.magic = "draig"
|
||||
u.magic = "tybied"
|
||||
u:set_skill("magic", 100) -- level 100 should beat magic resistance
|
||||
u.aura = 200
|
||||
u:add_spell("astral_disruption")
|
||||
u:add_spell("astral_disruption", 14)
|
||||
u:add_order('ZAUBERE STUFE 1 "Stoere Astrale Integritaet"')
|
||||
process_orders()
|
||||
assert_not_nil(r2:get_curse("astralblock"))
|
||||
assert_equal(60, u.aura)
|
||||
assert_equal(100, r2:get_curse("astralblock"))
|
||||
assert_nil(r3:get_curse("astralblock"))
|
||||
assert_equal(r, uh.region)
|
||||
end
|
||||
|
||||
function test_astral_disruption_levels()
|
||||
local r = region.create(0, 0, "plain")
|
||||
local r2 = r:get_astral('fog')
|
||||
local r3 = region.create(r2.x+1, r2.y, 'fog')
|
||||
local r4 = region.create(r2.x+2, r2.y, 'fog')
|
||||
local f = faction.create("human")
|
||||
local u = unit.create(f, r)
|
||||
local uh = unit.create(get_monsters(), r2, 1, "braineater")
|
||||
u.magic = "tybied"
|
||||
u:set_skill("magic", 100) -- level 100 should beat magic resistance
|
||||
u.aura = 200
|
||||
u:add_spell("astral_disruption", 14)
|
||||
-- at level 5, range +1:
|
||||
u:add_order('ZAUBERE STUFE 5 "Stoere Astrale Integritaet"')
|
||||
process_orders()
|
||||
assert_equal(60, u.aura)
|
||||
assert_equal(100, r2:get_curse("astralblock"))
|
||||
assert_equal(100, r3:get_curse("astralblock"))
|
||||
assert_nil(r4:get_curse("astralblock"))
|
||||
assert_equal(r, uh.region)
|
||||
end
|
||||
|
||||
function test_astral_disruption_default_level()
|
||||
local r = region.create(0, 0, "plain")
|
||||
local r2 = r:get_astral('fog')
|
||||
local r3 = region.create(r2.x+1, r2.y, 'fog')
|
||||
local r4 = region.create(r3.x+1, r2.y, 'fog')
|
||||
local r5 = region.create(r4.x+1, r2.y, 'fog')
|
||||
local f = faction.create("human")
|
||||
local u = unit.create(f, r)
|
||||
local uh = unit.create(get_monsters(), r2, 1, "braineater")
|
||||
u.magic = "tybied"
|
||||
u:set_skill("magic", 100) -- level 100 should beat magic resistance
|
||||
u.aura = 200
|
||||
u:add_spell("astral_disruption", 14)
|
||||
-- no level means cast at the spell's level (14)
|
||||
u:add_order('ZAUBERE "Stoere Astrale Integritaet"')
|
||||
process_orders()
|
||||
assert_equal(60, u.aura)
|
||||
assert_equal(100, r2:get_curse("astralblock"))
|
||||
assert_equal(100, r3:get_curse("astralblock"))
|
||||
assert_equal(100, r4:get_curse("astralblock"))
|
||||
assert_nil(r5:get_curse("astralblock"))
|
||||
assert_equal(r, uh.region)
|
||||
end
|
||||
|
|
|
@ -230,6 +230,27 @@ function test_use_domore()
|
|||
assert_equal(2, u:get_item("sword"))
|
||||
end
|
||||
|
||||
function test_make_greatbow()
|
||||
local r = region.create(0, 0, "plain")
|
||||
local f = faction.create("human", "greatbow@eressea.de", "de")
|
||||
local u = unit.create(f, r, 1)
|
||||
turn_begin()
|
||||
u:add_item('mallorn', 2)
|
||||
u:set_skill('weaponsmithing', 5)
|
||||
u:clear_orders()
|
||||
u:add_order("MACHE 1 Elfenbogen")
|
||||
turn_process()
|
||||
assert_equal(2, u:get_item('mallorn'))
|
||||
assert_equal(0, u:get_item('greatbow'))
|
||||
assert_equal(1, f:count_msg_type('error117'))
|
||||
|
||||
u.race='elf'
|
||||
turn_process()
|
||||
assert_equal(0, u:get_item('mallorn'))
|
||||
assert_equal(1, u:get_item('greatbow'))
|
||||
turn_end()
|
||||
end
|
||||
|
||||
function test_bloodpotion_demon()
|
||||
local r = region.create(0, 0, "plain")
|
||||
local f = faction.create("demon")
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
project (server C)
|
||||
|
||||
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
@ -92,7 +91,6 @@ set (PARSER_SRC
|
|||
|
||||
set (ERESSEA_SRC
|
||||
vortex.c
|
||||
academy.c
|
||||
alchemy.c
|
||||
automate.c
|
||||
battle.c
|
||||
|
@ -168,6 +166,7 @@ set(SERVER_SRC
|
|||
bindings.c
|
||||
console.c
|
||||
helpers.c
|
||||
signals.c
|
||||
main.c
|
||||
)
|
||||
|
||||
|
@ -180,9 +179,11 @@ set (SERVER_SRC ${SERVER_SRC}
|
|||
endif(CURSES_FOUND)
|
||||
|
||||
#find_program(IWYU_PATH NAMES include-what-you-use iwyu)
|
||||
#if(NOT IWYU_PATH)
|
||||
# message(STATUS "Could not find the program include-what-you-use")
|
||||
#endif()
|
||||
if(IWYU_PATH)
|
||||
# set(C_INCLUDE_WHAT_YOU_USE "${IWYU_PATH} -Xiwyu --no_fwd_decls")
|
||||
else(IWYU_PATH)
|
||||
message(STATUS "Could not find the program include-what-you-use")
|
||||
endif()
|
||||
|
||||
add_library(version STATIC ${VERSION_SRC})
|
||||
add_library(parser ${PARSER_SRC})
|
||||
|
@ -212,7 +213,6 @@ target_link_libraries(eressea
|
|||
)
|
||||
|
||||
set(TESTS_SRC
|
||||
academy.test.c
|
||||
alchemy.test.c
|
||||
automate.test.c
|
||||
battle.test.c
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
#include "platform.h"
|
||||
#include "kernel/config.h"
|
||||
#include <kernel/unit.h>
|
||||
#include <kernel/building.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/pool.h>
|
||||
|
||||
#include "academy.h"
|
||||
#include "study.h"
|
||||
|
||||
void academy_teaching_bonus(struct unit *u, skill_t sk, int students) {
|
||||
if (students > 0 && sk != NOSKILL) {
|
||||
/* actually students * EXPERIENCEDAYS / MAX_STUDENTS */
|
||||
learn_skill(u, sk, students);
|
||||
}
|
||||
}
|
||||
|
||||
bool academy_can_teach(unit *teacher, unit *scholar, skill_t sk) {
|
||||
const struct building_type *btype = bt_find("academy");
|
||||
return (active_building(scholar, btype));
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#ifndef H_ACADEMY
|
||||
#define H_ACADEMY
|
||||
|
||||
#include <skill.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct unit;
|
||||
void academy_teaching_bonus(struct unit *u, skill_t sk, int academy);
|
||||
bool academy_can_teach(struct unit *teacher, struct unit *scholar, skill_t sk);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -1,52 +0,0 @@
|
|||
#include <platform.h>
|
||||
|
||||
#include "academy.h"
|
||||
#include "skill.h"
|
||||
|
||||
#include <kernel/config.h>
|
||||
#include <kernel/building.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/unit.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/region.h>
|
||||
|
||||
#include <CuTest.h>
|
||||
#include "tests.h"
|
||||
|
||||
static void test_academy(CuTest * tc)
|
||||
{
|
||||
faction *f;
|
||||
unit *u, *u2;
|
||||
region *r;
|
||||
building *b;
|
||||
const item_type *it_silver;
|
||||
|
||||
test_setup();
|
||||
config_set_int("skills.cost.alchemy", 100);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
u = test_create_unit(f, r);
|
||||
b = test_create_building(r, test_create_buildingtype("academy"));
|
||||
u2 = test_create_unit(f, r);
|
||||
it_silver = test_create_silver();
|
||||
|
||||
CuAssert(tc, "teacher must be in academy", !academy_can_teach(u, u2, SK_CROSSBOW));
|
||||
u_set_building(u, b);
|
||||
CuAssert(tc, "student must be in academy", !academy_can_teach(u, u2, SK_CROSSBOW));
|
||||
u_set_building(u2, b);
|
||||
CuAssert(tc, "student must have 50 silver", !academy_can_teach(u, u2, SK_CROSSBOW));
|
||||
i_change(&u2->items, it_silver, 50);
|
||||
CuAssert(tc, "building must be maintained", !academy_can_teach(u, u2, SK_CROSSBOW));
|
||||
b->flags |= BLD_MAINTAINED;
|
||||
CuAssert(tc, "building must have capacity", !academy_can_teach(u, u2, SK_CROSSBOW));
|
||||
b->size = 2;
|
||||
CuAssertTrue(tc, academy_can_teach(u, u2, SK_CROSSBOW));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_academy_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_academy);
|
||||
return suite;
|
||||
}
|
|
@ -29,10 +29,10 @@ static void test_herbsearch(CuTest * tc)
|
|||
r = test_create_region(0, 0, NULL);
|
||||
rc = rc_get_or_create("dragon");
|
||||
rc->flags |= RCF_UNARMEDGUARD;
|
||||
u2 = test_create_unit(test_create_faction(rc), r);
|
||||
u2 = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
setguard(u2, true);
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
itype = test_create_itemtype("rosemary");
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ static void test_otherfaction(CuTest *tc) {
|
|||
faction *f;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
f = test_create_faction(NULL);
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
f = test_create_faction_ex(u->faction->race, u->faction->locale);
|
||||
config_set("stealth.faction.other", "1");
|
||||
CuAssertIntEquals(tc, true, rule_stealth_other());
|
||||
CuAssertPtrEquals(tc, u->faction, visible_faction(f, u));
|
||||
|
|
|
@ -15,7 +15,7 @@ static void test_stealth(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
set_level(u, SK_STEALTH, 2);
|
||||
CuAssertIntEquals(tc, -1, u_geteffstealth(u));
|
||||
CuAssertIntEquals(tc, 2, eff_stealth(u, u->region));
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#include "kernel/order.h"
|
||||
#include "kernel/region.h"
|
||||
#include "kernel/unit.h"
|
||||
#include "kernel/pool.h"
|
||||
#include "kernel/item.h"
|
||||
|
||||
#include "util/keyword.h"
|
||||
#include "util/log.h"
|
||||
|
@ -210,7 +212,12 @@ void do_autostudy(region *r)
|
|||
autostudy_run(scholars, nscholars);
|
||||
for (i = 0; i != nscholars; ++i) {
|
||||
int days = STUDYDAYS * scholars[i].learn;
|
||||
learn_skill(scholars[i].u, skill, days);
|
||||
int money = learn_skill(scholars[i].u, skill, days, 0);
|
||||
if (money > 0) {
|
||||
use_pooled(u, get_resourcetype(R_SILVER), GET_DEFAULT, money);
|
||||
ADDMSG(&u->faction->msgs, msg_message("studycost",
|
||||
"unit region cost skill", u, u->region, money, skill));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ static void test_autostudy_init(CuTest *tc) {
|
|||
mt_create_error(771);
|
||||
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
u1->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||
test_create_unit(f, r);
|
||||
|
@ -40,7 +40,7 @@ static void test_autostudy_init(CuTest *tc) {
|
|||
u4->thisorder = create_order(K_AUTOSTUDY, f->locale, "Dudelidu");
|
||||
u3 = test_create_unit(f, r);
|
||||
u3->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_PERCEPTION]);
|
||||
u5 = test_create_unit(test_create_faction(NULL), r);
|
||||
u5 = test_create_unit(test_create_faction(), r);
|
||||
u5->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_PERCEPTION]);
|
||||
scholars[2].u = NULL;
|
||||
|
||||
|
@ -82,7 +82,7 @@ static void test_autostudy_run_twoteachers(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
set_level(u1, SK_ENTERTAINMENT, 2);
|
||||
u1->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||
|
@ -123,7 +123,7 @@ static void test_autostudy_run_bigunit(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
set_number(u1, 20);
|
||||
set_level(u1, SK_ENTERTAINMENT, 16);
|
||||
|
@ -154,7 +154,7 @@ static void test_autostudy_run_few_teachers(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
set_number(u1, 20);
|
||||
set_level(u1, SK_ENTERTAINMENT, 16);
|
||||
|
@ -190,7 +190,7 @@ static void test_autostudy_run_few_teachers_reverse(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
set_number(u1, 20);
|
||||
set_level(u1, SK_ENTERTAINMENT, 16);
|
||||
|
@ -224,7 +224,7 @@ static void test_autostudy_run(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
u1->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||
set_number(u1, 2);
|
||||
|
@ -268,7 +268,7 @@ static void test_autostudy_run_noteachers(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
u1->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||
set_number(u1, 5);
|
||||
|
@ -303,7 +303,7 @@ static void test_autostudy_run_teachers_learn(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
u1->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||
set_number(u1, 2);
|
||||
|
@ -332,7 +332,7 @@ static void test_autostudy_run_skilldiff(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
u1->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_PERCEPTION]);
|
||||
set_number(u1, 1);
|
||||
|
@ -364,7 +364,7 @@ static void test_autostudy_batches(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
u1->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_PERCEPTION]);
|
||||
set_number(u1, 1);
|
||||
|
@ -396,7 +396,7 @@ static void test_do_autostudy(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
u1->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_PERCEPTION]);
|
||||
set_number(u1, 1);
|
||||
|
@ -406,7 +406,7 @@ static void test_do_autostudy(CuTest *tc) {
|
|||
set_number(u2, 10);
|
||||
u3 = test_create_unit(f, r);
|
||||
u3->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||
u4 = test_create_unit(test_create_faction(NULL), r);
|
||||
u4 = test_create_unit(test_create_faction(), r);
|
||||
u4->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||
do_autostudy(r);
|
||||
CuAssertIntEquals(tc, 2, get_level(u1, SK_PERCEPTION));
|
||||
|
|
|
@ -899,7 +899,7 @@ void drain_exp(struct unit *u, int n)
|
|||
}
|
||||
}
|
||||
if (sk != NOSKILL) {
|
||||
reduce_skill_days(u, sk, n);
|
||||
change_skill_days(u, sk, -n);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ static void test_make_fighter(CuTest * tc)
|
|||
test_setup();
|
||||
test_create_horse();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
au = test_create_unit(f, r);
|
||||
enable_skill(SK_MAGIC, true);
|
||||
enable_skill(SK_RIDING, true);
|
||||
|
@ -103,7 +103,7 @@ static void test_select_weapon_restricted(CuTest *tc) {
|
|||
race * rc;
|
||||
|
||||
test_setup();
|
||||
au = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
au = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
itype = test_create_itemtype("halberd");
|
||||
wtype = new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
|
||||
i_change(&au->items, itype, 1);
|
||||
|
@ -160,7 +160,7 @@ static void test_select_armor(CuTest *tc) {
|
|||
battle *b;
|
||||
|
||||
test_setup();
|
||||
au = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
au = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
itype = test_create_itemtype("plate");
|
||||
new_armortype(itype, 0.0, frac_zero, 1, 0);
|
||||
i_change(&au->items, itype, 2);
|
||||
|
@ -215,8 +215,8 @@ static void test_defenders_get_building_bonus(CuTest * tc)
|
|||
r = test_create_region(0, 0, NULL);
|
||||
bld = test_create_building(r, btype);
|
||||
|
||||
du = test_create_unit(test_create_faction(NULL), r);
|
||||
au = test_create_unit(test_create_faction(NULL), r);
|
||||
du = test_create_unit(test_create_faction(), r);
|
||||
au = test_create_unit(test_create_faction(), r);
|
||||
u_set_building(du, bld);
|
||||
|
||||
b = make_battle(r);
|
||||
|
@ -264,7 +264,7 @@ static void test_attackers_get_no_building_bonus(CuTest * tc)
|
|||
bld = test_create_building(r, btype);
|
||||
bld->size = 10;
|
||||
|
||||
au = test_create_unit(test_create_faction(NULL), r);
|
||||
au = test_create_unit(test_create_faction(), r);
|
||||
u_set_building(au, bld);
|
||||
|
||||
b = make_battle(r);
|
||||
|
@ -294,7 +294,7 @@ static void test_building_bonus_respects_size(CuTest * tc)
|
|||
bld = test_create_building(r, btype);
|
||||
bld->size = 10;
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
au = test_create_unit(f, r);
|
||||
scale_number(au, 9);
|
||||
u_set_building(au, bld);
|
||||
|
@ -355,7 +355,7 @@ static void test_natural_armor(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
rc = test_create_race("human");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
set_level(u, SK_STAMINA, 2);
|
||||
CuAssertIntEquals(tc, 0, rc_armor_bonus(rc));
|
||||
CuAssertIntEquals(tc, 0, natural_armor(u));
|
||||
|
@ -399,7 +399,7 @@ static void test_calculate_armor(CuTest * tc)
|
|||
achain = new_armortype(ichain, 0.0, v50p, 3, ATF_NONE);
|
||||
wtype = new_weapontype(it_get_or_create(rt_get_or_create("sword")), 0, v50p, 0, 0, 0, 0, SK_MELEE);
|
||||
rc = test_create_race("human");
|
||||
du = test_create_unit(test_create_faction(rc), r);
|
||||
du = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
dt.index = 0;
|
||||
|
||||
dt.fighter = setup_fighter(&b, du);
|
||||
|
@ -472,7 +472,7 @@ static void test_magic_resistance(CuTest *tc)
|
|||
ichain = it_get_or_create(rt_get_or_create("chainmail"));
|
||||
achain = new_armortype(ichain, 0.0, v50p, 3, ATF_NONE);
|
||||
rc = test_create_race("human");
|
||||
du = test_create_unit(test_create_faction(rc), r);
|
||||
du = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
dt.index = 0;
|
||||
|
||||
i_change(&du->items, ishield, 1);
|
||||
|
@ -543,7 +543,7 @@ static void test_projectile_armor(CuTest * tc)
|
|||
wtype = new_weapontype(it_get_or_create(rt_get_or_create("sword")), 0, v50p, 0, 0, 0, 0, SK_MELEE);
|
||||
rc = test_create_race("human");
|
||||
rc->battle_flags |= BF_EQUIPMENT;
|
||||
du = test_create_unit(test_create_faction(rc), r);
|
||||
du = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
dt.index = 0;
|
||||
|
||||
i_change(&du->items, ishield, 1);
|
||||
|
@ -571,8 +571,8 @@ static void test_battle_skilldiff(CuTest *tc)
|
|||
test_setup();
|
||||
|
||||
r = test_create_region(0, 0, NULL);
|
||||
ud = test_create_unit(test_create_faction(NULL), r);
|
||||
ua = test_create_unit(test_create_faction(NULL), r);
|
||||
ud = test_create_unit(test_create_faction(), r);
|
||||
ua = test_create_unit(test_create_faction(), r);
|
||||
td.fighter = setup_fighter(&b, ud);
|
||||
td.index = 0;
|
||||
ta.fighter = setup_fighter(&b, ua);
|
||||
|
@ -606,8 +606,8 @@ static void test_terminate(CuTest * tc)
|
|||
r = test_create_region(0, 0, NULL);
|
||||
|
||||
rc = test_create_race("human");
|
||||
au = test_create_unit(test_create_faction(rc), r);
|
||||
du = test_create_unit(test_create_faction(rc), r);
|
||||
au = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
du = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
dt.index = 0;
|
||||
at.index = 0;
|
||||
|
||||
|
@ -638,8 +638,8 @@ static void test_battle_report_one(CuTest *tc)
|
|||
test_setup();
|
||||
setup_messages();
|
||||
r = test_create_plain(0, 0);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
b = make_battle(r);
|
||||
join_battle(b, u1, true, &fig);
|
||||
join_battle(b, u2, false, &fig);
|
||||
|
@ -669,9 +669,8 @@ static void test_battle_report_two(CuTest *tc)
|
|||
locale_setstring(lang, "and", "and");
|
||||
setup_messages();
|
||||
r = test_create_plain(0, 0);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1->faction->locale = lang;
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction_ex(NULL, lang), r);
|
||||
u2 = test_create_unit(test_create_faction_ex(NULL, lang), r);
|
||||
u2->faction->locale = lang;
|
||||
|
||||
str_slprintf(expect, sizeof(expect), "%s and %s", factionname(u1->faction), factionname(u2->faction));
|
||||
|
@ -702,11 +701,11 @@ static void test_battle_report_three(CuTest *tc)
|
|||
locale_setstring(lang, "and", "and");
|
||||
setup_messages();
|
||||
r = test_create_plain(0, 0);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u1->faction->locale = lang;
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
u2->faction->locale = lang;
|
||||
u3 = test_create_unit(test_create_faction(NULL), r);
|
||||
u3 = test_create_unit(test_create_faction(), r);
|
||||
u3->faction->locale = lang;
|
||||
|
||||
str_slprintf(expect, sizeof(expect), "%s, %s and %s", factionname(u1->faction), factionname(u2->faction), factionname(u3->faction));
|
||||
|
@ -735,9 +734,9 @@ static void test_battle_skilldiff_building(CuTest *tc)
|
|||
btype = setup_castle();
|
||||
|
||||
r = test_create_region(0, 0, NULL);
|
||||
ud = test_create_unit(test_create_faction(NULL), r);
|
||||
ud = test_create_unit(test_create_faction(), r);
|
||||
ud->building = test_create_building(ud->region, btype);
|
||||
ua = test_create_unit(test_create_faction(NULL), r);
|
||||
ua = test_create_unit(test_create_faction(), r);
|
||||
td.fighter = setup_fighter(&b, ud);
|
||||
td.index = 0;
|
||||
ta.fighter = setup_fighter(&b, ua);
|
||||
|
@ -784,7 +783,7 @@ static void test_drain_exp(CuTest *tc)
|
|||
|
||||
test_setup();
|
||||
config_set("study.random_progress", "0");
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
set_level(u, SK_STAMINA, 3);
|
||||
|
||||
CuAssertIntEquals(tc, 3, unit_skill(u, SK_STAMINA)->level);
|
||||
|
@ -842,7 +841,7 @@ static void test_tactics_chance(CuTest *tc) {
|
|||
ship_type *stype;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_ocean(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_ocean(0, 0));
|
||||
CuAssertDblEquals(tc, 0.1, tactics_chance(u, 1), 0.01);
|
||||
CuAssertDblEquals(tc, 0.3, tactics_chance(u, 3), 0.01);
|
||||
stype = test_create_shiptype("brot");
|
||||
|
@ -859,8 +858,8 @@ static void test_battle_fleeing(CuTest *tc) {
|
|||
test_setup();
|
||||
setup_messages();
|
||||
r = test_create_plain(0, 0);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
u1->status = ST_FLEE;
|
||||
u2->status = ST_AGGRO;
|
||||
#if 0
|
||||
|
|
|
@ -524,7 +524,7 @@ static int tolua_region_set_age(lua_State * L)
|
|||
region *self = (region *)tolua_tousertype(L, 1, NULL);
|
||||
|
||||
if (self) {
|
||||
self->age = lua_tointeger(L, 2);
|
||||
self->age = (unsigned short)lua_tointeger(L, 2);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -556,7 +556,7 @@ static int tolua_region_set_peasants(lua_State * L)
|
|||
region *self = (region *)tolua_tousertype(L, 1, NULL);
|
||||
|
||||
if (self && self->land) {
|
||||
rsetpeasants(self, lua_tointeger(L, 2));
|
||||
rsetpeasants(self, (int)lua_tointeger(L, 2));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ static int tolua_ship_set_name(lua_State * L)
|
|||
static int tolua_ship_set_size(lua_State * L)
|
||||
{
|
||||
ship *sh = (ship *)tolua_tousertype(L, 1, NULL);
|
||||
sh->size = lua_tointeger(L, 2);
|
||||
sh->size = (int)lua_tointeger(L, 2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -271,7 +271,7 @@ static int tolua_unit_get_guard(lua_State * L)
|
|||
static int tolua_unit_set_guard(lua_State * L)
|
||||
{
|
||||
unit *u = (unit *)tolua_tousertype(L, 1, 0);
|
||||
unsigned int flags = (unsigned int)tolua_tonumber(L, 2, 0);
|
||||
int flags = tolua_toboolean(L, 2, 0);
|
||||
setguard(u, flags!=0);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -310,18 +310,6 @@ static int tolua_create_curse(lua_State * L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_learn_skill(lua_State * L)
|
||||
{
|
||||
unit *u = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *skname = tolua_tostring(L, 2, 0);
|
||||
int days = (int)tolua_tonumber(L, 3, 0);
|
||||
skill_t sk = findskill(skname);
|
||||
if (sk != NOSKILL) {
|
||||
learn_skill(u, sk, days);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_update_scores(lua_State * L)
|
||||
{
|
||||
UNUSED_ARG(L);
|
||||
|
@ -378,7 +366,7 @@ static int tolua_write_report(lua_State * L)
|
|||
{
|
||||
faction *f = (faction *)tolua_tousertype(L, 1, 0);
|
||||
if (f) {
|
||||
int result = write_reports(f);
|
||||
int result = write_reports(f, NULL);
|
||||
lua_pushinteger(L, result);
|
||||
}
|
||||
else {
|
||||
|
@ -973,7 +961,6 @@ int tolua_bindings_open(lua_State * L, const dictionary *inifile)
|
|||
tolua_function(L, TOLUA_CAST "remove_empty_units", tolua_remove_empty_units);
|
||||
tolua_function(L, TOLUA_CAST "update_scores", tolua_update_scores);
|
||||
tolua_function(L, TOLUA_CAST "update_owners", tolua_update_owners);
|
||||
tolua_function(L, TOLUA_CAST "learn_skill", tolua_learn_skill);
|
||||
tolua_function(L, TOLUA_CAST "create_curse", tolua_create_curse);
|
||||
tolua_function(L, TOLUA_CAST "translate", &tolua_translate);
|
||||
tolua_function(L, TOLUA_CAST "spells", tolua_get_spells);
|
||||
|
|
|
@ -36,7 +36,7 @@ int parsefile(FILE *F) {
|
|||
OP_SetUserData(parser, &state);
|
||||
|
||||
while (!done) {
|
||||
size_t len = (int)fread(buf, 1, sizeof(buf), F);
|
||||
int len = (int)fread(buf, 1, sizeof(buf), F);
|
||||
if (ferror(F)) {
|
||||
/* TODO: error message */
|
||||
err = errno;
|
||||
|
|
|
@ -19,10 +19,10 @@ static void test_contact(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
u2 = test_create_unit(f, r);
|
||||
u3 = test_create_unit(test_create_faction(NULL), r);
|
||||
u3 = test_create_unit(test_create_faction(), r);
|
||||
CuAssertTrue(tc, ucontact(u1, u1));
|
||||
CuAssertTrue(tc, ucontact(u1, u2));
|
||||
CuAssertTrue(tc, !ucontact(u1, u3));
|
||||
|
@ -40,30 +40,30 @@ static void test_contact_cmd(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
lang = u->faction->locale;
|
||||
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
ord = create_order(K_CONTACT, u->faction->locale, "%s %i",
|
||||
LOC(lang, parameters[P_UNIT]), u2->no);
|
||||
contact_cmd(u, ord);
|
||||
CuAssertTrue(tc, ucontact(u, u2));
|
||||
free_order(ord);
|
||||
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
ord = create_order(K_CONTACT, u->faction->locale, "%s %i",
|
||||
LOC(lang, parameters[P_FACTION]), u2->faction->no);
|
||||
contact_cmd(u, ord);
|
||||
CuAssertTrue(tc, ucontact(u, u2));
|
||||
free_order(ord);
|
||||
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
ord = create_order(K_CONTACT, u->faction->locale, "%i", u2->no);
|
||||
contact_cmd(u, ord);
|
||||
CuAssertTrue(tc, ucontact(u, u2));
|
||||
free_order(ord);
|
||||
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
usetalias(u2, 42);
|
||||
ord = create_order(K_CONTACT, u->faction->locale, "%s %i",
|
||||
LOC(lang, parameters[P_TEMP]), ualias(u2));
|
||||
|
@ -82,7 +82,7 @@ static void test_contact_cmd_invalid(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
lang = u->faction->locale;
|
||||
|
||||
/* KONTAKTIERE EINHEIT <not-found> */
|
||||
|
|
|
@ -1363,9 +1363,11 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
|
|||
fprintf(F, "%d;Rekruten\n", rpeasants(r) / RECRUITFRACTION);
|
||||
}
|
||||
if (max_production(r)) {
|
||||
int p_wage = wage(r, NULL, NULL, turn + 1);
|
||||
/* Im CR steht der Bauernlohn, der bei Trauer nur 10 ist */
|
||||
bool mourn = is_mourning(r, turn);
|
||||
int p_wage = peasant_wage(r, mourn);
|
||||
fprintf(F, "%d;Lohn\n", p_wage);
|
||||
if (is_mourning(r, turn + 1)) {
|
||||
if (mourn) {
|
||||
fputs("1;mourning\n", F);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ static void test_cr_unit(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u = test_create_unit(f, r);
|
||||
renumber_unit(u, 1234);
|
||||
|
@ -93,7 +93,7 @@ static void test_cr_resources(CuTest *tc) {
|
|||
|
||||
setup_resources();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u = test_create_unit(f, r);
|
||||
set_level(u, SK_QUARRYING, 1);
|
||||
|
@ -171,7 +171,7 @@ static void test_cr_mallorn(CuTest *tc) {
|
|||
|
||||
setup_resources();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
r->land->horses = 1;
|
||||
r->land->peasants = 200;
|
||||
|
@ -253,7 +253,7 @@ static void test_cr_hiderace(CuTest *tc) {
|
|||
struct locale * lang;
|
||||
|
||||
test_setup();
|
||||
default_locale = test_create_locale();
|
||||
default_locale = get_or_create_locale(__FUNCTION__);
|
||||
locale_setstring(default_locale, "race::elf_p", "Elfen");
|
||||
locale_setstring(default_locale, "race::elf", "elf");
|
||||
locale_setstring(default_locale, "race::human_p", "Menschen");
|
||||
|
@ -263,8 +263,8 @@ static void test_cr_hiderace(CuTest *tc) {
|
|||
locale_setstring(lang, "race::human", "human");
|
||||
locale_setstring(lang, "race::elf_p", "elves");
|
||||
locale_setstring(lang, "race::elf", "elf");
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f1 = test_create_faction_ex(NULL, default_locale);
|
||||
f2 = test_create_faction_ex(NULL, default_locale);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u = test_create_unit(f1, r);
|
||||
|
||||
|
@ -333,8 +333,8 @@ static void test_cr_factionstealth(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u = test_create_unit(f1, r);
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ static void test_add_donation(CuTest *tc) {
|
|||
test_setup();
|
||||
mt_create_va(mt_new("donation", NULL), "from:faction", "to:faction", "amount:int", MT_NEW_END);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
add_donation(f1, f2, 100, r);
|
||||
report_donations();
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(r->individual_messages->msgs, "donation"));
|
||||
|
|
|
@ -1993,7 +1993,8 @@ expandwork(region * r, econ_request * work_begin, econ_request * work_end, int m
|
|||
/* n: verbleibende Einnahmen */
|
||||
/* fishes: maximale Arbeiter */
|
||||
int jobs = maxwork;
|
||||
int p_wage = wage(r, NULL, NULL, turn);
|
||||
bool mourn = is_mourning(r, turn);
|
||||
int p_wage = peasant_wage(r, mourn);
|
||||
int money = rmoney(r);
|
||||
if (total > 0 && !rule_autowork()) {
|
||||
econ_request *o;
|
||||
|
@ -2017,7 +2018,7 @@ expandwork(region * r, econ_request * work_begin, econ_request * work_end, int m
|
|||
|
||||
assert(workers >= 0);
|
||||
|
||||
u->n = workers * wage(u->region, u->faction, u_race(u), turn);
|
||||
u->n = workers * wage(u->region, u_race(u));
|
||||
|
||||
jobs -= workers;
|
||||
assert(jobs >= 0);
|
||||
|
@ -2061,7 +2062,7 @@ static int work_cmd(unit * u, order * ord, econ_request ** io_req)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
w = wage(r, u->faction, u_race(u), turn);
|
||||
w = wage(r, u_race(u));
|
||||
add_request(req++, ECON_WORK, u, ord, w * u->number);
|
||||
*io_req = req;
|
||||
return u->number;
|
||||
|
|
|
@ -37,7 +37,7 @@ static void test_give_control_building(CuTest * tc)
|
|||
region *r;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
b = test_create_building(r, NULL);
|
||||
u1 = test_create_unit(f, r);
|
||||
|
@ -58,7 +58,7 @@ static void test_give_control_ship(CuTest * tc)
|
|||
region *r;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
sh = test_create_ship(r, NULL);
|
||||
u1 = test_create_unit(f, r);
|
||||
|
@ -79,7 +79,7 @@ struct steal {
|
|||
|
||||
static void setup_steal(struct steal *env, struct terrain_type *ter, struct race *rc) {
|
||||
env->r = test_create_region(0, 0, ter);
|
||||
env->f = test_create_faction(rc);
|
||||
env->f = test_create_faction_ex(rc, NULL);
|
||||
env->u = test_create_unit(env->f, env->r);
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ static struct unit *create_recruiter(void) {
|
|||
|
||||
r=test_create_region(0, 0, NULL);
|
||||
rsetpeasants(r, 999);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
rtype = get_resourcetype(R_SILVER);
|
||||
change_resource(u, rtype, 1000);
|
||||
|
@ -228,7 +228,7 @@ static unit *setup_trade_unit(CuTest *tc, region *r, const struct race *rc) {
|
|||
unit *u;
|
||||
|
||||
UNUSED_ARG(tc);
|
||||
u = test_create_unit(test_create_faction(rc), r);
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
set_level(u, SK_TRADE, 2);
|
||||
return u;
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ static void test_trade_limits(CuTest *tc) {
|
|||
b->size = 2;
|
||||
rsetpeasants(r, TRADE_FRACTION * 20);
|
||||
it_jewel = it_find("jewel");
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
set_level(u, SK_TRADE, 1);
|
||||
i_change(&u->items, it_find("money"), 500);
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, "5 %s",
|
||||
|
@ -288,7 +288,7 @@ static void test_trade_needs_castle(CuTest *tc) {
|
|||
CuAssertTrue(tc, trade_needs_castle(t_desert, rc));
|
||||
CuAssertTrue(tc, trade_needs_castle(t_plain, rc));
|
||||
|
||||
u = test_create_unit(test_create_faction(rc), r);
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, "1 %s",
|
||||
LOC(u->faction->locale, resourcename(it_luxury->rtype, 0))));
|
||||
unit_addorder(u, create_order(K_SELL, u->faction->locale, "1 %s",
|
||||
|
@ -366,7 +366,7 @@ static void test_buy_cmd(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, rt_silver);
|
||||
CuAssertPtrNotNull(tc, rt_silver->itype);
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, "1 %s", LOC(u->faction->locale, resourcename(it_luxury->rtype, 0))));
|
||||
test_set_item(u, rt_silver->itype, 1000);
|
||||
|
||||
|
@ -418,7 +418,7 @@ static void test_tax_cmd(CuTest *tc) {
|
|||
test_setup();
|
||||
setup_production();
|
||||
config_set("taxing.perlevel", "20");
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
assert(r && f);
|
||||
u = test_create_unit(f, r);
|
||||
|
@ -487,7 +487,7 @@ static void test_maintain_buildings(CuTest *tc) {
|
|||
btype = test_create_buildingtype("Hort");
|
||||
btype->maxsize = 10;
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
b = test_create_building(r, btype);
|
||||
itype = test_create_itemtype("money");
|
||||
|
@ -544,7 +544,7 @@ static void test_recruit(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
setup_economy();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
CuAssertIntEquals(tc, 1, u->number);
|
||||
CuAssertIntEquals(tc, 1, f->num_people);
|
||||
|
@ -571,7 +571,7 @@ static void test_recruit_insect(CuTest *tc) {
|
|||
test_setup();
|
||||
test_create_calendar();
|
||||
test_create_terrain("desert", -1);
|
||||
f = test_create_faction(test_create_race("insect"));
|
||||
f = test_create_faction_ex(test_create_race("insect"), NULL);
|
||||
u = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
u->thisorder = create_order(K_RECRUIT, f->locale, "%d", 1);
|
||||
|
||||
|
@ -600,7 +600,7 @@ static void test_income(CuTest *tc)
|
|||
unit *u;
|
||||
test_setup();
|
||||
rc = test_create_race("nerd");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
CuAssertIntEquals(tc, 20, income(u));
|
||||
u->number = 5;
|
||||
CuAssertIntEquals(tc, 100, income(u));
|
||||
|
@ -616,7 +616,7 @@ static void test_modify_material(CuTest *tc) {
|
|||
test_setup();
|
||||
setup_production();
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
set_level(u, SK_WEAPONSMITH, 1);
|
||||
|
||||
/* the unit's race gets 2x savings on iron used to produce goods */
|
||||
|
@ -665,7 +665,7 @@ static void test_modify_skill(CuTest *tc) {
|
|||
test_setup();
|
||||
setup_production();
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
set_level(u, SK_WEAPONSMITH, 1);
|
||||
|
||||
itype = test_create_itemtype("iron");
|
||||
|
@ -728,7 +728,7 @@ static void test_modify_production(CuTest *tc) {
|
|||
rt_silver = get_resourcetype(R_SILVER);
|
||||
itype = test_create_itemtype("stone");
|
||||
rtype = itype->rtype;
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
make_item(u, itype, 1);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error_cannotmake"));
|
||||
CuAssertIntEquals(tc, 0, get_item(u, itype));
|
||||
|
@ -825,7 +825,7 @@ static void test_loot(CuTest *tc) {
|
|||
mt_create_error(48); /* unit is unarmed */
|
||||
it_silver = test_create_silver();
|
||||
config_set("rules.enable_loot", "1");
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->thisorder = create_order(K_LOOT, f->locale, NULL);
|
||||
produce(u->region);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error48")); /* unit is unarmed */
|
||||
|
@ -847,7 +847,7 @@ static void test_expand_production(CuTest *tc) {
|
|||
test_setup();
|
||||
orders = calloc(1, sizeof(econ_request));
|
||||
orders->qty = 2;
|
||||
orders->unit = u = test_create_unit(test_create_faction(NULL), r = test_create_region(0, 0, NULL));
|
||||
orders->unit = u = test_create_unit(test_create_faction(), r = test_create_region(0, 0, NULL));
|
||||
orders->next = NULL;
|
||||
|
||||
u->n = 1; /* will be overwritten */
|
||||
|
|
|
@ -1577,7 +1577,7 @@ int exparse_readfile(const char * filename) {
|
|||
XML_SetUserData(xp, &pi);
|
||||
memset(&pi, 0, sizeof(pi));
|
||||
for (;;) {
|
||||
size_t len = (int)fread(buf, 1, sizeof(buf), F);
|
||||
int len = (int)fread(buf, 1, sizeof(buf), F);
|
||||
int done;
|
||||
|
||||
if (ferror(F)) {
|
||||
|
|
|
@ -54,7 +54,6 @@ static void setup_give(struct give *env) {
|
|||
env->dst = NULL;
|
||||
}
|
||||
if (env->lang) {
|
||||
locale_setstring(env->lang, env->itype->rtype->_name, "SILBER");
|
||||
init_locale(env->lang);
|
||||
env->f1->locale = env->lang;
|
||||
}
|
||||
|
@ -90,8 +89,8 @@ static void test_give_unit(CuTest * tc) {
|
|||
struct give env = { 0 };
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f2 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = test_create_faction();
|
||||
setup_give(&env);
|
||||
|
||||
CuAssertIntEquals(tc, 1, env.f1->num_units);
|
||||
|
@ -120,8 +119,8 @@ static void test_give_unit_humans(CuTest * tc) {
|
|||
race *rc;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(test_create_race("elf"));
|
||||
env.f2 = test_create_faction(rc = test_create_race("human"));
|
||||
env.f1 = test_create_faction_ex(test_create_race("elf"), NULL);
|
||||
env.f2 = test_create_faction_ex(rc = test_create_race("human"), env.f1->locale);
|
||||
rc->flags |= RCF_MIGRANTS;
|
||||
setup_give(&env);
|
||||
|
||||
|
@ -139,8 +138,8 @@ static void test_give_unit_humans(CuTest * tc) {
|
|||
static void test_give_unit_other_race(CuTest * tc) {
|
||||
struct give env = { 0 };
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(test_create_race("elf"));
|
||||
env.f2 = test_create_faction(test_create_race("orc"));
|
||||
env.f1 = test_create_faction_ex(test_create_race("elf"), NULL);
|
||||
env.f2 = test_create_faction_ex(test_create_race("orc"), env.f1->locale);
|
||||
setup_give(&env);
|
||||
scale_number(env.dst, 57);
|
||||
CuAssertIntEquals(tc, 0, count_maxmigrants(env.f2));
|
||||
|
@ -153,8 +152,8 @@ static void test_give_unit_other_race(CuTest * tc) {
|
|||
static void test_give_unit_limits(CuTest * tc) {
|
||||
struct give env = { 0 };
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f2 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = test_create_faction();
|
||||
setup_give(&env);
|
||||
config_set("rules.limit.faction", "1");
|
||||
|
||||
|
@ -170,7 +169,7 @@ static void test_give_unit_limits(CuTest * tc) {
|
|||
static void test_give_unit_to_peasants(CuTest * tc) {
|
||||
struct give env = { 0 };
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = 0;
|
||||
setup_give(&env);
|
||||
rsetpeasants(env.r, 0);
|
||||
|
@ -183,7 +182,7 @@ static void test_give_unit_to_peasants(CuTest * tc) {
|
|||
static void test_give_unit_to_ocean(CuTest * tc) {
|
||||
struct give env = { 0 };
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = 0;
|
||||
setup_give(&env);
|
||||
env.r->terrain = test_create_terrain("ocean", SEA_REGION);
|
||||
|
@ -196,7 +195,7 @@ static void test_give_men(CuTest * tc) {
|
|||
struct give env = { 0 };
|
||||
message * msg;
|
||||
test_setup_ex(tc);
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
env.f2 = env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
CuAssertPtrEquals(tc, NULL, msg = give_men(1, env.src, env.dst, NULL));
|
||||
assert(!msg);
|
||||
|
@ -212,7 +211,7 @@ static void test_give_men_magicians(CuTest * tc) {
|
|||
|
||||
test_setup_ex(tc);
|
||||
mt_create_error(158);
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
env.f2 = env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
set_level(env.src, SK_MAGIC, 1);
|
||||
CuAssertPtrNotNull(tc, msg = give_men(1, env.src, env.dst, NULL));
|
||||
|
@ -236,8 +235,8 @@ static void test_give_men_limit(CuTest * tc) {
|
|||
message *msg;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f2 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f2 = test_create_faction();
|
||||
env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
config_set("rules.give.max_men", "1");
|
||||
|
||||
|
@ -267,7 +266,7 @@ static void test_give_men_in_ocean(CuTest * tc) {
|
|||
message * msg;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = 0;
|
||||
setup_give(&env);
|
||||
env.r->terrain = test_create_terrain("ocean", SEA_REGION);
|
||||
|
@ -283,7 +282,7 @@ static void test_give_men_too_many(CuTest * tc) {
|
|||
message * msg;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
env.f2 = env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
CuAssertPtrEquals(tc, NULL, msg = give_men(2, env.src, env.dst, NULL));
|
||||
assert(!msg);
|
||||
|
@ -296,7 +295,7 @@ static void test_give_cmd_limit(CuTest * tc) {
|
|||
struct give env = { 0 };
|
||||
unit *u;
|
||||
test_setup_ex(tc);
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
env.f2 = env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
u = env.src;
|
||||
scale_number(u, 2);
|
||||
|
@ -312,7 +311,7 @@ static void test_give_men_none(CuTest * tc) {
|
|||
message * msg;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
env.f2 = env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
msg = give_men(0, env.src, env.dst, NULL);
|
||||
CuAssertStrEquals(tc, "error96", test_get_messagetype(msg));
|
||||
|
@ -327,8 +326,8 @@ static void test_give_men_other_faction(CuTest * tc) {
|
|||
message * msg;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f2 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = test_create_faction();
|
||||
setup_give(&env);
|
||||
contact_unit(env.dst, env.src);
|
||||
msg = give_men(1, env.src, env.dst, NULL);
|
||||
|
@ -345,8 +344,8 @@ static void test_give_men_requires_contact(CuTest * tc) {
|
|||
order *ord;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f2 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = test_create_faction();
|
||||
setup_give(&env);
|
||||
msg = give_men(1, env.src, env.dst, NULL);
|
||||
CuAssertStrEquals(tc, "feedback_no_contact", test_get_messagetype(msg));
|
||||
|
@ -368,7 +367,7 @@ static void test_give_men_not_to_self(CuTest * tc) {
|
|||
struct give env = { 0 };
|
||||
message * msg;
|
||||
test_setup_ex(tc);
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
env.f2 = env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
msg = give_men(1, env.src, env.src, NULL);
|
||||
CuAssertStrEquals(tc, "error10", test_get_messagetype(msg));
|
||||
|
@ -382,7 +381,7 @@ static void test_give_peasants(CuTest * tc) {
|
|||
message * msg;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = 0;
|
||||
setup_give(&env);
|
||||
rsetpeasants(env.r, 0);
|
||||
|
@ -398,7 +397,7 @@ static void test_give(CuTest * tc) {
|
|||
struct give env = { 0 };
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
env.f2 = env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
|
||||
i_change(&env.src->items, env.itype, 10);
|
||||
|
@ -418,7 +417,7 @@ static void test_give_cmd(CuTest * tc) {
|
|||
|
||||
test_setup_ex(tc);
|
||||
env.lang = test_create_locale();
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
env.f2 = env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
|
||||
i_change(&env.src->items, env.itype, 10);
|
||||
|
@ -438,7 +437,7 @@ static void test_give_herbs(CuTest * tc) {
|
|||
struct order *ord;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
env.f2 = env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
i_change(&env.src->items, env.itype, 10);
|
||||
|
||||
|
@ -456,7 +455,7 @@ static void test_give_okay(CuTest * tc) {
|
|||
struct give env = { 0 };
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
env.f2 = env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
|
||||
config_set("rules.give.flags", "0");
|
||||
|
@ -469,8 +468,8 @@ static void test_give_denied_by_rules(CuTest * tc) {
|
|||
struct message *msg;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f2 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = test_create_faction();
|
||||
setup_give(&env);
|
||||
|
||||
config_set("rules.give.flags", "0");
|
||||
|
@ -484,8 +483,8 @@ static void test_give_dead_unit(CuTest * tc) {
|
|||
struct message *msg;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f2 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = test_create_faction();
|
||||
setup_give(&env);
|
||||
env.dst->number = 0;
|
||||
freset(env.dst, UFL_ISNEW);
|
||||
|
@ -498,8 +497,8 @@ static void test_give_new_unit(CuTest * tc) {
|
|||
struct give env = { 0 };
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f2 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = test_create_faction();
|
||||
setup_give(&env);
|
||||
env.dst->number = 0;
|
||||
fset(env.dst, UFL_ISNEW);
|
||||
|
@ -513,7 +512,7 @@ static void test_give_invalid_target(CuTest *tc) {
|
|||
order *ord;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = 0;
|
||||
setup_give(&env);
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ static void test_is_guarded(CuTest *tc) {
|
|||
rc = rc_get_or_create("dragon");
|
||||
rc->flags |= RCF_UNARMEDGUARD;
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(rc), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
CuAssertPtrEquals(tc, NULL, is_guarded(r, u1));
|
||||
setguard(u2, true);
|
||||
CuAssertPtrEquals(tc, u2, is_guarded(r, u1));
|
||||
|
@ -46,8 +46,8 @@ static void test_guard_unskilled(CuTest * tc)
|
|||
itype = it_get_or_create(rt_get_or_create("sword"));
|
||||
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
ug = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
ug = test_create_unit(test_create_faction(), r);
|
||||
i_change(&ug->items, itype, 1);
|
||||
|
||||
setguard(ug, true);
|
||||
|
@ -70,8 +70,8 @@ static void test_guard_armed(CuTest * tc)
|
|||
itype = it_get_or_create(rt_get_or_create("sword"));
|
||||
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
ug = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
ug = test_create_unit(test_create_faction(), r);
|
||||
i_change(&ug->items, itype, 1);
|
||||
set_level(ug, SK_MELEE, 2);
|
||||
setguard(ug, true);
|
||||
|
@ -89,7 +89,7 @@ static void test_is_guard(CuTest * tc)
|
|||
itype = it_get_or_create(rt_get_or_create("sword"));
|
||||
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
ug = test_create_unit(test_create_faction(NULL), r);
|
||||
ug = test_create_unit(test_create_faction(), r);
|
||||
i_change(&ug->items, itype, 1);
|
||||
setguard(ug, true);
|
||||
CuAssertIntEquals(tc, 0, armedmen(ug, false));
|
||||
|
@ -110,8 +110,8 @@ static void test_guard_unarmed(CuTest * tc)
|
|||
rc = test_create_race("mountainguard");
|
||||
rc->flags |= RCF_UNARMEDGUARD;
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
ug = test_create_unit(test_create_faction(rc), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
ug = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
setguard(ug, true);
|
||||
CuAssertPtrEquals(tc, ug, is_guarded(r, u));
|
||||
test_teardown();
|
||||
|
@ -124,7 +124,7 @@ static void test_guard_monsters(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
ug = test_create_unit(get_monsters(), r);
|
||||
setguard(ug, true);
|
||||
CuAssertPtrEquals(tc, ug, is_guarded(r, u));
|
||||
|
@ -145,7 +145,7 @@ static void test_update_guard(CuTest * tc)
|
|||
itype = it_get_or_create(rt_get_or_create("sword"));
|
||||
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
|
||||
r = test_create_region(0, 0, t_plain);
|
||||
ug = test_create_unit(test_create_faction(NULL), r);
|
||||
ug = test_create_unit(test_create_faction(), r);
|
||||
i_change(&ug->items, itype, 1);
|
||||
set_level(ug, SK_MELEE, 1);
|
||||
setguard(ug, true);
|
||||
|
@ -172,7 +172,7 @@ static void test_guard_on(CuTest * tc)
|
|||
itype = it_get_or_create(rt_get_or_create("sword"));
|
||||
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
|
||||
r = test_create_region(0, 0, t_plain);
|
||||
ug = test_create_unit(test_create_faction(NULL), r);
|
||||
ug = test_create_unit(test_create_faction(), r);
|
||||
i_change(&ug->items, itype, 1);
|
||||
set_level(ug, SK_MELEE, 1);
|
||||
ug->thisorder = create_order(K_GUARD, ug->faction->locale, NULL);
|
||||
|
|
|
@ -37,7 +37,7 @@ struct order *ord)
|
|||
skill *sv = u->skills;
|
||||
while (sv != u->skills + u->skill_size) {
|
||||
/* only one person learns for 3 weeks */
|
||||
learn_skill(u, (skill_t)sv->id, STUDYDAYS * 3);
|
||||
change_skill_days(u, (skill_t)sv->id, STUDYDAYS * 3);
|
||||
++sv;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ static void test_manacrystal(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
itype = test_create_itemtype("manacrystal");
|
||||
change_resource(u, itype->rtype, 1);
|
||||
CuAssertIntEquals(tc, -1, use_manacrystal(u, itype, 1, NULL));
|
||||
|
@ -48,21 +48,21 @@ static void test_skillpotion(CuTest *tc) {
|
|||
int initialWeeks_Magic = 0;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
itype = test_create_itemtype("skillpotion");
|
||||
change_resource(u, itype->rtype, 2);
|
||||
|
||||
learn_skill(u, SK_ENTERTAINMENT, STUDYDAYS * u->number);
|
||||
change_skill_days(u, SK_ENTERTAINMENT, STUDYDAYS * u->number);
|
||||
pSkill = unit_skill(u, SK_ENTERTAINMENT);
|
||||
sk_set(pSkill, 5);
|
||||
initialWeeks_Entertainment = pSkill->weeks = 4;
|
||||
|
||||
learn_skill(u, SK_STAMINA, STUDYDAYS * u->number);
|
||||
change_skill_days(u, SK_STAMINA, STUDYDAYS * u->number);
|
||||
pSkill = unit_skill(u, SK_STAMINA);
|
||||
sk_set(pSkill, 5);
|
||||
initialWeeks_Stamina = pSkill->weeks = 4;
|
||||
|
||||
learn_skill(u, SK_MAGIC, STUDYDAYS * u->number);
|
||||
change_skill_days(u, SK_MAGIC, STUDYDAYS * u->number);
|
||||
pSkill = unit_skill(u, SK_MAGIC);
|
||||
sk_set(pSkill, 5);
|
||||
initialWeeks_Magic = pSkill->weeks = 4;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
cmake_minimum_required(VERSION 2.6)
|
||||
project(kernel C)
|
||||
|
||||
SET(_DBFILES db/memory.c)
|
||||
|
|
|
@ -12,16 +12,14 @@
|
|||
#include <assert.h>
|
||||
|
||||
typedef struct alliance_fixture {
|
||||
struct race * rc;
|
||||
struct faction *f1, *f2;
|
||||
} alliance_fixture;
|
||||
|
||||
static void setup_alliance(alliance_fixture *fix) {
|
||||
test_setup();
|
||||
fix->rc = test_create_race("human");
|
||||
fix->f1 = test_create_faction(fix->rc);
|
||||
fix->f2 = test_create_faction(fix->rc);
|
||||
assert(fix->rc && fix->f1 && fix->f2);
|
||||
fix->f1 = test_create_faction();
|
||||
fix->f2 = test_create_faction();
|
||||
assert(fix->f1 && fix->f2);
|
||||
}
|
||||
|
||||
static void test_alliance_make(CuTest *tc) {
|
||||
|
@ -69,8 +67,8 @@ static void test_alliance_dead_faction(CuTest *tc) {
|
|||
alliance *al;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
al = makealliance(42, "Hodor");
|
||||
setalliance(f, al);
|
||||
setalliance(f2, al);
|
||||
|
@ -92,8 +90,8 @@ static void test_alliance_cmd(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
unit_addorder(u1, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_NEW], itoa36(42)));
|
||||
unit_addorder(u1, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_INVITE], itoa36(u2->faction->no)));
|
||||
unit_addorder(u2, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_JOIN], itoa36(42)));
|
||||
|
@ -118,8 +116,8 @@ static void test_alliance_limits(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
|
||||
config_set("rules.limit.alliance", "1");
|
||||
unit_addorder(u1, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_NEW], itoa36(42)));
|
||||
|
@ -143,8 +141,8 @@ static void test_alliance_cmd_kick(CuTest *tc) {
|
|||
test_setup();
|
||||
al = makealliance(42, "Hodor");
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
setalliance(u1->faction, al);
|
||||
setalliance(u2->faction, al);
|
||||
|
||||
|
@ -162,8 +160,8 @@ static void test_alliance_cmd_no_invite(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
unit_addorder(u1, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_NEW], itoa36(42)));
|
||||
unit_addorder(u2, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_JOIN], itoa36(42)));
|
||||
CuAssertTrue(tc, is_allied(u1->faction, u1->faction));
|
||||
|
@ -184,8 +182,8 @@ static void test_alliance_cmd_leave(CuTest *tc) {
|
|||
test_setup();
|
||||
al = makealliance(42, "Hodor");
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
setalliance(u1->faction, al);
|
||||
setalliance(u2->faction, al);
|
||||
|
||||
|
@ -205,8 +203,8 @@ static void test_alliance_cmd_transfer(CuTest *tc) {
|
|||
test_setup();
|
||||
al = makealliance(42, "Hodor");
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
setalliance(u1->faction, al);
|
||||
setalliance(u2->faction, al);
|
||||
CuAssertPtrEquals(tc, u1->faction, alliance_get_leader(al));
|
||||
|
|
|
@ -12,7 +12,7 @@ static void test_allies_clone(CuTest * tc)
|
|||
struct faction * f;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
CuAssertPtrEquals(tc, NULL, allies_clone(NULL));
|
||||
|
||||
ally_set(&al, f, HELP_GUARD);
|
||||
|
@ -31,7 +31,7 @@ static void test_allies(CuTest *tc) {
|
|||
struct faction * f;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
|
||||
CuAssertIntEquals(tc, 0, ally_get(al, f));
|
||||
ally_set(&al, f, 42);
|
||||
|
@ -47,8 +47,8 @@ static void test_allies_set(CuTest *tc) {
|
|||
struct allies * al = NULL;
|
||||
|
||||
test_setup();
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
|
||||
CuAssertPtrEquals(tc, NULL, al);
|
||||
ally_set(&al, f1, HELP_ALL);
|
||||
|
|
|
@ -43,7 +43,7 @@ static unit * setup_build(build_fixture *bf) {
|
|||
bf->btype = test_create_buildingtype("castle");
|
||||
bf->rc = test_create_race("human");
|
||||
bf->r = test_create_region(0, 0, NULL);
|
||||
bf->f = test_create_faction(bf->rc);
|
||||
bf->f = test_create_faction_ex(bf->rc, NULL);
|
||||
assert(bf->rc && bf->f && bf->r);
|
||||
bf->u = test_create_unit(bf->f, bf->r);
|
||||
assert(bf->u);
|
||||
|
@ -100,7 +100,7 @@ static void test_build_building_stages(CuTest *tc) {
|
|||
init_resources();
|
||||
it_stone = test_create_itemtype("stone");
|
||||
btype = setup_castle(it_stone);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u->building = test_create_building(u->region, btype);
|
||||
u->building->size = 1;
|
||||
set_level(u, SK_BUILDING, 2);
|
||||
|
@ -122,7 +122,7 @@ static void test_build_building_stage_continue(CuTest *tc) {
|
|||
init_resources();
|
||||
it_stone = test_create_itemtype("stone");
|
||||
btype = setup_castle(it_stone);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
set_level(u, SK_BUILDING, 2);
|
||||
i_change(&u->items, it_stone, 4);
|
||||
build_building(u, btype, -1, INT_MAX, NULL);
|
||||
|
@ -337,7 +337,7 @@ static void test_build_destroy_road(CuTest *tc)
|
|||
r2 = test_create_region(1, 0, 0);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
rsetroad(r, D_EAST, 100);
|
||||
u = test_create_unit(f = test_create_faction(NULL), r);
|
||||
u = test_create_unit(f = test_create_faction(), r);
|
||||
u->orders = ord = create_order(K_DESTROY, f->locale, "%s %s", LOC(f->locale, parameters[P_ROAD]), LOC(f->locale, directions[D_EAST]));
|
||||
|
||||
CuAssertIntEquals(tc, 0, destroy_cmd(u, ord));
|
||||
|
@ -371,7 +371,7 @@ unit *test_create_guard(region *r, faction *f, race *rc) {
|
|||
rc->flags |= RCF_UNARMEDGUARD;
|
||||
}
|
||||
if (!f) {
|
||||
f = test_create_faction(rc);
|
||||
f = test_create_faction_ex(rc, NULL);
|
||||
}
|
||||
ug = test_create_unit(f, r);
|
||||
setguard(ug, true);
|
||||
|
@ -391,7 +391,7 @@ static void test_build_destroy_road_guard(CuTest *tc)
|
|||
r = test_create_region(0, 0, NULL);
|
||||
rsetroad(r, D_EAST, 100);
|
||||
ug = test_create_guard(r, 0, 0);
|
||||
u = test_create_unit(f = test_create_faction(NULL), r);
|
||||
u = test_create_unit(f = test_create_faction(), r);
|
||||
u->orders = ord = create_order(K_DESTROY, f->locale, "%s %s", LOC(f->locale, parameters[P_ROAD]), LOC(f->locale, directions[D_EAST]));
|
||||
|
||||
set_level(u, SK_ROAD_BUILDING, 1);
|
||||
|
@ -422,7 +422,7 @@ static void test_build_destroy_road_limit(CuTest *tc)
|
|||
test_create_region(1, 0, 0);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
rsetroad(r, D_EAST, 100);
|
||||
u = test_create_unit(f = test_create_faction(NULL), r);
|
||||
u = test_create_unit(f = test_create_faction(), r);
|
||||
u->orders = ord = create_order(K_DESTROY, f->locale, "1 %s %s", LOC(f->locale, parameters[P_ROAD]), LOC(f->locale, directions[D_EAST]));
|
||||
|
||||
set_level(u, SK_ROAD_BUILDING, 1);
|
||||
|
@ -444,7 +444,7 @@ static void test_build_destroy_cmd(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
mt_create_error(138);
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->thisorder = create_order(K_DESTROY, f->locale, NULL);
|
||||
CuAssertIntEquals(tc, 138, destroy_cmd(u, u->thisorder));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error138"));
|
||||
|
|
|
@ -126,6 +126,7 @@ building_type *bt_get_or_create(const char *name)
|
|||
btype->maxsize = -1;
|
||||
btype->capacity = 1;
|
||||
btype->maxcapacity = -1;
|
||||
btype->magres = frac_zero;
|
||||
bt_register(btype);
|
||||
}
|
||||
return btype;
|
||||
|
@ -495,20 +496,22 @@ extern struct attrib_type at_icastle;
|
|||
/** returns the building's build stage (NOT size in people).
|
||||
* only makes sense for castles or similar buildings with multiple
|
||||
* stages */
|
||||
int buildingeffsize(const building * b, int img)
|
||||
int buildingeffsize(const building * b, bool imaginary)
|
||||
{
|
||||
const struct building_type *btype = NULL;
|
||||
|
||||
if (b == NULL)
|
||||
return 0;
|
||||
|
||||
btype = b->type;
|
||||
if (img) {
|
||||
if (imaginary) {
|
||||
const attrib *a = a_find(b->attribs, &at_icastle);
|
||||
if (a) {
|
||||
btype = (const struct building_type *)a->data.v;
|
||||
}
|
||||
}
|
||||
else {
|
||||
btype = b->type;
|
||||
}
|
||||
return bt_effsize(btype, b, b->size);
|
||||
}
|
||||
|
||||
|
@ -518,7 +521,7 @@ int bt_effsize(const building_type * btype, const building * b, int bsize)
|
|||
bsize = adjust_size(b, bsize);
|
||||
}
|
||||
|
||||
if (btype->stages) {
|
||||
if (btype && btype->stages) {
|
||||
int n = 0;
|
||||
const building_stage *stage = btype->stages;
|
||||
do {
|
||||
|
@ -728,7 +731,7 @@ static const int wagetable[7][3] = {
|
|||
};
|
||||
|
||||
static int
|
||||
default_wage(const region * r, const faction * f, const race * rc, int in_turn)
|
||||
default_wage(const region * r, const race * rc)
|
||||
{
|
||||
building *b = largestbuilding(r, cmp_wage, false);
|
||||
int esize = 0;
|
||||
|
@ -739,25 +742,23 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn)
|
|||
esize = buildingeffsize(b, false);
|
||||
}
|
||||
|
||||
if (f != NULL) {
|
||||
if (rc != NULL) {
|
||||
static const struct race *rc_orc, *rc_snotling;
|
||||
static int rc_cache;
|
||||
int index = 0;
|
||||
if (rc == get_race(RC_ORC) || rc == get_race(RC_SNOTLING)) {
|
||||
if (rc_changed(&rc_cache)) {
|
||||
rc_orc = get_race(RC_ORC);
|
||||
rc_snotling = get_race(RC_SNOTLING);
|
||||
}
|
||||
if (rc == rc_orc || rc == rc_snotling) {
|
||||
index = 1;
|
||||
}
|
||||
wage = wagetable[esize][index];
|
||||
}
|
||||
else {
|
||||
if (is_mourning(r, in_turn)) {
|
||||
wage = 10;
|
||||
}
|
||||
else if (fval(r->terrain, SEA_REGION)) {
|
||||
wage = 11;
|
||||
}
|
||||
else {
|
||||
wage = wagetable[esize][2];
|
||||
}
|
||||
if (r->attribs && rule_blessed_harvest() == HARVEST_WORK) {
|
||||
/* E1 rules */
|
||||
wage = wagetable[esize][2];
|
||||
if (rule_blessed_harvest() & HARVEST_WORK) {
|
||||
/* Geändert in E3 */
|
||||
wage += harvest_effect(r);
|
||||
}
|
||||
}
|
||||
|
@ -766,7 +767,7 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn)
|
|||
attrib *a;
|
||||
curse *c;
|
||||
variant vm;
|
||||
|
||||
|
||||
/* Godcurse: Income -10 */
|
||||
vm = frac_make(wage, 1);
|
||||
|
||||
|
@ -786,31 +787,37 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn)
|
|||
}
|
||||
|
||||
static int
|
||||
minimum_wage(const region * r, const faction * f, const race * rc, int in_turn)
|
||||
minimum_wage(const region * r, const race * rc)
|
||||
{
|
||||
if (f && rc) {
|
||||
if (rc) {
|
||||
return rc->maintenance;
|
||||
}
|
||||
return default_wage(r, f, rc, in_turn);
|
||||
return default_wage(r, rc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt Arbeitslohn fuer entsprechende Rasse zurueck, oder fuer
|
||||
* die Bauern wenn f == NULL. */
|
||||
int wage(const region * r, const faction * f, const race * rc, int in_turn)
|
||||
* die Bauern wenn rc == NULL. */
|
||||
int wage(const region * r, const race * rc)
|
||||
{
|
||||
static int config;
|
||||
static int rule_wage;
|
||||
if (config_changed(&config)) {
|
||||
rule_wage = config_get_int("rules.wage.function", 1);
|
||||
}
|
||||
if (rule_wage==0) {
|
||||
if (rule_wage == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (rule_wage==1) {
|
||||
return default_wage(r, f, rc, in_turn);
|
||||
|
||||
if (rule_wage == 1) {
|
||||
return default_wage(r, rc);
|
||||
}
|
||||
return minimum_wage(r, f, rc, in_turn);
|
||||
return minimum_wage(r, rc);
|
||||
}
|
||||
|
||||
int peasant_wage(const struct region *r, bool mourn)
|
||||
{
|
||||
return mourn ? 10 : wage(r, NULL);
|
||||
}
|
||||
|
||||
int cmp_wage(const struct building *b, const building * a)
|
||||
|
|
|
@ -116,8 +116,8 @@ extern "C" {
|
|||
int id, int size, struct order *ord);
|
||||
bool building_finished(const struct building *b);
|
||||
|
||||
int wage(const struct region *r, const struct faction *f,
|
||||
const struct race *rc, int in_turn);
|
||||
int wage(const struct region *r, const struct race *rc);
|
||||
int peasant_wage(const struct region *r, bool mourn);
|
||||
|
||||
typedef int(*cmp_building_cb) (const struct building * b,
|
||||
const struct building * a);
|
||||
|
@ -130,7 +130,7 @@ extern "C" {
|
|||
int building_taxes(const building *b);
|
||||
|
||||
/* old functions, still in build.c: */
|
||||
int buildingeffsize(const building * b, int imaginary);
|
||||
int buildingeffsize(const building * b, bool imaginary);
|
||||
void bhash(struct building *b);
|
||||
void bunhash(struct building *b);
|
||||
int buildingcapacity(const struct building *b);
|
||||
|
|
|
@ -44,7 +44,7 @@ static void test_building_set_owner(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
|
||||
bld = test_create_building(r, NULL);
|
||||
|
@ -69,7 +69,7 @@ static void test_buildingowner_goes_to_next_when_empty(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
bld = test_create_building(r, NULL);
|
||||
|
@ -95,7 +95,7 @@ static void test_buildingowner_goes_to_other_when_empty(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
bld = test_create_building(r, NULL);
|
||||
|
@ -122,8 +122,8 @@ static void test_buildingowner_goes_to_same_faction_when_empty(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
bld = test_create_building(r, NULL);
|
||||
|
@ -152,7 +152,7 @@ static void test_buildingowner_goes_to_next_after_leave(CuTest * tc)
|
|||
struct faction *f;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
bld = test_create_building(r, NULL);
|
||||
|
@ -178,7 +178,7 @@ static void test_buildingowner_goes_to_other_after_leave(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
bld = test_create_building(r, NULL);
|
||||
|
@ -204,8 +204,8 @@ static void test_buildingowner_goes_to_same_faction_after_leave(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
bld = test_create_building(r, NULL);
|
||||
|
@ -237,7 +237,7 @@ static void test_buildingowner_resets_when_empty(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
bld = test_create_building(r, NULL);
|
||||
|
@ -263,7 +263,7 @@ void test_buildingowner_goes_to_empty_unit_after_leave(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
|
||||
f1 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
bld = test_create_building(r, NULL);
|
||||
|
@ -358,7 +358,7 @@ static void test_active_building(CuTest *tc) {
|
|||
btype = test_create_buildingtype("castle");
|
||||
assert(btype && btype->maxsize == -1);
|
||||
b = test_create_building(r = test_create_region(0, 0, NULL), btype);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
CuAssertIntEquals(tc, false, building_is_active(b));
|
||||
CuAssertPtrEquals(tc, NULL, active_building(u, btype));
|
||||
|
||||
|
@ -388,8 +388,8 @@ static void test_safe_building(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
btype = test_create_buildingtype("castle");
|
||||
u1 = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u2 = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u1 = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u2 = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
CuAssertIntEquals(tc, false, in_safe_building(u1, u2));
|
||||
u1->building = test_create_building(u1->region, btype);
|
||||
CuAssertIntEquals(tc, false, in_safe_building(u1, u2));
|
||||
|
@ -422,9 +422,9 @@ static void test_cmp_castle_size(CuTest *tc) {
|
|||
r = test_create_region(0, 0, NULL);
|
||||
b1 = test_create_building(r, NULL);
|
||||
b2 = test_create_building(r, NULL);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u_set_building(u1, b1);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
u_set_building(u2, b2);
|
||||
b1->size = 5;
|
||||
b2->size = 10;
|
||||
|
@ -434,6 +434,80 @@ static void test_cmp_castle_size(CuTest *tc) {
|
|||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_wage(CuTest *tc) {
|
||||
region *r;
|
||||
building *b;
|
||||
building_type *btype;
|
||||
struct building_stage *stage;
|
||||
race *rc_orc, *rc_elf;
|
||||
test_setup();
|
||||
rc_orc = test_create_race("orc");
|
||||
rc_elf = test_create_race("elf");
|
||||
rc_elf->maintenance = 13;
|
||||
btype = test_create_buildingtype("castle");
|
||||
stage = btype->stages;
|
||||
stage->construction->maxsize = 2; /* site */
|
||||
stage = stage->next = calloc(1, sizeof(struct building_stage));
|
||||
stage->construction = calloc(1, sizeof(struct construction));
|
||||
stage->construction->maxsize = 8; /* tradepost */
|
||||
stage = stage->next = calloc(1, sizeof(struct building_stage));
|
||||
stage->construction = calloc(1, sizeof(struct construction));
|
||||
stage->construction->maxsize = 40; /* fortification */
|
||||
stage = stage->next = calloc(1, sizeof(struct building_stage));
|
||||
stage->construction = calloc(1, sizeof(struct construction));
|
||||
stage->construction->maxsize = 200; /* fortification */
|
||||
r = test_create_plain(0, 0);
|
||||
CuAssertIntEquals(tc, 10, wage(r, rc_elf));
|
||||
CuAssertIntEquals(tc, 10, wage(r, rc_orc));
|
||||
CuAssertIntEquals(tc, 11, peasant_wage(r, false));
|
||||
CuAssertIntEquals(tc, 10, peasant_wage(r, true));
|
||||
|
||||
b = test_create_building(r, btype);
|
||||
b->size = 1;
|
||||
CuAssertIntEquals(tc, 0, buildingeffsize(b, false));
|
||||
CuAssertIntEquals(tc, 10, wage(r, rc_elf));
|
||||
CuAssertIntEquals(tc, 10, wage(r, rc_orc));
|
||||
CuAssertIntEquals(tc, 11, peasant_wage(r, false));
|
||||
CuAssertIntEquals(tc, 10, peasant_wage(r, true));
|
||||
b->size = 2;
|
||||
CuAssertIntEquals(tc, 1, buildingeffsize(b, false));
|
||||
b->size = 9;
|
||||
CuAssertIntEquals(tc, 1, buildingeffsize(b, false));
|
||||
CuAssertIntEquals(tc, 10, wage(r, rc_elf));
|
||||
CuAssertIntEquals(tc, 10, wage(r, rc_orc));
|
||||
CuAssertIntEquals(tc, 11, peasant_wage(r, false));
|
||||
CuAssertIntEquals(tc, 10, peasant_wage(r, true));
|
||||
b->size = 10;
|
||||
CuAssertIntEquals(tc, 2, buildingeffsize(b, false));
|
||||
b->size = 49;
|
||||
CuAssertIntEquals(tc, 2, buildingeffsize(b, false));
|
||||
CuAssertIntEquals(tc, 11, wage(r, rc_elf));
|
||||
CuAssertIntEquals(tc, 11, wage(r, rc_orc));
|
||||
CuAssertIntEquals(tc, 12, peasant_wage(r, false));
|
||||
CuAssertIntEquals(tc, 10, peasant_wage(r, true));
|
||||
b->size = 50;
|
||||
CuAssertIntEquals(tc, 3, buildingeffsize(b, false));
|
||||
b->size = 249;
|
||||
CuAssertIntEquals(tc, 3, buildingeffsize(b, false));
|
||||
CuAssertIntEquals(tc, 12, wage(r, rc_elf));
|
||||
CuAssertIntEquals(tc, 11, wage(r, rc_orc));
|
||||
CuAssertIntEquals(tc, 13, peasant_wage(r, false));
|
||||
CuAssertIntEquals(tc, 10, peasant_wage(r, true));
|
||||
b->size = 250;
|
||||
CuAssertIntEquals(tc, 4, buildingeffsize(b, false));
|
||||
CuAssertIntEquals(tc, 13, wage(r, rc_elf));
|
||||
CuAssertIntEquals(tc, 12, wage(r, rc_orc));
|
||||
CuAssertIntEquals(tc, 14, peasant_wage(r, false));
|
||||
CuAssertIntEquals(tc, 10, peasant_wage(r, true));
|
||||
config_set_int("rules.wage.function", 1);
|
||||
CuAssertIntEquals(tc, 13, wage(r, rc_elf));
|
||||
config_set_int("rules.wage.function", 0);
|
||||
CuAssertIntEquals(tc, 0, wage(r, rc_elf));
|
||||
config_set_int("rules.wage.function", 2);
|
||||
CuAssertIntEquals(tc, rc_elf->maintenance, wage(r, rc_elf));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_cmp_wage(CuTest *tc) {
|
||||
region *r;
|
||||
building *b1, *b2;
|
||||
|
@ -468,9 +542,9 @@ static void test_cmp_taxes(CuTest *tc) {
|
|||
b2 = test_create_building(r, btype);
|
||||
b1->size = 5;
|
||||
b2->size = 10;
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u_set_building(u1, b1);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
u_set_building(u2, b2);
|
||||
CuAssertPtrEquals(tc, b2, largestbuilding(r, cmp_taxes, false));
|
||||
CuAssertTrue(tc, cmp_taxes(b1, b2) < 0);
|
||||
|
@ -500,9 +574,9 @@ static void test_cmp_current_owner(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 1, buildingeffsize(b1, false));
|
||||
b2->size = 1;
|
||||
CuAssertIntEquals(tc, 1, buildingeffsize(b2, false));
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u_set_building(u1, b1);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
u_set_building(u2, b2);
|
||||
region_set_owner(r, u1->faction, turn);
|
||||
CuAssertPtrEquals(tc, b1, largestbuilding(r, cmp_current_owner, false));
|
||||
|
@ -619,6 +693,7 @@ CuSuite *get_building_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_cmp_castle_size);
|
||||
SUITE_ADD_TEST(suite, test_cmp_taxes);
|
||||
SUITE_ADD_TEST(suite, test_cmp_wage);
|
||||
SUITE_ADD_TEST(suite, test_wage);
|
||||
SUITE_ADD_TEST(suite, test_cmp_current_owner);
|
||||
SUITE_ADD_TEST(suite, test_register_building);
|
||||
SUITE_ADD_TEST(suite, test_btype_defaults);
|
||||
|
|
|
@ -31,7 +31,7 @@ static void test_command(CuTest * tc) {
|
|||
stree_add(st, "six", parser_six);
|
||||
CuAssertPtrNotNull(tc, st->root);
|
||||
CuAssertPtrEquals(tc, st->root, stree_find(st, loc));
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->thisorder = create_order(K_ALLIANCE, loc, "two");
|
||||
do_command(st->root, u, u->thisorder);
|
||||
CuAssertIntEquals(tc, u->number, 2);
|
||||
|
|
|
@ -42,7 +42,7 @@ extern "C" {
|
|||
bool rule_stealth_anon(void); /* units can anonymize their faction, TARNE PARTEI [NICHT] */
|
||||
int rule_alliance_limit(void);
|
||||
int rule_faction_limit(void);
|
||||
#define HARVEST_WORK 0x00
|
||||
#define HARVEST_WORK 0x02
|
||||
#define HARVEST_TAXES 0x01
|
||||
int rule_blessed_harvest(void);
|
||||
#define GIVE_SELF 1
|
||||
|
|
|
@ -29,7 +29,7 @@ static void test_read_unitid(CuTest *tc) {
|
|||
lang = test_create_locale();
|
||||
/* note that the english order is FIGHT, not COMBAT, so this is a poor example */
|
||||
t_plain = test_create_terrain("plain", LAND_REGION);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, t_plain));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, t_plain));
|
||||
usetalias(u, atoi36("42"));
|
||||
|
||||
ord = create_order(K_GIVE, lang, "TEMP 42");
|
||||
|
@ -72,7 +72,7 @@ static void test_getunit(CuTest *tc) {
|
|||
lang = test_create_locale();
|
||||
/* note that the english order is FIGHT, not COMBAT, so this is a poor example */
|
||||
t_plain = test_create_terrain("plain", LAND_REGION);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, t_plain));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, t_plain));
|
||||
/* This unit is also TEMP 42: */
|
||||
usetalias(u, atoi36("42"));
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ typedef struct {
|
|||
static void setup_curse(curse_fixture *fix, const char *name) {
|
||||
test_setup();
|
||||
fix->r = test_create_region(0, 0, NULL);
|
||||
fix->u = test_create_unit(test_create_faction(NULL), fix->r);
|
||||
fix->u = test_create_unit(test_create_faction(), fix->r);
|
||||
fix->c = create_curse(fix->u, &fix->r->attribs, ct_find(name), 1.0, 1, 1.0, 0);
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ static void test_curse_flags(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
c1 = create_curse(u, &u->attribs, &ct_dummy, 1, 1, 1, 0);
|
||||
CuAssertPtrEquals(tc, u, c1->magician);
|
||||
CuAssertIntEquals(tc, 1, (int)c1->effect);
|
||||
|
|
|
@ -52,7 +52,7 @@ static void test_update_faction(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
db_driver_open(DB_GAME, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
CuAssertIntEquals(tc, 0, f->uid);
|
||||
id = 0;
|
||||
err = db_driver_faction_save(&id, f->no,
|
||||
|
|
|
@ -101,7 +101,7 @@ int db_driver_faction_save(dbrow_id * p_id, int no, const char *email, const cha
|
|||
dbrow_id id = *p_id;
|
||||
int err;
|
||||
char dbno[4];
|
||||
size_t len;
|
||||
int len;
|
||||
const char *str;
|
||||
sqlite3_stmt *stmt = (id > 0) ? g_stmt_update_faction : g_stmt_insert_faction;
|
||||
|
||||
|
@ -110,8 +110,8 @@ int db_driver_faction_save(dbrow_id * p_id, int no, const char *email, const cha
|
|||
err = sqlite3_reset(stmt);
|
||||
if (err != SQLITE_OK) return err;
|
||||
str = itoa36(no);
|
||||
len = strlen(str);
|
||||
assert(len <= 4);
|
||||
len = (int)strlen(str);
|
||||
assert(len > 0 && len <= 4);
|
||||
memcpy(dbno, str, len);
|
||||
err = sqlite3_bind_text(stmt, 1, dbno, len, SQLITE_STATIC);
|
||||
if (err != SQLITE_OK) return err;
|
||||
|
|
|
@ -29,7 +29,7 @@ static void test_equipment(CuTest * tc)
|
|||
test_setup();
|
||||
callbacks.equip_unit = equip_callback;
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
CuAssertIntEquals(tc, true, equip_unit_mask(u, "hodor", EQUIP_ALL));
|
||||
CuAssertIntEquals(tc, EQUIP_ALL, eq_mask);
|
||||
CuAssertPtrEquals(tc, u, eq_unit);
|
||||
|
|
|
@ -33,9 +33,9 @@ static void test_destroyfaction_allies(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f1 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
test_create_unit(f1, r);
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
ally_set(&f1->allies, f2, HELP_FIGHT);
|
||||
CuAssertIntEquals(tc, HELP_FIGHT, alliedfaction(f1, f2, HELP_ALL));
|
||||
CuAssertPtrEquals(tc, f2, f1->next);
|
||||
|
@ -50,7 +50,7 @@ static void test_remove_empty_factions_alliance(CuTest *tc) {
|
|||
struct alliance *al;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
al = makealliance(0, "Hodor");
|
||||
setalliance(f, al);
|
||||
CuAssertPtrEquals(tc, f, alliance_get_leader(al));
|
||||
|
@ -68,7 +68,7 @@ static void test_remove_empty_factions(CuTest *tc) {
|
|||
test_setup();
|
||||
fm = get_or_create_monsters();
|
||||
assert(fm);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
fno = f->no;
|
||||
remove_empty_factions();
|
||||
CuAssertIntEquals(tc, false, f->_alive);
|
||||
|
@ -87,7 +87,7 @@ static void test_remove_dead_factions(CuTest *tc) {
|
|||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
fm = get_or_create_monsters();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
assert(fm && r && f);
|
||||
test_create_unit(f, r);
|
||||
test_create_unit(fm, r);
|
||||
|
@ -136,7 +136,7 @@ static void test_check_passwd(CuTest *tc) {
|
|||
faction *f;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
faction_setpassword(f, password_hash("password", PASSWORD_DEFAULT));
|
||||
CuAssertTrue(tc, checkpasswd(f, "password"));
|
||||
CuAssertTrue(tc, !checkpasswd(f, "assword"));
|
||||
|
@ -151,7 +151,7 @@ static void test_change_locale(CuTest *tc) {
|
|||
struct locale *lang;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
lang = get_or_create_locale("en");
|
||||
u = test_create_unit(f, test_create_plain(0, 0));
|
||||
u->thisorder = create_order(K_ENTERTAIN, f->locale, NULL);
|
||||
|
@ -208,7 +208,7 @@ static void test_set_origin(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
pl = create_new_plane(0, "", 0, 19, 0, 19, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
CuAssertPtrEquals(tc, NULL, f->origin);
|
||||
faction_setorigin(f, 0, 1, 1);
|
||||
CuAssertIntEquals(tc, 0, f->origin->id);
|
||||
|
@ -233,7 +233,7 @@ static void test_set_origin_bug(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
pl = create_new_plane(0, "", 0, 19, 0, 19, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
faction_setorigin(f, 0, -10, 3);
|
||||
faction_setorigin(f, 0, -13, -4);
|
||||
adjust_coordinates(f, &x, &y, pl);
|
||||
|
@ -250,7 +250,7 @@ static void test_max_migrants(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
rc = test_create_race("human");
|
||||
f = test_create_faction(rc);
|
||||
f = test_create_faction_ex(rc, NULL);
|
||||
u = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
CuAssertIntEquals(tc, 0, count_maxmigrants(f));
|
||||
rc->flags |= RCF_MIGRANTS;
|
||||
|
@ -264,7 +264,7 @@ static void test_skill_limit(CuTest *tc) {
|
|||
faction *f;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
CuAssertIntEquals(tc, INT_MAX, faction_skill_limit(f, SK_ENTERTAINMENT));
|
||||
CuAssertIntEquals(tc, 3, faction_skill_limit(f, SK_ALCHEMY));
|
||||
config_set_int("rules.maxskills.alchemy", 4);
|
||||
|
@ -287,7 +287,7 @@ static void test_valid_race(CuTest *tc) {
|
|||
test_setup();
|
||||
rc1 = test_create_race("human");
|
||||
rc2 = test_create_race("elf");
|
||||
f = test_create_faction(rc1);
|
||||
f = test_create_faction_ex(rc1, NULL);
|
||||
CuAssertTrue(tc, valid_race(f, rc1));
|
||||
CuAssertTrue(tc, !valid_race(f, rc2));
|
||||
rc_set_param(rc1, "other_race", "elf");
|
||||
|
@ -300,7 +300,7 @@ static void test_dbstrings(CuTest *tc) {
|
|||
const char *lipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
|
||||
faction *f;
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
faction_setbanner(f, lipsum);
|
||||
faction_setpassword(f, lipsum + 12);
|
||||
CuAssertStrEquals(tc, lipsum, faction_getbanner(f));
|
||||
|
@ -319,7 +319,7 @@ static void test_set_email(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, -1, check_email("eressea@"));
|
||||
CuAssertIntEquals(tc, -1, check_email(""));
|
||||
CuAssertIntEquals(tc, -1, check_email(NULL));
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
|
||||
sprintf(email, "enno");
|
||||
faction_setemail(f, email);
|
||||
|
@ -345,7 +345,7 @@ static void test_save_special_items(CuTest *tc) {
|
|||
itype = test_create_itemtype("banana");
|
||||
itype->flags |= ITF_NOTLOST;
|
||||
rc = test_create_race("template");
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
i_change(&u->items, itype, 1);
|
||||
|
||||
/* when there is no monster in the region, a ghost of the dead unit is created: */
|
||||
|
@ -387,7 +387,7 @@ static void test_addplayer(CuTest *tc) {
|
|||
callbacks.equip_unit = NULL;
|
||||
itype = test_create_silver();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = addplayer(r, f);
|
||||
CuAssertPtrNotNull(tc, u);
|
||||
CuAssertPtrEquals(tc, r, u->region);
|
||||
|
|
|
@ -31,11 +31,11 @@ static void test_group_readwrite_dead_faction(CuTest *tc) {
|
|||
int fno;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
fno = f->no;
|
||||
CuAssertPtrEquals(tc, f, factions);
|
||||
CuAssertPtrEquals(tc, NULL, f->next);
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
CuAssertPtrEquals(tc, f2, factions->next);
|
||||
u = test_create_unit(f2, test_create_region(0, 0, NULL));
|
||||
CuAssertPtrNotNull(tc, u);
|
||||
|
@ -79,7 +79,7 @@ static void test_group_readwrite(CuTest * tc)
|
|||
test_setup();
|
||||
mstream_init(&data.strm);
|
||||
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
create_group(f, "NW", 42);
|
||||
g = create_group(f, "Egoisten", 43);
|
||||
CuAssertPtrEquals(tc, f, g->f);
|
||||
|
@ -122,7 +122,7 @@ static void test_group(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
assert(r && f);
|
||||
u = test_create_unit(f, r);
|
||||
assert(u);
|
||||
|
|
|
@ -74,7 +74,7 @@ void test_change_item(CuTest * tc)
|
|||
test_create_itemtype("iron");
|
||||
init_resources();
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
test_uchange(tc, u, get_resourcetype(R_IRON));
|
||||
test_log_stderr(1);
|
||||
test_teardown();
|
||||
|
|
|
@ -29,7 +29,7 @@ void test_missing_feedback(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->thisorder = create_order(K_ENTERTAIN, u->faction->locale, NULL);
|
||||
message_handle_missing(MESSAGE_MISSING_REPLACE);
|
||||
msg = msg_error(u, NULL, 77);
|
||||
|
@ -103,7 +103,7 @@ static void test_noerror(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
lang = test_create_locale();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->thisorder = parse_order("!@move", lang);
|
||||
CuAssertIntEquals(tc, K_MOVE | CMD_QUIET | CMD_PERSIST, u->thisorder->command);
|
||||
CuAssertTrue(tc, !is_persistent(u->thisorder));
|
||||
|
|
|
@ -390,7 +390,7 @@ static void test_study_order(CuTest *tc) {
|
|||
locale_setstring(lang, "keyword::study", "LERNE");
|
||||
init_keywords(lang);
|
||||
init_skills(lang);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u->thisorder = create_order(K_STUDY, lang, "ALCH");
|
||||
CuAssertIntEquals(tc, K_STUDY, init_order(u->thisorder, lang));
|
||||
CuAssertStrEquals(tc, skillname(SK_ALCHEMY, lang), gettoken(token, sizeof(token)));
|
||||
|
@ -419,7 +419,7 @@ static void test_study_order_unknown(CuTest *tc) {
|
|||
locale_setstring(lang, "keyword::study", "LERNE");
|
||||
init_keywords(lang);
|
||||
init_skills(lang);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u->thisorder = create_order(K_STUDY, lang, "Schiffsbau");
|
||||
CuAssertIntEquals(tc, K_STUDY, init_order(u->thisorder, lang));
|
||||
CuAssertStrEquals(tc, "Schiffsbau", gettoken(token, sizeof(token)));
|
||||
|
@ -449,7 +449,7 @@ static void test_study_order_quoted(CuTest *tc) {
|
|||
locale_setstring(lang, "keyword::study", "LERNE");
|
||||
init_keywords(lang);
|
||||
init_skills(lang);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u->thisorder = create_order(K_STUDY, lang, "Waffenloser~Kampf");
|
||||
CuAssertIntEquals(tc, K_STUDY, init_order(u->thisorder, lang));
|
||||
CuAssertStrEquals(tc, skillname(SK_WEAPONLESS, lang), gettoken(token, sizeof(token)));
|
||||
|
@ -478,7 +478,7 @@ static void test_study_order_unknown_tilde(CuTest *tc) {
|
|||
locale_setstring(lang, "keyword::study", "LERNE");
|
||||
init_keywords(lang);
|
||||
init_skills(lang);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u->thisorder = create_order(K_STUDY, lang, "Waffenloser~Mampf");
|
||||
CuAssertIntEquals(tc, K_STUDY, init_order(u->thisorder, lang));
|
||||
CuAssertStrEquals(tc, "Waffenloser Mampf", gettoken(token, sizeof(token)));
|
||||
|
@ -507,7 +507,7 @@ static void test_study_order_unknown_quoted(CuTest *tc) {
|
|||
locale_setstring(lang, "keyword::study", "LERNE");
|
||||
init_keywords(lang);
|
||||
init_skills(lang);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u->thisorder = create_order(K_STUDY, lang, "'Waffenloser Dampf'");
|
||||
CuAssertIntEquals(tc, K_STUDY, init_order(u->thisorder, lang));
|
||||
CuAssertStrEquals(tc, "Waffenloser Dampf", gettoken(token, sizeof(token)));
|
||||
|
@ -552,7 +552,7 @@ static void test_create_order_long(CuTest *tc) {
|
|||
stream_order(&out, ord, lang, true);
|
||||
out.api->rewind(out.handle);
|
||||
out.api->readln(out.handle, buffer, sizeof(buffer));
|
||||
CuAssertIntEquals(tc, 1026, strlen(buffer));
|
||||
CuAssertIntEquals(tc, 1026, (int)strlen(buffer));
|
||||
mstream_done(&out);
|
||||
free_order(ord);
|
||||
test_teardown();
|
||||
|
|
|
@ -46,7 +46,7 @@ static void test_origin(CuTest *tc) {
|
|||
int x, y;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
x = 0;
|
||||
y = 0;
|
||||
adjust_coordinates(f, &x, &y, 0);
|
||||
|
|
|
@ -24,7 +24,7 @@ void test_reservation(CuTest *tc) {
|
|||
test_create_world();
|
||||
rtype = rt_get_or_create("money");
|
||||
it_get_or_create(rtype);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
assert(r && f && rtype && rtype->itype);
|
||||
u = test_create_unit(f, r);
|
||||
|
@ -54,7 +54,7 @@ void test_pool_get_item(CuTest *tc) {
|
|||
rtype = rt_get_or_create("money");
|
||||
rtype->flags |= RTF_POOLED;
|
||||
it_get_or_create(rtype);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
u1 = test_create_unit(f, r);
|
||||
u_setrace(u1, rc = test_create_race("undead"));
|
||||
|
@ -77,12 +77,12 @@ void test_pool(CuTest *tc) {
|
|||
rtype = rt_get_or_create("money");
|
||||
rtype->flags |= RTF_POOLED;
|
||||
it_get_or_create(rtype);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
assert(r && f && rtype && rtype->itype);
|
||||
u1 = test_create_unit(f, r);
|
||||
u2 = test_create_unit(f, r);
|
||||
u3 = test_create_unit(test_create_faction(NULL), r);
|
||||
u3 = test_create_unit(test_create_faction(), r);
|
||||
assert(u1 && u2);
|
||||
i_change(&u1->items, rtype->itype, 100);
|
||||
set_resvalue(u1, rtype->itype, 50);
|
||||
|
@ -122,7 +122,7 @@ void test_pool_bug_2042(CuTest *tc) {
|
|||
test_create_world();
|
||||
rtype = rt_get_or_create("money");
|
||||
it_get_or_create(rtype);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
assert(r && f && rtype && rtype->itype);
|
||||
u1 = test_create_unit(f, r);
|
||||
|
@ -144,12 +144,12 @@ void test_pool_use(CuTest *tc) {
|
|||
test_setup();
|
||||
test_create_world();
|
||||
itype = it_get_or_create(rt_get_or_create("money"));
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
assert(r && f && itype);
|
||||
u1 = test_create_unit(f, r);
|
||||
u2 = test_create_unit(f, r);
|
||||
u3 = test_create_unit(test_create_faction(NULL), r);
|
||||
u3 = test_create_unit(test_create_faction(), r);
|
||||
assert(u1 && u2);
|
||||
i_change(&u1->items, itype, 100);
|
||||
set_resvalue(u1, itype, 50);
|
||||
|
@ -193,7 +193,7 @@ void test_change_resource(CuTest * tc)
|
|||
enable_skill(SK_MAGIC, true);
|
||||
|
||||
r = findregion(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
CuAssertPtrNotNull(tc, u);
|
||||
set_level(u, SK_MAGIC, 5);
|
||||
|
|
|
@ -173,8 +173,8 @@ static void test_racename(CuTest *tc) {
|
|||
unit *u;
|
||||
struct locale * lang;
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u->faction->locale = lang = test_create_locale();
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->faction->locale = lang = get_or_create_locale(__FUNCTION__);
|
||||
locale_setstring(lang, "race::human_p", "Menschen");
|
||||
locale_setstring(lang, "race::human", "Mensch");
|
||||
locale_setstring(lang, "prefix::dark", "Dunkel");
|
||||
|
|
|
@ -602,7 +602,7 @@ int rpeasants(const region * r)
|
|||
return value;
|
||||
}
|
||||
|
||||
void rsetpeasants(region * r, int value)
|
||||
int rsetpeasants(region * r, int value)
|
||||
{
|
||||
assert(r->land || value==0);
|
||||
assert(value >= 0);
|
||||
|
@ -612,7 +612,9 @@ void rsetpeasants(region * r, int value)
|
|||
value = USHRT_MAX;
|
||||
}
|
||||
r->land->peasants = (unsigned short)value;
|
||||
return r->land->peasants;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rmoney(const region * r)
|
||||
|
@ -746,17 +748,16 @@ int rsettrees(const region * r, int ageclass, int value)
|
|||
{
|
||||
if (!r->land) {
|
||||
assert(value == 0);
|
||||
return 0;
|
||||
}
|
||||
assert(value >= 0);
|
||||
if (value < MAXTREES) {
|
||||
r->land->trees[ageclass] = value;
|
||||
}
|
||||
else {
|
||||
assert(value >= 0);
|
||||
if (value <= MAXTREES) {
|
||||
return r->land->trees[ageclass] = value;
|
||||
}
|
||||
else {
|
||||
r->land->trees[ageclass] = MAXTREES;
|
||||
}
|
||||
r->land->trees[ageclass] = MAXTREES;
|
||||
}
|
||||
return 0;
|
||||
return r->land->trees[ageclass];
|
||||
}
|
||||
|
||||
region *region_create(int uid)
|
||||
|
@ -1095,11 +1096,10 @@ void init_region(region *r)
|
|||
|
||||
if (!fval(r, RF_CHAOTIC)) {
|
||||
int peasants;
|
||||
int p_wage = 1 + peasant_wage(r, false) + rng_int() % 5;
|
||||
peasants = (region_maxworkers(r) * (20 + dice(6, 10))) / 100;
|
||||
if (peasants < 100) peasants = 100;
|
||||
rsetpeasants(r, peasants);
|
||||
rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL,
|
||||
INT_MAX) + 1) + rng_int() % 5));
|
||||
rsetmoney(r, rsetpeasants(r, peasants) * p_wage);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ extern "C" {
|
|||
int rsettrees(const struct region *r, int ageclass, int value);
|
||||
|
||||
int rpeasants(const struct region *r);
|
||||
void rsetpeasants(struct region *r, int value);
|
||||
int rsetpeasants(struct region *r, int value);
|
||||
int rmoney(const struct region *r);
|
||||
void rsetmoney(struct region *r, int value);
|
||||
int rhorses(const struct region *r);
|
||||
|
|
|
@ -47,9 +47,9 @@ static void test_region_get_owner(CuTest *tc) {
|
|||
b2 = test_create_building(r, NULL);
|
||||
b1->size = 5;
|
||||
b2->size = 10;
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u_set_building(u1, b1);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
u_set_building(u2, b2);
|
||||
CuAssertPtrEquals(tc, u2->faction, region_get_owner(r));
|
||||
test_teardown();
|
||||
|
|
|
@ -118,30 +118,41 @@ static void terraform_default(struct rawmaterial *res, const region * r)
|
|||
}
|
||||
|
||||
static int visible_default(const rawmaterial * res, int skilllevel)
|
||||
/* resources are visible, if skill equals minimum skill to mine them
|
||||
/* resources are visible if skill equals minimum skill to mine them
|
||||
* plus current level of difficulty */
|
||||
{
|
||||
const struct item_type *itype = res->rtype->itype;
|
||||
int level = res->level + itype->construction->minskill - 1;
|
||||
if (res->level <= 1
|
||||
&& res->level + itype->construction->minskill <= skilllevel + 1) {
|
||||
&& level <= skilllevel) {
|
||||
assert(res->amount > 0);
|
||||
return res->amount;
|
||||
}
|
||||
else if (res->level + itype->construction->minskill <= skilllevel + 2) {
|
||||
else if (level < skilllevel) {
|
||||
assert(res->amount > 0);
|
||||
return res->amount;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int visible_half_skill(const rawmaterial * res, int skilllevel)
|
||||
/* resources are visible if skill equals half as much as normal */
|
||||
{
|
||||
const struct item_type *itype = res->rtype->itype;
|
||||
int level = res->level + itype->construction->minskill - 1;
|
||||
if (2 * skilllevel >= level) {
|
||||
return res->amount;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void use_default(rawmaterial * res, const region * r, int amount)
|
||||
{
|
||||
assert(res->amount > 0 && amount >= 0 && amount <= res->amount);
|
||||
res->amount -= amount;
|
||||
while (res->amount == 0) {
|
||||
double modifier =
|
||||
1.0 + ((rng_int() % (SHIFT * 2 + 1)) - SHIFT) * ((rng_int() % (SHIFT * 2 +
|
||||
1)) - SHIFT) / 10000.0;
|
||||
long rn = ((rng_int() % (SHIFT * 2 + 1)) - SHIFT) * ((rng_int() % (SHIFT * 2 + 1)) - SHIFT);
|
||||
double modifier = 1.0 + rn / 10000.0;
|
||||
int i;
|
||||
|
||||
for (i = 0; r->terrain->production[i].type; ++i) {
|
||||
|
@ -171,13 +182,19 @@ struct rawmaterial_type *rmt_get(const struct resource_type *rtype)
|
|||
struct rawmaterial_type *rmt_create(struct resource_type *rtype)
|
||||
{
|
||||
if (!rtype->raw) {
|
||||
int rule = config_get_int("resource.visibility.rule", 1);
|
||||
rawmaterial_type *rmtype = rtype->raw = malloc(sizeof(rawmaterial_type));
|
||||
if (!rmtype) abort();
|
||||
rmtype->rtype = rtype;
|
||||
rmtype->terraform = terraform_default;
|
||||
rmtype->update = NULL;
|
||||
rmtype->use = use_default;
|
||||
rmtype->visible = visible_default;
|
||||
if (rule == 0) {
|
||||
rmtype->visible = visible_default;
|
||||
}
|
||||
else {
|
||||
rmtype->visible = visible_half_skill;
|
||||
}
|
||||
}
|
||||
return rtype->raw;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ static void test_readwrite_unit(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
fno = f->no;
|
||||
u = test_create_unit(f, r);
|
||||
unit_setname(u, " Hodor ");
|
||||
|
@ -77,7 +77,7 @@ static void test_readwrite_unit(CuTest * tc)
|
|||
|
||||
data.strm.api->rewind(data.strm.handle);
|
||||
free_gamedata();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
renumber_faction(f, fno);
|
||||
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||
|
@ -101,7 +101,7 @@ static void test_readwrite_faction(CuTest * tc)
|
|||
faction *f;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
free(f->name);
|
||||
f->name = str_strdup(" Hodor ");
|
||||
CuAssertStrEquals(tc, " Hodor ", f->name);
|
||||
|
@ -258,11 +258,11 @@ static void test_readwrite_dead_faction_group(CuTest *tc) {
|
|||
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
fno = f->no;
|
||||
CuAssertPtrEquals(tc, f, factions);
|
||||
CuAssertPtrEquals(tc, NULL, f->next);
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
CuAssertPtrEquals(tc, f2, factions->next);
|
||||
u = test_create_unit(f2, test_create_region(0, 0, NULL));
|
||||
CuAssertPtrNotNull(tc, u);
|
||||
|
@ -303,7 +303,7 @@ static void test_readwrite_dead_faction_regionowner(CuTest *tc) {
|
|||
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||
|
||||
config_set("rules.region_owners", "1");
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
test_create_unit(f, r = test_create_region(0, 0, NULL));
|
||||
region_set_owner(r, f, 0);
|
||||
destroyfaction(&factions);
|
||||
|
@ -331,8 +331,8 @@ static void test_readwrite_dead_faction_changefaction(CuTest *tc) {
|
|||
unit * u;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
u = test_create_unit(f2, r = test_create_region(0, 0, NULL));
|
||||
tr = trigger_changefaction(u, f);
|
||||
add_trigger(&u->attribs, "timer", trigger_timeout(10, tr));
|
||||
|
@ -368,8 +368,8 @@ static void test_readwrite_dead_faction_createunit(CuTest *tc) {
|
|||
unit * u;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
u = test_create_unit(f2, r = test_create_region(0, 0, NULL));
|
||||
tr = trigger_createunit(r, f, f->race, 1);
|
||||
add_trigger(&u->attribs, "timer", trigger_timeout(10, tr));
|
||||
|
@ -402,7 +402,7 @@ static void test_read_password(CuTest *tc) {
|
|||
faction *f;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
faction_setpassword(f, password_hash("secret", PASSWORD_DEFAULT));
|
||||
mstream_init(&data.strm);
|
||||
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||
|
@ -426,7 +426,7 @@ static void test_read_password_external(CuTest *tc) {
|
|||
if (remove(pwfile) != 0) {
|
||||
errno = 0;
|
||||
}
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
faction_setpassword(f, password_hash("secret", PASSWORD_DEFAULT));
|
||||
CuAssertPtrNotNull(tc, faction_getpassword(f));
|
||||
mstream_init(&data.strm);
|
||||
|
|
|
@ -39,7 +39,7 @@ static void test_ship_crewed(CuTest * tc)
|
|||
struct ship_type *stype;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_ocean(0, 0);
|
||||
stype = test_create_shiptype("longboat");
|
||||
stype->cptskill = 2;
|
||||
|
@ -89,14 +89,12 @@ static void test_ship_set_owner(CuTest * tc)
|
|||
struct unit *u1, *u2;
|
||||
struct faction *f;
|
||||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
stype = st_find("boat");
|
||||
f = test_create_faction(human);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
|
||||
sh = test_create_ship(r, stype);
|
||||
|
@ -119,18 +117,14 @@ static void test_shipowner_goes_to_next_when_empty(CuTest * tc)
|
|||
struct unit *u, *u2;
|
||||
struct faction *f;
|
||||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
|
||||
stype = st_find("boat");
|
||||
CuAssertPtrNotNull(tc, stype);
|
||||
|
||||
f = test_create_faction(human);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
|
||||
sh = test_create_ship(r, stype);
|
||||
|
@ -154,18 +148,14 @@ static void test_shipowner_goes_to_other_when_empty(CuTest * tc)
|
|||
struct unit *u, *u2;
|
||||
struct faction *f;
|
||||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
|
||||
stype = st_find("boat");
|
||||
CuAssertPtrNotNull(tc, stype);
|
||||
|
||||
f = test_create_faction(human);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
|
||||
sh = test_create_ship(r, stype);
|
||||
|
@ -189,19 +179,15 @@ static void test_shipowner_goes_to_same_faction_when_empty(CuTest * tc)
|
|||
struct unit *u, *u2, *u3;
|
||||
struct faction *f1, *f2;
|
||||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
|
||||
stype = st_find("boat");
|
||||
CuAssertPtrNotNull(tc, stype);
|
||||
|
||||
f1 = test_create_faction(human);
|
||||
f2 = test_create_faction(human);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
|
||||
sh = test_create_ship(r, stype);
|
||||
|
@ -229,18 +215,14 @@ static void test_shipowner_goes_to_next_after_leave(CuTest * tc)
|
|||
struct unit *u, *u2;
|
||||
struct faction *f;
|
||||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
|
||||
stype = st_find("boat");
|
||||
CuAssertPtrNotNull(tc, stype);
|
||||
|
||||
f = test_create_faction(human);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
|
||||
sh = test_create_ship(r, stype);
|
||||
|
@ -264,18 +246,14 @@ static void test_shipowner_goes_to_other_after_leave(CuTest * tc)
|
|||
struct unit *u, *u2;
|
||||
struct faction *f;
|
||||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
|
||||
stype = st_find("boat");
|
||||
CuAssertPtrNotNull(tc, stype);
|
||||
|
||||
f = test_create_faction(human);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
|
||||
sh = test_create_ship(r, stype);
|
||||
|
@ -299,19 +277,15 @@ static void test_shipowner_goes_to_same_faction_after_leave(CuTest * tc)
|
|||
struct unit *u, *u2, *u3;
|
||||
struct faction *f1, *f2;
|
||||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
|
||||
stype = st_find("boat");
|
||||
CuAssertPtrNotNull(tc, stype);
|
||||
|
||||
f1 = test_create_faction(human);
|
||||
f2 = test_create_faction(human);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
|
||||
sh = test_create_ship(r, stype);
|
||||
|
@ -341,18 +315,14 @@ static void test_shipowner_resets_when_empty(CuTest * tc)
|
|||
struct unit *u;
|
||||
struct faction *f;
|
||||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
|
||||
stype = st_find("boat");
|
||||
CuAssertPtrNotNull(tc, stype);
|
||||
|
||||
f = test_create_faction(human);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
|
||||
sh = test_create_ship(r, stype);
|
||||
|
@ -374,18 +344,14 @@ void test_shipowner_goes_to_empty_unit_after_leave(CuTest * tc)
|
|||
struct unit *u1, *u2, *u3;
|
||||
struct faction *f1;
|
||||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
|
||||
stype = st_find("boat");
|
||||
CuAssertPtrNotNull(tc, stype);
|
||||
|
||||
f1 = test_create_faction(human);
|
||||
f1 = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
|
||||
sh = test_create_ship(r, stype);
|
||||
|
@ -450,7 +416,7 @@ static ship *setup_ship(void) {
|
|||
}
|
||||
|
||||
static void setup_crew(ship *sh, struct faction *f, unit **cap, unit **crew) {
|
||||
if (!f) f = test_create_faction(NULL);
|
||||
if (!f) f = test_create_faction();
|
||||
assert(cap);
|
||||
assert(crew);
|
||||
*cap = test_create_unit(f, sh->region);
|
||||
|
@ -470,7 +436,7 @@ static void test_shipspeed_speedy(CuTest *tc) {
|
|||
stype->range = 5;
|
||||
stype->range_max = -1;
|
||||
stype->flags |= SFL_SPEEDY;
|
||||
cap = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
cap = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
crw = test_create_unit(cap->faction, cap->region);
|
||||
sh = test_create_ship(cap->region, stype);
|
||||
cap->ship = sh;
|
||||
|
@ -603,7 +569,7 @@ static void test_maximum_shipspeed(CuTest *tc) {
|
|||
sh = setup_ship();
|
||||
rc = test_create_race("aquarian");
|
||||
rc->flags |= RCF_SHIPSPEED;
|
||||
f = test_create_faction(rc);
|
||||
f = test_create_faction_ex(rc, NULL);
|
||||
setup_crew(sh, f, &cap, &crew);
|
||||
CuAssertIntEquals(tc, sh->type->range + 1, shipspeed(sh, cap));
|
||||
create_curse(0, &sh->attribs, &ct_stormwind, 1, 1, 1, 0);
|
||||
|
@ -661,7 +627,7 @@ static void test_shipspeed_max_range(CuTest *tc) {
|
|||
setup_crew(sh, NULL, &cap, &crew);
|
||||
config_set("movement.shipspeed.skillbonus", "5");
|
||||
r = sh->region;
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
assert(r && f);
|
||||
stype = st_get_or_create(sh->type->_name);
|
||||
|
||||
|
@ -692,7 +658,7 @@ static void test_crew_skill(CuTest *tc) {
|
|||
r = test_create_ocean(0, 0);
|
||||
sh = test_create_ship(r, stype);
|
||||
CuAssertIntEquals(tc, 0, crew_skill(sh));
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
set_level(u, SK_SAILING, 1);
|
||||
CuAssertIntEquals(tc, 0, crew_skill(sh));
|
||||
u_set_ship(u, sh);
|
||||
|
|
|
@ -15,7 +15,7 @@ static void test_skills(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
config_set_int("study.random_progress", 0);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
CuAssertPtrEquals(tc, NULL, u->skills);
|
||||
CuAssertIntEquals(tc, 0, u->skill_size);
|
||||
CuAssertIntEquals(tc, 0, get_level(u, SK_CROSSBOW));
|
||||
|
|
|
@ -705,27 +705,33 @@ bool can_survive(const unit * u, const region * r)
|
|||
return false;
|
||||
}
|
||||
|
||||
void leave_region(unit* u)
|
||||
{
|
||||
assert(u->region);
|
||||
setguard(u, false);
|
||||
fset(u, UFL_MOVED);
|
||||
if (u->ship || u->building) {
|
||||
/* can_leave must be checked in travel_i */
|
||||
#ifndef NDEBUG
|
||||
bool result = leave(u, false);
|
||||
assert(result);
|
||||
#else
|
||||
leave(u, false);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void move_unit(unit * u, region * r, unit ** ulist)
|
||||
{
|
||||
assert(u && r);
|
||||
|
||||
assert(u->faction || !"this unit is dead");
|
||||
if (u->region == r)
|
||||
return;
|
||||
if (!ulist)
|
||||
if (!ulist) {
|
||||
ulist = (&r->units);
|
||||
}
|
||||
if (u->region) {
|
||||
setguard(u, false);
|
||||
fset(u, UFL_MOVED);
|
||||
if (u->ship || u->building) {
|
||||
/* can_leave must be checked in travel_i */
|
||||
#ifndef NDEBUG
|
||||
bool result = leave(u, false);
|
||||
assert(result);
|
||||
#else
|
||||
leave(u, false);
|
||||
#endif
|
||||
}
|
||||
leave_region(u);
|
||||
translist(&u->region->units, ulist, u);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -143,6 +143,7 @@ extern "C" {
|
|||
int get_modifier(const struct unit *u, skill_t sk, int level,
|
||||
const struct region *r, bool noitem);
|
||||
int remove_unit(struct unit **ulist, struct unit *u);
|
||||
void leave_region(struct unit* u);
|
||||
|
||||
/* looking up dead units' factions: */
|
||||
struct faction *dfindhash(int no);
|
||||
|
|
|
@ -36,7 +36,7 @@ static void test_remove_empty_units(CuTest *tc) {
|
|||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
|
||||
u = test_create_unit(test_create_faction(), findregion(0, 0));
|
||||
uid = u->no;
|
||||
remove_empty_units();
|
||||
CuAssertPtrNotNull(tc, findunit(uid));
|
||||
|
@ -53,7 +53,7 @@ static void test_remove_empty_units_in_region(CuTest *tc) {
|
|||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
|
||||
u = test_create_unit(test_create_faction(), findregion(0, 0));
|
||||
u = test_create_unit(u->faction, u->region);
|
||||
CuAssertPtrNotNull(tc, u->nextF);
|
||||
uid = u->no;
|
||||
|
@ -74,7 +74,7 @@ static void test_remove_units_without_faction(CuTest *tc) {
|
|||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
|
||||
u = test_create_unit(test_create_faction(), findregion(0, 0));
|
||||
uid = u->no;
|
||||
u_setfaction(u, 0);
|
||||
remove_empty_units_in_region(u->region);
|
||||
|
@ -90,7 +90,7 @@ static void test_remove_units_with_dead_faction(CuTest *tc) {
|
|||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
|
||||
u = test_create_unit(test_create_faction(), findregion(0, 0));
|
||||
uid = u->no;
|
||||
u->faction->_alive = false;
|
||||
remove_empty_units_in_region(u->region);
|
||||
|
@ -106,7 +106,7 @@ static void test_scale_number(CuTest *tc) {
|
|||
test_setup();
|
||||
test_create_world();
|
||||
ptype = it_get_or_create(rt_get_or_create("hodor"));
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
|
||||
u = test_create_unit(test_create_faction(), findregion(0, 0));
|
||||
change_effect(u, ptype, 1);
|
||||
u->hp = 35;
|
||||
CuAssertIntEquals(tc, 1, u->number);
|
||||
|
@ -135,7 +135,7 @@ static void test_unit_name(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
|
||||
u = test_create_unit(test_create_faction(), findregion(0, 0));
|
||||
renumber_unit(u, 666);
|
||||
unit_setname(u, "Hodor");
|
||||
CuAssertStrEquals(tc, "Hodor (ii)", unitname(u));
|
||||
|
@ -146,7 +146,7 @@ static void test_unit_name_from_race(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
renumber_unit(u, 666);
|
||||
unit_setname(u, NULL);
|
||||
|
||||
|
@ -166,7 +166,7 @@ static void test_update_monster_name(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
rc = test_create_race("human");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
|
||||
unit_setname(u, "Hodor");
|
||||
CuAssertTrue(tc, !unit_name_equals_race(u));
|
||||
|
@ -191,7 +191,7 @@ static void test_names(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
|
||||
u = test_create_unit(test_create_faction(), findregion(0, 0));
|
||||
|
||||
unit_setname(u, "Hodor");
|
||||
unit_setid(u, 5);
|
||||
|
@ -207,10 +207,10 @@ static void test_default_name(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
|
||||
lang = test_create_locale();
|
||||
lang = get_or_create_locale(__FUNCTION__);
|
||||
locale_setstring(lang, "unitdefault", "Zweiheit");
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction_ex(NULL, lang), test_create_plain(0, 0));
|
||||
|
||||
default_name(u, buf, sizeof(buf));
|
||||
|
||||
|
@ -232,7 +232,7 @@ static void test_skillmod(CuTest *tc) {
|
|||
attrib *a;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
set_level(u, SK_ARMORER, 5);
|
||||
CuAssertIntEquals(tc, 5, effskill(u, SK_ARMORER, NULL));
|
||||
|
||||
|
@ -259,7 +259,7 @@ static void test_skill_hunger(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
set_level(u, SK_ARMORER, 6);
|
||||
set_level(u, SK_SAILING, 6);
|
||||
fset(u, UFL_HUNGER);
|
||||
|
@ -277,7 +277,7 @@ static void test_skill_familiar(CuTest *tc) {
|
|||
test_setup();
|
||||
|
||||
/* setup two units */
|
||||
mag = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
mag = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
fam = test_create_unit(mag->faction, test_create_region(0, 0, NULL));
|
||||
set_level(fam, SK_PERCEPTION, 6);
|
||||
CuAssertIntEquals(tc, 6, effskill(fam, SK_PERCEPTION, NULL));
|
||||
|
@ -303,7 +303,7 @@ static void test_inside_building(CuTest *tc) {
|
|||
building *b;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
b = test_create_building(u->region, NULL);
|
||||
|
||||
b->size = 1;
|
||||
|
@ -327,7 +327,7 @@ static void test_skills(CuTest *tc) {
|
|||
unit *u;
|
||||
skill *sv;
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
sv = add_skill(u, SK_ALCHEMY);
|
||||
CuAssertPtrNotNull(tc, sv);
|
||||
CuAssertPtrEquals(tc, sv, u->skills);
|
||||
|
@ -368,7 +368,7 @@ static void test_limited_skills(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
CuAssertIntEquals(tc, false, has_limited_skills(u));
|
||||
set_level(u, SK_ENTERTAINMENT, 1);
|
||||
CuAssertIntEquals(tc, false, has_limited_skills(u));
|
||||
|
@ -395,7 +395,7 @@ static void test_unit_description(CuTest *tc) {
|
|||
test_setup();
|
||||
lang = test_create_locale();
|
||||
rc = test_create_race("hodor");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
|
||||
CuAssertStrEquals(tc, NULL, unit_getinfo(u));
|
||||
CuAssertStrEquals(tc, NULL, u_description(u, lang));
|
||||
|
@ -421,7 +421,7 @@ static void test_remove_unit(CuTest *tc) {
|
|||
init_resources();
|
||||
rtype = get_resourcetype(R_SILVER);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u2 = test_create_unit(f, r);
|
||||
u1 = test_create_unit(f, r);
|
||||
CuAssertPtrEquals(tc, u1, f->units);
|
||||
|
@ -465,7 +465,7 @@ static void test_renumber_unit(CuTest *tc) {
|
|||
unit *u1, *u2;
|
||||
|
||||
test_setup();
|
||||
u1 = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u1 = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u2 = test_create_unit(u1->faction, u1->region);
|
||||
rng_init(0);
|
||||
renumber_unit(u1, 0);
|
||||
|
@ -486,7 +486,7 @@ static void test_name_unit(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
rc = test_create_race("skeleton");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
rc->name_unit = gen_name;
|
||||
name_unit(u);
|
||||
CuAssertStrEquals(tc, "Hodor", unit_getname(u));
|
||||
|
@ -502,7 +502,7 @@ static void test_heal_factor(CuTest *tc) {
|
|||
test_setup();
|
||||
t_plain = test_create_terrain("plain", LAND_REGION|FOREST_REGION);
|
||||
rc = rc_get_or_create("human");
|
||||
u = test_create_unit(test_create_faction(rc), r = test_create_region(0, 0, t_plain));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), r = test_create_region(0, 0, t_plain));
|
||||
rsettrees(r, 1, r->terrain->size / TREESIZE);
|
||||
rsettrees(r, 2, 0);
|
||||
CuAssertTrue(tc, r_isforest(r));
|
||||
|
@ -524,7 +524,7 @@ static void test_unlimited_units(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
CuAssertIntEquals(tc, 0, f->num_units);
|
||||
CuAssertIntEquals(tc, 0, f->num_people);
|
||||
u = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
|
@ -553,7 +553,7 @@ static void test_clone_men_bug_2386(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
scale_number(u1, 8237);
|
||||
u1->hp = 39 * u1->number;
|
||||
|
@ -572,7 +572,7 @@ static void test_clone_men(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
scale_number(u1, 10);
|
||||
u2 = test_create_unit(f, r);
|
||||
|
@ -596,7 +596,7 @@ static void test_transfermen(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
scale_number(u1, 3500);
|
||||
u2 = test_create_unit(f, r);
|
||||
|
@ -624,7 +624,7 @@ static void test_get_modifier(CuTest *tc) {
|
|||
rc->bonus[SK_ARMORER] = 1;
|
||||
rc->bonus[SK_TAXING] = 0;
|
||||
rc->bonus[SK_TRADE] = -1;
|
||||
u = test_create_unit(test_create_faction(rc), r = test_create_region(0, 0, t_plain));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), r = test_create_region(0, 0, t_plain));
|
||||
|
||||
/* no effects for insects in plains: */
|
||||
CuAssertIntEquals(tc, 0, get_modifier(u, SK_TAXING, 0, r, true));
|
||||
|
@ -649,7 +649,7 @@ static void test_gift_items(CuTest *tc) {
|
|||
test_setup();
|
||||
init_resources();
|
||||
r = test_create_plain(0, 0);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
rtype = get_resourcetype(R_SILVER);
|
||||
region_setresource(r, rtype, 0);
|
||||
i_change(&u->items, rtype->itype, 10);
|
||||
|
@ -661,7 +661,7 @@ static void test_gift_items(CuTest *tc) {
|
|||
region_setresource(r, rtype, 0);
|
||||
i_change(&u->items, rtype->itype, 10);
|
||||
i_change(&u->items, get_resourcetype(R_HORSE)->itype, 20);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(u1->faction, r);
|
||||
gift_items(u, GIFT_FRIENDS | GIFT_PEASANTS | GIFT_SELF);
|
||||
CuAssertIntEquals(tc, 20, region_getresource(r, get_resourcetype(R_HORSE)));
|
||||
|
@ -682,7 +682,7 @@ static void test_gift_items(CuTest *tc) {
|
|||
i_change(&u1->items, rtype->itype, -10);
|
||||
|
||||
set_number(u1, 2);
|
||||
u_setfaction(u2, test_create_faction(NULL));
|
||||
u_setfaction(u2, test_create_faction());
|
||||
ally_set(&u->faction->allies, u2->faction, HELP_MONEY);
|
||||
ally_set(&u2->faction->allies, u->faction, HELP_GIVE);
|
||||
region_setresource(r, rtype, 0);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#ifndef ERESSEA_VERSION
|
||||
/* the version number, if it was not passed to make with -D */
|
||||
#define ERESSEA_VERSION "3.25.0"
|
||||
#define ERESSEA_VERSION "3.26.0"
|
||||
#endif
|
||||
|
||||
const char *eressea_version(void) {
|
||||
|
|
|
@ -743,7 +743,8 @@ void immigration(void)
|
|||
/* if less than 50 are in the region and there is space and no monster or demon units in the region */
|
||||
if (repopulate) {
|
||||
int peasants = rpeasants(r);
|
||||
int income = wage(r, NULL, NULL, turn) - maintenance_cost(NULL) + 1;
|
||||
bool mourn = is_mourning(r, turn);
|
||||
int income = peasant_wage(r, mourn) - maintenance_cost(NULL) + 1;
|
||||
if (income >= 0 && r->land && (peasants < repopulate) && region_maxworkers(r) >(peasants + 30) * 2) {
|
||||
int badunit = 0;
|
||||
unit *u;
|
||||
|
@ -754,7 +755,7 @@ void immigration(void)
|
|||
}
|
||||
}
|
||||
if (badunit == 0) {
|
||||
peasants += (int)(rng_double()*income);
|
||||
peasants += (int)(rng_double() * income);
|
||||
rsetpeasants(r, peasants);
|
||||
}
|
||||
}
|
||||
|
@ -836,8 +837,10 @@ void demographics(void)
|
|||
|
||||
if (r->age > 20) {
|
||||
double mwp = fmax(region_maxworkers(r), 1);
|
||||
bool mourn = is_mourning(r, turn);
|
||||
int p_wage = peasant_wage(r, mourn);
|
||||
double prob =
|
||||
pow(rpeasants(r) / (mwp * wage(r, NULL, NULL, turn) * 0.13), 4.0)
|
||||
pow(rpeasants(r) / (mwp * p_wage * 0.13), 4.0)
|
||||
* PLAGUE_CHANCE;
|
||||
|
||||
if (rng_double() < prob) {
|
||||
|
|
156
src/laws.test.c
156
src/laws.test.c
|
@ -62,7 +62,7 @@ static void test_rename_building(CuTest * tc)
|
|||
btype = test_create_buildingtype("castle");
|
||||
r = test_create_region(0, 0, NULL);
|
||||
b = new_building(btype, r, default_locale, 1);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
u_set_building(u, b);
|
||||
|
||||
|
@ -85,7 +85,7 @@ static void test_rename_building_twice(CuTest * tc)
|
|||
btype = test_create_buildingtype("castle");
|
||||
r = test_create_region(0, 0, NULL);
|
||||
b = new_building(btype, r, default_locale, 1);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
u_set_building(u, b);
|
||||
|
||||
|
@ -108,7 +108,7 @@ static void test_enter_building(CuTest * tc)
|
|||
test_create_locale();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
rc = test_create_race("human");
|
||||
u = test_create_unit(test_create_faction(rc), r);
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
b = test_create_building(r, test_create_buildingtype("castle"));
|
||||
|
||||
rc->flags = RCF_WALK;
|
||||
|
@ -143,7 +143,7 @@ static void test_enter_ship(CuTest * tc)
|
|||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
rc = test_create_race("smurf");
|
||||
u = test_create_unit(test_create_faction(rc), r);
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
sh = test_create_ship(r, NULL);
|
||||
|
||||
rc->flags = RCF_WALK;
|
||||
|
@ -181,7 +181,7 @@ static void test_display_cmd(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, test_create_terrain("plain", LAND_REGION));
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
assert(r && f);
|
||||
u = test_create_unit(f, r);
|
||||
assert(u);
|
||||
|
@ -244,9 +244,9 @@ static void test_force_leave_buildings(CuTest *tc) {
|
|||
test_setup();
|
||||
mt_create_va(mt_new("force_leave_building", NULL), "unit:unit", "owner:unit", "building:building", MT_NEW_END);
|
||||
r = test_create_region(0, 0, test_create_terrain("plain", LAND_REGION));
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(u1->faction, r);
|
||||
u3 = test_create_unit(test_create_faction(NULL), r);
|
||||
u3 = test_create_unit(test_create_faction(), r);
|
||||
b = test_create_building(r, NULL);
|
||||
u_set_building(u1, b);
|
||||
building_set_owner(u1);
|
||||
|
@ -273,8 +273,8 @@ static void test_force_leave_ships(CuTest *tc) {
|
|||
test_setup();
|
||||
mt_create_va(mt_new("force_leave_ship", NULL), "unit:unit", "owner:unit", "ship:ship", MT_NEW_END);
|
||||
r = test_create_region(0, 0, test_create_terrain("plain", LAND_REGION));
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
sh = test_create_ship(r, NULL);
|
||||
u_set_ship(u1, sh);
|
||||
u_set_ship(u2, sh);
|
||||
|
@ -292,8 +292,8 @@ static void test_force_leave_ships_on_ocean(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_ocean(0, 0);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
sh = test_create_ship(r, NULL);
|
||||
u_set_ship(u1, sh);
|
||||
u_set_ship(u2, sh);
|
||||
|
@ -313,7 +313,7 @@ static void test_fishing_feeds_2_people(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_ocean(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
sh = test_create_ship(r, NULL);
|
||||
u_set_ship(u, sh);
|
||||
|
@ -349,7 +349,7 @@ static void test_fishing_does_not_give_goblins_money(CuTest * tc)
|
|||
itype = test_create_silver();
|
||||
|
||||
r = test_create_ocean(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
sh = test_create_ship(r, NULL);
|
||||
u_set_ship(u, sh);
|
||||
|
@ -374,7 +374,7 @@ static void test_fishing_gets_reset(CuTest * tc)
|
|||
itype = test_create_silver();
|
||||
|
||||
r = test_create_ocean(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
sh = test_create_ship(r, NULL);
|
||||
u_set_ship(u, sh);
|
||||
|
@ -432,7 +432,7 @@ static void test_maketemp(CuTest * tc)
|
|||
unit *u, *u2;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
|
||||
u->orders = create_order(K_MAKETEMP, f->locale, "1");
|
||||
|
@ -460,7 +460,7 @@ static void test_maketemp_default_order(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
config_set("orders.default", "work");
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
|
||||
new_units();
|
||||
|
@ -495,7 +495,7 @@ static void test_limit_new_units(CuTest * tc)
|
|||
mt_create_va(mt_new("too_many_units_in_alliance", NULL), "unit:unit",
|
||||
"region:region", "command:order", "allowed:int", MT_NEW_END);
|
||||
al = makealliance(1, "Hodor");
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
CuAssertIntEquals(tc, 1, f->num_units);
|
||||
CuAssertIntEquals(tc, 1, f->num_people);
|
||||
|
@ -526,7 +526,7 @@ static void test_limit_new_units(CuTest * tc)
|
|||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "too_many_units_in_alliance"));
|
||||
|
||||
config_set("rules.limit.alliance", "3");
|
||||
u = test_create_unit(test_create_faction(NULL), u->region);
|
||||
u = test_create_unit(test_create_faction(), u->region);
|
||||
setalliance(u->faction, al);
|
||||
|
||||
CuAssertPtrEquals(tc, NULL, u->orders);
|
||||
|
@ -544,7 +544,7 @@ static void test_cannot_create_unit_above_limit(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
config_set("rules.limit.faction", "4");
|
||||
|
||||
CuAssertIntEquals(tc, 0, checkunitnumber(f, 4));
|
||||
|
@ -568,7 +568,7 @@ static void test_reserve_cmd(CuTest *tc) {
|
|||
|
||||
rtype = get_resourcetype(R_SILVER);
|
||||
assert(rtype && rtype->itype);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
assert(r && f);
|
||||
u1 = test_create_unit(f, r);
|
||||
|
@ -597,7 +597,7 @@ static void setup_pay_cmd(struct pay_fixture *fix) {
|
|||
building_type *btcastle;
|
||||
|
||||
test_create_world();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
assert(r && f);
|
||||
btcastle = test_create_buildingtype("castle");
|
||||
|
@ -682,7 +682,7 @@ static void test_new_units(CuTest *tc) {
|
|||
const struct locale *loc;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
assert(r && f);
|
||||
u = test_create_unit(f, r);
|
||||
|
@ -711,7 +711,7 @@ void setup_guard(guard_fixture *fix, bool armed) {
|
|||
|
||||
test_setup();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
assert(r && f);
|
||||
u = test_create_unit(f, r);
|
||||
|
@ -822,7 +822,7 @@ static void test_reserve_self(CuTest *tc) {
|
|||
|
||||
rtype = get_resourcetype(R_SILVER);
|
||||
assert(rtype && rtype->itype);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
assert(r && f);
|
||||
u1 = test_create_unit(f, r);
|
||||
|
@ -914,7 +914,7 @@ static unit * setup_name_cmd(void) {
|
|||
mt_create_error(12);
|
||||
mt_create_va(mt_new("renamed_building_seen", NULL), "renamer:unit", "region:region", "building:building", MT_NEW_END);
|
||||
mt_create_va(mt_new("renamed_building_notseen", NULL), "region:region", "building:building", MT_NEW_END);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
return test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
}
|
||||
|
||||
|
@ -981,7 +981,7 @@ static void test_name_building(CuTest *tc) {
|
|||
u = setup_name_cmd();
|
||||
u->building = test_create_building(u->region, NULL);
|
||||
f = u->faction;
|
||||
uo = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
uo = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u_set_building(uo, u->building);
|
||||
ux = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
u_set_building(ux, u->building);
|
||||
|
@ -1029,7 +1029,7 @@ static void test_name_ship(CuTest *tc) {
|
|||
u = setup_name_cmd();
|
||||
u->ship = test_create_ship(u->region, NULL);
|
||||
f = u->faction;
|
||||
uo = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
uo = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u_set_ship(uo, u->ship);
|
||||
ux = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
u_set_ship(ux, u->ship);
|
||||
|
@ -1067,7 +1067,7 @@ static void test_long_order_normal(CuTest *tc) {
|
|||
order *ord;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
fset(u, UFL_MOVED);
|
||||
fset(u, UFL_LONGACTION);
|
||||
unit_addorder(u, ord = create_order(K_MOVE, u->faction->locale, 0));
|
||||
|
@ -1085,7 +1085,7 @@ static void test_long_order_none(CuTest *tc) {
|
|||
/* TODO: write more tests */
|
||||
unit *u;
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
update_long_order(u);
|
||||
CuAssertPtrEquals(tc, NULL, u->thisorder);
|
||||
CuAssertPtrEquals(tc, NULL, u->orders);
|
||||
|
@ -1097,7 +1097,7 @@ static void test_long_order_cast(CuTest *tc) {
|
|||
/* TODO: write more tests */
|
||||
unit *u;
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
unit_addorder(u, create_order(K_CAST, u->faction->locale, NULL));
|
||||
unit_addorder(u, create_order(K_CAST, u->faction->locale, NULL));
|
||||
update_long_order(u);
|
||||
|
@ -1111,7 +1111,7 @@ static void test_long_order_buy_sell(CuTest *tc) {
|
|||
/* TODO: write more tests */
|
||||
unit *u;
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, NULL));
|
||||
unit_addorder(u, create_order(K_SELL, u->faction->locale, NULL));
|
||||
unit_addorder(u, create_order(K_SELL, u->faction->locale, NULL));
|
||||
|
@ -1127,7 +1127,7 @@ static void test_long_order_multi_long(CuTest *tc) {
|
|||
unit *u;
|
||||
test_setup();
|
||||
mt_create_error(52);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
unit_addorder(u, create_order(K_MOVE, u->faction->locale, NULL));
|
||||
unit_addorder(u, create_order(K_DESTROY, u->faction->locale, NULL));
|
||||
update_long_order(u);
|
||||
|
@ -1142,7 +1142,7 @@ static void test_long_order_multi_buy(CuTest *tc) {
|
|||
unit *u;
|
||||
test_setup();
|
||||
mt_create_error(52);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, 0));
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, 0));
|
||||
update_long_order(u);
|
||||
|
@ -1156,7 +1156,7 @@ static void test_long_order_multi_sell(CuTest *tc) {
|
|||
/* TODO: write more tests */
|
||||
unit *u;
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
unit_addorder(u, create_order(K_SELL, u->faction->locale, 0));
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, 0));
|
||||
unit_addorder(u, create_order(K_SELL, u->faction->locale, 0));
|
||||
|
@ -1172,7 +1172,7 @@ static void test_long_order_buy_cast(CuTest *tc) {
|
|||
unit *u;
|
||||
test_setup();
|
||||
mt_create_error(52);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, 0));
|
||||
unit_addorder(u, create_order(K_CAST, u->faction->locale, 0));
|
||||
update_long_order(u);
|
||||
|
@ -1186,7 +1186,7 @@ static void test_long_order_hungry(CuTest *tc) {
|
|||
unit *u;
|
||||
test_setup();
|
||||
config_set("hunger.long", "1");
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
fset(u, UFL_HUNGER);
|
||||
unit_addorder(u, create_order(K_MOVE, u->faction->locale, 0));
|
||||
unit_addorder(u, create_order(K_DESTROY, u->faction->locale, 0));
|
||||
|
@ -1205,7 +1205,7 @@ static void test_ally_cmd_errors(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
mt_create_error(66);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
fid = u->faction->no + 1;
|
||||
CuAssertPtrEquals(tc, NULL, findfaction(fid));
|
||||
|
||||
|
@ -1225,7 +1225,7 @@ static void test_banner_cmd(CuTest *tc) {
|
|||
test_setup();
|
||||
mt_create_error(125);
|
||||
mt_create_va(mt_new("changebanner", NULL), "value:string", MT_NEW_END);
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
|
||||
ord = create_order(K_BANNER, f->locale, "Hodor!");
|
||||
banner_cmd(u, ord);
|
||||
|
@ -1253,7 +1253,7 @@ static void test_email_cmd(CuTest *tc) {
|
|||
mt_create_error(85);
|
||||
mt_create_va(mt_new("changemail", NULL), "value:string", MT_NEW_END);
|
||||
mt_create_va(mt_new("changemail_invalid", NULL), "value:string", MT_NEW_END);
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
|
||||
ord = create_order(K_EMAIL, f->locale, "hodor@example.com");
|
||||
email_cmd(u, ord);
|
||||
|
@ -1286,7 +1286,7 @@ static void test_name_cmd(CuTest *tc) {
|
|||
order *ord;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
setalliance(f, al = makealliance(42, ""));
|
||||
|
||||
ord = create_order(K_NAME, f->locale, "%s ' Ho\tdor '", LOC(f->locale, parameters[P_UNIT]));
|
||||
|
@ -1331,7 +1331,7 @@ static void test_name_foreign_cmd(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(f = test_create_faction(NULL), r = test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), r = test_create_region(0, 0, NULL));
|
||||
b = test_create_building(u->region, NULL);
|
||||
u->thisorder = create_order(K_NAME, f->locale, "%s %s %s Hodor",
|
||||
LOC(f->locale, parameters[P_FOREIGN]),
|
||||
|
@ -1349,8 +1349,8 @@ static void test_name_cmd_2274(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
u3 = test_create_unit(u2->faction, r);
|
||||
u_set_building(u1, test_create_building(r, NULL));
|
||||
u1->building->size = 10;
|
||||
|
@ -1379,8 +1379,8 @@ static void test_ally_cmd(CuTest *tc) {
|
|||
order *ord;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
f = test_create_faction(NULL);
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
f = test_create_faction();
|
||||
|
||||
ord = create_order(K_ALLY, f->locale, "%s", itoa36(f->no));
|
||||
ally_cmd(u, ord);
|
||||
|
@ -1416,8 +1416,8 @@ static void test_nmr_warnings(CuTest *tc) {
|
|||
mt_create_va(mt_new("nmr_warning_final", NULL), MT_NEW_END);
|
||||
mt_create_va(mt_new("warn_dropout", NULL), "faction:faction", "turn:int", MT_NEW_END);
|
||||
config_set("nmr.timeout", "3");
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
f2->age = 2;
|
||||
f2->lastorders = 1;
|
||||
turn = 3;
|
||||
|
@ -1441,7 +1441,7 @@ static unit * setup_mail_cmd(void) {
|
|||
mt_create_va(mt_new("regionmessage", NULL), "region:region", "sender:unit", "string:string", MT_NEW_END);
|
||||
mt_create_va(mt_new("unitmessage", NULL), "region:region", "sender:unit", "string:string", "unit:unit", MT_NEW_END);
|
||||
mt_create_va(mt_new("mail_result", NULL), "message:string", "unit:unit", MT_NEW_END);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
return test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
}
|
||||
|
||||
|
@ -1566,7 +1566,7 @@ static void test_show_without_item(CuTest *tc)
|
|||
init_parameters(loc);
|
||||
|
||||
r = test_create_region(0, 0, test_create_terrain("testregion", LAND_REGION));
|
||||
f = test_create_faction(test_create_race("human"));
|
||||
f = test_create_faction_ex(test_create_race("human"), NULL);
|
||||
u = test_create_unit(f, r);
|
||||
|
||||
itype = it_get_or_create(rt_get_or_create("testitem"));
|
||||
|
@ -1636,7 +1636,7 @@ static void test_show_race(CuTest *tc) {
|
|||
rc = test_create_race("elf");
|
||||
|
||||
loc = setup_locale();
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
u->faction->locale = loc;
|
||||
|
||||
ord = create_order(K_RESHOW, loc, "Mensch");
|
||||
|
@ -1676,7 +1676,7 @@ static void test_show_both(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, finditemtype("elf", loc));
|
||||
CuAssertPtrNotNull(tc, findrace("elf", loc));
|
||||
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
u->faction->locale = loc;
|
||||
i_change(&u->items, finditemtype("elfenpferd", loc), 1);
|
||||
ord = create_order(K_RESHOW, loc, "Elf");
|
||||
|
@ -1735,7 +1735,7 @@ static void test_demon_hunger(CuTest * tc)
|
|||
init_resources();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
rc = test_create_race("demon");
|
||||
f = test_create_faction(rc);
|
||||
f = test_create_faction_ex(rc, NULL);
|
||||
u = test_create_unit(f, r);
|
||||
u->hp = 999;
|
||||
|
||||
|
@ -1767,7 +1767,7 @@ static void test_armedmen(CuTest *tc) {
|
|||
item_type *it_sword;
|
||||
weapon_type *wtype;
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
it_sword = test_create_itemtype("sword");
|
||||
wtype = new_weapontype(it_sword, 0, frac_make(1, 2), 0, 0, 0, 0, SK_MELEE);
|
||||
CuAssertIntEquals(tc, 0, armedmen(u, false));
|
||||
|
@ -1796,8 +1796,8 @@ static void test_cansee(CuTest *tc) {
|
|||
unit *u, *u2;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u2 = test_create_unit(test_create_faction(NULL), u->region);
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u2 = test_create_unit(test_create_faction(), u->region);
|
||||
|
||||
CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0));
|
||||
|
||||
|
@ -1815,8 +1815,8 @@ static void test_cansee_ring(CuTest *tc) {
|
|||
item_type *itype[2];
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u2 = test_create_unit(test_create_faction(NULL), u->region);
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u2 = test_create_unit(test_create_faction(), u->region);
|
||||
scale_number(u2, 2);
|
||||
|
||||
itype[0] = test_create_itemtype("roi");
|
||||
|
@ -1848,8 +1848,8 @@ static void test_cansee_sphere(CuTest *tc) {
|
|||
item_type *itype[2];
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u2 = test_create_unit(test_create_faction(NULL), u->region);
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u2 = test_create_unit(test_create_faction(), u->region);
|
||||
|
||||
itype[0] = test_create_itemtype("sphereofinv");
|
||||
itype[1] = test_create_itemtype("aots");
|
||||
|
@ -1894,7 +1894,7 @@ static void test_long_orders(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
CuAssertTrue(tc, long_order_allowed(u));
|
||||
u->flags |= UFL_LONGACTION;
|
||||
CuAssertTrue(tc, !long_order_allowed(u));
|
||||
|
@ -1907,13 +1907,13 @@ static void test_long_order_on_ocean(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
rc = test_create_race("pikachu");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_ocean(0, 0));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_ocean(0, 0));
|
||||
CuAssertTrue(tc, !long_order_allowed(u));
|
||||
rc->flags |= RCF_SWIM;
|
||||
CuAssertTrue(tc, long_order_allowed(u));
|
||||
|
||||
rc = test_create_race("aquarian");
|
||||
u = test_create_unit(test_create_faction(rc), u->region);
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), u->region);
|
||||
CuAssertTrue(tc, long_order_allowed(u));
|
||||
test_teardown();
|
||||
}
|
||||
|
@ -1932,7 +1932,7 @@ static void test_password_cmd(CuTest *tc) {
|
|||
mt_create_error(283);
|
||||
mt_create_error(321);
|
||||
mt_create_va(mt_new("changepasswd", NULL), "value:string", MT_NEW_END);
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_plain(0, 0));
|
||||
u->thisorder = create_order(K_PASSWORD, f->locale, "password1234", NULL);
|
||||
password_cmd(u, u->thisorder);
|
||||
CuAssertTrue(tc, checkpasswd(f, "password1234"));
|
||||
|
@ -2026,7 +2026,7 @@ static void test_quit(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
u->thisorder = create_order(K_QUIT, f->locale, "password");
|
||||
|
||||
|
@ -2052,10 +2052,10 @@ static void test_quit_transfer(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f1 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
faction_setpassword(f1, "password");
|
||||
u1 = test_create_unit(f1, r);
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
u2 = test_create_unit(f2, r);
|
||||
contact_unit(u2, u1);
|
||||
u1->thisorder = create_order(K_QUIT, f1->locale, "password %s %s",
|
||||
|
@ -2079,10 +2079,10 @@ static void test_quit_transfer_limited(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f1 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
faction_setpassword(f1, "password");
|
||||
u1 = test_create_unit(f1, r);
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
u2 = test_create_unit(f2, r);
|
||||
contact_unit(u2, u1);
|
||||
u1->thisorder = create_order(K_QUIT, f1->locale, "password %s %s",
|
||||
|
@ -2117,10 +2117,10 @@ static void test_quit_transfer_mages(CuTest *tc) {
|
|||
test_setup();
|
||||
config_set_int("rules.maxskills.magic", 2);
|
||||
r = test_create_plain(0, 0);
|
||||
f1 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
faction_setpassword(f1, "password");
|
||||
u1 = test_create_unit(f1, r);
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
u2 = test_create_unit(f2, r);
|
||||
contact_unit(u2, u1);
|
||||
u1->thisorder = create_order(K_QUIT, f1->locale, "password %s %s",
|
||||
|
@ -2153,10 +2153,10 @@ static void test_quit_transfer_different_mages(CuTest *tc) {
|
|||
test_setup();
|
||||
config_set_int("rules.maxskills.magic", 2);
|
||||
r = test_create_plain(0, 0);
|
||||
f1 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
faction_setpassword(f1, "password");
|
||||
u1 = test_create_unit(f1, r);
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
u2 = test_create_unit(f2, r);
|
||||
contact_unit(u2, u1);
|
||||
u1->thisorder = create_order(K_QUIT, f1->locale, "password %s %s",
|
||||
|
@ -2188,10 +2188,10 @@ static void test_quit_transfer_migrants(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f1 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
faction_setpassword(f1, "password");
|
||||
u1 = test_create_unit(f1, r);
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
u2 = test_create_unit(f2, r);
|
||||
contact_unit(u2, u1);
|
||||
u1->thisorder = create_order(K_QUIT, f1->locale, "password %s %s",
|
||||
|
@ -2216,10 +2216,10 @@ static void test_quit_transfer_hero(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f1 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
faction_setpassword(f1, "password");
|
||||
u1 = test_create_unit(f1, r);
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
u2 = test_create_unit(f2, r);
|
||||
contact_unit(u2, u1);
|
||||
u1->thisorder = create_order(K_QUIT, f1->locale, "password %s %s",
|
||||
|
@ -2242,8 +2242,8 @@ static void test_transfer_faction(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
u1 = test_create_unit(f1, r);
|
||||
u2 = test_create_unit(f1, r);
|
||||
u_setrace(u2, test_create_race("smurf"));
|
||||
|
|
|
@ -21,7 +21,12 @@ attrib_type at_lighthouse = {
|
|||
|
||||
bool is_lighthouse(const building_type *btype)
|
||||
{
|
||||
return is_building_type(btype, "lighthouse");
|
||||
static int config;
|
||||
static const building_type *bt_lighthouse;
|
||||
if (bt_changed(&config)) {
|
||||
bt_lighthouse = bt_find("lighthouse");
|
||||
}
|
||||
return btype == bt_lighthouse;
|
||||
}
|
||||
|
||||
/* update_lighthouse: call this function whenever the size of a lighthouse changes
|
||||
|
@ -81,7 +86,7 @@ void remove_lighthouse(const building *lh) {
|
|||
|
||||
int lighthouse_range(const building * b)
|
||||
{
|
||||
if (b->size >= 10 && (b->flags & BLD_MAINTAINED)) {
|
||||
if (b->size >= 10) {
|
||||
return (int)log10(b->size) + 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -112,13 +117,19 @@ bool lighthouse_guarded(const region * r)
|
|||
for (a = a_find(r->attribs, &at_lighthouse); a && a->type == &at_lighthouse;
|
||||
a = a->next) {
|
||||
building *b = (building *)a->data.v;
|
||||
|
||||
assert(is_building_type(b->type, "lighthouse"));
|
||||
if ((b->flags & BLD_MAINTAINED) && b->size >= 10) {
|
||||
int maxd = (int)log10(b->size) + 1;
|
||||
int d = distance(r, b->region);
|
||||
assert(maxd >= d);
|
||||
return true;
|
||||
if (b->flags & BLD_MAINTAINED) {
|
||||
if (r == b->region) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
int maxd = lighthouse_range(b);
|
||||
if (maxd > 0) {
|
||||
int d = distance(r, b->region);
|
||||
if (maxd >= d) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,15 +23,13 @@ static void test_lighthouse_range(CuTest * tc)
|
|||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
test_create_region(1, 0, 0);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
b = test_create_building(r, test_create_buildingtype("lighthouse"));
|
||||
CuAssertIntEquals(tc, 0, lighthouse_range(b));
|
||||
b->size = 9;
|
||||
CuAssertIntEquals(tc, 0, lighthouse_range(b));
|
||||
b->size = 10;
|
||||
CuAssertIntEquals(tc, 0, lighthouse_range(b));
|
||||
b->flags |= BLD_MAINTAINED;
|
||||
CuAssertIntEquals(tc, 2, lighthouse_range(b));
|
||||
u1->building = b;
|
||||
u2->building = b;
|
||||
|
@ -39,6 +37,8 @@ static void test_lighthouse_range(CuTest * tc)
|
|||
set_level(u1, SK_PERCEPTION, 3);
|
||||
set_level(u2, SK_PERCEPTION, 3);
|
||||
|
||||
CuAssertIntEquals(tc, 0, lighthouse_view_distance(b, u1));
|
||||
b->flags |= BLD_MAINTAINED;
|
||||
CuAssertIntEquals(tc, 1, lighthouse_view_distance(b, u1));
|
||||
set_level(u1, SK_PERCEPTION, 6);
|
||||
CuAssertIntEquals(tc, 1, lighthouse_view_distance(b, u2));
|
||||
|
@ -126,6 +126,7 @@ static void test_lighthouse_guard(CuTest * tc) {
|
|||
CuAssertIntEquals(tc, true, lighthouse_guarded(r3));
|
||||
CuAssertIntEquals(tc, false, lighthouse_guarded(r4));
|
||||
b->size = 1; /* size can go down in destroy_cmd */
|
||||
update_lighthouse(b);
|
||||
CuAssertIntEquals(tc, false, lighthouse_guarded(r2));
|
||||
CuAssertIntEquals(tc, false, lighthouse_guarded(r3));
|
||||
test_teardown();
|
||||
|
|
|
@ -37,7 +37,7 @@ void test_updatespells(CuTest * tc)
|
|||
test_setup();
|
||||
test_create_race("human");
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
sp = create_spell("testspell");
|
||||
CuAssertPtrNotNull(tc, sp);
|
||||
|
||||
|
@ -109,7 +109,7 @@ void test_pay_spell(CuTest * tc)
|
|||
test_setup();
|
||||
init_resources();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
CuAssertPtrNotNull(tc, u);
|
||||
|
||||
|
@ -143,7 +143,7 @@ void test_pay_spell_failure(CuTest * tc)
|
|||
test_setup();
|
||||
init_resources();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
CuAssertPtrNotNull(tc, u);
|
||||
|
||||
|
@ -180,7 +180,7 @@ void test_getspell_unit(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
create_mage(u, M_GWYRRD);
|
||||
enable_skill(SK_MAGIC, true);
|
||||
|
@ -208,7 +208,7 @@ void test_getspell_faction(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f->magiegebiet = M_TYBIED;
|
||||
u = test_create_unit(f, r);
|
||||
create_mage(u, f->magiegebiet);
|
||||
|
@ -239,7 +239,7 @@ void test_getspell_school(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f->magiegebiet = M_TYBIED;
|
||||
u = test_create_unit(f, r);
|
||||
create_mage(u, f->magiegebiet);
|
||||
|
@ -269,7 +269,7 @@ void test_set_pre_combatspell(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f->magiegebiet = M_TYBIED;
|
||||
u = test_create_unit(f, r);
|
||||
enable_skill(SK_MAGIC, true);
|
||||
|
@ -301,7 +301,7 @@ void test_set_main_combatspell(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f->magiegebiet = M_TYBIED;
|
||||
u = test_create_unit(f, r);
|
||||
enable_skill(SK_MAGIC, true);
|
||||
|
@ -333,7 +333,7 @@ void test_set_post_combatspell(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f->magiegebiet = M_TYBIED;
|
||||
u = test_create_unit(f, r);
|
||||
enable_skill(SK_MAGIC, true);
|
||||
|
@ -364,7 +364,7 @@ void test_hasspell(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f->magiegebiet = M_TYBIED;
|
||||
u = test_create_unit(f, r);
|
||||
enable_skill(SK_MAGIC, true);
|
||||
|
@ -405,7 +405,7 @@ void test_multi_cast(CuTest *tc) {
|
|||
locale_setstring(lang, mkname_spell(sp), "Feuerball");
|
||||
CuAssertStrEquals(tc, "Feuerball", spell_name(mkname_spell(sp), lang));
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
set_level(u, SK_MAGIC, 10);
|
||||
unit_add_spell(u, sp, 1);
|
||||
CuAssertPtrEquals(tc, sp, unit_getspell(u, "Feuerball", lang));
|
||||
|
@ -426,7 +426,7 @@ static void test_magic_resistance(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
rc = test_create_race("human");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_plain(0, 0));
|
||||
CuAssertTrue(tc, frac_equal(rc->magres, magic_resistance(u)));
|
||||
rc->magres = frac_one;
|
||||
CuAssert(tc, "magic resistance is capped at 0.9", frac_equal(magic_resistance(u), frac_make(9, 10)));
|
||||
|
@ -446,7 +446,7 @@ static void test_max_spellpoints(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
rc = test_create_race("human");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_plain(0, 0));
|
||||
CuAssertIntEquals(tc, 0, max_spellpoints(u, u->region));
|
||||
CuAssertIntEquals(tc, 0, max_spellpoints(u, NULL));
|
||||
create_mage(u, M_GWYRRD);
|
||||
|
@ -472,7 +472,7 @@ static void test_regenerate_aura(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
create_mage(u, M_GWYRRD);
|
||||
CuAssertIntEquals(tc, 0, get_spellpoints(u));
|
||||
CuAssertIntEquals(tc, 1, max_spellpoints(u, NULL));
|
||||
|
@ -503,7 +503,7 @@ static void test_regenerate_aura_migrants(CuTest *tc) {
|
|||
rc->maxaura = 100;
|
||||
rc->flags |= RCF_FAMILIAR;
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u_setrace(u, rc);
|
||||
CuAssertIntEquals(tc, 0, get_spellpoints(u));
|
||||
regenerate_aura();
|
||||
|
@ -521,7 +521,7 @@ static void test_fix_fam_migrants(CuTest *tc) {
|
|||
rc->flags |= RCF_FAMILIAR;
|
||||
|
||||
/* u is a migrant with at_mage attribute, but not a familiar */
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u_setrace(u, rc);
|
||||
create_mage(u, M_GRAY);
|
||||
CuAssertTrue(tc, !is_familiar(u));
|
||||
|
@ -531,8 +531,8 @@ static void test_fix_fam_migrants(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, NULL, get_mage(u));
|
||||
|
||||
/* u is a familiar, and stays unchanged: */
|
||||
mage = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
mage = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u_setrace(u, rc);
|
||||
/* reproduce the bug, create a broken familiar: */
|
||||
create_newfamiliar(mage, u);
|
||||
|
@ -564,8 +564,8 @@ static void test_fix_fam_spells(CuTest *tc) {
|
|||
rc->flags |= RCF_FAMILIAR;
|
||||
|
||||
/* u is a familiar, and gets equipped: */
|
||||
mage = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
mage = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u_setrace(u, rc);
|
||||
/* reproduce the bug, create a broken familiar: */
|
||||
callbacks.equip_unit = NULL;
|
||||
|
@ -581,7 +581,7 @@ static void test_fix_fam_spells(CuTest *tc) {
|
|||
CuAssertTrue(tc, u_hasspell(u, sp));
|
||||
|
||||
/* u is a migrant, and does not get equipped: */
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u_setrace(u, rc);
|
||||
CuAssertTrue(tc, !is_familiar(u));
|
||||
fix_fam_spells(u);
|
||||
|
@ -617,7 +617,7 @@ static void test_is_mage(CuTest *tc) {
|
|||
struct sc_mage *mage;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
CuAssertPtrEquals(tc, NULL, get_mage(u));
|
||||
CuAssertTrue(tc, !is_mage(u));
|
||||
set_level(u, SK_MAGIC, 1);
|
||||
|
@ -634,7 +634,7 @@ static void test_get_mage(CuTest *tc) {
|
|||
struct sc_mage *mage;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
CuAssertPtrEquals(tc, NULL, get_mage(u));
|
||||
CuAssertPtrNotNull(tc, mage = create_mage(u, M_CERDDOR));
|
||||
CuAssertPtrEquals(tc, mage, get_mage(u));
|
||||
|
@ -646,7 +646,7 @@ static void test_familiar_set(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
|
||||
mag = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
mag = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
fam = test_create_unit(mag->faction, test_create_plain(0, 0));
|
||||
CuAssertPtrEquals(tc, NULL, get_familiar(mag));
|
||||
CuAssertPtrEquals(tc, NULL, get_familiar_mage(fam));
|
||||
|
@ -661,12 +661,30 @@ static void test_familiar_set(CuTest *tc) {
|
|||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_familiar_skillmod(CuTest* tc) {
|
||||
unit* mag, * fam;
|
||||
|
||||
test_setup();
|
||||
|
||||
mag = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
fam = test_create_unit(mag->faction, test_create_plain(0, 0));
|
||||
set_level(mag, SK_STAMINA, 5);
|
||||
set_familiar(mag, fam);
|
||||
set_level(mag, SK_STAMINA, 5);
|
||||
CuAssertIntEquals(tc, 5, effskill(mag, SK_STAMINA, mag->region));
|
||||
set_level(fam, SK_STAMINA, 6);
|
||||
CuAssertIntEquals(tc, 8, effskill(mag, SK_STAMINA, mag->region));
|
||||
remove_familiar(mag);
|
||||
CuAssertIntEquals(tc, 5, effskill(mag, SK_STAMINA, mag->region));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_familiar_age(CuTest *tc) {
|
||||
unit *mag, *fam;
|
||||
|
||||
test_setup();
|
||||
|
||||
mag = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
mag = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
fam = test_create_unit(mag->faction, test_create_plain(0, 0));
|
||||
set_familiar(mag, fam);
|
||||
CuAssertPtrEquals(tc, fam, get_familiar(mag));
|
||||
|
@ -697,7 +715,7 @@ static void test_familiar_equip(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
callbacks.equip_unit = equip_callback;
|
||||
mag = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
mag = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u = test_create_unit(mag->faction, test_create_plain(0, 0));
|
||||
CuAssertStrEquals(tc, "human", u->_race->_name);
|
||||
set_familiar(mag, u);
|
||||
|
@ -715,6 +733,7 @@ CuSuite *get_familiar_suite(void)
|
|||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_familiar_equip);
|
||||
SUITE_ADD_TEST(suite, test_familiar_skillmod);
|
||||
SUITE_ADD_TEST(suite, test_familiar_set);
|
||||
SUITE_ADD_TEST(suite, test_familiar_age);
|
||||
return suite;
|
||||
|
|
34
src/main.c
34
src/main.c
|
@ -17,6 +17,7 @@
|
|||
#include "gmtool.h"
|
||||
#endif
|
||||
|
||||
#include "signals.h"
|
||||
#include "bindings.h"
|
||||
|
||||
#include <iniparser.h>
|
||||
|
@ -247,39 +248,6 @@ static int parse_args(int argc, char **argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_BACKTRACE
|
||||
#include <execinfo.h>
|
||||
#include <signal.h>
|
||||
static void *btrace[50];
|
||||
|
||||
static void report_segfault(int signo, siginfo_t * sinf, void *arg)
|
||||
{
|
||||
size_t size;
|
||||
int fd = fileno(stderr);
|
||||
|
||||
fflush(stdout);
|
||||
fputs("\n\nProgram received SIGSEGV, backtrace follows.\n", stderr);
|
||||
size = backtrace(btrace, 50);
|
||||
backtrace_symbols_fd(btrace, size, fd);
|
||||
abort();
|
||||
}
|
||||
|
||||
static int setup_signal_handler(void)
|
||||
{
|
||||
struct sigaction act;
|
||||
|
||||
act.sa_flags = SA_RESETHAND | SA_SIGINFO;
|
||||
act.sa_sigaction = report_segfault;
|
||||
sigfillset(&act.sa_mask);
|
||||
return sigaction(SIGSEGV, &act, NULL);
|
||||
}
|
||||
#else
|
||||
static int setup_signal_handler(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void locale_init(void)
|
||||
{
|
||||
setlocale(LC_CTYPE, "");
|
||||
|
|
|
@ -68,7 +68,7 @@ static void test_market_curse(CuTest * tc)
|
|||
b->flags |= BLD_MAINTAINED;
|
||||
b->size = b->type->maxsize;
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
u_set_building(u, b);
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ order * ord)
|
|||
UNUSED_ARG(amount);
|
||||
|
||||
/* Pruefen ob in Eingangshalle */
|
||||
if (u->region->x != 9525 || u->region->y != 9525) {
|
||||
if (warden == NULL || u->region->x != 9525 || u->region->y != 9525) {
|
||||
cmistake(u, ord, 266, MSG_MAGIC);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -974,7 +974,11 @@ void spawn_undead(void)
|
|||
{
|
||||
region *r;
|
||||
faction *monsters = get_monsters();
|
||||
int spawn_chance = config_get_int("monsters.spawn.chance", 100) * 100;
|
||||
|
||||
if (spawn_chance <= 0) {
|
||||
return;
|
||||
}
|
||||
for (r = regions; r; r = r->next) {
|
||||
int unburied = deathcount(r);
|
||||
|
||||
|
@ -985,7 +989,7 @@ void spawn_undead(void)
|
|||
}
|
||||
|
||||
if (r->land && unburied > rpeasants(r) / 20
|
||||
&& rng_int() % 10000 < 100) {
|
||||
&& rng_int() % spawn_chance < 100) {
|
||||
message *msg;
|
||||
unit *u;
|
||||
/* es ist sinnfrei, wenn irgendwo im Wald 3er-Einheiten Untote entstehen.
|
||||
|
|
|
@ -55,7 +55,7 @@ static void create_monsters(unit **up, unit **um) {
|
|||
"dragon:unit", "number:int", "target:region", "growl:string", MT_NEW_END);
|
||||
test_create_horse();
|
||||
default_locale = test_create_locale();
|
||||
fp = test_create_faction(NULL);
|
||||
fp = test_create_faction();
|
||||
|
||||
fm = get_or_create_monsters();
|
||||
fset(fm, FFL_NOIDLEOUT);
|
||||
|
@ -273,7 +273,7 @@ static void test_spawn_seaserpent(CuTest *tc) {
|
|||
rc = test_create_race("seaserpent");
|
||||
rc->flags &= ~RCF_PLAYABLE;
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = spawn_seaserpent(r, f);
|
||||
CuAssertPtrNotNull(tc, u);
|
||||
CuAssertPtrEquals(tc, NULL, u->_name);
|
||||
|
@ -287,7 +287,7 @@ static void test_monsters_hate(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
test_setup();
|
||||
tu = test_create_unit(test_create_faction(NULL), test_create_plain(1, 0));
|
||||
tu = test_create_unit(test_create_faction(), test_create_plain(1, 0));
|
||||
mu = test_create_unit(get_monsters(), test_create_plain(0, 0));
|
||||
lang = mu->faction->locale;
|
||||
a_add(&mu->attribs, make_hate(tu));
|
||||
|
|
43
src/move.c
43
src/move.c
|
@ -624,9 +624,6 @@ mark_travelthru(unit * u, region * r, const region_list * route,
|
|||
|
||||
void move_ship(ship * sh, region * from, region * to, region_list * route)
|
||||
{
|
||||
unit **iunit = &from->units;
|
||||
unit **ulist = &to->units;
|
||||
|
||||
assert(sh);
|
||||
if (from != to) {
|
||||
translist(&from->ships, &to->ships, sh);
|
||||
|
@ -636,25 +633,35 @@ void move_ship(ship * sh, region * from, region * to, region_list * route)
|
|||
leave_trail(sh, from, route);
|
||||
}
|
||||
|
||||
while (*iunit != NULL) {
|
||||
unit *u = *iunit;
|
||||
assert(u->region == from);
|
||||
if (route != NULL && from->units) {
|
||||
unit** iunit = &from->units;
|
||||
unit** ulist = &to->units;
|
||||
unit* ufirst = NULL;
|
||||
|
||||
if (u->ship == sh) {
|
||||
if (route != NULL)
|
||||
do {
|
||||
unit *u = *iunit;
|
||||
|
||||
if (u->ship == sh) {
|
||||
*iunit = u->next;
|
||||
if (!ufirst) {
|
||||
ufirst = u;
|
||||
}
|
||||
mark_travelthru(u, from, route, NULL);
|
||||
if (from != to) {
|
||||
u->ship = 0; /* temporary trick -- do not use u_set_ship here */
|
||||
u->ship = NULL; /* temporary trick -- do not use u_set_ship here */
|
||||
leave_region(u);
|
||||
u->region = NULL;
|
||||
u->next = NULL;
|
||||
move_unit(u, to, ulist);
|
||||
ulist = &u->next;
|
||||
u->ship = sh; /* undo the trick -- do not use u_set_ship here */
|
||||
if (effskill(u, SK_SAILING, from) >= 1) {
|
||||
produceexp(u, SK_SAILING, u->number);
|
||||
}
|
||||
}
|
||||
if (route && effskill(u, SK_SAILING, from) >= 1) {
|
||||
produceexp(u, SK_SAILING, u->number);
|
||||
else {
|
||||
iunit = &u->next;
|
||||
}
|
||||
}
|
||||
if (*iunit == u)
|
||||
iunit = &u->next;
|
||||
} while (*iunit && (ufirst == NULL || ufirst != *iunit));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1612,9 +1619,9 @@ static const region_list *travel_route(unit * u,
|
|||
/* Berichte ueber Durchreiseregionen */
|
||||
|
||||
if (mode != TRAVEL_TRANSPORTED) {
|
||||
arg_regions ar;
|
||||
arg_regions *arp = NULL;
|
||||
if (steps > 1) {
|
||||
arg_regions ar;
|
||||
arp = &ar;
|
||||
var_create_regions(arp, route_begin, steps - 1);
|
||||
}
|
||||
|
@ -2192,8 +2199,8 @@ void move_cmd_ex(unit * u, order * ord, const char *directions)
|
|||
init_order(ord, u->faction->locale);
|
||||
}
|
||||
if (u->ship && u == ship_owner(u->ship)) {
|
||||
bool drifting = (getkeyword(ord) == K_MOVE);
|
||||
sail(u, ord, drifting);
|
||||
keyword_t kwd = getkeyword(ord);
|
||||
sail(u, ord, (kwd == K_MOVE || kwd == K_ROUTE));
|
||||
}
|
||||
else {
|
||||
travel(u, ord);
|
||||
|
|
|
@ -86,7 +86,7 @@ static void setup_harbor(move_fixture *mf) {
|
|||
b = test_create_building(r, btype);
|
||||
b->flags |= BLD_MAINTAINED;
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
u->ship = sh;
|
||||
ship_set_owner(u);
|
||||
|
||||
|
@ -114,7 +114,7 @@ static void test_ship_blocked_by_harbormaster(CuTest * tc) {
|
|||
test_setup();
|
||||
setup_harbor(&mf);
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), mf.r);
|
||||
u = test_create_unit(test_create_faction(), mf.r);
|
||||
u->building = mf.b;
|
||||
building_set_owner(u);
|
||||
|
||||
|
@ -129,7 +129,7 @@ static void test_ship_has_harbormaster_contact(CuTest * tc) {
|
|||
test_setup();
|
||||
setup_harbor(&mf);
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), mf.r);
|
||||
u = test_create_unit(test_create_faction(), mf.r);
|
||||
u->building = mf.b;
|
||||
building_set_owner(u);
|
||||
contact_unit(mf.b->_owner, mf.sh->_owner);
|
||||
|
@ -160,7 +160,7 @@ static void test_ship_has_harbormaster_ally(CuTest * tc) {
|
|||
test_setup();
|
||||
setup_harbor(&mf);
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), mf.r);
|
||||
u = test_create_unit(test_create_faction(), mf.r);
|
||||
u->building = mf.b;
|
||||
building_set_owner(u);
|
||||
ally_set(&u->faction->allies, mf.u->faction, HELP_GUARD);
|
||||
|
@ -177,7 +177,7 @@ static void test_walkingcapacity(CuTest *tc) {
|
|||
test_setup();
|
||||
init_resources();
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
cap = u->number * (u->_race->capacity + u->_race->weight);
|
||||
CuAssertIntEquals(tc, cap, walkingcapacity(u));
|
||||
scale_number(u, 2);
|
||||
|
@ -282,7 +282,7 @@ void setup_drift (struct drift_fixture *fix) {
|
|||
fix->st_boat->cabins = 20000;
|
||||
|
||||
test_create_ocean(0, 0);
|
||||
fix->u = test_create_unit(fix->f = test_create_faction(NULL), fix->r = test_create_ocean(-1, 0));
|
||||
fix->u = test_create_unit(fix->f = test_create_faction(), fix->r = test_create_ocean(-1, 0));
|
||||
assert(fix->r && fix->u && fix->f);
|
||||
set_level(fix->u, SK_SAILING, fix->st_boat->sumskill);
|
||||
u_set_ship(fix->u, fix->sh = test_create_ship(fix->u->region, fix->st_boat));
|
||||
|
@ -455,10 +455,10 @@ static void test_follow_unit(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, test_create_plain(0, 0));
|
||||
r = test_create_plain(1, 0);
|
||||
u2 = test_create_unit(test_create_faction(NULL), u->region);
|
||||
u2 = test_create_unit(test_create_faction(), u->region);
|
||||
ord = create_order(K_MOVE, f->locale, shortdirections[D_EAST] + 4);
|
||||
unit_addorder(u2, ord);
|
||||
u2->thisorder = copy_order(ord);
|
||||
|
@ -492,7 +492,7 @@ static void test_follow_unit_self(CuTest *tc) {
|
|||
mt_create_va(mt_new("followfail", NULL),
|
||||
"unit:unit", "follower:unit", MT_NEW_END);
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, test_create_plain(0, 0));
|
||||
ord = create_order(K_FOLLOW, f->locale, "EINHEIT %s", itoa36(u->no));
|
||||
unit_addorder(u, ord);
|
||||
|
@ -523,7 +523,7 @@ static void test_follow_ship_msg(CuTest * tc) {
|
|||
test_setup();
|
||||
init_resources();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
test_create_ocean(-1, 1); /* D_NORTHWEST */
|
||||
|
||||
|
@ -619,7 +619,7 @@ static void test_movement_speed(CuTest *tc) {
|
|||
test_setup();
|
||||
it_horse = test_create_horse();
|
||||
rc = test_create_race(NULL);
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
|
||||
rc->speed = 1.0;
|
||||
CuAssertIntEquals(tc, BP_WALKING, movement_speed(u));
|
||||
|
@ -646,7 +646,7 @@ static void test_route_cycle(CuTest *tc) {
|
|||
r = test_create_region(2, 0, NULL);
|
||||
lang = test_create_locale();
|
||||
CuAssertPtrNotNull(tc, LOC(lang, shortdirections[D_WEST]));
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
u->faction->locale = lang;
|
||||
CuAssertIntEquals(tc, RCF_WALK, u->_race->flags & RCF_WALK);
|
||||
u->orders = create_order(K_ROUTE, u->faction->locale, "WEST EAST NW");
|
||||
|
@ -694,7 +694,7 @@ static void test_route_pause(CuTest *tc) {
|
|||
r = test_create_region(2, 0, NULL);
|
||||
lang = test_create_locale();
|
||||
CuAssertPtrNotNull(tc, LOC(lang, shortdirections[D_WEST]));
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
u->faction->locale = lang;
|
||||
CuAssertIntEquals(tc, RCF_WALK, u->_race->flags & RCF_WALK);
|
||||
u->orders = create_order(K_ROUTE, u->faction->locale, "PAUSE EAST NW");
|
||||
|
@ -713,7 +713,7 @@ static void test_movement_speed_dragon(CuTest *tc) {
|
|||
rc = test_create_race("dragon");
|
||||
rc->flags |= RCF_DRAGON;
|
||||
rc->speed = 1.5;
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
CuAssertIntEquals(tc, 6, movement_speed(u));
|
||||
test_teardown();
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ static void test_names(CuTest * tc)
|
|||
CuAssertPtrNotNull(tc, get_function("name_dracoid"));
|
||||
default_locale = test_create_locale();
|
||||
rc = test_create_race("undead");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, default_locale), test_create_region(0, 0, NULL));
|
||||
locale_setstring(default_locale, "undead_name_0", "Graue");
|
||||
locale_setstring(default_locale, "undead_postfix_0", "Kobolde");
|
||||
CuAssertPtrNotNull(tc, rc->name_unit);
|
||||
|
@ -44,11 +44,11 @@ static void test_monster_names(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
register_names();
|
||||
default_locale = test_create_locale();
|
||||
default_locale = get_or_create_locale(__FUNCTION__);
|
||||
locale_setstring(default_locale, "race::irongolem", "Eisengolem");
|
||||
locale_setstring(default_locale, "race::irongolem_p", "Eisengolems");
|
||||
rc = test_create_race("irongolem");
|
||||
f = test_create_faction(rc);
|
||||
f = test_create_faction_ex(rc, default_locale);
|
||||
f->flags |= FFL_NPC;
|
||||
u = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
unit_setname(u, "Hodor");
|
||||
|
|
|
@ -159,7 +159,7 @@ int parseorders(FILE *F)
|
|||
OP_SetUserData(parser, &state);
|
||||
|
||||
while (!done) {
|
||||
size_t len = (int)fread(buf, 1, sizeof(buf), F);
|
||||
int len = (int)fread(buf, 1, sizeof(buf), F);
|
||||
if (ferror(F)) {
|
||||
/* TODO: error message */
|
||||
err = errno;
|
||||
|
|
|
@ -27,7 +27,7 @@ static void test_unit_orders(CuTest *tc) {
|
|||
FILE *F = tmpfile();
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_plain(0, 0));
|
||||
f->locale = test_create_locale();
|
||||
u->orders = create_order(K_ENTERTAIN, f->locale, NULL);
|
||||
faction_setpassword(f, password_hash("password", PASSWORD_DEFAULT));
|
||||
|
@ -53,7 +53,7 @@ static void test_faction_password_okay(CuTest *tc) {
|
|||
FILE *F;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
renumber_faction(f, 1);
|
||||
CuAssertIntEquals(tc, 1, f->no);
|
||||
faction_setpassword(f, "password");
|
||||
|
@ -74,7 +74,7 @@ static void test_faction_password_bad(CuTest *tc) {
|
|||
test_setup();
|
||||
mt_create_va(mt_new("wrongpasswd", NULL), "password:string", MT_NEW_END);
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
renumber_faction(f, 1);
|
||||
CuAssertIntEquals(tc, 1, f->no);
|
||||
faction_setpassword(f, "patzword");
|
||||
|
|
|
@ -56,7 +56,7 @@ static void setup_pirate(unit **pirate, int p_r_flags, int p_rc_flags, const cha
|
|||
setup_piracy();
|
||||
vterrain = get_or_create_terrain("terrain1");
|
||||
fset(vterrain, v_r_flags);
|
||||
*victim = test_create_unit(test_create_faction(NULL), test_create_region(1, 0, vterrain));
|
||||
*victim = test_create_unit(test_create_faction(), test_create_region(1, 0, vterrain));
|
||||
assert(*victim);
|
||||
|
||||
if (v_shiptype) {
|
||||
|
@ -68,7 +68,7 @@ static void setup_pirate(unit **pirate, int p_r_flags, int p_rc_flags, const cha
|
|||
st_boat->coasts[1] = 0;
|
||||
}
|
||||
|
||||
*pirate = create_unit(test_create_region(0, 0, get_or_create_terrain("terrain2")), f = test_create_faction(NULL), 1, rc = rc_get_or_create("pirate"), 0, 0, 0);
|
||||
*pirate = create_unit(test_create_region(0, 0, get_or_create_terrain("terrain2")), f = test_create_faction(), 1, rc = rc_get_or_create("pirate"), 0, 0, 0);
|
||||
fset(rc, p_rc_flags);
|
||||
assert(f && *pirate);
|
||||
|
||||
|
@ -97,10 +97,10 @@ static void test_piracy_cmd(CuTest * tc) {
|
|||
|
||||
t_ocean = get_or_create_terrain("ocean");
|
||||
st_boat = st_get_or_create("boat");
|
||||
u2 = test_create_unit(test_create_faction(NULL), test_create_region(1, 0, t_ocean));
|
||||
u2 = test_create_unit(test_create_faction(), test_create_region(1, 0, t_ocean));
|
||||
assert(u2);
|
||||
u_set_ship(u2, test_create_ship(u2->region, st_boat));
|
||||
u = test_create_unit(f = test_create_faction(NULL), r = test_create_region(0, 0, t_ocean));
|
||||
u = test_create_unit(f = test_create_faction(), r = test_create_region(0, 0, t_ocean));
|
||||
assert(f && u);
|
||||
set_level(u, SK_SAILING, st_boat->sumskill);
|
||||
u_set_ship(u, test_create_ship(u->region, st_boat));
|
||||
|
@ -130,8 +130,7 @@ static void test_piracy_cmd_errors(CuTest * tc) {
|
|||
|
||||
st_boat = st_get_or_create("boat");
|
||||
r = test_create_race("pirates");
|
||||
u = test_create_unit(f = test_create_faction(r), test_create_region(0, 0, get_or_create_terrain("ocean")));
|
||||
f->locale = test_create_locale();
|
||||
u = test_create_unit(f = test_create_faction_ex(r, NULL), test_create_region(0, 0, get_or_create_terrain("ocean")));
|
||||
u->thisorder = create_order(K_PIRACY, f->locale, "");
|
||||
assert(u && u->thisorder);
|
||||
|
||||
|
@ -199,14 +198,14 @@ static void test_piracy_cmd_land_to_land(CuTest * tc) {
|
|||
|
||||
/* create a target: */
|
||||
r = test_create_region(0, 0, t_plain);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
u->ship = test_create_ship(r, stype);
|
||||
target = f->no;
|
||||
|
||||
/* create a pirate: */
|
||||
r = test_create_region(1, 0, t_plain);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
u->ship = test_create_ship(r, stype);
|
||||
set_level(u, SK_SAILING, u->ship->type->sumskill);
|
||||
|
|
|
@ -28,7 +28,7 @@ static void test_renumber_faction(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
no = u->faction->no;
|
||||
uno = (no > 1) ? no - 1 : no + 1;
|
||||
lang = u->faction->locale;
|
||||
|
@ -47,8 +47,8 @@ static void test_renumber_faction_duplicate(CuTest *tc) {
|
|||
|
||||
setup_renumber(tc);
|
||||
mt_create_va(mt_new("renumber_inuse", NULL), "id:int", MT_NEW_END);
|
||||
f2 = test_create_faction(NULL);
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
f2 = test_create_faction();
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
no = f->no;
|
||||
lang = f->locale;
|
||||
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_FACTION]), itoa36(f2->no));
|
||||
|
@ -66,7 +66,7 @@ static void test_renumber_faction_invalid(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, 0));
|
||||
no = f->no;
|
||||
lang = f->locale;
|
||||
u->thisorder = create_order(K_NUMBER, lang, "%s [halima]", LOC(lang, parameters[P_FACTION]));
|
||||
|
@ -96,7 +96,7 @@ static void test_renumber_building(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->building = test_create_building(u->region, NULL);
|
||||
no = u->building->no;
|
||||
uno = (no > 1) ? no - 1 : no + 1;
|
||||
|
@ -119,7 +119,7 @@ static void test_renumber_building_duplicate(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->building = test_create_building(u->region, NULL);
|
||||
uno = u->building->no;
|
||||
u->building = test_create_building(u->region, NULL);
|
||||
|
@ -138,7 +138,7 @@ static void test_renumber_ship(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->ship = test_create_ship(u->region, NULL);
|
||||
no = u->ship->no;
|
||||
uno = (no > 1) ? no - 1 : no + 1;
|
||||
|
@ -155,7 +155,7 @@ static void test_renumber_ship_twice(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->ship = test_create_ship(u->region, NULL);
|
||||
no = u->ship->no;
|
||||
uno = (no > 1) ? no - 1 : no + 1;
|
||||
|
@ -177,7 +177,7 @@ static void test_renumber_ship_duplicate(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->ship = test_create_ship(u->region, NULL);
|
||||
uno = u->ship->no;
|
||||
u->ship = test_create_ship(u->region, NULL);
|
||||
|
@ -196,7 +196,7 @@ static void test_renumber_unit(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
no = u->no;
|
||||
uno = (no > 1) ? no - 1 : no + 1;
|
||||
lang = u->faction->locale;
|
||||
|
@ -214,7 +214,7 @@ static void test_renumber_unit_duplicate(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
no = u->no;
|
||||
u2 = test_create_unit(f, u->region);
|
||||
lang = f->locale;
|
||||
|
@ -233,7 +233,7 @@ static void test_renumber_unit_limit(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
no = u->no;
|
||||
lang = f->locale;
|
||||
u->thisorder = create_order(K_NUMBER, lang, "%s 10000", LOC(lang, parameters[P_UNIT]));
|
||||
|
@ -251,7 +251,7 @@ static void test_renumber_unit_invalid(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
no = u->no;
|
||||
lang = f->locale;
|
||||
u->thisorder = create_order(K_NUMBER, lang, "%s TEMP", LOC(lang, parameters[P_UNIT]));
|
||||
|
|
|
@ -1182,11 +1182,13 @@ static void report_statistics(struct stream *out, const region * r, const factio
|
|||
if (max_production(r) && (!fval(r->terrain, SEA_REGION)
|
||||
|| f->race == get_race(RC_AQUARIAN))) {
|
||||
if (markets_module()) { /* hack */
|
||||
bool mourn = is_mourning(r, turn);
|
||||
int p_wage = peasant_wage(r, mourn);
|
||||
m =
|
||||
msg_message("nr_stat_salary_new", "max", wage(r, NULL, NULL, turn + 1));
|
||||
msg_message("nr_stat_salary_new", "max", p_wage);
|
||||
}
|
||||
else {
|
||||
m = msg_message("nr_stat_salary", "max", wage(r, f, f->race, turn + 1));
|
||||
m = msg_message("nr_stat_salary", "max", wage(r, f->race));
|
||||
}
|
||||
nr_render(m, f->locale, buf, sizeof(buf), f);
|
||||
paragraph(out, buf, 2, 2, 0);
|
||||
|
@ -1337,7 +1339,7 @@ report_template(const char *filename, report_context * ctx, const char *bom)
|
|||
}
|
||||
rps_nowrap(out, buf);
|
||||
newline(out);
|
||||
sprintf(buf, "; ECheck Lohn %d", wage(r, f, f->race, turn + 1));
|
||||
sprintf(buf, "; ECheck Lohn %d", wage(r, f->race));
|
||||
rps_nowrap(out, buf);
|
||||
newline(out);
|
||||
newline(out);
|
||||
|
|
|
@ -106,8 +106,7 @@ static void test_report_region(CuTest *tc) {
|
|||
rsettrees(r, 0, 1);
|
||||
rsettrees(r, 1, 2);
|
||||
rsettrees(r, 2, 3);
|
||||
f = test_create_faction(NULL);
|
||||
f->locale = lang;
|
||||
f = test_create_faction_ex(NULL, lang);
|
||||
u = test_create_unit(f, r);
|
||||
set_level(u, SK_QUARRYING, 1);
|
||||
|
||||
|
@ -187,11 +186,10 @@ static void test_report_allies(CuTest *tc) {
|
|||
lang = test_create_locale();
|
||||
locale_setstring(lang, "list_and", " und ");
|
||||
mstream_init(&out);
|
||||
f = test_create_faction(NULL);
|
||||
f->locale = lang;
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f3 = test_create_faction(NULL);
|
||||
f = test_create_faction_ex(NULL, lang);
|
||||
f1 = test_create_faction_ex(NULL, lang);
|
||||
f2 = test_create_faction_ex(NULL, lang);
|
||||
f3 = test_create_faction_ex(NULL, lang);
|
||||
snprintf(exp, sizeof(exp), "Wir helfen %s (%s).\n\n",
|
||||
factionname(f1),
|
||||
LOC(lang, parameters[P_GUARD]));
|
||||
|
@ -242,7 +240,7 @@ static void test_report_travelthru(CuTest *tc) {
|
|||
mstream_init(&out);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
r->flags |= RF_TRAVELUNIT;
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f->locale = lang;
|
||||
u = test_create_unit(f, test_create_region(0, 1, NULL));
|
||||
unit_setname(u, "Hodor");
|
||||
|
@ -282,7 +280,7 @@ typedef struct {
|
|||
} spell_fixture;
|
||||
|
||||
static void setup_spell_fixture(spell_fixture * spf) {
|
||||
spf->lang = test_create_locale();
|
||||
spf->lang = get_or_create_locale(__FUNCTION__);
|
||||
locale_setstring(spf->lang, mkname("spell", "testspell"), "Testzauber");
|
||||
locale_setstring(spf->lang, "nr_spell_type", "Typ:");
|
||||
locale_setstring(spf->lang, "sptype_normal", "Normal");
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue