fix CRLF massacre

This commit is contained in:
Enno Rehling 2011-03-07 08:35:23 +01:00
parent 610c6799ea
commit 791e4cd673

View file

@ -66,15 +66,15 @@ without prior permission by the authors of Eressea.
#include <time.h>
#include <assert.h>
int log_lua_error(lua_State * L)
int log_lua_error(lua_State * L)
{
const char *error = lua_tostring(L, -1);
log_error(("LUA call failed.\n%s\n", error));
lua_pop(L, 1);
return 1;
}
}
int tolua_orderlist_next(lua_State * L)
int tolua_orderlist_next(lua_State * L)
{
order ** order_ptr = (order **) lua_touserdata(L, lua_upvalueindex(1));
order * ord = *order_ptr;
@ -88,9 +88,9 @@ without prior permission by the authors of Eressea.
else
return 0; /* no more values to return */
}
}
static int tolua_quicklist_iter(lua_State * L)
static int tolua_quicklist_iter(lua_State * L)
{
quicklist ** qlp = (quicklist **) lua_touserdata(L, lua_upvalueindex(1));
quicklist * ql = *qlp;
@ -107,9 +107,9 @@ without prior permission by the authors of Eressea.
else
return 0; /* no more values to return */
}
}
int tolua_quicklist_push(struct lua_State *L, const char *list_type,
int tolua_quicklist_push(struct lua_State *L, const char *list_type,
const char *elem_type, struct quicklist *list)
{
if (list) {
@ -125,9 +125,9 @@ without prior permission by the authors of Eressea.
lua_pushnil(L);
}
return 1;
}
}
int tolua_itemlist_next(lua_State * L)
int tolua_itemlist_next(lua_State * L)
{
item ** item_ptr = (item **) lua_touserdata(L, lua_upvalueindex(1));
item * itm = *item_ptr;
@ -139,9 +139,9 @@ without prior permission by the authors of Eressea.
else
return 0; /* no more values to return */
}
}
static int tolua_autoseed(lua_State * L)
static int tolua_autoseed(lua_State * L)
{
const char *filename = tolua_tostring(L, 1, 0);
int new_island = tolua_toboolean(L, 2, 0);
@ -158,18 +158,18 @@ without prior permission by the authors of Eressea.
}
}
return 0;
}
}
static int tolua_getkey(lua_State * L)
static int tolua_getkey(lua_State * L)
{
const char *name = tolua_tostring(L, 1, 0);
int flag = atoi36(name);
attrib * a = find_key(global.attribs, flag);
lua_pushboolean(L, a != NULL);
return 1;
}
}
static int tolua_translate(lua_State * L)
static int tolua_translate(lua_State * L)
{
const char *str = tolua_tostring(L, 1, 0);
const char *lang = tolua_tostring(L, 2, 0);
@ -180,9 +180,9 @@ without prior permission by the authors of Eressea.
return 1;
}
return 0;
}
}
static int tolua_setkey(lua_State * L)
static int tolua_setkey(lua_State * L)
{
const char *name = tolua_tostring(L, 1, 0);
int value = tolua_toboolean(L, 2, 0);
@ -194,23 +194,23 @@ without prior permission by the authors of Eressea.
a_remove(&global.attribs, a);
}
return 0;
}
}
static int tolua_rng_int(lua_State * L)
static int tolua_rng_int(lua_State * L)
{
lua_pushnumber(L, (lua_Number) rng_int());
return 1;
}
}
static int tolua_read_orders(lua_State * L)
static int tolua_read_orders(lua_State * L)
{
const char *filename = tolua_tostring(L, 1, 0);
int result = readorders(filename);
lua_pushnumber(L, (lua_Number) result);
return 1;
}
}
static int tolua_message_unit(lua_State * L)
static int tolua_message_unit(lua_State * L)
{
unit * sender = (unit *) tolua_tousertype(L, 1, 0);
unit * target = (unit *) tolua_tousertype(L, 2, 0);
@ -221,9 +221,9 @@ without prior permission by the authors of Eressea.
tolua_error(L, TOLUA_CAST "sender is nil", NULL);
deliverMail(target->faction, sender->region, sender, str, target);
return 0;
}
}
static int tolua_message_faction(lua_State * L)
static int tolua_message_faction(lua_State * L)
{
unit * sender = (unit *) tolua_tousertype(L, 1, 0);
faction * target = (faction *) tolua_tousertype(L, 2, 0);
@ -234,9 +234,9 @@ without prior permission by the authors of Eressea.
tolua_error(L, TOLUA_CAST "sender is nil", NULL);
deliverMail(target, sender->region, sender, str, NULL);
return 0;
}
}
static int tolua_message_region(lua_State * L)
static int tolua_message_region(lua_State * L)
{
unit * sender = (unit *) tolua_tousertype(L, 1, 0);
const char *str = tolua_tostring(L, 2, 0);
@ -245,48 +245,48 @@ without prior permission by the authors of Eressea.
ADDMSG(&sender->region->msgs, msg_message("mail_result", "unit message",
sender, str));
return 0;
}
}
static int tolua_update_guards(lua_State * L)
static int tolua_update_guards(lua_State * L)
{
update_guards();
return 0;
}
}
static int tolua_set_turn(lua_State * L)
static int tolua_set_turn(lua_State * L)
{
turn = (int)tolua_tonumber(L, 1, 0);
return 0;
}
}
static int tolua_get_turn(lua_State * L)
static int tolua_get_turn(lua_State * L)
{
tolua_pushnumber(L, (lua_Number) turn);
return 1;
}
}
static int tolua_atoi36(lua_State * L)
static int tolua_atoi36(lua_State * L)
{
const char *s = tolua_tostring(L, 1, 0);
tolua_pushnumber(L, (lua_Number) atoi36(s));
return 1;
}
}
static int tolua_itoa36(lua_State * L)
static int tolua_itoa36(lua_State * L)
{
int i = (int)tolua_tonumber(L, 1, 0);
tolua_pushstring(L, itoa36(i));
return 1;
}
}
static int tolua_dice_rand(lua_State * L)
static int tolua_dice_rand(lua_State * L)
{
const char *s = tolua_tostring(L, 1, 0);
tolua_pushnumber(L, dice_rand(s));
return 1;
}
}
static int tolua_addequipment(lua_State * L)
static int tolua_addequipment(lua_State * L)
{
const char *eqname = tolua_tostring(L, 1, 0);
const char *iname = tolua_tostring(L, 2, 0);
@ -301,18 +301,18 @@ without prior permission by the authors of Eressea.
}
lua_pushnumber(L, (lua_Number) result);
return 1;
}
}
static int tolua_get_season(lua_State * L)
static int tolua_get_season(lua_State * L)
{
int turnno = (int)tolua_tonumber(L, 1, 0);
gamedate gd;
get_gamedate(turnno, &gd);
tolua_pushstring(L, seasonnames[gd.season]);
return 1;
}
}
static int tolua_create_curse(lua_State * L)
static int tolua_create_curse(lua_State * L)
{
unit * u = (unit *) tolua_tousertype(L, 1, 0);
tolua_Error tolua_err;
@ -351,9 +351,9 @@ without prior permission by the authors of Eressea.
}
tolua_pushboolean(L, false);
return 1;
}
}
static int tolua_learn_skill(lua_State * L)
static int tolua_learn_skill(lua_State * L)
{
unit * u = (unit *) tolua_tousertype(L, 1, 0);
const char *skname = tolua_tostring(L, 2, 0);
@ -363,36 +363,36 @@ without prior permission by the authors of Eressea.
learn_skill(u, sk, chances);
}
return 0;
}
}
static int tolua_update_scores(lua_State * L)
static int tolua_update_scores(lua_State * L)
{
score();
return 0;
}
}
static int tolua_update_owners(lua_State * L)
static int tolua_update_owners(lua_State * L)
{
region * r;
for (r = regions; r; r = r->next) {
update_owners(r);
}
return 0;
}
}
static int tolua_update_subscriptions(lua_State * L)
static int tolua_update_subscriptions(lua_State * L)
{
update_subscriptions();
return 0;
}
}
static int tolua_remove_empty_units(lua_State * L)
static int tolua_remove_empty_units(lua_State * L)
{
remove_empty_units();
return 0;
}
}
static int tolua_get_nmrs(lua_State * L)
static int tolua_get_nmrs(lua_State * L)
{
int result = -1;
int n = (int)tolua_tonumber(L, 1, 0);
@ -404,17 +404,17 @@ without prior permission by the authors of Eressea.
}
tolua_pushnumber(L, (lua_Number) result);
return 1;
}
}
static int tolua_equipunit(lua_State * L)
static int tolua_equipunit(lua_State * L)
{
unit * u = (unit *) tolua_tousertype(L, 1, 0);
const char *eqname = tolua_tostring(L, 2, 0);
equip_unit(u, get_equipment(eqname));
return 0;
}
}
static int tolua_equipment_setitem(lua_State * L)
static int tolua_equipment_setitem(lua_State * L)
{
int result = -1;
const char *eqname = tolua_tostring(L, 1, 0);
@ -429,7 +429,7 @@ without prior permission by the authors of Eressea.
}
tolua_pushnumber(L, (lua_Number) result);
return 1;
}
}
#ifdef TODO_FOSS
@ -442,7 +442,7 @@ static int tolua_levitate_ship(lua_State * L)
int cno = levitate_ship(sh, mage, power, duration);
tolua_pushnumber(L, (lua_Number) cno);
return 1;
}
}
#endif /* */
@ -451,34 +451,34 @@ static int tolua_spawn_braineaters(lua_State * L)
float chance = (float)tolua_tonumber(L, 1, 0);
spawn_braineaters(chance);
return 0;
}
}
static int tolua_init_reports(lua_State * L)
static int tolua_init_reports(lua_State * L)
{
int result = init_reports();
tolua_pushnumber(L, (lua_Number) result);
return 1;
}
}
static int tolua_write_report(lua_State * L)
static int tolua_write_report(lua_State * L)
{
faction * f = (faction *) tolua_tousertype(L, 1, 0);
time_t ltime = time(0);
int result = write_reports(f, ltime);
tolua_pushnumber(L, (lua_Number) result);
return 1;
}
}
static int tolua_write_reports(lua_State * L)
static int tolua_write_reports(lua_State * L)
{
int result;
init_reports();
result = reports();
tolua_pushnumber(L, (lua_Number) result);
return 1;
}
}
static void reset_game(void)
static void reset_game(void)
{
region * r;
faction * f;
@ -507,31 +507,31 @@ static int tolua_spawn_braineaters(lua_State * L)
for (f = factions; f; f = f->next) {
f->flags &= FFL_SAVEMASK;
}
}
}
static int tolua_process_orders(lua_State * L)
static int tolua_process_orders(lua_State * L)
{
++turn;
reset_game();
processorders();
return 0;
}
}
static int tolua_write_passwords(lua_State * L)
static int tolua_write_passwords(lua_State * L)
{
int result = writepasswd();
lua_pushnumber(L, (lua_Number) result);
return 0;
}
}
static struct summary *sum_begin = 0;
static int tolua_init_summary(lua_State * L)
static struct summary *sum_begin = 0;
static int tolua_init_summary(lua_State * L)
{
sum_begin = make_summary();
return 0;
}
}
static int tolua_write_summary(lua_State * L)
static int tolua_write_summary(lua_State * L)
{
if (sum_begin) {
struct summary *sum_end = make_summary();
@ -540,24 +540,24 @@ static int tolua_spawn_braineaters(lua_State * L)
return 0;
}
return 0;
}
}
static int tolua_free_game(lua_State * L)
static int tolua_free_game(lua_State * L)
{
free_gamedata();
return 0;
}
}
static int tolua_write_map(lua_State * L)
static int tolua_write_map(lua_State * L)
{
const char *filename = tolua_tostring(L, 1, 0);
if (filename) {
crwritemap(filename);
}
return 0;
}
}
static int tolua_write_game(lua_State * L)
static int tolua_write_game(lua_State * L)
{
const char *filename = tolua_tostring(L, 1, 0);
const char *mode = tolua_tostring(L, 2, 0);
@ -568,9 +568,9 @@ static int tolua_spawn_braineaters(lua_State * L)
result = writegame(filename, m);
tolua_pushnumber(L, (lua_Number) result);
return 1;
}
}
static int tolua_read_game(lua_State * L)
static int tolua_read_game(lua_State * L)
{
const char *filename = tolua_tostring(L, 1, 0);
const char *mode = tolua_tostring(L, 2, 0);
@ -580,24 +580,24 @@ static int tolua_spawn_braineaters(lua_State * L)
rv = readgame(filename, m, false);
tolua_pushnumber(L, (lua_Number) rv);
return 1;
}
}
static int tolua_read_turn(lua_State * L)
static int tolua_read_turn(lua_State * L)
{
int cturn = current_turn();
tolua_pushnumber(L, (lua_Number) cturn);
return 1;
}
}
static int tolua_get_faction(lua_State * L)
static int tolua_get_faction(lua_State * L)
{
int no = tolua_toid(L, 1, 0);
faction * f = findfaction(no);
tolua_pushusertype(L, f, TOLUA_CAST "faction");
return 1;
}
}
static int tolua_get_region(lua_State * L)
static int tolua_get_region(lua_State * L)
{
int x = (int)tolua_tonumber(L, 1, 0);
int y = (int)tolua_tonumber(L, 2, 0);
@ -606,58 +606,58 @@ static int tolua_spawn_braineaters(lua_State * L)
r = findregion(x, y);
tolua_pushusertype(L, r, TOLUA_CAST "region");
return 1;
}
}
static int tolua_get_region_byid(lua_State * L)
static int tolua_get_region_byid(lua_State * L)
{
int uid = (int)tolua_tonumber(L, 1, 0);
region * r = findregionbyid(uid);
tolua_pushusertype(L, r, TOLUA_CAST "region");
return 1;
}
}
static int tolua_get_building(lua_State * L)
static int tolua_get_building(lua_State * L)
{
int no = tolua_toid(L, 1, 0);
building * b = findbuilding(no);
tolua_pushusertype(L, b, TOLUA_CAST "building");
return 1;
}
}
static int tolua_get_ship(lua_State * L)
static int tolua_get_ship(lua_State * L)
{
int no = tolua_toid(L, 1, 0);
ship * sh = findship(no);
tolua_pushusertype(L, sh, TOLUA_CAST "ship");
return 1;
}
}
static int tolua_get_alliance(lua_State * L)
static int tolua_get_alliance(lua_State * L)
{
int no = tolua_toid(L, 1, 0);
alliance * f = findalliance(no);
tolua_pushusertype(L, f, TOLUA_CAST "alliance");
return 1;
}
}
static int tolua_get_unit(lua_State * L)
static int tolua_get_unit(lua_State * L)
{
int no = tolua_toid(L, 1, 0);
unit * u = findunit(no);
tolua_pushusertype(L, u, TOLUA_CAST "unit");
return 1;
}
}
static int tolua_alliance_create(lua_State * L)
static int tolua_alliance_create(lua_State * L)
{
int id = (int)tolua_tonumber(L, 1, 0);
const char *name = tolua_tostring(L, 2, 0);
alliance * alli = makealliance(id, name);
tolua_pushusertype(L, alli, TOLUA_CAST "alliance");
return 1;
}
}
static int tolua_get_regions(lua_State * L)
static int tolua_get_regions(lua_State * L)
{
region ** region_ptr = (region **) lua_newuserdata(L, sizeof(region *));
luaL_getmetatable(L, "region");
@ -665,9 +665,9 @@ static int tolua_spawn_braineaters(lua_State * L)
*region_ptr = regions;
lua_pushcclosure(L, tolua_regionlist_next, 1);
return 1;
}
}
static int tolua_get_factions(lua_State * L)
static int tolua_get_factions(lua_State * L)
{
faction ** faction_ptr = (faction **) lua_newuserdata(L, sizeof(faction *));
luaL_getmetatable(L, "faction");
@ -675,34 +675,34 @@ static int tolua_spawn_braineaters(lua_State * L)
*faction_ptr = factions;
lua_pushcclosure(L, tolua_factionlist_next, 1);
return 1;
}
}
static int tolua_get_alliance_factions(lua_State * L)
static int tolua_get_alliance_factions(lua_State * L)
{
alliance * self = (alliance *) tolua_tousertype(L, 1, 0);
return tolua_quicklist_push(L, "faction_list", "faction", self->members);
}
}
static int tolua_get_alliance_id(lua_State * L)
static int tolua_get_alliance_id(lua_State * L)
{
alliance * self = (alliance *) tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number) self->id);
return 1;
}
}
static int tolua_get_alliance_name(lua_State * L)
static int tolua_get_alliance_name(lua_State * L)
{
alliance * self = (alliance *) tolua_tousertype(L, 1, 0);
tolua_pushstring(L, self->name);
return 1;
}
}
static int tolua_set_alliance_name(lua_State * L)
static int tolua_set_alliance_name(lua_State * L)
{
alliance * self = (alliance *) tolua_tousertype(L, 1, 0);
alliance_setname(self, tolua_tostring(L, 2, 0));
return 0;
}
}
#include <libxml/tree.h>
@ -775,9 +775,9 @@ static int tolua_write_spells(lua_State * L)
xmlSaveFormatFileEnc(filename, doc, "utf-8", 1);
xmlFreeDoc(doc);
return 0;
}
}
static int config_get_ships(lua_State * L)
static int config_get_ships(lua_State * L)
{
quicklist * ql;
int qi, i = 0;
@ -788,9 +788,9 @@ static int tolua_write_spells(lua_State * L)
lua_rawseti(L, -2, ++i);
}
return 1;
}
}
static int config_get_locales(lua_State * L)
static int config_get_locales(lua_State * L)
{
const struct locale *lang;
int i = 0, n = 0;
@ -802,9 +802,9 @@ static int tolua_write_spells(lua_State * L)
lua_rawseti(L, -2, ++i);
}
return 1;
}
}
static int config_get_resource(lua_State * L)
static int config_get_resource(lua_State * L)
{
const char *name = tolua_tostring(L, 1, 0);
if (name) {
@ -843,75 +843,75 @@ static int tolua_write_spells(lua_State * L)
}
}
return 0;
}
}
static int tolua_get_spell_text(lua_State * L)
static int tolua_get_spell_text(lua_State * L)
{
const struct locale *loc = default_locale;
spell * self = (spell *) tolua_tousertype(L, 1, 0);
lua_pushstring(L, spell_info(self, loc));
return 1;
}
}
static int tolua_get_spell_school(lua_State * L)
static int tolua_get_spell_school(lua_State * L)
{
spell * self = (spell *) tolua_tousertype(L, 1, 0);
lua_pushstring(L, magic_school[self->magietyp]);
return 1;
}
}
static int tolua_get_spell_level(lua_State * L)
static int tolua_get_spell_level(lua_State * L)
{
spell * self = (spell *) tolua_tousertype(L, 1, 0);
lua_pushnumber(L, self->level);
return 1;
}
}
static int tolua_get_spell_name(lua_State * L)
static int tolua_get_spell_name(lua_State * L)
{
const struct locale *lang = default_locale;
spell * self = (spell *) tolua_tousertype(L, 1, 0);
lua_pushstring(L, spell_name(self, lang));
return 1;
}
}
static int tolua_get_spells(lua_State * L)
static int tolua_get_spells(lua_State * L)
{
return tolua_quicklist_push(L, "spell_list", "spell", spells);
}
}
int tolua_read_xml(lua_State * L)
int tolua_read_xml(lua_State * L)
{
const char *filename = tolua_tostring(L, 1, 0);
const char *catalog = tolua_tostring(L, 2, 0);
init_data(filename, catalog);
return 0;
}
}
int tolua_process_markets(lua_State * L)
int tolua_process_markets(lua_State * L)
{
do_markets();
return 0;
}
}
int tolua_process_produce(lua_State * L)
int tolua_process_produce(lua_State * L)
{
region * r;
for (r = regions; r; r = r->next) {
produce(r);
}
return 0;
}
}
typedef struct event_args {
typedef struct event_args {
int hfunction;
int hargs;
const char *sendertype;
} event_args;
static void args_free(void *udata)
} event_args;
static void args_free(void *udata)
{
free(udata);
} static void event_cb(void *sender, const char *event, void *udata)
} static void event_cb(void *sender, const char *event, void *udata)
{
lua_State * L = (lua_State *) global.vm_state;
event_args * args = (event_args *) udata;
@ -928,9 +928,9 @@ static int tolua_write_spells(lua_State * L)
++nargs;
}
lua_pcall(L, nargs, 0, 0);
}
}
static int tolua_eventbus_register(lua_State * L)
static int tolua_eventbus_register(lua_State * L)
{
/* parameters:
@ -953,18 +953,18 @@ static int tolua_write_spells(lua_State * L)
}
eventbus_register(sender, event, &event_cb, &args_free, args);
return 0;
}
}
static int tolua_eventbus_fire(lua_State * L)
static int tolua_eventbus_fire(lua_State * L)
{
void *sender = tolua_tousertype(L, 1, 0);
const char *event = tolua_tostring(L, 2, 0);
void *args = NULL;
eventbus_fire(sender, event, args);
return 0;
}
}
static int tolua_report_unit(lua_State * L)
static int tolua_report_unit(lua_State * L)
{
char buffer[512];
unit * u = (unit *) tolua_tousertype(L, 1, 0);
@ -972,24 +972,24 @@ static int tolua_write_spells(lua_State * L)
bufunit(f, u, 0, see_unit, buffer, sizeof(buffer));
tolua_pushstring(L, buffer);
return 1;
}
}
static int tolua_settings_get(lua_State * L)
static int tolua_settings_get(lua_State * L)
{
const char *name = tolua_tostring(L, 1, 0);
tolua_pushstring(L, get_param(global.parameters, name));
return 1;
}
}
static int tolua_settings_set(lua_State * L)
static int tolua_settings_set(lua_State * L)
{
const char *name = tolua_tostring(L, 1, 0);
const char *value = tolua_tostring(L, 2, 0);
set_param(&global.parameters, name, value);
return 0;
}
}
static void
static void
parse_inifile(lua_State * L, dictionary * d, const char *section)
{
int i;
@ -1014,9 +1014,9 @@ parse_inifile(lua_State * L, dictionary * d, const char *section)
lua_pushstring(L, "basepath");
lua_pushstring(L, basepath());
lua_rawset(L, -3);
}
}
int tolua_eressea_open(lua_State * L)
int tolua_eressea_open(lua_State * L)
{
tolua_open(L);
@ -1150,6 +1150,6 @@ parse_inifile(lua_State * L, dictionary * d, const char *section)
tolua_function(L, TOLUA_CAST "read_xml", tolua_read_xml);
} tolua_endmodule(L);
return 1;
}
}