From 5750f816862450d89ad4199bb7b65fb8923a7656 Mon Sep 17 00:00:00 2001 From: Tom Callaway Date: May 13 2013 14:35:15 +0000 Subject: lua 5.2 --- diff --git a/boswars-2.6.1-lua-5.2.patch b/boswars-2.6.1-lua-5.2.patch new file mode 100644 index 0000000..8a6200b --- /dev/null +++ b/boswars-2.6.1-lua-5.2.patch @@ -0,0 +1,220 @@ +diff -up boswars-2.6.1-src/engine/ai/ai.cpp.lua-52 boswars-2.6.1-src/engine/ai/ai.cpp +--- boswars-2.6.1-src/engine/ai/ai.cpp.lua-52 2010-04-11 08:12:38.000000000 -0400 ++++ boswars-2.6.1-src/engine/ai/ai.cpp 2013-05-13 10:19:18.322312662 -0400 +@@ -156,8 +156,7 @@ static void AiExecuteScript() + { + if (!AiPlayer->Script.empty()) + { +- lua_pushstring(Lua, "_ai_scripts_"); +- lua_gettable(Lua, LUA_GLOBALSINDEX); ++ lua_getglobal(Lua, "_ai_scripts_"); + lua_pushstring(Lua, AiPlayer->Script.c_str()); + lua_rawget(Lua, -2); + LuaCall(0, 1); +diff -up boswars-2.6.1-src/engine/ai/script_ai.cpp.lua-52 boswars-2.6.1-src/engine/ai/script_ai.cpp +--- boswars-2.6.1-src/engine/ai/script_ai.cpp.lua-52 2010-04-11 08:12:38.000000000 -0400 ++++ boswars-2.6.1-src/engine/ai/script_ai.cpp 2013-05-13 10:19:18.323312662 -0400 +@@ -328,16 +328,13 @@ static int CclDefineAi(lua_State *l) + // + // AI Script + // +- lua_pushstring(l, "_ai_scripts_"); +- lua_gettable(l, LUA_GLOBALSINDEX); ++ lua_getglobal(l, "_ai_scripts_"); + if (lua_isnil(l, -1)) + { + lua_pop(l, 1); +- lua_pushstring(l, "_ai_scripts_"); + lua_newtable(l); +- lua_settable(l, LUA_GLOBALSINDEX); +- lua_pushstring(l, "_ai_scripts_"); +- lua_gettable(l, LUA_GLOBALSINDEX); ++ lua_setglobal(l, "_ai_scripts_"); ++ lua_getglobal(l, "_ai_scripts_"); + } + aitype->Script = aitype->Name + aitype->Class; + lua_pushstring(l, aitype->Script.c_str()); +diff -up boswars-2.6.1-src/engine/game/trigger.cpp.lua-52 boswars-2.6.1-src/engine/game/trigger.cpp +--- boswars-2.6.1-src/engine/game/trigger.cpp.lua-52 2013-05-13 10:28:01.768320516 -0400 ++++ boswars-2.6.1-src/engine/game/trigger.cpp 2013-05-13 10:31:23.566323544 -0400 +@@ -557,17 +557,14 @@ static int CclAddTrigger(lua_State *l) + // Make a list of all triggers. + // A trigger is a pair of condition and action + // +- lua_pushstring(l, "_triggers_"); +- lua_gettable(l, LUA_GLOBALSINDEX); ++ lua_getglobal(l, "_triggers_"); + + if (lua_isnil(l, -1)) { + puts("Trigger not set, defining trigger"); + lua_pop(l, 1); +- lua_pushstring(l, "_triggers_"); + lua_newtable(l); +- lua_settable(l, LUA_GLOBALSINDEX); +- lua_pushstring(l, "_triggers_"); +- lua_gettable(l, LUA_GLOBALSINDEX); ++ lua_setglobal(l, "_triggers_"); ++ lua_getglobal(l, "_triggers_"); + } + + i = lua_objlen(l, -1); +@@ -668,8 +665,7 @@ void TriggersEachCycle(void) + int triggers; + int base = lua_gettop(Lua); + +- lua_pushstring(Lua, "_triggers_"); +- lua_gettable(Lua, LUA_GLOBALSINDEX); ++ lua_getglobal(Lua, "_triggers_"); + triggers = lua_objlen(Lua, -1); + + if (nextTrigger >= triggers) { +@@ -729,8 +725,7 @@ void SaveTriggers(CFile *file) + int i; + int triggers; + +- lua_pushstring(Lua, "_triggers_"); +- lua_gettable(Lua, LUA_GLOBALSINDEX); ++ lua_getglobal(Lua, "_triggers_"); + triggers = lua_objlen(Lua, -1); + + file->printf("SetActiveTriggers("); +@@ -769,11 +764,9 @@ void InitTriggers(void) + // + // FIXME: choose the triggers for game type + +- lua_pushstring(Lua, "_triggers_"); +- lua_gettable(Lua, LUA_GLOBALSINDEX); ++ lua_getglobal(Lua, "_triggers_"); + if (lua_isnil(Lua, -1)) { +- lua_pushstring(Lua, "SinglePlayerTriggers"); +- lua_gettable(Lua, LUA_GLOBALSINDEX); ++ lua_getglobal(Lua, "SinglePlayerTriggers"); + LuaCall(0, 1); + } + lua_pop(Lua, 1); +@@ -784,9 +777,8 @@ void InitTriggers(void) + */ + void CleanTriggers(void) + { +- lua_pushstring(Lua, "_triggers_"); + lua_pushnil(Lua); +- lua_settable(Lua, LUA_GLOBALSINDEX); ++ lua_setglobal(Lua, "_triggers_"); + + nextTrigger = 0; + +diff -up boswars-2.6.1-src/engine/include/script.h.lua-52 boswars-2.6.1-src/engine/include/script.h +--- boswars-2.6.1-src/engine/include/script.h.lua-52 2008-01-26 18:02:48.000000000 -0500 ++++ boswars-2.6.1-src/engine/include/script.h 2013-05-13 10:19:18.323312662 -0400 +@@ -46,6 +46,10 @@ extern "C" { + } + #endif + ++#ifndef lua_objlen ++#define lua_objlen(L,i) lua_rawlen(L, (i)) ++#endif ++ + /*---------------------------------------------------------------------------- + -- Declarations + ----------------------------------------------------------------------------*/ +diff -up boswars-2.6.1-src/engine/sound/music.cpp.lua-52 boswars-2.6.1-src/engine/sound/music.cpp +--- boswars-2.6.1-src/engine/sound/music.cpp.lua-52 2013-05-13 10:33:00.200324994 -0400 ++++ boswars-2.6.1-src/engine/sound/music.cpp 2013-05-13 10:33:21.527325314 -0400 +@@ -84,8 +84,7 @@ void CheckMusicFinished(bool force) + SDL_UnlockMutex(MusicFinishedMutex); + + if ((proceed || force) && SoundEnabled() && IsMusicEnabled() && CallbackMusic) { +- lua_pushstring(Lua, "MusicStopped"); +- lua_gettable(Lua, LUA_GLOBALSINDEX); ++ lua_getglobal(Lua, "MusicStopped"); + if (!lua_isfunction(Lua, -1)) { + fprintf(stderr, "No MusicStopped function in Lua\n"); + StopMusic(); +diff -up boswars-2.6.1-src/engine/stratagus/script.cpp.lua-52 boswars-2.6.1-src/engine/stratagus/script.cpp +--- boswars-2.6.1-src/engine/stratagus/script.cpp.lua-52 2013-05-13 10:31:34.540323709 -0400 ++++ boswars-2.6.1-src/engine/stratagus/script.cpp 2013-05-13 10:32:52.366324877 -0400 +@@ -144,8 +144,7 @@ static int report(int status, bool exitO + + static int luatraceback(lua_State *L) + { +- lua_pushliteral(L, "debug"); +- lua_gettable(L, LUA_GLOBALSINDEX); ++ lua_getglobal(L, "debug"); + if (!lua_istable(L, -1)) { + lua_pop(L, 1); + return 1; +@@ -873,8 +872,7 @@ char *SaveGlobal(lua_State *l, bool is_r + first = true; + res = NULL; + if (is_root) { +- lua_pushstring(l, "_G");// global table in lua. +- lua_gettable(l, LUA_GLOBALSINDEX); ++ lua_getglobal(l, "_G"); + } + sep = is_root ? "" : ", "; + Assert(lua_istable(l, -1)); +@@ -1045,8 +1043,7 @@ void SavePreferences(void) + FILE *fd; + std::string path; + +- lua_pushstring(Lua, "preferences"); +- lua_gettable(Lua, LUA_GLOBALSINDEX); ++ lua_getglobal(Lua, "preferences"); + if (lua_type(Lua, -1) == LUA_TTABLE) { + path = UserDirectory + "preferences.lua"; + +diff -up boswars-2.6.1-src/engine/ui/interface.cpp.lua-52 boswars-2.6.1-src/engine/ui/interface.cpp +--- boswars-2.6.1-src/engine/ui/interface.cpp.lua-52 2013-05-13 10:20:44.841313960 -0400 ++++ boswars-2.6.1-src/engine/ui/interface.cpp 2013-05-13 10:21:54.076314999 -0400 +@@ -474,8 +474,7 @@ bool HandleCommandKey(int key) + bool ret; + int base = lua_gettop(Lua); + +- lua_pushstring(Lua, "HandleCommandKey"); +- lua_gettable(Lua, LUA_GLOBALSINDEX); ++ lua_getglobal(Lua, "HandleCommandKey"); + if (!lua_isfunction(Lua, -1)) { + DebugPrint("No HandleCommandKey function in lua.\n"); + return false; +@@ -719,8 +718,7 @@ int HandleCheats(const std::string &inpu + } + #endif + int base = lua_gettop(Lua); +- lua_pushstring(Lua, "HandleCheats"); +- lua_gettable(Lua, LUA_GLOBALSINDEX); ++ lua_getglobal(Lua, "HandleCheats"); + if (!lua_isfunction(Lua, -1)) { + DebugPrint("No HandleCheats function in lua.\n"); + return 0; +diff -up boswars-2.6.1-src/engine/ui/script_ui.cpp.lua-52 boswars-2.6.1-src/engine/ui/script_ui.cpp +--- boswars-2.6.1-src/engine/ui/script_ui.cpp.lua-52 2013-05-13 10:27:36.691320140 -0400 ++++ boswars-2.6.1-src/engine/ui/script_ui.cpp 2013-05-13 10:27:41.517320212 -0400 +@@ -703,15 +703,12 @@ static int CclDefineButtonStyle(lua_Stat + */ + int AddHandler(lua_State *l) + { +- lua_pushstring(l, "_handlers_"); +- lua_gettable(l, LUA_GLOBALSINDEX); ++ lua_getglobal(l, "_handlers_"); + if (lua_isnil(l, -1)) { + lua_pop(l, 1); +- lua_pushstring(l, "_handlers_"); + lua_newtable(l); +- lua_settable(l, LUA_GLOBALSINDEX); +- lua_pushstring(l, "_handlers_"); +- lua_gettable(l, LUA_GLOBALSINDEX); ++ lua_setglobal(l, "_handlers_"); ++ lua_getglobal(l, "_handlers_"); + } + lua_pushvalue(l, -2); + lua_rawseti(l, -2, HandleCount); +@@ -725,8 +722,7 @@ int AddHandler(lua_State *l) + */ + void CallHandler(unsigned int handle, int value) + { +- lua_pushstring(Lua, "_handlers_"); +- lua_gettable(Lua, LUA_GLOBALSINDEX); ++ lua_getglobal(Lua, "_handlers_"); + lua_rawgeti(Lua, -1, handle); + lua_pushnumber(Lua, value); + LuaCall(1, 1); diff --git a/boswars.spec b/boswars.spec index 39df8af..3e58970 100644 --- a/boswars.spec +++ b/boswars.spec @@ -1,6 +1,6 @@ Name: boswars Version: 2.6.1 -Release: 8%{?dist} +Release: 9%{?dist} Summary: Bos Wars is a futuristic real-time strategy game Group: Amusements/Games License: GPLv2 @@ -11,6 +11,8 @@ Patch0: boswars-2.4.1-SConstruct.patch # incomplete patch to port boswars to the system guichan-0.6 instead of # using the included guichan-0.4. Incomplete, NOT finished and NOT working! #Patch1: boswars-2.4.1-guichan26.patch +# Lua 5.2 +Patch2: boswars-2.6.1-lua-5.2.patch BuildRequires: libtheora-devel libvorbis-devel lua-devel SDL-devel libGL-devel BuildRequires: tolua++-devel libpng-devel scons desktop-file-utils Requires: hicolor-icon-theme xorg-x11-utils @@ -24,6 +26,7 @@ Bos Wars aims to create a completly original and fun open source RTS game. %prep %setup -q -n %{name}-%{version}-src %patch0 -p1 +%patch2 -p1 -b .lua-52 chmod -x engine/guichan/include/guichan/sdl/sdlgraphics.h \ engine/include/animation.h engine/guichan/sdl/gsdl.cpp # we want to use the system version of these @@ -67,6 +70,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : %{_datadir}/icons/hicolor/32x32/apps/%{name}.png %changelog +* Mon May 13 2013 Tom Callaway - 2.6.1-9 +- lua 5.2 + * Thu Feb 14 2013 Rahul Sundaram - 2.6.1-8 - remove vendor tag from desktop file. https://fedorahosted.org/fpc/ticket/247 - clean up spec to follow current guidelines