stratagus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Stratagus-CVS] stratagus/src include/script.h include/spells.h...


From: address@hidden
Subject: [Stratagus-CVS] stratagus/src include/script.h include/spells.h...
Date: 18 Jan 2004 09:23:29 +1100

CVSROOT:        /home/strat
Module name:    stratagus
Changes by:      <address@hidden>       04/01/18 09:23:28

Modified files:
        src/include    : script.h spells.h 
        src/stratagus  : script.c script_spell.c spells.c stratagus.c 
        src/unit       : unittype.c 

Log message:
        Changes SpellTypeTable to be an array of pointer.
        Initial META_LUA, have to use more macros!!!

Patches:
Index: stratagus/src/include/script.h
diff -u stratagus/src/include/script.h:1.51 stratagus/src/include/script.h:1.52
--- stratagus/src/include/script.h:1.51 Sat Jan 17 02:17:24 2004
+++ stratagus/src/include/script.h      Sun Jan 18 09:23:25 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: script.h,v 1.51 2004/01/16 15:17:24 wizzard Exp $
+//      $Id: script.h,v 1.52 2004/01/17 22:23:25 nobody_ Exp $
 
 #ifndef __SCRIPT_H__
 #define __SCRIPT_H__
@@ -83,6 +83,79 @@
 extern int CclCommand(const char*);      /// Execute a ccl command
 extern void CclFree(void*);               /// Save free
 extern void CleanCclCredits();            /// Free Ccl Credits Memory
+
+#ifdef META_LUA
+
+/*----------------------------------------------------------------------------
+--  Functions.
+----------------------------------------------------------------------------*/
+
+       /// Really dumb set function that always goes into an error.
+extern int ScriptSetValueBlock(lua_State* l);
+
+/*----------------------------------------------------------------------------
+--  Quick macros for meta lua. Use them in well-formed get/set functions.
+----------------------------------------------------------------------------*/
+
+//
+//     Pushing 0 as a string to lua is ok. strdup-ing 0 is not.
+//
+#define META_GET_STRING(keyval, v) \
+{ \
+       if (!strcmp(key, keyval)) { \
+               if (v) { \
+                       lua_pushstring(l, strdup(v)); \
+               } else { \
+                       lua_pushstring(l, 0); \
+               } \
+               return 1; \
+       } \
+}
+
+#define META_SET_STRING(keyval, v) \
+{ \
+       if (!strcmp(key, keyval)) { \
+               luaL_checktype(l, -1, LUA_TSTRING); \
+               v = strdup(lua_tostring(l, -1)); \
+               return 0; \
+       } \
+}
+
+#define META_GET_INT(keyval, v) \
+{ \
+       if (!strcmp(key, keyval)) { \
+               lua_pushnumber(l, v); \
+               return 1; \
+       } \
+}
+
+#define META_SET_INT(keyval, v) \
+{ \
+       if (!strcmp(key, keyval)) { \
+               luaL_checktype(l, -1, LUA_TNUMBER); \
+               v = lua_tonumber(l, -1); \
+               return 0; \
+       } \
+}
+
+#define META_GET_BOOL(keyval, v) \
+{ \
+       if (!strcmp(key, keyval)) { \
+               lua_pushboolean(l, v); \
+               return 1; \
+       } \
+}
+
+#define META_SET_BOOL(keyval, v) \
+{ \
+       if (!strcmp(key, keyval)) { \
+               luaL_checktype(l, -1, LUA_TBOOLEAN); \
+               v = lua_toboolean(l, -1); \
+               return 0; \
+       } \
+}
+
+#endif // META_LUA
 
 //@}
 
Index: stratagus/src/include/spells.h
diff -u stratagus/src/include/spells.h:1.45 stratagus/src/include/spells.h:1.46
--- stratagus/src/include/spells.h:1.45 Sat Jan 17 02:17:24 2004
+++ stratagus/src/include/spells.h      Sun Jan 18 09:23:25 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: spells.h,v 1.45 2004/01/16 15:17:24 wizzard Exp $
+//     $Id: spells.h,v 1.46 2004/01/17 22:23:25 nobody_ Exp $
 
 #ifndef __SPELLS_H__
 #define __SPELLS_H__
@@ -242,6 +242,7 @@
 */
 typedef struct _spell_type_ {
        //  Identification stuff
+       void* ScriptData;                                       /// Script Data 
for this object.
        int Ident;                                                              
/// Spell numeric identifier
        char *IdentName;                                                /// 
Spell unique identifier (spell-holy-vision)
        char *Name;                                                             
/// Spell name shown by the engine
@@ -274,7 +275,7 @@
 /**
 **             Define the names and effects of all available spells.
 */
-extern SpellType *SpellTypeTable;
+extern SpellType **SpellTypeTable;
 
 /// How many spell-types are available
 extern int SpellTypeCount;
@@ -341,6 +342,17 @@
 SpellFunc CastDeathCoil;
 SpellFunc CastSpawnPortal;
 SpellFunc CastSpawnMissile;
+
+#ifdef META_LUA
+
+       /// Initialize Spell scripting.
+extern void ScriptSpellInit(void);
+    /// Register the spell-table user-data.
+extern void ScriptSpellTableCreateUserdata(lua_State* l);
+       /// Register a spell user-data.
+extern void ScriptSpellCreateUserdata(lua_State* l, SpellType* spell);
+
+#endif
 
 //@}
 
Index: stratagus/src/stratagus/script.c
diff -u stratagus/src/stratagus/script.c:1.157 
stratagus/src/stratagus/script.c:1.158
--- stratagus/src/stratagus/script.c:1.157      Sat Jan 17 10:55:42 2004
+++ stratagus/src/stratagus/script.c    Sun Jan 18 09:23:26 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: script.c,v 1.157 2004/01/16 23:55:42 nobody_ Exp $
+//      $Id: script.c,v 1.158 2004/01/17 22:23:26 nobody_ Exp $
 
 //@{
 
@@ -950,28 +950,11 @@
 
 #ifdef META_LUA
 
-#define FAST_GET_STRING(keyval, v) \
-{ \
-       if (!strcmp(key, keyval)) { \
-               lua_pushstring(l, strdup(v)); \
-               return 1; \
-       } \
-}
-
-#define FAST_GET_INT(keyval, v) \
-{ \
-       if (!strcmp(key, keyval)) { \
-               lua_pushnumber(l, v); \
-               return 1; \
-       } \
-}
-
-#define FAST_GET_BOOL(keyval, v) \
-{ \
-       if (!strcmp(key, keyval)) { \
-               lua_pushboolean(l, v); \
-               return 1; \
-       } \
+global int ScriptSetValueBlock(lua_State* l)
+{
+       lua_pushstring(l, "Structure is read-only, sorry.\n");
+       lua_error(l);
+       return 0;
 }
 
 /**
@@ -981,14 +964,14 @@
 {
        const char* key;
 
-       DebugCheck(lua_gettop(l) != 2);
        key = LuaToString(l, -1);
+       DebugCheck(!key);
+       DebugLevel0Fn("(%s)\n" _C_ key);
 
-       // Here start the fields.
-       FAST_GET_STRING("LibraryPath", StratagusLibPath);
-       FAST_GET_INT("GameCycle", GameCycle);
-       FAST_GET_STRING("GameName", GameName);
-       FAST_GET_BOOL("GamePaused", GamePaused);
+       META_GET_STRING("LibraryPath", StratagusLibPath);
+       META_GET_INT("GameCycle", GameCycle);
+       META_GET_STRING("GameName", GameName);
+       META_GET_BOOL("GamePaused", GamePaused);
 
        //  Something went wrong.
        lua_pushfstring(l, "Unknown field \"%s\". Going DOWN!!!\n", key);
@@ -1005,6 +988,8 @@
 
        DebugCheck(lua_gettop(l) != 3);
        key = LuaToString(l, -2);
+       DebugCheck(!key);
+       DebugLevel0Fn("(%s)\n" _C_ key);
 
        //  Here start the fields.
        //  Sorry, none yet.
@@ -1023,19 +1008,29 @@
 {
        lua_pushstring(Lua, "Stratagus");
 
-       /* First is the main table, and the metatable for Stratagus. */
+       /* Generate a weak table in the registry */
+       lua_pushstring(Lua, "StratagusReferences");
+       lua_newtable(Lua);
+       lua_newtable(Lua);
+       lua_pushstring(Lua, "__mode");
+       lua_pushstring(Lua, "v");
+       lua_settable(Lua, -3);
+       lua_setmetatable(Lua, -2);
+       lua_settable(Lua, LUA_REGISTRYINDEX);
+       
+       /* This is the main table, and the metatable for Stratagus. */
        lua_newtable(Lua);
        lua_newtable(Lua);
-
        lua_pushstring(Lua, "__index");
        lua_pushcfunction(Lua, ScriptStratagusGetValue);
        lua_settable(Lua, -3);
        lua_pushstring(Lua, "__newindex");
        lua_pushcfunction(Lua, ScriptStratagusSetValue);
        lua_settable(Lua, -3);
-
        lua_setmetatable(Lua, -2);
-               
+       
+       /* Add all our namesspaces and stuff.*/
+       ScriptSpellInit();
        lua_settable(Lua, LUA_GLOBALSINDEX);
 }
 
@@ -1199,7 +1194,7 @@
        }
 
        fprintf(fd, "--- -----------------------------------------\n");
-       fprintf(fd, "--- $Id: script.c,v 1.157 2004/01/16 23:55:42 nobody_ Exp 
$\n");
+       fprintf(fd, "--- $Id: script.c,v 1.158 2004/01/17 22:23:26 nobody_ Exp 
$\n");
 
        fprintf(fd, "SetVideoResolution(%d, %d)\n", VideoWidth, VideoHeight);
        fprintf(fd, "SetGroupKeys(\"");
@@ -1235,7 +1230,7 @@
        }
 
        fprintf(fd, "--- -----------------------------------------\n");
-       fprintf(fd, "--- $Id: script.c,v 1.157 2004/01/16 23:55:42 nobody_ Exp 
$\n");
+       fprintf(fd, "--- $Id: script.c,v 1.158 2004/01/17 22:23:26 nobody_ Exp 
$\n");
 
        // Global options
        if (OriginalFogOfWar) {
@@ -1338,7 +1333,7 @@
        extern SCM oblistvar;
 
        CLprintf(file, "\n;;; -----------------------------------------\n");
-       CLprintf(file, ";;; MODULE: CCL $Id: script.c,v 1.157 2004/01/16 
23:55:42 nobody_ Exp $\n\n");
+       CLprintf(file, ";;; MODULE: CCL $Id: script.c,v 1.158 2004/01/17 
22:23:26 nobody_ Exp $\n\n");
 
        for (list = oblistvar; gh_list_p(list); list = gh_cdr(list)) {
                SCM sym;
Index: stratagus/src/stratagus/script_spell.c
diff -u stratagus/src/stratagus/script_spell.c:1.35 
stratagus/src/stratagus/script_spell.c:1.36
--- stratagus/src/stratagus/script_spell.c:1.35 Sat Jan 17 02:17:30 2004
+++ stratagus/src/stratagus/script_spell.c      Sun Jan 18 09:23:26 2004
@@ -10,7 +10,7 @@
 //
 /address@hidden script_spells.c        -       The spell script functions.. */
 //
-//     (c) Copyright 1998-2003 by Joris DAUPHIN
+//     (c) Copyright 1998-2003 by Joris Dauphin and Crestez Leonard
 //
 //      This program is free software; you can redistribute it and/or modify
 //      it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: script_spell.c,v 1.35 2004/01/16 15:17:30 wizzard Exp $
+//     $Id: script_spell.c,v 1.36 2004/01/17 22:23:26 nobody_ Exp $
 //@{
 
 /*----------------------------------------------------------------------------
@@ -590,11 +590,11 @@
        ++j;
        spell = SpellTypeByIdent(identname);
        if (spell != NULL) {
-                       DebugLevel0Fn("Redefining spell-type `%s'\n" _C_ 
identname);
+               DebugLevel0Fn("Redefining spell-type `%s'\n" _C_ identname);
                free(identname);
        } else {
-               SpellTypeTable = realloc(SpellTypeTable, (1 + SpellTypeCount) * 
sizeof(SpellType));
-               spell = &SpellTypeTable[SpellTypeCount++];
+               SpellTypeTable = realloc(SpellTypeTable, (1 + SpellTypeCount) * 
sizeof(SpellType*));
+               spell = SpellTypeTable[SpellTypeCount++] = 
malloc(sizeof(SpellType));
                memset(spell, 0, sizeof(SpellType));
                spell->Ident = SpellTypeCount - 1;
                spell->IdentName = identname;
@@ -1010,5 +1010,292 @@
        }
 #endif
 }
+
+#ifdef META_LUA
+
+//
+//     Functions directly acessible from lua. Placed in the stratagus 
namespace.
+//
+
+/**
+**  Create a new spell
+**
+**     @param l    Lua state, contains one string, the spell name.
+**
+**     @return The spell UserData in the stack.
+*/
+local int ScriptCreateSpell(lua_State* l)
+{
+       const char* name;
+       SpellType* spell;
+
+       if (lua_gettop(l) != 1) {
+               lua_pushstring(l, "incorrect argument");
+               lua_error(l);
+               return 0;
+       }
+       name = LuaToString(l, 1);
+
+       spell = SpellTypeByIdent(name);
+       if (spell != NULL) {
+               lua_pushstring(l, "Spell allready exists");
+               lua_error(l);
+               return 0;
+       } else {
+               SpellTypeTable = realloc(SpellTypeTable, (1 + SpellTypeCount) * 
sizeof(SpellType));
+               spell = &SpellTypeTable[SpellTypeCount++];
+               memset(spell, 0, sizeof(SpellType));
+               spell->Ident = SpellTypeCount - 1;
+               spell->IdentName = strdup(name);
+               spell->DependencyId = -1;
+               ScriptSpellCreateUserdata(l, spell);
+               return 1;
+       }
+}
+
+/**
+**     Get function for a spell userdata.
+**
+**     @param l        The Lua State.
+*/
+local int ScriptSpellGetValue(lua_State* l)
+{
+       const SpellType* spell;
+       const char* key;
+
+       spell = *((SpellType**)lua_touserdata(l, -2));
+       key = lua_tostring(l, -1);
+       DebugCheck((!spell) || (!key));
+       DebugLevel0Fn("%p->(%s)\n" _C_ spell _C_ key);
+
+       META_GET_STRING("DisplayName", spell->Name);
+       META_GET_STRING("Ident", spell->IdentName);
+       META_GET_INT("ManaCost", spell->ManaCost);
+       META_GET_INT("Range", spell->Range);
+       META_GET_BOOL("RepeatCast", spell->RepeatCast);
+       
+       //  FIXME: macro for enums.
+       if (!strcmp(key, "Target")) {
+               switch (spell->Target) {
+                       case TargetSelf:
+                               lua_pushstring(l, "TargetSelf");
+                               return 1;
+                       case TargetPosition:
+                               lua_pushstring(l, "TargetPosition");
+                               return 1;
+                       case TargetUnit:
+                               lua_pushstring(l, "TargetUnit");
+                               return 1;
+               }
+               // Somehow Target got a bad value
+               DebugCheck(1);
+       }
+
+       lua_pushfstring(l, "Field \"%s\" is innexistent or write-only (yes, we 
have those).\n", key);
+       lua_error(l);
+       return 0;
+}
+
+/**
+**     Get function for a spell userdata.
+**
+**     @param l        The Lua State.
+*/
+local int ScriptSpellSetValue(lua_State* l)
+{
+       SpellType* spell;
+       const char* key;
+       const char* val;
+
+       spell = *((SpellType**)lua_touserdata(l, -3));
+       key = LuaToString(l, -2);
+       DebugCheck((!spell) || (!key));
+       DebugLevel0Fn("%p->(%s)\n" _C_ spell _C_ key);
+
+       META_SET_STRING("DisplayName", spell->Name);
+       META_SET_STRING("Ident", spell->IdentName);
+       META_SET_INT("ManaCost", spell->ManaCost);
+       META_SET_INT("Range", spell->Range);
+       META_SET_BOOL("RepeatCast", spell->RepeatCast);
+
+       //  FIXME: macro for enums.
+       if (!strcmp(key, "Target")) {
+               val = LuaToString(l, -1);
+               if (!strcmp(val, "TargetSelf")) {
+                       spell->Target = TargetSelf;
+                       return 0;
+               } else if (!strcmp(val, "TargetPosition")) {
+                       spell->Target = TargetPosition;
+                       return 0;
+               } else if (!strcmp(val, "TargetUnit")) {
+                       spell->Target = TargetUnit;
+                       return 0;
+               }
+
+               lua_pushfstring(l, "Enum field \"%s\" can't receive value 
\"%s\"", key, val);
+               lua_error(l);
+               return 0;
+       }
+
+       lua_pushfstring(l, "Field \"%s\" is innexistent or read-only.\n", key);
+       lua_error(l);
+       return 0;
+}
+
+/**
+**     Garbage collection for a spell
+**
+**     @param l         The lua state.
+*/
+global int ScriptSpellGCollect(lua_State* l)
+{
+       SpellType* spell;
+
+       spell = *((SpellType**)lua_touserdata(l, -1));
+       DebugLevel0Fn("Collecting ScriptData for a %s at %p.\n" _C_ "SpellType" 
_C_ spell->ScriptData);
+/*     lua_pushstring(l, "StratagusReferences");
+       lua_gettable(l, LUA_REGISTRYINDEX);
+       lua_pushfstring(l, "%p", spell->ScriptData); //  FIXME: 64-bit?
+       lua_pushnil(l);
+       lua_settable(l, -3);
+       lua_settop(l, -2);
+       spell->ScriptData = 0;*/
+       return 0;
+}
+
+/**
+**  Create a lua table for a spell.
+**
+**     @param l      The lua state.
+**     @param spell  Point to the spell.
+*/
+global void ScriptSpellCreateUserdata(lua_State* l, SpellType* spell)
+{
+       char s[20];
+       int z = lua_gettop(l);
+       SpellType** sp;
+
+       if (spell->ScriptData) {
+               lua_pushstring(l, "StratagusReferences");
+               lua_gettable(l, LUA_REGISTRYINDEX);
+               sprintf(s, "%p", spell->ScriptData); // FIXME: 64-bit.
+               lua_pushstring(l, s);
+               lua_gettable(l, -2);
+               lua_remove(l, -2);
+               DebugLevel0Fn("Reusing ScriptData for a %s at %p.\n" _C_ 
"SpellType" _C_ lua_touserdata(l, -1));
+       } else {
+               // Create userdata.
+               sp = (SpellType**)lua_newuserdata(l, sizeof(SpellType));
+               *sp = spell;
+               spell->ScriptData = sp;
+               // Generate the metatable
+               lua_newtable(l);
+               lua_pushstring(l, "__index");
+               lua_pushcfunction(l, ScriptSpellGetValue);
+               lua_settable(l, -3);
+               lua_pushstring(l, "__newindex");
+               lua_pushcfunction(l, ScriptSpellSetValue);
+               lua_settable(l, -3);
+               lua_pushstring(l, "__gc");
+               lua_pushcfunction(l, ScriptSpellGCollect);
+               lua_settable(l, -3);
+               lua_setmetatable(l, -2);
+               // Add to weak ref table.
+               lua_pushstring(l, "StratagusReferences");
+               lua_gettable(l, LUA_REGISTRYINDEX);
+               sprintf(s, "%p", spell->ScriptData); // FIXME: 64-bit.
+               lua_pushstring(l, s);
+               lua_pushvalue(l, -3);
+               lua_settable(l, -3);
+               lua_remove(l, -1);
+               DebugLevel0Fn("Creating ScriptData for a %s at %p.\n" _C_ 
"SpellType" _C_ lua_touserdata(l, -1));
+       }
+       DebugLevel0Fn("%d -> %d\n" _C_ z _C_ lua_gettop(l));
+}
+
+/**
+**     Create a lua table for the spell array
+**
+**  @param l     The lua state
+*/
+global void ScriptSpellTableCreateUserdata(lua_State* l)
+{
+}
+
+/**
+**     Get function for the big spell list.
+**
+**     @param l        The Lua State.
+*/
+local int ScriptSpellNamespaceGetValue(lua_State* l)
+{
+       int i;
+       const char* key;
+       SpellType* spell;
+
+       //  Index with number
+       if (lua_isnumber(l, 2)) {
+               i = LuaToNumber(l, 2);
+               DebugLevel3Fn("(%d)\n" _C_ i);
+               if (i < 0 || i >= SpellTypeCount) {
+                       lua_pushstring(l, "Spell index out of range");
+                       lua_error(l);
+                       return 0;
+               }
+               ScriptSpellCreateUserdata(l, SpellTypeTable + i);
+               return 1;
+       }
+
+       //  Index with string. FIXME: hashtable? :)
+       key = LuaToString(l, 2);
+       DebugCheck(!key);
+       DebugLevel3Fn("(%s)\n" _C_ key);
+
+       META_GET_INT("n", SpellTypeCount);
+
+       spell = SpellTypeByIdent(key);
+       if (spell) {
+               ScriptSpellCreateUserdata(l, spell);
+               return 1;
+       }
+
+       lua_pushfstring(l, "Spell \"%s\" doesn't exist.\n", key);
+       lua_error(l);
+       return 0;
+}
+
+
+
+/**
+**     Initialize spell scripting. The main table is at -1
+**
+**     @param l   The lua state.
+*/
+global void ScriptSpellInit(void)
+{
+       // Create Stratagus.Spells namespace.
+       // No userdata, there's no data. And no finalizer
+       lua_pushstring(Lua, "Spells");
+       lua_newtable(Lua);
+
+       // Generate the metatable
+       lua_newtable(Lua);
+       lua_pushstring(Lua, "__index");
+       lua_pushcfunction(Lua, ScriptSpellNamespaceGetValue);
+       lua_settable(Lua, -3);
+       lua_pushstring(Lua, "__newindex");
+       lua_pushcfunction(Lua, ScriptSetValueBlock); // Read-Only
+       lua_settable(Lua, -3);
+       lua_setmetatable(Lua, -2);
+
+       // Add functions.
+       lua_pushstring(Lua, "Create");
+       lua_pushcfunction(Lua, ScriptCreateSpell);
+       lua_rawset(Lua, -3);
+
+       lua_rawset(Lua, -3);
+}
+
+#endif
 
 //@}
Index: stratagus/src/stratagus/spells.c
diff -u stratagus/src/stratagus/spells.c:1.137 
stratagus/src/stratagus/spells.c:1.138
--- stratagus/src/stratagus/spells.c:1.137      Sat Jan 17 05:17:21 2004
+++ stratagus/src/stratagus/spells.c    Sun Jan 18 09:23:26 2004
@@ -27,7 +27,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: spells.c,v 1.137 2004/01/16 18:17:21 nobody_ Exp $
+//     $Id: spells.c,v 1.138 2004/01/17 22:23:26 nobody_ Exp $
 
 /*
 **             And when we cast our final spell
@@ -72,7 +72,7 @@
 /**
 **             Define the names and effects of all im play available spells.
 */
-global SpellType* SpellTypeTable;
+global SpellType** SpellTypeTable;
 
 
 /// How many spell-types are available
@@ -1001,9 +1001,8 @@
        int id;
 
        DebugCheck(!ident);
-
        for (id = 0; id < SpellTypeCount; ++id) {
-               if (strcmp(SpellTypeTable[id].IdentName, ident) == 0) {
+               if (strcmp(SpellTypeTable[id]->IdentName, ident) == 0) {
                        return id;
                }
        }
@@ -1022,9 +1021,8 @@
        int id;
 
        DebugCheck(!ident);
-
        id = SpellIdByIdent(ident);
-       return (id == -1 ? NULL : &SpellTypeTable[id]);
+       return (id == -1 ? NULL : SpellTypeTable[id]);
 }
 
 /**
@@ -1037,7 +1035,7 @@
 
        value = LuaToString(l, -1);
        for (i = 0; i < SpellTypeCount; ++i) {
-               if (!strcmp(value, SpellTypeTable[i].IdentName)) {
+               if (!strcmp(value, SpellTypeTable[i]->IdentName)) {
                        return i;
                }
        }
@@ -1054,7 +1052,7 @@
 global SpellType* SpellTypeById(int id)
 {
        DebugCheck(!(0 <= id && id < SpellTypeCount));
-       return &SpellTypeTable[id];
+       return SpellTypeTable[id];
 }
 
 // ****************************************************************************
@@ -1073,7 +1071,7 @@
        DebugCheck(!player);
        DebugCheck(!(0 <= spellid && spellid < SpellTypeCount));
 
-       dependencyId = SpellTypeTable[spellid].DependencyId;
+       dependencyId = SpellTypeTable[spellid]->DependencyId;
 
        return dependencyId == -1 || UpgradeIdAllowed(player, dependencyId) == 
'R';
 }
@@ -1239,12 +1237,14 @@
 */
 void CleanSpells(void)
 {
+       int i;
        SpellType* spell;
        SpellActionType *act;
        SpellActionType *nextact;
 
        DebugLevel0("Cleaning spells.\n");
-       for (spell = SpellTypeTable; spell < SpellTypeTable + SpellTypeCount; 
++spell) {
+       for (i = 0; i < SpellTypeCount; ++i) {
+               spell = SpellTypeTable[i];
                free(spell->IdentName);
                free(spell->Name);
 
Index: stratagus/src/stratagus/stratagus.c
diff -u stratagus/src/stratagus/stratagus.c:1.249 
stratagus/src/stratagus/stratagus.c:1.250
--- stratagus/src/stratagus/stratagus.c:1.249   Sat Jan 17 10:55:43 2004
+++ stratagus/src/stratagus/stratagus.c Sun Jan 18 09:23:27 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: stratagus.c,v 1.249 2004/01/16 23:55:43 nobody_ Exp $
+//      $Id: stratagus.c,v 1.250 2004/01/17 22:23:27 nobody_ Exp $
 
 //@{
 
@@ -951,6 +951,9 @@
 #endif
 #ifdef USE_OPENGL
                "OPENGL "
+#endif
+#ifdef META_LUA
+               "META-LUA"
 #endif
        ;
 
Index: stratagus/src/unit/unittype.c
diff -u stratagus/src/unit/unittype.c:1.145 stratagus/src/unit/unittype.c:1.146
--- stratagus/src/unit/unittype.c:1.145 Sat Jan 17 18:26:10 2004
+++ stratagus/src/unit/unittype.c       Sun Jan 18 09:23:28 2004
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: unittype.c,v 1.145 2004/01/17 07:26:10 jsalmon3 Exp $
+//      $Id: unittype.c,v 1.146 2004/01/17 22:23:28 nobody_ Exp $
 
 //@{
 
@@ -1039,7 +1039,7 @@
                CLprintf(file, "  'can-cast-spell '( ");
                for (i = 0; i < SpellTypeCount; ++i) {
                        if (type->CanCastSpell[i]) {
-                               CLprintf(file, "%s ", 
SpellTypeTable[i].IdentName);
+                               CLprintf(file, "%s ", 
SpellTypeTable[i]->IdentName);
                        }
                }
                CLprintf(file, ")\n");
@@ -1187,7 +1187,7 @@
 //     char** sp;
 
        CLprintf(file, "\n--- -----------------------------------------\n");
-       CLprintf(file, "--- MODULE: unittypes $Id: unittype.c,v 1.145 
2004/01/17 07:26:10 jsalmon3 Exp $\n\n");
+       CLprintf(file, "--- MODULE: unittypes $Id: unittype.c,v 1.146 
2004/01/17 22:23:28 nobody_ Exp $\n\n");
 #if 0
        // Original number to internal unit-type name.
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]