Author: cazfi Date: Sat May 6 08:10:37 2017 New Revision: 35417 URL: http://svn.gna.org/viewcvs/freeciv?rev=35417&view=rev Log: Add player.controlling_gui() to scripting API
Requested by Jacob Nevins <jtn> See gna patch #7500 Modified: branches/S3_0/common/scriptcore/api_game_methods.c branches/S3_0/common/scriptcore/api_game_methods.h branches/S3_0/common/scriptcore/tolua_game.pkg Modified: branches/S3_0/common/scriptcore/api_game_methods.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/scriptcore/api_game_methods.c?rev=35417&r1=35416&r2=35417&view=diff ============================================================================== --- branches/S3_0/common/scriptcore/api_game_methods.c (original) +++ branches/S3_0/common/scriptcore/api_game_methods.c Sat May 6 08:10:37 2017 @@ -405,6 +405,30 @@ } /***************************************************************************** + Return gui type string of the controlling connection. +*****************************************************************************/ +const char *api_methods_player_controlling_gui(lua_State *L, Player *pplayer) +{ + struct connection *conn = NULL; + + LUASCRIPT_CHECK_STATE(L, FALSE); + LUASCRIPT_CHECK_SELF(L, pplayer, FALSE); + + conn_list_iterate(pplayer->connections, pconn) { + if (!pconn->observer) { + conn = pconn; + break; + } + } conn_list_iterate_end; + + if (conn == NULL) { + return "None"; + } + + return gui_type_name(conn->client_gui); +} + +/***************************************************************************** Return TRUE iff player has wonder *****************************************************************************/ bool api_methods_player_has_wonder(lua_State *L, Player *pplayer, Modified: branches/S3_0/common/scriptcore/api_game_methods.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/scriptcore/api_game_methods.h?rev=35417&r1=35416&r2=35417&view=diff ============================================================================== --- branches/S3_0/common/scriptcore/api_game_methods.h (original) +++ branches/S3_0/common/scriptcore/api_game_methods.h Sat May 6 08:10:37 2017 @@ -77,6 +77,7 @@ Nation_Type *pnation); /* Player */ +const char *api_methods_player_controlling_gui(lua_State *L, Player *pplayer); bool api_methods_player_has_wonder(lua_State *L, Player *pplayer, Building_Type *building); int api_methods_player_number(lua_State *L, Player *pplayer); Modified: branches/S3_0/common/scriptcore/tolua_game.pkg URL: http://svn.gna.org/viewcvs/freeciv/branches/S3_0/common/scriptcore/tolua_game.pkg?rev=35417&r1=35416&r2=35417&view=diff ============================================================================== --- branches/S3_0/common/scriptcore/tolua_game.pkg (original) +++ branches/S3_0/common/scriptcore/tolua_game.pkg Sat May 6 08:10:37 2017 @@ -143,6 +143,9 @@ int api_methods_player_number @ id (lua_State *L, Player *self); } + + const char *api_methods_player_controlling_gui + @ controlling_gui (lua_State *L, Player *self); int api_methods_player_num_cities @ num_cities (lua_State *L, Player *self); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits