From 2e9e7f1e237e36213edeeae84e47a15573f26981 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 6 May 2005 22:30:19 +0000 Subject: [PATCH] =?UTF-8?q?Implemented=20BSD=20string.h=20extensions=20(st?= =?UTF-8?q?rlcat,=20strlcpy).=20Big=20items=20in=20astral=20space=20crumbl?= =?UTF-8?q?e=20(disabled=20by=20define).=20Chaossog=20verursacht=203/4=20S?= =?UTF-8?q?chaden=20beim=20durchgehen=20(ungetestet).=20=C3=9Cberladeschut?= =?UTF-8?q?z=20bei=20Schiffen=20abgeschaltet.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/gamecode/laws.c | 32 +++++++ src/common/gamecode/monster.c | 15 ---- src/common/gamecode/monster.h | 1 - src/common/gamecode/report.c | 150 ++++++++++++++++----------------- src/common/kernel/eressea.h | 1 - src/common/kernel/item.c | 8 +- src/common/kernel/reports.c | 111 ++++++++++++------------ src/common/kernel/spell.c | 40 ++++++++- src/common/kernel/spell.h | 3 +- src/common/settings-eressea.h | 7 +- src/common/settings-tutorial.h | 6 +- src/common/util/Jamfile | 1 + src/common/util/bsdstring.c | 61 ++++++++++++++ src/common/util/bsdstring.h | 13 +++ src/common/util/util.vcproj | 3 + src/config.h | 3 + src/eressea/korrektur.c | 25 ++++++ src/res/eressea.xml | 4 +- 18 files changed, 319 insertions(+), 165 deletions(-) create mode 100644 src/common/util/bsdstring.c create mode 100644 src/common/util/bsdstring.h diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 23c74310d..64de0c9f9 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -295,6 +295,38 @@ get_food(region *r) } } +static void +age_unit(region * r, unit * u) +{ + if (u->race == new_race[RC_SPELL]) { + if (--u->age <= 0) { + destroy_unit(u); + } + } else { + ++u->age; + if (u->race->age) { + u->race->age(u); + } + } + +#ifdef ASTRAL_ITEM_RESTRICTIONS + if (u->region->planep==astral_plane) { + item ** itemp = &u->items; + while (*itemp) { + item * itm = *itemp; + if (itm->type->flags & ITF_NOTLOST == 0) { + if (itm->type->flags & (ITF_BIG|ITF_ANIMAL|ITF_CURSED)) { + i_free(i_remove(itemp, itm)); + continue; + } + } + itemp=&itm->next; + } + } +#endif +} + + static void live(region * r) { diff --git a/src/common/gamecode/monster.c b/src/common/gamecode/monster.c index a6c91f1fb..47aba2dbc 100644 --- a/src/common/gamecode/monster.c +++ b/src/common/gamecode/monster.c @@ -986,18 +986,3 @@ plan_monsters(void) } } } - -void -age_unit(region * r, unit * u) -{ - if (u->race == new_race[RC_SPELL]) { - if (--u->age <= 0) { - destroy_unit(u); - } - } else { - ++u->age; - if (u->race->age) { - u->race->age(u); - } - } -} diff --git a/src/common/gamecode/monster.h b/src/common/gamecode/monster.h index 9c4a98122..e13c84d84 100644 --- a/src/common/gamecode/monster.h +++ b/src/common/gamecode/monster.h @@ -31,7 +31,6 @@ void age_illusion(struct unit *u); void monsters_kill_peasants(void); void plan_monsters(void); -void age_unit(struct region * r, struct unit * u); struct unit *random_unit(const struct region * r); #ifdef __cplusplus diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index 91887eb99..88bb538cf 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -109,7 +109,7 @@ char *agename; int seasons; static size_t -strlcpy(char * dst, const char * src) { +strxcpy(char * dst, const char * src) { size_t s = 0; while ((*dst++ = *src++)!=0) ++s; return s; @@ -477,13 +477,13 @@ report_spell(FILE * F, spellid_t id, const struct locale * lang) bufp = strcpy(buf, "Art: "); if (sp->sptyp & PRECOMBATSPELL) { - bufp += strlcpy(bufp, "Präkampfzauber"); + bufp += strxcpy(bufp, "Präkampfzauber"); } else if (sp->sptyp & COMBATSPELL) { - bufp += strlcpy(bufp, "Kampfzauber"); + bufp += strxcpy(bufp, "Kampfzauber"); } else if (sp->sptyp & POSTCOMBATSPELL) { - bufp += strlcpy(bufp, "Postkampfzauber"); + bufp += strxcpy(bufp, "Postkampfzauber"); } else { - bufp += strlcpy(bufp, "Normaler Zauber"); + bufp += strxcpy(bufp, "Normaler Zauber"); } rps(F, buf); @@ -497,7 +497,7 @@ report_spell(FILE * F, spellid_t id, const struct locale * lang) if (sp->sptyp & SPELLLEVEL) { bufp = buf + sprintf(buf, " %d %s", itemanz, LOC(lang, resname(res, itemanz!=1))); if (costtyp == SPC_LEVEL || costtyp == SPC_LINEAR ) { - bufp += strlcpy(bufp, " * Stufe"); + bufp += strxcpy(bufp, " * Stufe"); } } else { if (costtyp == SPC_LEVEL || costtyp == SPC_LINEAR ) { @@ -509,35 +509,35 @@ report_spell(FILE * F, spellid_t id, const struct locale * lang) } } - bufp = buf + strlcpy(buf, "Modifikationen: "); + bufp = buf + strxcpy(buf, "Modifikationen: "); if (sp->sptyp & FARCASTING) { - bufp += strlcpy(bufp, "Fernzauber"); + bufp += strxcpy(bufp, "Fernzauber"); dh = 1; } if (sp->sptyp & OCEANCASTABLE) { if (dh == 1){ - bufp += strlcpy(bufp, ", "); + bufp += strxcpy(bufp, ", "); } - bufp += strlcpy(bufp, "Seezauber"); + bufp += strxcpy(bufp, "Seezauber"); dh = 1; } if (sp->sptyp & ONSHIPCAST) { if (dh == 1){ - bufp += strlcpy(bufp, ", "); + bufp += strxcpy(bufp, ", "); } - bufp += strlcpy(bufp, "Schiffszauber"); + bufp += strxcpy(bufp, "Schiffszauber"); dh = 1; } if (sp->sptyp & NOTFAMILIARCAST) { if (dh == 1){ - bufp += strlcpy(bufp, ", k"); + bufp += strxcpy(bufp, ", k"); } else { - bufp += strlcpy(bufp, "K"); + bufp += strxcpy(bufp, "K"); } - bufp += strlcpy(bufp, "ann nicht vom Vertrauten gezaubert werden"); + bufp += strxcpy(bufp, "ann nicht vom Vertrauten gezaubert werden"); dh = 1; } - if(dh == 0) bufp += strlcpy(bufp, "Keine"); + if(dh == 0) bufp += strxcpy(bufp, "Keine"); rps(F, buf); @@ -553,39 +553,39 @@ report_spell(FILE * F, spellid_t id, const struct locale * lang) if (!sp->syntax) { if (sp->sptyp & ISCOMBATSPELL) { - bufp = buf + strlcpy(buf, "KAMPFZAUBER "); + bufp = buf + strxcpy(buf, "KAMPFZAUBER "); } else { - bufp = buf + strlcpy(buf, "ZAUBERE "); + bufp = buf + strxcpy(buf, "ZAUBERE "); } /* Reihenfolge beachten: Erst REGION, dann STUFE! */ if (sp->sptyp & FARCASTING) { - bufp += strlcpy(bufp, "[REGION x y] "); + bufp += strxcpy(bufp, "[REGION x y] "); } if (sp->sptyp & SPELLLEVEL) { - bufp += strlcpy(bufp, "[STUFE n] "); + bufp += strxcpy(bufp, "[STUFE n] "); } - bufp += strlcpy(bufp, "\""); - bufp += strlcpy(bufp, spell_name(sp, lang)); - bufp += strlcpy(bufp, "\" "); + bufp += strxcpy(bufp, "\""); + bufp += strxcpy(bufp, spell_name(sp, lang)); + bufp += strxcpy(bufp, "\" "); if (sp->sptyp & ONETARGET){ if (sp->sptyp & UNITSPELL) { - bufp += strlcpy(bufp, ""); + bufp += strxcpy(bufp, ""); } else if (sp->sptyp & SHIPSPELL) { - bufp += strlcpy(bufp, ""); + bufp += strxcpy(bufp, ""); } else if (sp->sptyp & BUILDINGSPELL) { - bufp += strlcpy(bufp, ""); + bufp += strxcpy(bufp, ""); } } else { if (sp->sptyp & UNITSPELL) { - bufp += strlcpy(bufp, " [ ...]"); + bufp += strxcpy(bufp, " [ ...]"); } else if (sp->sptyp & SHIPSPELL) { - bufp += strlcpy(bufp, " [ ...]"); + bufp += strxcpy(bufp, " [ ...]"); } else if (sp->sptyp & BUILDINGSPELL) { - bufp += strlcpy(bufp, " [ ...]"); + bufp += strxcpy(bufp, " [ ...]"); } } } else { - bufp += strlcpy(bufp, sp->syntax); + bufp += strxcpy(bufp, sp->syntax); } rps(F, buf); rnl(F); @@ -996,9 +996,9 @@ prices(FILE * F, const region * r, const faction * f) if (n > 0) { char * bufp = buf + strlen(buf); - bufp += strlcpy(bufp, " "); - bufp += strlcpy(bufp, LOC(f->locale, "nr_trade_intro")); - bufp += strlcpy(bufp, " "); + bufp += strxcpy(bufp, " "); + bufp += strxcpy(bufp, LOC(f->locale, "nr_trade_intro")); + bufp += strxcpy(bufp, " "); for (dmd=r->land->demands;dmd;dmd=dmd->next) if(dmd->value > 0) { m = msg_message("nr_market_price", "product price", @@ -1008,14 +1008,14 @@ prices(FILE * F, const region * r, const faction * f) n--; bufp += strlen(bufp); if (n == 0) { - bufp += strlcpy(bufp, LOC(f->locale, "nr_trade_end")); + bufp += strxcpy(bufp, LOC(f->locale, "nr_trade_end")); } else if (n == 1) { strcpy(bufp++, " "); - bufp += strlcpy(bufp, LOC(f->locale, "nr_trade_final")); + bufp += strxcpy(bufp, LOC(f->locale, "nr_trade_final")); strcpy(bufp++, " "); } else { - bufp += strlcpy(bufp, LOC(f->locale, "nr_trade_next")); + bufp += strxcpy(bufp, LOC(f->locale, "nr_trade_next")); strcpy(bufp++, " "); } } @@ -1134,27 +1134,27 @@ describe(FILE * F, const region * r, int partial, faction * f) } } - bufp += strlcpy(bufp, f_regionid(r, f)); + bufp += strxcpy(bufp, f_regionid(r, f)); if (partial == 1) { - bufp += strlcpy(bufp, " (durchgereist)"); + bufp += strxcpy(bufp, " (durchgereist)"); } else if (partial == 3) { - bufp += strlcpy(bufp, " (benachbart)"); + bufp += strxcpy(bufp, " (benachbart)"); } else if (partial == 2) { - bufp += strlcpy(bufp, " (vom Turm erblickt)"); + bufp += strxcpy(bufp, " (vom Turm erblickt)"); } /* Terrain */ - bufp += strlcpy(bufp, ", "); + bufp += strxcpy(bufp, ", "); if(is_cursed(r->attribs,C_MAELSTROM, 0)) tname = "maelstrom"; else { if (r_isforest(r)) tname = "forest"; else tname = terrain[rterrain(r)].name; } - bufp += strlcpy(bufp, LOC(f->locale, tname)); + bufp += strxcpy(bufp, LOC(f->locale, tname)); /* Bäume */ @@ -1166,14 +1166,14 @@ describe(FILE * F, const region * r, int partial, faction * f) bufp += sprintf(bufp, ", %d/%d ", trees, ytrees); if (fval(r, RF_MALLORN)) { if (trees == 1) - bufp += strlcpy(bufp, LOC(f->locale, "nr_mallorntree")); + bufp += strxcpy(bufp, LOC(f->locale, "nr_mallorntree")); else - bufp += strlcpy(bufp, LOC(f->locale, "nr_mallorntree_p")); + bufp += strxcpy(bufp, LOC(f->locale, "nr_mallorntree_p")); } else if (trees == 1) - bufp += strlcpy(bufp, LOC(f->locale, "nr_tree")); + bufp += strxcpy(bufp, LOC(f->locale, "nr_tree")); else - bufp += strlcpy(bufp, LOC(f->locale, "nr_tree_p")); + bufp += strxcpy(bufp, LOC(f->locale, "nr_tree_p")); } } #else @@ -1182,14 +1182,14 @@ describe(FILE * F, const region * r, int partial, faction * f) bufp += sprintf(bufp, ", %d ", trees); if (fval(r, RF_MALLORN)) { if (trees == 1) - bufp += strlcpy(bufp, LOC(f->locale, "nr_mallorntree")); + bufp += strxcpy(bufp, LOC(f->locale, "nr_mallorntree")); else - bufp += strlcpy(bufp, LOC(f->locale, "nr_mallorntree_p")); + bufp += strxcpy(bufp, LOC(f->locale, "nr_mallorntree_p")); } else if (trees == 1) - bufp += strlcpy(bufp, LOC(f->locale, "nr_tree")); + bufp += strxcpy(bufp, LOC(f->locale, "nr_tree")); else - bufp += strlcpy(bufp, LOC(f->locale, "nr_tree_p")); + bufp += strxcpy(bufp, LOC(f->locale, "nr_tree_p")); } #endif @@ -1251,15 +1251,15 @@ describe(FILE * F, const region * r, int partial, faction * f) if(fval(r, RF_ORCIFIED)) { strcpy(bufp++, " "); - bufp += strlcpy(bufp, LOC(f->locale, rpeasants(r)==1?"rc_orc":"rc_orc_p")); + bufp += strxcpy(bufp, LOC(f->locale, rpeasants(r)==1?"rc_orc":"rc_orc_p")); } else { strcpy(bufp++, " "); - bufp += strlcpy(bufp, LOC(f->locale, resourcename(oldresourcetype[R_PEASANTS], rpeasants(r)!=1))); + bufp += strxcpy(bufp, LOC(f->locale, resourcename(oldresourcetype[R_PEASANTS], rpeasants(r)!=1))); } if (rmoney(r) && partial == 0) { bufp += sprintf(bufp, ", %d ", rmoney(r)); - bufp += strlcpy(bufp, LOC(f->locale, resourcename(oldresourcetype[R_SILVER], rmoney(r)!=1))); + bufp += strxcpy(bufp, LOC(f->locale, resourcename(oldresourcetype[R_SILVER], rmoney(r)!=1))); } } /* Pferde */ @@ -1267,16 +1267,16 @@ describe(FILE * F, const region * r, int partial, faction * f) if (rhorses(r)) { bufp += sprintf(bufp, ", %d ", rhorses(r)); #ifdef NEW_ITEMS - bufp += strlcpy(bufp, LOC(f->locale, resourcename(oldresourcetype[R_HORSE], (rhorses(r)>1)?GR_PLURAL:0))); + bufp += strxcpy(bufp, LOC(f->locale, resourcename(oldresourcetype[R_HORSE], (rhorses(r)>1)?GR_PLURAL:0))); #else - bufp += strlcpy(bufp, itemdata[I_HORSE].name[rhorses(r) > 1]); + bufp += strxcpy(bufp, itemdata[I_HORSE].name[rhorses(r) > 1]); #endif } strcpy(bufp++, "."); if (r->display && r->display[0]) { strcpy(bufp++, " "); - bufp += strlcpy(bufp, r->display); + bufp += strxcpy(bufp, r->display); n = r->display[strlen(r->display) - 1]; if (n != '!' && n != '?' && n != '.') @@ -1286,8 +1286,8 @@ describe(FILE * F, const region * r, int partial, faction * f) { const unit * u = region_owner(r); if (u) { - bufp += strlcpy(bufp, " Die Region ist im Besitz von "); - bufp += strlcpy(bufp, factionname(u->faction)); + bufp += strxcpy(bufp, " Die Region ist im Besitz von "); + bufp += strxcpy(bufp, factionname(u->faction)); strcpy(bufp++, "."); } } @@ -1296,7 +1296,7 @@ describe(FILE * F, const region * r, int partial, faction * f) attrib *a_do = a_find(r->attribs, &at_overrideroads); if(a_do) { strcpy(bufp++, " "); - bufp += strlcpy(bufp, (char *)a_do->data.v); + bufp += strxcpy(bufp, (char *)a_do->data.v); } else { int nrd = 0; @@ -1314,11 +1314,11 @@ describe(FILE * F, const region * r, int partial, faction * f) if (dh) { if (nrd == 0) { strcpy(bufp++, " "); - bufp += strlcpy(bufp, LOC(f->locale, "nr_nb_final")); + bufp += strxcpy(bufp, LOC(f->locale, "nr_nb_final")); } else { - bufp += strlcpy(bufp, LOC(f->locale, "nr_nb_next")); + bufp += strxcpy(bufp, LOC(f->locale, "nr_nb_next")); } - bufp += strlcpy(bufp, LOC(f->locale, directions[d])); + bufp += strxcpy(bufp, LOC(f->locale, directions[d])); strcpy(bufp++, " "); bufp += sprintf(bufp, trailinto(r2, f->locale), f_regionid(r2, f)); @@ -1334,17 +1334,17 @@ describe(FILE * F, const region * r, int partial, faction * f) for (a = a_find(r->attribs, &at_direction);a;a = a->nexttype) { spec_direction * d = (spec_direction *)(a->data.v); strcpy(bufp++, " "); - bufp += strlcpy(bufp, d->desc); - bufp += strlcpy(bufp, " (\""); - bufp += strlcpy(bufp, d->keyword); - bufp += strlcpy(bufp, "\")"); + bufp += strxcpy(bufp, d->desc); + bufp += strxcpy(bufp, " (\""); + bufp += strxcpy(bufp, d->keyword); + bufp += strxcpy(bufp, "\")"); strcpy(bufp++, "."); dh = 1; } if (dh) strcpy(bufp++, "."); } } else { - bufp += strlcpy(bufp, " Große Verwirrung befällt alle Reisenden in dieser Region."); + bufp += strxcpy(bufp, " Große Verwirrung befällt alle Reisenden in dieser Region."); } rnl(F); rparagraph(F, buf, 0, 0); @@ -1389,18 +1389,18 @@ describe(FILE * F, const region * r, int partial, faction * f) boolean first = true; for (d=0;d!=MAXDIRECTIONS;++d) { if (!e->exist[d]) continue; - if (first) bufp += strlcpy(bufp, "Im "); + if (first) bufp += strxcpy(bufp, "Im "); else { - if (e->lastd==d) bufp += strlcpy(bufp, " und im "); - else bufp += strlcpy(bufp, ", im "); + if (e->lastd==d) bufp += strxcpy(bufp, " und im "); + else bufp += strxcpy(bufp, ", im "); } - bufp += strlcpy(bufp, LOC(f->locale, directions[d])); + bufp += strxcpy(bufp, LOC(f->locale, directions[d])); first = false; } - if (!e->transparent) bufp += strlcpy(bufp, " versperrt "); - else bufp += strlcpy(bufp, " befindet sich "); - bufp += strlcpy(bufp, e->name); - if (!e->transparent) bufp += strlcpy(bufp, " die Sicht."); + if (!e->transparent) bufp += strxcpy(bufp, " versperrt "); + else bufp += strxcpy(bufp, " befindet sich "); + bufp += strxcpy(bufp, e->name); + if (!e->transparent) bufp += strxcpy(bufp, " die Sicht."); else strcpy(bufp++, "."); rparagraph(F, buf, 0, 0); } diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index 1c15523c3..a8f68a5c7 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -100,7 +100,6 @@ struct building_type; #define NEW_RECEIPIES /* Vereinfachte, besser verteilte Kräuterzutaten für Tränke */ #define GOBLINKILL -#define USE_FIREWALL 1 #undef COMPATIBILITY #define MONSTER_FACTION 0 /* Die Partei, in der die Monster sind. */ diff --git a/src/common/kernel/item.c b/src/common/kernel/item.c index 78f6a81cc..075df67c2 100644 --- a/src/common/kernel/item.c +++ b/src/common/kernel/item.c @@ -1159,15 +1159,15 @@ static t_item itemdata[MAXITEMS] = { }, { /* I_PEGASUS 60 */ {"Pegasus", "Pegasi", "Pegasus", "Pegasi" }, G_M, - IS_MAGIC, 0, 0, {0, 0, 0, 0, 0, 0}, 5000, 0, FL_ITEM_ANIMAL | FL_ITEM_NOTINBAG, NULL + IS_MAGIC, 0, 0, {0, 0, 0, 0, 0, 0}, 5000, 0, FL_ITEM_ANIMAL | FL_ITEM_NOTINBAG | FL_ITEM_NOTLOST, NULL }, { /* I_UNICORN 61 */ {"Elfenpferd", "Elfenpferde", "Elfenpferd", "Elfenpferde"}, G_N, - IS_MAGIC, 0, 0, {0, 0, 0, 0, 0, 0}, 5000, 0, FL_ITEM_ANIMAL | FL_ITEM_NOTINBAG, NULL + IS_MAGIC, 0, 0, {0, 0, 0, 0, 0, 0}, 5000, 0, FL_ITEM_ANIMAL | FL_ITEM_NOTINBAG | FL_ITEM_NOTLOST, NULL }, { /* I_DOLPHIN 62 */ {"Delphin", "Delphine", "Delphin", "Delphine"}, G_M, - IS_MAGIC, 0, 0, {0, 0, 0, 0, 0, 0}, 5000, 0, FL_ITEM_ANIMAL | FL_ITEM_NOTINBAG, NULL + IS_MAGIC, 0, 0, {0, 0, 0, 0, 0, 0}, 5000, 0, FL_ITEM_ANIMAL | FL_ITEM_NOTINBAG | FL_ITEM_NOTLOST, NULL }, { /* I_ANTIMAGICCRYSTAL 63 */ {"Antimagiekristall", "Antimagiekristalle", "Amulett", "Amulette"}, G_M, @@ -1216,7 +1216,7 @@ static t_item itemdata[MAXITEMS] = { }, { {"Zauberbeutel", "Zauberbeutel", "Zauberbeutel", "Zauberbeutel"}, G_M, - IS_MAGIC, 0, 0, {0, 0, 0, 0, 0, 0}, 100, 0, FL_ITEM_NOTINBAG, NULL + IS_MAGIC, 0, 0, {0, 0, 0, 0, 0, 0}, 100, 0, FL_ITEM_NOTINBAG|FL_ITEM_NOTLOST, NULL }, { /* I_RUSTY_SWORD */ {"Schartiges Schwert", "Schartige Schwerter", "Schartiges Schwert", "Schartige Schwerter"}, G_N, diff --git a/src/common/kernel/reports.c b/src/common/kernel/reports.c index 575f997cd..1ea5be4bf 100644 --- a/src/common/kernel/reports.c +++ b/src/common/kernel/reports.c @@ -56,14 +56,9 @@ #include #include -const char * g_reportdir; +#include -static size_t -strlcpy(char * dst, const char * src) { - size_t s = 0; - while ((*dst++ = *src++)!=0) ++s; - return s; -} +const char * g_reportdir; const char *neue_gebiete[] = { "none", @@ -191,7 +186,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode) if (fspecial(u->faction, FS_HIDDEN)) a_fshidden = a_find(u->attribs, &at_fshidden); - bufp += strlcpy(bufp, unitname(u)); + bufp += strlcpy(bufp, unitname(u), sizeof(buf)); if (!isbattle) { attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction); @@ -199,30 +194,30 @@ bufunit(const faction * f, const unit * u, int indent, int mode) attrib *a = a_find(u->attribs, &at_group); if (a) { group * g = (group*)a->data.v; - bufp += strlcpy(bufp, ", "); - bufp += strlcpy(bufp, groupid(g, f)); + bufp += strlcpy(bufp, ", ", sizeof(buf)-(bufp-buf)); + bufp += strlcpy(bufp, groupid(g, f), sizeof(buf)-(bufp-buf)); } if (getarnt) { - bufp += strlcpy(bufp, ", "); - bufp += strlcpy(bufp, LOC(f->locale, "anonymous")); + bufp += strlcpy(bufp, ", ", sizeof(buf)-(bufp-buf)); + bufp += strlcpy(bufp, LOC(f->locale, "anonymous"), sizeof(buf)-(bufp-buf)); } else if (a_otherfaction) { faction * otherfaction = get_otherfaction(a_otherfaction); if (otherfaction) { - bufp += strlcpy(bufp, ", "); - bufp += strlcpy(bufp, factionname(otherfaction)); + bufp += strlcpy(bufp, ", ", sizeof(buf)-(bufp-buf)); + bufp += strlcpy(bufp, factionname(otherfaction), sizeof(buf)-(bufp-buf)); } } } else { if (getarnt) { - bufp += strlcpy(bufp, ", "); - bufp += strlcpy(bufp, LOC(f->locale, "anonymous")); + bufp += strlcpy(bufp, ", ", sizeof(buf)-(bufp-buf)); + bufp += strlcpy(bufp, LOC(f->locale, "anonymous"), sizeof(buf)-(bufp-buf)); } else { if (a_otherfaction && alliedunit(u, f, HELP_FSTEALTH)) { faction * f = get_otherfaction(a_otherfaction); bufp += sprintf(bufp, ", %s (%s)", factionname(f), factionname(u->faction)); } else { - bufp += strlcpy(bufp, ", "); - bufp += strlcpy(bufp, factionname(fv)); + bufp += strlcpy(bufp, ", ", sizeof(buf)-(bufp-buf)); + bufp += strlcpy(bufp, factionname(fv), sizeof(buf)-(bufp-buf)); } } } @@ -235,15 +230,15 @@ bufunit(const faction * f, const unit * u, int indent, int mode) if (is_ugroupleader(u, ug)) { strcpy(bufp++, "*"); } - bufp += strlcpy(bufp, itoa36(ug->id)); + bufp += strlcpy(bufp, itoa36(ug->id), sizeof(buf)-(bufp-buf)); } } #endif - bufp += strlcpy(bufp, ", "); + bufp += strlcpy(bufp, ", ", sizeof(buf)-(bufp-buf)); if (u->faction != f && a_fshidden && a_fshidden->data.ca[0] == 1 && effskill(u, SK_STEALTH) >= 6) { - bufp += strlcpy(bufp, "? "); + bufp += strlcpy(bufp, "? ", sizeof(buf)-(bufp-buf)); } else { bufp += sprintf(bufp, "%d ", u->number); } @@ -252,56 +247,56 @@ bufunit(const faction * f, const unit * u, int indent, int mode) if (pzTmp) { scat(pzTmp); if (u->faction==f && fval(u->race, RCF_SHAPESHIFTANY)) { - bufp += strlcpy(bufp, " ("); - bufp += strlcpy(bufp, racename(f->locale, u, u->race)); + bufp += strlcpy(bufp, " (", sizeof(buf)-(bufp-buf)); + bufp += strlcpy(bufp, racename(f->locale, u, u->race), sizeof(buf)-(bufp-buf)); strcpy(bufp++, ")"); } } else { - bufp += strlcpy(bufp, racename(f->locale, u, u->irace)); + bufp += strlcpy(bufp, racename(f->locale, u, u->irace), sizeof(buf)-(bufp-buf)); if (u->faction==f && u->irace!=u->race) { - bufp += strlcpy(bufp, " ("); - bufp += strlcpy(bufp, racename(f->locale, u, u->race)); + bufp += strlcpy(bufp, " (", sizeof(buf)-(bufp-buf)); + bufp += strlcpy(bufp, racename(f->locale, u, u->race), sizeof(buf)-(bufp-buf)); strcpy(bufp++, ")"); } } #ifdef HEROES if (fval(u, UFL_HERO) && (u->faction == f || omniscient(f))) { - bufp += strlcpy(bufp, ", "); - bufp += strlcpy(bufp, LOC(f->locale, "hero")); + bufp += strlcpy(bufp, ", ", sizeof(buf)-(bufp-buf)); + bufp += strlcpy(bufp, LOC(f->locale, "hero"), sizeof(buf)-(bufp-buf)); } #endif /* status */ if (u->number && (u->faction == f || telepath_see || isbattle)) { const char * c = locale_string(f->locale, hp_status(u)); - bufp += strlcpy(bufp, ", "); - bufp += strlcpy(bufp, report_kampfstatus(u, f->locale)); + bufp += strlcpy(bufp, ", ", sizeof(buf)-(bufp-buf)); + bufp += strlcpy(bufp, report_kampfstatus(u, f->locale), sizeof(buf)-(bufp-buf)); if (c || fval(u, UFL_HUNGER)) { - bufp += strlcpy(bufp, " ("); - if (c) bufp += strlcpy(bufp, c); + bufp += strlcpy(bufp, " (", sizeof(buf)-(bufp-buf)); + if (c) bufp += strlcpy(bufp, c, sizeof(buf)-(bufp-buf)); if (fval(u, UFL_HUNGER)) { - if (c) bufp += strlcpy(bufp, ", hungert"); - else bufp += strlcpy(bufp, "hungert"); + if (c) bufp += strlcpy(bufp, ", hungert", sizeof(buf)-(bufp-buf)); + else bufp += strlcpy(bufp, "hungert", sizeof(buf)-(bufp-buf)); } strcpy(bufp++, ")"); } } - if (getguard(u)) bufp += strlcpy(bufp, ", bewacht die Region"); + if (getguard(u)) bufp += strlcpy(bufp, ", bewacht die Region", sizeof(buf)-(bufp-buf)); if (u->faction==f || telepath_see) { attrib * a = a_find(u->attribs, &at_follow); if (a) { unit * uf = (unit*)a->data.v; if (uf) { - bufp += strlcpy(bufp, ", folgt "); - bufp += strlcpy(bufp, itoa36(uf->no)); + bufp += strlcpy(bufp, ", folgt ", sizeof(buf)-(bufp-buf)); + bufp += strlcpy(bufp, itoa36(uf->no), sizeof(buf)-(bufp-buf)); } } } if ((b = usiege(u))!=NULL) { - bufp += strlcpy(bufp, ", belagert "); - bufp += strlcpy(bufp, buildingname(b)); + bufp += strlcpy(bufp, ", belagert ", sizeof(buf)-(bufp-buf)); + bufp += strlcpy(bufp, buildingname(b), sizeof(buf)-(bufp-buf)); } dh = 0; @@ -347,14 +342,14 @@ bufunit(const faction * f, const unit * u, int indent, int mode) int in; report_item(u, itm, f, &ic, NULL, &in, false); if (in==0 || ic==NULL) continue; - bufp += strlcpy(bufp, ", "); + bufp += strlcpy(bufp, ", ", sizeof(buf)-(bufp-buf)); if (!dh) { bufp += sprintf(bufp, "%s: ", LOC(f->locale, "nr_inventory")); dh = 1; } if (in == 1) { - bufp += strlcpy(bufp, ic); + bufp += strlcpy(bufp, ic, sizeof(buf)-(bufp-buf)); } else { bufp += sprintf(bufp, "%d %s", in, ic); } @@ -377,9 +372,9 @@ bufunit(const faction * f, const unit * u, int indent, int mode) bufp += sprintf(bufp, ", %s: ", LOC(f->locale, "nr_spells")); dh = 1; } else { - bufp += strlcpy(bufp, ", "); + bufp += strlcpy(bufp, ", ", sizeof(buf)-(bufp-buf)); } - bufp += strlcpy(bufp, spell_name(sp, f->locale)); + bufp += strlcpy(bufp, spell_name(sp, f->locale), sizeof(buf)-(bufp-buf)); } } dh = 0; @@ -396,17 +391,17 @@ bufunit(const faction * f, const unit * u, int indent, int mode) if (!dh){ dh = 1; } else { - bufp += strlcpy(bufp, ", "); + bufp += strlcpy(bufp, ", ", sizeof(buf)-(bufp-buf)); } sp = get_combatspell(u,i); if (sp) { int sl; - bufp += strlcpy(bufp, spell_name(sp, u->faction->locale)); + bufp += strlcpy(bufp, spell_name(sp, u->faction->locale), sizeof(buf)-(bufp-buf)); if ((sl = get_combatspelllevel(u,i)) > 0) { bufp += sprintf(bufp, " (%d)", sl); } } else { - bufp += strlcpy(bufp, LOC(f->locale, "nr_nospells")); + bufp += strlcpy(bufp, LOC(f->locale, "nr_nospells"), sizeof(buf)-(bufp-buf)); } } } @@ -414,8 +409,8 @@ bufunit(const faction * f, const unit * u, int indent, int mode) #ifdef LASTORDER if (!isbattle && u->lastorder) { char * cmd = getcommand(u->lastorder); - bufp += strlcpy(bufp, ", \""); - bufp += strlcpy(bufp, cmd); + bufp += strlcpy(bufp, ", \"", sizeof(buf)-(bufp-buf)); + bufp += strlcpy(bufp, cmd, sizeof(buf)-(bufp-buf)); strcpy(bufp++, "\""); free(cmd); } @@ -424,8 +419,8 @@ bufunit(const faction * f, const unit * u, int indent, int mode) i = 0; if (u->display && u->display[0]) { - bufp += strlcpy(bufp, "; "); - bufp += strlcpy(bufp, u->display); + bufp += strlcpy(bufp, "; ", sizeof(buf)-(bufp-buf)); + bufp += strlcpy(bufp, u->display, sizeof(buf)-(bufp-buf)); i = u->display[strlen(u->display) - 1]; } @@ -434,9 +429,9 @@ bufunit(const faction * f, const unit * u, int indent, int mode) pzTmp = uprivate(u); if (u->faction == f && pzTmp) { - bufp += strlcpy(bufp, " (Bem: "); - bufp += strlcpy(bufp, pzTmp); - bufp += strlcpy(bufp, ")"); + bufp += strlcpy(bufp, " (Bem: ", sizeof(buf)-(bufp-buf)); + bufp += strlcpy(bufp, pzTmp, sizeof(buf)-(bufp-buf)); + bufp += strlcpy(bufp, ")", sizeof(buf)-(bufp-buf)); } dh=0; @@ -611,19 +606,19 @@ spskill(char * buffer, const struct locale * lang, const struct unit * u, skill_ if (!has_skill(u, sk)) return 0; - pbuf += strlcpy(pbuf, ", "); + pbuf += strlcpy(pbuf, ", ", sizeof(buf)); if (!*dh) { - pbuf += strlcpy(pbuf, LOC(lang, "nr_skills")); - pbuf += strlcpy(pbuf, ": "); + pbuf += strlcpy(pbuf, LOC(lang, "nr_skills"), sizeof(buf)-(bufp-buf)); + pbuf += strlcpy(pbuf, ": ", sizeof(buf)-(bufp-buf)); *dh = 1; } - pbuf += strlcpy(pbuf, skillname(sk, lang)); + pbuf += strlcpy(pbuf, skillname(sk, lang), sizeof(buf)-(bufp-buf)); strcpy(pbuf++, " "); if (sk == SK_MAGIC){ if (find_magetype(u) != M_GRAU){ - pbuf += strlcpy(pbuf, LOC(lang, mkname("school", magietypen[find_magetype(u)]))); + pbuf += strlcpy(pbuf, LOC(lang, mkname("school", magietypen[find_magetype(u)])), sizeof(buf)-(bufp-buf)); strcpy(pbuf++, " "); } } diff --git a/src/common/kernel/spell.c b/src/common/kernel/spell.c index f9cda99d5..eaea88142 100644 --- a/src/common/kernel/spell.c +++ b/src/common/kernel/spell.c @@ -2817,7 +2817,6 @@ sp_summondragon(castorder *co) return cast_level; } -#if USE_FIREWALL /* ------------------------------------------------------------- */ /* Name: Feuerwand * Stufe: @@ -3170,7 +3169,6 @@ sp_wisps(castorder *co) return cast_level; } -#endif /* ------------------------------------------------------------- */ /* Name: Unheilige Kraft @@ -3614,6 +3612,7 @@ sp_chaossuction(castorder *co) create_special_direction(rt, r, 2, "Ein Wirbel aus reinem Chaos zieht über die Region.", "Wirbel"); + new_border(&bt_chaosgate, r, rt); for (f = factions; f; f = f->next) freset(f, FL_DH); for (u = r->units; u; u = u->next) { @@ -10546,3 +10545,40 @@ init_spells(void) register_spell(spelldaten+i); } } + +static boolean +chaosgate_valid(const border * b) +{ + const attrib * a = a_findc(b->from->attribs, &at_direction); + if (!a) a = a_findc(b->to->attribs, &at_direction); + if (!a) return false; + return true; +} + +struct region * +chaosgate_move(const border * b, struct unit * u, struct region * from, struct region * to, boolean routing) +{ + if (!routing) { + int maxhp = u->hp / 4; + if (maxhpnumber) maxhp = u->number; + u->hp = maxhp; + } + return to; +} + +border_type bt_chaosgate = { + "chaosgate", + b_transparent, /* transparent */ + NULL, /* init */ + NULL, /* destroy */ + NULL, /* read */ + NULL, /* write */ + b_blocknone, /* block */ + NULL, /* name */ + b_rinvisible, /* rvisible */ + b_finvisible, /* fvisible */ + b_uinvisible, /* uvisible */ + chaosgate_valid, + chaosgate_move +}; + diff --git a/src/common/kernel/spell.h b/src/common/kernel/spell.h index 13417b270..4352a9d78 100644 --- a/src/common/kernel/spell.h +++ b/src/common/kernel/spell.h @@ -265,11 +265,11 @@ extern "C" { /* ------------------------------------------------------------- */ -#if USE_FIREWALL /* für Feuerwände: in movement muß das noch explizit getestet werden. * besser wäre eine blcok_type::move() routine, die den effekt * der Bewegung auf eine struct unit anwendet. */ + extern struct border_type bt_chaosgate; extern struct border_type bt_firewall; extern struct border_type bt_wisps; typedef struct wall_data { @@ -277,7 +277,6 @@ extern "C" { int force; boolean active; } wall_data; -#endif extern struct attrib_type at_cursewall; extern struct attrib_type at_unitdissolve; diff --git a/src/common/settings-eressea.h b/src/common/settings-eressea.h index d004bb3a6..6a991d175 100644 --- a/src/common/settings-eressea.h +++ b/src/common/settings-eressea.h @@ -27,16 +27,17 @@ #define GUARD_DISABLES_RECRUIT 1 #define GUARD_DISABLES_PRODUCTION 1 #define RESOURCE_QUANTITY 0.5 -#define RECRUITFRACTION 40 /* 100/RECRUITFRACTION% */ +#define RECRUITFRACTION 40 /* 100/RECRUITFRACTION% */ #define CHANGED_CROSSBOWS 1 #define COMBAT_TURNS 5 #define PEASANTS_DO_NOT_STARVE 0 #define NEW_MIGRATION 1 #define ASTRAL_HUNGER #define NEWATSROI 0 - #define HUNGER_REDUCES_SKILL /* Hunger reduziert den Talentwert - auf die Hälfte */ + auf die Hälfte */ + +#undef ASTRAL_ITEM_RESTRICTIONS /* keine grossen dinge im astralraum */ #define MUSEUM_MODULE #define ARENA_MODULE diff --git a/src/common/settings-tutorial.h b/src/common/settings-tutorial.h index 1bbdab065..59f53a33e 100644 --- a/src/common/settings-tutorial.h +++ b/src/common/settings-tutorial.h @@ -6,7 +6,7 @@ | | Ingo Wilken +-------------------+ Stefan Reich - This program may not be used, modified or distributed + This program may not be used, modified or distributed without prior permission by the authors of Eressea. */ @@ -27,10 +27,12 @@ #define GUARD_DISABLES_RECRUIT 1 #define GUARD_DISABLES_PRODUCTION 1 #define RESOURCE_QUANTITY 0.5 -#define RECRUITFRACTION 40 /* 100/RECRUITFRACTION% */ +#define RECRUITFRACTION 40 /* 100/RECRUITFRACTION% */ #define CHANGED_CROSSBOWS 1 #define NEWATSROI 0 #define COMBAT_TURNS 5 #define PEASANTS_DO_NOT_STARVE 0 #define NEW_MIGRATION 1 #define ASTRAL_HUNGER + +#undef ASTRAL_ITEM_RESTRICTIONS /* keine grossen dinge im astralraum */ diff --git a/src/common/util/Jamfile b/src/common/util/Jamfile index e1c03213c..00d639499 100644 --- a/src/common/util/Jamfile +++ b/src/common/util/Jamfile @@ -12,6 +12,7 @@ SOURCES = #
malloc.c attrib.c base36.c + bsdstring.c command.c crmessage.c cvector.c diff --git a/src/common/util/bsdstring.c b/src/common/util/bsdstring.c new file mode 100644 index 000000000..c66da87aa --- /dev/null +++ b/src/common/util/bsdstring.c @@ -0,0 +1,61 @@ +#include +#include "bsdstring.h" + +#include + +#if !defined(HAVE_STRLCPY) +INLINE_FUNCTION size_t +strlcpy(char *dst, const char *src, size_t siz) /* copied from OpenBSD source code */ +{ + register char *d = dst; + register const char *s = src; + register size_t n = siz; + + /* Copy as many bytes as will fit */ + if (n != 0 && --n != 0) { + do { + if ((*d++ = *s++) == 0) + break; + } while (--n != 0); + } + + /* Not enough room in dst, add NUL and traverse rest of src */ + if (n == 0) { + if (siz != 0) + *d = '\0'; /* NUL-terminate dst */ + while (*s++) + ; + } + + return(s - src - 1); /* count does not include NUL */ +} + + +INLINE_FUNCTION size_t +strlcat(char * dst, const char * src, size_t siz) +{ + register char *d = dst; + register const char *s = src; + register size_t n = siz; + size_t dlen; + + /* Find the end of dst and adjust bytes left but don't go past end */ + while (*d != '\0' && n-- != 0) + d++; + dlen = d - dst; + n = siz - dlen; + + if (n == 0) + return(dlen + strlen(s)); + while (*s != '\0') { + if (n != 1) { + *d++ = *s; + n--; + } + s++; + } + *d = '\0'; + + return(dlen + (s - src)); /* count does not include NUL */ +} +#endif diff --git a/src/common/util/bsdstring.h b/src/common/util/bsdstring.h new file mode 100644 index 000000000..a855d41fd --- /dev/null +++ b/src/common/util/bsdstring.h @@ -0,0 +1,13 @@ +#ifndef UTIL_BSDSTRING_H +#define UTIL_BSDSTRING_H + +#if !defined(HAVE_STRLCPY) +# ifdef HAVE_INLINE +# include "bsdstring.c" +# else + extern size_t strlcpy(char *dst, const char *src, size_t siz); + extern size_t strlcat(char * dst, const char * src, size_t siz); +# endif +#endif + +#endif diff --git a/src/common/util/util.vcproj b/src/common/util/util.vcproj index c6a24cb18..de7317c46 100644 --- a/src/common/util/util.vcproj +++ b/src/common/util/util.vcproj @@ -179,6 +179,9 @@ + + diff --git a/src/config.h b/src/config.h index d3f876c6b..f982b9eb6 100644 --- a/src/config.h +++ b/src/config.h @@ -148,6 +148,9 @@ typedef struct stat stat_type; # define R_OK 4 # define HAVE__MKDIR_WITHOUT_PERMISSION +#define HAVE_INLINE +#define INLINE_FUNCTION __inline + # define snprintf _snprintf # define HAVE_SNPRINTF diff --git a/src/eressea/korrektur.c b/src/eressea/korrektur.c index db092cc91..5914fbe53 100644 --- a/src/eressea/korrektur.c +++ b/src/eressea/korrektur.c @@ -1010,6 +1010,30 @@ nothing(void) return 0; } +static int +fix_chaosgates(void) +{ + region * r; + for (r = regions; r; r=r->next) { + const attrib *a = a_findc(r->attribs, &at_direction); + + while (a!=NULL) { + spec_direction * sd = (spec_direction *)a->data.v; + region * r2 = findregion(sd->x, sd->y); + border * b = get_borders(r, r2); + while (b) { + if (b->type==&bt_chaosgate) break; + b = b->next; + } + if (b==NULL) { + b = new_border(&bt_chaosgate, r, r2); + } + a = a->nexttype; + } + } + return 0; +} + void korrektur(void) { @@ -1024,6 +1048,7 @@ korrektur(void) do_once("zvrm", nothing()); } + do_once("chgt", fix_chaosgates()); fix_astralplane(); fix_firewalls(); fix_gates(); diff --git a/src/res/eressea.xml b/src/res/eressea.xml index fc7b6b181..45b49f7ff 100644 --- a/src/res/eressea.xml +++ b/src/res/eressea.xml @@ -24,7 +24,7 @@ - + @@ -42,7 +42,7 @@ Bitte denke daran, deine Befehle mit dem Betreff ERESSEA BEFEHLE an eressea-server@eressea.upb.de zu senden. Am besten, du verwendest die Befehlsvorlage am Ende des Reports. - Remember to send your orders to eressea-server@eressea.upb.de with the subject ERESSEA ORDERS. + Remember to send your orders to eressea-server@eressea.upb.de with the subject ERESSEA ORDERS. ERESSEA BEFEHLE