forked from github/server
ugroups code entfernt:
- Es ist unwahrscheinlich, dass er je genutzt wird, - Er ist nicht vollständig - Er ist gründlich veraltet
This commit is contained in:
parent
6e0e9543cf
commit
64318eaab3
|
@ -31,7 +31,6 @@ SOURCES =
|
|||
reduceproduction.c
|
||||
synonym.c
|
||||
targetregion.c
|
||||
ugroup.c
|
||||
viewrange.c
|
||||
variable.c
|
||||
;
|
||||
|
|
|
@ -34,9 +34,6 @@
|
|||
#include "synonym.h"
|
||||
#include "targetregion.h"
|
||||
#include "variable.h"
|
||||
#ifdef USE_UGROUPS
|
||||
# include "ugroup.h"
|
||||
#endif
|
||||
#ifdef AT_OPTION
|
||||
# include "option.h"
|
||||
#endif
|
||||
|
@ -81,9 +78,6 @@ init_attributes(void)
|
|||
init_moved();
|
||||
#ifdef AT_OPTION
|
||||
init_option();
|
||||
#endif
|
||||
#ifdef USE_UGROUPS
|
||||
init_ugroup();
|
||||
#endif
|
||||
init_variable();
|
||||
#ifdef WDW_PYRAMID
|
||||
|
|
|
@ -239,9 +239,6 @@
|
|||
<File
|
||||
RelativePath=".\targetregion.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ugroup.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\variable.h">
|
||||
</File>
|
||||
|
@ -315,9 +312,6 @@
|
|||
<File
|
||||
RelativePath=".\targetregion.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ugroup.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\variable.c">
|
||||
</File>
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "eressea.h"
|
||||
#include "ugroup.h"
|
||||
|
||||
#include <attrib.h>
|
||||
|
||||
#ifdef USE_UGROUPS
|
||||
|
||||
attrib_type at_ugroup = {
|
||||
"ugroup", NULL, NULL, NULL, NULL, NULL, ATF_UNIQUE
|
||||
};
|
||||
|
||||
void
|
||||
init_ugroup(void)
|
||||
{
|
||||
at_register(&at_ugroup);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,26 +0,0 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef H_ATTRIBUTE_UGROUP
|
||||
#define H_ATTRIBUTE_UGROUP
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct attrib_type at_ugroup;
|
||||
void init_ugroup(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -63,9 +63,6 @@
|
|||
#include <kernel/terrain.h>
|
||||
#include <kernel/terrainid.h> /* for volcanoes in emigration (needs a flag) */
|
||||
#include <kernel/unit.h>
|
||||
#ifdef USE_UGROUPS
|
||||
# include <kernel/ugroup.h>
|
||||
#endif
|
||||
|
||||
/* attributes includes */
|
||||
#include <attributes/racename.h>
|
||||
|
@ -4013,11 +4010,6 @@ processorders (void)
|
|||
karma();
|
||||
#endif
|
||||
|
||||
#ifdef USE_UGROUPS
|
||||
puts(" - Verbände bilden");
|
||||
ugroups();
|
||||
#endif
|
||||
|
||||
puts(" - Einheiten Sortieren");
|
||||
reorder();
|
||||
#ifdef ALLIANCEJOIN
|
||||
|
|
|
@ -65,9 +65,6 @@
|
|||
#include <kernel/terrainid.h>
|
||||
#include <kernel/unit.h>
|
||||
#include <kernel/alliance.h>
|
||||
#ifdef USE_UGROUPS
|
||||
# include <ugroup.h>
|
||||
#endif
|
||||
|
||||
/* util includes */
|
||||
#include <util/bsdstring.h>
|
||||
|
@ -694,21 +691,8 @@ rpunit(FILE * F, const faction * f, const unit * u, int indent, int mode)
|
|||
char marker;
|
||||
int dh;
|
||||
boolean isbattle = (boolean)(mode == see_battle);
|
||||
#ifdef USE_UGROUPS
|
||||
ugroup *ug = findugroup(u);
|
||||
#endif
|
||||
if(u->race == new_race[RC_SPELL]) return;
|
||||
|
||||
#ifdef USE_UGROUPS
|
||||
if(u->faction != f && (isbattle || ug)) {
|
||||
if(is_ugroupleader(u, ug)) {
|
||||
rnl(F);
|
||||
dh = bufunit_ugroupleader(f, u, indent, mode);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
rnl(F);
|
||||
dh = bufunit(f, u, indent, mode);
|
||||
|
@ -734,14 +718,6 @@ rpunit(FILE * F, const faction * f, const unit * u, int indent, int mode)
|
|||
rparagraph(F, buf, indent, marker);
|
||||
|
||||
if(!isbattle){
|
||||
#ifdef USE_UGROUPS
|
||||
if(ug) {
|
||||
int i;
|
||||
for(i=0; i<ug->members; i++) {
|
||||
print_curses(F, f, ug->unit_array[i], TYP_UNIT, indent);
|
||||
}
|
||||
} else
|
||||
#endif /* USE_UGROUPS */
|
||||
print_curses(F, f, u, TYP_UNIT, indent);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ SOURCES =
|
|||
spell.c
|
||||
teleport.c
|
||||
terrain.c
|
||||
ugroup.c
|
||||
unit.c
|
||||
xmlreader.c
|
||||
;
|
||||
|
|
|
@ -395,10 +395,6 @@ const char *keywords[MAXKEYWORDS] =
|
|||
"JIHAD",
|
||||
"GM",
|
||||
"INFO",
|
||||
#ifdef USE_UGROUPS
|
||||
"JOINVERBAND",
|
||||
"LEAVEVERBAND",
|
||||
#endif
|
||||
"PRAEFIX",
|
||||
"SYNONYM",
|
||||
"PFLANZEN",
|
||||
|
|
|
@ -180,7 +180,6 @@ struct building_type;
|
|||
|
||||
#define MIN_VERSION CURSETYPE_VERSION
|
||||
#define REGIONOWNERS_VERSION 400
|
||||
#define UGROUPS_VERSION 500 /* nicht aktivieren, nicht fertig */
|
||||
|
||||
#ifdef ENEMIES
|
||||
# define RELEASE_VERSION ENEMIES_VERSION
|
||||
|
@ -436,10 +435,6 @@ enum {
|
|||
K_SETJIHAD,
|
||||
K_GM, /* perform GM commands */
|
||||
K_INFO, /* set player-info */
|
||||
#ifdef USE_UGROUPS
|
||||
K_JOINUGROUP,
|
||||
K_LEAVEUGROUP,
|
||||
#endif
|
||||
K_PREFIX,
|
||||
K_SYNONYM,
|
||||
K_PLANT,
|
||||
|
|
|
@ -77,9 +77,6 @@ typedef struct faction {
|
|||
int options;
|
||||
int no_units;
|
||||
int karma;
|
||||
#ifdef USE_UGROUPS
|
||||
struct ugroup *ugroups;
|
||||
#endif
|
||||
#ifdef MSG_LEVELS
|
||||
struct msglevel * msglevels;
|
||||
struct warning * warnings;
|
||||
|
|
|
@ -292,9 +292,6 @@
|
|||
<File
|
||||
RelativePath=".\terrain.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ugroup.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\unit.h">
|
||||
</File>
|
||||
|
@ -404,9 +401,6 @@
|
|||
<File
|
||||
RelativePath=".\terrainid.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ugroup.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\unit.c">
|
||||
</File>
|
||||
|
|
|
@ -38,10 +38,6 @@
|
|||
#include <kernel/ship.h>
|
||||
#include <kernel/skill.h>
|
||||
#include <kernel/unit.h>
|
||||
#ifdef USE_UGROUPS
|
||||
# include <kernel/ugroup.h>
|
||||
# include <attributes/ugroup.h>
|
||||
#endif
|
||||
|
||||
/* util includes */
|
||||
#include <util/bsdstring.h>
|
||||
|
@ -301,24 +297,6 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
|
|||
}
|
||||
}
|
||||
}
|
||||
#ifdef USE_UGROUPS
|
||||
if (u->faction == f) {
|
||||
attrib *a = a_find(u->attribs, &at_ugroup);
|
||||
if (a) {
|
||||
ugroup *ug = findugroupid(u->faction, a->data.i);
|
||||
if (is_ugroupleader(u, ug)) {
|
||||
if (size>1) {
|
||||
strcpy(bufp++, "*");
|
||||
--size;
|
||||
}
|
||||
}
|
||||
rsize = strlcpy(bufp, itoa36(ug->id), size);
|
||||
if (rsize>size) rsize = size-1;
|
||||
size -= rsize;
|
||||
bufp += rsize;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
rsize = strlcpy(bufp, ", ", size);
|
||||
if (rsize>size) rsize = size-1;
|
||||
|
@ -657,164 +635,6 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
|
|||
* bekommen, alles andere ist darstellungsteschnisch kompliziert.
|
||||
*/
|
||||
|
||||
#ifdef USE_UGROUPS
|
||||
int
|
||||
bufunit_ugroupleader(const faction * f, const unit * u, int indent, int mode)
|
||||
{
|
||||
int i, dh;
|
||||
int getarnt = fval(u, UFL_PARTEITARNUNG);
|
||||
faction *fv;
|
||||
const char *pzTmp;
|
||||
attrib *a_fshidden = NULL;
|
||||
item * itm;
|
||||
item * show;
|
||||
ugroup *ug = findugroup(u);
|
||||
boolean guards = false;
|
||||
boolean sieges = false;
|
||||
boolean itemcloak = false;
|
||||
static const curse_type * itemcloak_ct = 0;
|
||||
static boolean init = false;
|
||||
|
||||
if (!init) {
|
||||
init = true;
|
||||
itemcloak_ct = ct_find("itemcloak");
|
||||
}
|
||||
if (itemcloak_ct!=NULL) {
|
||||
itemcloak = curse_active(get_curse(u->attribs, itemcloak_ct));
|
||||
}
|
||||
|
||||
if(fspecial(u->faction, FS_HIDDEN))
|
||||
a_fshidden = a_find(u->attribs, &at_fshidden);
|
||||
|
||||
strcpy(buf, u->name);
|
||||
|
||||
fv = visible_faction(f, u);
|
||||
|
||||
if (getarnt) {
|
||||
scat(", ");
|
||||
scat(LOC(f->locale, "anonymous"));
|
||||
} else {
|
||||
scat(", ");
|
||||
scat(factionname(fv));
|
||||
}
|
||||
|
||||
scat(", ");
|
||||
|
||||
for(i = 0; i < ug->members; i++) {
|
||||
unit *uc = ug->unit_array[i];
|
||||
if(uc->faction != f && a_fshidden
|
||||
&& a_fshidden->data.ca[0] == 1 && effskill(uc, SK_STEALTH) >= 6) {
|
||||
scat("? ");
|
||||
} else {
|
||||
icat(uc->number);
|
||||
scat(" ");
|
||||
}
|
||||
pzTmp = get_racename(uc->attribs);
|
||||
if (pzTmp || u->irace != uc->race) {
|
||||
if (pzTmp)
|
||||
scat(pzTmp);
|
||||
else
|
||||
scat(racename(f->locale, u, u->irace));
|
||||
scat(" (");
|
||||
scat(itoa36(uc->no));
|
||||
scat("), ");
|
||||
} else {
|
||||
scat(racename(f->locale, u, u->race));
|
||||
scat(" (");
|
||||
scat(itoa36(uc->no));
|
||||
scat("), ");
|
||||
}
|
||||
if(getguard(uc)) guards = true;
|
||||
if(usiege(uc)) sieges = true;
|
||||
}
|
||||
|
||||
if(guards == true) scat(", bewacht die Region");
|
||||
|
||||
if(sieges == true) {
|
||||
scat(", belagert ");
|
||||
for(i = 0; i < ug->members; i++) {
|
||||
building *b = usiege(ug->unit_array[i]);
|
||||
if(b) {
|
||||
scat(buildingname(b));
|
||||
scat(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dh = 0;
|
||||
show = NULL;
|
||||
for(i = 0; i < ug->members; i++) {
|
||||
unit *uc = ug->unit_array[i];
|
||||
if (!itemcloak && mode >= see_unit && !(a_fshidden
|
||||
&& a_fshidden->data.ca[1] == 1 && effskill(u, SK_STEALTH) >= 3)) {
|
||||
for (itm=uc->items;itm;itm=itm->next) {
|
||||
item *ishow;
|
||||
const char * ic;
|
||||
int in;
|
||||
report_item(u, itm, f, NULL, &ic, &in, false);
|
||||
if (ic && *ic && in>0) {
|
||||
for (ishow = show; ishow; ishow=ishow->next) {
|
||||
const char * sc;
|
||||
int sn;
|
||||
if (ishow->type==itm->type) sc=ic;
|
||||
else report_item(u, ishow, f, NULL, &sc, &sn, false);
|
||||
if (sc==ic || strcmp(sc, ic)==0) {
|
||||
ishow->number+=itm->number;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ishow==NULL) {
|
||||
ishow = i_add(&show, i_new(itm->type, itm->number));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (itm=show; itm; itm=itm->next) {
|
||||
const char * ic;
|
||||
int in;
|
||||
report_item(u, itm, f, &ic, NULL, &in, false);
|
||||
if (in==0 || ic==NULL) continue;
|
||||
scat(", ");
|
||||
|
||||
if (!dh) {
|
||||
sprintf(buf+strlen(buf), "%s: ", LOC(f->locale, "nr_inventory"));
|
||||
dh = 1;
|
||||
}
|
||||
if (in == 1) {
|
||||
scat(ic);
|
||||
} else {
|
||||
icat(in);
|
||||
scat(" ");
|
||||
scat(ic);
|
||||
}
|
||||
}
|
||||
if(show) while(show) i_free(i_remove(&show, show));
|
||||
|
||||
i = 0;
|
||||
if (u->display && u->display[0]) {
|
||||
scat("; ");
|
||||
scat(u->display);
|
||||
|
||||
i = u->display[strlen(u->display) - 1];
|
||||
}
|
||||
if (i != '!' && i != '?' && i != '.')
|
||||
scat(".");
|
||||
|
||||
dh=0;
|
||||
if (!getarnt && f && f->allies) {
|
||||
ally *sf;
|
||||
|
||||
for (sf = f->allies; sf && !dh; sf = sf->next) {
|
||||
if (sf->status > 0 && sf->status <= HELP_ALL && sf->faction == fv) {
|
||||
dh = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return dh;
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t
|
||||
spskill(char * buffer, size_t size, const struct locale * lang, const struct unit * u, skill_t sk, int *dh, int days)
|
||||
{
|
||||
|
@ -941,19 +761,7 @@ void
|
|||
spunit(struct strlist ** SP, const struct faction * f, const unit * u, int indent,
|
||||
int mode)
|
||||
{
|
||||
int dh;
|
||||
#ifdef USE_UGROUPS
|
||||
ugroup *ug = findugroup(u);
|
||||
|
||||
if(ug) {
|
||||
if(is_ugroupleader(u, ug)) {
|
||||
dh = bufunit_ugroupleader(f, u, indent, mode);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
dh = bufunit(f, u, indent, mode);
|
||||
int dh = bufunit(f, u, indent, mode);
|
||||
lparagraph(SP, buf, indent, (char) ((u->faction == f) ? '*' : (dh ? '+' : '-')));
|
||||
}
|
||||
|
||||
|
|
|
@ -101,9 +101,6 @@ extern void register_reporttype(const char * extension, report_fun write, int fl
|
|||
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 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);
|
||||
#endif
|
||||
|
||||
extern const char * reportpath(void);
|
||||
extern const char * trailinto(const struct region * r, const struct locale * lang);
|
||||
|
|
|
@ -48,11 +48,6 @@
|
|||
#include "terrainid.h" /* only for conversion code */
|
||||
#include "unit.h"
|
||||
|
||||
#ifdef USE_UGROUPS
|
||||
#include "ugroup.h"
|
||||
#include <attributes/ugroup.h>
|
||||
#endif
|
||||
|
||||
/* attributes includes */
|
||||
#include <attributes/key.h>
|
||||
|
||||
|
@ -783,39 +778,6 @@ read_laen(struct region * r, int laen)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_UGROUPS
|
||||
void
|
||||
read_ugroups(FILE *file)
|
||||
{
|
||||
int i;
|
||||
faction *f;
|
||||
ugroup *ug;
|
||||
int fno, ugid, ugmem;
|
||||
|
||||
while(1) {
|
||||
fno = ri(file);
|
||||
if(fno == -1) break;
|
||||
f = findfaction(fno);
|
||||
while(1) {
|
||||
ugid = ri(file);
|
||||
if(ugid == -1) break;
|
||||
ugmem = ri(file);
|
||||
ug = malloc(sizeof(ugroup));
|
||||
ug->id = ugid;
|
||||
ug->members = ugmem;
|
||||
ug->unit_array = malloc(ug->members * sizeof(unit *));
|
||||
for(i=0; i<ugmem; i++) {
|
||||
unit *u = findunitg(ri36(file), NULL);
|
||||
ug->unit_array[i] = u;
|
||||
a_add(&u->attribs, a_new(&at_ugroup))->data.i = ugid;
|
||||
}
|
||||
ug->next = f->ugroups;
|
||||
f->ugroups = ug;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
read_alliances(FILE * F)
|
||||
{
|
||||
|
@ -890,29 +852,6 @@ write_items(FILE *F, item *ilist)
|
|||
fputs("end ", F);
|
||||
}
|
||||
|
||||
#ifdef USE_UGROUPS
|
||||
void
|
||||
write_ugroups(FILE *file)
|
||||
{
|
||||
faction *f;
|
||||
ugroup *ug;
|
||||
int i;
|
||||
|
||||
for(f=factions; f; f=f->next) if(f->ugroups) {
|
||||
wi(file, f->no);
|
||||
for(ug = f->ugroups; ug; ug=ug->next) {
|
||||
wi(file, ug->id);
|
||||
wi(file, ug->members);
|
||||
for(i=0; i<ug->members; i++) {
|
||||
wi36(file, ug->unit_array[i]->no);
|
||||
}
|
||||
}
|
||||
fputs("-1\n", file);
|
||||
}
|
||||
fputs("-1\n", file);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_PLAYERS
|
||||
static void
|
||||
export_players(const char * path)
|
||||
|
@ -1954,9 +1893,6 @@ readgame(const char * filename, int backup)
|
|||
printf("\n");
|
||||
if (!dirtyload) {
|
||||
read_borders(F);
|
||||
#ifdef USE_UGROUPS
|
||||
if (global.data_version >= UGROUPS_VERSION) read_ugroups(F);
|
||||
#endif
|
||||
}
|
||||
|
||||
fclose(F);
|
||||
|
@ -2162,10 +2098,6 @@ writegame(const char *filename, char quiet)
|
|||
wnl(F);
|
||||
write_borders(F);
|
||||
wnl(F);
|
||||
#if RELEASE_VERSION >= UGROUPS_VERSION
|
||||
write_ugroups(F);
|
||||
wnl(F);
|
||||
#endif
|
||||
fclose(F);
|
||||
printf("\nOk.\n");
|
||||
return 0;
|
||||
|
|
|
@ -1,202 +0,0 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "eressea.h"
|
||||
|
||||
/* kernel includes */
|
||||
#include "unit.h"
|
||||
#include "region.h"
|
||||
#include "faction.h"
|
||||
#include "ugroup.h"
|
||||
|
||||
/* attributes includes */
|
||||
#include <attributes/ugroup.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* TODO:
|
||||
* - Anzeige (CR)
|
||||
* - Speicherung
|
||||
* - Evt. NACH (Betrete/Verlasse?) des Leaders vererben auf Members.
|
||||
* - Routine zur automatischen Aufsplittung.
|
||||
*/
|
||||
|
||||
/* Nur die erste Einheit in der Liste
|
||||
(ugroup->unit_array[0] == u) kann NACH ausführen. */
|
||||
|
||||
#ifdef USE_UGROUPS
|
||||
boolean
|
||||
is_ugroupleader(const unit *u, const ugroup *ug)
|
||||
{
|
||||
if(ug->unit_array[0] == u) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
ugroup *
|
||||
findugroupid(const faction *f, int id)
|
||||
{
|
||||
ugroup *ug;
|
||||
|
||||
for(ug=f->ugroups;ug; ug=ug->next) {
|
||||
if(ug->id == id) return ug;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ugroup *
|
||||
findugroup(const unit *u)
|
||||
{
|
||||
attrib *a = a_find(u->attribs, &at_ugroup);
|
||||
if(!a) return NULL;
|
||||
return findugroupid(u->faction, a->data.i);
|
||||
}
|
||||
|
||||
static int
|
||||
ugroupfreeid(const ugroup *ug)
|
||||
{
|
||||
const ugroup *ug2 = ug;
|
||||
int id = 0;
|
||||
|
||||
while(ug2) {
|
||||
if(ug2->id == id) {
|
||||
id++;
|
||||
ug2 = ug;
|
||||
} else {
|
||||
ug2 = ug2->next;
|
||||
}
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
ugroup *
|
||||
createugroup(unit *uleader, unit *umember)
|
||||
{
|
||||
ugroup *ug = calloc(1,sizeof(ugroup));
|
||||
|
||||
ug->id = ugroupfreeid(uleader->faction->ugroups);
|
||||
ug->members = 2;
|
||||
ug->unit_array = malloc(2 * sizeof(unit *));
|
||||
ug->unit_array[0] = uleader;
|
||||
a_add(&uleader->attribs, a_new(&at_ugroup))->data.i = ug->id;
|
||||
ug->unit_array[1] = umember;
|
||||
a_add(&umember->attribs, a_new(&at_ugroup))->data.i = ug->id;
|
||||
ug->next = uleader->faction->ugroups;
|
||||
uleader->faction->ugroups = ug;
|
||||
|
||||
return ug;
|
||||
}
|
||||
|
||||
void
|
||||
join_ugroup(unit *u, strlist *order)
|
||||
{
|
||||
unit *u2;
|
||||
ugroup *ug;
|
||||
|
||||
u2 = getunit(u->region, u->faction);
|
||||
if(!u2 || cansee(u->faction, u->region, u2, 0) == false) {
|
||||
cmistake(u, order->s, 63, MSG_EVENT);
|
||||
return;
|
||||
}
|
||||
if(u2 == u) {
|
||||
cmistake(u, order->s, 292, MSG_EVENT);
|
||||
return;
|
||||
}
|
||||
if(u2->faction != u->faction) {
|
||||
cmistake(u, order->s, 293, MSG_EVENT);
|
||||
return;
|
||||
}
|
||||
if(u2->building != u->building || u2->ship != u->ship) {
|
||||
cmistake(u, order->s, 294, MSG_EVENT);
|
||||
return;
|
||||
}
|
||||
if(a_find(u->attribs, &at_ugroup)) {
|
||||
cmistake(u, order->s, 290, MSG_EVENT);
|
||||
return;
|
||||
}
|
||||
|
||||
ug = findugroup(u2);
|
||||
|
||||
if(ug) {
|
||||
ug->members++;
|
||||
ug->unit_array = realloc(ug->unit_array,
|
||||
ug->members * sizeof(unit *));
|
||||
ug->unit_array[ug->members-1] = u;
|
||||
a_add(&u->attribs, a_new(&at_ugroup))->data.i = ug->id;
|
||||
} else {
|
||||
createugroup(u2, u);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
leave_ugroup(unit *u, strlist *order)
|
||||
{
|
||||
attrib *a = a_find(u->attribs, &at_ugroup);
|
||||
ugroup *ug;
|
||||
boolean found = false;
|
||||
int i;
|
||||
|
||||
if(!a) {
|
||||
cmistake(u, order->s, 286, MSG_EVENT);
|
||||
return;
|
||||
}
|
||||
|
||||
ug = findugroupid(u->faction, a->data.i);
|
||||
for(i=0; i<ug->members; i++) {
|
||||
if(found == true) {
|
||||
ug->unit_array[i-1] = ug->unit_array[i];
|
||||
} else if(ug->unit_array[i] == u) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
ug->members--;
|
||||
a_remove(&u->attribs, a);
|
||||
|
||||
if(ug->members == 1) {
|
||||
a_remove(&ug->unit_array[0]->attribs, a);
|
||||
free(ug->unit_array);
|
||||
removelist(&u->faction->ugroups, ug);
|
||||
} else {
|
||||
ug->unit_array = realloc(ug->unit_array,
|
||||
ug->members * sizeof(unit *));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ugroups(void)
|
||||
{
|
||||
region *r;
|
||||
unit *u;
|
||||
strlist *o;
|
||||
|
||||
for(r=regions; r; r=r->next) {
|
||||
for(u=r->units; u; u=u->next) {
|
||||
for(o = u->orders; o; o=o->next) {
|
||||
if(igetkeyword(o->s, u->faction->locale) == K_LEAVEUGROUP) {
|
||||
leave_ugroup(u, o);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(u=r->units; u; u=u->next) {
|
||||
for(o = u->orders; o; o=o->next) {
|
||||
if(igetkeyword(o->s, u->faction->locale) == K_JOINUGROUP) {
|
||||
join_ugroup(u, o);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* USE_UGROUPS */
|
|
@ -1,39 +0,0 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
|
||||
#ifndef UGROUP_H
|
||||
#define UGROUP_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Globale Liste ugroups.
|
||||
Bei jeder unit u->ugroup zeigt auf aktuelle Gruppe.
|
||||
Gruppen mit members <= 1 werden vor den Reports
|
||||
aufgelöst. */
|
||||
|
||||
typedef struct ugroup {
|
||||
struct ugroup *next;
|
||||
int id;
|
||||
int members;
|
||||
struct unit **unit_array;
|
||||
} ugroup;
|
||||
|
||||
boolean is_ugroupleader(const struct unit *u, const struct ugroup *ug);
|
||||
ugroup *findugroupid(const struct faction *f, int id);
|
||||
ugroup *findugroup(const struct unit *u);
|
||||
void ugroups(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -364,28 +364,6 @@
|
|||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="XML files"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath="..\res\buildings.xml">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\res\messages.xml">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\res\races.xml">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\res\resources.xml">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\res\de\strings.xml">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\res\terrains.xml">
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\console.c">
|
||||
</File>
|
||||
|
|
Loading…
Reference in New Issue