forked from github/server
Merge remote-tracking branch 'upstream/develop' into develop
This commit is contained in:
commit
54b016a735
|
@ -1,5 +1,5 @@
|
|||
[game]
|
||||
email = eressea-server@kn-bremen.de
|
||||
email = eressea-server@example.com
|
||||
sender = Eressea Server
|
||||
name = Eressea
|
||||
report = reports
|
||||
|
|
|
@ -16,7 +16,7 @@ then
|
|||
shift
|
||||
fi
|
||||
|
||||
if [ "$1" == "-Lde" ]
|
||||
if [ "$1" == "-Len" ]
|
||||
then
|
||||
TEMPLATE=report-mail.en.txt
|
||||
shift
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
## this script takes a backup of a turn.
|
||||
## usage: backup.sh <turn>
|
||||
|
||||
if [ -z $ERESSEA ]; then
|
||||
echo "You have to define the \$ERESSEA environment variable to run $0"
|
||||
|
|
|
@ -10,7 +10,7 @@ done
|
|||
if [ "$FORCE" != "yes" ] ; then
|
||||
BRANCH=$(git status -s -b | head -1 | cut -d\ -f 2 | sed 's/\..*//')
|
||||
if [ "$BRANCH" != "master" ] ; then
|
||||
echo "you should only install stable versions from the master branch"
|
||||
echo "You should only install stable versions from the master branch. Use -f to override."
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
|
50
s/setup
50
s/setup
|
@ -11,9 +11,9 @@ done
|
|||
ERESSEA=$(dirname $ROOT)
|
||||
|
||||
function abort() {
|
||||
echo $1
|
||||
[ -z $2 ] && exit -1
|
||||
exit $2 # otherwise
|
||||
echo $1
|
||||
[ -z $2 ] && exit -1
|
||||
exit $2 # otherwise
|
||||
}
|
||||
|
||||
function usage() {
|
||||
|
@ -63,34 +63,36 @@ if [ -d $dir ] ; then
|
|||
[ $force -eq 1 ] || abort "$dir directory exists. Use -f to force"
|
||||
fi
|
||||
mkdir -p $dir
|
||||
cd $dir || abort "could not chdir to game-$game"
|
||||
cd $dir || abort "could not chdir to $dir"
|
||||
mkdir -p data reports
|
||||
|
||||
function ini_sec() {
|
||||
if [ $edit -eq 1 ]; then
|
||||
$INIFILE eressea.ini add $1
|
||||
else
|
||||
echo "[$1]" >> eressea.ini
|
||||
fi
|
||||
if [ $edit -eq 1 ]; then
|
||||
$INIFILE eressea.ini add $1
|
||||
else
|
||||
echo "[$1]" >> eressea.ini
|
||||
fi
|
||||
}
|
||||
|
||||
function ini_add() {
|
||||
if [ $edit -eq 1 ]; then
|
||||
$INIFILE eressea.ini add $1:$2 $3
|
||||
else
|
||||
echo "$2 = $3" >> eressea.ini
|
||||
fi
|
||||
if [ $edit -eq 1 ]; then
|
||||
$INIFILE eressea.ini add $1:$2 $3
|
||||
else
|
||||
echo "$2 = $3" >> eressea.ini
|
||||
fi
|
||||
}
|
||||
|
||||
function ini_start() {
|
||||
if [ -e eressea.ini ]; then
|
||||
if [ ! -e $INIFILE ] && [ $edit -eq 1 ]; then
|
||||
abort "missing editor for eressea.ini. use -n to create new file."
|
||||
fi
|
||||
rm -f eressea.ini
|
||||
edit=0
|
||||
else
|
||||
edit=0
|
||||
fi
|
||||
touch eressea.ini
|
||||
if [ -e eressea.ini ]; then
|
||||
if [ ! -e $INIFILE ] && [ $edit -eq 1 ]; then
|
||||
abort "missing editor for eressea.ini. use -n to create new file."
|
||||
fi
|
||||
rm -f eressea.ini
|
||||
edit=0
|
||||
else
|
||||
edit=0
|
||||
fi
|
||||
touch eressea.ini
|
||||
}
|
||||
|
||||
ini_start
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
4 lelong 0x00000002
|
||||
>0 leshort x eressea data version %d
|
||||
|
|
@ -1053,8 +1053,8 @@ static void cr_find_address(FILE * F, const faction * uf, selist * addresses)
|
|||
if (uf != f) {
|
||||
fprintf(F, "PARTEI %d\n", f->no);
|
||||
fprintf(F, "\"%s\";Parteiname\n", f->name);
|
||||
if (f->email)
|
||||
fprintf(F, "\"%s\";email\n", f->email);
|
||||
if (strcmp(faction_getemail(f), "") != 0)
|
||||
fprintf(F, "\"%s\";email\n", faction_getemail(f));
|
||||
if (f->banner)
|
||||
fprintf(F, "\"%s\";banner\n", f->banner);
|
||||
fprintf(F, "\"%s\";locale\n", locale_name(f->locale));
|
||||
|
@ -1602,7 +1602,7 @@ report_computer(const char *filename, report_context * ctx, const char *bom)
|
|||
}
|
||||
|
||||
fprintf(F, "\"%s\";Parteiname\n", f->name);
|
||||
fprintf(F, "\"%s\";email\n", f->email);
|
||||
fprintf(F, "\"%s\";email\n", faction_getemail(f));
|
||||
if (f->banner)
|
||||
fprintf(F, "\"%s\";banner\n", f->banner);
|
||||
print_items(F, f->items, f->locale);
|
||||
|
|
|
@ -859,7 +859,7 @@ static void select_regions(state * st, int selectmode)
|
|||
static void loaddata(state *st) {
|
||||
char datafile[MAX_PATH];
|
||||
|
||||
askstring(st->wnd_status->handle, "save as:", datafile, sizeof(datafile));
|
||||
askstring(st->wnd_status->handle, "load from:", datafile, sizeof(datafile));
|
||||
if (strlen(datafile) > 0) {
|
||||
readgame(datafile);
|
||||
st->modified = 0;
|
||||
|
|
|
@ -102,7 +102,7 @@ int json_export(stream * out, int flags) {
|
|||
cJSON *data;
|
||||
cJSON_AddItemToObject(json, itoa36(f->no), data = cJSON_CreateObject());
|
||||
cJSON_AddStringToObject(data, "name", f->name);
|
||||
cJSON_AddStringToObject(data, "email", f->email);
|
||||
cJSON_AddStringToObject(data, "email", faction_getemail(f));
|
||||
cJSON_AddNumberToObject(data, "score", (double)f->score);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -229,8 +229,11 @@ faction *addfaction(const char *email, const char *password,
|
|||
faction *f = calloc(sizeof(faction), 1);
|
||||
char buf[128];
|
||||
|
||||
if (set_email(&f->email, email) != 0) {
|
||||
log_warning("Invalid email address for faction %s: %s\n", itoa36(f->no), email);
|
||||
if (check_email(email) == 0) {
|
||||
faction_setemail(f, email);
|
||||
} else {
|
||||
log_warning("Invalid email address for faction %s: %s\n", itoa36(f->no), email?email:"");
|
||||
faction_setemail(f, NULL);
|
||||
}
|
||||
|
||||
f->alliance_joindate = turn;
|
||||
|
@ -544,6 +547,8 @@ void faction_setemail(faction * self, const char *email)
|
|||
free(self->email);
|
||||
if (email)
|
||||
self->email = strdup(email);
|
||||
else
|
||||
self->email = NULL;
|
||||
}
|
||||
|
||||
const char *faction_getbanner(const faction * self)
|
||||
|
@ -797,7 +802,7 @@ int writepasswd(void)
|
|||
|
||||
for (f = factions; f; f = f->next) {
|
||||
fprintf(F, "%s:%s:%s:%d\n",
|
||||
itoa36(f->no), f->email, f->_password, f->subscription);
|
||||
itoa36(f->no), faction_getemail(f), f->_password, f->subscription);
|
||||
}
|
||||
fclose(F);
|
||||
return 0;
|
||||
|
|
|
@ -225,17 +225,28 @@ static void test_valid_race(CuTest *tc) {
|
|||
}
|
||||
|
||||
static void test_set_email(CuTest *tc) {
|
||||
char * email = NULL;
|
||||
faction *f;
|
||||
char email[10];
|
||||
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);
|
||||
CuAssertIntEquals(tc, 0, check_email("enno@eressea.de"));
|
||||
CuAssertIntEquals(tc, 0, check_email("bugs@eressea.de"));
|
||||
CuAssertIntEquals(tc, -1, check_email("bad@@eressea.de"));
|
||||
CuAssertIntEquals(tc, -1, check_email("eressea.de"));
|
||||
CuAssertIntEquals(tc, -1, check_email("eressea@"));
|
||||
CuAssertIntEquals(tc, -1, check_email(""));
|
||||
CuAssertIntEquals(tc, -1, check_email(NULL));
|
||||
f = test_create_faction(0);
|
||||
|
||||
sprintf(email, "enno");
|
||||
faction_setemail(f, email);
|
||||
email[0] = 0;
|
||||
CuAssertStrEquals(tc, "enno", f->email);
|
||||
CuAssertStrEquals(tc, "enno", faction_getemail(f));
|
||||
faction_setemail(f, "bugs@eressea.de");
|
||||
CuAssertStrEquals(tc, "bugs@eressea.de", f->email);
|
||||
faction_setemail(f, NULL);
|
||||
CuAssertPtrEquals(tc, 0, f->email);
|
||||
CuAssertStrEquals(tc, "", faction_getemail(f));
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
|
|
|
@ -1067,9 +1067,11 @@ faction *read_faction(gamedata * data)
|
|||
log_debug(" - Lese Partei %s (%s)", f->name, itoa36(f->no));
|
||||
|
||||
READ_STR(data->store, name, sizeof(name));
|
||||
if (set_email(&f->email, name) != 0) {
|
||||
log_warning("Invalid email address for faction %s: %s", itoa36(f->no), name);
|
||||
set_email(&f->email, "");
|
||||
if (check_email(name) == 0) {
|
||||
faction_setemail(f, name);
|
||||
} else {
|
||||
log_warning("Invalid email address for faction %s: %s", itoa36(f->no), name);
|
||||
faction_setemail(f, NULL);
|
||||
}
|
||||
|
||||
read_password(data, f);
|
||||
|
@ -1168,7 +1170,7 @@ void write_faction(gamedata *data, const faction * f)
|
|||
|
||||
WRITE_STR(data->store, f->name);
|
||||
WRITE_STR(data->store, f->banner);
|
||||
WRITE_STR(data->store, f->email);
|
||||
WRITE_STR(data->store, f->email?f->email:"");
|
||||
write_password(data, f);
|
||||
WRITE_TOK(data->store, locale_name(f->locale));
|
||||
WRITE_INT(data->store, f->lastorders);
|
||||
|
|
|
@ -2139,13 +2139,13 @@ int email_cmd(unit * u, struct order *ord)
|
|||
}
|
||||
else {
|
||||
faction *f = u->faction;
|
||||
if (set_email(&f->email, s) != 0) {
|
||||
if (check_email(s) == 0) {
|
||||
faction_setemail(f, s);
|
||||
ADDMSG(&f->msgs, msg_message("changemail", "value", faction_getemail(f)));
|
||||
} else {
|
||||
log_error("Invalid email address for faction %s: %s\n", itoa36(f->no), s);
|
||||
ADDMSG(&f->msgs, msg_message("changemail_invalid", "value", s));
|
||||
}
|
||||
else {
|
||||
ADDMSG(&f->msgs, msg_message("changemail", "value", f->email));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ newfaction *read_newfactions(const char *filename)
|
|||
sz += strlcat(password, itoa36(rng_int()), sizeof(password));
|
||||
}
|
||||
for (f = factions; f; f = f->next) {
|
||||
if (strcmp(f->email, email) == 0 && f->age < MINAGE_MULTI) {
|
||||
if (strcmp(faction_getemail(f), email) == 0 && f->age < MINAGE_MULTI) {
|
||||
log_warning("email %s already in use by %s", email, factionname(f));
|
||||
break;
|
||||
}
|
||||
|
@ -188,7 +188,9 @@ newfaction *read_newfactions(const char *filename)
|
|||
continue;
|
||||
}
|
||||
nf = calloc(sizeof(newfaction), 1);
|
||||
if (set_email(&nf->email, email) != 0) {
|
||||
if (check_email(email) == 0) {
|
||||
nf->email = strdup(email);
|
||||
} else {
|
||||
log_error("Invalid email address for subscription %s: %s\n", itoa36(subscription), email);
|
||||
free(nf);
|
||||
continue;
|
||||
|
@ -619,6 +621,7 @@ int autoseed(newfaction ** players, int nsize, int max_agediff)
|
|||
while (*nfp) {
|
||||
newfaction *nf = *nfp;
|
||||
if (strcmp(nextf->email, nf->email) == 0) {
|
||||
log_warning("Duplicate email %s\n", nf->email?nf->email:"");
|
||||
*nfp = nf->next;
|
||||
free_newfaction(nf);
|
||||
}
|
||||
|
|
|
@ -1140,7 +1140,7 @@ faction *get_or_create_monsters(void)
|
|||
if (!f) {
|
||||
const race *rc = rc_get_or_create("dragon");
|
||||
const char *email = config_get("monster.email");
|
||||
f = addfaction(email ? email : NULL, NULL, rc, default_locale, 0);
|
||||
f = addfaction(email, NULL, rc, default_locale, 0);
|
||||
renumber_faction(f, MONSTER_ID);
|
||||
faction_setname(f, "Monster");
|
||||
fset(f, FFL_NPC | FFL_NOIDLEOUT);
|
||||
|
|
21
src/report.c
21
src/report.c
|
@ -1753,7 +1753,7 @@ static void list_address(struct stream *out, const faction * uf, selist * seenfa
|
|||
char buf[8192];
|
||||
char label = '-';
|
||||
|
||||
sprintf(buf, "%s: %s; %s", factionname(f), f->email,
|
||||
sprintf(buf, "%s: %s; %s", factionname(f), faction_getemail(f),
|
||||
f->banner ? f->banner : "");
|
||||
if (uf == f)
|
||||
label = '*';
|
||||
|
@ -2078,7 +2078,7 @@ report_plaintext(const char *filename, report_context * ctx,
|
|||
newline(out);
|
||||
sprintf(buf, "%s, %s/%s (%s)", factionname(f),
|
||||
LOC(f->locale, rc_name_s(f->race, NAME_PLURAL)),
|
||||
LOC(f->locale, mkname("school", magic_school[f->magiegebiet])), f->email);
|
||||
LOC(f->locale, mkname("school", magic_school[f->magiegebiet])), faction_getemail(f));
|
||||
centre(out, buf, true);
|
||||
if (f_get_alliance(f)) {
|
||||
centre(out, alliancename(f->alliance), true);
|
||||
|
@ -2088,12 +2088,17 @@ report_plaintext(const char *filename, report_context * ctx,
|
|||
const char *email;
|
||||
const char *subject;
|
||||
email = config_get("game.email");
|
||||
subject = get_mailcmd(f->locale);
|
||||
m = msg_message("newbie_info_game", "email subject", email, subject);
|
||||
if (m) {
|
||||
nr_render(m, f->locale, buf, sizeof(buf), f);
|
||||
msg_release(m);
|
||||
centre(out, buf, true);
|
||||
if (!email)
|
||||
log_error("game.email not set");
|
||||
else {
|
||||
subject = get_mailcmd(f->locale);
|
||||
|
||||
m = msg_message("newbie_info_game", "email subject", email, subject);
|
||||
if (m) {
|
||||
nr_render(m, f->locale, buf, sizeof(buf), f);
|
||||
msg_release(m);
|
||||
centre(out, buf, true);
|
||||
}
|
||||
}
|
||||
if ((f->options & want(O_COMPUTER)) == 0) {
|
||||
const char *s;
|
||||
|
|
|
@ -1561,7 +1561,11 @@ static void write_script(FILE * F, const faction * f)
|
|||
report_type *rtype;
|
||||
char buf[1024];
|
||||
|
||||
fprintf(F, "faction=%s:email=%s:lang=%s", itoa36(f->no), f->email,
|
||||
if (check_email(faction_getemail(f)) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(F, "faction=%s:email=%s:lang=%s", itoa36(f->no), faction_getemail(f),
|
||||
locale_name(f->locale));
|
||||
if (f->options & (1 << O_BZIP2))
|
||||
fputs(":compression=bz2", F);
|
||||
|
|
|
@ -144,7 +144,8 @@ static bool db_faction_cb(void *el, void *arg) {
|
|||
struct cb_data *cb = (struct cb_data *)arg;
|
||||
const faction *f = cb->f;
|
||||
|
||||
if (f->no == df->no || strcmp(f->email, df->email) == 0 || strcmp(f->name, df->name) == 0) {
|
||||
/* FIXME comparing name and email is inaccurate ... */
|
||||
if (f->no == df->no || strcmp(faction_getemail(f), df->email?df->email:"") == 0 || strcmp(f->name, df->name) == 0) {
|
||||
cb->dbf = df;
|
||||
}
|
||||
if (f->subscription == df->uid) {
|
||||
|
@ -172,7 +173,7 @@ int db_update_factions(sqlite3 * db, bool force, int game_id) {
|
|||
log_warning("faction %s(%d) not found in database, but matches %d\n", itoa36(f->no), f->subscription, dbf->uid);
|
||||
f->subscription = dbf->uid;
|
||||
}
|
||||
update = (dbf->no != f->no) || (strcmp(f->email, dbf->email) != 0) || (strcmp(f->name, dbf->name) != 0);
|
||||
update = (dbf->no != f->no) || (strcmp(faction_getemail(f), dbf->email?dbf->email:"") != 0) || (strcmp(f->name, dbf->name) != 0);
|
||||
}
|
||||
else {
|
||||
f->subscription = insert_faction(db, game_id, f);
|
||||
|
|
|
@ -109,17 +109,13 @@ static int spc_email_isvalid(const char *address)
|
|||
return (count >= 1);
|
||||
}
|
||||
|
||||
int set_email(char **pemail, const char *newmail)
|
||||
int check_email(const char *newmail)
|
||||
{
|
||||
if (newmail && *newmail) {
|
||||
if (spc_email_isvalid(newmail) <= 0)
|
||||
return -1;
|
||||
}
|
||||
if (*pemail)
|
||||
free(*pemail);
|
||||
*pemail = 0;
|
||||
if (newmail) {
|
||||
*pemail = strdup(newmail);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
int set_email(char **pemail, const char *newmail);
|
||||
int check_email(const char *newmail);
|
||||
|
||||
int *intlist_init(void);
|
||||
int *intlist_add(int *i_p, int i);
|
||||
|
|
Loading…
Reference in New Issue