some logging and error reporting

This commit is contained in:
Enno Rehling 2010-02-21 20:47:09 +00:00
parent da1bdfb088
commit e25a2e3884
5 changed files with 12 additions and 30 deletions

View File

@ -30,6 +30,7 @@ int main(int argc, char ** argv)
{
int err;
log_open("eressea.log");
load_config("eressea.ini");
err = eressea_init();

View File

@ -193,10 +193,10 @@ void eressea_done(void)
static int
log_lua_error(lua_State * L)
{
static int s_abort_on_errors = 0;
static int s_abort_on_errors = 1;
const char* error = lua_tostring(L, -1);
log_error(("A LUA error occurred: %s\n", error));
log_error(("LUA call failed.\n%s\n", error));
lua_pop(L, 1);
if (s_abort_on_errors) {
@ -207,22 +207,27 @@ log_lua_error(lua_State * L)
int eressea_run(const char * luafile, const char * entry_point)
{
int err;
lua_State * L = (lua_State *)global.vm_state;
/* run the main script */
if (luafile) {
lua_getglobal(L, "dofile");
lua_pushstring(L, luafile);
if (lua_pcall(L, 1, 0, 0) != 0) {
err = lua_pcall(L, 1, 0, 0);
if (err != 0) {
log_lua_error(L);
return err;
}
}
if (entry_point) {
lua_getglobal(L, entry_point);
if (lua_pcall(L, 0, 1, 0) != 0) {
err = lua_pcall(L, 0, 1, 0);
if (err != 0) {
log_lua_error(L);
return err;
}
} else {
lua_console(L);
err = lua_console(L);
}
return 0;
return err;
}

View File

@ -2226,7 +2226,6 @@ kernel_done(void)
* calling it is optional, e.g. a release server will most likely not do it.
*/
translation_done();
skill_done();
gc_done();
sql_done();
}
@ -3163,7 +3162,6 @@ void
kernel_init(void)
{
char zBuffer[MAX_PATH];
skill_init();
attrib_init();
translation_init();

View File

@ -253,26 +253,6 @@ rc_skillmod(const struct race * rc, const region *r, skill_t sk)
return mods;
}
void
skill_init(void)
{
}
void
skill_done(void)
{
#ifdef FASTER_SKILLMOD
int i;
for (i = 0;i!=RCMODMAXHASH;++i) {
while (modhash[i]) {
struct skillmods * mods = modhash[i];
modhash[i] = mods->next;
free(mods);
}
}
#endif
}
int
level_days(int level)
{

View File

@ -42,8 +42,6 @@ typedef struct skillmod_data {
extern struct attrib_type at_skillmod;
extern int rc_skillmod(const struct race * rc, const struct region *r, skill_t sk);
extern int skillmod(const struct attrib * a, const struct unit * u, const struct region * r, skill_t sk, int value, int flags);
extern void skill_init(void);
extern void skill_done(void);
extern struct attrib * make_skillmod(skill_t sk, unsigned int flags, skillmod_fun special, double multiplier, int bonus);
extern const char * skillname(skill_t, const struct locale *);