[crossfire-client] lua 5.2

Tom Callaway spot at fedoraproject.org
Tue May 14 19:47:20 UTC 2013


commit bb829d8cdbdd27818d59fc131ccab207a2f713bc
Author: Tom Callaway <spot at fedoraproject.org>
Date:   Tue May 14 15:46:52 2013 -0400

    lua 5.2

 crossfire-client-1.70.0-lua-5.2.patch |  104 +++++++++++++++++++++++++++++++++
 crossfire-client.spec                 |    7 ++-
 2 files changed, 110 insertions(+), 1 deletions(-)
---
diff --git a/crossfire-client-1.70.0-lua-5.2.patch b/crossfire-client-1.70.0-lua-5.2.patch
new file mode 100644
index 0000000..d869a31
--- /dev/null
+++ b/crossfire-client-1.70.0-lua-5.2.patch
@@ -0,0 +1,104 @@
+diff -up crossfire-client-1.70.0/common/script_lua.c.lua-52 crossfire-client-1.70.0/common/script_lua.c
+--- crossfire-client-1.70.0/common/script_lua.c.lua-52	2012-03-18 02:17:45.000000000 -0400
++++ crossfire-client-1.70.0/common/script_lua.c	2013-05-14 15:45:34.025340540 -0400
+@@ -53,6 +53,10 @@ const char * const rcsid_common_script_l
+ #include <lauxlib.h>
+ #endif
+ 
++#ifndef lua_open
++#define lua_open()     luaL_newstate()
++#endif
++
+ struct script_state
+ {
+     lua_State* state;
+@@ -88,8 +92,7 @@ static int script_count = 0;
+ 
+ static void update_player(lua_State* lua)
+ {
+-    lua_pushstring(lua, "player");
+-    lua_gettable(lua, LUA_GLOBALSINDEX);
++    lua_getglobal(lua, "player");
+     if (!lua_istable(lua, -1))
+     {
+         lua_pop(lua, 1);
+@@ -145,11 +148,10 @@ static void update_inv(lua_State* lua)
+ {
+     item* it;
+     int index = 1;
+-    lua_pushstring(lua, "inv");
++
+     lua_newtable(lua);
+-    lua_settable(lua, LUA_GLOBALSINDEX);
+-    lua_pushstring(lua, "inv");
+-    lua_gettable(lua, LUA_GLOBALSINDEX);
++    lua_setglobal(lua, "inv");
++    lua_getglobal(lua, "inv");
+ 
+     for ( it = cpl.ob->inv; it; it = it->next )
+     {
+@@ -164,11 +166,9 @@ static void update_ground(lua_State* lua
+ {
+     item* it;
+     int index = 1;
+-    lua_pushstring(lua, "ground");
+     lua_newtable(lua);
+-    lua_settable(lua, LUA_GLOBALSINDEX);
+-    lua_pushstring(lua, "ground");
+-    lua_gettable(lua, LUA_GLOBALSINDEX);
++    lua_setglobal(lua, "ground");
++    lua_getglobal(lua, "ground");
+ 
+     for ( it = cpl.below->inv; it; it = it->next )
+     {
+@@ -267,7 +267,7 @@ void script_lua_load(const char* name)
+     luaopen_table(lua);
+     lua_pop(lua,1);
+ 
+-    if (( load = lua_load(lua, l_readerfile, (void*)file, name)))
++    if (( load = lua_load(lua, l_readerfile, (void*)file, name, NULL)))
+     {
+         draw_ext_info(NDI_RED, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_SCRIPT,
+             "Load error!");
+@@ -283,9 +283,8 @@ void script_lua_load(const char* name)
+     lua_register(lua, "cfdraw", lua_draw);
+     lua_register(lua, "cfissue", lua_issue);
+ 
+-    lua_pushstring(lua, "player");
+     lua_newtable(lua);
+-    lua_settable(lua, LUA_GLOBALSINDEX);
++    lua_setglobal(lua, "player");
+     update_player(lua);
+     update_inv(lua);
+     update_ground(lua);
+@@ -308,9 +307,8 @@ void script_lua_load(const char* name)
+     /*
+     printf("lua_gettop = %d, lua_type => %s\n", lua_gettop(lua), lua_typename( lua, lua_type(lua, lua_gettop(lua))));
+     printf("lua_gettop = %d, lua_type => %s\n", lua_gettop(lua), lua_typename( lua, lua_type(lua, lua_gettop(lua))));
+-    lua_pushstring(lua, "init");
+     printf("lua_gettop = %d, lua_type => %s\n", lua_gettop(lua), lua_typename( lua, lua_type(lua, lua_gettop(lua))));
+-    lua_gettable(lua, LUA_GLOBALSINDEX);
++    lua_getglobal(lua, "init);
+     printf("lua_gettop = %d, lua_type => %s\n", lua_gettop(lua), lua_typename( lua, lua_type(lua, lua_gettop(lua))));
+     if (lua_isfunction(lua, lua_gettop(lua)))
+         lua_call(lua, 0, 0);
+@@ -367,8 +365,7 @@ void script_lua_stats()
+     for ( script = 0; script < script_count; script++ )
+     {
+         lua = scripts[script].state;
+-        lua_pushstring(lua, "event_stats");
+-        lua_gettable(lua, LUA_GLOBALSINDEX);
++        lua_getglobal(lua, "event_stats");
+         if (lua_isfunction(lua, lua_gettop(lua)))
+         {
+             int luaerror;
+@@ -396,8 +393,7 @@ int script_lua_command(const char* comma
+     for ( script = 0; script < script_count; script++ )
+     {
+         lua = scripts[script].state;
+-        lua_pushstring(lua, "event_command");
+-        lua_gettable(lua, LUA_GLOBALSINDEX);
++        lua_getglobal(lua, "event_command");
+         if (lua_isfunction(lua, lua_gettop(lua)))
+         {
+             int luaerror;
diff --git a/crossfire-client.spec b/crossfire-client.spec
index d3365ed..0a16bf8 100644
--- a/crossfire-client.spec
+++ b/crossfire-client.spec
@@ -1,6 +1,6 @@
 Name: crossfire-client
 Version: 1.70.0
-Release: 3%{?dist}
+Release: 4%{?dist}
 Summary: Client for connecting to crossfire servers
 Group: Amusements/Games
 License: GPLv2+
@@ -8,6 +8,7 @@ URL: http://crossfire.real-time.com
 Source0: http://downloads.sourceforge.net/crossfire/%{name}-%{version}.tar.gz
 #Patch0: crossfire-client-1.11.0-curl.patch
 #Patch1: crossfire-client-1.60.0-libpng15.patch
+Patch2: crossfire-client-1.70.0-lua-5.2.patch
 BuildRequires: SDL-devel SDL_image-devel
 BuildRequires: gtk+-devel gtk2-devel libpng-devel curl-devel
 BuildRequires: desktop-file-utils ImageMagick
@@ -32,6 +33,7 @@ package.
 
 #%patch0 -p0
 #%patch1 -p0
+%patch2 -p1 -b .lua-52
 
 for size in 48x48 32x32 16x16 ; do 
     convert -transparent white pixmaps/${size}.png temp.png
@@ -118,6 +120,9 @@ fi
 
 
 %changelog
+* Tue May 14 2013 Tom Callaway <spot at fedoraproject.org> - 1.70.0-4
+- rebuild for lua 5.2
+
 * Mon Feb 11 2013 Jon Ciesla <limburgher at gmail.com> - 1.70.0-3
 - Drop desktop vendor tag.
 


More information about the scm-commits mailing list