From 1c7ace755682b00f396851353bdd72ecb7a09aa6 Mon Sep 17 00:00:00 2001 From: Christian Schlittchen Date: Sun, 23 Oct 2005 11:27:55 +0000 Subject: [PATCH] WdW-Pyramiden --- src/common/attributes/Jamfile | 1 + src/common/attributes/attributes.c | 3 + src/common/gamecode/report.c | 63 ++++++++++++++--- src/common/kernel/build.c | 32 ++++++--- src/common/kernel/building.c | 103 ++++++++++------------------ src/common/kernel/building.h | 7 +- src/common/kernel/xmlreader.c | 1 + src/common/settings-wdw.h | 2 +- src/res/buildings.xml | 8 --- src/res/messages.xml | 11 +++ src/res/vinyambar-wdw.xml | 1 + src/res/vinyambar/wdw-buildings.xml | 47 +++++++++++++ src/res/vinyambar/wdw-strings.xml | 46 ++++++++++++- 13 files changed, 224 insertions(+), 101 deletions(-) create mode 100644 src/res/vinyambar/wdw-buildings.xml diff --git a/src/common/attributes/Jamfile b/src/common/attributes/Jamfile index ce3307cf3..af137def9 100644 --- a/src/common/attributes/Jamfile +++ b/src/common/attributes/Jamfile @@ -9,6 +9,7 @@ SubDirHdrs $(SUBDIR)/../.. ; SOURCES = aggressive.c + alliance.c at_movement.c attributes.c fleechance.c diff --git a/src/common/attributes/attributes.c b/src/common/attributes/attributes.c index 3f56485a2..91663b7cc 100644 --- a/src/common/attributes/attributes.c +++ b/src/common/attributes/attributes.c @@ -39,6 +39,9 @@ #endif #include "moved.h" #include "variable.h" +#ifdef WDW_PYRAMID +#include "alliance.h" +#endif /* util includes */ #include diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index d4b1b15c1..fa2866b95 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -24,6 +24,7 @@ #include #include #include +#include #ifdef AT_OPTION # include #endif @@ -61,6 +62,7 @@ #include #include #include +#include #ifdef USE_UGROUPS # include #endif @@ -1870,20 +1872,59 @@ report_building(FILE *F, const region * r, const building * b, const faction * f scat(b->display); i = b->display[strlen(b->display) - 1]; } + +#ifdef WDW_PYRAMID + + if (i != '!' && i != '?' && i != '.') + scat(", "); + + if(b->type == bt_find("pyramid")) { + unit * owner = buildingowner(r, b); + scat("Größenstufe "); + icat(wdw_pyramid_level(b)); + scat("."); + + if (owner && owner->faction==f) { + const construction *ctype = b->type->construction; + int completed = b->size; + int c; + + scat(" Baukosten pro Größenpunkt: "); + + while(ctype->improvement != NULL && + ctype->improvement != ctype && + ctype->maxsize > 0 && + ctype->maxsize <= completed) + { + completed -= ctype->maxsize; + ctype = ctype->improvement; + } + + assert(ctype->materials != NULL); + + for (c=0;ctype->materials[c].number;c++) { + resource_t rtype = ctype->materials[c].type; + int number = ctype->materials[c].number; + + if(c > 0) { + scat(", "); + } + icat(number); + scat(" "); + scat(locale_string(lang, + resourcename(oldresourcetype[rtype], + number!=1?GR_PLURAL:0))); + } + + scat("."); + } + } + +#else + if (i != '!' && i != '?' && i != '.') scat("."); -#if WDW_PYRAMID - if(b->type == bt_find("wdw_pyramid")) { - attrib *a = a_find(b->attribs, &at_alliance)); - if(f->alliance && f->alliance->id == a->data.i) { - scat("Die Größenstufe dieser Pyramide ist "); - icat(wdw_pyramid_level(b)); - scat(". Die nächste Größenstufe wird mit "); - icat(wdw_pyramid_size_for_next_level(b)); - scat(" Größenpunkten erreicht. Baukosten pro Größenpunkt: "); - } - } #endif rparagraph(F, buf, 2, 0); diff --git a/src/common/kernel/build.c b/src/common/kernel/build.c index 860c29262..f39de76e6 100644 --- a/src/common/kernel/build.c +++ b/src/common/kernel/build.c @@ -40,6 +40,7 @@ #include "ship.h" #include "skill.h" #include "unit.h" +#include "alliance.h" /* from libutil */ #include @@ -59,6 +60,7 @@ /* attributes inclues */ #include +#include #define STONERECYCLE 50 /* Name, MaxGroesse, MinBauTalent, Kapazitaet, {Eisen, Holz, Stein, BauSilber, @@ -627,16 +629,19 @@ build(unit * u, const construction * ctype, int completed, int want) effsk = basesk; if (inside_building(u)) { - effsk = skillmod(u->building->type->attribs, u, u->region, type->skill, effsk, SMF_PRODUCTION); + effsk = skillmod(u->building->type->attribs, u, u->region, type->skill, + effsk, SMF_PRODUCTION); } - effsk = skillmod(type->attribs, u, u->region, type->skill, effsk, SMF_PRODUCTION); + effsk = skillmod(type->attribs, u, u->region, type->skill, + effsk, SMF_PRODUCTION); if (effsk<0) return effsk; /* pass errors to caller */ if (effsk==0) return ENEEDSKILL; skills = effsk * u->number; - /* technically, nimblefinge and domore should be in a global set of "game"-attributes, - * (as at_skillmod) but for a while, we're leaving them in here. */ + /* technically, nimblefinge and domore should be in a global set of + * "game"-attributes, (as at_skillmod) but for a while, we're leaving + * them in here. */ if (dm != 0) { /* Auswirkung Schaffenstrunk */ @@ -649,9 +654,9 @@ build(unit * u, const construction * ctype, int completed, int want) /* skip over everything that's already been done: * type->improvement==NULL means no more improvements, but no size limits - * type->improvement==type means build another object of the same time while material lasts - * type->improvement==x means build x when type is finished - */ + * type->improvement==type means build another object of the same time + * while material lasts type->improvement==x means build x when type + * is finished */ while (type->improvement!=NULL && type->improvement!=type && type->maxsize>0 && @@ -852,6 +857,13 @@ build_building(unit * u, const building_type * btype, int want, order * ord) cmistake(u, ord, 221, MSG_PRODUCE); return; } + if (btype->flags & BTF_ONEPERTURN) { + if(b && fval(b, BLD_EXPANDED)) { + cmistake(u, ord, 318, MSG_PRODUCE); + return; + } + want = 1; + } if (b) built = b->size; if (want<=0 || want == INT_MAX) { @@ -913,8 +925,8 @@ build_building(unit * u, const building_type * btype, int want, order * ord) u->building = b; fset(u, UFL_OWNER); -#if WDW_PYRAMID - if(b->type == bt_find("wdw_pyramid") && u->faction->alliance != NULL) { +#ifdef WDW_PYRAMID + if(b->type == bt_find("pyramid") && u->faction->alliance != NULL) { attrib * a = a_add(&b->attribs, a_new(&at_alliance)); a->data.i = u->faction->alliance->id; } @@ -949,6 +961,8 @@ build_building(unit * u, const building_type * btype, int want, order * ord) } b->size += built; + fset(b, BLD_EXPANDED); + update_lighthouse(b); diff --git a/src/common/kernel/building.c b/src/common/kernel/building.c index 975977613..0c29076d6 100644 --- a/src/common/kernel/building.c +++ b/src/common/kernel/building.c @@ -37,6 +37,7 @@ #include #include #include +#include /* attributes includes */ #include @@ -298,81 +299,51 @@ castle_name(int bsize) return fname[i]; } -#if WDW_PYRAMID -static requirement wdw_pyramid_req[][] = { - {{R_STONE, 100, 0}, {R_WOOD, 100, 0}, {R_IRON, 100, 0}, {NORESOURCE, 0, 0.0 }}, - {{R_STONE, 1, 0}, {R_WOOD, 1, 0}, {R_IRON, 1, 0}, {NORESOURCE, 0, 0.0 }}, - {{R_STONE, 1, 0}, {R_WOOD, 1, 0}, {R_IRON, 1, 0}, - {R_MALLORN, 1, 0}, {NORESOURCE, 0, 0.0 }}, - {{R_STONE, 1, 0}, {R_WOOD, 1, 0}, {R_IRON, 1, 0}, - {R_LAEN, 1, 0}, {NORESOURCE, 0, 0.0 }}, - {{R_STONE, 1, 0}, {R_WOOD, 1, 0}, {R_IRON, 1, 0}, - {R_TOADSLIME, 1, 0}, {NORESOURCE, 0, 0.0 }}, - {{R_STONE, 1, 0}, {R_WOOD, 1, 0}, {R_IRON, 1, 0}, - {R_BALM, 1, 0.0 }, {R_SPICES, 1, 0.0 }, {R_JEWELERY, 1, 0.0 }, - {R_MYRRH, 1, 0.0 }, {R_OIL, 1, 0.0 }, {R_SILK, 1, 0.0 }, - {R_INCENSE, 1, 0.0 }, {NORESOURCE, 0, 0.0 }} -} +#ifdef WDW_PYRAMID +static const char * +pyramid_name(int bsize) +{ + static const struct building_type * bt_pyramid; + static char p_name_buf[32]; + int level=0; + const construction * ctype; -static construction wdw_pyramid_bld[] = { - { SK_BUILDING, 10, 1, 1, pyramid_req[0], wdw_pyramid_bld[0] }, /* 0 -> 1 */ - { SK_BUILDING, 3, 6, 1, pyramid_req[1], wdw_pyramid_bld[1] }, /* -> 7 */ - { SK_BUILDING, 4, 1, 1, pyramid_req[2], wdw_pyramid_bld[2] }, /* -> 8 */ - { SK_BUILDING, 5, 13, 1, pyramid_req[1], wdw_pyramid_bld[3] }, /* -> 21 */ - { SK_BUILDING, 6, 1, 1, pyramid_req[3], wdw_pyramid_bld[4] }, /* -> 22 */ - { SK_BUILDING, 7, 41, 1, pyramid_req[1], wdw_pyramid_bld[5] }, /* -> 63 */ - { SK_BUILDING, 8, 1, 1, pyramid_req[4], wdw_pyramid_bld[6] }, /* -> 64 */ - { SK_BUILDING, 9, 125, 1, pyramid_req[1], wdw_pyramid_bld[7] }, /* -> 189 */ - { SK_BUILDING, 10, 1, 1, pyramid_req[5], wdw_pyramid_bld[8] }, /* -> 190 */ - { SK_BUILDING, 100, 100000, 1, pyramid_req[0], NULL } /* should never be seen */ + if(!bt_pyramid) bt_pyramid = bt_find("pyramid"); + assert(bt_pyramid); + + ctype = bt_pyramid->construction; + + while (ctype && ctype->maxsize != -1 && ctype->maxsize<=bsize) { + bsize-=ctype->maxsize; + ctype=ctype->improvement; + ++level; + } + + sprintf(p_name_buf, "pyramid%d", level); + + return p_name_buf; } int wdw_pyramid_level(const struct building *b) { - int size = 0; - int level; + const construction *ctype = b->type->construction; + int completed = b->size; + int level = 0; - for(level=0; wdw_pyramid_bld[level].improvement != NULL; level++) { - size += wdw_pyramid_bld[level].maxsize; - if(size > b->size) break; + while(ctype->improvement != NULL && + ctype->improvement != ctype && + ctype->maxsize > 0 && + ctype->maxsize <= completed) + { + ++level; + completed-=ctype->maxsize; + ctype = ctype->improvement; } return level; } - -int -wdw_pyramid_size_for_next_level(const struct building *b) -{ - int size = 0; - int level; - - for(level=0; wdw_pyramid_bld[level].improvement != NULL; level++) { - size += wdw_pyramid_bld[level].maxsize; - if(size > b->size) { - return size - b->size; - } - } - - return INT_MAX; -} - -static const char * -wdw_pyramid_name(int bsize) -{ - return "wdw_pyramid"; -} - -building_type bt_wdw_pyramid = { - "wdw_pyramid", - BTF_INDESTRUCTIBLE, - 1, 4, -1, - 0, 0, 0, 1.0, - NULL, - &wdw_pyramid_bld[0], - wdw_pyramid_name -}; #endif /* for finding out what was meant by a particular building string */ @@ -412,10 +383,8 @@ register_buildings(void) { register_function((pf_generic)init_smithy, "init_smithy"); register_function((pf_generic)castle_name, "castle_name"); - -#if WDW_PYRAMID - register_function((pf_generic)wdw_pyramid_name, "wdw_pyramid_name"); - bt_register(&bt_wdw_pyramid); +#ifdef WDW_PYRAMID + register_function((pf_generic)pyramid_name, "pyramid_name"); #endif } diff --git a/src/common/kernel/building.h b/src/common/kernel/building.h index 347eed1f1..80de5c340 100644 --- a/src/common/kernel/building.h +++ b/src/common/kernel/building.h @@ -39,6 +39,7 @@ typedef struct maintenance { #define BTF_DYNAMIC 0x10 /* dynamic type, needs bt_write */ #define BTF_PROTECTION 0x20 /* protection in combat */ #define BTF_MAGIC 0x40 /* magical effect */ +#define BTF_ONEPERTURN 0x80 /* one one sizepoint can be added per turn */ typedef struct building_type { const char * _name; @@ -82,6 +83,7 @@ extern struct building_typelist *buildingtypes; #define BLD_MAINTAINED 0x01 /* vital maintenance paid for */ #define BLD_WORKING 0x02 /* full maintenance paid, it works */ #define BLD_UNGUARDED 0x04 /* you can enter this building anytime */ +#define BLD_EXPANDED 0x08 /* has been expanded this turn */ #define BLD_SAVEMASK 0x00 /* mask for persistent flags */ @@ -143,9 +145,8 @@ extern struct unit * buildingowner(const struct region * r, const struct buildin extern attrib_type at_nodestroy; extern attrib_type at_building_action; -#if WDW_PYRAMID -extern int wdw_pyramid_size(const struct building *b); -extern int wdw_pyramid_size_for_next_level(const struct building *b); +#ifdef WDW_PYRAMID +extern int wdw_pyramid_level(const struct building *b); #endif typedef struct building_action { diff --git a/src/common/kernel/xmlreader.c b/src/common/kernel/xmlreader.c index e2030aad2..58d47f8c6 100644 --- a/src/common/kernel/xmlreader.c +++ b/src/common/kernel/xmlreader.c @@ -267,6 +267,7 @@ parse_buildings(xmlDocPtr doc) bt->auraregen = xml_fvalue(node, "auraregen", 1.0); if (xml_bvalue(node, "nodestroy", false)) bt->flags |= BTF_INDESTRUCTIBLE; + if (xml_bvalue(node, "oneperturn", false)) bt->flags |= BTF_ONEPERTURN; if (xml_bvalue(node, "nobuild", false)) bt->flags |= BTF_NOBUILD; if (xml_bvalue(node, "unique", false)) bt->flags |= BTF_UNIQUE; if (xml_bvalue(node, "decay", false)) bt->flags |= BTF_DECAY; diff --git a/src/common/settings-wdw.h b/src/common/settings-wdw.h index e6f11a5bc..9b564d6dc 100644 --- a/src/common/settings-wdw.h +++ b/src/common/settings-wdw.h @@ -53,4 +53,4 @@ #undef XECMD_MODULE #define WDW_PHOENIX #define WDW_PYRAMIDSPELL -/* #define WDW_PYRAMID 1 */ +#define WDW_PYRAMID diff --git a/src/res/buildings.xml b/src/res/buildings.xml index f8c54876c..ab5901158 100644 --- a/src/res/buildings.xml +++ b/src/res/buildings.xml @@ -166,14 +166,6 @@ - - - - - - - - diff --git a/src/res/messages.xml b/src/res/messages.xml index 86a0d8f1f..dcff1d5ca 100644 --- a/src/res/messages.xml +++ b/src/res/messages.xml @@ -2750,6 +2750,17 @@ "$unit($unit) drowns when $ship($ship) in $region($region) sinks." "$unit($unit) drowns when $ship($ship) in $region($region) sinks." + + + + + + + + "$unit($unit) in $region($region): '$order($command)' - Das Gebäude kann nur einmal pro Runde erweitert werden." + "$unit($unit) in $region($region): '$order($command)' - Thhe building can be expanded only once per turn." + + diff --git a/src/res/vinyambar-wdw.xml b/src/res/vinyambar-wdw.xml index aed4ede71..278935469 100644 --- a/src/res/vinyambar-wdw.xml +++ b/src/res/vinyambar-wdw.xml @@ -46,6 +46,7 @@ + diff --git a/src/res/vinyambar/wdw-buildings.xml b/src/res/vinyambar/wdw-buildings.xml new file mode 100644 index 000000000..14bcc5356 --- /dev/null +++ b/src/res/vinyambar/wdw-buildings.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/res/vinyambar/wdw-strings.xml b/src/res/vinyambar/wdw-strings.xml index 5216fa7e7..9c9eaf908 100644 --- a/src/res/vinyambar/wdw-strings.xml +++ b/src/res/vinyambar/wdw-strings.xml @@ -90,6 +90,48 @@ Smaragde emeralds - - + + Pyramide des Hapi + pyramid of Hapi + + + Pyramide der Tayet + pyramid of Tayet + + + Pyramide der Tefnut + pyramid of Tefnut + + + Pyramide des Shu + pyramid of Shu + + + Pyramide der Nuit + pyramid of Nuit + + + Pyramide der Bastet + pyramid of Bastet + + + Pyramide des Horus + pyramid of Horus + + + Pyramide der Maat + pyramid of Maat + + + Pyramide des Osiris + pyramid of Osiris + + + Pyramide des Set + pyramid of Set + + + Pyramide des Thoth + pyramid of Thoth +