diff --git a/src/common/attributes/racename.c b/src/common/attributes/racename.c index ca7ecc022..f0ea212f7 100644 --- a/src/common/attributes/racename.c +++ b/src/common/attributes/racename.c @@ -24,36 +24,36 @@ #include attrib_type at_racename = { - "racename", NULL, a_finalizestring, NULL, a_writestring, a_readstring + "racename", NULL, a_finalizestring, NULL, a_writestring, a_readstring }; const char * get_racename(attrib * alist) { - attrib * a = a_find(alist, &at_racename); - if (a) return (const char *)a->data.v; - return NULL; + attrib * a = a_find(alist, &at_racename); + if (a) return (const char *)a->data.v; + return NULL; } void set_racename(attrib ** palist, const char * name) { - attrib * a = a_find(*palist, &at_racename); - if (!a && name) { - a = a_add(palist, a_new(&at_racename)); - a->data.v = strdup(name); - } else if (a && !name) { - a_remove(palist, a); - } else if (a) { - if (strcmp(a->data.v, name)!=0) { - free(a->data.v); - a->data.v = strdup(name); - } - } + attrib * a = a_find(*palist, &at_racename); + if (!a && name) { + a = a_add(palist, a_new(&at_racename)); + a->data.v = strdup(name); + } else if (a && !name) { + a_remove(palist, a); + } else if (a) { + if (strcmp(a->data.v, name)!=0) { + free(a->data.v); + a->data.v = strdup(name); + } + } } void init_racename(void) { - at_register(&at_racename); + at_register(&at_racename); } diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index 4d1590ce5..429de718f 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -3029,7 +3029,7 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork) { int earnings; /* n: verbleibende Einnahmen */ - /* m: maximale Arbeiter */ + /* fishes: maximale Arbeiter */ int jobs = maxwork; int p_wage = wage(r, NULL, NULL); request *o; @@ -3241,6 +3241,27 @@ peasant_taxes(region * r) } } +static void fishing(region * r) { + ship * sh; + for (sh=r->ships;sh;sh=sh->next) { + if (sh->type->fishing>0) { + unit * u = captain(sh); + if (u) { + int weight, cabins; + int cap = shipcapacity(sh); + getshipweight(sh, &weight, &cabins); + if (cap>weight) { + int fishes = min(cap-weight, sh->type->fishing*i_silver->weight); + fishes /= i_silver->weight; + i_change(&u->items, i_silver, fishes); + ADDMSG(&u->faction->msgs, msg_message("income_fishing", + "unit region amount", u, r, fishes)); + } + } + } + } +} + void produce(void) { @@ -3274,6 +3295,9 @@ produce(void) peasant_taxes(r); } + if (r->ships && fval(r->terrain, SEA_REGION)) { + fishing(r); + } buyorders = 0; sellorders = 0; working = 0; diff --git a/src/common/gamecode/randenc.c b/src/common/gamecode/randenc.c index 8428b1907..4f958ce1f 100644 --- a/src/common/gamecode/randenc.c +++ b/src/common/gamecode/randenc.c @@ -856,7 +856,7 @@ move_iceberg(region *r) for (sh = r->ships; sh;) { shn = sh->next; if (fval(sh, SF_SELECT)) { - u = captain(sh, r); + u = captain(sh); if (sh->damage>=sh->size * DAMAGE_SCALE) { if (u!=NULL) { ADDMSG(&u->faction->msgs, msg_message("overrun_by_iceberg_des", diff --git a/src/common/kernel/move.c b/src/common/kernel/move.c index 83a764873..c3593390d 100644 --- a/src/common/kernel/move.c +++ b/src/common/kernel/move.c @@ -1464,7 +1464,7 @@ travel_route(unit * u, const region_list * route_begin, const region_list * rout } /* terrain is marked as forbidden (curse, etc) */ - if (fval(next->terrain, FORBIDDEN_REGION)) { + if (fval(next, RF_BLOCKED) || fval(next->terrain, FORBIDDEN_REGION)) { ADDMSG(&u->faction->msgs, msg_message("detectforbidden", "unit region", u, next)); break; diff --git a/src/common/kernel/pathfinder.c b/src/common/kernel/pathfinder.c index 53a134561..c07076824 100644 --- a/src/common/kernel/pathfinder.c +++ b/src/common/kernel/pathfinder.c @@ -33,22 +33,22 @@ boolean allowed_swim(const region * src, const region * r) { - if (fval(r->terrain, SWIM_INTO)) return true; - return false; + if (fval(r->terrain, SWIM_INTO)) return true; + return false; } boolean allowed_walk(const region * src, const region * r) { - if (fval(r->terrain, WALK_INTO)) return true; - return false; + if (fval(r->terrain, WALK_INTO)) return true; + return false; } boolean allowed_fly(const region * src, const region * r) { - if (fval(r->terrain, FLY_INTO)) return true; - return false; + if (fval(r->terrain, FLY_INTO)) return true; + return false; } typedef struct node { diff --git a/src/common/kernel/region.c b/src/common/kernel/region.c index 57f64646a..ceb080cb8 100644 --- a/src/common/kernel/region.c +++ b/src/common/kernel/region.c @@ -909,7 +909,8 @@ r_demand(const region * r, const luxury_type * ltype) } const char * -rname(const region * r, const struct locale * lang) { +rname(const region * r, const struct locale * lang) +{ if (r->land) { return r->land->name; } diff --git a/src/common/kernel/ship.c b/src/common/kernel/ship.c index 2206568af..acf9546dd 100644 --- a/src/common/kernel/ship.c +++ b/src/common/kernel/ship.c @@ -153,11 +153,11 @@ damage_ship(ship * sh, double percent) } unit * -captain(ship *sh, region *r) +captain(ship *sh) { unit *u; - for(u = r->units; u; u = u->next) + for(u = sh->region->units; u; u = u->next) if(u->ship == sh && fval(u, UFL_OWNER)) return u; return NULL; diff --git a/src/common/kernel/ship.h b/src/common/kernel/ship.h index 2c352c18b..664e35a29 100644 --- a/src/common/kernel/ship.h +++ b/src/common/kernel/ship.h @@ -43,6 +43,8 @@ typedef struct ship_type { int minskill; /* min. skill to sail this (crew) */ int sumskill; /* min. sum of crew+captain */ + int fishing; /* weekly income from fishing */ + int at_bonus; /* Verändert den Angriffsskill (default: 0)*/ int df_bonus; /* Verändert den Verteidigungskill (default: 0)*/ float tac_bonus; @@ -87,7 +89,7 @@ typedef struct ship { } ship; extern void damage_ship(ship *sh, double percent); -extern struct unit *captain(ship *sh, struct region *r); +extern struct unit *captain(ship *sh); extern struct unit *shipowner(const struct ship * sh); extern const char * shipname(const struct ship * self); extern int shipcapacity(const struct ship * sh); diff --git a/src/common/kernel/terrain.c b/src/common/kernel/terrain.c index f442a9646..937daa28a 100644 --- a/src/common/kernel/terrain.c +++ b/src/common/kernel/terrain.c @@ -124,6 +124,13 @@ oldterrain(const struct terrain_type * terrain) const char * terrain_name(const struct region * r) { + if (r->attribs) { + attrib * a = a_find(r->attribs, &at_racename); + if (a) { + return get_racename(a); + } + } + if (r->terrain->name!=NULL) { return r->terrain->name(r); } else if (fval(r->terrain, SEA_REGION)) { diff --git a/src/common/kernel/xmlreader.c b/src/common/kernel/xmlreader.c index c39855ef6..4fe5ee473 100644 --- a/src/common/kernel/xmlreader.c +++ b/src/common/kernel/xmlreader.c @@ -536,6 +536,7 @@ parse_ships(xmlDocPtr doc) st->damage = xml_fvalue(node, "damage", 0.0); if (xml_bvalue(node, "fly", false)) st->flags |= SFL_FLY; if (xml_bvalue(node, "opensea", false)) st->flags |= SFL_OPENSEA; + st->fishing = xml_ivalue(node, "fishing", 0); st->minskill = xml_ivalue(node, "minskill", 0); st->range = xml_ivalue(node, "range", 0); st->storm = xml_fvalue(node, "storm", 1.0); diff --git a/src/eressea/tolua/bind_region.c b/src/eressea/tolua/bind_region.c index 35c3da1d8..ea2977439 100644 --- a/src/eressea/tolua/bind_region.c +++ b/src/eressea/tolua/bind_region.c @@ -16,6 +16,7 @@ without prior permission by the authors of Eressea. #include "bind_ship.h" #include "bind_building.h" +#include #include #include #include @@ -28,6 +29,7 @@ without prior permission by the authors of Eressea. #include #include #include +#include #include #include @@ -36,6 +38,8 @@ without prior permission by the authors of Eressea. #include #include +#include + int tolua_regionlist_next(lua_State *L) { region** region_ptr = (region **)lua_touserdata(L, lua_upvalueindex(1)); @@ -80,6 +84,31 @@ tolua_region_get_terrain(lua_State* L) return 1; } +static int +tolua_region_get_terrainname(lua_State* L) +{ + region* self = (region*) tolua_tousertype(L, 1, 0); + attrib * a = a_find(self->attribs, &at_racename); + if (a) { + tolua_pushstring(L, get_racename(a)); + return 1; + } + return 0; +} + +static int +tolua_region_set_terrainname(lua_State* L) +{ + region* self = (region*) tolua_tousertype(L, 1, 0); + const char * name = tolua_tostring(L, 2, 0); + if (name==NULL) { + a_removeall(&self->attribs, &at_racename); + } else { + set_racename(&self->attribs, name); + } + return 0; +} + static int tolua_region_get_info(lua_State* L) { region* self = (region*) tolua_tousertype(L, 1, 0); @@ -132,7 +161,7 @@ static int tolua_region_set_flag(lua_State* L) { region* self = (region*)tolua_tousertype(L, 1, 0); int bit = (int)tolua_tonumber(L, 2, 0); - int set = tolua_toboolean(L, 3, 0); + int set = tolua_toboolean(L, 3, 1); if (set) self->flags |= (1<flags &= ~(1< - + @@ -17,7 +17,7 @@ - + @@ -27,7 +27,7 @@ - + @@ -44,7 +44,7 @@ - + @@ -62,7 +62,7 @@ - + @@ -80,7 +80,7 @@ - + @@ -90,7 +90,7 @@ - + @@ -98,7 +98,7 @@ - + @@ -107,7 +107,7 @@ - + @@ -117,7 +117,7 @@ - + @@ -128,7 +128,7 @@ - + @@ -139,7 +139,7 @@ - + diff --git a/src/res/e3a/spells.xml b/src/res/e3a/spells.xml index da4fba606..c0ff03a3e 100644 --- a/src/res/e3a/spells.xml +++ b/src/res/e3a/spells.xml @@ -285,7 +285,7 @@ - + @@ -503,6 +503,7 @@ + diff --git a/src/res/e3a/strings.xml b/src/res/e3a/strings.xml index 6e3eea473..fe451325e 100644 --- a/src/res/e3a/strings.xml +++ b/src/res/e3a/strings.xml @@ -12,6 +12,18 @@ the third age + + Urkunden + Certificates + + + Nußhälften + nut halves + + + Flaschengeister + bottle demons + Pandoras Urkunde für Halbling ehrenhalber, weiblich Pandora's Certificate diff --git a/src/res/messages.xml b/src/res/messages.xml index 9e1090dc1..913d8209e 100644 --- a/src/res/messages.xml +++ b/src/res/messages.xml @@ -2638,8 +2638,7 @@ "$unit($unit) arbeitet in $region($region) für einen Lohn von $int($amount) Silber." - "$unit($unit) works in $region($region) for a wage of $int($amount) silver." - "$unit($unit) works in $region($region) for a wage of $int($amount) silver." + "In $region($region), $unit($unit) works for a wage of $int($amount) silver." @@ -2649,8 +2648,16 @@ "$unit($unit) verdient in $region($region) $int($amount)$if($eq($wanted,$amount),""," statt $int($wanted)") Silber durch Unterhaltung." - "$unit($unit) earns only $int($amount) instead of$if($eq($wanted,$amount),""," of$if($eq($wanted,$amount),""," of $int($wanted)") ") in $region($region) with entertainment." - "$unit($unit) earns only $int($amount) instead of$if($eq($wanted,$amount),""," of$if($eq($wanted,$amount),""," of $int($wanted)") ") in $region($region) with entertainment." + "In $region($region), $unit($unit) earns only $int($amount) instead of$if($eq($wanted,$amount),""," of$if($eq($wanted,$amount),""," of $int($wanted)") ") with entertainment." + + + + + + + + "$unit($unit) fängt in $region($region) Fische im Wert von $int($amount) Silber." + "In $region($region), $unit($unit) catches fish worth $int($amount) silver." @@ -2707,7 +2714,7 @@ - "$unit($unit) treibt Steuern in Höhe von in $region($region) $int($amount)$if($eq($wanted,$amount),""," statt $int($wanted)") Silber ein." + "$unit($unit) treibt in $region($region) Steuern in Höhe von $int($amount)$if($eq($wanted,$amount),""," statt $int($wanted)") Silber ein." "$unit($unit) collects taxes of only $int($amount) instead of$if($eq($wanted,$amount),""," of$if($eq($wanted,$amount),""," of $int($wanted)") ") silver in $region($region)." @@ -2716,7 +2723,7 @@ - "$unit($unit) treibt Steuern in Höhe von $region($region) $int($amount) Silber ein." + "$unit($unit) treibt in $region($region) Steuern in Höhe von $int($amount) Silber ein." "$unit($unit) collects taxes of $int($amount) silver in $region($region)." diff --git a/src/scripts/e3a/rules.lua b/src/scripts/e3a/rules.lua index ab104bf8e..5ee2a801d 100644 --- a/src/scripts/e3a/rules.lua +++ b/src/scripts/e3a/rules.lua @@ -1,3 +1,4 @@ +print("loaded rules.lua") -- when appending to this, make sure the item has a canuse-function! local goblin_denied = " plate lance mallornlance greatbow axe greatsword halberd rustyaxe rustyhalberd towershield " function item_canuse(u, iname)