[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src/clone groups.c
From: |
Jimmy Salmon |
Subject: |
[Stratagus-CVS] stratagus/src/clone groups.c |
Date: |
Tue, 02 Dec 2003 19:35:46 -0500 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: Jimmy Salmon <address@hidden> 03/12/02 19:35:46
Modified files:
src/clone : groups.c
Log message:
Added lua functions
Patches:
Index: stratagus/src/clone/groups.c
diff -u stratagus/src/clone/groups.c:1.26 stratagus/src/clone/groups.c:1.27
--- stratagus/src/clone/groups.c:1.26 Wed Nov 12 15:40:24 2003
+++ stratagus/src/clone/groups.c Tue Dec 2 19:35:46 2003
@@ -10,7 +10,8 @@
//
/address@hidden groups.c - The units' groups handling. */
//
-// (c) Copyright 1999-2003 by Patrice Fortier and Lutz Sammer
+// (c) Copyright 1999-2003 by Patrice Fortier, Lutz Sammer,
+// and Jimmy Salmon
//
// 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 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: groups.c,v 1.26 2003/11/12 20:40:24 jsalmon3 Exp $
+// $Id: groups.c,v 1.27 2003/12/03 00:35:46 jsalmon3 Exp $
//@{
@@ -95,7 +96,7 @@
char* ref;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: groups $Id: groups.c,v 1.26 2003/11/12
20:40:24 jsalmon3 Exp $\n\n");
+ CLprintf(file, ";;; MODULE: groups $Id: groups.c,v 1.27 2003/12/03
00:35:46 jsalmon3 Exp $\n\n");
for (g = 0; g < NUM_GROUPS; ++g) {
CLprintf(file, "(group %d %d '(", g, Groups[g].NumUnits);
@@ -117,7 +118,7 @@
for (i = 0; i < NUM_GROUPS; ++i) {
free(Groups[i].Units);
- memset(&Groups[i], 0, sizeof(Groups[i]));
+ memset(&Groups[i], 0, sizeof(Groups[i]));
}
}
@@ -177,7 +178,7 @@
group = &Groups[num];
for (i = 0; group->NumUnits < MaxSelectable && i < nunits; ++i) {
- group->Units[group->NumUnits++] = units[i];
+ group->Units[group->NumUnits++] = units[i];
units[i]->GroupId |= (1 << num);
}
}
@@ -260,6 +261,33 @@
return SCM_UNSPECIFIED;
}
#elif defined(USE_LUA)
+local int CclGroup(lua_State* l)
+{
+ int i;
+ UnitGroup* grp;
+ int args;
+ int j;
+
+ if (lua_gettop(l) != 3) {
+ lua_pushstring(l, "incorrect argument");
+ lua_error(l);
+ }
+
+ grp = &Groups[(int)LuaToNumber(l, 1)];
+ grp->NumUnits = LuaToNumber(l, 2);
+ i = 0;
+ args = luaL_getn(l, 3);
+ for (j = 0; j < args; ++j) {
+ const char* str;
+
+ lua_rawgeti(l, 3, j + 1);
+ str = LuaToString(l, -1);
+ lua_pop(l, 1);
+ grp->Units[i++] = (Unit*)strtol(str + 1, NULL, 16);
+ }
+
+ return 0;
+}
#endif
/**
@@ -269,6 +297,8 @@
{
#if defined(USE_GUILE) || defined(USE_SIOD)
gh_new_procedure3_0("group", CclGroup);
+#elif defined(USE_LUA)
+ lua_register(Lua, "Group", CclGroup);
#endif
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src/clone groups.c,
Jimmy Salmon <=