Bug #493 ยป 0060-Lua-Don-t-expose-internal-tech-cost-and-leakage-ids.patch
| common/scriptcore/api_game_methods.c | ||
|---|---|---|
|   return game.control.name; | ||
| } | ||
| /**********************************************************************//** | ||
|   Return name of the current tech cost style | ||
| **************************************************************************/ | ||
| const char *api_methods_tech_cost_style(lua_State *L) | ||
| { | ||
|   return tech_cost_style_name(game.info.tech_cost_style); | ||
| } | ||
| /**********************************************************************//** | ||
|   Return name of the current tech leakage style | ||
| **************************************************************************/ | ||
| const char *api_methods_tech_leakage_style(lua_State *L) | ||
| { | ||
|   return tech_leakage_style_name(game.info.tech_leakage); | ||
| } | ||
| /**********************************************************************//** | ||
|   Return TRUE if pbuilding is a wonder. | ||
| **************************************************************************/ | ||
| common/scriptcore/api_game_methods.h | ||
|---|---|---|
| const char *api_methods_game_rulesetdir(lua_State *L); | ||
| const char *api_methods_game_ruleset_name(lua_State *L); | ||
| const char *api_methods_tech_cost_style(lua_State *L); | ||
| const char *api_methods_tech_leakage_style(lua_State *L); | ||
| /* Building Type */ | ||
| bool api_methods_building_type_is_wonder(lua_State *L, | ||
|                                          Building_Type *pbuilding); | ||
| common/scriptcore/api_game_specenum.c | ||
|---|---|---|
|   Define the __index function for each exported specenum type. | ||
| **************************************************************************/ | ||
| API_SPECENUM_DEFINE_INDEX(event_type, "E_") | ||
| API_SPECENUM_DEFINE_INDEX_REV(tech_cost_style); | ||
| API_SPECENUM_DEFINE_INDEX_REV(tech_leakage_style); | ||
| /**********************************************************************//** | ||
|   Load the specenum modules into Lua state L. | ||
| ... | ... | |
| int api_game_specenum_open(lua_State *L) | ||
| { | ||
|   API_SPECENUM_CREATE_TABLE(L, event_type, "E"); | ||
|   API_SPECENUM_CREATE_TABLE_REV(L, tech_cost_style, "TECH_COST"); | ||
|   API_SPECENUM_CREATE_TABLE_REV(L, tech_leakage_style, "TECH_LEAKAGE"); | ||
|   return 0; | ||
| } | ||
| common/scriptcore/tolua_game.pkg | ||
|---|---|---|
|   const bool tech_parasite_allow_holes; | ||
|   const bool tech_loss_allow_holes; | ||
|   const int sciencebox; | ||
|   const char tech_cost_style @ tech_cost_style_id; | ||
|   const char tech_leakage @ tech_leakage_style_id; | ||
| }; | ||
| /* Module Game */ | ||
| ... | ... | |
|   const char *api_methods_game_ruleset_name | ||
|     @ ruleset_name (lua_State *L); | ||
|   const char *api_methods_tech_cost_style | ||
|     @ tech_cost_style (lua_State *L); | ||
|   const char *api_methods_tech_leakage_style | ||
|     @ tech_leakage_style (lua_State *L); | ||
| } | ||
| module Counter { | ||
| ... | ... | |
| } | ||
| $[ | ||
| -- Getting enums from game.info as rule names | ||
| -- The tables are defined and filled in api_game_specenum.c | ||
| local tcs, tls = TECH_COST, TECH_LEAKAGE | ||
| -- Remove the tables from _G, likely no more use for them | ||
| TECH_COST, TECH_LEAKAGE = nil, nil | ||
| Game_Info.properties = { | ||
|   tech_cost_style = function(self) | ||
|     return tcs[self.tech_cost_style_id]; | ||
|   end, | ||
|   tech_leakage_style = function(self) | ||
|     return tls[self.tech_leakage_style_id]; | ||
|   end | ||
| } | ||
| -- *************************************************************************** | ||
| -- Player and Tile: cities_iterate and units_iterate methods | ||