forked from github/server
* bugfix transfermen: reports testlesen!
* bugfix migration: crash fehlende nachbarn * bugfix migration: division by zero * bugfix migration: nullpointer * bugfix gm tell plane: strdup() vergessen
This commit is contained in:
parent
b910647eab
commit
e7c9e10b98
|
@ -675,7 +675,7 @@ cr_output_unit(FILE * F, const region * r,
|
|||
fprintf(F, "%d %d;%s\n", get_skill(u, sk), esk,
|
||||
add_translation(skillname(sk, NULL), skillname(sk, f->locale)));
|
||||
#else
|
||||
fprintf(F, "%d %d;%s\n", level_days(get_level(u, sk)), esk,
|
||||
fprintf(F, "%d %d;%s\n", u->number*level_days(get_level(u, sk)), esk,
|
||||
add_translation(skillname(sk, NULL), skillname(sk, f->locale)));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -442,22 +442,22 @@ calculate_emigration(region *r)
|
|||
region *rc = rconnect(r,i);
|
||||
int w;
|
||||
|
||||
if(rterrain(rc) == T_OCEAN) {
|
||||
if (rc ==NULL || rterrain(rc) == T_OCEAN) {
|
||||
w = 0;
|
||||
} else {
|
||||
w = rpeasants(rc) - maxworkingpeasants(rc);
|
||||
if(rterrain(rc) == T_VOLCANO || rterrain(rc) == T_VOLCANO_SMOKING) {
|
||||
w = w/10;
|
||||
}
|
||||
}
|
||||
|
||||
if(rterrain(rc) == T_VOLCANO || rterrain(rc) == T_VOLCANO_SMOKING) {
|
||||
w = w/10;
|
||||
}
|
||||
weight[i] = w;
|
||||
weightall += w;
|
||||
}
|
||||
|
||||
for (i = 0; i != MAXDIRECTIONS; i++) {
|
||||
if (weightall!=0) for (i = 0; i != MAXDIRECTIONS; i++) {
|
||||
region *rc = rconnect(r,i);
|
||||
int wandering_peasants = (overpopulation * weight[i])/weightall;
|
||||
if (wandering_peasants==0 || rc==NULL) continue;
|
||||
|
||||
r->land->newpeasants -= wandering_peasants;
|
||||
rc->land->newpeasants += wandering_peasants;
|
||||
|
@ -550,7 +550,10 @@ peasants(region * r)
|
|||
* den Bauern genug für 11 Bauern pro Ebene ohne Wald. Der Wald
|
||||
* breitet sich nicht in Gebiete aus, die bebaut werden. */
|
||||
|
||||
int peasants, money, n, i, dead, satiated;
|
||||
int peasants, n, i;
|
||||
#if PEASANTS_DO_NOT_STARVE == 0
|
||||
int dead, satiated, money;
|
||||
#endif
|
||||
attrib * a;
|
||||
|
||||
/* Bauern vermehren sich */
|
||||
|
|
|
@ -493,103 +493,13 @@ u_geteffstealth(const struct unit * u)
|
|||
return (a?a->data.i:-1);
|
||||
}
|
||||
|
||||
#if SKILLPOINTS
|
||||
int
|
||||
change_skill(unit * u, skill_t id, int byvalue)
|
||||
{
|
||||
skill *i = u->skills;
|
||||
int wounds = 0;
|
||||
|
||||
if (id == SK_AUSDAUER) {
|
||||
wounds = unit_max_hp(u)*u->number - u->hp;
|
||||
}
|
||||
for (; i != u->skills + u->skill_size; ++i)
|
||||
if (i->id == id) {
|
||||
i->value = max(0, i->value + byvalue);
|
||||
if (id == SK_AUSDAUER) {
|
||||
u->hp = unit_max_hp(u)*u->number - wounds;
|
||||
}
|
||||
return i->value;
|
||||
}
|
||||
|
||||
set_skill(u, id, byvalue);
|
||||
|
||||
if (id == SK_AUSDAUER) {
|
||||
u->hp = unit_max_hp(u)*u->number - wounds;
|
||||
}
|
||||
return byvalue;
|
||||
}
|
||||
|
||||
static int
|
||||
change_skill_transfermen(unit * u, skill_t id, int byvalue)
|
||||
{
|
||||
skill * sv = u->skills;
|
||||
|
||||
while (sv != u->skills + u->skill_size) {
|
||||
if (sv->id == id) {
|
||||
sv->value = max(0, sv->value + byvalue);
|
||||
return sv->value;
|
||||
}
|
||||
++sv;
|
||||
}
|
||||
|
||||
set_skill(u, id, byvalue);
|
||||
|
||||
return byvalue;
|
||||
}
|
||||
|
||||
int
|
||||
get_skill(const unit * u, skill_t id)
|
||||
{
|
||||
skill *i = u->skills;
|
||||
|
||||
for (; i != u->skills + u->skill_size; ++i)
|
||||
if (i->id == id)
|
||||
return i->value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
set_skill(unit * u, skill_t id, int value)
|
||||
{
|
||||
skill *i = u->skills;
|
||||
|
||||
assert(value>=0);
|
||||
for (; i != u->skills + u->skill_size; ++i)
|
||||
if (i->id == id) {
|
||||
if (value)
|
||||
i->value = value;
|
||||
else {
|
||||
*i = *(u->skills + u->skill_size - 1);
|
||||
--u->skill_size;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!value)
|
||||
return;
|
||||
++u->skill_size;
|
||||
u->skills = realloc(u->skills, u->skill_size * sizeof(skill));
|
||||
(u->skills + u->skill_size - 1)->value = value;
|
||||
(u->skills + u->skill_size - 1)->id = id;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if SKILLPOINTS
|
||||
extern int level(int days);
|
||||
#endif
|
||||
|
||||
int
|
||||
get_level(const unit * u, skill_t id)
|
||||
{
|
||||
skill * sv = u->skills;
|
||||
while (sv != u->skills + u->skill_size) {
|
||||
if (sv->id == id) {
|
||||
#if SKILLPOINTS
|
||||
return level(sv->value/u->number);
|
||||
#else
|
||||
return sv->level;
|
||||
#endif
|
||||
}
|
||||
++sv;
|
||||
}
|
||||
|
@ -599,9 +509,6 @@ get_level(const unit * u, skill_t id)
|
|||
void
|
||||
set_level(unit * u, skill_t id, int value)
|
||||
{
|
||||
#if SKILLPOINTS
|
||||
set_skill(u, id, level_days(value)*u->number);
|
||||
#else
|
||||
skill * sv = u->skills;
|
||||
while (sv != u->skills + u->skill_size) {
|
||||
if (sv->id == id) {
|
||||
|
@ -611,7 +518,6 @@ set_level(unit * u, skill_t id, int value)
|
|||
++sv;
|
||||
}
|
||||
sk_set(add_skill(u, id), value);
|
||||
#endif
|
||||
}
|
||||
|
||||
static attrib_type at_leftship = {
|
||||
|
@ -756,9 +662,6 @@ move_unit(unit * u, region * r, unit ** ulist)
|
|||
void
|
||||
transfermen(unit * u, unit * u2, int n)
|
||||
{
|
||||
#if SKILLPOINTS
|
||||
int skills[MAXSKILLS];
|
||||
#endif
|
||||
const attrib * a;
|
||||
int hp = u->hp;
|
||||
region * r = u->region;
|
||||
|
@ -768,62 +671,36 @@ transfermen(unit * u, unit * u2, int n)
|
|||
/* "hat attackiert"-status wird übergeben */
|
||||
|
||||
if (u2) {
|
||||
#if SKILLPOINTS
|
||||
skill_t sk;
|
||||
if (u->skills) {
|
||||
for (sk = 0; sk < MAXSKILLS; ++sk) {
|
||||
skills[sk] = get_skill(u, sk);
|
||||
}
|
||||
}
|
||||
#else
|
||||
char has_skill[MAXSKILLS];
|
||||
skill *sv, *sn;
|
||||
skill_t i;
|
||||
skill_t sk;
|
||||
assert(u2->number+n>0);
|
||||
|
||||
for (i=0; i<MAXSKILLS; ++i) {
|
||||
has_skill[i]=(char)0;
|
||||
}
|
||||
for (sv=u->skills;sv!=u->skills+u->skill_size;++sv) {
|
||||
has_skill[sv->id]=(char)1;
|
||||
}
|
||||
for (sv=u2->skills;sv!=u2->skills+u2->skill_size;++sv) {
|
||||
has_skill[sv->id]=(char)1;
|
||||
}
|
||||
for(i=0; i<MAXSKILLS; ++i) if(has_skill[i] == (char)1) {
|
||||
int level;
|
||||
int weeks;
|
||||
for (sk=0; sk!=MAXSKILLS; ++sk) {
|
||||
double dlevel = 0.0;
|
||||
int weeks, level;
|
||||
|
||||
sv = get_skill(u, i);
|
||||
sn = get_skill(u2, i);
|
||||
sv = get_skill(u, sk);
|
||||
sn = get_skill(u2, sk);
|
||||
|
||||
if(sn==NULL) sn = add_skill(u2, i);
|
||||
if (sv==NULL && sn==NULL) continue;
|
||||
if (sv && sv->level) dlevel += (sv->level + 1 - sv->weeks/(sv->level*2.0+1)) * n;
|
||||
else dlevel += 0.5 * n;
|
||||
if (sn && sn->level) dlevel += (sn->level + 1 - sn->weeks/(sn->level*2.0+1)) * u2->number;
|
||||
else dlevel += 0.5 * u2->number;
|
||||
|
||||
if(sv==NULL) {
|
||||
if(sn->level > 0) {
|
||||
level = (sn->level*u2->number)/(u2->number+n);
|
||||
weeks = (sn->weeks*u2->number*(level+1)/(sn->level+1)+u2->number+n-1)/(u2->number+n);
|
||||
sn->level = (unsigned char)level;
|
||||
sn->weeks = (unsigned char)weeks;
|
||||
} else {
|
||||
weeks = (sn->weeks*u2->number+u2->number+n-1)/(u2->number+n);
|
||||
sn->weeks = (unsigned char)weeks;
|
||||
}
|
||||
} else {
|
||||
if(sn->level != sv->level) {
|
||||
level = (sv->level*n+sn->level*u2->number)/(u2->number+n);
|
||||
weeks = (sv->weeks*n*(level+1)/(sv->level+1)+sn->weeks*u2->number*(level+1)/
|
||||
(sn->level+1)+u2->number+n-1)/(u2->number+n);
|
||||
sn->level = (unsigned char)level;
|
||||
sn->weeks = (unsigned char)weeks;
|
||||
} else {
|
||||
weeks = (sv->weeks*n+sn->weeks*u2->number+u2->number+n-1)/(u2->number+n);
|
||||
sn->weeks = (unsigned char)weeks;
|
||||
}
|
||||
dlevel = dlevel / (n + u2->number);
|
||||
level = (int)dlevel;
|
||||
weeks = (int)((level*2.0+1) * (1 - dlevel + level)+0.9999999);
|
||||
|
||||
if (level) {
|
||||
if (sn==NULL) sn = add_skill(u2, sk);
|
||||
sn->level = (unsigned char)level;
|
||||
sn->weeks = (unsigned char)weeks;
|
||||
assert(sn->level>=0 && sn->weeks>0 && sn->weeks<=sn->level*2+1);
|
||||
} else if (sn) {
|
||||
sk_set(sn, 0);
|
||||
}
|
||||
assert(sn->level>=0 && sn->weeks>=0 && sn->weeks<=sn->level*2+1);
|
||||
}
|
||||
#endif
|
||||
a = a_find(u->attribs, &at_effect);
|
||||
while (a) {
|
||||
effect_data * olde = (effect_data*)a->data.v;
|
||||
|
@ -837,19 +714,9 @@ transfermen(unit * u, unit * u2, int n)
|
|||
}
|
||||
scale_number(u, u->number - n);
|
||||
if (u2) {
|
||||
#if SKILLPOINTS
|
||||
skill_t sk;
|
||||
#endif
|
||||
set_number(u2, u2->number + n);
|
||||
hp -= u->hp;
|
||||
u2->hp += hp;
|
||||
#if SKILLPOINTS
|
||||
if (u->skills) {
|
||||
for (sk = 0; sk < MAXSKILLS; ++sk) {
|
||||
change_skill_transfermen(u2, sk, skills[sk] - get_skill(u, sk));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* TODO: Das ist schnarchlahm! und gehört ncht hierhin */
|
||||
a = a_find(u2->attribs, &at_effect);
|
||||
while (a) {
|
||||
|
@ -951,8 +818,6 @@ set_number(unit * u, int count)
|
|||
#endif
|
||||
}
|
||||
|
||||
#if !SKILLPOINTS
|
||||
|
||||
boolean
|
||||
learn_skill(unit * u, skill_t sk, double chance)
|
||||
{
|
||||
|
@ -974,33 +839,6 @@ learn_skill(unit * u, skill_t sk, double chance)
|
|||
sk_set(sv, 1);
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
int coins, heads = 0;
|
||||
int level = 0;
|
||||
int weeks = 0;
|
||||
skill * sv;
|
||||
assert (chance <= 1.0);
|
||||
sv = get_skill(u, sk);
|
||||
if (sv) {
|
||||
level = sv->level;
|
||||
weeks = sv->learning;
|
||||
}
|
||||
coins = level * 2;
|
||||
heads = coins - weeks;
|
||||
while (heads>0 && coins--) {
|
||||
if (rand()%2==0) --heads;
|
||||
if (heads>coins) break;
|
||||
}
|
||||
if (heads) {
|
||||
++weeks;
|
||||
} else {
|
||||
++level;
|
||||
weeks = 0;
|
||||
}
|
||||
set_skill(u, sk, level, weeks, false);
|
||||
return heads==0;
|
||||
}
|
||||
*/
|
||||
|
||||
skill *
|
||||
add_skill(unit * u, skill_t id)
|
||||
|
@ -1046,8 +884,6 @@ has_skill(const unit * u, skill_t sk)
|
|||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static int
|
||||
item_modification(const unit *u, skill_t sk, int val)
|
||||
{
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
/* kernel includes */
|
||||
#include <building.h>
|
||||
#include <reports.h>
|
||||
#include <faction.h>
|
||||
#include <item.h>
|
||||
#include <message.h>
|
||||
|
@ -242,7 +243,7 @@ gm_messageplane(const char * str, void * data, const char * cmd)
|
|||
{
|
||||
unit * u = (unit*)data;
|
||||
const struct plane * p = rplane(u->region);
|
||||
const char * msg = igetstrtoken(str);
|
||||
const char * zmsg = igetstrtoken(str);
|
||||
if (p==NULL) {
|
||||
mistake(u, cmd, "In diese Ebene kann keine Nachricht gesandt werden.\n", 0);
|
||||
} else {
|
||||
|
@ -252,6 +253,7 @@ gm_messageplane(const char * str, void * data, const char * cmd)
|
|||
mistake(u, cmd, "Unzureichende Rechte für diesen Befehl.\n", 0);
|
||||
}
|
||||
else {
|
||||
message * msg = msg_message("msg_event", "string", strdup(zmsg));
|
||||
faction * f;
|
||||
region * r;
|
||||
for (f=factions;f;f=f->next) {
|
||||
|
@ -263,9 +265,10 @@ gm_messageplane(const char * str, void * data, const char * cmd)
|
|||
for (u=r->units;u;u=u->next) if (!fval(u->faction, FL_DH)) {
|
||||
f = u->faction;
|
||||
fset(f, FL_DH);
|
||||
add_message(&f->msgs, msg_message("msg_event", "string", msg));
|
||||
add_message(&f->msgs, msg);
|
||||
}
|
||||
}
|
||||
msg_release(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -604,6 +607,7 @@ gm_addquest(const char * email, const char * name, int radius, unsigned int flag
|
|||
plane * p;
|
||||
attrib * a;
|
||||
unit * u;
|
||||
watcher * w = calloc(sizeof(watcher), 1);
|
||||
region * center;
|
||||
boolean invalid = false;
|
||||
int minx, miny, maxx, maxy, cx, cy;
|
||||
|
@ -665,6 +669,12 @@ gm_addquest(const char * email, const char * name, int radius, unsigned int flag
|
|||
}
|
||||
}
|
||||
|
||||
/* watcher: */
|
||||
w->faction = f;
|
||||
w->mode = see_unit;
|
||||
w->next = p->watchers;
|
||||
p->watchers = w;
|
||||
|
||||
/* generic permissions */
|
||||
a = a_add(&f->attribs, a_new(&at_permissions));
|
||||
|
||||
|
|
|
@ -1863,6 +1863,15 @@ fix_timeouts(void)
|
|||
|
||||
#include <modules/gmcmd.h>
|
||||
|
||||
static int
|
||||
regatta_quest(void)
|
||||
{
|
||||
plane * p = gm_addplane(20, PFL_NORECRUITS, "Regatta");
|
||||
region * center = findregion(p->minx+(p->maxx-p->minx)/2, p->miny+(p->maxy-p->miny)/2);
|
||||
gm_addfaction("gregorjochmann@gmx.de", p, center);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
secondfaction(faction * pf)
|
||||
{
|
||||
|
@ -1901,6 +1910,7 @@ update_gmquests(void)
|
|||
if (!a) a_add((attrib**)&permissions->data.v, make_atgmcreate(oldpotiontype[p]->itype));
|
||||
}
|
||||
}
|
||||
do_once("rq01", regatta_quest());
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -1939,7 +1949,7 @@ create_xe(void)
|
|||
PFL_NOGIVE | PFL_NOATTACK | PFL_NOTERRAIN | PFL_NOMAGIC |
|
||||
PFL_NOSTEALTH | PFL_NOTEACH | PFL_NOBUILD | PFL_NOFEED,
|
||||
"Xontormia-Expreß");
|
||||
region * center = findregion((p->maxx-p->minx)/2, (p->maxy-p->miny)/2);
|
||||
region * center = findregion(p->minx+(p->maxx-p->minx)/2, p->miny+(p->maxy-p->miny)/2);
|
||||
faction * f = gm_addfaction("abeer@gmx.de", p, center);
|
||||
|
||||
log_printf("Xe-Partei %s\n", factionname(f));
|
||||
|
|
Loading…
Reference in New Issue