forked from github/server
cleaning up some alliance code, killing bitrot from WDW.
This commit is contained in:
parent
2c077c25e8
commit
9b56ccf53c
|
@ -4,7 +4,6 @@ stealth.test.c
|
|||
)
|
||||
|
||||
SET(_FILES
|
||||
alliance.c
|
||||
attributes.c
|
||||
fleechance.c
|
||||
follow.c
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
**/
|
||||
|
||||
#include <platform.h>
|
||||
#include "alliance.h"
|
||||
|
||||
#include <kernel/save.h>
|
||||
#include <util/attrib.h>
|
||||
|
||||
attrib_type at_alliance = {
|
||||
"alliance",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
a_writeint,
|
||||
a_readint,
|
||||
ATF_UNIQUE
|
||||
};
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
**/
|
||||
|
||||
#ifndef H_ATTRIBUTE_ALLIANCE
|
||||
#define H_ATTRIBUTE_ALLIANCE
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct attrib_type at_alliance;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -37,9 +37,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include "raceprefix.h"
|
||||
#include "reduceproduction.h"
|
||||
#include "targetregion.h"
|
||||
#ifdef WDW_PYRAMID
|
||||
# include "alliance.h"
|
||||
#endif
|
||||
|
||||
/* kernel includes */
|
||||
#include <kernel/unit.h>
|
||||
|
@ -53,30 +50,26 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <util/attrib.h>
|
||||
|
||||
attrib_type at_unitdissolve = {
|
||||
"unitdissolve", NULL, NULL, NULL, a_writechars, a_readchars
|
||||
"unitdissolve", NULL, NULL, NULL, a_writechars, a_readchars
|
||||
};
|
||||
|
||||
void register_attributes(void)
|
||||
{
|
||||
at_register(&at_stealth);
|
||||
at_register(&at_object);
|
||||
at_register(&at_unitdissolve);
|
||||
at_register(&at_overrideroads);
|
||||
at_register(&at_raceprefix);
|
||||
at_register(&at_iceberg);
|
||||
at_register(&at_key);
|
||||
at_register(&at_gm);
|
||||
at_register(&at_follow);
|
||||
at_register(&at_targetregion);
|
||||
at_register(&at_orcification);
|
||||
at_register(&at_hate);
|
||||
at_register(&at_reduceproduction);
|
||||
at_register(&at_otherfaction);
|
||||
at_register(&at_racename);
|
||||
at_register(&at_movement);
|
||||
at_register(&at_moved);
|
||||
|
||||
#ifdef WDW_PYRAMID
|
||||
at_register(&at_alliance);
|
||||
#endif /* WDW_PYRAMID */
|
||||
at_register(&at_unitdissolve);
|
||||
at_register(&at_overrideroads);
|
||||
at_register(&at_raceprefix);
|
||||
at_register(&at_iceberg);
|
||||
at_register(&at_key);
|
||||
at_register(&at_gm);
|
||||
at_register(&at_follow);
|
||||
at_register(&at_targetregion);
|
||||
at_register(&at_orcification);
|
||||
at_register(&at_hate);
|
||||
at_register(&at_reduceproduction);
|
||||
at_register(&at_otherfaction);
|
||||
at_register(&at_racename);
|
||||
at_register(&at_movement);
|
||||
at_register(&at_moved);
|
||||
}
|
||||
|
|
|
@ -513,3 +513,7 @@ void alliance_setname(alliance * self, const char *name)
|
|||
else
|
||||
self->name = NULL;
|
||||
}
|
||||
|
||||
bool is_allied(const struct faction *f1, const struct faction *f2) {
|
||||
return (f1 == f2 || (f1->alliance && f1->alliance == f2->alliance));
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ extern "C" {
|
|||
void free_alliance(struct alliance *al);
|
||||
extern struct faction *alliance_get_leader(struct alliance *al);
|
||||
extern void alliance_cmd(void);
|
||||
bool is_allied(const struct faction *f1, const struct faction *f2);
|
||||
|
||||
void alliance_setname(alliance * self, const char *name);
|
||||
/* execute commands */
|
||||
|
|
|
@ -65,7 +65,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
/* attributes inclues */
|
||||
#include <attributes/matmod.h>
|
||||
#include <attributes/alliance.h>
|
||||
|
||||
struct building *getbuilding(const struct region *r)
|
||||
{
|
||||
|
@ -775,12 +774,6 @@ build_building(unit * u, const building_type * btype, int id, int want, order *
|
|||
if (u->number && leave(u, false)) {
|
||||
u_set_building(u, b);
|
||||
}
|
||||
#ifdef WDW_PYRAMID
|
||||
if (b->type == bt_find("pyramid") && f_get_alliance(u->faction) != NULL) {
|
||||
attrib *a = a_add(&b->attribs, a_new(&at_alliance));
|
||||
a->data.i = u->faction->alliance->id;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
btname = LOC(lang, btype->_name);
|
||||
|
|
|
@ -270,45 +270,6 @@ static const char *fort_name(const struct building_type *btype,
|
|||
return castle_name_i(btype, b, bsize, fname);
|
||||
}
|
||||
|
||||
#ifdef WDW_PYRAMID
|
||||
|
||||
static const char *pyramid_name(const struct building_type *btype, int bsize)
|
||||
{
|
||||
static char p_name_buf[32];
|
||||
int level = 0;
|
||||
const construction *ctype;
|
||||
|
||||
ctype = btype->construction;
|
||||
|
||||
while (ctype && ctype->maxsize != -1 && ctype->maxsize <= bsize) {
|
||||
bsize -= ctype->maxsize;
|
||||
ctype = ctype->improvement;
|
||||
++level;
|
||||
}
|
||||
|
||||
sprintf(p_name_buf, "pyramid%d", level);
|
||||
|
||||
return p_name_buf;
|
||||
}
|
||||
|
||||
int wdw_pyramid_level(const struct building *b)
|
||||
{
|
||||
const construction *ctype = b->type->construction;
|
||||
int completed = b->size;
|
||||
int level = 0;
|
||||
|
||||
while (ctype->improvement != NULL &&
|
||||
ctype->improvement != ctype &&
|
||||
ctype->maxsize > 0 && ctype->maxsize <= completed) {
|
||||
++level;
|
||||
completed -= ctype->maxsize;
|
||||
ctype = ctype->improvement;
|
||||
}
|
||||
|
||||
return level;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* for finding out what was meant by a particular building string */
|
||||
|
||||
static local_names *bnames;
|
||||
|
@ -371,9 +332,6 @@ void register_buildings(void)
|
|||
register_function((pf_generic) & castle_name, "castle_name");
|
||||
register_function((pf_generic) & castle_name_2, "castle_name_2");
|
||||
register_function((pf_generic) & fort_name, "fort_name");
|
||||
#ifdef WDW_PYRAMID
|
||||
register_function((pf_generic) & pyramid_name, "pyramid_name");
|
||||
#endif
|
||||
}
|
||||
|
||||
void write_building_reference(const struct building *b, struct storage *store)
|
||||
|
|
|
@ -34,9 +34,6 @@ extern "C" {
|
|||
#define INSECT_POTION /* Spezialtrank für Insekten */
|
||||
#define ORCIFICATION /* giving snotlings to the peasants gets counted */
|
||||
|
||||
// TODO: remove macro, move all alliance code into a module.
|
||||
#define ALLIED(f1, f2) (f1==f2 || (f1->alliance && f1->alliance==f2->alliance))
|
||||
|
||||
/* for some good prime numbers, check http://www.math.niu.edu/~rusin/known-math/98/pi_x */
|
||||
#ifndef MAXREGIONS
|
||||
# define MAXREGIONS 524287 /* must be prime for hashing. 262139 was a little small */
|
||||
|
|
|
@ -568,6 +568,7 @@ keyword_t init_order(const struct order *ord)
|
|||
{
|
||||
char *cmd = 0;
|
||||
|
||||
assert(ord && ord->data);
|
||||
if (ord->data->_str) cmd = _strdup(ord->data->_str);
|
||||
init_tokens_str(cmd, cmd);
|
||||
return ord->data->_keyword;
|
||||
|
|
56
src/report.c
56
src/report.c
|
@ -31,7 +31,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
/* attributes includes */
|
||||
#include <attributes/overrideroads.h>
|
||||
#include <attributes/otherfaction.h>
|
||||
#include <attributes/alliance.h>
|
||||
#include <attributes/reduceproduction.h>
|
||||
|
||||
/* gamecode includes */
|
||||
|
@ -711,8 +710,7 @@ nr_unit(FILE * F, const faction * f, const unit * u, int indent, int mode)
|
|||
if (u->faction == f) {
|
||||
marker = '*';
|
||||
}
|
||||
else if ALLIED
|
||||
(u->faction, f) {
|
||||
else if (is_allied(u->faction, f)) {
|
||||
marker = 'o';
|
||||
}
|
||||
else if (a_otherfaction && f != u->faction
|
||||
|
@ -1889,7 +1887,7 @@ static void list_address(FILE * F, const faction * uf, quicklist * seenfactions)
|
|||
f->banner ? f->banner : "");
|
||||
if (uf == f)
|
||||
label = '*';
|
||||
else if (ALLIED(uf, f))
|
||||
else if (is_allied(uf, f))
|
||||
label = 'o';
|
||||
else if (alliedfaction(NULL, uf, f, HELP_ALL))
|
||||
label = '+';
|
||||
|
@ -2046,62 +2044,12 @@ const faction * f)
|
|||
WARN_STATIC_BUFFER();
|
||||
i = b->display[strlen(b->display) - 1];
|
||||
}
|
||||
#ifdef WDW_PYRAMID
|
||||
|
||||
if (i != '!' && i != '?' && i != '.') {
|
||||
scat(", ");
|
||||
}
|
||||
|
||||
if (b->type == bt_find("pyramid")) {
|
||||
unit *owner = building_owner(b);
|
||||
scat("Größenstufe ");
|
||||
icat(wdw_pyramid_level(b));
|
||||
scat(".");
|
||||
|
||||
if (owner && owner->faction == f) {
|
||||
const construction *ctype = b->type->construction;
|
||||
int completed = b->size;
|
||||
int c;
|
||||
|
||||
scat(" Baukosten pro Größenpunkt: ");
|
||||
|
||||
while (ctype->improvement != NULL &&
|
||||
ctype->improvement != ctype &&
|
||||
ctype->maxsize > 0 && ctype->maxsize <= completed) {
|
||||
completed -= ctype->maxsize;
|
||||
ctype = ctype->improvement;
|
||||
}
|
||||
|
||||
assert(ctype->materials != NULL);
|
||||
|
||||
for (c = 0; ctype->materials[c].number; c++) {
|
||||
const resource_type *rtype = ctype->materials[c].rtype;
|
||||
int number = ctype->materials[c].number;
|
||||
|
||||
if (c > 0) {
|
||||
scat(", ");
|
||||
}
|
||||
icat(number);
|
||||
scat(" ");
|
||||
scat(locale_string(lang, resourcename(rtype,
|
||||
number != 1 ? GR_PLURAL : 0)));
|
||||
}
|
||||
|
||||
scat(".");
|
||||
|
||||
scat(" Erforderlicher Talentwert: ");
|
||||
icat(b->type->construction->minskill);
|
||||
scat(".");
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
if (i != '!' && i != '?' && i != '.') {
|
||||
bytes = (int)strlcpy(bufp, ".", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
#endif
|
||||
*bufp = 0;
|
||||
rparagraph(F, buffer, 2, 0, 0);
|
||||
|
||||
|
|
|
@ -1108,7 +1108,7 @@ static void get_addresses(report_context * ctx)
|
|||
faction *sf = visible_faction(ctx->f, u);
|
||||
bool ballied = sf && sf != ctx->f && sf != lastf
|
||||
&& !fval(u, UFL_ANON_FACTION) && cansee(ctx->f, r, u, stealthmod);
|
||||
if (ballied || ALLIED(ctx->f, sf)) {
|
||||
if (ballied || is_allied(ctx->f, sf)) {
|
||||
add_seen_faction_i(&flist, sf);
|
||||
lastf = sf;
|
||||
}
|
||||
|
|
49
src/spells.c
49
src/spells.c
|
@ -6526,54 +6526,6 @@ int sp_becomewyrm(castorder * co)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
/* Name: WDW-Pyramidenfindezauber
|
||||
* Stufe: unterschiedlich
|
||||
* Gebiet: alle
|
||||
* Wirkung:
|
||||
* gibt die ungefaehre Entfernung zur naechstgelegenen Pyramiden-
|
||||
* region an.
|
||||
*
|
||||
* Flags:
|
||||
*/
|
||||
static int sp_wdwpyramid(castorder * co)
|
||||
{
|
||||
region *r = co_get_region(co);
|
||||
unit *mage = co->magician.u;
|
||||
int cast_level = co->level;
|
||||
|
||||
if (a_find(r->attribs, &at_wdwpyramid) != NULL) {
|
||||
ADDMSG(&mage->faction->msgs, msg_message("wdw_pyramidspell_found",
|
||||
"unit region command", mage, r, co->order));
|
||||
}
|
||||
else {
|
||||
region *r2;
|
||||
int mindist = INT_MAX;
|
||||
int minshowdist;
|
||||
int maxshowdist;
|
||||
|
||||
for (r2 = regions; r2; r2 = r2->next) {
|
||||
if (a_find(r2->attribs, &at_wdwpyramid) != NULL) {
|
||||
int dist = distance(mage->region, r2);
|
||||
if (dist < mindist) {
|
||||
mindist = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert(mindist >= 1);
|
||||
|
||||
minshowdist = mindist - rng_int() % 5;
|
||||
maxshowdist = minshowdist + 4;
|
||||
|
||||
ADDMSG(&mage->faction->msgs, msg_message("wdw_pyramidspell_notfound",
|
||||
"unit region command mindist maxdist", mage, r, co->order,
|
||||
_max(1, minshowdist), maxshowdist));
|
||||
}
|
||||
|
||||
return cast_level;
|
||||
}
|
||||
|
||||
typedef struct spelldata {
|
||||
const char *sname;
|
||||
spell_f cast;
|
||||
|
@ -6861,7 +6813,6 @@ void register_spells(void)
|
|||
ct_register(&ct_deathcloud);
|
||||
|
||||
register_function((pf_generic)sp_blessedharvest, "cast_blessedharvest");
|
||||
register_function((pf_generic)sp_wdwpyramid, "wdwpyramid");
|
||||
register_function((pf_generic)sp_summon_familiar, "cast_familiar");
|
||||
register_function((pf_generic)sp_babbler, "cast_babbler");
|
||||
register_function((pf_generic)sp_readmind, "cast_readmind");
|
||||
|
|
Loading…
Reference in New Issue