Author: cazfi
Date: Sat May  6 08:10:26 2017
New Revision: 35416

URL: http://svn.gna.org/viewcvs/freeciv?rev=35416&view=rev
Log:
Add player.controlling_gui() to scripting API

Requested by Jacob Nevins <jtn>

See gna patch #7500

Modified:
    trunk/common/scriptcore/api_game_methods.c
    trunk/common/scriptcore/api_game_methods.h
    trunk/common/scriptcore/tolua_game.pkg

Modified: trunk/common/scriptcore/api_game_methods.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/scriptcore/api_game_methods.c?rev=35416&r1=35415&r2=35416&view=diff
==============================================================================
--- trunk/common/scriptcore/api_game_methods.c  (original)
+++ trunk/common/scriptcore/api_game_methods.c  Sat May  6 08:10:26 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: trunk/common/scriptcore/api_game_methods.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/scriptcore/api_game_methods.h?rev=35416&r1=35415&r2=35416&view=diff
==============================================================================
--- trunk/common/scriptcore/api_game_methods.h  (original)
+++ trunk/common/scriptcore/api_game_methods.h  Sat May  6 08:10:26 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: trunk/common/scriptcore/tolua_game.pkg
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/scriptcore/tolua_game.pkg?rev=35416&r1=35415&r2=35416&view=diff
==============================================================================
--- trunk/common/scriptcore/tolua_game.pkg      (original)
+++ trunk/common/scriptcore/tolua_game.pkg      Sat May  6 08:10:26 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

Reply via email to