diff --git a/conf/e2/config.json b/conf/e2/config.json index 5d29cd1f5..6450e9d54 100644 --- a/conf/e2/config.json +++ b/conf/e2/config.json @@ -1,9 +1,27 @@ { "include": [ - "keywords.json", - "calendar.json", - "prefixes.json", - "e2/terrains.json" + "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://conf/e2/rules.xml", + "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/familiars.xml", + "config://res/eressea/equipment.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" diff --git a/conf/e2/items.json b/conf/e2/items.json new file mode 100644 index 000000000..643248d32 --- /dev/null +++ b/conf/e2/items.json @@ -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" + ] +} diff --git a/conf/e2/locales.json b/conf/e2/locales.json new file mode 100644 index 000000000..4a3a100ef --- /dev/null +++ b/conf/e2/locales.json @@ -0,0 +1,14 @@ +{ + "include": [ + "config://res/core/messages.xml", + "config://res/core/de/strings.xml", + "config://res/core/en/strings.xml", + "config://res/eressea/strings.xml", + "config://res/eressea/spellinfo.xml", + "config://res/names-undead.xml", + "config://res/names-skeletons.xml", + "config://res/names-zombies.xml", + "config://res/names-ghouls.xml", + "config://res/names-dragons.xml" + ] +} diff --git a/conf/e2/locales.xml b/conf/e2/locales.xml deleted file mode 100644 index 7a31bbc17..000000000 --- a/conf/e2/locales.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/conf/e2/rules.xml b/conf/e2/rules.xml index 22ff8109f..9e40910e0 100644 --- a/conf/e2/rules.xml +++ b/conf/e2/rules.xml @@ -1,24 +1,6 @@ - + - - - - - - - - - - - - - - - - - - diff --git a/conf/e3/config.json b/conf/e3/config.json index f3bddfdc0..528d0a7f2 100644 --- a/conf/e3/config.json +++ b/conf/e3/config.json @@ -1,9 +1,25 @@ { "include": [ - "keywords.json", - "calendar.json", - "prefixes.json", - "e3/terrains.json" + "config://conf/keywords.json", + "config://conf/calendar.json", + "config://conf/prefixes.json", + "config://conf/e3/locales.json", + "config://conf/e3/terrains.json", + "config://conf/e3/items.json", + "config://conf/e3/races.json", + "config://res/e3a/familiars.xml", + "config://res/e3a/equipment.xml", + "config://res/e3a/ships.xml", + "config://res/e3a/buildings.xml", + "config://res/e3a/spells.xml", + "config://res/e3a/spellbooks/gray.xml", + "config://res/e3a/spellbooks/gwyrrd.xml", + "config://res/e3a/spellbooks/draig.xml", + "config://res/e3a/spellbooks/illaun.xml", + "config://res/e3a/spellbooks/cerddor.xml", + "config://res/e3a/spellbooks/common.xml", + "config://res/core/common/buildings.xml", + "config://res/buildings/castle-2.xml" ], "disabled": [ "herbalism", diff --git a/conf/e3/items.json b/conf/e3/items.json new file mode 100644 index 000000000..071bec4e6 --- /dev/null +++ b/conf/e3/items.json @@ -0,0 +1,29 @@ +{ + "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/resources/cart.xml", + "config://res/core/resources/horse.xml", + "config://res/core/resources/hp.xml", + "config://res/core/resources/laen.xml", + "config://res/core/resources/log.xml", + "config://res/core/resources/mallorn.xml", + "config://res/core/resources/peasant.xml", + "config://res/core/weapons/bow.xml", + "config://res/core/weapons/catapult.xml", + "config://res/core/weapons/mallornbow.xml", + "config://res/core/weapons/mallornspear.xml", + "config://res/core/weapons/runesword.xml", + "config://res/core/weapons/rustyaxe.xml", + "config://res/core/weapons/rustysword.xml", + "config://res/core/weapons/spear.xml", + "config://res/core/weapons/sword.xml", + "config://res/core/weapons/firesword.xml", + "config://res/e3a/weapons.xml", + "config://res/e3a/armor.xml", + "config://res/e3a/items.xml", + "config://res/adamantium.xml" + ] +} diff --git a/conf/e3/locales.json b/conf/e3/locales.json new file mode 100644 index 000000000..af43ccaed --- /dev/null +++ b/conf/e3/locales.json @@ -0,0 +1,14 @@ +{ + "include": [ + "config://res/core/messages.xml", + "config://res/core/de/strings.xml", + "config://res/core/en/strings.xml", + "config://res/e3a/strings.xml", + "config://res/e3a/shipnames.xml", + "config://res/names-undead.xml", + "config://res/names-skeletons.xml", + "config://res/names-zombies.xml", + "config://res/names-ghouls.xml", + "config://res/names-dragons.xml" + ] +} diff --git a/conf/e3/locales.xml b/conf/e3/locales.xml deleted file mode 100644 index bb7245fa3..000000000 --- a/conf/e3/locales.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/conf/e3/races.json b/conf/e3/races.json new file mode 100644 index 000000000..1ac473f49 --- /dev/null +++ b/conf/e3/races.json @@ -0,0 +1,9 @@ +{ + "include": [ + "config://res/races/goblin-3.xml", + "config://res/races/wyrm.xml", + "config://res/races/dragon.xml", + "config://res/races/youngdragon.xml", + "config://res/e3a/races.xml" + ] +} diff --git a/conf/e3/rules.xml b/conf/e3/rules.xml deleted file mode 100644 index 7fbf7dc6e..000000000 --- a/conf/e3/rules.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/res/adamantium.xml b/res/adamantium.xml index e1f0643e2..563299e51 100644 --- a/res/adamantium.xml +++ b/res/adamantium.xml @@ -1,4 +1,5 @@ + @@ -32,3 +33,4 @@ + diff --git a/res/buildings/castle-2.xml b/res/buildings/castle-2.xml index accb92c08..a22cb50f3 100644 --- a/res/buildings/castle-2.xml +++ b/res/buildings/castle-2.xml @@ -1,4 +1,6 @@ + + @@ -19,3 +21,5 @@ + + diff --git a/res/buildings/castle.xml b/res/buildings/castle.xml index ce64e8030..14d959ed7 100644 --- a/res/buildings/castle.xml +++ b/res/buildings/castle.xml @@ -1,4 +1,6 @@ + + @@ -22,3 +24,5 @@ + + diff --git a/res/core/armor/chainmail.xml b/res/core/armor/chainmail.xml index b03221b35..048a94ae9 100644 --- a/res/core/armor/chainmail.xml +++ b/res/core/armor/chainmail.xml @@ -1,4 +1,5 @@ + @@ -7,3 +8,4 @@ + diff --git a/res/core/armor/laenmail.xml b/res/core/armor/laenmail.xml index 0e1411945..f26e5363b 100644 --- a/res/core/armor/laenmail.xml +++ b/res/core/armor/laenmail.xml @@ -1,4 +1,5 @@ + @@ -7,3 +8,4 @@ + diff --git a/res/core/armor/laenshield.xml b/res/core/armor/laenshield.xml index 8a9d6d5c3..03f9f479a 100644 --- a/res/core/armor/laenshield.xml +++ b/res/core/armor/laenshield.xml @@ -1,4 +1,5 @@ + @@ -7,3 +8,4 @@ + diff --git a/res/core/armor/plate.xml b/res/core/armor/plate.xml index 97d855a73..f43a704b8 100644 --- a/res/core/armor/plate.xml +++ b/res/core/armor/plate.xml @@ -1,4 +1,5 @@ + @@ -7,3 +8,4 @@ + diff --git a/res/core/armor/rustychainmail.xml b/res/core/armor/rustychainmail.xml index b46380634..f7947bbb1 100644 --- a/res/core/armor/rustychainmail.xml +++ b/res/core/armor/rustychainmail.xml @@ -1,4 +1,5 @@ + @@ -7,4 +8,4 @@ - + diff --git a/res/core/armor/rustyshield.xml b/res/core/armor/rustyshield.xml index 56a8abe5a..218b4fa6a 100644 --- a/res/core/armor/rustyshield.xml +++ b/res/core/armor/rustyshield.xml @@ -1,4 +1,5 @@ + @@ -7,3 +8,4 @@ + diff --git a/res/core/armor/shield.xml b/res/core/armor/shield.xml index b0ee7de3a..af099dc2e 100644 --- a/res/core/armor/shield.xml +++ b/res/core/armor/shield.xml @@ -1,4 +1,5 @@ + @@ -7,3 +8,4 @@ + diff --git a/res/core/common/armor.xml b/res/core/common/armor.xml deleted file mode 100644 index 58abae47f..000000000 --- a/res/core/common/armor.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/res/core/common/buildings.xml b/res/core/common/buildings.xml index 932326f1c..3b8719b3b 100644 --- a/res/core/common/buildings.xml +++ b/res/core/common/buildings.xml @@ -1,4 +1,5 @@ + @@ -167,4 +168,4 @@ - + diff --git a/res/core/common/construction.xml b/res/core/common/construction.xml deleted file mode 100644 index 089ddfe1c..000000000 --- a/res/core/common/construction.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/res/core/common/herbs.xml b/res/core/common/herbs.xml index d7d0ef2e6..9175b4a42 100644 --- a/res/core/common/herbs.xml +++ b/res/core/common/herbs.xml @@ -1,4 +1,5 @@  + @@ -87,3 +88,4 @@ + diff --git a/res/core/common/items.xml b/res/core/common/items.xml index 564e9fafd..d04b6a252 100644 --- a/res/core/common/items.xml +++ b/res/core/common/items.xml @@ -1,4 +1,5 @@ + @@ -133,3 +134,4 @@ + diff --git a/res/core/common/luxuries.xml b/res/core/common/luxuries.xml index bdf9c110b..05e125b33 100644 --- a/res/core/common/luxuries.xml +++ b/res/core/common/luxuries.xml @@ -1,4 +1,5 @@ + @@ -24,3 +25,4 @@ + diff --git a/res/core/common/potions.xml b/res/core/common/potions.xml index 4812727dd..bb4556eb7 100644 --- a/res/core/common/potions.xml +++ b/res/core/common/potions.xml @@ -1,4 +1,5 @@ + @@ -180,3 +181,4 @@ + diff --git a/res/core/common/resources.xml b/res/core/common/resources.xml deleted file mode 100644 index 91d0e8afc..000000000 --- a/res/core/common/resources.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/res/core/common/weapons.xml b/res/core/common/weapons.xml deleted file mode 100644 index e91b15e69..000000000 --- a/res/core/common/weapons.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index 6801cbb35..896a7e009 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -1,4 +1,5 @@ + diff --git a/res/core/spoils.xml b/res/core/spoils.xml index 952971cab..8cd39a455 100644 --- a/res/core/spoils.xml +++ b/res/core/spoils.xml @@ -1,4 +1,5 @@ + @@ -57,3 +58,4 @@ + diff --git a/res/core/weapons/axe.xml b/res/core/weapons/axe.xml index 3f97a5b8a..07f511a62 100644 --- a/res/core/weapons/axe.xml +++ b/res/core/weapons/axe.xml @@ -1,4 +1,6 @@ + + @@ -11,3 +13,5 @@ + + diff --git a/res/core/weapons/bow.xml b/res/core/weapons/bow.xml index 4fb9b2000..a62f90b58 100644 --- a/res/core/weapons/bow.xml +++ b/res/core/weapons/bow.xml @@ -1,4 +1,6 @@ + + @@ -11,3 +13,5 @@ + + diff --git a/res/core/weapons/catapult.xml b/res/core/weapons/catapult.xml index e05c5a025..6312dd4d6 100644 --- a/res/core/weapons/catapult.xml +++ b/res/core/weapons/catapult.xml @@ -1,4 +1,6 @@ + + @@ -12,3 +14,5 @@ + + diff --git a/res/core/weapons/crossbow.xml b/res/core/weapons/crossbow.xml index c7bf4715d..c048e3dcd 100644 --- a/res/core/weapons/crossbow.xml +++ b/res/core/weapons/crossbow.xml @@ -1,4 +1,6 @@ + + @@ -11,3 +13,5 @@ + + diff --git a/res/core/weapons/firesword.xml b/res/core/weapons/firesword.xml index d716e6013..dc3b47af5 100644 --- a/res/core/weapons/firesword.xml +++ b/res/core/weapons/firesword.xml @@ -1,4 +1,6 @@ + + @@ -8,3 +10,5 @@ + + diff --git a/res/core/weapons/greatbow.xml b/res/core/weapons/greatbow.xml index 452ac0250..b30cae8c6 100644 --- a/res/core/weapons/greatbow.xml +++ b/res/core/weapons/greatbow.xml @@ -1,4 +1,6 @@ + + @@ -15,3 +17,5 @@ + + diff --git a/res/core/weapons/greatsword.xml b/res/core/weapons/greatsword.xml index 56285f6af..af2420700 100644 --- a/res/core/weapons/greatsword.xml +++ b/res/core/weapons/greatsword.xml @@ -1,4 +1,6 @@ + + @@ -10,3 +12,5 @@ + + diff --git a/res/core/weapons/halberd.xml b/res/core/weapons/halberd.xml index 7abc86902..8475d53e1 100644 --- a/res/core/weapons/halberd.xml +++ b/res/core/weapons/halberd.xml @@ -1,4 +1,6 @@ + + @@ -12,3 +14,5 @@ + + diff --git a/res/core/weapons/laensword.xml b/res/core/weapons/laensword.xml index 3053d5f1b..325d25d10 100644 --- a/res/core/weapons/laensword.xml +++ b/res/core/weapons/laensword.xml @@ -1,4 +1,6 @@ + + @@ -10,3 +12,5 @@ + + diff --git a/res/core/weapons/lance.xml b/res/core/weapons/lance.xml index 4a02bc06f..9325494fa 100644 --- a/res/core/weapons/lance.xml +++ b/res/core/weapons/lance.xml @@ -1,4 +1,6 @@ + + @@ -10,3 +12,5 @@ + + diff --git a/res/core/weapons/mallornbow.xml b/res/core/weapons/mallornbow.xml index abdcc4810..9164d2c4b 100644 --- a/res/core/weapons/mallornbow.xml +++ b/res/core/weapons/mallornbow.xml @@ -1,4 +1,6 @@ + + @@ -14,3 +16,5 @@ + + diff --git a/res/core/weapons/mallorncrossbow.xml b/res/core/weapons/mallorncrossbow.xml index 385720d8c..e5ec685c0 100644 --- a/res/core/weapons/mallorncrossbow.xml +++ b/res/core/weapons/mallorncrossbow.xml @@ -1,4 +1,6 @@ + + @@ -11,3 +13,5 @@ + + diff --git a/res/core/weapons/mallornlance.xml b/res/core/weapons/mallornlance.xml index 4024d4578..952839fda 100644 --- a/res/core/weapons/mallornlance.xml +++ b/res/core/weapons/mallornlance.xml @@ -1,4 +1,6 @@ + + @@ -10,3 +12,5 @@ + + diff --git a/res/core/weapons/mallornspear.xml b/res/core/weapons/mallornspear.xml index 516f59540..ee827c754 100644 --- a/res/core/weapons/mallornspear.xml +++ b/res/core/weapons/mallornspear.xml @@ -1,4 +1,6 @@ + + @@ -12,3 +14,5 @@ + + diff --git a/res/core/weapons/runesword.xml b/res/core/weapons/runesword.xml index 1bfae2544..6f23697f2 100644 --- a/res/core/weapons/runesword.xml +++ b/res/core/weapons/runesword.xml @@ -1,4 +1,6 @@ + + @@ -8,3 +10,5 @@ + + diff --git a/res/core/weapons/rustyaxe.xml b/res/core/weapons/rustyaxe.xml index fea6b8642..ff4172059 100644 --- a/res/core/weapons/rustyaxe.xml +++ b/res/core/weapons/rustyaxe.xml @@ -1,4 +1,6 @@ + + @@ -11,3 +13,5 @@ + + diff --git a/res/core/weapons/rustygreatsword.xml b/res/core/weapons/rustygreatsword.xml index 7f21cce17..b67e2cf4b 100644 --- a/res/core/weapons/rustygreatsword.xml +++ b/res/core/weapons/rustygreatsword.xml @@ -1,4 +1,6 @@ + + @@ -10,3 +12,5 @@ + + diff --git a/res/core/weapons/rustyhalberd.xml b/res/core/weapons/rustyhalberd.xml index 3f0bd93b7..9d3c4ae6b 100644 --- a/res/core/weapons/rustyhalberd.xml +++ b/res/core/weapons/rustyhalberd.xml @@ -1,4 +1,6 @@ + + @@ -12,3 +14,5 @@ + + diff --git a/res/core/weapons/rustysword.xml b/res/core/weapons/rustysword.xml index 2a76c109b..e5c9a9442 100644 --- a/res/core/weapons/rustysword.xml +++ b/res/core/weapons/rustysword.xml @@ -1,4 +1,6 @@ + + @@ -10,3 +12,5 @@ + + diff --git a/res/core/weapons/spear.xml b/res/core/weapons/spear.xml index 32a79b9a2..e81f608ab 100644 --- a/res/core/weapons/spear.xml +++ b/res/core/weapons/spear.xml @@ -1,4 +1,6 @@ + + @@ -12,3 +14,5 @@ + + diff --git a/res/core/weapons/sword.xml b/res/core/weapons/sword.xml index 4bd2ebdb1..21b481079 100644 --- a/res/core/weapons/sword.xml +++ b/res/core/weapons/sword.xml @@ -1,4 +1,6 @@ + + @@ -10,3 +12,5 @@ + + diff --git a/res/e3a/armor.xml b/res/e3a/armor.xml index fe1d7fb45..d0d5138ef 100644 --- a/res/e3a/armor.xml +++ b/res/e3a/armor.xml @@ -1,12 +1,83 @@ - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/e3a/armor/chainmail.xml b/res/e3a/armor/chainmail.xml deleted file mode 100644 index 509df07e6..000000000 --- a/res/e3a/armor/chainmail.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/res/e3a/armor/laenmail.xml b/res/e3a/armor/laenmail.xml deleted file mode 100644 index f03add574..000000000 --- a/res/e3a/armor/laenmail.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/res/e3a/armor/laenshield.xml b/res/e3a/armor/laenshield.xml deleted file mode 100644 index 8d003bccc..000000000 --- a/res/e3a/armor/laenshield.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/res/e3a/armor/plate.xml b/res/e3a/armor/plate.xml deleted file mode 100644 index 79391fbcb..000000000 --- a/res/e3a/armor/plate.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/res/e3a/armor/rustychainmail.xml b/res/e3a/armor/rustychainmail.xml deleted file mode 100644 index 361564c76..000000000 --- a/res/e3a/armor/rustychainmail.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/res/e3a/armor/rustyshield.xml b/res/e3a/armor/rustyshield.xml deleted file mode 100644 index d9d8a54ef..000000000 --- a/res/e3a/armor/rustyshield.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/res/e3a/armor/scale.xml b/res/e3a/armor/scale.xml deleted file mode 100644 index 4d3e38e8a..000000000 --- a/res/e3a/armor/scale.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/res/e3a/armor/shield.xml b/res/e3a/armor/shield.xml deleted file mode 100644 index 5770711e2..000000000 --- a/res/e3a/armor/shield.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/res/e3a/armor/towershield.xml b/res/e3a/armor/towershield.xml deleted file mode 100644 index aebbfc682..000000000 --- a/res/e3a/armor/towershield.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/res/e3a/buildings.xml b/res/e3a/buildings.xml index 069a24150..6d3db765e 100644 --- a/res/e3a/buildings.xml +++ b/res/e3a/buildings.xml @@ -1,7 +1,6 @@ - - - + + @@ -24,4 +23,4 @@ - + diff --git a/res/e3a/equipment.xml b/res/e3a/equipment.xml index 62123766a..d8c529d8a 100644 --- a/res/e3a/equipment.xml +++ b/res/e3a/equipment.xml @@ -1,4 +1,5 @@ + @@ -7,3 +8,4 @@ + diff --git a/res/e3a/familiars.xml b/res/e3a/familiars.xml index 4a9fad6c8..b30c733ed 100644 --- a/res/e3a/familiars.xml +++ b/res/e3a/familiars.xml @@ -1,4 +1,5 @@ + @@ -101,4 +102,4 @@ - + diff --git a/res/e3a/items.xml b/res/e3a/items.xml index 0399043e5..1d403cfb4 100644 --- a/res/e3a/items.xml +++ b/res/e3a/items.xml @@ -1,6 +1,32 @@  + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -76,3 +102,4 @@ + diff --git a/res/e3a/races.xml b/res/e3a/races.xml index ce0ce336a..feefb0ded 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -1,13 +1,9 @@ - + + - - - - - @@ -846,3 +842,4 @@ + diff --git a/res/e3a/resources.xml b/res/e3a/resources.xml deleted file mode 100644 index 32a79d52e..000000000 --- a/res/e3a/resources.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/res/e3a/resources/iron.xml b/res/e3a/resources/iron.xml deleted file mode 100644 index 55f63ca67..000000000 --- a/res/e3a/resources/iron.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/res/e3a/resources/mallornseed.xml b/res/e3a/resources/mallornseed.xml deleted file mode 100644 index 576035b34..000000000 --- a/res/e3a/resources/mallornseed.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/res/e3a/resources/seed.xml b/res/e3a/resources/seed.xml deleted file mode 100644 index 62c971540..000000000 --- a/res/e3a/resources/seed.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/res/e3a/resources/stone.xml b/res/e3a/resources/stone.xml deleted file mode 100644 index d8fd08573..000000000 --- a/res/e3a/resources/stone.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/res/e3a/shipnames.xml b/res/e3a/shipnames.xml index 15e261ef0..6d5c46b05 100644 --- a/res/e3a/shipnames.xml +++ b/res/e3a/shipnames.xml @@ -1,4 +1,5 @@  + ein Einbaum @@ -106,3 +107,4 @@ trireme + diff --git a/res/e3a/ships.xml b/res/e3a/ships.xml index 291900a3b..454c99169 100644 --- a/res/e3a/ships.xml +++ b/res/e3a/ships.xml @@ -1,4 +1,5 @@ + @@ -143,4 +144,4 @@ - + diff --git a/res/e3a/spellbooks/cerddor.xml b/res/e3a/spellbooks/cerddor.xml index 9b6e4cd8e..9e1a3f835 100644 --- a/res/e3a/spellbooks/cerddor.xml +++ b/res/e3a/spellbooks/cerddor.xml @@ -1,4 +1,5 @@ + @@ -35,3 +36,4 @@ + diff --git a/res/e3a/spellbooks/common.xml b/res/e3a/spellbooks/common.xml index 688a1b9ae..92f54e1d1 100644 --- a/res/e3a/spellbooks/common.xml +++ b/res/e3a/spellbooks/common.xml @@ -1,4 +1,5 @@ + @@ -42,3 +43,4 @@ + diff --git a/res/e3a/spellbooks/draig.xml b/res/e3a/spellbooks/draig.xml index d97a695b3..a0da7b449 100644 --- a/res/e3a/spellbooks/draig.xml +++ b/res/e3a/spellbooks/draig.xml @@ -1,4 +1,5 @@ + @@ -31,3 +32,4 @@ + diff --git a/res/e3a/spellbooks/gray.xml b/res/e3a/spellbooks/gray.xml index 78645f907..a807963c2 100644 --- a/res/e3a/spellbooks/gray.xml +++ b/res/e3a/spellbooks/gray.xml @@ -1,4 +1,5 @@ + @@ -142,3 +143,4 @@ + diff --git a/res/e3a/spellbooks/gwyrrd.xml b/res/e3a/spellbooks/gwyrrd.xml index 452100ace..83fd4e99c 100644 --- a/res/e3a/spellbooks/gwyrrd.xml +++ b/res/e3a/spellbooks/gwyrrd.xml @@ -1,4 +1,5 @@ + @@ -32,3 +33,4 @@ + diff --git a/res/e3a/spellbooks/illaun.xml b/res/e3a/spellbooks/illaun.xml index 6b89df8fa..02c9b34d8 100644 --- a/res/e3a/spellbooks/illaun.xml +++ b/res/e3a/spellbooks/illaun.xml @@ -1,4 +1,5 @@ + @@ -32,3 +33,4 @@ + diff --git a/res/e3a/spells.xml b/res/e3a/spells.xml index 80d9e6260..25d123d43 100644 --- a/res/e3a/spells.xml +++ b/res/e3a/spells.xml @@ -1,12 +1,6 @@ - - - - - - - - + + @@ -656,3 +650,4 @@ + diff --git a/res/e3a/strings.xml b/res/e3a/strings.xml index 253501f9f..2dd79abb6 100644 --- a/res/e3a/strings.xml +++ b/res/e3a/strings.xml @@ -1,4 +1,5 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/e3a/weapons/axe.xml b/res/e3a/weapons/axe.xml deleted file mode 100644 index 6066c4cfc..000000000 --- a/res/e3a/weapons/axe.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/res/e3a/weapons/crossbow.xml b/res/e3a/weapons/crossbow.xml deleted file mode 100644 index 7b2ed743c..000000000 --- a/res/e3a/weapons/crossbow.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/res/e3a/weapons/greatbow.xml b/res/e3a/weapons/greatbow.xml deleted file mode 100644 index 358a55f7d..000000000 --- a/res/e3a/weapons/greatbow.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/res/e3a/weapons/greatsword.xml b/res/e3a/weapons/greatsword.xml deleted file mode 100644 index 5a199321d..000000000 --- a/res/e3a/weapons/greatsword.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - diff --git a/res/e3a/weapons/halberd.xml b/res/e3a/weapons/halberd.xml deleted file mode 100644 index c22e020b4..000000000 --- a/res/e3a/weapons/halberd.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/res/e3a/weapons/laensword.xml b/res/e3a/weapons/laensword.xml deleted file mode 100644 index 50f824e8c..000000000 --- a/res/e3a/weapons/laensword.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - diff --git a/res/e3a/weapons/lance.xml b/res/e3a/weapons/lance.xml deleted file mode 100644 index 285862484..000000000 --- a/res/e3a/weapons/lance.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/res/e3a/weapons/mallorncrossbow.xml b/res/e3a/weapons/mallorncrossbow.xml deleted file mode 100644 index 86991bc10..000000000 --- a/res/e3a/weapons/mallorncrossbow.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/res/e3a/weapons/mallornlance.xml b/res/e3a/weapons/mallornlance.xml deleted file mode 100644 index 0c50d125a..000000000 --- a/res/e3a/weapons/mallornlance.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/res/e3a/weapons/rep_crossbow.xml b/res/e3a/weapons/rep_crossbow.xml deleted file mode 100644 index ffa1c0455..000000000 --- a/res/e3a/weapons/rep_crossbow.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/res/e3a/weapons/rustygreatsword.xml b/res/e3a/weapons/rustygreatsword.xml deleted file mode 100644 index 607f16a6a..000000000 --- a/res/e3a/weapons/rustygreatsword.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - diff --git a/res/e3a/weapons/rustyhalberd.xml b/res/e3a/weapons/rustyhalberd.xml deleted file mode 100644 index a53aec515..000000000 --- a/res/e3a/weapons/rustyhalberd.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - diff --git a/res/eressea/artrewards.xml b/res/eressea/artrewards.xml index b18fd5b20..9a144da07 100644 --- a/res/eressea/artrewards.xml +++ b/res/eressea/artrewards.xml @@ -1,5 +1,5 @@ - + @@ -11,4 +11,4 @@ - + diff --git a/res/eressea/buildings.xml b/res/eressea/buildings.xml index 1559fd987..d239907f1 100644 --- a/res/eressea/buildings.xml +++ b/res/eressea/buildings.xml @@ -1,8 +1,9 @@ - - + + + diff --git a/res/eressea/equipment.xml b/res/eressea/equipment.xml index e4d48aefe..94d0deb07 100644 --- a/res/eressea/equipment.xml +++ b/res/eressea/equipment.xml @@ -1,5 +1,5 @@ - + @@ -271,3 +271,5 @@ + + diff --git a/res/eressea/familiars.xml b/res/eressea/familiars.xml index 7e9bb75dc..112a82420 100644 --- a/res/eressea/familiars.xml +++ b/res/eressea/familiars.xml @@ -1,4 +1,5 @@ + @@ -129,4 +130,4 @@ - + diff --git a/res/eressea/items.xml b/res/eressea/items.xml index 3f5cc3d17..2cfa9e653 100644 --- a/res/eressea/items.xml +++ b/res/eressea/items.xml @@ -1,4 +1,5 @@ + @@ -128,3 +129,4 @@ + diff --git a/res/eressea/races.xml b/res/eressea/races.xml index cdd483851..21ff5b028 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -1,5 +1,6 @@ - + + + diff --git a/res/eressea/spellbooks/cerddor.xml b/res/eressea/spellbooks/cerddor.xml index 3a690b116..804d0bbe6 100644 --- a/res/eressea/spellbooks/cerddor.xml +++ b/res/eressea/spellbooks/cerddor.xml @@ -1,4 +1,5 @@ + @@ -36,3 +37,4 @@ + diff --git a/res/eressea/spellbooks/draig.xml b/res/eressea/spellbooks/draig.xml index b31905875..e2b432176 100644 --- a/res/eressea/spellbooks/draig.xml +++ b/res/eressea/spellbooks/draig.xml @@ -1,4 +1,5 @@ + @@ -30,3 +31,4 @@ + diff --git a/res/eressea/spellbooks/gray.xml b/res/eressea/spellbooks/gray.xml index ae7a1f611..942b50237 100644 --- a/res/eressea/spellbooks/gray.xml +++ b/res/eressea/spellbooks/gray.xml @@ -1,4 +1,5 @@ + @@ -165,3 +166,4 @@ + diff --git a/res/eressea/spellbooks/gwyrrd.xml b/res/eressea/spellbooks/gwyrrd.xml index 42863df34..ff57342ea 100644 --- a/res/eressea/spellbooks/gwyrrd.xml +++ b/res/eressea/spellbooks/gwyrrd.xml @@ -1,4 +1,5 @@ + @@ -39,3 +40,4 @@ + diff --git a/res/eressea/spellbooks/illaun.xml b/res/eressea/spellbooks/illaun.xml index ff99a0a81..83ffcfc27 100644 --- a/res/eressea/spellbooks/illaun.xml +++ b/res/eressea/spellbooks/illaun.xml @@ -1,4 +1,5 @@ + @@ -27,4 +28,4 @@ - + diff --git a/res/eressea/spellbooks/tybied.xml b/res/eressea/spellbooks/tybied.xml index 9c64f22ca..9670196e7 100644 --- a/res/eressea/spellbooks/tybied.xml +++ b/res/eressea/spellbooks/tybied.xml @@ -1,4 +1,5 @@ + @@ -34,3 +35,4 @@ + diff --git a/res/eressea/spellinfo.xml b/res/eressea/spellinfo.xml index 7d8704247..4304bb5fd 100644 --- a/res/eressea/spellinfo.xml +++ b/res/eressea/spellinfo.xml @@ -1,4 +1,5 @@ + @@ -117,3 +118,4 @@ + diff --git a/res/eressea/spells.xml b/res/eressea/spells.xml index 6b2e43a15..089ec1a6c 100644 --- a/res/eressea/spells.xml +++ b/res/eressea/spells.xml @@ -1,12 +1,6 @@ - - - - - - - - + + @@ -616,3 +610,5 @@ + + diff --git a/res/eressea/strings.xml b/res/eressea/strings.xml index 8afeabbca..2922bca0d 100644 --- a/res/eressea/strings.xml +++ b/res/eressea/strings.xml @@ -1,4 +1,5 @@ + @@ -403,3 +404,4 @@ amulettes du chaton + diff --git a/res/names-dragons.xml b/res/names-dragons.xml index 7272ba052..18723086f 100644 --- a/res/names-dragons.xml +++ b/res/names-dragons.xml @@ -1,6 +1,6 @@ + - der Weise @@ -91,5 +91,5 @@ die Schöne - + diff --git a/res/names-ghouls.xml b/res/names-ghouls.xml index 4d8c938d9..b1514f317 100644 --- a/res/names-ghouls.xml +++ b/res/names-ghouls.xml @@ -1,6 +1,6 @@ + - Faulende @@ -113,3 +113,4 @@ + diff --git a/res/names-skeletons.xml b/res/names-skeletons.xml index 8e282ae74..adb994fab 100644 --- a/res/names-skeletons.xml +++ b/res/names-skeletons.xml @@ -1,6 +1,6 @@ + - Klapperige @@ -117,5 +117,5 @@ aus der Unterwelt - + diff --git a/res/names-undead.xml b/res/names-undead.xml index 058bdef26..4c6b16726 100644 --- a/res/names-undead.xml +++ b/res/names-undead.xml @@ -1,4 +1,5 @@ + Grausige @@ -154,3 +155,4 @@ + diff --git a/res/names-zombies.xml b/res/names-zombies.xml index cbad1951f..5aa3fb961 100644 --- a/res/names-zombies.xml +++ b/res/names-zombies.xml @@ -1,4 +1,5 @@ + Faulende @@ -106,3 +107,4 @@ + diff --git a/res/races/dragon.xml b/res/races/dragon.xml index f42037312..7e0da2056 100644 --- a/res/races/dragon.xml +++ b/res/races/dragon.xml @@ -1,3 +1,5 @@ + + - + + diff --git a/res/races/goblin-3.xml b/res/races/goblin-3.xml index a65d4c99a..636f8cc29 100644 --- a/res/races/goblin-3.xml +++ b/res/races/goblin-3.xml @@ -1,4 +1,6 @@ + + + + diff --git a/res/races/wyrm.xml b/res/races/wyrm.xml index dab1a9e1f..df2008a80 100644 --- a/res/races/wyrm.xml +++ b/res/races/wyrm.xml @@ -1,3 +1,6 @@ + + + + + diff --git a/res/races/youngdragon.xml b/res/races/youngdragon.xml index df10a44e9..d8b3d366f 100644 --- a/res/races/youngdragon.xml +++ b/res/races/youngdragon.xml @@ -1,3 +1,5 @@ + + - + + diff --git a/scripts/eressea/xmlconf.lua b/scripts/eressea/xmlconf.lua index 84f29eceb..756d3c18a 100644 --- a/scripts/eressea/xmlconf.lua +++ b/scripts/eressea/xmlconf.lua @@ -1,11 +1,10 @@ -local confdir = 'conf/' -if config.install then - confdir = config.install .. '/' .. confdir -end +local rules = 'conf' + if config.rules then - local rules = config.rules .. '/' - assert(0 == eressea.config.read(rules .. 'config.json', confdir), "could not read JSON data") - assert(0 == read_xml(confdir .. rules .. 'rules.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?") - assert(0 == read_xml(confdir .. rules .. 'locales.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?") + rules = rules .. '/' .. config.rules + assert(0 == eressea.config.read(rules .. '/config.json', config.install), "could not read JSON data") +-- assert(0 == read_xml(confdir .. rules .. 'rules.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?") +-- assert(0 == read_xml(confdir .. rules .. 'locales.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?") end + eressea.game.reset() diff --git a/scripts/run-tests-e2.lua b/scripts/run-tests-e2.lua index 27617592f..2672b7ef2 100644 --- a/scripts/run-tests-e2.lua +++ b/scripts/run-tests-e2.lua @@ -18,6 +18,13 @@ require 'tests.e2' require 'lunit' rng.inject(0) +eressea.settings.set("rules.food.flags", "4") +eressea.settings.set("rules.ship.damage.nocrew", "0") +eressea.settings.set("rules.ship.drifting", "0") +eressea.settings.set("rules.ship.storms", "0") +eressea.settings.set("rules.encounters", "0") +eressea.settings.set("nmr.timeout", "0") +eressea.settings.set("NewbieImmunity", "0") rules = require('eressea.' .. config.rules) result = lunit.main() return result.errors + result.failed diff --git a/scripts/run-tests-e3.lua b/scripts/run-tests-e3.lua index 0aefb5d3a..9ad78a81f 100644 --- a/scripts/run-tests-e3.lua +++ b/scripts/run-tests-e3.lua @@ -19,6 +19,13 @@ require 'lunit' rng.inject(0) eressea.settings.set("rules.alliances", "0") +eressea.settings.set("rules.food.flags", "4") +eressea.settings.set("rules.ship.damage.nocrew", "0") +eressea.settings.set("rules.ship.drifting", "0") +eressea.settings.set("rules.ship.storms", "0") +eressea.settings.set("rules.encounters", "0") +eressea.settings.set("nmr.timeout", "0") +eressea.settings.set("NewbieImmunity", "0") rules = require('eressea.' .. config.rules) result = lunit.main() return result.errors + result.failed diff --git a/scripts/tests/e3/production.lua b/scripts/tests/e3/production.lua index 3469b06c4..be63158cf 100644 --- a/scripts/tests/e3/production.lua +++ b/scripts/tests/e3/production.lua @@ -53,6 +53,7 @@ function test_dwarf_no_mining_bonus() local r = region.create(0, 0, 'mountain') local f = create_faction('dwarf') local u = unit.create(f, r, 1) + u.name = 'Xolgrim' turn_begin() r:set_resource('iron', 100) diff --git a/src/bindings.c b/src/bindings.c index b399dbdb8..811c1853e 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -897,10 +897,10 @@ static int tolua_get_spells(lua_State * L) return tolua_selist_push(L, "spell_list", "spell", spells); } -static int init_data(const char *filename, const char *catalog) +static int init_data(const char *filename) { int l; - l = read_xml(filename, catalog); + l = read_xml(filename); reset_locales(); if (l) { return l; @@ -915,8 +915,7 @@ static int init_data(const char *filename, const char *catalog) int tolua_read_xml(lua_State * L) { const char *filename = tolua_tostring(L, 1, "config.xml"); - const char *catalog = tolua_tostring(L, 2, "catalog.xml"); - lua_pushinteger(L, init_data(filename, catalog)); + lua_pushinteger(L, init_data(filename)); return 1; } diff --git a/src/convert.c b/src/convert.c index 2368043bb..6470c9e32 100644 --- a/src/convert.c +++ b/src/convert.c @@ -23,11 +23,10 @@ int main(int argc, char **argv) { if (argc < 2) return usage(); mode = argv[1]; if (strcmp(mode, "rules")==0) { - const char *xmlfile, *catalog; + const char *xmlfile; if (argc < 4) return usage(); xmlfile = argv[2]; - catalog = argv[3]; - read_xml(xmlfile, catalog); + read_xml(xmlfile); write_rules("rules.dat"); return 0; } diff --git a/src/jsonconf.c b/src/jsonconf.c index 3c5411b9d..cd9d991aa 100644 --- a/src/jsonconf.c +++ b/src/jsonconf.c @@ -887,6 +887,92 @@ static void json_races(cJSON *json) { const char * json_relpath; +/* TODO: much more configurable authority-to-file lookup */ +static const char * authority_to_path(const char *authority, char *name, size_t size) { + /* source and destination cannot share the same buffer */ + assert(authority < name || authority > name + size); + + return join_path(json_relpath, authority, name, size); +} + +static const char * uri_to_file(const char * uri, char *name, size_t size) { + const char *pos, *scheme, *path = uri; + + /* source and destination cannot share the same buffer */ + assert(uri < name || uri > name + size); + + /* identify scheme */ + scheme = uri; + pos = strstr(scheme, "://"); + if (pos) { + size_t slen = pos - scheme; + if (strncmp(scheme, "config", slen) == 0) { + const char *authority = pos + 3; + /* authority */ + pos = strstr(authority, "/"); + if (pos) { + char buffer[16]; + size_t alen = pos - authority; + assert(alen < sizeof(buffer)); + memcpy(buffer, authority, alen); + buffer[alen] = 0; + + path = authority_to_path(buffer, name, size); + path = path_join(path, pos + 1, name, size); + } + } + else { + log_fatal("unknown URI scheme: %s", uri); + } + } + return path; +} + +static int include_json(const char *uri) { + FILE *F; + char name[PATH_MAX]; + const char *filename = uri_to_file(uri, name, sizeof(name)); + + F = fopen(filename, "r"); + if (F) { + long pos; + fseek(F, 0, SEEK_END); + pos = ftell(F); + rewind(F); + if (pos > 0) { + cJSON *config; + char *data; + size_t sz; + + data = malloc(pos + 1); + sz = fread(data, 1, (size_t)pos, F); + data[sz] = 0; + config = cJSON_Parse(data); + free(data); + if (config) { + json_config(config); + cJSON_Delete(config); + } + else { + log_error("could not parse JSON from %s", uri); + return -1; + } + } + fclose(F); + } + return 0; +} + +static int include_xml(const char *uri) { + char name[PATH_MAX]; + const char *filename = uri_to_file(uri, name, sizeof(name)); + int err = read_xml(filename); + if (err < 0) { + log_error("could not parse XML from %s", uri); + } + return err; +} + static void json_include(cJSON *json) { cJSON *child; if (json->type != cJSON_Array) { @@ -894,39 +980,17 @@ static void json_include(cJSON *json) { return; } for (child = json->child; child; child = child->next) { - FILE *F; - if (json_relpath) { - char name[PATH_MAX]; - path_join(json_relpath, child->valuestring, name, sizeof(name)); - F = fopen(name, "r"); + const char *uri = child->valuestring; + int err; + + if (strstr(uri, ".xml") != NULL) { + err = include_xml(uri); } else { - F = fopen(child->valuestring, "r"); + err = include_json(uri); } - if (F) { - long pos; - fseek(F, 0, SEEK_END); - pos = ftell(F); - rewind(F); - if (pos > 0) { - cJSON *config; - char *data; - size_t sz; - - data = malloc(pos + 1); - sz = fread(data, 1, (size_t)pos, F); - data[sz] = 0; - config = cJSON_Parse(data); - free(data); - if (config) { - json_config(config); - cJSON_Delete(config); - } - else { - log_error("invalid JSON, could not parse %s", child->valuestring); - } - } - fclose(F); + if (err != 0) { + log_error("no data found in %s", uri); } } } diff --git a/src/laws.c b/src/laws.c index d90d2f173..85b820323 100644 --- a/src/laws.c +++ b/src/laws.c @@ -4085,7 +4085,12 @@ static void reset_game(void) void turn_begin(void) { + int start = first_turn(); assert(turn >= 0); + if (turn < start) { + /* this should only happen during tests */ + turn = start; + } ++turn; reset_game(); } diff --git a/src/util/xml.c b/src/util/xml.c index ec72179c3..7ce893916 100644 --- a/src/util/xml.c +++ b/src/util/xml.c @@ -77,7 +77,6 @@ double xml_fvalue(xmlNodePtr node, const char *name, double dflt) /* libxml includes */ #include #include -#include typedef struct xml_reader { struct xml_reader *next; @@ -108,32 +107,25 @@ void xml_register_callback(xml_callback callback) *insert = reader; } -int read_xml(const char *filename, const char *catalog) +int read_xml(const char *filename) { xml_reader *reader = xmlReaders; xmlDocPtr doc; - int result; + int results = 0; - if (catalog) { - xmlLoadCatalog(catalog); - } - doc = xmlReadFile(filename, NULL, XML_PARSE_XINCLUDE | XML_PARSE_NONET | XML_PARSE_PEDANTIC | XML_PARSE_COMPACT); + doc = xmlReadFile(filename, NULL, XML_PARSE_NONET | XML_PARSE_PEDANTIC | XML_PARSE_COMPACT); if (doc == NULL) { log_error("could not open '%s'\n", filename); return -1; } - - result = xmlXIncludeProcessFlags(doc, XML_PARSE_XINCLUDE | XML_PARSE_NONET | XML_PARSE_PEDANTIC | XML_PARSE_COMPACT); - if (result >= 0) { - while (reader != NULL) { - int i = reader->callback(doc); - if (i != 0) { - return i; - } - reader = reader->next; + while (reader != NULL) { + int i = reader->callback(doc); + if (i < 0) { + return i; } - result = 0; + results += i; + reader = reader->next; } xmlFreeDoc(doc); - return result; + return (results > 0) ? 0 : -1; } diff --git a/src/util/xml.h b/src/util/xml.h index f2dc5fda5..c7a67a82c 100644 --- a/src/util/xml.h +++ b/src/util/xml.h @@ -31,7 +31,7 @@ extern "C" { bool xml_bvalue(xmlNodePtr node, const char *name, bool dflt); void xml_done(void); - int read_xml(const char *filename, const char *catalog); + int read_xml(const char *filename); #ifdef __cplusplus } diff --git a/src/xmlreader.c b/src/xmlreader.c index ad01ff7ca..a711b7dbd 100644 --- a/src/xmlreader.c +++ b/src/xmlreader.c @@ -282,6 +282,7 @@ static int parse_buildings(xmlDocPtr doc) { xmlXPathContextPtr xpath = xmlXPathNewContext(doc); xmlXPathObjectPtr buildings; + int result = 0; /* reading eressea/buildings/building */ buildings = @@ -289,6 +290,7 @@ static int parse_buildings(xmlDocPtr doc) if (buildings->nodesetval != NULL) { xmlNodeSetPtr nodes = buildings->nodesetval; int i; + result += nodes->nodeNr; for (i = 0; i != nodes->nodeNr; ++i) { xmlNodePtr node = nodes->nodeTab[i]; xmlChar *propValue; @@ -387,19 +389,21 @@ static int parse_buildings(xmlDocPtr doc) xmlXPathFreeObject(buildings); xmlXPathFreeContext(xpath); - return 0; + return result; } static int parse_ships(xmlDocPtr doc) { xmlXPathContextPtr xpath = xmlXPathNewContext(doc); xmlXPathObjectPtr ships; + int result = 0; /* reading eressea/ships/ship */ ships = xmlXPathEvalExpression(BAD_CAST "/eressea/ships/ship", xpath); if (ships->nodesetval != NULL) { xmlNodeSetPtr nodes = ships->nodesetval; int i; + result += nodes->nodeNr; for (i = 0; i != nodes->nodeNr; ++i) { xmlNodePtr child, node = nodes->nodeTab[i]; xmlChar *propValue; @@ -481,7 +485,7 @@ static int parse_ships(xmlDocPtr doc) xmlXPathFreeObject(ships); xmlXPathFreeContext(xpath); - return 0; + return result; } static void xml_readpotion(xmlXPathContextPtr xpath, item_type * itype) @@ -794,95 +798,98 @@ static int parse_resources(xmlDocPtr doc) { xmlXPathContextPtr xpath = xmlXPathNewContext(doc); xmlXPathObjectPtr resources; - xmlNodeSetPtr nodes; - int i; + int results = 0; /* reading eressea/resources/resource */ resources = xmlXPathEvalExpression(BAD_CAST "/eressea/resources/resource", xpath); - nodes = resources->nodesetval; - for (i = 0; i != nodes->nodeNr; ++i) { - xmlNodePtr node = nodes->nodeTab[i]; - xmlChar *propValue, *name, *appearance; - resource_type *rtype; - unsigned int flags = RTF_NONE; - xmlXPathObjectPtr result; + if (resources->nodesetval) { + int i; + xmlNodeSetPtr nodes = resources->nodesetval; + results = nodes->nodeNr; + for (i = 0; i != nodes->nodeNr; ++i) { + xmlNodePtr node = nodes->nodeTab[i]; + xmlChar *propValue, *name, *appearance; + resource_type *rtype; + unsigned int flags = RTF_NONE; + xmlXPathObjectPtr result; - if (xml_bvalue(node, "pooled", true)) - flags |= RTF_POOLED; + if (xml_bvalue(node, "pooled", true)) + flags |= RTF_POOLED; - name = xmlGetProp(node, BAD_CAST "name"); - if (!name) { - assert(name); - log_error("invalid resource %d has no name", i); - continue; - } - rtype = rt_get_or_create((const char *)name); - rtype->flags |= flags; - xmlFree(name); + name = xmlGetProp(node, BAD_CAST "name"); + if (!name) { + assert(name); + log_error("invalid resource %d has no name", i); + continue; + } + rtype = rt_get_or_create((const char *)name); + rtype->flags |= flags; + xmlFree(name); - /* reading eressea/resources/resource/function */ - xpath->node = node; - result = xmlXPathEvalExpression(BAD_CAST "function", xpath); - if (result->nodesetval != NULL) { - int k; - for (k = 0; k != result->nodesetval->nodeNr; ++k) { - xmlNodePtr node = result->nodesetval->nodeTab[k]; - pf_generic fun; + /* reading eressea/resources/resource/function */ + xpath->node = node; + result = xmlXPathEvalExpression(BAD_CAST "function", xpath); + if (result->nodesetval != NULL) { + int k; + for (k = 0; k != result->nodesetval->nodeNr; ++k) { + xmlNodePtr node = result->nodesetval->nodeTab[k]; + pf_generic fun; - parse_function(node, &fun, &propValue); - if (fun == NULL) { - log_error("unknown function name '%s' for resource %s\n", (const char *)propValue, rtype->_name); + parse_function(node, &fun, &propValue); + if (fun == NULL) { + log_error("unknown function name '%s' for resource %s\n", (const char *)propValue, rtype->_name); + xmlFree(propValue); + continue; + } + + assert(propValue != NULL); + if (strcmp((const char *)propValue, "change") == 0) { + rtype->uchange = (rtype_uchange)fun; + } + else if (strcmp((const char *)propValue, "name") == 0) { + rtype->name = (rtype_name)fun; + } + else { + log_error("unknown function type '%s' for resource %s\n", (const char *)propValue, rtype->_name); + } xmlFree(propValue); - continue; } - - assert(propValue != NULL); - if (strcmp((const char *)propValue, "change") == 0) { - rtype->uchange = (rtype_uchange)fun; - } - else if (strcmp((const char *)propValue, "name") == 0) { - rtype->name = (rtype_name)fun; - } - else { - log_error("unknown function type '%s' for resource %s\n", (const char *)propValue, rtype->_name); - } - xmlFree(propValue); } - } - xmlXPathFreeObject(result); + xmlXPathFreeObject(result); - if (xml_bvalue(node, "material", false)) { - rmt_create(rtype); - } - - if (xml_bvalue(node, "limited", false)) { - rtype->flags |= RTF_LIMITED; - } - xpath->node = node; - result = xmlXPathEvalExpression(BAD_CAST "modifier", xpath); - rtype->modifiers = xml_readmodifiers(result, node); - xmlXPathFreeObject(result); - /* reading eressea/resources/resource/resourcelimit/function */ - xpath->node = node; - result = xmlXPathEvalExpression(BAD_CAST "resourcelimit/function", xpath); - xmlXPathFreeObject(result); - - /* reading eressea/resources/resource/item */ - xpath->node = node; - result = xmlXPathEvalExpression(BAD_CAST "item", xpath); - assert(result->nodesetval->nodeNr <= 1); - if (result->nodesetval->nodeNr != 0) { - rtype->flags |= RTF_ITEM; - xpath->node = result->nodesetval->nodeTab[0]; - rtype->itype = xml_readitem(xpath, rtype); - appearance = xmlGetProp(node, BAD_CAST "appearance"); - if (appearance) { - it_set_appearance(rtype->itype, (const char *)appearance); - xmlFree(appearance); + if (xml_bvalue(node, "material", false)) { + rmt_create(rtype); } + + if (xml_bvalue(node, "limited", false)) { + rtype->flags |= RTF_LIMITED; + } + xpath->node = node; + result = xmlXPathEvalExpression(BAD_CAST "modifier", xpath); + rtype->modifiers = xml_readmodifiers(result, node); + xmlXPathFreeObject(result); + /* reading eressea/resources/resource/resourcelimit/function */ + xpath->node = node; + result = xmlXPathEvalExpression(BAD_CAST "resourcelimit/function", xpath); + xmlXPathFreeObject(result); + + /* reading eressea/resources/resource/item */ + xpath->node = node; + result = xmlXPathEvalExpression(BAD_CAST "item", xpath); + assert(result->nodesetval->nodeNr <= 1); + if (result->nodesetval->nodeNr != 0) { + rtype->flags |= RTF_ITEM; + xpath->node = result->nodesetval->nodeTab[0]; + rtype->itype = xml_readitem(xpath, rtype); + appearance = xmlGetProp(node, BAD_CAST "appearance"); + if (appearance) { + it_set_appearance(rtype->itype, (const char *)appearance); + xmlFree(appearance); + } + } + xmlXPathFreeObject(result); } - xmlXPathFreeObject(result); } xmlXPathFreeObject(resources); @@ -891,7 +898,7 @@ static int parse_resources(xmlDocPtr doc) /* make sure old items (used in requirements) are available */ init_resources(); - return 0; + return results; } static void add_items(equipment * eq, xmlNodeSetPtr nsetItems) @@ -1055,6 +1062,7 @@ static int parse_equipment(xmlDocPtr doc) { xmlXPathContextPtr xpath = xmlXPathNewContext(doc); xmlXPathObjectPtr xpathRaces; + int result = 0; /* reading eressea/equipment/set */ xpathRaces = xmlXPathEvalExpression(BAD_CAST "/eressea/equipment/set", xpath); @@ -1062,6 +1070,7 @@ static int parse_equipment(xmlDocPtr doc) xmlNodeSetPtr nsetRaces = xpathRaces->nodesetval; int i; + result += nsetRaces->nodeNr; for (i = 0; i != nsetRaces->nodeNr; ++i) { xmlNodePtr node = nsetRaces->nodeTab[i]; xmlChar *propName = xmlGetProp(node, BAD_CAST "name"); @@ -1108,21 +1117,23 @@ static int parse_equipment(xmlDocPtr doc) xmlXPathFreeObject(xpathRaces); xmlXPathFreeContext(xpath); - return 0; + return result; } static int parse_spellbooks(xmlDocPtr doc) { xmlXPathContextPtr xpath = xmlXPathNewContext(doc); xmlXPathObjectPtr spellbooks; + int results = 0; /* reading eressea/spells/spell */ - spellbooks = xmlXPathEvalExpression(BAD_CAST "/eressea/spells/spellbook", xpath); + spellbooks = xmlXPathEvalExpression(BAD_CAST "/eressea/spellbook", xpath); if (spellbooks->nodesetval != NULL) { xmlNodeSetPtr nodes = spellbooks->nodesetval; int i, k; + results += nodes->nodeNr; for (i = 0; i != nodes->nodeNr; ++i) { xmlXPathObjectPtr result; xmlNodePtr node = nodes->nodeTab[i]; @@ -1166,13 +1177,14 @@ static int parse_spellbooks(xmlDocPtr doc) } xmlXPathFreeObject(spellbooks); xmlXPathFreeContext(xpath); - return 0; + return results; } static int parse_spells(xmlDocPtr doc) { xmlXPathContextPtr xpath = xmlXPathNewContext(doc); xmlXPathObjectPtr spells; + int result = 0; /* reading eressea/spells/spell */ spells = xmlXPathEvalExpression(BAD_CAST "/eressea/spells/spell", xpath); @@ -1180,6 +1192,7 @@ static int parse_spells(xmlDocPtr doc) xmlNodeSetPtr nodes = spells->nodesetval; int i; + result += nodes->nodeNr; for (i = 0; i != nodes->nodeNr; ++i) { xmlXPathObjectPtr result; xmlNodePtr node = nodes->nodeTab[i]; @@ -1299,7 +1312,7 @@ static int parse_spells(xmlDocPtr doc) xmlXPathFreeContext(xpath); - return 0; + return result; } static void parse_ai(race * rc, xmlNodePtr node) @@ -1332,246 +1345,249 @@ static int parse_races(xmlDocPtr doc) { xmlXPathContextPtr xpath = xmlXPathNewContext(doc); xmlXPathObjectPtr races; - xmlNodeSetPtr nodes; - int i; + int results = 0; /* reading eressea/races/race */ races = xmlXPathEvalExpression(BAD_CAST "/eressea/races/race", xpath); - nodes = races->nodesetval; - for (i = 0; i != nodes->nodeNr; ++i) { - xmlNodePtr node = nodes->nodeTab[i]; - xmlNodePtr child; - xmlChar *propValue; - race *rc, *frc = 0; - xmlXPathObjectPtr result; - int k, study_speed_base, attacks; - struct att *attack; - skill_t sk; - - propValue = xmlGetProp(node, BAD_CAST "name"); - assert(propValue != NULL); - rc = rc_get_or_create((const char *)propValue); - xmlFree(propValue); - - propValue = xmlGetProp(node, BAD_CAST "damage"); - assert(propValue != NULL); - rc->def_damage = str_strdup((const char *)propValue); - xmlFree(propValue); - - rc->magres = frac_make(xml_ivalue(node, "magres", 100), 100); - rc->healing = (int)(xml_fvalue(node, "healing", rc->healing) * 100); /* TODO: store as int in XML */ - rc->maxaura = (int)(xml_fvalue(node, "maxaura", rc->maxaura) * 100); /* TODO: store as int in XML */ - rc->regaura = (float)xml_fvalue(node, "regaura", rc->regaura); - rc->recruitcost = xml_ivalue(node, "recruitcost", rc->recruitcost); - rc->maintenance = xml_ivalue(node, "maintenance", rc->maintenance); - rc->weight = xml_ivalue(node, "weight", rc->weight); - rc->capacity = xml_ivalue(node, "capacity", rc->capacity); - rc->income = xml_ivalue(node, "income", rc->income); - rc->speed = (float)xml_fvalue(node, "speed", rc->speed); - rc->hitpoints = xml_ivalue(node, "hp", rc->hitpoints); - rc->armor = (char)xml_ivalue(node, "ac", rc->armor); - study_speed_base = xml_ivalue(node, "studyspeed", 0); - if (study_speed_base != 0) { - for (sk = 0; sk < MAXSKILLS; ++sk) { - set_study_speed(rc, sk, study_speed_base); - } - } - - rc->at_default = (char)xml_ivalue(node, "unarmedattack", -2); - rc->df_default = (char)xml_ivalue(node, "unarmeddefense", -2); - rc->at_bonus = (char)xml_ivalue(node, "attackmodifier", rc->at_bonus); - rc->df_bonus = (char)xml_ivalue(node, "defensemodifier", rc->df_bonus); - - if (!xml_bvalue(node, "playerrace", false)) { - assert(rc->recruitcost == 0); - rc->flags |= RCF_NPC; - } - if (xml_bvalue(node, "scarepeasants", false)) - rc->flags |= RCF_SCAREPEASANTS; - if (!xml_bvalue(node, "cansteal", true)) - rc->flags |= RCF_NOSTEAL; - if (xml_bvalue(node, "cansail", true)) - rc->flags |= RCF_CANSAIL; - if (xml_bvalue(node, "cannotmove", false)) - rc->flags |= RCF_CANNOTMOVE; - if (xml_bvalue(node, "fly", false)) - rc->flags |= RCF_FLY; - if (xml_bvalue(node, "invisible", false)) - rc->flags |= RCF_INVISIBLE; - if (xml_bvalue(node, "coastal", false)) - rc->flags |= RCF_COASTAL; - if (xml_bvalue(node, "unarmedguard", false)) - rc->flags |= RCF_UNARMEDGUARD; - if (xml_bvalue(node, "swim", false)) - rc->flags |= RCF_SWIM; - if (xml_bvalue(node, "walk", false)) - rc->flags |= RCF_WALK; - if (!xml_bvalue(node, "canlearn", true)) - rc->flags |= RCF_NOLEARN; - if (!xml_bvalue(node, "canteach", true)) - rc->flags |= RCF_NOTEACH; - if (xml_bvalue(node, "horse", false)) - rc->flags |= RCF_HORSE; - if (xml_bvalue(node, "desert", false)) - rc->flags |= RCF_DESERT; - if (xml_bvalue(node, "absorbpeasants", false)) - rc->flags |= RCF_ABSORBPEASANTS; - if (xml_bvalue(node, "noheal", false)) - rc->flags |= RCF_NOHEAL; - if (xml_bvalue(node, "noweapons", false)) - rc->flags |= RCF_NOWEAPONS; - if (xml_bvalue(node, "shapeshift", false)) - rc->flags |= RCF_SHAPESHIFT; - if (xml_bvalue(node, "shapeshiftany", false)) - rc->flags |= RCF_SHAPESHIFTANY; - if (xml_bvalue(node, "illusionary", false)) - rc->flags |= RCF_ILLUSIONARY; - if (xml_bvalue(node, "undead", false)) - rc->flags |= RCF_UNDEAD; - if (xml_bvalue(node, "dragon", false)) - rc->flags |= RCF_DRAGON; - if (xml_bvalue(node, "shipspeed", false)) - rc->flags |= RCF_SHIPSPEED; - - if (xml_bvalue(node, "giveperson", false)) - rc->ec_flags |= ECF_GIVEPERSON; - if (xml_bvalue(node, "giveunit", false)) - rc->ec_flags |= ECF_GIVEUNIT; - if (xml_bvalue(node, "getitem", false)) - rc->ec_flags |= ECF_GETITEM; - if (xml_bvalue(node, "recruitethereal", false)) - rc->ec_flags |= ECF_REC_ETHEREAL; - if (xml_bvalue(node, "recruitunlimited", false)) - rc->ec_flags |= ECF_REC_UNLIMITED; - if (xml_bvalue(node, "stonegolem", false)) - rc->ec_flags |= ECF_STONEGOLEM; - if (xml_bvalue(node, "irongolem", false)) - rc->ec_flags |= ECF_IRONGOLEM; - - if (xml_bvalue(node, "equipment", false)) - rc->battle_flags |= BF_EQUIPMENT; /* TODO: invert this flag, so rc_get_or_create gets simpler */ - if (xml_bvalue(node, "noblock", false)) - rc->battle_flags |= BF_NOBLOCK; - if (xml_bvalue(node, "invinciblenonmagic", false)) - rc->battle_flags |= BF_INV_NONMAGIC; - if (xml_bvalue(node, "resistbash", false)) - rc->battle_flags |= BF_RES_BASH; - if (xml_bvalue(node, "resistcut", false)) - rc->battle_flags |= BF_RES_CUT; - if (xml_bvalue(node, "resistpierce", false)) - rc->battle_flags |= BF_RES_PIERCE; - if (xml_bvalue(node, "noattack", false)) - rc->battle_flags |= BF_NO_ATTACK; - - rc->recruit_multi = 1.0; - for (child = node->children; child; child = child->next) { - if (strcmp((const char *)child->name, "ai") == 0) { - parse_ai(rc, child); - } - else if (strcmp((const char *)child->name, "param") == 0) { - xmlChar *propName = xmlGetProp(child, BAD_CAST "name"); - xmlChar *propValue = xmlGetProp(child, BAD_CAST "value"); - rc_set_param(rc, (const char *)propName, (const char *)propValue); - xmlFree(propName); - xmlFree(propValue); - } - } - - /* reading eressea/races/race/skill */ - xpath->node = node; - result = xmlXPathEvalExpression(BAD_CAST "skill", xpath); - memset(rc->bonus, 0, sizeof(rc->bonus)); - for (k = 0; k != result->nodesetval->nodeNr; ++k) { - xmlNodePtr node = result->nodesetval->nodeTab[k]; - int mod = xml_ivalue(node, "modifier", 0); - int speed = xml_ivalue(node, "speed", study_speed_base); + if (races->nodesetval) { + xmlNodeSetPtr nodes = races->nodesetval; + int i; + results += nodes->nodeNr; + for (i = 0; i != nodes->nodeNr; ++i) { + xmlNodePtr node = nodes->nodeTab[i]; + xmlNodePtr child; + xmlChar *propValue; + race *rc, *frc = 0; + xmlXPathObjectPtr result; + int k, study_speed_base, attacks; + struct att *attack; + skill_t sk; propValue = xmlGetProp(node, BAD_CAST "name"); assert(propValue != NULL); - sk = findskill((const char *)propValue); - if (sk != NOSKILL) { - rc->bonus[sk] = (char)mod; - if (speed) { - set_study_speed(rc, sk, speed); + rc = rc_get_or_create((const char *)propValue); + xmlFree(propValue); + + propValue = xmlGetProp(node, BAD_CAST "damage"); + assert(propValue != NULL); + rc->def_damage = str_strdup((const char *)propValue); + xmlFree(propValue); + + rc->magres = frac_make(xml_ivalue(node, "magres", 100), 100); + rc->healing = (int)(xml_fvalue(node, "healing", rc->healing) * 100); /* TODO: store as int in XML */ + rc->maxaura = (int)(xml_fvalue(node, "maxaura", rc->maxaura) * 100); /* TODO: store as int in XML */ + rc->regaura = (float)xml_fvalue(node, "regaura", rc->regaura); + rc->recruitcost = xml_ivalue(node, "recruitcost", rc->recruitcost); + rc->maintenance = xml_ivalue(node, "maintenance", rc->maintenance); + rc->weight = xml_ivalue(node, "weight", rc->weight); + rc->capacity = xml_ivalue(node, "capacity", rc->capacity); + rc->income = xml_ivalue(node, "income", rc->income); + rc->speed = (float)xml_fvalue(node, "speed", rc->speed); + rc->hitpoints = xml_ivalue(node, "hp", rc->hitpoints); + rc->armor = (char)xml_ivalue(node, "ac", rc->armor); + study_speed_base = xml_ivalue(node, "studyspeed", 0); + if (study_speed_base != 0) { + for (sk = 0; sk < MAXSKILLS; ++sk) { + set_study_speed(rc, sk, study_speed_base); } } - else { - log_error("unknown skill '%s' in race '%s'\n", (const char *)propValue, rc->_name); + + rc->at_default = (char)xml_ivalue(node, "unarmedattack", -2); + rc->df_default = (char)xml_ivalue(node, "unarmeddefense", -2); + rc->at_bonus = (char)xml_ivalue(node, "attackmodifier", rc->at_bonus); + rc->df_bonus = (char)xml_ivalue(node, "defensemodifier", rc->df_bonus); + + if (!xml_bvalue(node, "playerrace", false)) { + assert(rc->recruitcost == 0); + rc->flags |= RCF_NPC; } - xmlFree(propValue); - } - xmlXPathFreeObject(result); + if (xml_bvalue(node, "scarepeasants", false)) + rc->flags |= RCF_SCAREPEASANTS; + if (!xml_bvalue(node, "cansteal", true)) + rc->flags |= RCF_NOSTEAL; + if (xml_bvalue(node, "cansail", true)) + rc->flags |= RCF_CANSAIL; + if (xml_bvalue(node, "cannotmove", false)) + rc->flags |= RCF_CANNOTMOVE; + if (xml_bvalue(node, "fly", false)) + rc->flags |= RCF_FLY; + if (xml_bvalue(node, "invisible", false)) + rc->flags |= RCF_INVISIBLE; + if (xml_bvalue(node, "coastal", false)) + rc->flags |= RCF_COASTAL; + if (xml_bvalue(node, "unarmedguard", false)) + rc->flags |= RCF_UNARMEDGUARD; + if (xml_bvalue(node, "swim", false)) + rc->flags |= RCF_SWIM; + if (xml_bvalue(node, "walk", false)) + rc->flags |= RCF_WALK; + if (!xml_bvalue(node, "canlearn", true)) + rc->flags |= RCF_NOLEARN; + if (!xml_bvalue(node, "canteach", true)) + rc->flags |= RCF_NOTEACH; + if (xml_bvalue(node, "horse", false)) + rc->flags |= RCF_HORSE; + if (xml_bvalue(node, "desert", false)) + rc->flags |= RCF_DESERT; + if (xml_bvalue(node, "absorbpeasants", false)) + rc->flags |= RCF_ABSORBPEASANTS; + if (xml_bvalue(node, "noheal", false)) + rc->flags |= RCF_NOHEAL; + if (xml_bvalue(node, "noweapons", false)) + rc->flags |= RCF_NOWEAPONS; + if (xml_bvalue(node, "shapeshift", false)) + rc->flags |= RCF_SHAPESHIFT; + if (xml_bvalue(node, "shapeshiftany", false)) + rc->flags |= RCF_SHAPESHIFTANY; + if (xml_bvalue(node, "illusionary", false)) + rc->flags |= RCF_ILLUSIONARY; + if (xml_bvalue(node, "undead", false)) + rc->flags |= RCF_UNDEAD; + if (xml_bvalue(node, "dragon", false)) + rc->flags |= RCF_DRAGON; + if (xml_bvalue(node, "shipspeed", false)) + rc->flags |= RCF_SHIPSPEED; - /* reading eressea/races/race/familiar */ - xpath->node = node; - result = xmlXPathEvalExpression(BAD_CAST "familiar", xpath); - if (result->nodesetval->nodeNr > MAXMAGIETYP) { - log_error("race %s has %d potential familiars", rc->_name, result->nodesetval->nodeNr); - } - else { - for (k = 0; k != MAXMAGIETYP; ++k) { - if (k < result->nodesetval->nodeNr) { - xmlNodePtr node = result->nodesetval->nodeTab[k]; + if (xml_bvalue(node, "giveperson", false)) + rc->ec_flags |= ECF_GIVEPERSON; + if (xml_bvalue(node, "giveunit", false)) + rc->ec_flags |= ECF_GIVEUNIT; + if (xml_bvalue(node, "getitem", false)) + rc->ec_flags |= ECF_GETITEM; + if (xml_bvalue(node, "recruitethereal", false)) + rc->ec_flags |= ECF_REC_ETHEREAL; + if (xml_bvalue(node, "recruitunlimited", false)) + rc->ec_flags |= ECF_REC_UNLIMITED; + if (xml_bvalue(node, "stonegolem", false)) + rc->ec_flags |= ECF_STONEGOLEM; + if (xml_bvalue(node, "irongolem", false)) + rc->ec_flags |= ECF_IRONGOLEM; - propValue = xmlGetProp(node, BAD_CAST "race"); - assert(propValue != NULL); - frc = rc_get_or_create((const char *)propValue); - frc->flags |= RCF_FAMILIAR; - if (xml_bvalue(node, "default", false)) { - rc->familiars[k] = rc->familiars[0]; - rc->familiars[0] = frc; + if (xml_bvalue(node, "equipment", false)) + rc->battle_flags |= BF_EQUIPMENT; /* TODO: invert this flag, so rc_get_or_create gets simpler */ + if (xml_bvalue(node, "noblock", false)) + rc->battle_flags |= BF_NOBLOCK; + if (xml_bvalue(node, "invinciblenonmagic", false)) + rc->battle_flags |= BF_INV_NONMAGIC; + if (xml_bvalue(node, "resistbash", false)) + rc->battle_flags |= BF_RES_BASH; + if (xml_bvalue(node, "resistcut", false)) + rc->battle_flags |= BF_RES_CUT; + if (xml_bvalue(node, "resistpierce", false)) + rc->battle_flags |= BF_RES_PIERCE; + if (xml_bvalue(node, "noattack", false)) + rc->battle_flags |= BF_NO_ATTACK; + + rc->recruit_multi = 1.0; + for (child = node->children; child; child = child->next) { + if (strcmp((const char *)child->name, "ai") == 0) { + parse_ai(rc, child); + } + else if (strcmp((const char *)child->name, "param") == 0) { + xmlChar *propName = xmlGetProp(child, BAD_CAST "name"); + xmlChar *propValue = xmlGetProp(child, BAD_CAST "value"); + rc_set_param(rc, (const char *)propName, (const char *)propValue); + xmlFree(propName); + xmlFree(propValue); + } + } + + /* reading eressea/races/race/skill */ + xpath->node = node; + result = xmlXPathEvalExpression(BAD_CAST "skill", xpath); + memset(rc->bonus, 0, sizeof(rc->bonus)); + for (k = 0; k != result->nodesetval->nodeNr; ++k) { + xmlNodePtr node = result->nodesetval->nodeTab[k]; + int mod = xml_ivalue(node, "modifier", 0); + int speed = xml_ivalue(node, "speed", study_speed_base); + + propValue = xmlGetProp(node, BAD_CAST "name"); + assert(propValue != NULL); + sk = findskill((const char *)propValue); + if (sk != NOSKILL) { + rc->bonus[sk] = (char)mod; + if (speed) { + set_study_speed(rc, sk, speed); + } + } + else { + log_error("unknown skill '%s' in race '%s'\n", (const char *)propValue, rc->_name); + } + xmlFree(propValue); + } + xmlXPathFreeObject(result); + + /* reading eressea/races/race/familiar */ + xpath->node = node; + result = xmlXPathEvalExpression(BAD_CAST "familiar", xpath); + if (result->nodesetval->nodeNr > MAXMAGIETYP) { + log_error("race %s has %d potential familiars", rc->_name, result->nodesetval->nodeNr); + } + else { + for (k = 0; k != MAXMAGIETYP; ++k) { + if (k < result->nodesetval->nodeNr) { + xmlNodePtr node = result->nodesetval->nodeTab[k]; + + propValue = xmlGetProp(node, BAD_CAST "race"); + assert(propValue != NULL); + frc = rc_get_or_create((const char *)propValue); + frc->flags |= RCF_FAMILIAR; + if (xml_bvalue(node, "default", false)) { + rc->familiars[k] = rc->familiars[0]; + rc->familiars[0] = frc; + } + else { + rc->familiars[k] = frc; + } + xmlFree(propValue); } else { rc->familiars[k] = frc; } + } + } + xmlXPathFreeObject(result); + + /* reading eressea/races/race/attack */ + xpath->node = node; + result = xmlXPathEvalExpression(BAD_CAST "attack", xpath); + attack = rc->attack; + attacks = 0; + for (k = 0; k != result->nodesetval->nodeNr; ++k) { + xmlNodePtr node = result->nodesetval->nodeTab[k]; + while (attack->type != AT_NONE) { + ++attack; + if (attacks++ >= RACE_ATTACKS) { + log_error("too many attacks for race '%s'\n", rc->_name); + assert(!"aborting"); + } + } + + propValue = xmlGetProp(node, BAD_CAST "damage"); + if (propValue != NULL) { + attack->data.dice = str_strdup((const char *)propValue); xmlFree(propValue); } else { - rc->familiars[k] = frc; - } - } - } - xmlXPathFreeObject(result); - - /* reading eressea/races/race/attack */ - xpath->node = node; - result = xmlXPathEvalExpression(BAD_CAST "attack", xpath); - attack = rc->attack; - attacks = 0; - for (k = 0; k != result->nodesetval->nodeNr; ++k) { - xmlNodePtr node = result->nodesetval->nodeTab[k]; - while (attack->type != AT_NONE) { - ++attack; - if (attacks++ >= RACE_ATTACKS) { - log_error("too many attacks for race '%s'\n", rc->_name); - assert(!"aborting"); - } - } - - propValue = xmlGetProp(node, BAD_CAST "damage"); - if (propValue != NULL) { - attack->data.dice = str_strdup((const char *)propValue); - xmlFree(propValue); - } - else { - attack->data.sp = xml_spellref(node, "spell"); - if (attack->data.sp) { - attack->level = xml_ivalue(node, "level", 0); - if (attack->level <= 0) { - log_error("magical attack '%s' for race '%s' needs a level: %d\n", attack->data.sp->name, rc->_name, attack->level); + attack->data.sp = xml_spellref(node, "spell"); + if (attack->data.sp) { + attack->level = xml_ivalue(node, "level", 0); + if (attack->level <= 0) { + log_error("magical attack '%s' for race '%s' needs a level: %d\n", attack->data.sp->name, rc->_name, attack->level); + } } } + attack->type = xml_ivalue(node, "type", 0); + attack->flags = xml_ivalue(node, "flags", 0); } - attack->type = xml_ivalue(node, "type", 0); - attack->flags = xml_ivalue(node, "flags", 0); + xmlXPathFreeObject(result); } - xmlXPathFreeObject(result); } xmlXPathFreeObject(races); xmlXPathFreeContext(xpath); - return 0; + return results; } static int parse_messages(xmlDocPtr doc) @@ -1579,7 +1595,7 @@ static int parse_messages(xmlDocPtr doc) xmlXPathContextPtr xpath; xmlXPathObjectPtr messages; xmlNodeSetPtr nodes; - int i; + int i, results; xpath = xmlXPathNewContext(doc); @@ -1587,6 +1603,7 @@ static int parse_messages(xmlDocPtr doc) messages = xmlXPathEvalExpression(BAD_CAST "/eressea/messages/message", xpath); nodes = messages->nodesetval; + results = nodes->nodeNr; for (i = 0; i != nodes->nodeNr; ++i) { xmlNodePtr node = nodes->nodeTab[i]; const char *default_section = "events"; @@ -1671,7 +1688,7 @@ static int parse_messages(xmlDocPtr doc) xmlXPathFreeObject(messages); xmlXPathFreeContext(xpath); - return 0; + return results; } static void @@ -1726,21 +1743,24 @@ static int parse_strings(xmlDocPtr doc) { xmlXPathContextPtr xpath = xmlXPathNewContext(doc); xmlXPathObjectPtr strings; + int results = 0; /* reading eressea/strings/string */ strings = xmlXPathEvalExpression(BAD_CAST "/eressea/strings/string", xpath); xml_readstrings(xpath, strings->nodesetval->nodeTab, strings->nodesetval->nodeNr, false); + results += strings->nodesetval->nodeNr; xmlXPathFreeObject(strings); strings = xmlXPathEvalExpression(BAD_CAST "/eressea/strings/namespace/string", xpath); xml_readstrings(xpath, strings->nodesetval->nodeTab, strings->nodesetval->nodeNr, true); + results += strings->nodesetval->nodeNr; xmlXPathFreeObject(strings); xmlXPathFreeContext(xpath); - return 0; + return results; } void register_xmlreader(void)