forked from github/server
simplified the work() functions
splitting more functionality from process_orders into separate functions
This commit is contained in:
parent
422008c0e2
commit
7783077517
23 changed files with 169 additions and 185 deletions
|
@ -866,7 +866,7 @@ show_allies(FILE * F, const faction * f, const ally * sf)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef REGIONOWNERS
|
||||
#ifdef ENEMIES
|
||||
static void
|
||||
show_enemies(FILE * F, const faction_list* flist)
|
||||
{
|
||||
|
@ -1137,7 +1137,7 @@ report_computer(const char * filename, report_context * ctx)
|
|||
for (i=0;i!=MAXOPTIONS;++i) {
|
||||
fprintf(F, "%d;%s\n", (f->options&want(i))?1:0, options[i]);
|
||||
}
|
||||
#ifdef REGIONOWNERS
|
||||
#ifdef ENEMIES
|
||||
show_enemies(F, f->enemies);
|
||||
#endif
|
||||
show_allies(F, f, f->allies);
|
||||
|
@ -1237,9 +1237,9 @@ report_computer(const char * filename, report_context * ctx)
|
|||
if (sd->mode!=see_unit) fprintf(F, "\"%s\";visibility\n", visibility[sd->mode]);
|
||||
|
||||
{
|
||||
unit * owner = region_owner(r);
|
||||
faction * owner = region_owner(r);
|
||||
if (owner) {
|
||||
fprintf(F, "%d;owner\n", owner->faction->no);
|
||||
fprintf(F, "%d;owner\n", owner->no);
|
||||
}
|
||||
}
|
||||
if (sd->mode == see_neighbour) {
|
||||
|
@ -1285,7 +1285,7 @@ report_computer(const char * filename, report_context * ctx)
|
|||
fprintf(F, "%d;Rekruten\n", rpeasants(r) / RECRUITFRACTION);
|
||||
}
|
||||
if (production(r)) {
|
||||
fprintf(F, "%d;Lohn\n", fwage(r, f, true));
|
||||
fprintf(F, "%d;Lohn\n", wage(r, NULL, NULL));
|
||||
}
|
||||
|
||||
while (res) {
|
||||
|
|
|
@ -2884,7 +2884,7 @@ expandwork(region * r)
|
|||
/* n: verbleibende Einnahmen */
|
||||
/* m: maximale Arbeiter */
|
||||
int m = maxworkingpeasants(r);
|
||||
int p_wage = wage(r,NULL,false);
|
||||
int p_wage = wage(r, NULL, NULL);
|
||||
int verdienst = 0;
|
||||
request *o;
|
||||
|
||||
|
@ -2902,7 +2902,7 @@ expandwork(region * r)
|
|||
|
||||
assert(workers>=0);
|
||||
|
||||
u->n = workers * wage(u->region, u, false);
|
||||
u->n = workers * wage(u->region, u->faction, u->race);
|
||||
|
||||
m -= workers;
|
||||
assert(m>=0);
|
||||
|
@ -2954,7 +2954,7 @@ work(unit * u, order * ord)
|
|||
cmistake(u, ord, 69, MSG_INCOME);
|
||||
return;
|
||||
}
|
||||
w = wage(r,u,false);
|
||||
w = wage(r, u->faction, u->race);
|
||||
u->wants = u->number * w;
|
||||
o = nextworker++;
|
||||
o->unit = u;
|
||||
|
|
|
@ -2764,7 +2764,7 @@ instant_orders(void)
|
|||
/* Beachten: einige Monster sollen auch unbewaffent die Region bewachen
|
||||
* können */
|
||||
void
|
||||
remove_unequipped_guarded(void)
|
||||
update_guards(void)
|
||||
{
|
||||
region *r;
|
||||
unit *u;
|
||||
|
@ -3038,7 +3038,7 @@ evict(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef REGIONOWNERS
|
||||
#ifdef ENEMIES
|
||||
static void
|
||||
declare_war(void)
|
||||
{
|
||||
|
@ -4037,7 +4037,7 @@ processorders (void)
|
|||
#ifdef ALLIANCEJOIN
|
||||
alliancejoin();
|
||||
#endif
|
||||
#ifdef REGIONOWNERS
|
||||
#ifdef ENEMIES
|
||||
puts(" - Krieg & Frieden");
|
||||
declare_war();
|
||||
#endif
|
||||
|
|
|
@ -32,7 +32,7 @@ void demographics(void);
|
|||
void last_orders(void);
|
||||
void stripunit(struct unit * u);
|
||||
void find_address(void);
|
||||
void remove_unequipped_guarded(void);
|
||||
void update_guards(void);
|
||||
|
||||
/* eressea-specific. put somewhere else, please. */
|
||||
#include "resolve.h"
|
||||
|
|
|
@ -1126,10 +1126,10 @@ describe(FILE * F, const region * r, int partial, faction * f)
|
|||
}
|
||||
|
||||
{
|
||||
const unit * u = region_owner(r);
|
||||
if (u) {
|
||||
const faction * owner = region_owner(r);
|
||||
if (owner!=NULL) {
|
||||
bufp += strxcpy(bufp, " Die Region ist im Besitz von ");
|
||||
bufp += strxcpy(bufp, factionname(u->faction));
|
||||
bufp += strxcpy(bufp, factionname(owner));
|
||||
strcpy(bufp++, ".");
|
||||
}
|
||||
}
|
||||
|
@ -1290,7 +1290,7 @@ statistics(FILE * F, const region * r, const faction * f)
|
|||
msg_release(m);
|
||||
}
|
||||
if (production(r) && (!fval(r->terrain, SEA_REGION) || f->race == new_race[RC_AQUARIAN])) {
|
||||
m = msg_message("nr_stat_salary", "max", fwage(r, f, true));
|
||||
m = msg_message("nr_stat_salary", "max", wage(r, f, f->race));
|
||||
nr_render(m, f->locale, buf, sizeof(buf), f);
|
||||
rps(F, buf);
|
||||
msg_release(m);
|
||||
|
@ -1470,7 +1470,7 @@ report_template(const char * filename, report_context * ctx)
|
|||
}
|
||||
rps_nowrap(F, buf);
|
||||
rnl(F);
|
||||
sprintf(buf,"; ECheck Lohn %d", fwage(r,f,true));
|
||||
sprintf(buf,"; ECheck Lohn %d", wage(r, f, f->race));
|
||||
rps_nowrap(F, buf);
|
||||
rnl(F);
|
||||
rps_nowrap(F, "");
|
||||
|
@ -1655,7 +1655,7 @@ allies(FILE * F, const faction * f)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef REGIONOWNERS
|
||||
#ifdef ENEMIES
|
||||
static void
|
||||
enemies(FILE * F, const faction * f)
|
||||
{
|
||||
|
@ -2150,7 +2150,7 @@ report_plaintext(const char * filename, report_context * ctx)
|
|||
centre(F, LOC(f->locale, "nr_alliances"), false);
|
||||
rnl(F);
|
||||
|
||||
#ifdef REGIONOWNERS
|
||||
#ifdef ENEMIES
|
||||
enemies(F, f);
|
||||
#endif
|
||||
allies(F, f);
|
||||
|
|
|
@ -2784,7 +2784,7 @@ plagues(region * r, boolean ismagic)
|
|||
/* Seuchenwahrscheinlichkeit in % */
|
||||
|
||||
prob = pow((double) rpeasants(r) /
|
||||
(mwp * (((double)wage(r,NULL,false)) / 10.0) * 1.3), 4.0)
|
||||
(mwp * (((double)wage(r, NULL, NULL)) / 10.0) * 1.3), 4.0)
|
||||
* (double) SEUCHE;
|
||||
|
||||
if (rand() % 100 >= (int)prob && !ismagic) return;
|
||||
|
@ -2823,43 +2823,46 @@ static const int wagetable[7][4] = {
|
|||
{15, 13, 16, 2} /* Zitadelle */
|
||||
};
|
||||
|
||||
/* Gibt Arbeitslohn für entsprechende Rasse zurück, oder für
|
||||
* die Bauern wenn f == NULL. */
|
||||
int
|
||||
wage(const region *r, const unit *u, boolean img)
|
||||
/* Gibt Arbeitslohn für entsprechende Rasse zurück, oder für
|
||||
* die Bauern wenn ra == NORACE. */
|
||||
wage(const region *r, const faction * f, const race * rc)
|
||||
{
|
||||
building *b = largestbuilding(r, img);
|
||||
int esize = 0;
|
||||
curse * c;
|
||||
int wage;
|
||||
attrib *a;
|
||||
building *b = largestbuilding(r, false);
|
||||
int esize = 0;
|
||||
curse * c;
|
||||
int wage;
|
||||
attrib *a;
|
||||
const building_type *artsculpture_type = bt_find("artsculpture");
|
||||
static const curse_type * drought_ct, * blessedharvest_ct;
|
||||
static boolean init;
|
||||
static const curse_type * drought_ct, * blessedharvest_ct;
|
||||
static boolean init;
|
||||
|
||||
if (!init) {
|
||||
init = true;
|
||||
drought_ct = ct_find("drought");
|
||||
blessedharvest_ct = ct_find("blessedharvest");
|
||||
}
|
||||
if (!init) {
|
||||
init = true;
|
||||
drought_ct = ct_find("drought");
|
||||
blessedharvest_ct = ct_find("blessedharvest");
|
||||
}
|
||||
|
||||
if (b) esize = buildingeffsize(b, img);
|
||||
if (b!=NULL) {
|
||||
/* TODO: this reveals imaginary castles */
|
||||
esize = buildingeffsize(b, false);
|
||||
}
|
||||
|
||||
if (u) {
|
||||
wage = wagetable[esize][u->race == new_race[RC_ORC] || u->race == new_race[RC_SNOTLING] || u->race == new_race[RC_URUK]];
|
||||
if (fspecial(u->faction, FS_URBAN)) {
|
||||
wage += wagetable[esize][3];
|
||||
}
|
||||
} else {
|
||||
if (fval(r->terrain, SEA_REGION)) {
|
||||
wage = 11;
|
||||
} else if (fval(r, RF_ORCIFIED)) {
|
||||
wage = wagetable[esize][1];
|
||||
} else {
|
||||
wage = wagetable[esize][2];
|
||||
}
|
||||
wage += curse_geteffect(get_curse(r->attribs, blessedharvest_ct));
|
||||
}
|
||||
if (f!=NULL) {
|
||||
wage = wagetable[esize][rc == new_race[RC_ORC]];
|
||||
if (fspecial(f, FS_URBAN)) {
|
||||
wage += wagetable[esize][3];
|
||||
}
|
||||
} else {
|
||||
if (fval(r->terrain, SEA_REGION)) {
|
||||
wage = 11;
|
||||
} else if (fval(r, RF_ORCIFIED)) {
|
||||
wage = wagetable[esize][1];
|
||||
} else {
|
||||
wage = wagetable[esize][2];
|
||||
}
|
||||
wage += curse_geteffect(get_curse(r->attribs, blessedharvest_ct));
|
||||
}
|
||||
|
||||
/* Artsculpture: Income +5 */
|
||||
for(b=r->buildings; b; b=b->next) {
|
||||
|
@ -2868,63 +2871,21 @@ wage(const region *r, const unit *u, boolean img)
|
|||
}
|
||||
}
|
||||
|
||||
/* Godcurse: Income -10 */
|
||||
if (curse_active(get_curse(r->attribs, ct_find("godcursezone")))) {
|
||||
wage = max(0,wage-10);
|
||||
}
|
||||
/* Godcurse: Income -10 */
|
||||
if (curse_active(get_curse(r->attribs, ct_find("godcursezone")))) {
|
||||
wage = max(0,wage-10);
|
||||
}
|
||||
|
||||
/* Bei einer Dürre verdient man nur noch ein Viertel */
|
||||
if (drought_ct) {
|
||||
c = get_curse(r->attribs, drought_ct);
|
||||
if (curse_active(c)) wage /= curse_geteffect(c);
|
||||
}
|
||||
/* Bei einer Dürre verdient man nur noch ein Viertel */
|
||||
if (drought_ct) {
|
||||
c = get_curse(r->attribs, drought_ct);
|
||||
if (curse_active(c)) wage /= curse_geteffect(c);
|
||||
}
|
||||
|
||||
a = a_find(r->attribs, &at_reduceproduction);
|
||||
if (a) wage = (wage * a->data.sa[0])/100;
|
||||
a = a_find(r->attribs, &at_reduceproduction);
|
||||
if (a) wage = (wage * a->data.sa[0])/100;
|
||||
|
||||
return wage;
|
||||
}
|
||||
|
||||
int
|
||||
fwage(const region *r, const faction *f, boolean img)
|
||||
{
|
||||
building *b = largestbuilding(r, img);
|
||||
int esize = 0;
|
||||
int wage;
|
||||
attrib *a;
|
||||
curse * c;
|
||||
|
||||
if (b) esize = buildingeffsize(b, img);
|
||||
|
||||
if (f) {
|
||||
wage = wagetable[esize][f->race == new_race[RC_ORC]];
|
||||
if (fspecial(f, FS_URBAN)) {
|
||||
wage += wagetable[esize][3];
|
||||
}
|
||||
} else {
|
||||
if (fval(r->terrain, SEA_REGION)) {
|
||||
wage = 11;
|
||||
} else if (fval(r, RF_ORCIFIED)) {
|
||||
wage = wagetable[esize][1];
|
||||
} else {
|
||||
wage = wagetable[esize][2];
|
||||
}
|
||||
wage += curse_geteffect(get_curse(r->attribs, ct_find("blessedharvest")));
|
||||
}
|
||||
|
||||
/* Godcurse: Income -10 */
|
||||
if (curse_active(get_curse(r->attribs, ct_find("godcursezone")))) {
|
||||
wage = max(0,wage-10);
|
||||
}
|
||||
|
||||
/* Bei einer Dürre verdient man nur noch ein Viertel */
|
||||
c = get_curse(r->attribs, ct_find("drought"));
|
||||
if (curse_active(c)) wage /= curse_geteffect(c);
|
||||
|
||||
a = a_find(r->attribs, &at_reduceproduction);
|
||||
if (a) wage = (wage * a->data.sa[0])/100;
|
||||
|
||||
return wage;
|
||||
return wage;
|
||||
}
|
||||
|
||||
static region *
|
||||
|
|
|
@ -181,8 +181,8 @@ struct building_type;
|
|||
#define REGIONOWNERS_VERSION 400
|
||||
#define UGROUPS_VERSION 500 /* nicht aktivieren, nicht fertig */
|
||||
|
||||
#ifdef REGIONOWNERS
|
||||
# define RELEASE_VERSION REGIONOWNERS_VERSION
|
||||
#ifdef ENEMIES
|
||||
# define RELEASE_VERSION ENEMIES_VERSION
|
||||
#else
|
||||
# define RELEASE_VERSION TERRAIN_VERSION
|
||||
#endif
|
||||
|
@ -1121,8 +1121,7 @@ extern int lifestyle(const struct unit*);
|
|||
extern int besieged(const struct unit * u);
|
||||
extern int maxworkingpeasants(const struct region * r);
|
||||
|
||||
extern int wage(const struct region *r, const struct unit *u, boolean img);
|
||||
extern int fwage(const struct region *r, const struct faction *f, boolean img);
|
||||
extern int wage(const struct region *r, const struct faction *f, const struct race * rc);
|
||||
extern int movewhere(const struct unit *u, const char * token, struct region * r, struct region** resultp);
|
||||
extern struct message * movement_error(struct unit * u, const char * token, struct order * ord, int error_code);
|
||||
extern boolean move_blocked(const struct unit * u, const struct region *src, const struct region *dest);
|
||||
|
@ -1159,6 +1158,7 @@ typedef struct settings {
|
|||
boolean disabled[MAXKEYWORDS];
|
||||
struct param * parameters;
|
||||
void * vm_state;
|
||||
|
||||
} settings;
|
||||
extern settings global;
|
||||
|
||||
|
|
|
@ -314,7 +314,7 @@ update_interval(struct faction * f, struct region * r)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef REGIONOWNERS
|
||||
#ifdef ENEMIES
|
||||
boolean
|
||||
is_enemy(const struct faction * f, const struct faction * enemy)
|
||||
{
|
||||
|
|
|
@ -95,7 +95,7 @@ typedef struct faction {
|
|||
struct unit * units;
|
||||
struct attrib *attribs;
|
||||
struct message_list * msgs;
|
||||
#ifdef REGIONOWNERS
|
||||
#ifdef ENEMIES
|
||||
struct faction_list * enemies;
|
||||
#endif
|
||||
struct bmsg {
|
||||
|
@ -124,7 +124,7 @@ extern void destroyfaction(faction * f);
|
|||
extern void set_alliance(struct faction * a, struct faction * b, int status);
|
||||
extern int get_alliance(const struct faction * a, const struct faction * b);
|
||||
|
||||
#ifdef REGIONOWNERS
|
||||
#ifdef ENEMIES
|
||||
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, struct faction * enemy);
|
||||
|
|
|
@ -191,13 +191,16 @@ 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;
|
||||
faction * owner = region_owner(r);
|
||||
if (owner == NULL || u->faction == owner) return true;
|
||||
if (alliedfaction(r->planep, owner, u->faction, HELP_TRAVEL)) return true;
|
||||
#ifdef ENEMIES
|
||||
if (is_enemy(u->faction, owner)) return true;
|
||||
#endif
|
||||
return false;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -1002,7 +1002,7 @@ terraform_region(region * r, const terrain_type * terrain)
|
|||
peasants = MAXPEASANTS_PER_AREA * (rand() % (terrain->size / MAXPEASANTS_PER_AREA / 2));
|
||||
#endif
|
||||
rsetpeasants(r, max(100, peasants));
|
||||
rsetmoney(r, rpeasants(r) * ((wage(r, NULL, false)+1) + rand() % 5));
|
||||
rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL)+1) + rand() % 5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1079,24 +1079,22 @@ r_addmessage(struct region * r, const struct faction * viewer, struct message *
|
|||
return add_message(&imsg->msgs, msg);
|
||||
}
|
||||
|
||||
struct unit *
|
||||
struct faction *
|
||||
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) {
|
||||
struct unit * u = buildingowner(r, b);
|
||||
if (u) {
|
||||
owner = u;
|
||||
maxsize=b->size;
|
||||
}
|
||||
}
|
||||
}
|
||||
return owner;
|
||||
return r->owner;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
region_setowner(struct region * r, struct faction * owner)
|
||||
{
|
||||
#ifdef REGIONOWNERS
|
||||
r->owner = owner;
|
||||
#else
|
||||
unused(r, owner);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -106,6 +106,9 @@ typedef struct region {
|
|||
struct donation * donations;
|
||||
const struct terrain_type * terrain;
|
||||
struct rawmaterial * resources;
|
||||
#ifdef REGIONOWNERS
|
||||
struct faction * owner;
|
||||
#endif
|
||||
#ifdef FAST_CONNECT
|
||||
struct region * connect[MAXDIRECTIONS];
|
||||
#endif
|
||||
|
@ -232,7 +235,9 @@ extern int production(const struct region *r);
|
|||
extern int read_region_reference(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);
|
||||
void region_setowner(struct region * r, struct faction * owner);
|
||||
extern struct faction * region_owner(const struct region * r);
|
||||
|
||||
extern struct region * r_connect(const struct region *, direction_t dir);
|
||||
#ifdef FAST_CONNECT
|
||||
# define rconnect(r, dir) ((r)->connect[dir]?(r)->connect[dir]:r_connect(r, dir))
|
||||
|
|
|
@ -425,11 +425,11 @@ getbuf(FILE * F)
|
|||
return buf;
|
||||
}
|
||||
|
||||
#ifdef REGIONOWNERS
|
||||
#ifdef ENEMIES
|
||||
static void
|
||||
read_enemies(FILE * F, faction * f)
|
||||
{
|
||||
if (global.data_version<REGIONOWNERS_VERSION) return;
|
||||
if (global.data_version<ENEMIES_VERSION) return;
|
||||
f->enemies = NULL;
|
||||
for (;;) {
|
||||
char zText[32];
|
||||
|
@ -448,12 +448,10 @@ read_enemies(FILE * F, faction * f)
|
|||
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
|
||||
|
||||
|
@ -1666,7 +1664,7 @@ readfaction(FILE * F)
|
|||
}
|
||||
}
|
||||
read_groups(F, f);
|
||||
#ifdef REGIONOWNERS
|
||||
#ifdef ENEMIES
|
||||
read_enemies(F, f);
|
||||
#endif
|
||||
return f;
|
||||
|
@ -1731,7 +1729,7 @@ writefaction(FILE * F, const faction * f)
|
|||
fprintf(F, "end ");
|
||||
wnl(F);
|
||||
write_groups(F, f->groups);
|
||||
#ifdef REGIONOWNERS
|
||||
#ifdef ENEMIES
|
||||
write_enemies(F, f->enemies);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <config.h>
|
||||
#include "eressea.h"
|
||||
#ifdef SCORE_MODULE
|
||||
#include "score.h"
|
||||
|
||||
/* kernel includes */
|
||||
#include <kernel/alliance.h>
|
||||
|
|
|
@ -220,7 +220,7 @@ extern char * strdup(const char *s);
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#define unused(var) var = var
|
||||
#define unused(var) (var)
|
||||
|
||||
|
||||
/**** ****
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <attributes/key.h>
|
||||
#include <modules/autoseed.h>
|
||||
#include <modules/score.h>
|
||||
|
||||
// gamecode includes
|
||||
#include <gamecode/laws.h>
|
||||
|
@ -218,6 +219,40 @@ lua_equipunit(unit& u, const char * eqname)
|
|||
equip_unit(&u, get_equipment(eqname));
|
||||
}
|
||||
|
||||
static void
|
||||
update_subscriptions(void)
|
||||
{
|
||||
FILE * F;
|
||||
char zText[MAX_PATH];
|
||||
faction * f;
|
||||
strcat(strcpy(zText, basepath()), "/subscriptions");
|
||||
F = fopen(zText, "r");
|
||||
if (F==NULL) {
|
||||
log_info((0, "could not open %s.\n", zText));
|
||||
return;
|
||||
}
|
||||
for (;;) {
|
||||
char zFaction[5];
|
||||
int subscription, fno;
|
||||
if (fscanf(F, "%d %s", &subscription, zFaction)<=0) break;
|
||||
fno = atoi36(zFaction);
|
||||
f = findfaction(fno);
|
||||
if (f!=NULL) {
|
||||
f->subscription=subscription;
|
||||
}
|
||||
}
|
||||
fclose(F);
|
||||
|
||||
sprintf(zText, "subscriptions.%u", turn);
|
||||
F = fopen(zText, "w");
|
||||
for (f=factions;f!=NULL;f=f->next) {
|
||||
fprintf(F, "%s:%u:%s:%s:%s:%u:\n",
|
||||
itoa36(f->no), f->subscription, f->email, f->override,
|
||||
dbrace(f->race), f->lastorders);
|
||||
}
|
||||
fclose(F);
|
||||
}
|
||||
|
||||
static void
|
||||
lua_learnskill(unit& u, const char * skname, float chances)
|
||||
{
|
||||
|
@ -248,6 +283,10 @@ bind_eressea(lua_State * L)
|
|||
def("get_turn", &get_turn),
|
||||
def("remove_empty_units", &remove_empty_units),
|
||||
|
||||
def("update_subscriptions", &update_subscriptions),
|
||||
def("update_guards", &update_guards),
|
||||
def("update_scores", &score),
|
||||
|
||||
def("equip_unit", &lua_equipunit),
|
||||
def("learn_skill", &lua_learnskill),
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
// kernel includes
|
||||
#include <kernel/building.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/plane.h>
|
||||
#include <kernel/region.h>
|
||||
|
@ -58,6 +59,16 @@ region_getname(const region& r) {
|
|||
return r.terrain->_name;
|
||||
}
|
||||
|
||||
static void
|
||||
lua_region_setowner(region& r, faction * f) {
|
||||
region_setowner(&r, f);
|
||||
}
|
||||
|
||||
static faction *
|
||||
lua_region_getowner(const region& r) {
|
||||
return region_owner(&r);
|
||||
}
|
||||
|
||||
static void
|
||||
region_setinfo(region& r, const char * info) {
|
||||
set_string(&r.display, info);
|
||||
|
@ -244,6 +255,7 @@ bind_region(lua_State * L)
|
|||
.def(self == region())
|
||||
.property("name", ®ion_getname, ®ion_setname)
|
||||
.property("info", ®ion_getinfo, ®ion_setinfo)
|
||||
.property("owner", &lua_region_getowner, &lua_region_setowner)
|
||||
.property("terrain", ®ion_getterrain)
|
||||
.def("add_notice", ®ion_addnotice)
|
||||
.def("add_direction", ®ion_adddirection)
|
||||
|
|
|
@ -268,7 +268,7 @@ processturn(char *filename)
|
|||
autoseed(&players, k, true);
|
||||
}
|
||||
score();
|
||||
remove_unequipped_guarded();
|
||||
update_guards();
|
||||
if (!noreports) reports();
|
||||
free_units();
|
||||
puts(" - Beseitige leere Parteien");
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include <items/itemtypes.h>
|
||||
|
||||
/* modules includes */
|
||||
#include <modules/score.h>
|
||||
#include <modules/xmas.h>
|
||||
#include <modules/gmcmd.h>
|
||||
#include <modules/infocmd.h>
|
||||
|
@ -324,40 +323,6 @@ lua_done(lua_State * luaState)
|
|||
lua_close(luaState);
|
||||
}
|
||||
|
||||
static void
|
||||
update_subscriptions(void)
|
||||
{
|
||||
FILE * F;
|
||||
char zText[MAX_PATH];
|
||||
faction * f;
|
||||
strcat(strcpy(zText, basepath()), "/subscriptions");
|
||||
F = fopen(zText, "r");
|
||||
if (F==NULL) {
|
||||
log_info((0, "could not open %s.\n", zText));
|
||||
return;
|
||||
}
|
||||
for (;;) {
|
||||
char zFaction[5];
|
||||
int subscription, fno;
|
||||
if (fscanf(F, "%d %s", &subscription, zFaction)<=0) break;
|
||||
fno = atoi36(zFaction);
|
||||
f = findfaction(fno);
|
||||
if (f!=NULL) {
|
||||
f->subscription=subscription;
|
||||
}
|
||||
}
|
||||
fclose(F);
|
||||
|
||||
sprintf(zText, "subscriptions.%u", turn);
|
||||
F = fopen(zText, "w");
|
||||
for (f=factions;f!=NULL;f=f->next) {
|
||||
fprintf(F, "%s:%u:%s:%s:%s:%u:\n",
|
||||
itoa36(f->no), f->subscription, f->email, f->override,
|
||||
dbrace(f->race), f->lastorders);
|
||||
}
|
||||
fclose(F);
|
||||
}
|
||||
|
||||
int
|
||||
process_orders()
|
||||
{
|
||||
|
@ -369,10 +334,7 @@ process_orders()
|
|||
#endif
|
||||
turn++;
|
||||
processorders();
|
||||
score();
|
||||
remove_unequipped_guarded();
|
||||
|
||||
update_subscriptions();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ end
|
|||
function process(orders)
|
||||
-- initialize starting equipment for new players
|
||||
equipment_setitem("new_faction", "conquesttoken", "1");
|
||||
equipment_setitem("new_faction", "wood", "30");
|
||||
equipment_setitem("new_faction", "log", "30");
|
||||
equipment_setitem("new_faction", "stone", "30");
|
||||
equipment_setitem("new_faction", "money", "4200");
|
||||
|
||||
|
|
|
@ -81,6 +81,8 @@ function process(orders)
|
|||
spawn_braineaters(0.25)
|
||||
plan_monsters()
|
||||
process_orders()
|
||||
update_guards()
|
||||
update_scores()
|
||||
|
||||
change_locales()
|
||||
|
||||
|
@ -99,6 +101,11 @@ function process(orders)
|
|||
end
|
||||
end
|
||||
|
||||
-- demo: how to add a special familiars-constructor
|
||||
function initfamiliar_lynx(u)
|
||||
print("a lynx is born ;-)")
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- main body of script
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
function initfamiliar_lynx(u)
|
||||
print("a lynx is born :-)")
|
||||
end
|
||||
|
||||
function peasant_getresource(u)
|
||||
return u.region:get_resource("peasant")
|
||||
end
|
||||
|
|
|
@ -18,7 +18,8 @@ function process(orders)
|
|||
-- (no more braineaters) spawn_braineaters(0.25)
|
||||
plan_monsters()
|
||||
process_orders()
|
||||
outfile = "" .. get_turn()
|
||||
update_guards()
|
||||
update_scores()
|
||||
|
||||
-- write out the initial reports (no need to run a turn)
|
||||
write_passwords()
|
||||
|
@ -28,6 +29,7 @@ function process(orders)
|
|||
write_standings()
|
||||
|
||||
-- save the game
|
||||
outfile = "" .. get_turn()
|
||||
if write_game(outfile)~=0 then
|
||||
print("could not write game")
|
||||
return -1
|
||||
|
|
Loading…
Reference in a new issue