dev-version: einbau allen neuen sources aus beta-branch. otherfaction.h fehlt, corwin

This commit is contained in:
Enno Rehling 2001-04-14 12:11:45 +00:00
parent c106e40fb7
commit 7dfb177044
23 changed files with 226 additions and 65 deletions

View File

@ -26,7 +26,8 @@ LDFLAGS = $(LIBS)
LIBS = -L$(PUBLISH_DIR)
LINTFLAGS = -booltype boolean -boolops +posixlib +matchanyintegral \
-predboolint -retvalint -retvalother -realcompare -exportlocal
-predboolint -retvalint -retvalother -realcompare -exportlocal \
-DHAVE_READDIR
ARCHITECTURE = Linux

View File

@ -1,4 +1,5 @@
/* vi: set ts=2:
*
*
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
@ -25,6 +26,7 @@
#include "iceberg.h"
#include "hate.h"
#include "overrideroads.h"
#include "otherfaction.h"
#include "racename.h"
#ifdef AT_OPTION
# include "option.h"
@ -53,6 +55,7 @@ init_attributes(void)
init_orcification();
init_hate();
init_reduceproduction();
init_otherfaction();
init_racename();
#ifdef AT_MOVED
init_moved();

View File

@ -1,4 +1,5 @@
/* vi: set ts=2:
*
*
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
@ -24,6 +25,7 @@
/* attributes include */
#include <attributes/follow.h>
#include <attributes/otherfaction.h>
#include <attributes/racename.h>
/* gamecode includes */
@ -413,7 +415,7 @@ cr_output_unit(FILE * F, region * r,
if (strlen(u->display))
fprintf(F, "\"%s\";Beschr\n", u->display);
if ((u->faction == f || omniscient(f)) || !fval(u, FL_PARTEITARNUNG)) {
if( u->faction == f || omniscient(f)) {
#ifdef GROUPS
if (u->faction == f) {
const attrib * a = a_find(u->attribs, &at_group);
@ -424,6 +426,13 @@ cr_output_unit(FILE * F, region * r,
}
#endif
fprintf(F, "%d;Partei\n", u->faction->no);
} else if(!fval(u, FL_PARTEITARNUNG)) {
attrib *a = a_find(u->attribs, &at_otherfaction);
if(a) {
fprintf(F, "%d;Partei\n", a->data.i);
} else {
fprintf(F, "%d;Partei\n", u->faction->no);
}
}
if(u->faction != f && a_fshidden
@ -463,6 +472,8 @@ cr_output_unit(FILE * F, region * r,
unit * u = (unit*)a->data.v;
if (u) fprintf(F, "%d;folgt\n", u->no);
}
a = a_find(u->attribs, &at_otherfaction);
if(a) fprintf(F, "%d;verkleidung\n", a->data.i);
i = ualias(u);
if (i>0)
fprintf(F, "%d;temp\n", i);

View File

@ -254,16 +254,16 @@ expandrecruit(region * r, request * recruitorders)
race_t rc = u->faction->race;
int recruitcost = race[rc].rekrutieren;
/* check if recruiting is limited. either horses or peasant fraction or not at all */
/* check if recruiting is limited.
* either horses or peasant fraction or not at all */
if ((race[rc].ec_flags & ECF_REC_UNLIMITED)==0) {
/* not unlimited, and everything's gone: */
if (race[rc].ec_flags & ECF_REC_HORSES) {
/* recruit from horses if not all gone */
if (h <= 0) continue;
}
else if ((race[rc].ec_flags & ECF_REC_ETHEREAL) == 0) {
} else if ((race[rc].ec_flags & ECF_REC_ETHEREAL) == 0) {
/* recruit from peasants if any space left */
if (n > rfrac) continue;
if (n >= rfrac) continue;
}
}
if (recruitcost) {

View File

@ -1,4 +1,5 @@
/* vi: set ts=2:
*
*
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
@ -80,6 +81,8 @@
#include <assert.h>
#include <ctype.h>
#include <attributes/otherfaction.h>
/* - external symbols ------------------------------------------ */
extern int dropouts[2];
extern int * age;
@ -96,6 +99,7 @@ findoption(char *s)
static void
destroyfaction(faction * f)
{
region *rc;
unit *u;
faction *ff;
@ -198,16 +202,27 @@ destroyfaction(faction * f)
}
#endif
}
/* units of other factions that were disguised as this faction
* have their disguise replaced by ordinary faction hiding. */
for(rc=regions; rc; rc=rc->next) {
for(u=rc->units; u; u=u->next) {
attrib *a = a_find(u->attribs, &at_otherfaction);
if(!a) continue;
if(a->data.i == f->no) {
a_removeall(&u->attribs, &at_otherfaction);
fset(u, FL_PARTEITARNUNG);
}
}
}
}
void
restart(unit *u, int race)
{
#ifdef ALLOW_RESTART
faction *f = addplayer(u->region, u->faction->email, race)->faction;
f->magiegebiet = u->faction->magiegebiet;
destroyfaction(u->faction);
#endif
}
/* ------------------------------------------------------------- */
@ -2246,7 +2261,18 @@ renumber_factions(void)
}
}
for (rp=renum;rp;rp=rp->next) {
region *r;
unit *u;
a_remove(&rp->faction->attribs, rp->attrib);
/* all units disguised as belonging to this faction have their
* attribute changed */
for(r=regions; r; r=r->next) {
for(u=r->units; u; u=u->next) {
attrib *a = a_find(u->attribs, &at_otherfaction);
if(!a) continue;
a->data.i = rp->want;
}
}
rp->faction->no = rp->want;
register_faction_id(rp->want);
fset(rp->faction, FF_NEWID);

View File

@ -1,4 +1,5 @@
/* vi: set ts=2:
*
*
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
@ -488,8 +489,9 @@ monster_seeks_target(region *r, unit *u)
}
/* TODO: prüfen, ob target überhaupt noch existiert... */
if(!target) return; /* this is a bug workaround! remove!! */
if( r == target->region ) { /* Wir haben ihn! */
if(r == target->region ) { /* Wir haben ihn! */
switch( u->race ) {
case RC_ALP:
alp_findet_opfer(u, r);

View File

@ -1,4 +1,5 @@
/* vi: set ts=2:
*
*
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
@ -1282,8 +1283,9 @@ randomevents(void)
set_skill(u, SK_OBSERVATION, u->number * (rand() % 180));
set_skill(u, SK_AUSDAUER, u->number * 30);
set_skill(u, SK_STEALTH, u->number * 30);
fprintf(stderr, "%d %s in %s.\n", u->number,
log_printf("%d %s in %s.\n", u->number,
race[u->race].name[1], regionname(r, NULL));
name_unit(u);
set_string(&u->lastorder, "WARTEN");
@ -1362,8 +1364,9 @@ randomevents(void)
set_string(&u->lastorder, "WARTEN");
name_unit(u);
fprintf(stderr, "%d %s in %s.\n", u->number,
log_printf("%d %s in %s.\n", u->number,
race[u->race].name[1], regionname(r, NULL));
add_message(&r->msgs, new_message(NULL,
"undeadrise%r:region", r));
for (u=r->units;u;u=u->next) freset(u->faction, FL_DH);
@ -1414,7 +1417,8 @@ randomevents(void)
else
set_string(&u->name, "Wütende Ents");
fprintf(stderr, "%d Ents in %s.\n", u->number, regionname(r, NULL));
log_printf("%d Ents in %s.\n", u->number, regionname(r, NULL));
add_message(&r->msgs, new_message(NULL,
"entrise%r:region", r));
for (u=r->units;u;u=u->next) freset(u->faction, FL_DH);

View File

@ -1,4 +1,5 @@
/* vi: set ts=2:
*
*
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
@ -22,6 +23,7 @@
/* attributes includes */
#include <attributes/overrideroads.h>
#include <attributes/otherfaction.h>
#ifdef AT_OPTION
# include <attributes/option.h>
#endif
@ -62,6 +64,7 @@
#include <nrmessage.h>
#include <translation.h>
#include <util/message.h>
#include <log.h>
/* libc includes */
#include <assert.h>
@ -101,7 +104,7 @@ read_datenames(const char *filename)
int i, l;
if( (namesFP=fopen(filename,"r")) == NULL) {
fprintf(stderr, "Kann Datei '%s' nicht öffnen, Abbruch\n",filename);
log_error(("Kann Datei '%s' nicht öffnen, Abbruch\n", filename));
return -1;
}
@ -2778,10 +2781,9 @@ can_find(faction * f, faction * f2)
}
void
add_find(faction * f, unit * u)
add_find(faction * f, unit * u, faction *f2)
{
/* faction f sees f2 through u */
faction * f2 = u->faction;
int key = f->no % FMAXHASH;
struct fsee ** fp = &fsee[key];
struct fsee * fs;
@ -2817,8 +2819,15 @@ update_find(void)
if (u2->faction==lastf || u2->faction==u->faction)
continue;
if (seefaction(u->faction, r, u2, 0)) {
attrib *a = a_find(u2->attribs, &at_otherfaction);
if(a) {
faction *f = findfaction(a->data.i);
lastf=f;
add_find(u->faction, u2, f);
} else {
lastf=u2->faction;
add_find(u->faction, u2);
add_find(u->faction, u2, u2->faction);
}
}
}
}

View File

@ -1,4 +1,5 @@
/* vi: set ts=2:
*
*
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
@ -51,6 +52,8 @@
#include <stdlib.h>
#include <string.h>
#include <attributes/otherfaction.h>
void
spy(region * r, unit * u)
{
@ -136,12 +139,30 @@ setstealth(unit * u, strlist * S)
switch(findparam(s)) {
case P_FACTION:
/* TARNE PARTEI [NICHT] */
/* TARNE PARTEI [NICHT|NUMMER abcd] */
s = getstrtoken();
if (findparam(s) == P_NOT) {
freset(u, FL_PARTEITARNUNG);
} else {
if(!s || *s == 0) {
fset(u, FL_PARTEITARNUNG);
} else if (findparam(s) == P_NOT) {
freset(u, FL_PARTEITARNUNG);
} else if (findkeyword(s) == K_NUMBER) {
char *s2 = getstrtoken();
int nr;
if(!s2 || *s2 == 0 || (nr = atoi36(s2)) == u->faction->no) {
a_removeall(&u->faction->attribs, &at_otherfaction);
} else {
/* TODO: Prüfung ob Partei sichtbar */
if(!findfaction(nr)) {
cmistake(u, S->s, 66, MSG_EVENT);
} else {
attrib *a;
a = a_find(u->attribs, &at_otherfaction);
if(!a) a = a_add(&u->attribs, a_new(&at_otherfaction));
a->data.i = nr;
}
}
} else {
cmistake(u, S->s, 289, MSG_EVENT);
}
break;
case P_ANY:

View File

@ -1,4 +1,5 @@
/* vi: set ts=2:
*
*
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)

View File

@ -1,4 +1,5 @@
/* vi: set ts=2:
*
*
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)

View File

@ -1,4 +1,5 @@
/* vi: set ts=2:
*
*
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
@ -59,6 +60,7 @@ typedef enum combatmagic {
#include <base36.h>
#include <cvector.h>
#include <rand.h>
#include <log.h>
/* attributes includes */
#include <attributes/key.h>
@ -3020,7 +3022,7 @@ make_battle(region * r)
sprintf(zFilename, "%s/battle-%d-%s.log", zText, obs_count, simplename(r));
bdebug = fopen(zFilename, "w");
#endif
if (!bdebug) fputs("battles können nicht debugged werden\n", stderr);
if (!bdebug) log_error(("battles können nicht debugged werden\n"));
else {
dbgprintf((bdebug, "In %s findet ein Kampf statt:", rname(r, NULL)));
}

View File

@ -11,15 +11,21 @@
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
*/
#include <config.h>
#include "eressea.h"
#include "faction.h"
#include "unit.h"
#include "race.h"
#include "region.h"
#include "plane.h"
/* util includes */
#include <base36.h>
/* libc includes */
#include <stdio.h>
#include <stdlib.h>
const char *
factionname(const faction * f)
@ -42,3 +48,65 @@ void *
resolve_faction(void * id) {
return findfaction((int)id);
}
#define MAX_FACTION_ID (36*36*36*36)
static int
unused_faction_id(void)
{
int id = rand()%MAX_FACTION_ID;
while(!faction_id_is_unused(id)) {
id++; if(id == MAX_FACTION_ID) id = 0;
}
return id;
}
unit *
addplayer(region *r, char *email, race_t frace)
{
int i;
unit *u;
faction *f = (faction *) calloc(1, sizeof(faction));
set_string(&f->email, email);
for (i = 0; i < 6; i++) buf[i] = (char) (97 + rand() % 26); buf[i] = 0;
set_string(&f->passw, buf);
f->lastorders = turn;
f->alive = 1;
f->age = 0;
f->race = frace;
f->magiegebiet = 0;
set_ursprung(f, 0, r->x, r->y);
f->options = Pow(O_REPORT) | Pow(O_ZUGVORLAGE) | Pow(O_SILBERPOOL);
f->no = unused_faction_id();
register_faction_id(f->no);
f->unique_id = max_unique_id + 1;
max_unique_id++;
sprintf(buf, "Partei %s", factionid(f));
set_string(&f->name, buf);
fset(f, FL_UNNAMED);
addlist(&factions, f);
u = createunit(r, f, 1, f->race);
give_starting_equipment(r, u);
fset(u, FL_ISNEW);
if (f->race == RC_DAEMON) {
do
u->irace = (char) (rand() % MAXRACES);
while (u->irace == RC_DAEMON || race[u->irace].nonplayer);
}
fset(u, FL_PARTEITARNUNG);
return u;
}

View File

@ -65,5 +65,6 @@ typedef struct faction {
extern const char * factionname(const struct faction * f);
extern void * resolve_faction(void * data);
extern struct unit * addplayer(struct region *r, char *email, race_t frace);
#endif

View File

@ -251,8 +251,8 @@ struct fspecialdata fspecials[MAXFACTIONSPECIALS] = {
"komplett.",
100
},
{ /* TODO: Namen ändern */
"Schnell",
{
"Windvolk",
"Ein solches Volk ist sehr athletisch und die Kinder üben besonders "
"den Langstreckenlauf von kleinauf. Nach jahrelangem Training sind "
"sie dann in der Lage, sich zu Fuß so schnell zu bewegen als würden "

View File

@ -1,5 +1,4 @@
/* vi: set ts=2:
*
*
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
@ -31,11 +30,12 @@
#include "building.h"
/* util includes */
#include <goodies.h>
#include <base36.h>
#include <goodies.h>
#include <message.h>
#include <nrmessage.h>
#include <crmessage.h>
#include <log.h>
/* libc includes */
#include <stddef.h>
@ -428,7 +428,7 @@ caddmessage(region * r, faction * f, char *s, msg_t mtype, int level)
m = add_message(&r->msgs, new_message(f, "msg_event%s:string", s));
break;
default:
fprintf(stderr, "Warnung: Ungültige Msg-Klasse!");
assert(!"Ungültige Msg-Klasse!");
}
}

View File

@ -44,6 +44,7 @@
/* attributes includes */
#include <attributes/follow.h>
#include <attributes/otherfaction.h>
#include <attributes/racename.h>
const char * g_reportdir;
@ -124,8 +125,10 @@ hp_status(const unit * u)
{
double p = (double) ((double) u->hp / (double) (u->number * unit_max_hp(u)));
if (p > 1.25)
return "magisch gestärkt";
if (p > 2.00)
return "sehr stark";
if (p > 1.50)
return "stark";
if (p < 0.50)
return "schwer verwundet";
if (p < 0.75)
@ -178,6 +181,8 @@ bufunit(const faction * f, const unit * u, int indent,
int i, dh;
skill_t sk;
int getarnt = fval(u, FL_PARTEITARNUNG);
attrib *a_otherfaction = NULL;
const char *c;
const char *pzTmp;
spell *sp;
building * b;
@ -193,22 +198,35 @@ bufunit(const faction * f, const unit * u, int indent,
strcpy(buf, unitname(u));
if (!getarnt && (u->faction != f)) {
scat(", ");
scat(factionname(u->faction));
} else {
a_otherfaction = a_find(u->attribs, &at_otherfaction);
if (u->faction == f) {
#ifdef GROUPS
if (u->faction==f) {
attrib * a = a_find(u->attribs, &at_group);
attrib *a = a_find(u->attribs, &at_group);
if (a) {
group * g = (group*)a->data.v;
scat(", ");
scat(groupid(g, f));
}
}
#endif
if (getarnt) scat(", parteigetarnt");
if (getarnt) {
scat(", parteigetarnt");
} else if (a_otherfaction) {
scat(", ");
scat(factionname(findfaction(a_otherfaction->data.i)));
}
} else {
if (getarnt) {
scat(", parteigetarnt");
} else if(a_otherfaction) {
scat(", ");
scat(factionname(findfaction(a_otherfaction->data.i)));
} else {
scat(", ");
scat(factionname(u->faction));
}
}
scat(", ");
if(u->faction != f && a_fshidden
&& a_fshidden->data.ca[0] == 1 && effskill(u, SK_STEALTH) >= 6) {

View File

@ -32,7 +32,7 @@ extern const char *neue_gebiete[];
/* kann_finden speedups */
extern boolean kann_finden(struct faction * f1, struct faction * f2);
extern void add_find(struct faction *, struct unit *);
extern void add_find(struct faction *, struct unit *, struct faction *);
extern struct unit * can_find(struct faction *, struct faction *);
/* funktionen zum schreiben eines reports */
extern int read_datenames(const char *filename);

View File

@ -1134,7 +1134,7 @@ fix_age(void)
for (f=factions;f;f=f->next) {
if (f->no!=MONSTER_FACTION && !nonplayer_race(f->race)) continue;
if (f->age!=turn) {
fprintf(stderr, " - Alter von Partei %s anpassen", factionid(f));
log_printf("Alter von Partei %s auf %d angepasst.\n", factionid(f), turn);
f->age = turn;
}
}
@ -1915,7 +1915,10 @@ fix_herbs(void)
for (r=regions; r; r=r->next) if (rterrain(r) == T_PLAIN) {
const herb_type *htype = rherbtype(r);
assert(htype);
if (htype==NULL) {
htype = htypes[i];
rsetherbtype(r, htype);
}
for (i=0;i!=6;++i) if (htypes[i]==htype) break;
assert(i!=6);
herbs[i]++;

View File

@ -1,17 +1,7 @@
alchemy.h
creation.h
economy.h
magic.h
race.h
randenc.h
alp.c
build.c
creation.c
creport.c
economy.c
laws.c
monster.c
randenc.c
report.c
spy.c
study.c
common/gamecode/economy.c
common/gamecode/randenc.c
common/gamecode/report.c
common/kernel/karma.c
common/kernel/message.c
common/kernel/reports.c
mapper/map_partei.c

View File

@ -1,5 +1,4 @@
/* vi: set ts=2:
*
*
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)

View File

@ -54,7 +54,7 @@ error48;errors:0;de;{unit} in {region}: '{command}' - Die Einheit ist nicht bewa
error49;errors:0;de;{unit} in {region}: '{command}' - Die Einheit ist nicht der Eigentümer.
error50;errors:0;de;{unit} in {region}: '{command}' - Die Einheit ist nicht erfahren genug dafür.
error51;errors:0;de;{unit} in {region}: '{command}' - Die Einheit hat nicht genug Silber.
error52;errors:0;de;{unit} in {region}: '{command}' - Die Einheit ist vom Kampf erschöpft.
error52;errors:0;de;{unit} in {region}: '{command}' - Die Einheit kann keinen langen Befehl mehr ausführen.
error53;errors:0;de;{unit} in {region}: '{command}' - Die Einheit kann keine Tränke herstellen.
error54;errors:0;de;{unit} in {region}: '{command}' - Die Einheit kann nicht handeln.
error55;errors:0;de;{unit} in {region}: '{command}' - Die Einheit kann sich nicht fortbewegen.
@ -287,6 +287,7 @@ error285;errors:0;de;{unit} in {region}: '{command}' - Diese Einheit kennt keine
error286;errors:0;de;{unit} in {region}: '{command}' - Die Einheit transportiert uns nicht.
error287;errors:0;de;{unit} in {region}: '{command}' - Dorthin können wir die Einheit nicht transportieren.
error288;errors:0;de;{unit} in {region}: '{command}' - Wieviel sollen wir einreißen?
error289;errors:0;de;{unit} in {region}: '{command}' - Tarne wie?
# Meldungen und Ereignisse
msg_event;events:0;de;{string}