[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src/clone ccl.c
From: |
Jimmy Salmon |
Subject: |
[Stratagus-CVS] stratagus/src/clone ccl.c |
Date: |
Wed, 19 Nov 2003 22:21:34 -0500 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: Jimmy Salmon <address@hidden> 03/11/19 22:21:33
Modified files:
src/clone : ccl.c
Log message:
Added Units
Patches:
Index: stratagus/src/clone/ccl.c
diff -u stratagus/src/clone/ccl.c:1.134 stratagus/src/clone/ccl.c:1.135
--- stratagus/src/clone/ccl.c:1.134 Wed Nov 19 21:27:29 2003
+++ stratagus/src/clone/ccl.c Wed Nov 19 22:21:33 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ccl.c,v 1.134 2003/11/20 02:27:29 jsalmon3 Exp $
+// $Id: ccl.c,v 1.135 2003/11/20 03:21:33 jsalmon3 Exp $
//@{
@@ -1466,6 +1466,51 @@
return gh_int2scm(destroyed);
}
#elif defined(USE_LUA)
+local int CclUnits(lua_State* l)
+{
+ Unit** slot;
+ int freeslots;
+ int destroyed;
+ int nullrefs;
+ int i;
+ static char buf[80];
+
+ if (lua_gettop(l) != 0) {
+ lua_pushstring(l, "incorrect argument");
+ lua_error(l);
+ }
+ i = 0;
+ slot = UnitSlotFree;
+ while (slot) { // count the free slots
+ ++i;
+ slot = (void*)*slot;
+ }
+ freeslots = i;
+
+ //
+ // Look how many slots are used
+ //
+ destroyed = nullrefs = 0;
+ for (slot = UnitSlots; slot < UnitSlots + MAX_UNIT_SLOTS; ++slot) {
+ if (*slot && (*slot < (Unit*)UnitSlots ||
+ *slot > (Unit*)(UnitSlots + MAX_UNIT_SLOTS))) {
+ if ((*slot)->Destroyed) {
+ ++destroyed;
+ } else if (!(*slot)->Refs) {
+ ++nullrefs;
+ }
+ }
+ }
+
+ sprintf(buf, "%d free, %d(%d) used, %d, destroyed, %d null",
+ freeslots, MAX_UNIT_SLOTS - 1 - freeslots, NumUnits, destroyed,
nullrefs);
+ SetStatusLine(buf);
+ fprintf(stderr, "%d free, %d(%d) used, %d destroyed, %d null\n",
+ freeslots, MAX_UNIT_SLOTS - 1 - freeslots, NumUnits, destroyed,
nullrefs);
+
+ lua_pushnumber(l, destroyed);
+ return 1;
+}
#endif
/**
@@ -1887,7 +1932,7 @@
lua_register(Lua, "LoadPud", CclLoadPud);
lua_register(Lua, "LoadMap", CclLoadMap);
-// lua_register(Lua, "Units", CclUnits);
+ lua_register(Lua, "Units", CclUnits);
lua_register(Lua, "WithSound", CclWithSound);
lua_register(Lua, "GetStratagusHomePath", CclGetStratagusHomePath);
@@ -1992,7 +2037,7 @@
}
fprintf(fd, ";;; -----------------------------------------\n");
- fprintf(fd, ";;; $Id: ccl.c,v 1.134 2003/11/20 02:27:29 jsalmon3 Exp $\n");
+ fprintf(fd, ";;; $Id: ccl.c,v 1.135 2003/11/20 03:21:33 jsalmon3 Exp $\n");
fprintf(fd, "(set-video-resolution! %d %d)\n", VideoWidth, VideoHeight);
@@ -2012,7 +2057,7 @@
}
fprintf(fd, "--[[\n");
- fprintf(fd, " $Id: ccl.c,v 1.134 2003/11/20 02:27:29 jsalmon3 Exp
$\n");
+ fprintf(fd, " $Id: ccl.c,v 1.135 2003/11/20 03:21:33 jsalmon3 Exp
$\n");
fprintf(fd, "]]\n");
fprintf(fd, "SetVideoResolution(%d, %d)\n", VideoWidth, VideoHeight);
@@ -2039,7 +2084,7 @@
}
fprintf(fd, ";;; -----------------------------------------\n");
- fprintf(fd, ";;; $Id: ccl.c,v 1.134 2003/11/20 02:27:29 jsalmon3 Exp $\n");
+ fprintf(fd, ";;; $Id: ccl.c,v 1.135 2003/11/20 03:21:33 jsalmon3 Exp $\n");
// Global options
if (OriginalFogOfWar) {
@@ -2120,7 +2165,7 @@
}
fprintf(fd, "--[[\n");
- fprintf(fd, " $Id: ccl.c,v 1.134 2003/11/20 02:27:29 jsalmon3 Exp
$\n");
+ fprintf(fd, " $Id: ccl.c,v 1.135 2003/11/20 03:21:33 jsalmon3 Exp
$\n");
fprintf(fd, "]]\n");
fprintf(fd, "SetVideoFullscreen(%s)\n", VideoFullScreen ? "true" :
"false");
@@ -2180,7 +2225,7 @@
extern SCM oblistvar;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: CCL $Id: ccl.c,v 1.134 2003/11/20 02:27:29
jsalmon3 Exp $\n\n");
+ CLprintf(file, ";;; MODULE: CCL $Id: ccl.c,v 1.135 2003/11/20 03:21:33
jsalmon3 Exp $\n\n");
for (list = oblistvar; gh_list_p(list); list = gh_cdr(list)) {
SCM sym;