From f36ddafc9ef423436f3676d5e8001ffd477c084c Mon Sep 17 00:00:00 2001 From: Sveinung Kvilhaugsvik Date: Mon, 15 Mar 2021 20:35:41 +0100 Subject: [PATCH 1/2] server/scripting: fix header line length. See osdn #41792 --- server/scripting/api_fcdb_auth.c | 8 +- server/scripting/api_fcdb_base.c | 4 +- server/scripting/api_server_base.c | 23 ++-- server/scripting/api_server_edit.c | 120 +++++++++++---------- server/scripting/api_server_game_methods.c | 24 ++--- server/scripting/api_server_luadata.c | 4 +- server/scripting/api_server_notify.c | 19 ++-- server/scripting/script_fcdb.c | 44 ++++---- 8 files changed, 126 insertions(+), 120 deletions(-) diff --git a/server/scripting/api_fcdb_auth.c b/server/scripting/api_fcdb_auth.c index 36b98815ca..0ffe049a0c 100644 --- a/server/scripting/api_fcdb_auth.c +++ b/server/scripting/api_fcdb_auth.c @@ -32,9 +32,9 @@ #include "api_fcdb_auth.h" -/*************************************************************************//** +/**********************************************************************//** Get the username. -*****************************************************************************/ +**************************************************************************/ const char *api_auth_get_username(lua_State *L, Connection *pconn) { LUASCRIPT_CHECK_STATE(L, NULL); @@ -44,9 +44,9 @@ const char *api_auth_get_username(lua_State *L, Connection *pconn) return auth_get_username(pconn); } -/*************************************************************************//** +/**********************************************************************//** Get the ip address. -*****************************************************************************/ +**************************************************************************/ const char *api_auth_get_ipaddr(lua_State *L, Connection *pconn) { LUASCRIPT_CHECK_STATE(L, NULL); diff --git a/server/scripting/api_fcdb_base.c b/server/scripting/api_fcdb_base.c index 476a70ffcb..a938f10369 100644 --- a/server/scripting/api_fcdb_base.c +++ b/server/scripting/api_fcdb_base.c @@ -23,9 +23,9 @@ #include "api_fcdb_base.h" -/*************************************************************************//** +/**********************************************************************//** Return the value for the fcdb setting 'type'. -*****************************************************************************/ +**************************************************************************/ const char *api_fcdb_option(lua_State *L, const char *type) { LUASCRIPT_CHECK_STATE(L, NULL); diff --git a/server/scripting/api_server_base.c b/server/scripting/api_server_base.c index 972bdd28fd..c008d1760a 100644 --- a/server/scripting/api_server_base.c +++ b/server/scripting/api_server_base.c @@ -31,9 +31,9 @@ #include "api_server_base.h" -/*************************************************************************//** +/**********************************************************************//** Return the civilization score (total) for player -*****************************************************************************/ +**************************************************************************/ int api_server_player_civilization_score(lua_State *L, Player *pplayer) { LUASCRIPT_CHECK_STATE(L, 0); @@ -42,9 +42,9 @@ int api_server_player_civilization_score(lua_State *L, Player *pplayer) return get_civ_score(pplayer); } -/*************************************************************************//** +/**********************************************************************//** Returns TRUE if the game was started. -*****************************************************************************/ +**************************************************************************/ bool api_server_was_started(lua_State *L) { LUASCRIPT_CHECK_STATE(L, FALSE); @@ -52,9 +52,9 @@ bool api_server_was_started(lua_State *L) return game_was_started(); } -/*************************************************************************//** +/**********************************************************************//** Save the game (a manual save is triggered). -*****************************************************************************/ +**************************************************************************/ bool api_server_save(lua_State *L, const char *filename) { LUASCRIPT_CHECK_STATE(L, FALSE); @@ -69,9 +69,9 @@ bool api_server_save(lua_State *L, const char *filename) return TRUE; } -/*************************************************************************//** +/**********************************************************************//** Play music track for player -*****************************************************************************/ +**************************************************************************/ bool api_play_music(lua_State *L, Player *pplayer, const char *tag) { struct packet_play_music p; @@ -87,9 +87,10 @@ bool api_play_music(lua_State *L, Player *pplayer, const char *tag) return TRUE; } -/*************************************************************************//** - Return the formated value of the setting or NULL if no such setting exists, -*****************************************************************************/ +/**********************************************************************//** + Return the formated value of the setting or NULL if no such setting + exists. +**************************************************************************/ const char *api_server_setting_get(lua_State *L, const char *sett_name) { struct setting *pset; diff --git a/server/scripting/api_server_edit.c b/server/scripting/api_server_edit.c index 884719d723..91128e0ff6 100644 --- a/server/scripting/api_server_edit.c +++ b/server/scripting/api_server_edit.c @@ -51,9 +51,9 @@ #include "api_server_edit.h" -/*************************************************************************//** +/**********************************************************************//** Unleash barbarians on a tile, for example from a hut -*****************************************************************************/ +**************************************************************************/ bool api_edit_unleash_barbarians(lua_State *L, Tile *ptile) { LUASCRIPT_CHECK_STATE(L, FALSE); @@ -62,9 +62,9 @@ bool api_edit_unleash_barbarians(lua_State *L, Tile *ptile) return unleash_barbarians(ptile); } -/*************************************************************************//** +/**********************************************************************//** Place partisans for a player around a tile (normally around a city). -*****************************************************************************/ +**************************************************************************/ void api_edit_place_partisans(lua_State *L, Tile *ptile, Player *pplayer, int count, int sq_radius) { @@ -78,9 +78,9 @@ void api_edit_place_partisans(lua_State *L, Tile *ptile, Player *pplayer, return place_partisans(ptile, pplayer, count, sq_radius); } -/*************************************************************************//** +/**********************************************************************//** Create a new unit. -*****************************************************************************/ +**************************************************************************/ Unit *api_edit_create_unit(lua_State *L, Player *pplayer, Tile *ptile, Unit_Type *ptype, int veteran_level, City *homecity, int moves_left) @@ -89,12 +89,14 @@ Unit *api_edit_create_unit(lua_State *L, Player *pplayer, Tile *ptile, homecity, moves_left, -1, NULL); } -/*************************************************************************//** +/**********************************************************************//** Create a new unit. -*****************************************************************************/ -Unit *api_edit_create_unit_full(lua_State *L, Player *pplayer, Tile *ptile, +**************************************************************************/ +Unit *api_edit_create_unit_full(lua_State *L, Player *pplayer, + Tile *ptile, Unit_Type *ptype, int veteran_level, - City *homecity, int moves_left, int hp_left, + City *homecity, int moves_left, + int hp_left, Unit *ptransport) { struct fc_lua *fcl; @@ -153,9 +155,9 @@ Unit *api_edit_create_unit_full(lua_State *L, Player *pplayer, Tile *ptile, hp_left, ptransport); } -/*************************************************************************//** +/**********************************************************************//** Teleport unit to destination tile -*****************************************************************************/ +**************************************************************************/ bool api_edit_unit_teleport(lua_State *L, Unit *punit, Tile *dest, Unit *embark_to, bool allow_disembark, bool conquer_city, bool conquer_extra, @@ -442,9 +444,9 @@ bool api_edit_perform_action_unit_vs_self(lua_State *L, Unit *punit, } } -/*************************************************************************//** +/**********************************************************************//** Change unit orientation -*****************************************************************************/ +**************************************************************************/ void api_edit_unit_turn(lua_State *L, Unit *punit, Direction dir) { LUASCRIPT_CHECK_STATE(L); @@ -459,9 +461,9 @@ void api_edit_unit_turn(lua_State *L, Unit *punit, Direction dir) } } -/*************************************************************************//** +/**********************************************************************//** Kill the unit. -*****************************************************************************/ +**************************************************************************/ void api_edit_unit_kill(lua_State *L, Unit *punit, const char *reason, Player *killer) { @@ -479,9 +481,9 @@ void api_edit_unit_kill(lua_State *L, Unit *punit, const char *reason, wipe_unit(punit, loss_reason, killer); } -/*************************************************************************//** +/**********************************************************************//** Change terrain on tile -*****************************************************************************/ +**************************************************************************/ bool api_edit_change_terrain(lua_State *L, Tile *ptile, Terrain *pterr) { struct terrain *old_terrain; @@ -509,9 +511,9 @@ bool api_edit_change_terrain(lua_State *L, Tile *ptile, Terrain *pterr) return TRUE; } -/*************************************************************************//** +/**********************************************************************//** Create a new city. -*****************************************************************************/ +**************************************************************************/ void api_edit_create_city(lua_State *L, Player *pplayer, Tile *ptile, const char *name) { @@ -527,9 +529,9 @@ void api_edit_create_city(lua_State *L, Player *pplayer, Tile *ptile, create_city(pplayer, ptile, name, pplayer); } -/*************************************************************************//** +/**********************************************************************//** Create a new player. -*****************************************************************************/ +**************************************************************************/ Player *api_edit_create_player(lua_State *L, const char *username, Nation_Type *pnation, const char *ai) { @@ -562,9 +564,9 @@ Player *api_edit_create_player(lua_State *L, const char *username, return pplayer; } -/*************************************************************************//** +/**********************************************************************//** Change pplayer's gold by amount. -*****************************************************************************/ +**************************************************************************/ void api_edit_change_gold(lua_State *L, Player *pplayer, int amount) { LUASCRIPT_CHECK_STATE(L); @@ -573,14 +575,15 @@ void api_edit_change_gold(lua_State *L, Player *pplayer, int amount) pplayer->economic.gold = MAX(0, pplayer->economic.gold + amount); } -/*************************************************************************//** +/**********************************************************************//** Give pplayer technology ptech. Quietly returns NULL if player already has this tech; otherwise returns the tech granted. Use NULL for ptech to grant a random tech. sends script signal "tech_researched" with the given reason -*****************************************************************************/ +**************************************************************************/ Tech_Type *api_edit_give_technology(lua_State *L, Player *pplayer, - Tech_Type *ptech, int cost, bool notify, + Tech_Type *ptech, int cost, + bool notify, const char *reason) { struct research *presearch; @@ -644,9 +647,9 @@ Tech_Type *api_edit_give_technology(lua_State *L, Player *pplayer, } } -/*************************************************************************//** +/**********************************************************************//** Modify player's trait value. -*****************************************************************************/ +**************************************************************************/ bool api_edit_trait_mod_set(lua_State *L, Player *pplayer, const char *tname, const int mod) { @@ -665,10 +668,11 @@ bool api_edit_trait_mod_set(lua_State *L, Player *pplayer, return TRUE; } -/*************************************************************************//** +/**********************************************************************//** Create a new owned extra. -*****************************************************************************/ -void api_edit_create_owned_extra(lua_State *L, Tile *ptile, const char *name, +**************************************************************************/ +void api_edit_create_owned_extra(lua_State *L, Tile *ptile, + const char *name, Player *pplayer) { struct extra_type *pextra; @@ -688,34 +692,34 @@ void api_edit_create_owned_extra(lua_State *L, Tile *ptile, const char *name, } } -/*************************************************************************//** +/**********************************************************************//** Create a new extra. -*****************************************************************************/ +**************************************************************************/ void api_edit_create_extra(lua_State *L, Tile *ptile, const char *name) { api_edit_create_owned_extra(L, ptile, name, NULL); } -/*************************************************************************//** +/**********************************************************************//** Create a new base. -*****************************************************************************/ +**************************************************************************/ void api_edit_create_base(lua_State *L, Tile *ptile, const char *name, Player *pplayer) { api_edit_create_owned_extra(L, ptile, name, pplayer); } -/*************************************************************************//** +/**********************************************************************//** Add a new road. -*****************************************************************************/ +**************************************************************************/ void api_edit_create_road(lua_State *L, Tile *ptile, const char *name) { api_edit_create_owned_extra(L, ptile, name, NULL); } -/*************************************************************************//** +/**********************************************************************//** Remove extra from tile, if present -*****************************************************************************/ +**************************************************************************/ void api_edit_remove_extra(lua_State *L, Tile *ptile, const char *name) { struct extra_type *pextra; @@ -735,9 +739,9 @@ void api_edit_remove_extra(lua_State *L, Tile *ptile, const char *name) } } -/*************************************************************************//** +/**********************************************************************//** Set tile label text. -*****************************************************************************/ +**************************************************************************/ void api_edit_tile_set_label(lua_State *L, Tile *ptile, const char *label) { LUASCRIPT_CHECK_STATE(L); @@ -750,9 +754,9 @@ void api_edit_tile_set_label(lua_State *L, Tile *ptile, const char *label) } } -/*************************************************************************//** +/**********************************************************************//** Global climate change. -*****************************************************************************/ +**************************************************************************/ void api_edit_climate_change(lua_State *L, enum climate_change_type type, int effect) { @@ -765,9 +769,9 @@ void api_edit_climate_change(lua_State *L, enum climate_change_type type, climate_change(type == CLIMATE_CHANGE_GLOBAL_WARMING, effect); } -/*************************************************************************//** +/**********************************************************************//** Provoke a civil war. -*****************************************************************************/ +**************************************************************************/ Player *api_edit_civil_war(lua_State *L, Player *pplayer, int probability) { LUASCRIPT_CHECK_STATE(L, NULL); @@ -794,9 +798,9 @@ Player *api_edit_civil_war(lua_State *L, Player *pplayer, int probability) return civil_war(pplayer); } -/*************************************************************************//** +/**********************************************************************//** Make player winner of the scenario -*****************************************************************************/ +**************************************************************************/ void api_edit_player_victory(lua_State *L, Player *pplayer) { LUASCRIPT_CHECK_STATE(L); @@ -805,9 +809,9 @@ void api_edit_player_victory(lua_State *L, Player *pplayer) player_status_add(pplayer, PSTATUS_WINNER); } -/*************************************************************************//** +/**********************************************************************//** Move a unit. -*****************************************************************************/ +**************************************************************************/ bool api_edit_unit_move(lua_State *L, Unit *punit, Tile *ptile, int movecost, Unit *embark_to, bool disembark, @@ -834,9 +838,9 @@ bool api_edit_unit_move(lua_State *L, Unit *punit, Tile *ptile, enter_hut, frighten_hut); } -/*************************************************************************//** +/**********************************************************************//** Prohibit unit from moving -*****************************************************************************/ +**************************************************************************/ void api_edit_unit_moving_disallow(lua_State *L, Unit *punit) { LUASCRIPT_CHECK_STATE(L); @@ -847,9 +851,9 @@ void api_edit_unit_moving_disallow(lua_State *L, Unit *punit) } } -/*************************************************************************//** +/**********************************************************************//** Allow unit to move -*****************************************************************************/ +**************************************************************************/ void api_edit_unit_moving_allow(lua_State *L, Unit *punit) { LUASCRIPT_CHECK_STATE(L); @@ -860,9 +864,9 @@ void api_edit_unit_moving_allow(lua_State *L, Unit *punit) } } -/*************************************************************************//** +/**********************************************************************//** Add history to a city -*****************************************************************************/ +**************************************************************************/ void api_edit_city_add_history(lua_State *L, City *pcity, int amount) { LUASCRIPT_CHECK_STATE(L); @@ -871,9 +875,9 @@ void api_edit_city_add_history(lua_State *L, City *pcity, int amount) pcity->history += amount; } -/*************************************************************************//** +/**********************************************************************//** Add history to a player -*****************************************************************************/ +**************************************************************************/ void api_edit_player_add_history(lua_State *L, Player *pplayer, int amount) { LUASCRIPT_CHECK_STATE(L); diff --git a/server/scripting/api_server_game_methods.c b/server/scripting/api_server_game_methods.c index bfc37f6c76..ff2a0a6726 100644 --- a/server/scripting/api_server_game_methods.c +++ b/server/scripting/api_server_game_methods.c @@ -26,9 +26,9 @@ #include "api_server_game_methods.h" -/*************************************************************************//** +/**********************************************************************//** Return the current value of an AI trait in force (base+mod) -*****************************************************************************/ +**************************************************************************/ int api_methods_player_trait(lua_State *L, Player *pplayer, const char *tname) { @@ -45,9 +45,9 @@ int api_methods_player_trait(lua_State *L, Player *pplayer, return ai_trait_get_value(tr, pplayer); } -/*************************************************************************//** +/**********************************************************************//** Return the current base value of an AI trait (not including Lua mod) -*****************************************************************************/ +**************************************************************************/ int api_methods_player_trait_base(lua_State *L, Player *pplayer, const char *tname) { @@ -64,10 +64,10 @@ int api_methods_player_trait_base(lua_State *L, Player *pplayer, return pplayer->ai_common.traits[tr].val; } -/*************************************************************************//** +/**********************************************************************//** Return the current Lua increment to an AI trait (can be changed with api_edit_trait_mod_set()) -*****************************************************************************/ +**************************************************************************/ int api_methods_player_trait_current_mod(lua_State *L, Player *pplayer, const char *tname) { @@ -84,9 +84,9 @@ int api_methods_player_trait_current_mod(lua_State *L, Player *pplayer, return pplayer->ai_common.traits[tr].mod; } -/*************************************************************************//** +/**********************************************************************//** Return the minimum random trait value that will be allocated for a nation -*****************************************************************************/ +**************************************************************************/ int api_methods_nation_trait_min(lua_State *L, Nation_Type *pnation, const char *tname) { @@ -103,9 +103,9 @@ int api_methods_nation_trait_min(lua_State *L, Nation_Type *pnation, return pnation->server.traits[tr].min; } -/*************************************************************************//** +/**********************************************************************//** Return the maximum random trait value that will be allocated for a nation -*****************************************************************************/ +**************************************************************************/ int api_methods_nation_trait_max(lua_State *L, Nation_Type *pnation, const char *tname) { @@ -122,9 +122,9 @@ int api_methods_nation_trait_max(lua_State *L, Nation_Type *pnation, return pnation->server.traits[tr].max; } -/*************************************************************************//** +/**********************************************************************//** Return the default trait value that will be allocated for a nation -*****************************************************************************/ +**************************************************************************/ int api_methods_nation_trait_default(lua_State *L, Nation_Type *pnation, const char *tname) { diff --git a/server/scripting/api_server_luadata.c b/server/scripting/api_server_luadata.c index 1983651b85..23d626c80d 100644 --- a/server/scripting/api_server_luadata.c +++ b/server/scripting/api_server_luadata.c @@ -29,9 +29,9 @@ #include "api_server_luadata.h" -/*************************************************************************//** +/**********************************************************************//** Get string value from luadata. -*****************************************************************************/ +**************************************************************************/ const char *api_luadata_get_str(lua_State *L, const char *field) { LUASCRIPT_CHECK_STATE(L, NULL); diff --git a/server/scripting/api_server_notify.c b/server/scripting/api_server_notify.c index e731da5a56..e5ca67b848 100644 --- a/server/scripting/api_server_notify.c +++ b/server/scripting/api_server_notify.c @@ -28,9 +28,9 @@ #include "api_server_notify.h" -/*************************************************************************//** +/**********************************************************************//** Notify players which have embassies with pplayer with the given message. -*****************************************************************************/ +**************************************************************************/ void api_notify_embassies_msg(lua_State *L, Player *pplayer, Tile *ptile, int event, const char *message) { @@ -39,9 +39,9 @@ void api_notify_embassies_msg(lua_State *L, Player *pplayer, Tile *ptile, notify_embassies(pplayer, ptile, event, ftc_any, "%s", message); } -/*************************************************************************//** +/**********************************************************************//** Notify pplayer of a complex event. -*****************************************************************************/ +**************************************************************************/ void api_notify_event_msg(lua_State *L, Player *pplayer, Tile *ptile, int event, const char *message) { @@ -50,10 +50,11 @@ void api_notify_event_msg(lua_State *L, Player *pplayer, Tile *ptile, notify_player(pplayer, ptile, event, ftc_any, "%s", message); } -/*************************************************************************//** +/**********************************************************************//** Notify players sharing research with the player. -*****************************************************************************/ -void api_notify_research_msg(lua_State *L, Player *pplayer, bool include_plr, +**************************************************************************/ +void api_notify_research_msg(lua_State *L, Player *pplayer, + bool include_plr, int event, const char *message) { struct research *pres; @@ -66,9 +67,9 @@ void api_notify_research_msg(lua_State *L, Player *pplayer, bool include_plr, ftc_any, "%s", message); } -/*************************************************************************//** +/**********************************************************************//** Notify players sharing research with the player. -*****************************************************************************/ +**************************************************************************/ void api_notify_research_embassies_msg(lua_State *L, Player *pplayer, int event, const char *message) { diff --git a/server/scripting/script_fcdb.c b/server/scripting/script_fcdb.c index c97b189f6f..e9456dac2f 100644 --- a/server/scripting/script_fcdb.c +++ b/server/scripting/script_fcdb.c @@ -75,12 +75,12 @@ static void script_fcdb_cmd_reply(struct fc_lua *lfcl, enum log_level level, const char *format, ...) fc__attribute((__format__ (__printf__, 3, 4))); -/*************************************************************************//** +/**********************************************************************//** Lua virtual machine state. -*****************************************************************************/ +**************************************************************************/ static struct fc_lua *fcl = NULL; -/*************************************************************************//** +/**********************************************************************//** Add fcdb callback functions; these must be defined in the lua script 'database.lua': @@ -103,9 +103,9 @@ static struct fc_lua *fcl = NULL; Bool observer): - returns Bool, whether requester is allowed to attach taker to pplayer. - If an error occurred, the functions return a non-NULL string error message - as the last return value. -*****************************************************************************/ + If an error occurred, the functions return a non-NULL string error + message as the last return value. +**************************************************************************/ static void script_fcdb_functions_define(void) { luascript_func_add(fcl, "database_init", TRUE, 0, 0); @@ -127,9 +127,9 @@ static void script_fcdb_functions_define(void) API_TYPE_BOOL); } -/*************************************************************************//** +/**********************************************************************//** Check the existence of all needed functions. -*****************************************************************************/ +**************************************************************************/ static bool script_fcdb_functions_check(const char *fcdb_luafile) { bool ret = TRUE; @@ -155,9 +155,9 @@ static bool script_fcdb_functions_check(const char *fcdb_luafile) return ret; } -/*************************************************************************//** +/**********************************************************************//** Send the message via cmd_reply(). -*****************************************************************************/ +**************************************************************************/ static void script_fcdb_cmd_reply(struct fc_lua *lfcl, enum log_level level, const char *format, ...) { @@ -192,9 +192,9 @@ static void script_fcdb_cmd_reply(struct fc_lua *lfcl, enum log_level level, cmd_reply(CMD_FCDB, lfcl->caller, rfc_status, "%s", buf); } -/*************************************************************************//** +/**********************************************************************//** MD5 checksum function for lua environment. -*****************************************************************************/ +**************************************************************************/ static int md5sum(lua_State *L) { int n = lua_gettop(L); @@ -215,10 +215,10 @@ static int md5sum(lua_State *L) } #endif /* HAVE_FCDB */ -/*************************************************************************//** - Initialize the scripting state. Returns the status of the freeciv database - lua state. -*****************************************************************************/ +/**********************************************************************//** + Initialize the scripting state. Returns the status of the freeciv + database lua state. +**************************************************************************/ bool script_fcdb_init(const char *fcdb_luafile) { #ifdef HAVE_FCDB @@ -284,12 +284,12 @@ bool script_fcdb_init(const char *fcdb_luafile) return TRUE; } -/*************************************************************************//** +/**********************************************************************//** Call a lua function. Example call to the lua function 'user_load()': success = script_fcdb_call("user_load", pconn); -*****************************************************************************/ +**************************************************************************/ bool script_fcdb_call(const char *func_name, ...) { bool success = TRUE; @@ -305,9 +305,9 @@ bool script_fcdb_call(const char *func_name, ...) return success; } -/*************************************************************************//** +/**********************************************************************//** Free the scripting data. -*****************************************************************************/ +**************************************************************************/ void script_fcdb_free(void) { #ifdef HAVE_FCDB @@ -323,10 +323,10 @@ void script_fcdb_free(void) #endif /* HAVE_FCDB */ } -/*************************************************************************//** +/**********************************************************************//** Parse and execute the script in str in the lua instance for the freeciv database. -*****************************************************************************/ +**************************************************************************/ bool script_fcdb_do_string(struct connection *caller, const char *str) { #ifdef HAVE_FCDB -- 2.20.1