[Freeciv-Dev] (PR#13019) Meta-Ticket: Improved scripting API
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] (PR#13019) Meta-Ticket: Improved scripting API |
From: |
"Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx> |
Date: |
Mon, 9 May 2005 17:34:33 -0700 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13019 >
This patch adds the Terrain type and makes all names use name_orig.
Requested by Jason Dorje Short.
Index: server/scripting/api.pkg
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/scripting/api.pkg,v
retrieving revision 1.3
diff -u -u -r1.3 api.pkg
--- server/scripting/api.pkg 4 May 2005 00:17:08 -0000 1.3
+++ server/scripting/api.pkg 10 May 2005 00:31:41 -0000
@@ -52,43 +52,40 @@
const int nat_x;
const int nat_y;
+ int terrain @ terrain_id;
+
const int index @ id;
};
struct Impr_Type {
- const char *name;
-
- const char *name_orig;
+ const char *name_orig @ name;
const int index @ id;
};
struct Nation_Type {
- const char *name;
- const char *name_plural;
-
- const char *name_orig;
- const char *name_plural_orig;
+ const char *name_orig @ name;
+ const char *name_plural_orig @ name_plural;
const int index @ id;
};
struct Unit_Type {
- const char *name;
-
- const char *name_orig;
+ const char *name_orig @ name;
const int index @ id;
};
struct Tech_Type {
- const char *name;
-
- const char *name_orig;
+ const char *name_orig @ name;
const int index @ id;
};
+struct Terrain {
+ const char *terrain_name_orig @ name;
+};
+
$[
-- Player methods.
function Player:nation()
@@ -112,6 +109,11 @@
function Unit:homecity()
return find.city(self:owner(), self.homecity_id)
end
+
+-- Tile methods.
+function Tile:terrain()
+ return find.terrain(self.terrain_id)
+end
$]
/* Object find module. */
@@ -137,6 +139,10 @@
api_find_tech_type_by_name @ tech_type (const char *name_orig);
Tech_Type *
api_find_tech_type @ tech_type (int tech_type_id);
+ Terrain *
+ api_find_terrain_by_name @ terrain (const char *name_orig);
+ Terrain *
+ api_find_terrain @ terrain(int terrain_id);
}
$[
Index: server/scripting/api_find.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/scripting/api_find.c,v
retrieving revision 1.2
diff -u -u -r1.2 api_find.c
--- server/scripting/api_find.c 3 May 2005 15:09:05 -0000 1.2
+++ server/scripting/api_find.c 10 May 2005 00:31:41 -0000
@@ -128,3 +128,20 @@
return api_find_tech_type(id);
}
+/**************************************************************************
+ Return the terrain with the given terrain_id index.
+**************************************************************************/
+Terrain *api_find_terrain(int terrain_id)
+{
+ return get_tile_type(terrain_id);
+}
+
+/**************************************************************************
+ Return the tech type with the given name_orig.
+**************************************************************************/
+Terrain *api_find_terrain_by_name(const char *name_orig)
+{
+ Terrain_type_id id = get_terrain_by_name(name_orig);
+ return api_find_terrain(id);
+}
+
Index: server/scripting/api_find.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/scripting/api_find.h,v
retrieving revision 1.2
diff -u -u -r1.2 api_find.h
--- server/scripting/api_find.h 3 May 2005 15:09:05 -0000 1.2
+++ server/scripting/api_find.h 10 May 2005 00:31:41 -0000
@@ -30,6 +30,8 @@
Unit_Type *api_find_unit_type_by_name(const char *name_orig);
Tech_Type *api_find_tech_type(int tech_type_id);
Tech_Type *api_find_tech_type_by_name(const char *name_orig);
+Terrain *api_find_terrain(int terrain_id);
+Terrain *api_find_terrain_by_name(const char *name_orig);
#endif
Index: server/scripting/api_types.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/scripting/api_types.h,v
retrieving revision 1.3
diff -u -u -r1.3 api_types.h
--- server/scripting/api_types.h 5 May 2005 18:32:54 -0000 1.3
+++ server/scripting/api_types.h 10 May 2005 00:31:41 -0000
@@ -23,6 +23,7 @@
#include "nation.h"
#include "tech.h"
#include "unittype.h"
+#include "terrain.h"
#include "events.h"
@@ -35,6 +36,7 @@
typedef struct nation_type Nation_Type;
typedef struct unit_type Unit_Type;
typedef struct advance Tech_Type;
+typedef struct tile_type Terrain;
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#13019) Meta-Ticket: Improved scripting API,
Vasco Alexandre da Silva Costa <=
|
|