[Freeciv-Dev] (PR#39450) Make unit_type etc names available in the scripting api

2007-07-17 Thread Ulrik Sverdrup

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39450 

Committed to trunk as r13111

It is possible to backport this change to the 2.1 branch, if needed or
wanted. 

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#39450) Make unit_type etc names available in the scripting api

2007-07-14 Thread Ulrik Sverdrup

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39450 

Patch attached, applies to trunk r13103

Now we have:
:rule_name()
:name_translation()
and for Nation_Type there is also:
:plural_translation()
Index: server/scripting/api_methods.h
===
--- server/scripting/api_methods.h	(revision 13103)
+++ server/scripting/api_methods.h	(arbetskopia)
@@ -27,5 +27,21 @@
 bool api_methods_building_type_is_small_wonder(Building_Type *pbuilding);
 bool api_methods_building_type_is_improvement(Building_Type *pbuilding);
 
+/* rule name and translated name methods */
+const char *api_methods_government_rule_name(Government *pgovernment);
+const char *api_methods_government_name_translation(Government *pgovernment);
+const char *api_methods_nation_type_rule_name(Nation_Type *pnation);
+const char *api_methods_nation_type_name_translation(Nation_Type *pnation);
+const char *api_methods_nation_type_plural_translation(Nation_Type
+   *pnation);
+const char *api_methods_building_type_rule_name(Building_Type *pbuilding);
+const char *api_methods_building_type_name_translation(Building_Type 
+   *pbuilding);
+const char *api_methods_unit_type_rule_name(Unit_Type *punit_type);
+const char *api_methods_unit_type_name_translation(Unit_Type *punit_type);
+const char *api_methods_tech_type_rule_name(Tech_Type *ptech);
+const char *api_methods_tech_type_name_translation(Tech_Type *ptech);
+const char *api_methods_terrain_rule_name(Terrain *pterrain);
+const char *api_methods_terrain_name_translation(Terrain *pterrain);
 #endif
 
Index: server/scripting/api.pkg
===
--- server/scripting/api.pkg	(revision 13103)
+++ server/scripting/api.pkg	(arbetskopia)
@@ -94,16 +94,28 @@
 
 
 /* Class methods. */
+
+/* Player */
 int api_methods_player_num_cities
 	@ methods_player_num_cities (Player *pplayer);
 int api_methods_player_num_units
 	@ methods_player_num_units (Player *pplayer);
 
-bool api_methods_unit_type_has_flag
-	@ methods_unit_type_has_flag (Unit_Type *punit_type, const char *flag);
-bool api_methods_unit_type_has_role
-	@ methods_unit_type_has_role (Unit_Type *punit_type, const char *role);
+/* Government */
+const char *api_methods_government_rule_name
+	@ methods_government_rule_name (Government *pgovernment);
+const char *api_methods_government_name_translation
+	@ methods_government_name_translation (Government *pgovernment);
 
+/* Nation_Type */
+const char *api_methods_nation_type_rule_name
+	@ methods_nation_type_rule_name (Nation_Type *pnation);
+const char *api_methods_nation_type_name_translation
+	@ methods_nation_type_name_translation (Nation_Type *pnation);
+const char *api_methods_nation_type_plural_translation
+	@ methods_nation_type_plural_translation (Nation_Type *pnation);
+
+/* Building_Type */
 bool api_methods_building_type_is_wonder
 	@ methods_building_type_is_wonder (Building_Type *pbuilding);
 bool api_methods_building_type_is_great_wonder
@@ -112,8 +124,33 @@
 	@ methods_building_type_is_small_wonder (Building_Type *pbuilding);
 bool api_methods_building_type_is_improvement
 	@ methods_building_type_is_improvement (Building_Type *pbuilding);
+const char *api_methods_building_type_rule_name
+	@ methods_building_type_rule_name (Building_Type *pbuilding);
+const char *api_methods_building_type_name_translation
+	@ methods_building_type_name_translation (Building_Type *pbuilding);
 
+/* Unit_Type */
+bool api_methods_unit_type_has_flag
+	@ methods_unit_type_has_flag (Unit_Type *punit_type, const char *flag);
+bool api_methods_unit_type_has_role
+	@ methods_unit_type_has_role (Unit_Type *punit_type, const char *role);
+const char *api_methods_unit_type_rule_name
+	@ methods_unit_type_rule_name (Unit_Type *punit_type);
+const char *api_methods_unit_type_name_translation
+	@ methods_unit_type_name_translation (Unit_Type *punit_type);
 
+/* Tech_Type */
+const char *api_methods_tech_type_rule_name
+	@ methods_tech_type_rule_name (Tech_Type *ptech);
+const char *api_methods_tech_type_name_translation
+	@ methods_tech_type_name_translation (Tech_Type *ptech);
+
+/* Terrain */
+const char *api_methods_terrain_rule_name
+	@ methods_terrain_rule_name (Terrain *pterrain);
+const char *api_methods_terrain_name_translation
+	@ methods_terrain_name_translation (Terrain *pterrain);
+
 $[
 -- Player methods.
 function Player:is_human()
@@ -133,6 +170,28 @@
   return find.city(self.owner, self.homecity_id)
 end
 
+-- Government methods
+function Government:rule_name()
+  return methods_government_rule_name(self)
+end
+
+function Government:name_translation()
+  return methods_government_name_translation(self)
+end
+
+-- Nation_Type methods
+function Nation_Type:rule_name()
+  return methods_nation_type_rule_name(self)
+end
+
+function Nation_Type:name_translation()
+