- fishing implemented

- bugfix shipweight
-
This commit is contained in:
Enno Rehling 2009-07-15 20:13:27 +00:00
parent 89535b0558
commit 2ed29bfc15
7 changed files with 86 additions and 58 deletions

View file

@ -607,16 +607,19 @@ cr_output_ship(FILE * F, const ship * sh, const unit * u, int fcaptain, const fa
/* calculate cargo */
if (u && (u->faction == f || omniscient(f))) {
int n = 0, p = 0, c = shipcapacity(sh);
static int rule_capacity = -1;
int n = 0, p = 0;
int mweight = shipcapacity(sh);
int mcabins = sh->type->cabins;
getshipweight(sh, &n, &p);
fprintf(F, "%d;cargo\n", n);
fprintf(F, "%d;capacity\n", c);
fprintf(F, "%d;capacity\n", mcabins);
fprintf(F, "%d;speed\n", shipspeed(sh, u));
n = (n+99) / 100; /* 1 Silber = 1 GE */
fprintf(F, "%d;Ladung\n", n);
fprintf(F, "%d;MaxLadung\n", c / 100);
fprintf(F, "%d;MaxLadung\n", mweight / 100);
}
/* shore */
w = NODIRECTION;

View file

@ -3234,27 +3234,6 @@ 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)
{
@ -3288,9 +3267,6 @@ produce(void)
peasant_taxes(r);
}
if (r->ships && fval(r->terrain, SEA_REGION)) {
fishing(r);
}
buyorders = 0;
sellorders = 0;
working = 0;

View file

@ -221,11 +221,31 @@ get_food(region *r)
* jede Einheit genug Silber für ihren Unterhalt hat. */
for (u = r->units; u; u = u->next) {
int need = lifestyle(u);
int style = lifestyle(u);
int need = style;
/* Erstmal zurücksetzen */
freset(u, UFL_HUNGER);
if (u->ship && (u->ship->flags&SF_FISHING)) {
unit * v;
int c = 2;
for (v=r->units;c>0 && v;v=v->next) {
if (v->ship==u->ship) {
if (u==v) {
if (u->number==c) {
need = 0;
} else {
int x = MIN(c, u->number);
int save = (style * x) / u->number;
need -= save;
}
}
c -= v->number;
}
}
}
if (food_rules&1) {
/* if the region is owned, and the owner is nice, then we'll get
* food from the peasants - should not be used with WORK */

View file

@ -459,19 +459,29 @@ canride(unit * u)
static boolean
cansail(const region * r, ship * sh)
{
int n = 0, p = 0;
/* sonst ist construction:: size nicht ship_type::maxsize */
assert(!sh->type->construction || sh->type->construction->improvement == NULL);
/* sonst ist construction:: size nicht ship_type::maxsize */
assert(!sh->type->construction || sh->type->construction->improvement == NULL);
if (sh->type->construction && sh->size!=sh->type->construction->maxsize) {
return false;
} else {
static int rule_capacity = -1;
int n = 0, p = 0;
int mweight = shipcapacity(sh);
int mcabins = sh->type->cabins;
if (sh->type->construction && sh->size!=sh->type->construction->maxsize)
return false;
getshipweight(sh, &n, &p);
if (rule_capacity<0) {
rule_capacity = get_param_int(global.parameters, "rules.ship.capacity", 0);
}
if (rule_capacity!=0) {
mcabins *= PERSON_WEIGHT;
}
getshipweight(sh, &n, &p);
if (n > shipcapacity(sh)) return false;
if (p > sh->type->cabins) return false;
return true;
if (n > mweight) return false;
if (p > mcabins) return false;
}
return true;
}
int
@ -730,6 +740,10 @@ drifting_ships(region * r)
int d_offset;
direction_t dir = 0;
if (sh->type->fishing>0) {
sh->flags |= SF_FISHING;
}
/* Schiff schon abgetrieben oder durch Zauber geschützt? */
if (fval(sh, SF_DRIFTED) || is_cursed(sh->attribs, C_SHIP_NODRIFT, 0)) {
shp = &sh->next;

View file

@ -20,6 +20,7 @@
#include "build.h"
#include "unit.h"
#include "item.h"
#include "race.h"
#include "region.h"
#include "skill.h"
@ -267,14 +268,27 @@ shipcapacity (const ship * sh)
void
getshipweight(const ship * sh, int *sweight, int *scabins)
{
unit * u;
*sweight = 0;
*scabins = 0;
for (u = sh->region->units; u; u = u->next)
if (u->ship == sh) {
*sweight += weight(u);
*scabins += u->number;
}
static int rule_capacity = -1;
unit * u;
*sweight = 0;
*scabins = 0;
if (rule_capacity<0) {
rule_capacity = get_param_int(global.parameters, "rules.ship.capacity", 0);
}
for (u = sh->region->units; u; u = u->next) {
if (u->ship == sh) {
*sweight += weight(u);
if (rule_capacity==0) {
*scabins += u->number;
} else {
/* weight goes into number of cabins, not cargo */
scabins += u->number * u->race->weight;
sweight -= u->number * u->race->weight;
}
}
}
}
unit *

View file

@ -72,6 +72,7 @@ extern void st_register(const ship_type * type);
#define SF_MOVED 1<<1
#define SF_DAMAGED 1<<2 /* for use in combat */
#define SF_SELECT 1<<3 /* previously FL_DH */
#define SF_FISHING 1<<4 /* was on an ocean, can fish */
typedef struct ship {
struct ship *next;

View file

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<ships>
<ship name="canoe" range="3" storm="1.00" fishing="20" damage="1.00" cabins="2" cargo="2000" cptskill="1" minskill="1" sumskill="2" opensea="no">
<ship name="canoe" range="3" fishing="20" storm="1.00" damage="1.00" cabins="2" cargo="2000" cptskill="1" minskill="1" sumskill="2" opensea="no">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="swamp"/>
@ -17,7 +17,7 @@
</construction>
</ship>
<ship name="raft" range="1" storm="1.00" fishing="20" damage="1.00" cabins="5" cargo="50000" cptskill="1" minskill="1" sumskill="5" opensea="no">
<ship name="raft" range="1" fishing="20" storm="1.00" damage="1.00" cabins="5" cargo="50000" cptskill="1" minskill="1" sumskill="5" opensea="no">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="swamp"/>
@ -27,7 +27,7 @@
</construction>
</ship>
<ship name="cutter" range="2" storm="1.00" fishing="20" damage="1.00" cabins="5" cargo="5000" cptskill="2" minskill="1" sumskill="5" opensea="yes">
<ship name="cutter" range="2" fishing="20" storm="1.00" damage="1.00" cabins="5" cargo="5000" cptskill="2" minskill="1" sumskill="5" opensea="yes">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="swamp"/>
@ -44,7 +44,7 @@
</construction>
</ship>
<ship name="barge" range="3" storm="1.00" fishing="20" damage="1.00" cabins="10" cargo="5000" cptskill="2" minskill="1" sumskill="5" opensea="no">
<ship name="barge" range="3" fishing="20" storm="1.00" damage="1.00" cabins="10" cargo="5000" cptskill="2" minskill="1" sumskill="5" opensea="no">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="swamp"/>
@ -62,7 +62,7 @@
</ship>
<ship name="royalbarge" range="5" storm="0.25" fishing="20" damage="1.00" cabins="10" cargo="5000" cptskill="5" minskill="1" sumskill="10" opensea="no">
<ship name="royalbarge" range="5" storm="0.25" damage="1.00" cabins="10" cargo="5000" cptskill="5" minskill="1" sumskill="10" opensea="no">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<coast terrain="swamp"/>
@ -80,7 +80,7 @@
</construction>
</ship>
<ship name="catamaran" range="7" storm="0.25" fishing="20" damage="1.00" cabins="20" cargo="10000" cptskill="7" minskill="1" sumskill="20" opensea="yes">
<ship name="catamaran" range="7" storm="0.25" damage="1.00" cabins="20" cargo="10000" cptskill="7" minskill="1" sumskill="20" opensea="yes">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<construction skill="shipcraft" minskill="8" maxsize="30" reqsize="1">
@ -90,7 +90,7 @@
</ship>
<ship name="cog" range="4" storm="0.50" fishing="20" damage="1.00" cabins="50" cargo="200000" cptskill="4" minskill="1" sumskill="20" opensea="yes">
<ship name="cog" range="4" storm="0.50" damage="1.00" cabins="50" cargo="200000" cptskill="4" minskill="1" sumskill="20" opensea="yes">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<construction skill="shipcraft" minskill="4" maxsize="100" reqsize="1">
@ -98,7 +98,7 @@
</construction>
</ship>
<ship name="caravel" range="4" storm="0.50" fishing="20" damage="1.00" cabins="150" cargo="600000" cptskill="6" minskill="1" sumskill="30" opensea="yes">
<ship name="caravel" range="4" storm="0.50" damage="1.00" cabins="150" cargo="600000" cptskill="6" minskill="1" sumskill="30" opensea="yes">
<coast terrain="ocean"/>
<coast terrain="plain"/>
<construction skill="shipcraft" minskill="6" maxsize="300" reqsize="1">
@ -107,7 +107,7 @@
</ship>
<ship name="frigate" range="4" storm="1.00" fishing="20" damage="1.00" cabins="110" cargo="100000" cptskill="5" minskill="1" sumskill="40" opensea="yes">
<ship name="frigate" range="4" storm="1.00" damage="1.00" cabins="110" cargo="100000" cptskill="5" minskill="1" sumskill="40" opensea="yes">
<modifier type="defense" value="+2"/>
<coast terrain="ocean"/>
<coast terrain="plain"/>
@ -117,7 +117,7 @@
</construction>
</ship>
<ship name="galleon" range="4" storm="1.00" fishing="20" damage="1.00" cabins="310" cargo="300000" cptskill="7" minskill="1" sumskill="60" opensea="yes">
<ship name="galleon" range="4" storm="1.00" damage="1.00" cabins="310" cargo="300000" cptskill="7" minskill="1" sumskill="60" opensea="yes">
<modifier type="defense" value="+2"/>
<coast terrain="ocean"/>
<coast terrain="plain"/>
@ -128,7 +128,7 @@
</ship>
<ship name="dragonship" range="6" storm="1.00" fishing="20" damage="1.00" cabins="110" cargo="50000" cptskill="5" minskill="1" sumskill="60" opensea="yes">
<ship name="dragonship" range="6" storm="1.00" damage="1.00" cabins="110" cargo="50000" cptskill="5" minskill="1" sumskill="60" opensea="yes">
<modifier type="attack" value="+1"/>
<modifier type="tactics" factor="2.00"/>
<coast terrain="ocean"/>
@ -139,7 +139,7 @@
</construction>
</ship>
<ship name="trireme" range="6" storm="1.00" fishing="20" damage="1.00" cabins="310" cargo="150000" cptskill="7" minskill="1" sumskill="90" opensea="yes">
<ship name="trireme" range="6" storm="1.00" damage="1.00" cabins="310" cargo="150000" cptskill="7" minskill="1" sumskill="90" opensea="yes">
<modifier type="attack" value="+1"/>
<modifier type="tactics" factor="2.00"/>
<coast terrain="ocean"/>