- knowlegdeg in #define USE_KNOWLEDGEgeklammert (ist noch kaum angefangen)

- ugroups in #define USE_UGROUPS geklammert (im makefile definieren, bis die ganz durchgetestet sind)
This commit is contained in:
Enno Rehling 2001-04-29 19:27:42 +00:00
parent 1dbaf7ffcd
commit 63f0c81ebd
11 changed files with 66 additions and 29 deletions

View File

@ -28,7 +28,9 @@
#include "overrideroads.h" #include "overrideroads.h"
#include "otherfaction.h" #include "otherfaction.h"
#include "racename.h" #include "racename.h"
#ifdef USE_UGROUPS
# include "ugroup.h" # include "ugroup.h"
#endif
#ifdef AT_OPTION #ifdef AT_OPTION
# include "option.h" # include "option.h"
#endif #endif
@ -64,5 +66,7 @@ init_attributes(void)
#ifdef AT_OPTION #ifdef AT_OPTION
init_option(); init_option();
#endif #endif
#ifdef USE_UGROUPS
init_ugroup(); init_ugroup();
#endif
} }

View File

@ -8,13 +8,16 @@
This program may not be used, modified or distributed This program may not be used, modified or distributed
without prior permission by the authors of Eressea. without prior permission by the authors of Eressea.
$Id: ugroup.c,v 1.1 2001/04/28 12:03:12 corwin Exp $ $Id: ugroup.c,v 1.2 2001/04/29 19:27:41 enno Exp $
*/ */
#include <config.h> #include <config.h>
#include "ugroup.h" #include "ugroup.h"
#include <attrib.h> #include <attrib.h>
#ifdef USE_UGROUPS
attrib_type at_ugroup = { attrib_type at_ugroup = {
"ugroup", NULL, NULL, NULL, NULL, NULL, ATF_UNIQUE "ugroup", NULL, NULL, NULL, NULL, NULL, ATF_UNIQUE
}; };
@ -24,3 +27,5 @@ init_ugroup(void)
{ {
at_register(&at_ugroup); at_register(&at_ugroup);
} }
#endif

View File

@ -58,8 +58,9 @@
#include <pool.h> #include <pool.h>
#include <building.h> #include <building.h>
#include <group.h> #include <group.h>
#ifdef USE_UGROUPS
# include <ugroup.h> # include <ugroup.h>
#endif
/* attributes includes */ /* attributes includes */
#include <attributes/racename.h> #include <attributes/racename.h>
@ -3035,8 +3036,10 @@ processorders (void)
puts(" - Jihads setzen"); puts(" - Jihads setzen");
set_jihad(); set_jihad();
#ifdef USE_UGROUPS
puts(" - Verbände bilden"); puts(" - Verbände bilden");
ugroups(); ugroups();
#endif
puts(" - Einheiten Sortieren"); puts(" - Einheiten Sortieren");
reorder(); reorder();

View File

@ -58,7 +58,9 @@
#include <skill.h> #include <skill.h>
#include <teleport.h> #include <teleport.h>
#include <unit.h> #include <unit.h>
#ifdef USE_UGROUPS
# include <ugroup.h> # include <ugroup.h>
#endif
/* util includes */ /* util includes */
#include <goodies.h> #include <goodies.h>
@ -682,10 +684,12 @@ rpunit(FILE * F, const faction * f, const unit * u, int indent, int mode)
strlist *S; strlist *S;
int dh; int dh;
boolean isbattle = (boolean)(mode == see_battle); boolean isbattle = (boolean)(mode == see_battle);
#ifdef USE_UGROUPS
ugroup *ug = findugroup(u); ugroup *ug = findugroup(u);
#endif
if(u->race == RC_SPELL) return; if(u->race == RC_SPELL) return;
#ifdef USE_UGROUPS
if(isbattle || ug) { if(isbattle || ug) {
if(is_ugroupleader(u, ug)) { if(is_ugroupleader(u, ug)) {
rnl(F); rnl(F);
@ -693,23 +697,27 @@ rpunit(FILE * F, const faction * f, const unit * u, int indent, int mode)
} else { } else {
return; return;
} }
} else { } else
#endif
{
rnl(F); rnl(F);
dh = bufunit(f, u, indent, mode); dh = bufunit(f, u, indent, mode);
} }
rparagraph(F, buf, indent, (char) ((u->faction == f) ? '*' : (dh ? '+' : '-'))); rparagraph(F, buf, indent, (char) ((u->faction == f) ? '*' : (dh ? '+' : '-')));
if(!isbattle){ if(!isbattle){
#ifdef USE_UGROUPS
if(ug) { if(ug) {
int i; int i;
for(i=0; i<ug->members; i++) { for(i=0; i<ug->members; i++) {
print_curses(F, u, TYP_UNIT, ug->unit_array[i]->attribs, (u->faction == f)? 1 : 0, indent); print_curses(F, u, TYP_UNIT, ug->unit_array[i]->attribs, (u->faction == f)? 1 : 0, indent);
} }
} else { } else
#endif /* USE_UGROUPS */
print_curses(F, u, TYP_UNIT, u->attribs, (u->faction == f)? 1 : 0, indent); print_curses(F, u, TYP_UNIT, u->attribs, (u->faction == f)? 1 : 0, indent);
} }
}
#ifdef USE_UGROUPS
if(ug) { if(ug) {
int i; int i;
for(i=0; i<ug->members; i++) { for(i=0; i<ug->members; i++) {
@ -720,7 +728,8 @@ rpunit(FILE * F, const faction * f, const unit * u, int indent, int mode)
} }
} }
} }
} else { } else
#endif
if (mode==see_unit && u->faction == f && u->botschaften) { if (mode==see_unit && u->faction == f && u->botschaften) {
for (S = u->botschaften; S; S = S->next) { for (S = u->botschaften; S; S = S->next) {
rnl(F); rnl(F);
@ -728,7 +737,6 @@ rpunit(FILE * F, const faction * f, const unit * u, int indent, int mode)
} }
} }
} }
}
static void static void
rp_messages(FILE * F, message_list * msgs, faction * viewer, int indent, boolean centered, boolean categorized) rp_messages(FILE * F, message_list * msgs, faction * viewer, int indent, boolean centered, boolean categorized)

View File

@ -204,8 +204,10 @@ const char *keywords[MAXKEYWORDS] =
"JIHAD", "JIHAD",
"GM", "GM",
"INFO", "INFO",
#ifdef USE_UGROUPS
"JOINVERBAND", "JOINVERBAND",
"LEAVEVERBAND" "LEAVEVERBAND"
#endif
}; };
const char *report_options[MAX_MSG] = const char *report_options[MAX_MSG] =

View File

@ -412,8 +412,10 @@ enum {
K_SETJIHAD, K_SETJIHAD,
K_GM, /* perform GM commands */ K_GM, /* perform GM commands */
K_INFO, /* set player-info */ K_INFO, /* set player-info */
#ifdef USE_UGROUPS
K_JOINUGROUP, K_JOINUGROUP,
K_LEAVEUGROUP, K_LEAVEUGROUP,
#endif
MAXKEYWORDS, MAXKEYWORDS,
NOKEYWORD = (keyword_t) - 1 NOKEYWORD = (keyword_t) - 1
}; };

View File

@ -41,7 +41,9 @@ typedef struct faction {
int options; int options;
int no_units; int no_units;
int karma; int karma;
#ifdef USE_UGROUPS
struct ugroup *ugroups; struct ugroup *ugroups;
#endif
struct warning * warnings; struct warning * warnings;
struct msglevel * msglevels; struct msglevel * msglevels;
struct ally *allies; struct ally *allies;

View File

@ -32,7 +32,9 @@
#include "ship.h" #include "ship.h"
#include "race.h" #include "race.h"
#include "magic.h" #include "magic.h"
#ifdef USE_UGROUPS
# include "ugroup.h" # include "ugroup.h"
#endif
/* util includes */ /* util includes */
#include <base36.h> #include <base36.h>
@ -440,6 +442,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
* bekommen, alles andere ist darstellungsteschnisch kompliziert. * bekommen, alles andere ist darstellungsteschnisch kompliziert.
*/ */
#ifdef USE_UGROUPS
int int
bufunit_ugroupleader(const faction * f, const unit * u, int indent, int mode) bufunit_ugroupleader(const faction * f, const unit * u, int indent, int mode)
{ {
@ -587,7 +590,7 @@ bufunit_ugroupleader(const faction * f, const unit * u, int indent, int mode)
} }
return dh; return dh;
} }
#endif
void void
spskill(const struct locale * lang, const struct unit * u, skill_t sk, int *dh, int days) spskill(const struct locale * lang, const struct unit * u, skill_t sk, int *dh, int days)
@ -656,6 +659,7 @@ spunit(struct strlist ** SP, const struct faction * f, const unit * u, int inden
int mode) int mode)
{ {
int dh; int dh;
#ifdef USE_UGROUPS
ugroup *ug = findugroup(u); ugroup *ug = findugroup(u);
if(ug) { if(ug) {
@ -664,9 +668,9 @@ spunit(struct strlist ** SP, const struct faction * f, const unit * u, int inden
} else { } else {
return; return;
} }
} else { } else
#endif
dh = bufunit(f, u, indent, mode); dh = bufunit(f, u, indent, mode);
}
lparagraph(SP, buf, indent, (char) ((u->faction == f) ? '*' : (dh ? '+' : '-'))); lparagraph(SP, buf, indent, (char) ((u->faction == f) ? '*' : (dh ? '+' : '-')));
} }

View File

@ -107,7 +107,9 @@ extern int months_per_year;
extern void report_item(const struct unit * owner, const struct item * i, const struct faction * viewer, const char ** name, const char ** basename, int * number, boolean singular); extern void report_item(const struct unit * owner, const struct item * i, const struct faction * viewer, const char ** name, const char ** basename, int * number, boolean singular);
extern void report_building(FILE *F, const struct region * r, const struct building * b, const struct faction * f, int mode); extern void report_building(FILE *F, const struct region * r, const struct building * b, const struct faction * f, int mode);
extern int bufunit(const struct faction * f, const struct unit * u, int indent, int mode); extern int bufunit(const struct faction * f, const struct unit * u, int indent, int mode);
#ifdef USE_UGROUPS
extern int bufunit_ugroupleader(const struct faction * f, const struct unit * u, int indent, int mode); extern int bufunit_ugroupleader(const struct faction * f, const struct unit * u, int indent, int mode);
#endif
extern const char *neue_gebiete[]; extern const char *neue_gebiete[];
extern const char *coasts[]; extern const char *coasts[];

View File

@ -8,17 +8,22 @@
This program may not be used, modified or distributed This program may not be used, modified or distributed
without prior permission by the authors of Eressea. without prior permission by the authors of Eressea.
$Id: ugroup.c,v 1.2 2001/04/28 15:39:13 corwin Exp $ $Id: ugroup.c,v 1.3 2001/04/29 19:27:42 enno Exp $
*/ */
#include <config.h> #include <config.h>
#include "eressea.h" #include "eressea.h"
/* kernel includes */
#include "unit.h" #include "unit.h"
#include "region.h" #include "region.h"
#include "faction.h" #include "faction.h"
#include <kernel/ugroup.h> #include "ugroup.h"
/* attributes includes */
#include <attributes/ugroup.h> #include <attributes/ugroup.h>
/* libc includes */
#include <stdlib.h> #include <stdlib.h>
/* TODO: /* TODO:
@ -31,15 +36,16 @@
/* Nur die erste Einheit in der Liste /* Nur die erste Einheit in der Liste
(ugroup->unit_array[0] == u) kann NACH ausführen. */ (ugroup->unit_array[0] == u) kann NACH ausführen. */
#ifdef USE_UGROUPS
boolean boolean
is_ugroupleader(unit *u, ugroup *ug) is_ugroupleader(const unit *u, const ugroup *ug)
{ {
if(ug->unit_array[0] == u) return true; if(ug->unit_array[0] == u) return true;
return false; return false;
} }
ugroup * ugroup *
findugroupid(faction *f, int id) findugroupid(const faction *f, int id)
{ {
ugroup *ug; ugroup *ug;
@ -50,7 +56,7 @@ findugroupid(faction *f, int id)
} }
ugroup * ugroup *
findugroup(unit *u) findugroup(const unit *u)
{ {
attrib *a = a_find(u->attribs, &at_ugroup); attrib *a = a_find(u->attribs, &at_ugroup);
if(!a) return NULL; if(!a) return NULL;
@ -58,13 +64,11 @@ findugroup(unit *u)
} }
static int static int
ugroupfreeid(ugroup *ug) ugroupfreeid(const ugroup *ug)
{ {
ugroup *ug2; const ugroup *ug2 = ug;
int id = 0; int id = 0;
ug2 = ug;
while(ug2) { while(ug2) {
if(ug2->id == id) { if(ug2->id == id) {
id++; id++;
@ -194,3 +198,4 @@ ugroups(void)
} }
} }
#endif /* USE_UGROUPS */

View File

@ -8,7 +8,7 @@
This program may not be used, modified or distributed This program may not be used, modified or distributed
without prior permission by the authors of Eressea. without prior permission by the authors of Eressea.
$Id: ugroup.h,v 1.2 2001/04/28 15:39:13 corwin Exp $ $Id: ugroup.h,v 1.3 2001/04/29 19:27:42 enno Exp $
*/ */
#ifndef UGROUP_H #ifndef UGROUP_H
@ -26,8 +26,8 @@ typedef struct ugroup {
struct unit **unit_array; struct unit **unit_array;
} ugroup; } ugroup;
boolean is_ugroupleader(struct unit *u, struct ugroup *ug); boolean is_ugroupleader(const struct unit *u, const struct ugroup *ug);
ugroup *findugroup(struct unit *u); ugroup *findugroup(const struct unit *u);
void ugroups(void); void ugroups(void);
#endif #endif