Better logging for invalid email addresses (incl. faction no)

This commit is contained in:
Enno Rehling 2004-08-28 23:06:15 +00:00
parent cd021ea812
commit f06e9e8bef
7 changed files with 30 additions and 22 deletions

View File

@ -2056,7 +2056,7 @@ email_cmd(unit * u, struct order * ord)
} else {
faction * f = u->faction;
if (set_email(&f->email, s)!=0) {
log_error(("Invalid email address: %s\n", s));
log_error(("Invalid email address for faction %s: %s\n", itoa36(f->no), s));
ADDMSG(&f->msgs, msg_message("changemail_invalid", "value",
gc_add(strdup(s))));
} else {
@ -2446,7 +2446,7 @@ reshow(unit * u, struct order * ord, const char * s, param_t p)
#ifdef HEROES
static int
promote_cmd(unit * u, struct order * ord)
promotion_cmd(unit * u, struct order * ord)
{
int money, people;
@ -2471,7 +2471,7 @@ promote_cmd(unit * u, struct order * ord)
use_all(u, i_silver->rtype, people);
fset(u, UFL_HERO);
ADDMSG(&u->faction->msgs, msg_message("hero_promotion", "unit cost",
u, money));
u, people));
return 0;
}
#endif
@ -3830,7 +3830,7 @@ processorders (void)
#ifdef HEROES
puts(" - Heldenbeförderung");
parse(K_PROMOTION, promote_cmd, false);
parse(K_PROMOTION, promotion_cmd, false);
#endif
puts(" - Neue Nummern");

View File

@ -99,7 +99,7 @@ addfaction(const char *email, const char * password,
assert(frace != new_race[RC_ORC]);
if (set_email(&f->email, email)!=0) {
log_error(("Invalid email address: %s\n", email));
log_error(("Invalid email address for faction %s: %s\n", itoa36(f->no), email));
}
if (password) {

View File

@ -1524,7 +1524,7 @@ readfaction(FILE * F)
rds(F, &f->banner);
rds(F, &email);
if (set_email(&f->email, email)!=0) {
log_error(("Invalid email address: %s\n", email));
log_error(("Invalid email address for faction %s: %s\n", itoa36(f->no), email));
set_email(&f->email, "");
}
rds(F, &f->passw);

View File

@ -630,7 +630,7 @@ gm_addquest(const char * email, const char * name, int radius, unsigned int flag
f->override = strdup(itoa36(rand()));
f->override = strdup(itoa36(rand()));
if (set_email(&f->email, email)!=0) {
log_error(("Invalid email address: %s\n", email));
log_error(("Invalid email address for faction %s: %s\n", itoa36(f->no), email));
}
f->name = strdup("Questenpartei");
f->race = new_race[RC_TEMPLATE];
@ -733,7 +733,7 @@ gm_addfaction(const char * email, plane * p, region * r)
f->banner = strdup("Questenpartei");
f->passw = strdup(itoa36(rand()));
if (set_email(&f->email, email)!=0) {
log_error(("Invalid email address: %s\n", email));
log_error(("Invalid email address for faction %s: %s\n", itoa36(f->no), email));
}
f->name = strdup("Questenpartei");
f->race = new_race[RC_TEMPLATE];

View File

@ -258,7 +258,7 @@ readshortpwds()
if (f!=NULL) {
shortpwd * pwd = (shortpwd*)malloc(sizeof(shortpwd));
if (set_email(&pwd->email, email)!=0) {
log_error(("Invalid email address: %s\n", email));
log_error(("Invalid email address faction %s: %s\n", faction, email));
}
pwd->pwd = strdup(passwd);
pwd->used = false;

View File

@ -631,6 +631,16 @@ typedef struct lostdata {
int ship;
} lostdata;
static void
my_lua_error(lua_State * L)
{
const char* error = lua_tostring(L, -1);
log_error((error));
lua_pop(L, 1);
std::terminate();
}
int
main(int argc, char *argv[])
{
@ -669,23 +679,21 @@ main(int argc, char *argv[])
// run the main script
if (luafile==NULL) lua_console(luaState);
else {
if (script_path) sprintf(buf, "%s/%s", script_path, luafile);
else strcpy(buf, luafile);
#ifdef LUABIND_NO_EXCEPTIONS
luabind::set_error_callback(my_lua_error);
#else
try {
if (script_path) {
sprintf(buf, "%s/%s", script_path, luafile);
#endif
lua_dofile(luaState, buf);
}
else lua_dofile(luaState, luafile);
#ifndef LUABIND_NO_EXCEPTIONS
}
catch (luabind::error& e) {
lua_State* L = e.state();
const char* error = lua_tostring(L, -1);
log_error((error));
lua_pop(L, 1);
std::terminate();
// L will now point to the destructed
// lua state and be invalid
/* ... */
my_lua_error(L);
}
#endif
}
#ifdef CLEANUP_CODE
game_done();

View File

@ -258,7 +258,7 @@ read_newfactions(const char * filename)
if (nf) continue;
nf = calloc(sizeof(newfaction), 1);
if (set_email(&nf->email, email)!=0) {
log_error(("Invalid email address: %s\n", email));
log_error(("Invalid email address for faction %s: %s\n", itoa36(nf->no), email));
}
nf->password = strdup(password);
nf->race = rc_find(race);