try to fix some binding errors

This commit is contained in:
Enno Rehling 2021-03-14 19:09:24 +01:00
parent 56141ee7a1
commit 7cab158af8
4 changed files with 52 additions and 29 deletions

View File

@ -51,6 +51,7 @@ int eressea_read_orders(const char * filename) {
}
int eressea_export_json(const char * filename, int flags) {
if (filename) {
FILE *F = fopen(filename, "w");
if (F) {
stream out = { 0 };
@ -61,6 +62,7 @@ int eressea_export_json(const char * filename, int flags) {
return err;
}
perror(filename);
}
return -1;
}

View File

@ -125,6 +125,16 @@ static int tolua_ship_set_display(lua_State * L)
static int tolua_ship_get_units(lua_State * L)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(L,1,"ship",0,&tolua_err) ||
!tolua_isuserdata(L,2,0,&tolua_err) ||
!tolua_isnoobj(L,3,&tolua_err)
) goto tolua_lerror;
else
#endif
{
ship *sh = (ship *)tolua_tousertype(L, 1, NULL);
unit **unit_ptr = (unit **)lua_newuserdata(L, sizeof(unit *));
unit *u = sh->region->units;
@ -138,6 +148,12 @@ static int tolua_ship_get_units(lua_State * L)
lua_pushcclosure(L, tolua_unitlist_nexts, 1);
return 1;
}
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(L, "#ferror in function 'export'.", &tolua_err);
return 0;
#endif
}
static int tolua_ship_create(lua_State * L)

View File

@ -760,8 +760,9 @@ static int tolua_unit_clear_attribs(lua_State *L) {
}
static int tolua_unit_has_attrib(lua_State *L) {
unit *u = (unit *)tolua_tousertype(L, 1, 0);
const char *name = tolua_tostring(L, 2, 0);
unit *u = (unit *)tolua_tousertype(L, 1, NULL);
const char *name = tolua_tostring(L, 2, NULL);
if (u && name) {
attrib * a = u->attribs;
while (a) {
if (strcmp(a->type->name, name) == 0) {
@ -771,6 +772,8 @@ static int tolua_unit_has_attrib(lua_State *L) {
}
lua_pushboolean(L, a != NULL);
return 1;
}
return 0;
}
static int tolua_unit_get_key(lua_State * L)

View File

@ -293,7 +293,8 @@ static int tolua_create_curse(lua_State * L)
ap = &target->attribs;
}
if (ap) {
const char *cname = tolua_tostring(L, 3, 0);
const char *cname = tolua_tostring(L, 3, NULL);
if (cname) {
const curse_type *ctype = ct_find(cname);
if (ctype) {
float vigour = (float)tolua_tonumber(L, 4, 0);
@ -307,6 +308,7 @@ static int tolua_create_curse(lua_State * L)
}
}
}
}
tolua_pushboolean(L, false);
return 1;
}