REGIONOWNERS (per makro enabled)

Implementiert:
- HELFE DURCHREISE
- NACH-Restriktionen
- Feindlisten, laden&speichern

Es fehlt noch:
- Schiffe
- Kontaktiere
- Parteitarnung
- Kriegserklärung
- Reportanzeigen
This commit is contained in:
Enno Rehling 2002-12-18 00:34:19 +00:00
parent 8c8f36f64c
commit c184a888a9
15 changed files with 170 additions and 87 deletions

View File

@ -31,6 +31,5 @@ void listnames(void);
void writemap(FILE * F, int mode); void writemap(FILE * F, int mode);
void regionspells(void); void regionspells(void);
void moveunit(void);
#endif #endif

View File

@ -1182,7 +1182,14 @@ set_ally(unit * u, strlist * S)
sf->status = HELP_ALL; sf->status = HELP_ALL;
break; break;
case P_GIB: case P_TRAVEL:
if (not_kw == P_NOT)
sf->status = sf->status & (HELP_ALL - HELP_TRAVEL);
else
sf->status = sf->status | HELP_TRAVEL;
break;
case P_GIB:
if (not_kw == P_NOT) if (not_kw == P_NOT)
sf->status = sf->status & (HELP_ALL - HELP_GIVE); sf->status = sf->status & (HELP_ALL - HELP_GIVE);
else else

View File

@ -12,7 +12,6 @@
* prior permission by the authors of Eressea. * prior permission by the authors of Eressea.
*/ */
#define FAST_SEEN 0
#define INDENT 0 #define INDENT 0
#include <config.h> #include <config.h>
@ -1672,6 +1671,10 @@ show_allies(const faction * f, const ally * allies)
for (h = 1; h < HELP_ALL; h *= 2) { for (h = 1; h < HELP_ALL; h *= 2) {
if ((mode & h) == h) if ((mode & h) == h)
switch (h) { switch (h) {
case HELP_TRAVEL:
scat("Durchreise");
hh = 1;
break;
case HELP_MONEY: case HELP_MONEY:
scat("Silber"); scat("Silber");
hh = 1; hh = 1;
@ -2574,52 +2577,6 @@ seen_done(void)
} }
} }
#if FAST_SEEN
static void
init_intervals()
{
region * r;
for (r=regions;r;r=r->next) {
unit * u;
attrib * a;
for (a=a_find(r->attribs, &at_travelunit);a;a=a->nexttype) {
unit * v = (unit*)a->data.v;
faction * f = v->faction;
if (!f) continue;
if (!f->first)
{
assert(!f->last);
f->first = r;
}
f->last = r->next;
}
for (a=a_find(r->attribs, &at_lighthouse);a;a=a->nexttype) {
building * b = (building*)a->data.v;
region * br = b->region;
if (!b->region) continue;
for (u=br->units;u;u=u->next) {
faction * f = u->faction;
if (!f->first)
{
assert(!f->last);
f->first = r;
}
f->last = r->next;
}
}
for (u=r->units;u;u=u->next) {
faction * f = u->faction;
if (!f->first)
{
assert(!f->last);
f->first = r;
}
f->last = r->next;
}
}
}
#endif
seen_region * seen_region *
find_seen(const region * r) find_seen(const region * r)
{ {
@ -2919,9 +2876,6 @@ reports(void)
printf("\n"); printf("\n");
report_donations(); report_donations();
#if FAST_SEEN
init_intervals();
#endif
remove_empty_units(); remove_empty_units();
log_printf("Report timestamp - %s\n", pzTime); log_printf("Report timestamp - %s\n", pzTime);
for (f = factions; f; f = f->next) { for (f = factions; f; f = f->next) {

View File

@ -151,6 +151,7 @@ const char *parameters[MAXPARAMS] =
"GEBÄUDE", "GEBÄUDE",
"GIB", /* Für HELFE */ "GIB", /* Für HELFE */
"KÄMPFE", "KÄMPFE",
"DURCHREISE",
"BEWACHE", "BEWACHE",
"ZAUBER", "ZAUBER",
"PAUSE", "PAUSE",
@ -478,9 +479,6 @@ stripfaction (faction * f)
free(f->passw); free(f->passw);
free(f->override); free(f->override);
free(f->name); free(f->name);
#ifndef FAST_REGION
vset_destroy(&f->regions);
#endif
while (f->attribs) a_remove (&f->attribs, f->attribs); while (f->attribs) a_remove (&f->attribs, f->attribs);
freelist(f->ursprung); freelist(f->ursprung);
funhash(f); funhash(f);

View File

@ -163,10 +163,16 @@ struct xml_stack;
#define CURSETYPE_VERSION 312 #define CURSETYPE_VERSION 312
#define ALLIANCES_VERSION 313 #define ALLIANCES_VERSION 313
#define DBLINK_VERSION 314 #define DBLINK_VERSION 314
#define REGIONOWNERS_VERSION 315
#define MIN_VERSION TYPES_VERSION #define MIN_VERSION TYPES_VERSION
#define UGROUPS_VERSION 400 /* nicht aktivieren, nicht fertig */ #define UGROUPS_VERSION 400 /* nicht aktivieren, nicht fertig */
#define RELEASE_VERSION ALLIANCES_VERSION
#ifdef REGIONOWNERS
# define RELEASE_VERSION REGIONOWNERS_VERSION
#else
# define RELEASE_VERSION DBLINK_VERSION
#endif
/* /*
#if RELEASE_VERSION >= UGROUPS_VERSION #if RELEASE_VERSION >= UGROUPS_VERSION
@ -495,6 +501,7 @@ enum {
P_GEBAEUDE, P_GEBAEUDE,
P_GIB, P_GIB,
P_KAEMPFE, P_KAEMPFE,
P_TRAVEL,
P_GUARD, P_GUARD,
P_ZAUBER, P_ZAUBER,
P_PAUSE, P_PAUSE,
@ -828,8 +835,9 @@ enum {
#define HELP_OBSERVE 4 /* Bei Wahrnehmung mithelfen */ #define HELP_OBSERVE 4 /* Bei Wahrnehmung mithelfen */
#define HELP_GIVE 8 /* Dinge annehmen ohne KONTAKTIERE */ #define HELP_GIVE 8 /* Dinge annehmen ohne KONTAKTIERE */
#define HELP_GUARD 16 /* Laesst Steuern eintreiben etc. */ #define HELP_GUARD 16 /* Laesst Steuern eintreiben etc. */
#define HELP_FSTEALTH 32 /* Laesst Steuern eintreiben etc. */ #define HELP_FSTEALTH 32 /* Parteitarnung anzeigen. */
#define HELP_ALL (63-HELP_OBSERVE) /* Alle "positiven" HELPs zusammen */ #define HELP_TRAVEL 64 /* Laesst Regionen betreten. */
#define HELP_ALL (127-HELP_OBSERVE) /* Alle "positiven" HELPs zusammen */
/* HELP_OBSERVE deaktiviert */ /* HELP_OBSERVE deaktiviert */
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
/* Prototypen */ /* Prototypen */

View File

@ -289,3 +289,40 @@ destroyfaction(faction * f)
} }
} }
#ifdef REGIONOWNERS
boolean
is_enemy(const struct faction * f, const struct faction * enemy)
{
struct faction_list * flist = f->enemies;
for (;flist!=NULL;flist=flist->next) {
if (flist->data==enemy) return true;
}
return false;
}
void
add_enemy(struct faction * f, struct faction * enemy)
{
if (!is_enemy(f, enemy)) {
struct faction_list * flist = malloc(sizeof(faction_list));
flist->next = f->enemies;
flist->data = enemy;
f->enemies = flist;
}
}
void
remove_enemy(struct faction * f, const struct faction * enemy)
{
struct faction_list **pflist = &f->enemies;
while (*pflist!=NULL) {
struct faction_list * flist = *pflist;
if (flist->data==enemy) {
*pflist = flist->next;
free(flist);
} else {
pflist = &flist->next;
}
}
}
#endif

View File

@ -61,13 +61,13 @@ typedef struct faction {
#endif #endif
#ifdef VICTORY_DELAY #ifdef VICTORY_DELAY
unsigned char victory_delay; unsigned char victory_delay;
#endif
#ifndef FAST_REGION
vset regions;
#endif #endif
struct unit * units; struct unit * units;
struct attrib *attribs; struct attrib *attribs;
struct message_list * msgs; struct message_list * msgs;
#ifdef REGIONOWNERS
struct faction_list * enemies;
#endif
struct bmsg { struct bmsg {
struct bmsg * next; struct bmsg * next;
struct region * r; struct region * r;
@ -89,4 +89,10 @@ extern struct unit * addplayer(struct region *r, const char *email,
extern boolean checkpasswd(const faction * f, const char * passwd); extern boolean checkpasswd(const faction * f, const char * passwd);
extern void destroyfaction(faction * f); extern void destroyfaction(faction * f);
#ifdef REGIONOWNERS
extern boolean is_enemy(const struct faction * f, const struct faction * enemy);
extern void add_enemy(struct faction * f, struct faction * enemy);
extern void remove_enemy(struct faction * f, const struct faction * enemy);
#endif
#endif #endif

View File

@ -143,6 +143,19 @@ static attrib_type at_driveweight = {
"driveweight", NULL, NULL, NULL, NULL, NULL "driveweight", NULL, NULL, NULL, NULL, NULL
}; };
static boolean
entrance_allowed(const struct unit * u, const struct region * r)
{
#ifdef REGIONOWNERS
unit * owner = region_owner(r);
if (owner==NULL || u->faction==owner->faction) return true;
if (alliedunit(owner, u->faction, HELP_TRAVEL)) return true;
if (is_enemy(u->faction, owner->faction)) return true;
return false;
#endif
return true;
}
int int
personcapacity(const unit *u) personcapacity(const unit *u)
{ {
@ -1073,6 +1086,11 @@ travel(region * first, unit * u, region * next, int flucht)
ADDMSG(&u->faction->msgs, msg_message("leavefail", ADDMSG(&u->faction->msgs, msg_message("leavefail",
"unit region", u, next)); "unit region", u, next));
} }
if (!entrance_allowed(u, next)) {
ADDMSG(&u->faction->msgs, msg_message("regionowned",
"unit region target", u, current, next));
break;
}
if ((wache = bewegung_blockiert_von(u, current)) != (unit *) NULL if ((wache = bewegung_blockiert_von(u, current)) != (unit *) NULL
&& gereist != 0) && gereist != 0)
{ {

View File

@ -25,6 +25,7 @@
/* kernel includes */ /* kernel includes */
#include "border.h" #include "border.h"
#include "building.h"
#include "curse.h" #include "curse.h"
#include "faction.h" #include "faction.h"
#include "item.h" #include "item.h"
@ -32,6 +33,7 @@
#include "plane.h" #include "plane.h"
#include "region.h" #include "region.h"
#include "resources.h" #include "resources.h"
#include "unit.h"
/* util includes */ /* util includes */
#include <resolve.h> #include <resolve.h>
@ -1090,4 +1092,24 @@ r_addmessage(struct region * r, const struct faction * viewer, struct message *
return add_message(&imsg->msgs, msg); return add_message(&imsg->msgs, msg);
} }
struct unit *
region_owner(const struct region * r)
{
#ifdef REGIONOWNERS
struct unit * owner = NULL;
int maxsize = 0;
building * b = r->buildings;
for (;b!=NULL;b=b->next) {
if (b->size>maxsize) {
unit * u = buildingowner(r, b);
if (u) {
owner = u;
maxsize=b->size;
}
}
}
return owner;
#else
return NULL;
#endif
}

View File

@ -218,4 +218,6 @@ extern int production(const struct region *r);
extern int read_region_reference(struct region ** r, FILE * F); extern int read_region_reference(struct region ** r, FILE * F);
extern void write_region_reference(const struct region * r, FILE * F); extern void write_region_reference(const struct region * r, FILE * F);
extern struct unit * region_owner(const struct region * r);
#endif /* _REGION_H */ #endif /* _REGION_H */

View File

@ -56,14 +56,6 @@ char *translate_regions(const char *st, const struct faction * f);
char *replace_global_coords(const char *s, const struct faction * f); char *replace_global_coords(const char *s, const struct faction * f);
#ifdef USE_MERIAN
#ifdef FAST_REGION
void merian(FILE * out, struct faction *f);
#else
void merian(FILE * out, vset* regs, struct faction *f);
#endif
#endif
char *f_regionid(const struct region *r, const struct faction *f); char *f_regionid(const struct region *r, const struct faction *f);
/* für fast_region und neuen CR: */ /* für fast_region und neuen CR: */

View File

@ -434,6 +434,38 @@ getbuf(FILE * F)
return buf; return buf;
} }
#ifdef REGIONOWNERS
static void
read_enemies(FILE * F, faction * f)
{
if (global.data_version<REGIONOWNERS_VERSION) return;
f->enemies = NULL;
for (;;) {
char zText[32];
fscanf(F, "%s", zText);
if (strcmp(zText, "end")==0) break;
else {
int fno = atoi36(zText);
faction_list * flist = malloc(sizeof(faction_list));
flist->next = f->enemies;
f->enemies = flist;
ur_add((void*)fno, (void**)&flist->data, resolve_faction);
}
}
}
static void
write_enemies(FILE * F, const faction_list * flist)
{
#if RELEASE_VERSION>=REGIONOWNERS_VERSION
while (flist) {
fprintf(F, "%s ", itoa36(flist->data->no));
}
fputs("end\n", F);
#endif
}
#endif
static unit * static unit *
unitorders(FILE * F, struct faction * f) unitorders(FILE * F, struct faction * f)
{ {
@ -2188,6 +2220,9 @@ readfaction(FILE * F)
} }
} }
read_groups(F, f); read_groups(F, f);
#ifdef REGIONOWNERS
read_enemies(F, f);
#endif
return f; return f;
} }
@ -2242,4 +2277,7 @@ writefaction(FILE * F, const faction * f)
fprintf(F, "end"); fprintf(F, "end");
wnl(F); wnl(F);
write_groups(F, f->groups); write_groups(F, f->groups);
#ifdef REGIONOWNERS
write_enemies(F, f->enemies);
#endif
} }

View File

@ -43,6 +43,7 @@
#define NEWATSROI 0 #define NEWATSROI 0
#define CHECK_OVERLOAD_ON_ENTER #define CHECK_OVERLOAD_ON_ENTER
#undef REGIONOWNERS
#define MUSEUM_MODULE #define MUSEUM_MODULE
#define ARENA_MODULE #define ARENA_MODULE

View File

@ -5393,17 +5393,22 @@
</locale> </locale>
</message> </message>
<message name="moveblockedbyguard"> <message name="regionowned" section="movement">
<type>
<arg name="unit" type="unit"></arg>
<arg name="region" type="region"></arg>
<arg name="target" type="region"></arg>
</type>
<text locale="de">"$unit($unit) konnte nicht von $region($region) nach $region($target) reisen, da der Besitzer der Region es verhinderte."</text>
</message>
<message name="moveblockedbyguard" section="movement">
<type> <type>
<arg name="unit" type="unit"></arg> <arg name="unit" type="unit"></arg>
<arg name="region" type="region"></arg> <arg name="region" type="region"></arg>
<arg name="guard" type="unit"></arg> <arg name="guard" type="unit"></arg>
</type> </type>
<locale name="de"> <text locale="de">"$unit($unit) wurde in $region($region) von $unit($guard) aufgehalten."</text>
<nr section="movement">
<text>"$unit($unit) wurde in $region($region) von $unit($guard) aufgehalten."</text>
</nr>
</locale>
</message> </message>
<message name="sailfail"> <message name="sailfail">
@ -7730,20 +7735,12 @@
<text locale="en">"($int36($id))"</text> <text locale="en">"($int36($id))"</text>
</message> </message>
<message name="mallorn_effect"> <message name="mallorn_effect" section="magic">
<type> <type>
<arg name="mage" type="unit"></arg> <arg name="mage" type="unit"></arg>
</type> </type>
<locale name="de"> <text locale="de">"$unit($mage) läßt einen Teil seiner selbst in die Erde fliessen. Die Bäume, die Transformation überlebt haben, erscheinen nun viel kräftiger."</text>
<nr section="magic"> <text locale="en">"The power of $unit($mage) flows into the region and the trees which survived the spell appear stronger now."</text>
<text>"$unit($mage) läßt einen Teil seiner selbst in die Erde fliessen. Die Bäume, die Transformation überlebt haben, erscheinen nun viel kräftiger."</text>
</nr>
</locale>
<locale name="en">
<nr section="magic">
<text>"The power of $unit($mage) flows into the region and the trees which survived the spell appear stronger now."</text>
</nr>
</locale>
</message> </message>
</messages> </messages>

View File

@ -1626,6 +1626,10 @@
<string name="KRÄUTER"> <string name="KRÄUTER">
<text locale="de">KRÄUTER</text> <text locale="de">KRÄUTER</text>
</string> </string>
<string name="DURCHREISE">
<text locale="de">DURCHREISE</text>
<text locale="en">TRAVEL</text>
</string>
<string name="KÄMPFE"> <string name="KÄMPFE">
<text locale="de">KÄMPFE</text> <text locale="de">KÄMPFE</text>
</string> </string>