* Bugfix Dämonen (siehe mail)

* FL_GUARD ist obsolet.
* SPELLPOINTS an mehr Stellen entfernt
This commit is contained in:
Enno Rehling 2002-03-11 21:20:31 +00:00
parent 0faa820456
commit 8c002d7f21
16 changed files with 85 additions and 249 deletions

View File

@ -240,8 +240,6 @@ expandorders(region * r, request * requests)
}
/* ------------------------------------------------------------- */
#if SKILLPOINTS == 0
static void
change_level(unit * u, skill_t sk, int bylevel)
{
@ -250,7 +248,6 @@ change_level(unit * u, skill_t sk, int bylevel)
if (sv==0) sv = add_skill(u, sk);
sk_set(sv, sv->level+bylevel);
}
#endif
static void
expandrecruit(region * r, request * recruitorders)
@ -1502,7 +1499,7 @@ allocate_resource(unit * u, const resource_type * rtype, int want)
{
for (u2 = r->units; u2; u2 = u2->next ) {
if (getguard(u) & GUARD_MINING
&& !fval(u2, FL_ISNEW)
&& !fval(u2, UFL_ISNEW)
&& u2->number
&& !ucontact(u2, u)
&& !allied(u2, u->faction, HELP_GUARD))

View File

@ -82,7 +82,7 @@ static FILE * dragonlog;
static boolean
is_waiting(const unit * u)
{
if (fval(u, FL_ISNEW)) return true;
if (fval(u, UFL_ISNEW)) return true;
if (strncasecmp(u->lastorder, "WARTEN", 6) == 0) return true;
return false;
@ -976,7 +976,7 @@ plan_monsters(void)
if (tr != r) is_moving = true;
}
if (!(fval(u, FL_ISNEW)) && r->terrain != T_OCEAN) { /* Monster bewachen immer */
if (!(fval(u, UFL_ISNEW)) && r->terrain != T_OCEAN) { /* Monster bewachen immer */
strlist *S;
S = makestrlist(locale_string(u->faction->locale, keywords[K_GUARD]));
addlist(&u->orders, S);

View File

@ -294,12 +294,8 @@ find_manual(region * r, unit * u)
addmessage(r, u->faction, buf, MSG_EVENT, ML_IMPORTANT);
if (improve_all(u->faction, skill, 3) == 0) {
#if SKILLPOINTS
change_skill(u, skill, 270);
#else
int i;
for (i=0;i!=9;++i) learn_skill(u, skill, 1.0);
#endif
}
}
@ -317,7 +313,7 @@ get_unit(region * r, unit * u)
newunit = createunit(r, u->faction, rand() % 20 + 3, u->faction->race);
set_string(&newunit->name, "Dorfbewohner");
set_money(newunit, (rand() % 26 + 10) * newunit->number);
fset(newunit, FL_ISNEW);
fset(newunit, UFL_ISNEW);
if (fval(u, FL_PARTEITARNUNG)) fset(newunit, FL_PARTEITARNUNG);
switch (rand() % 4) {
case 0:
@ -472,7 +468,7 @@ get_allies(region * r, unit * u)
newunit->irace = u->irace;
}
if (fval(u, FL_PARTEITARNUNG)) fset(newunit, FL_PARTEITARNUNG);
fset(u, FL_ISNEW);
fset(u, UFL_ISNEW);
sprintf(buf, "Plötzlich stolper%c %s über einige %s. Nach kurzem "
"Zögern entschließen sich die %s, sich Deiner Partei anzuschließen.",
@ -1448,7 +1444,7 @@ randomevents(void)
for (u=r->units; u; u=u->next) {
if (u->faction->no != MONSTER_FACTION
&& (u->race->flags & RCF_DESERT)) {
if (fval(u, FL_ISNEW)) continue;
if (fval(u, UFL_ISNEW)) continue;
if (rand()%100 < 5) {
ADDMSG(&u->faction->msgs, msg_message("desertion",
"unit region", u, r));

View File

@ -424,12 +424,8 @@ teach(region * r, unit * u)
}
if (academy) {
#if SKILLPOINTS
change_skill(u, sk, academy / 30);
#else
academy = academy/30;
learn_skill(u, sk, academy/30.0/TEACHNUMBER);
#endif
}
}
/* ------------------------------------------------------------- */

View File

@ -3804,9 +3804,11 @@ int
damage_unit(unit *u, const char *dam, boolean armor, boolean magic)
{
int *hp = malloc(u->number * sizeof(int));
int h = u->hp/u->number;
int h;
int i, dead = 0, hp_rem = 0, heiltrank;
if (u->number==0) return 0;
h = u->hp/u->number;
/* HP verteilen */
for (i=0; i<u->number; i++) hp[i] = h;
h = u->hp - (u->number * h);

View File

@ -693,7 +693,7 @@ scale_number (unit * u, int n)
}
for (sk = 0; sk < MAXSKILLS; sk++) {
if (n==0 || u->number == 0) {
set_level(u, sk, 0);
remove_skill(u, sk);
}
}
@ -1382,7 +1382,7 @@ getunit(const region * r, const faction * f)
if (n < 0) return 0;
for (u2 = r->units; u2; u2 = u2->next) {
if (u2->no == n && !fval(u2, FL_ISNEW)) {
if (u2->no == n && !fval(u2, UFL_ISNEW)) {
return u2;
}
}
@ -2512,7 +2512,7 @@ make_undead_unit(region * r, faction * f, int n, const struct race * rc)
u = createunit(r, f, n, rc);
set_string(&u->lastorder, "");
name_unit(u);
fset(u, FL_ISNEW);
fset(u, UFL_ISNEW);
return u;
}
@ -2991,13 +2991,8 @@ int
produceexp(struct unit * u, skill_t sk, int n)
{
if (n==0 || !playerrace(u->race)) return 0;
#if SKILLPOINTS
change_skill(u, sk, PRODUCEEXP * n);
return 1;
#else
learn_skill(u, sk, PRODUCEEXP/30.0);
return 0;
#endif
}
boolean

View File

@ -845,8 +845,8 @@ typedef struct strlist {
extern int max_unique_id;
#define FL_GUARD (1<<0) /* 1 */
#define FL_ISNEW (1<<1) /* 2 */
#define UFL_DEBUG (1<<0)
#define UFL_ISNEW (1<<1) /* 2 */
#define FL_LONGACTION (1<<2) /* 4 */
#define FL_OWNER (1<<3) /* 8 */
#define FL_PARTEITARNUNG (1<<4) /* 16 */

View File

@ -120,7 +120,7 @@ addplayer(region *r, const char *email, const struct race * frace, const locale
u = createunit(r, f, 1, f->race);
give_starting_equipment(r, u);
fset(u, FL_ISNEW);
fset(u, UFL_ISNEW);
if (old_race(f->race) == RC_DAEMON) {
race_t urc;
do

View File

@ -1669,10 +1669,10 @@ readunit(FILE * F)
guard(u, GUARD_NONE);
}
} else
u->flags = ri(F);
u->flags = ri(F) & ~UFL_DEBUG;
if (global.data_version < GUARD_VERSION) {
#if RELEASE_VERSION < GUARDFIX_VERSION
if (fval(u, FL_GUARD)) guard(u, GUARD_ALL);
if (fval(u, 1)) guard(u, GUARD_ALL);
#endif
}
/* Kurze persistente Befehle einlesen */

View File

@ -257,53 +257,6 @@ level(int days)
return i;
}
#if !SKILLPOINTS
/*
#define MAXLEVEL 32
static struct {
int permutations;
int * chances;
} upgrade[MAXLEVEL];
static double
fak(int n)
{
int i;
double f=1;
for (i=2;i<n;++i) f=f*i;
return f;
}
void
sk_set(skill * sv, int level)
{
double i;
int weeks;
int multi=1+(level/16);
if (upgrade[level].permutations==0) {
int m;
int ctr = 1;
int n = level * 2 / multi;
upgrade[level].permutations = 1 << n;
if (n>0) upgrade[level].chances = malloc(sizeof(double)*n);
for (m=0;m!=n;++m) {
upgrade[level].chances[m] = (int)(fak(n)/(fak(m)*fak(n-m)));
ctr += upgrade[level].chances[m];
}
assert(ctr==upgrade[level].permutations);
}
i = rand() % upgrade[level].permutations;
for (weeks=0;weeks!=level*2/multi;++weeks) {
if (i<=upgrade[level].chances[weeks]) break;
else i-=upgrade[level].chances[weeks];
}
weeks*=multi;
sv->weeks = (unsigned char)(weeks+1);
sv->level = (unsigned char)level;
}
*/
void
sk_set(skill * sv, int level)
{
@ -354,4 +307,3 @@ skill_compare(const skill * sk, const skill * sc)
if (sk->weeks > sc->weeks) return -1;
return 0;
}
#endif

View File

@ -23,15 +23,10 @@ extern signed char skill_bonus(struct unit * u, struct region * r);
#define SMF_RIDING (1<<2) /* Bonus für berittene - an der rasse*/
typedef struct skill {
#if SKILLPOINTS
skill_t id;
int value;
#else
unsigned char id;
unsigned char level;
unsigned char weeks;
unsigned char old;
#endif
} skill;
typedef struct skillmod_data {
@ -54,16 +49,12 @@ extern skill_t sk_find(const char * name);
extern int level_days(int level);
extern int level(int days);
#if SKILLPOINTS
# define skill_level(level) level_days(level)
#else
# define skill_level(level) (level)
#define skill_level(level) (level)
extern void reduce_skill(struct unit *u, skill * sv, int change);
extern int skill_weeks(int level);
extern int skill_compare(const skill * sk, const skill * sc);
extern void sk_set(skill * sv, int level);
#endif
#endif

View File

@ -2266,7 +2266,7 @@ sp_ironkeeper(castorder *co)
/*keeper->age = cast_level + 2;*/
guard(keeper, GUARD_MINING);
fset(keeper, FL_ISNEW);
fset(keeper, UFL_ISNEW);
keeper->status = ST_AVOID; /* kaempft nicht */
/* Parteitarnen, damit man nicht sofort weiß, wer dahinter steckt */
fset(keeper, FL_PARTEITARNUNG);

View File

@ -51,6 +51,8 @@
#define FIND_FOREIGN_TEMP
int demonfix = 0;
/* ------------------------------------------------------------- */
const unit u_peasants = { NULL, NULL, NULL, NULL, NULL, 2, "die Bauern" };
@ -679,6 +681,8 @@ transfermen(unit * u, unit * u2, int n)
skill_t sk;
assert(u2->number+n>0);
if (demonfix && u2->race==new_race[RC_DAEMON]) fset(u2, UFL_DEBUG);
for (sk=0; sk!=MAXSKILLS; ++sk) {
double dlevel = 0.0;
int weeks, level;

View File

@ -520,11 +520,7 @@ gm_skill(const char * str, void * data, const char * cmd)
mistake(u, cmd, "Unzureichende Rechte für diesen Befehl.\n", 0);
}
else {
#if SKILLPOINTS
set_skill(to, skill, num*to->number);
#else
set_level(to, skill, num);
#endif
}
}
}

View File

@ -52,15 +52,16 @@
/* kernel includes */
#include <building.h>
#include <unit.h>
#include <message.h>
#include <teleport.h>
#include <creport.h>
#include <faction.h>
#include <message.h>
#include <plane.h>
#include <race.h>
#include <reports.h>
#include <creport.h>
#include <skill.h>
#include <teleport.h>
#include <unit.h>
#include <region.h>
#include <reports.h>
#include <resources.h>
#include <save.h>
#include <ship.h>
@ -98,9 +99,6 @@ extern boolean nobattle;
extern boolean nobattledebug;
extern boolean dirtyload;
static boolean printpotions;
static int insertfaction;
extern void debug_messagetypes(FILE * out);
extern void free_region(region * r);
extern void render_init(void);
@ -140,20 +138,6 @@ crwritemap(void)
return 0;
}
static void
print_potions(FILE * F)
{
potion_type * p;
for (p=potiontypes;p;p=p->next) {
requirement * req = p->itype->construction->materials;
int i;
fprintf(F, "%s\n", locale_string(NULL, p->itype->rtype->_name[0]));
for (i=0;req[i].number;++i) {
fprintf(F, " %s\n", locale_string(NULL, resname(req[i].type, 0)));
}
}
}
static void
game_init(void)
{
@ -197,11 +181,6 @@ game_init(void)
abort();
}
#endif
if (printpotions) {
FILE * F = fopen("recipes.txt", "w");
print_potions(F);
fclose(F);
}
}
static void
@ -455,6 +434,8 @@ usage(const char * prog, const char * arg)
return -1;
}
extern int demonfix;
static int
read_args(int argc, char **argv)
{
@ -489,7 +470,7 @@ read_args(int argc, char **argv)
g_reportdir = argv[++i];
break;
case 'D': /* DEBUG */
printpotions = true;
demonfix = atoi(argv[++i]);
break;
case 'd':
g_datadir = argv[++i];
@ -503,9 +484,6 @@ read_args(int argc, char **argv)
case 't':
turn = atoi(argv[++i]);
break;
case 'i':
insertfaction = atoi36(argv[++i]);
break;
case 'f':
firstx = atoi(argv[++i]);
firsty = atoi(argv[++i]);
@ -593,124 +571,6 @@ main(int argc, char *argv[])
return 0;
#endif
if (insertfaction) {
faction * lostf;
unit *ulost, **ulostp = &lostunits;
faction **fp = &factions;
region **rp = &regions;
if ((i=readgame(false))!=0) return i;
lostf = findfaction(insertfaction);
lostf->lastorders = turn;
lostf->allies = NULL;
lostf->groups = NULL;
free(used_faction_ids);
while (*rp) {
building *b, *b2;
ship *s, *s2;
region *r = *rp;
int prevunit = 0;
unit ** up = &r->units;
while(*up) {
unit * u = *up;
if (u->faction != lostf) {
*up = u->next;
prevunit = u->no;
stripunit(u);
uunhash(u);
free(u);
} else {
lostdata * ld = calloc(sizeof(lostdata), 1);
ld->x = r->x;
ld->y = r->y;
ld->ship = u->ship?u->ship->no:0;
ld->building = u->building?u->building->no:0;
ld->prevunit = prevunit;
u->building = (building*)ld; /* hack */
u->ship = NULL;
u->region = NULL;
u->items = i_new(i_silver, 10);
prevunit = u->no;
*ulostp = u;
ulostp = &u->next;
up = &u->next;
}
}
for (b = r->buildings; b; b = b2) {
bunhash(b);
free(b->name);
free(b->display);
b2 = b->next;
free(b);
}
for (s = r->ships; s; s = s2) {
sunhash(s);
free(s->name);
free(s->display);
s2 = s->next;
free(s);
}
*rp = r->next;
free_region(r);
}
while (*fp) {
faction * f = *fp;
if (f!=lostf) {
stripfaction(f);
*fp = f->next;
free(f);
} else {
fp = &f->next;
}
}
while (planes) {
plane * pl = planes;
planes = planes->next;
free(pl);
}
free_borders();
++turn;
if ((i=readgame(false))!=0) return i;
ulost=lostunits;
while (ulost) {
unit * u = ulost;
lostdata * ld = (lostdata*)u->building;
region * r = findregion(ld->x, ld->y);
ulost = u->next;
u->items = NULL;
if (r) {
unit ** up = &r->units;
u->region = r;
if (ld->prevunit) {
while (*up && (*up)->no!=ld->prevunit) up = &(*up)->next;
if (*up) up=&(*up)->next;
}
u->next = *up;
*up = u;
if (ld->building) {
building * b = r->buildings;
while (b && b->no!=ld->building) b = b->next;
if (b) u->building = b;
}
if (ld->ship) {
ship * s = r->ships;
while (s && s->no!=ld->ship) s = s->next;
if (s) u->ship = s;
}
}
}
if (!nowrite) {
char ztext[64];
sprintf(ztext, "%s/%d.fix", datapath(), turn);
writegame(ztext, 0);
}
return 0;
}
if ((i=readgame(false))!=0) return i;
#ifdef BETA_CODE
if (dungeonstyles) {
@ -730,13 +590,60 @@ main(int argc, char *argv[])
}
}
if (g_writemap) return crwritemap();
/* {
* faction * monster = findfaction(MONSTER_FACTION);
* display_item(monster, monster->units, it_find("mistletoe"));
* }
* */
if (demonfix==2) {
FILE * F = fopen("demons.fix", "r");
for (;;) {
int x, y, id, fno, size, age, number;
unit * u;
if (fscanf(F, "%d %d %d %d %d %d %d", &id, &age, &fno, &x, &y, &size, &number)<=0) break;
u = findunit(id);
if (u==NULL || u->faction->no!=fno) {
region * r = findregion(x, y);
if (r) for (u=r->units;u;u=u->next) if (u->number==number && u->age==age && u->faction->no==fno) break;
}
if (!u) {
log_error(("could not find unit %s and fix it!\n", itoa36(id)));
}
else u->skill_size = 0;
while (size--) {
int sk, value, weeks;
if (fscanf(F, "%d %d %d", &sk, &value, &weeks)<=0) break;
if (u) {
skill * sv = add_skill(u, (skill_t)sk);
sv->level = (unsigned char)value;
sv->weeks = (unsigned char)weeks;
}
else {
log_error((" %s[%u] : %u/%u\n", skillname((skill_t)sk, default_locale), sk, value, weeks));
}
}
}
fclose(F);
}
if ((i=processturn(orders))!=0) return i;
if (demonfix==1) {
region * r;
FILE * F = fopen("demons.fix", "w");
for (r=regions;r;r=r->next) {
unit * u;
for (u=r->units;u;u=u->next) {
if (u->number && fval(u, UFL_DEBUG)) {
skill * sv;
fprintf(F, "%d %d %d %d %d %d %d\n", u->no, u->age, u->faction->no, r->x, r->y, u->skill_size, u->number);
for (sv=u->skills;sv!=u->skills+u->skill_size;++sv) {
fprintf(F, "%d %d %d\n", sv->id, sv->level, sv->weeks);
}
fputc('\n', F);
}
}
}
fclose(F);
exit(0);
}
#ifdef CLEANUP_CODE
game_done();
#endif

View File

@ -873,7 +873,7 @@ mapper_spunit(dbllist ** SP, unit * u, int indent)
sncat(buf, " (", BUFSIZE); icat(u->hp/u->number); sncat(buf, " HP)", BUFSIZE);
if (fval(u, FL_GUARD))
if (getguard(u, UFL_GUARD))
sncat(buf, ", bewacht die Region", BUFSIZE);
if (usiege(u)) {