forked from github/server
commit
292117f2b1
|
@ -20,6 +20,11 @@
|
||||||
<xi:include href="config://game/spells.xml"/>
|
<xi:include href="config://game/spells.xml"/>
|
||||||
<xi:include href="config://default/adamantium.xml"/>
|
<xi:include href="config://default/adamantium.xml"/>
|
||||||
<equipment>
|
<equipment>
|
||||||
|
<set name="first_unit">
|
||||||
|
<item name="money" amount="2500"/>
|
||||||
|
<item name="log" amount="10"/>
|
||||||
|
<item name="stone" amount="4"/>
|
||||||
|
</set>
|
||||||
<set name="autoseed_unit">
|
<set name="autoseed_unit">
|
||||||
<item name="log" amount="50"/>
|
<item name="log" amount="50"/>
|
||||||
<item name="stone" amount="50"/>
|
<item name="stone" amount="50"/>
|
||||||
|
|
|
@ -69,6 +69,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
#include <attributes/reduceproduction.h>
|
#include <attributes/reduceproduction.h>
|
||||||
#include <attributes/racename.h>
|
#include <attributes/racename.h>
|
||||||
|
#include <spells/regioncurse.h>
|
||||||
|
|
||||||
/* libs includes */
|
/* libs includes */
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
@ -2653,14 +2654,10 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork)
|
||||||
jobs = rpeasants(r);
|
jobs = rpeasants(r);
|
||||||
}
|
}
|
||||||
earnings = jobs * p_wage;
|
earnings = jobs * p_wage;
|
||||||
if (r->attribs && rule_blessed_harvest() == HARVEST_TAXES) {
|
if (jobs > 0 && r->attribs && rule_blessed_harvest() == HARVEST_TAXES) {
|
||||||
/* E3 rules */
|
/* E3 rules */
|
||||||
const curse_type *blessedharvest_ct = ct_find("blessedharvest");
|
int happy = harvest_effect(r);
|
||||||
if (blessedharvest_ct) {
|
earnings += happy * jobs;
|
||||||
int happy =
|
|
||||||
(int)(jobs * curse_geteffect(get_curse(r->attribs, blessedharvest_ct)));
|
|
||||||
earnings += happy;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
rsetmoney(r, money + earnings);
|
rsetmoney(r, money + earnings);
|
||||||
}
|
}
|
||||||
|
|
64
src/gmtool.c
64
src/gmtool.c
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* +-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
* +-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||||
* | | Enno Rehling <enno@eressea.de>
|
* | | Enno Rehling <enno@eressea.de>
|
||||||
* | Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
* | Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||||
|
@ -81,7 +81,7 @@ int gm_codepage = -1;
|
||||||
|
|
||||||
static void unicode_remove_diacritics(const char *rp, char *wp) {
|
static void unicode_remove_diacritics(const char *rp, char *wp) {
|
||||||
while (*rp) {
|
while (*rp) {
|
||||||
if (gm_codepage >=0 && *rp & 0x80) {
|
if (gm_codepage >= 0 && *rp & 0x80) {
|
||||||
size_t sz = 0;
|
size_t sz = 0;
|
||||||
unsigned char ch;
|
unsigned char ch;
|
||||||
switch (gm_codepage) {
|
switch (gm_codepage) {
|
||||||
|
@ -115,7 +115,7 @@ int umvwprintw(WINDOW *win, int y, int x, const char *format, ...) {
|
||||||
|
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
memset(buffer, 0, sizeof(buffer));
|
memset(buffer, 0, sizeof(buffer));
|
||||||
vsnprintf(buffer, sizeof(buffer)-1, format, args);
|
vsnprintf(buffer, sizeof(buffer) - 1, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
simplify(buffer, buffer);
|
simplify(buffer, buffer);
|
||||||
|
@ -344,7 +344,7 @@ map_region *cursor_region(const view * v, const coordinate * c)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
draw_cursor(WINDOW * win, selection * s, const view * v, const coordinate * c,
|
draw_cursor(WINDOW * win, selection * s, const view * v, const coordinate * c,
|
||||||
int show)
|
int show)
|
||||||
{
|
{
|
||||||
int lines = getmaxy(win) / THEIGHT;
|
int lines = getmaxy(win) / THEIGHT;
|
||||||
int xp, yp, nx, ny;
|
int xp, yp, nx, ny;
|
||||||
|
@ -814,7 +814,7 @@ static void select_regions(state * st, int selectmode)
|
||||||
st->wnd_map->update |= 3;
|
st->wnd_map->update |= 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loaddata(state *st) {
|
static void loaddata(state *st) {
|
||||||
char datafile[MAX_PATH];
|
char datafile[MAX_PATH];
|
||||||
|
|
||||||
askstring(st->wnd_status->handle, "save as:", datafile, sizeof(datafile));
|
askstring(st->wnd_status->handle, "save as:", datafile, sizeof(datafile));
|
||||||
|
@ -824,7 +824,7 @@ void loaddata(state *st) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void savedata(state *st) {
|
static void savedata(state *st) {
|
||||||
char datafile[MAX_PATH];
|
char datafile[MAX_PATH];
|
||||||
|
|
||||||
askstring(st->wnd_status->handle, "save as:", datafile, sizeof(datafile));
|
askstring(st->wnd_status->handle, "save as:", datafile, sizeof(datafile));
|
||||||
|
@ -835,6 +835,20 @@ void savedata(state *st) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void seed_player(state *st, const newfaction *player) {
|
||||||
|
if (player) {
|
||||||
|
region *r;
|
||||||
|
int nx = st->cursor.x;
|
||||||
|
int ny = st->cursor.y;
|
||||||
|
|
||||||
|
pnormalize(&nx, &ny, st->cursor.pl);
|
||||||
|
r = findregion(nx, ny);
|
||||||
|
if (r) {
|
||||||
|
addplayer(r, addfaction(player->email, player->password, player->race,
|
||||||
|
player->lang, player->subscription));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
static void handlekey(state * st, int c)
|
static void handlekey(state * st, int c)
|
||||||
{
|
{
|
||||||
window *wnd;
|
window *wnd;
|
||||||
|
@ -897,10 +911,6 @@ static void handlekey(state * st, int c)
|
||||||
loaddata(st);
|
loaddata(st);
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
if (!new_players) {
|
|
||||||
join_path(basepath(), "newfactions", sbuffer, sizeof(sbuffer));
|
|
||||||
new_players = read_newfactions(sbuffer);
|
|
||||||
}
|
|
||||||
cnormalize(&st->cursor, &nx, &ny);
|
cnormalize(&st->cursor, &nx, &ny);
|
||||||
minpop = config_get_int("editor.population.min", 8);
|
minpop = config_get_int("editor.population.min", 8);
|
||||||
maxpop = config_get_int("editor.population.max", minpop);
|
maxpop = config_get_int("editor.population.max", minpop);
|
||||||
|
@ -1111,13 +1121,15 @@ static void handlekey(state * st, int c)
|
||||||
else
|
else
|
||||||
tag_region(st->selected, nx, ny);
|
tag_region(st->selected, nx, ny);
|
||||||
break;
|
break;
|
||||||
case 'A':
|
case 's': /* seed */
|
||||||
if (!new_players) {
|
if (new_players) {
|
||||||
join_path(basepath(), "newfactions", sbuffer, sizeof(sbuffer));
|
newfaction * next = new_players->next;
|
||||||
new_players = read_newfactions(sbuffer);
|
seed_player(st, new_players);
|
||||||
|
free(new_players->email);
|
||||||
|
free(new_players->password);
|
||||||
|
free(new_players);
|
||||||
|
new_players = next;
|
||||||
}
|
}
|
||||||
seed_players(&new_players, false);
|
|
||||||
st->wnd_map->update |= 1;
|
|
||||||
break;
|
break;
|
||||||
case '/':
|
case '/':
|
||||||
statusline(st->wnd_status->handle, "find-");
|
statusline(st->wnd_status->handle, "find-");
|
||||||
|
@ -1289,13 +1301,15 @@ void run_mapper(void)
|
||||||
int split = 20;
|
int split = 20;
|
||||||
state *st;
|
state *st;
|
||||||
point tl;
|
point tl;
|
||||||
/* FIXME: dsiable logging
|
char sbuffer[512];
|
||||||
int old_flags = log_flags;
|
|
||||||
log_flags &= ~(LOG_CPERROR | LOG_CPWARNING);
|
if (!new_players) {
|
||||||
*/
|
join_path(basepath(), "newfactions", sbuffer, sizeof(sbuffer));
|
||||||
|
new_players = read_newfactions(sbuffer);
|
||||||
|
}
|
||||||
|
|
||||||
init_curses();
|
init_curses();
|
||||||
curs_set(1);
|
curs_set(1);
|
||||||
|
|
||||||
set_readline(curses_readline);
|
set_readline(curses_readline);
|
||||||
assert(stdscr);
|
assert(stdscr);
|
||||||
getbegyx(stdscr, x, y);
|
getbegyx(stdscr, x, y);
|
||||||
|
@ -1384,15 +1398,15 @@ void run_mapper(void)
|
||||||
set_readline(NULL);
|
set_readline(NULL);
|
||||||
curs_set(1);
|
curs_set(1);
|
||||||
endwin();
|
endwin();
|
||||||
/* FIXME: reset logging
|
/* FIXME: reset logging
|
||||||
log_flags = old_flags;
|
log_flags = old_flags;
|
||||||
*/
|
*/
|
||||||
state_close(st);
|
state_close(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
curses_readline(struct lua_State *L, char *buffer, size_t size,
|
curses_readline(struct lua_State *L, char *buffer, size_t size,
|
||||||
const char *prompt)
|
const char *prompt)
|
||||||
{
|
{
|
||||||
UNUSED_ARG(L);
|
UNUSED_ARG(L);
|
||||||
askstring(hstatus, prompt, buffer, size);
|
askstring(hstatus, prompt, buffer, size);
|
||||||
|
|
|
@ -22,7 +22,6 @@ extern "C" {
|
||||||
struct terrain_type;
|
struct terrain_type;
|
||||||
struct newfaction;
|
struct newfaction;
|
||||||
|
|
||||||
int gmmain(int argc, char *argv[]);
|
|
||||||
int curses_readline(struct lua_State *L, char *buffer, size_t size,
|
int curses_readline(struct lua_State *L, char *buffer, size_t size,
|
||||||
const char *prompt);
|
const char *prompt);
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
/* attributes includes */
|
/* attributes includes */
|
||||||
|
#include <spells/regioncurse.h>
|
||||||
#include <attributes/reduceproduction.h>
|
#include <attributes/reduceproduction.h>
|
||||||
|
|
||||||
typedef struct building_typelist {
|
typedef struct building_typelist {
|
||||||
|
@ -710,7 +711,7 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn)
|
||||||
}
|
}
|
||||||
if (r->attribs && rule_blessed_harvest() == HARVEST_WORK) {
|
if (r->attribs && rule_blessed_harvest() == HARVEST_WORK) {
|
||||||
/* E1 rules */
|
/* E1 rules */
|
||||||
wage += curse_geteffect(get_curse(r->attribs, ct_find("blessedharvest")));
|
wage += harvest_effect(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -596,28 +596,23 @@ curse *create_curse(unit * magician, attrib ** ap, const curse_type * ct,
|
||||||
if (ct->mergeflags & M_DURATION) {
|
if (ct->mergeflags & M_DURATION) {
|
||||||
c->duration = MAX(c->duration, duration);
|
c->duration = MAX(c->duration, duration);
|
||||||
}
|
}
|
||||||
if (ct->mergeflags & M_SUMDURATION) {
|
else if (ct->mergeflags & M_SUMDURATION) {
|
||||||
c->duration += duration;
|
c->duration += duration;
|
||||||
}
|
}
|
||||||
if (ct->mergeflags & M_SUMEFFECT) {
|
|
||||||
c->effect += effect;
|
|
||||||
}
|
|
||||||
if (ct->mergeflags & M_MAXEFFECT) {
|
if (ct->mergeflags & M_MAXEFFECT) {
|
||||||
c->effect = MAX(c->effect, effect);
|
c->effect = MAX(c->effect, effect);
|
||||||
}
|
}
|
||||||
|
else if (ct->mergeflags & M_SUMEFFECT) {
|
||||||
|
c->effect += effect;
|
||||||
|
}
|
||||||
if (ct->mergeflags & M_VIGOUR) {
|
if (ct->mergeflags & M_VIGOUR) {
|
||||||
c->vigour = MAX(vigour, c->vigour);
|
c->vigour = MAX(vigour, c->vigour);
|
||||||
}
|
}
|
||||||
if (ct->mergeflags & M_VIGOUR_ADD) {
|
else if (ct->mergeflags & M_VIGOUR_ADD) {
|
||||||
c->vigour = vigour + c->vigour;
|
c->vigour = vigour + c->vigour;
|
||||||
}
|
}
|
||||||
if (ct->mergeflags & M_MEN) {
|
if (ct->mergeflags & M_MEN && ct->typ == CURSETYP_UNIT) {
|
||||||
switch (ct->typ) {
|
c->data.i += men;
|
||||||
case CURSETYP_UNIT:
|
|
||||||
{
|
|
||||||
c->data.i += men;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
set_curseingmagician(magician, *ap, ct);
|
set_curseingmagician(magician, *ap, ct);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <kernel/region.h>
|
#include <kernel/region.h>
|
||||||
#include <kernel/unit.h>
|
#include <kernel/unit.h>
|
||||||
#include <kernel/config.h>
|
#include <kernel/config.h>
|
||||||
|
#include <util/goodies.h>
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
#include <util/password.h>
|
#include <util/password.h>
|
||||||
|
|
||||||
|
@ -223,6 +224,21 @@ static void test_valid_race(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_set_email(CuTest *tc) {
|
||||||
|
char * email = NULL;
|
||||||
|
test_setup();
|
||||||
|
CuAssertIntEquals(tc, 0, set_email(&email, "enno@eressea.de"));
|
||||||
|
CuAssertStrEquals(tc, "enno@eressea.de", email);
|
||||||
|
CuAssertIntEquals(tc, 0, set_email(&email, "bugs@eressea.de"));
|
||||||
|
CuAssertStrEquals(tc, "bugs@eressea.de", email);
|
||||||
|
CuAssertIntEquals(tc, -1, set_email(&email, "bad@@eressea.de"));
|
||||||
|
CuAssertIntEquals(tc, -1, set_email(&email, "eressea.de"));
|
||||||
|
CuAssertIntEquals(tc, -1, set_email(&email, "eressea@"));
|
||||||
|
CuAssertStrEquals(tc, "bugs@eressea.de", email);
|
||||||
|
free(email);
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
CuSuite *get_faction_suite(void)
|
CuSuite *get_faction_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
|
@ -237,5 +253,6 @@ CuSuite *get_faction_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_set_origin_bug);
|
SUITE_ADD_TEST(suite, test_set_origin_bug);
|
||||||
SUITE_ADD_TEST(suite, test_check_passwd);
|
SUITE_ADD_TEST(suite, test_check_passwd);
|
||||||
SUITE_ADD_TEST(suite, test_valid_race);
|
SUITE_ADD_TEST(suite, test_valid_race);
|
||||||
|
SUITE_ADD_TEST(suite, test_set_email);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,6 +161,8 @@ newfaction *read_newfactions(const char *filename)
|
||||||
break;
|
break;
|
||||||
if (email[0] == '\0')
|
if (email[0] == '\0')
|
||||||
break;
|
break;
|
||||||
|
if (email[0] == '#')
|
||||||
|
break;
|
||||||
if (password[0] == '\0') {
|
if (password[0] == '\0') {
|
||||||
size_t sz;
|
size_t sz;
|
||||||
sz = strlcpy(password, itoa36(rng_int()), sizeof(password));
|
sz = strlcpy(password, itoa36(rng_int()), sizeof(password));
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <kernel/unit.h>
|
#include <kernel/unit.h>
|
||||||
|
|
||||||
/* util includes */
|
/* util includes */
|
||||||
|
#include <util/log.h>
|
||||||
#include <util/nrmessage.h>
|
#include <util/nrmessage.h>
|
||||||
#include <util/message.h>
|
#include <util/message.h>
|
||||||
#include <util/functions.h>
|
#include <util/functions.h>
|
||||||
|
@ -33,10 +34,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
|
||||||
/* CurseInfo mit Spezialabfragen
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* godcursezone
|
* godcursezone
|
||||||
*/
|
*/
|
||||||
|
@ -206,6 +203,22 @@ static struct curse_type ct_blessedharvest = {
|
||||||
cinfo_simple
|
cinfo_simple
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int harvest_effect(const struct region *r) {
|
||||||
|
if (r->attribs) {
|
||||||
|
curse *c = get_curse(r->attribs, &ct_blessedharvest);
|
||||||
|
if (c) {
|
||||||
|
int happy = curse_geteffect_int(c);
|
||||||
|
if (happy != 1) {
|
||||||
|
/* https://bugs.eressea.de/view.php?id=2353 detect and fix bad harvest */
|
||||||
|
log_error("blessedharvest curse %d has effect=%d, duration=%d", c->no, happy, c->duration);
|
||||||
|
c->effect = 1.0;
|
||||||
|
}
|
||||||
|
return happy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static struct curse_type ct_drought = {
|
static struct curse_type ct_drought = {
|
||||||
"drought",
|
"drought",
|
||||||
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
|
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct curse;
|
struct region;
|
||||||
struct locale;
|
|
||||||
|
|
||||||
extern void register_regioncurse(void);
|
int harvest_effect(const struct region *r);
|
||||||
|
void register_regioncurse(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -483,7 +483,7 @@ int teach_cmd(unit * teacher, struct order *ord)
|
||||||
free_order(new_order); /* parse_order & set_order have each increased the refcount */
|
free_order(new_order); /* parse_order & set_order have each increased the refcount */
|
||||||
}
|
}
|
||||||
if (academy && sk_academy!=NOSKILL) {
|
if (academy && sk_academy!=NOSKILL) {
|
||||||
assert(academy % STUDYDAYS == 0);
|
/* assert(academy % STUDYDAYS == 0); bug 2355: why? */
|
||||||
academy_teaching_bonus(teacher, sk_academy, academy);
|
academy_teaching_bonus(teacher, sk_academy, academy);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -82,12 +82,18 @@ static int spc_email_isvalid(const char *address)
|
||||||
if (strchr(rfc822_specials, *c))
|
if (strchr(rfc822_specials, *c))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (*c!='@') {
|
||||||
|
/* no @ symbol */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
domain = ++c;
|
||||||
|
if (!*c) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (c == address || *(c - 1) == '.')
|
if (c == address || *(c - 1) == '.')
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* next we validate the domain portion (name@domain) */
|
/* next we validate the domain portion (name@domain) */
|
||||||
if (!*(domain = ++c))
|
|
||||||
return 0;
|
|
||||||
do {
|
do {
|
||||||
if (*c == '.') {
|
if (*c == '.') {
|
||||||
if (c == domain || *(c - 1) == '.')
|
if (c == domain || *(c - 1) == '.')
|
||||||
|
|
Loading…
Reference in New Issue