forked from github/server
- Verbände, nächster Schritt
This commit is contained in:
parent
b94f10c44b
commit
a9efe2898e
|
@ -58,6 +58,7 @@
|
||||||
#include <pool.h>
|
#include <pool.h>
|
||||||
#include <building.h>
|
#include <building.h>
|
||||||
#include <group.h>
|
#include <group.h>
|
||||||
|
#include <ugroup.h>
|
||||||
|
|
||||||
/* attributes includes */
|
/* attributes includes */
|
||||||
#include <attributes/racename.h>
|
#include <attributes/racename.h>
|
||||||
|
@ -3034,6 +3035,9 @@ processorders (void)
|
||||||
puts(" - Jihads setzen");
|
puts(" - Jihads setzen");
|
||||||
set_jihad();
|
set_jihad();
|
||||||
|
|
||||||
|
puts(" - Verbände bilden");
|
||||||
|
ugroups();
|
||||||
|
|
||||||
puts(" - Einheiten Sortieren");
|
puts(" - Einheiten Sortieren");
|
||||||
reorder();
|
reorder();
|
||||||
puts(" - Neue Nummern");
|
puts(" - Neue Nummern");
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
#include <skill.h>
|
#include <skill.h>
|
||||||
#include <teleport.h>
|
#include <teleport.h>
|
||||||
#include <unit.h>
|
#include <unit.h>
|
||||||
|
#include <ugroup.h>
|
||||||
|
|
||||||
/* util includes */
|
/* util includes */
|
||||||
#include <goodies.h>
|
#include <goodies.h>
|
||||||
|
@ -675,27 +676,51 @@ rps_nowrap(FILE * F, const char *s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int rpu = 0;
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rpunit(FILE * F, const faction * f, const unit * u, int indent, int mode)
|
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);
|
||||||
++rpu;
|
ugroup *ug = findugroup(u);
|
||||||
|
|
||||||
if(u->race == RC_SPELL)
|
if(u->race == RC_SPELL) return;
|
||||||
return;
|
|
||||||
|
|
||||||
|
if(isbattle || ug) {
|
||||||
|
if(is_ugroupleader(u, ug)) {
|
||||||
|
rnl(F);
|
||||||
|
dh = bufunit_ugroupleader(f, u, indent, mode);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
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){
|
||||||
|
if(ug) {
|
||||||
|
int 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);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ug) {
|
||||||
|
int i;
|
||||||
|
for(i=0; i<ug->members; i++) {
|
||||||
|
if (mode==see_unit && ug->unit_array[i]->faction == f && ug->unit_array[i]->botschaften) {
|
||||||
|
for (S = ug->unit_array[i]->botschaften; S; S = S->next) {
|
||||||
|
rnl(F);
|
||||||
|
rparagraph(F, S->s, indent, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
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);
|
||||||
|
@ -703,6 +728,7 @@ 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)
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "ship.h"
|
#include "ship.h"
|
||||||
#include "race.h"
|
#include "race.h"
|
||||||
#include "magic.h"
|
#include "magic.h"
|
||||||
|
#include "ugroup.h"
|
||||||
|
|
||||||
/* util includes */
|
/* util includes */
|
||||||
#include <base36.h>
|
#include <base36.h>
|
||||||
|
@ -175,8 +176,7 @@ report_item(const unit * owner, const item * i, const faction * viewer, const ch
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
bufunit(const faction * f, const unit * u, int indent,
|
bufunit(const faction * f, const unit * u, int indent, int mode)
|
||||||
int mode)
|
|
||||||
{
|
{
|
||||||
int i, dh;
|
int i, dh;
|
||||||
skill_t sk;
|
skill_t sk;
|
||||||
|
@ -227,6 +227,7 @@ bufunit(const faction * f, const unit * u, int indent,
|
||||||
}
|
}
|
||||||
|
|
||||||
scat(", ");
|
scat(", ");
|
||||||
|
|
||||||
if(u->faction != f && a_fshidden
|
if(u->faction != f && a_fshidden
|
||||||
&& a_fshidden->data.ca[0] == 1 && effskill(u, SK_STEALTH) >= 6) {
|
&& a_fshidden->data.ca[0] == 1 && effskill(u, SK_STEALTH) >= 6) {
|
||||||
scat("? ");
|
scat("? ");
|
||||||
|
@ -434,6 +435,160 @@ bufunit(const faction * f, const unit * u, int indent,
|
||||||
return dh;
|
return dh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: telepath_see wird nicht berücksichtigt: Parteien mit
|
||||||
|
* telepath_see sollten immer einzelne Einheiten zu sehen
|
||||||
|
* bekommen, alles andere ist darstellungsteschnisch kompliziert.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
bufunit_ugroupleader(const faction * f, const unit * u, int indent, int mode)
|
||||||
|
{
|
||||||
|
int i, dh;
|
||||||
|
int getarnt = fval(u, FL_PARTEITARNUNG);
|
||||||
|
attrib *a_otherfaction = NULL;
|
||||||
|
const char *pzTmp;
|
||||||
|
boolean itemcloak = is_cursed(u->attribs, C_ITEMCLOAK, 0);
|
||||||
|
attrib *a_fshidden = NULL;
|
||||||
|
item * itm;
|
||||||
|
item * show;
|
||||||
|
ugroup *ug = findugroup(u);
|
||||||
|
boolean guards = false;
|
||||||
|
boolean sieges = false;
|
||||||
|
|
||||||
|
if(fspecial(u->faction, FS_HIDDEN))
|
||||||
|
a_fshidden = a_find(u->attribs, &at_fshidden);
|
||||||
|
|
||||||
|
strcpy(buf, u->name);
|
||||||
|
|
||||||
|
a_otherfaction = a_find(u->attribs, &at_otherfaction);
|
||||||
|
|
||||||
|
if (getarnt) {
|
||||||
|
scat(", parteigetarnt");
|
||||||
|
} else if(a_otherfaction) {
|
||||||
|
scat(", ");
|
||||||
|
scat(factionname(findfaction(a_otherfaction->data.i)));
|
||||||
|
} else {
|
||||||
|
scat(", ");
|
||||||
|
scat(factionname(u->faction));
|
||||||
|
}
|
||||||
|
|
||||||
|
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(locale_string(f->locale, race[uc->irace].name[uc->number != 1]));
|
||||||
|
scat(" (");
|
||||||
|
scat(itoa36(uc->no));
|
||||||
|
scat("), ");
|
||||||
|
} else {
|
||||||
|
scat(locale_string(f->locale, race[uc->race].name[uc->number != 1]));
|
||||||
|
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));
|
||||||
|
ishow->number = 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[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 == u->faction) {
|
||||||
|
dh = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dh;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -500,8 +655,18 @@ void
|
||||||
spunit(struct strlist ** SP, const struct faction * f, const unit * u, int indent,
|
spunit(struct strlist ** SP, const struct faction * f, const unit * u, int indent,
|
||||||
int mode)
|
int mode)
|
||||||
{
|
{
|
||||||
int dh = bufunit(f, u, indent, mode);
|
int dh;
|
||||||
assert(SP);
|
ugroup *ug = findugroup(u);
|
||||||
|
|
||||||
|
if(ug) {
|
||||||
|
if(is_ugroupleader(u, ug)) {
|
||||||
|
dh = bufunit_ugroupleader(f, u, indent, mode);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dh = bufunit(f, u, indent, mode);
|
||||||
|
}
|
||||||
lparagraph(SP, buf, indent, (char) ((u->faction == f) ? '*' : (dh ? '+' : '-')));
|
lparagraph(SP, buf, indent, (char) ((u->faction == f) ? '*' : (dh ? '+' : '-')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,7 @@ 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);
|
||||||
|
extern int bufunit_ugroupleader(const struct faction * f, const struct unit * u, int indent, int mode);
|
||||||
|
|
||||||
extern const char *neue_gebiete[];
|
extern const char *neue_gebiete[];
|
||||||
extern const char *coasts[];
|
extern const char *coasts[];
|
||||||
|
|
|
@ -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.c,v 1.1 2001/04/28 12:03:12 corwin Exp $
|
$Id: ugroup.c,v 1.2 2001/04/28 15:39:13 corwin Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
@ -21,9 +21,23 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
/* TODO:
|
||||||
|
* - Anzeige (CR)
|
||||||
|
* - Speicherung
|
||||||
|
* - Evt. NACH (Betrete/Verlasse?) des Leaders vererben auf Members.
|
||||||
|
* - Routine zur automatisch Aufsplittung.
|
||||||
|
*/
|
||||||
|
|
||||||
/* 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. */
|
||||||
|
|
||||||
|
boolean
|
||||||
|
is_ugroupleader(unit *u, ugroup *ug)
|
||||||
|
{
|
||||||
|
if(ug->unit_array[0] == u) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ugroup *
|
ugroup *
|
||||||
findugroupid(faction *f, int id)
|
findugroupid(faction *f, int id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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.1 2001/04/28 12:03:12 corwin Exp $
|
$Id: ugroup.h,v 1.2 2001/04/28 15:39:13 corwin Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef UGROUP_H
|
#ifndef UGROUP_H
|
||||||
|
@ -23,7 +23,11 @@ typedef struct ugroup {
|
||||||
struct ugroup *next;
|
struct ugroup *next;
|
||||||
int id;
|
int id;
|
||||||
int members;
|
int members;
|
||||||
unit **unit_array;
|
struct unit **unit_array;
|
||||||
} ugroup;
|
} ugroup;
|
||||||
|
|
||||||
|
boolean is_ugroupleader(struct unit *u, struct ugroup *ug);
|
||||||
|
ugroup *findugroup(struct unit *u);
|
||||||
|
void ugroups(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue