From 85cf8da383e3c229a39921b9c6292b7d09cf8f93 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 10 May 2018 20:37:37 +0200 Subject: [PATCH] rename canteach/canlearn to teach/learn race/function is never used (and there is no namedragon function). --- res/e3a/races.xml | 78 ++++++++++++++++---------------- res/eressea/races.xml | 94 +++++++++++++++++++-------------------- res/races/dragon.xml | 3 +- res/races/wyrm.xml | 1 - res/races/youngdragon.xml | 1 - src/exparse.c | 34 +++++++++++++- src/xmlreader.c | 6 +-- 7 files changed, 123 insertions(+), 94 deletions(-) diff --git a/res/e3a/races.xml b/res/e3a/races.xml index 07322d521..2fa889160 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -8,7 +8,7 @@ - + @@ -192,7 +192,7 @@ - + @@ -218,7 +218,7 @@ - + @@ -239,7 +239,7 @@ - + @@ -260,7 +260,7 @@ - + @@ -283,7 +283,7 @@ - + @@ -306,7 +306,7 @@ - + @@ -328,7 +328,7 @@ - + @@ -354,7 +354,7 @@ - + @@ -376,7 +376,7 @@ - + @@ -400,7 +400,7 @@ - + @@ -425,7 +425,7 @@ - + @@ -448,7 +448,7 @@ - + @@ -471,7 +471,7 @@ - + @@ -493,7 +493,7 @@ - + @@ -520,7 +520,7 @@ - + @@ -543,7 +543,7 @@ - + @@ -565,7 +565,7 @@ - + @@ -589,15 +589,15 @@ - + - + - + @@ -651,34 +651,34 @@ - + - + - + - + - + - + @@ -687,14 +687,14 @@ - + - + @@ -703,14 +703,14 @@ - + @@ -736,7 +736,7 @@ - + @@ -754,7 +754,7 @@ - + @@ -771,7 +771,7 @@ - + @@ -787,7 +787,7 @@ - + @@ -801,7 +801,7 @@ - + @@ -816,7 +816,7 @@ - + @@ -830,12 +830,12 @@ - + - + diff --git a/res/eressea/races.xml b/res/eressea/races.xml index 851d89de6..1acffa872 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -6,7 +6,7 @@ regaura="0" weight="500" capacity="200" equipment="no" speed="1" hp="1000" ac="4" damage="2d4" unarmedattack="10" unarmeddefense="10" attackmodifier="8" defensemodifier="8" - fly="no" walk="no" canteach="no" getitem="yes"> + fly="no" walk="no" teach="no" getitem="yes"> @@ -26,7 +26,7 @@ - + @@ -59,7 +59,7 @@ - + @@ -87,7 +87,7 @@ - + @@ -114,7 +114,7 @@ - + @@ -143,7 +143,7 @@ - + @@ -172,7 +172,7 @@ - + @@ -202,7 +202,7 @@ - + @@ -236,7 +236,7 @@ - + @@ -266,7 +266,7 @@ - + @@ -298,7 +298,7 @@ - + @@ -328,7 +328,7 @@ - + @@ -357,7 +357,7 @@ - + @@ -387,7 +387,7 @@ - + @@ -416,7 +416,7 @@ - + @@ -447,7 +447,7 @@ - + @@ -478,7 +478,7 @@ - + @@ -507,7 +507,7 @@ - + @@ -539,7 +539,7 @@ - + @@ -569,16 +569,16 @@ - + - + + regaura="1.000000" weight="100" capacity="540" speed="1.000000" hp="20" damage="0d0" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="10" scarepeasants="yes" fly="yes" walk="yes" teach="no" invinciblenonmagic="yes"> @@ -648,34 +648,34 @@ - + - + - + - + - + - + @@ -683,25 +683,25 @@ - + - + - + - + @@ -711,7 +711,7 @@ - + @@ -721,7 +721,7 @@ - + @@ -732,7 +732,7 @@ - + @@ -924,7 +924,7 @@ - + @@ -961,7 +961,7 @@ - + @@ -969,7 +969,7 @@ - + @@ -983,7 +983,7 @@ - + @@ -1000,7 +1000,7 @@ - + @@ -1016,7 +1016,7 @@ - + @@ -1031,7 +1031,7 @@ - + @@ -1044,7 +1044,7 @@ - + @@ -1058,7 +1058,7 @@ - + @@ -1071,11 +1071,11 @@ - + - + @@ -1202,7 +1202,7 @@ - + diff --git a/res/races/dragon.xml b/res/races/dragon.xml index c9692cd9b..7625b914f 100644 --- a/res/races/dragon.xml +++ b/res/races/dragon.xml @@ -3,10 +3,9 @@ - diff --git a/res/races/wyrm.xml b/res/races/wyrm.xml index df2008a80..c69ca2953 100644 --- a/res/races/wyrm.xml +++ b/res/races/wyrm.xml @@ -7,7 +7,6 @@ damage="2d60" unarmedattack="0" unarmeddefense="0" attackmodifier="10" defensemodifier="10" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes" dragon="yes" income="5000"> - diff --git a/res/races/youngdragon.xml b/res/races/youngdragon.xml index d8b3d366f..bbfdb5a9f 100644 --- a/res/races/youngdragon.xml +++ b/res/races/youngdragon.xml @@ -6,7 +6,6 @@ damage="2d15" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="4" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes" dragon="yes" income="150"> - diff --git a/src/exparse.c b/src/exparse.c index e266d55ce..943b80741 100644 --- a/src/exparse.c +++ b/src/exparse.c @@ -878,13 +878,14 @@ static void XMLCALL start_ships(parseinfo *pi, const XML_Char *el, const XML_Cha } static int nattacks; +static int nfamiliars; static void XMLCALL start_races(parseinfo *pi, const XML_Char *el, const XML_Char **attr) { race *rc = (race *)pi->object; const char *flag_names[] = { "!playerrace", "killpeasants", "scarepeasants", "!cansteal", "moverandom", "cannotmove", "learn", "fly", "swim", "walk", - "!canlearn", "!canteach", "horse", "desert", "illusionary", + "!learn", "!teach", "horse", "desert", "illusionary", "absorbpeasants", "noheal", "noweapons", "shapeshift", "shapeshiftany", "undead", "dragon", "coastal", "unarmedguard", "cansail", "invisible", "shipspeed", "moveattack", "migrants", NULL }; @@ -922,10 +923,31 @@ static void XMLCALL start_races(parseinfo *pi, const XML_Char *el, const XML_Cha else if (xml_strcmp(key, "spell") == 0) { at->data.sp = spellref_create(NULL, val); } + else { + handle_bad_input(pi, el, key); + } } } else if (xml_strcmp(el, "familiar") == 0) { + race *frc = NULL; + int i; + assert(rc); + for (i = 0; attr[i]; i += 2) { + const XML_Char *key = attr[i], *val = attr[i + 1]; + if (xml_strcmp(key, "race") == 0) { + frc = rc_get_or_create(val); + frc->flags |= RCF_FAMILIAR; + } + else { + handle_bad_input(pi, el, key); + } + } + if (frc) { + if (nfamiliars < MAXMAGIETYP) { + rc->familiars[nfamiliars++] = frc; + } + } } else if (xml_strcmp(el, "skill") == 0) { const XML_Char *name = NULL; @@ -983,6 +1005,9 @@ static void XMLCALL start_races(parseinfo *pi, const XML_Char *el, const XML_Cha else if (xml_strcmp(el, "race") == 0) { const XML_Char *name; + nfamiliars = 0; + nattacks = 0; + name = attr_get(attr, "name"); if (name) { assert(!rc); @@ -1279,6 +1304,13 @@ static void end_races(parseinfo *pi, const XML_Char *el) { assert(rc); rc->attack[nattacks].type = AT_NONE; nattacks = 0; + if (nfamiliars > 0 && nfamiliars < MAXMAGIETYP) { + int i; + for (i = nfamiliars - 1; i != MAXMAGIETYP; ++i) { + rc->familiars[i] = rc->familiars[nfamiliars - 1]; + } + } + nfamiliars = 0; pi->object = NULL; } else if (xml_strcmp(el, "races") == 0) { diff --git a/src/xmlreader.c b/src/xmlreader.c index 53a8c1365..cf63a3ccb 100644 --- a/src/xmlreader.c +++ b/src/xmlreader.c @@ -1326,11 +1326,11 @@ static int parse_races(xmlDocPtr doc) 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, "canteach", true)) + if (!xml_bvalue(node, "teach", true)) rc->flags |= RCF_NOTEACH; if (!xml_bvalue(node, "cansteal", true)) rc->flags |= RCF_NOSTEAL; - if (!xml_bvalue(node, "canlearn", true)) + if (!xml_bvalue(node, "learn", true)) rc->flags |= RCF_NOLEARN; if (!xml_bvalue(node, "playerrace", false)) { assert(rc->recruitcost == 0); @@ -1695,8 +1695,8 @@ void register_xmlreader(void) xml_register_callback(parse_ships); xml_register_callback(parse_spellbooks); xml_register_callback(parse_spells); -#endif xml_register_callback(parse_races); +#endif xml_register_callback(parse_equipment);