Author: cazfi
Date: Thu May  4 17:26:53 2017
New Revision: 35388

URL: http://svn.gna.org/viewcvs/freeciv?rev=35388&view=rev
Log:
Add calendar access functions to scripting API

See hrm Feature #656845

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=35388&r1=35387&r2=35388&view=diff
==============================================================================
--- branches/S3_0/common/scriptcore/api_game_methods.c  (original)
+++ branches/S3_0/common/scriptcore/api_game_methods.c  Thu May  4 17:26:53 2017
@@ -21,6 +21,7 @@
 /* common */
 #include "achievements.h"
 #include "actions.h"
+#include "calendar.h"
 #include "citizens.h"
 #include "culture.h"
 #include "game.h"
@@ -50,6 +51,36 @@
   LUASCRIPT_CHECK_STATE(L, FALSE);
 
   return game.info.turn;
+}
+
+/*****************************************************************************
+  Return the current year.
+*****************************************************************************/
+int api_methods_game_year(lua_State *L)
+{
+  LUASCRIPT_CHECK_STATE(L, FALSE);
+
+  return game.info.year;
+}
+
+/*****************************************************************************
+  Return the current year fragment.
+*****************************************************************************/
+int api_methods_game_year_fragment(lua_State *L)
+{
+  LUASCRIPT_CHECK_STATE(L, FALSE);
+
+  return game.info.fragment_count;
+}
+
+/*****************************************************************************
+  Return the current year fragment.
+*****************************************************************************/
+const char *api_methods_game_year_text(lua_State *L)
+{
+  LUASCRIPT_CHECK_STATE(L, FALSE);
+
+  return calendar_text();
 }
 
 /*****************************************************************************

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=35388&r1=35387&r2=35388&view=diff
==============================================================================
--- branches/S3_0/common/scriptcore/api_game_methods.h  (original)
+++ branches/S3_0/common/scriptcore/api_game_methods.h  Thu May  4 17:26:53 2017
@@ -26,6 +26,9 @@
 /* Game */
 int api_methods_game_turn(lua_State *L);
 int api_methods_game_turn_deprecated(lua_State *L);
+int api_methods_game_year(lua_State *L);
+int api_methods_game_year_fragment(lua_State *L);
+const char *api_methods_game_year_text(lua_State *L);
 const char *api_methods_game_rulesetdir(lua_State *L);
 const char *api_methods_game_ruleset_name(lua_State *L);
 

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=35388&r1=35387&r2=35388&view=diff
==============================================================================
--- branches/S3_0/common/scriptcore/tolua_game.pkg      (original)
+++ branches/S3_0/common/scriptcore/tolua_game.pkg      Thu May  4 17:26:53 2017
@@ -120,6 +120,15 @@
   /* Deprecated. Use current_turn() to get the real turn number */
   int api_methods_game_turn_deprecated
     @ turn (lua_State *L);
+
+  int api_methods_game_year
+    @ current_year (lua_State *L);
+
+  int api_methods_game_year_fragment
+    @ current_fragment (lua_State *L);
+
+  const char *api_methods_game_year_text
+    @ current_year_text (lua_State *L);
 
   const char *api_methods_game_rulesetdir
     @ rulesetdir (lua_State *L);


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to