forked from github/server
- Fix transfermen
This commit is contained in:
parent
5c11911e67
commit
0dbedf10c9
1 changed files with 41 additions and 12 deletions
|
@ -775,21 +775,50 @@ transfermen(unit * u, unit * u2, int n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
skill * sv;
|
char has_skill[MAXSKILLS];
|
||||||
|
skill *sv, *sn;
|
||||||
|
skill_t i;
|
||||||
assert(u2->number+n>0);
|
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) {
|
for (sv=u->skills;sv!=u->skills+u->skill_size;++sv) {
|
||||||
skill * sn = get_skill(u2, sv->id);
|
has_skill[sv->id]=(char)1;
|
||||||
if (sn==NULL) sn = add_skill(u2, sv->id);
|
}
|
||||||
/* level abrunden, wochen aufrunden. */
|
for (sv=u2->skills;sv!=u2->skills+u2->skill_size;++sv) {
|
||||||
if (sn->level!=sv->level) {
|
has_skill[sv->id]=(char)1;
|
||||||
int level = (sv->level*n+sn->level*u2->number)/(u2->number+n);
|
}
|
||||||
int 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);
|
for(i=0; i<MAXSKILLS; ++i) if(has_skill[i] == (char)1) {
|
||||||
sn->level = (unsigned char)level;
|
int level;
|
||||||
sn->weeks = (unsigned char)weeks;
|
int weeks;
|
||||||
|
|
||||||
|
sv = get_skill(u, i);
|
||||||
|
sn = get_skill(u2, i);
|
||||||
|
|
||||||
|
if(sn==NULL) sn = add_skill(u2, i);
|
||||||
|
|
||||||
|
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 {
|
} else {
|
||||||
/* aufgerundete wochenzahl */
|
if(sn->level != sv->level) {
|
||||||
int weeks = (sv->weeks*n+sn->weeks*u2->number+u2->number+n-1)/(u2->number+n);
|
level = (sv->level*n+sn->level*u2->number)/(u2->number+n);
|
||||||
sn->weeks = (unsigned char)weeks;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert(sn->level>=0 && sn->weeks>=0 && sn->weeks<=sn->level*2+1);
|
assert(sn->level>=0 && sn->weeks>=0 && sn->weeks<=sn->level*2+1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue