[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src include/stratagus.h missile/scrip...
From: |
address@hidden |
Subject: |
[Stratagus-CVS] stratagus/src include/stratagus.h missile/scrip... |
Date: |
18 Jan 2004 11:52:20 +1100 |
CVSROOT: /home/strat
Module name: stratagus
Changes by: <address@hidden> 04/01/18 11:52:20
Modified files:
src/include : stratagus.h
src/missile : script_missile.c
src/stratagus : script_spell.c
Log message:
more META_LUA work.
Patches:
Index: stratagus/src/include/stratagus.h
diff -u stratagus/src/include/stratagus.h:1.37
stratagus/src/include/stratagus.h:1.38
--- stratagus/src/include/stratagus.h:1.37 Sat Jan 17 10:55:42 2004
+++ stratagus/src/include/stratagus.h Sun Jan 18 11:52:18 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: stratagus.h,v 1.37 2004/01/16 23:55:42 nobody_ Exp $
+// $Id: stratagus.h,v 1.38 2004/01/18 00:52:18 nobody_ Exp $
#ifndef __STRATAGUS_H__
#define __STRATAGUS_H__
@@ -44,7 +44,7 @@
#define NEW_UNIT_CACHE
// New Lua scripting.
-// #define META_LUA
+//#define META_LUA
//
// Default speed for many things, set it higher for faster
actions.
Index: stratagus/src/missile/script_missile.c
diff -u stratagus/src/missile/script_missile.c:1.56
stratagus/src/missile/script_missile.c:1.57
--- stratagus/src/missile/script_missile.c:1.56 Sat Jan 17 02:17:27 2004
+++ stratagus/src/missile/script_missile.c Sun Jan 18 11:52:18 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: script_missile.c,v 1.56 2004/01/16 15:17:27 wizzard Exp $
+// $Id: script_missile.c,v 1.57 2004/01/18 00:52:18 nobody_ Exp $
//@{
@@ -424,5 +424,11 @@
lua_register(Lua, "Missile", CclMissile);
lua_register(Lua, "DefineBurningBuilding", CclDefineBurningBuilding);
}
+
+#ifdef META_LUA
+/**
+** Register
+*/
+#endif
//@}
Index: stratagus/src/stratagus/script_spell.c
diff -u stratagus/src/stratagus/script_spell.c:1.36
stratagus/src/stratagus/script_spell.c:1.37
--- stratagus/src/stratagus/script_spell.c:1.36 Sun Jan 18 09:23:26 2004
+++ stratagus/src/stratagus/script_spell.c Sun Jan 18 11:52:19 2004
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: script_spell.c,v 1.36 2004/01/17 22:23:26 nobody_ Exp $
+// $Id: script_spell.c,v 1.37 2004/01/18 00:52:19 nobody_ Exp $
//@{
/*----------------------------------------------------------------------------
@@ -1042,8 +1042,8 @@
lua_error(l);
return 0;
} 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 = strdup(name);
@@ -1066,7 +1066,7 @@
spell = *((SpellType**)lua_touserdata(l, -2));
key = lua_tostring(l, -1);
DebugCheck((!spell) || (!key));
- DebugLevel0Fn("%p->(%s)\n" _C_ spell _C_ key);
+ DebugLevel3Fn("%p->(%s)\n" _C_ spell _C_ key);
META_GET_STRING("DisplayName", spell->Name);
META_GET_STRING("Ident", spell->IdentName);
@@ -1110,10 +1110,9 @@
spell = *((SpellType**)lua_touserdata(l, -3));
key = LuaToString(l, -2);
DebugCheck((!spell) || (!key));
- DebugLevel0Fn("%p->(%s)\n" _C_ spell _C_ key);
+ DebugLevel3Fn("%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);
@@ -1150,16 +1149,18 @@
global int ScriptSpellGCollect(lua_State* l)
{
SpellType* spell;
+ char s[20];
spell = *((SpellType**)lua_touserdata(l, -1));
- DebugLevel0Fn("Collecting ScriptData for a %s at %p.\n" _C_ "SpellType"
_C_ spell->ScriptData);
-/* lua_pushstring(l, "StratagusReferences");
+ DebugLevel3Fn("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?
+ sprintf(s, "%p", spell->ScriptData); // FIXME: 64-bit.
+ lua_pushstring(l, s);
lua_pushnil(l);
lua_settable(l, -3);
lua_settop(l, -2);
- spell->ScriptData = 0;*/
+ spell->ScriptData = 0;
return 0;
}
@@ -1172,7 +1173,6 @@
global void ScriptSpellCreateUserdata(lua_State* l, SpellType* spell)
{
char s[20];
- int z = lua_gettop(l);
SpellType** sp;
if (spell->ScriptData) {
@@ -1182,7 +1182,7 @@
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));
+ DebugLevel3Fn("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));
@@ -1208,18 +1208,8 @@
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));
+ DebugLevel3Fn("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)
-{
}
/**
@@ -1242,7 +1232,7 @@
lua_error(l);
return 0;
}
- ScriptSpellCreateUserdata(l, SpellTypeTable + i);
+ ScriptSpellCreateUserdata(l, SpellTypeTable[i]);
return 1;
}
@@ -1263,8 +1253,6 @@
lua_error(l);
return 0;
}
-
-
/**
** Initialize spell scripting. The main table is at -1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src include/stratagus.h missile/scrip...,
address@hidden <=