stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus/src game/trigger.c unit/ccl_unittype.c


From: address@hidden
Subject: [Stratagus-CVS] stratagus/src game/trigger.c unit/ccl_unittype.c
Date: 16 Dec 2003 16:59:56 +1100

CVSROOT:        /home/strat
Module name:    stratagus
Changes by:      <address@hidden>       03/12/16 16:59:56

Modified files:
        src/game       : trigger.c 
        src/unit       : ccl_unittype.c 

Log message:
        Fixed lua bugs

Patches:
Index: stratagus/src/game/trigger.c
diff -u stratagus/src/game/trigger.c:1.49 stratagus/src/game/trigger.c:1.50
--- stratagus/src/game/trigger.c:1.49   Fri Dec 12 08:35:42 2003
+++ stratagus/src/game/trigger.c        Tue Dec 16 16:59:54 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: trigger.c,v 1.49 2003/12/11 21:35:42 jsalmon3 Exp $
+//     $Id: trigger.c,v 1.50 2003/12/16 05:59:54 jsalmon3 Exp $
 
 //@{
 
@@ -1854,6 +1854,7 @@
 
     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);
@@ -2291,7 +2292,7 @@
     int trigger;
 
     CLprintf(file, "\n;;; -----------------------------------------\n");
-    CLprintf(file, ";;; MODULE: trigger $Id: trigger.c,v 1.49 2003/12/11 
21:35:42 jsalmon3 Exp $\n\n");
+    CLprintf(file, ";;; MODULE: trigger $Id: trigger.c,v 1.50 2003/12/16 
05:59:54 jsalmon3 Exp $\n\n");
 
     i = 0;
     trigger = -1;
Index: stratagus/src/unit/ccl_unittype.c
diff -u stratagus/src/unit/ccl_unittype.c:1.124 
stratagus/src/unit/ccl_unittype.c:1.125
--- stratagus/src/unit/ccl_unittype.c:1.124     Tue Dec 16 08:10:40 2003
+++ stratagus/src/unit/ccl_unittype.c   Tue Dec 16 16:59:55 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_unittype.c,v 1.124 2003/12/15 21:10:40 jsalmon3 Exp $
+//     $Id: ccl_unittype.c,v 1.125 2003/12/16 05:59:55 jsalmon3 Exp $
 
 //@{
 
@@ -1142,73 +1142,81 @@
            type->Transporter = LuaToBoolean(l, -1);
        } else if (!strcmp(value, "Coward")) {
            type->Coward = LuaToBoolean(l, -1);
-       } else if (!strcmp(value, "CanGatherResource")) {
-           res = (ResourceInfo*)malloc(sizeof(ResourceInfo));
-           memset(res, 0, sizeof(ResourceInfo));
-           if (!lua_istable(l, -1)) {
-               lua_pushstring(l, "incorrect argument");
-               lua_error(l);
-           }
-           subargs = luaL_getn(l, -1);
-           for (k = 0; k < subargs; ++k) {
-               lua_rawgeti(l, -1, k + 1);
-               value = LuaToString(l, -1);
-               lua_pop(l, 1);
-               ++k;
-               if (!strcmp(value, "resource-id")) {
-                   lua_rawgeti(l, -1, k + 1);
-                   res->ResourceId = CclGetResourceByName(l);
-                   lua_pop(l, 1);
-                   type->ResInfo[res->ResourceId] = res;
-               } else if (!strcmp(value, "resource-step")) {
-                   lua_rawgeti(l, -1, k + 1);
-                   res->ResourceStep = LuaToNumber(l, -1);
-                   lua_pop(l, 1);
-               } else if (!strcmp(value, "final-resource")) {
-                   lua_rawgeti(l, -1, k + 1);
-                   res->FinalResource = CclGetResourceByName(l);
-                   lua_pop(l, 1);
-               } else if (!strcmp(value, "wait-at-resource")) {
-                   lua_rawgeti(l, -1, k + 1);
-                   res->WaitAtResource = LuaToNumber(l, -1);
-                   lua_pop(l, 1);
-               } else if (!strcmp(value, "wait-at-depot")) {
-                   lua_rawgeti(l, -1, k + 1);
-                   res->WaitAtDepot = LuaToNumber(l, -1);
-                   lua_pop(l, 1);
-               } else if (!strcmp(value, "resource-capacity")) {
-                   lua_rawgeti(l, -1, k + 1);
-                   res->ResourceCapacity = LuaToNumber(l, -1);
-                   lua_pop(l, 1);
-               } else if (!strcmp(value, "terrain-harvester")) {
-                   res->TerrainHarvester = 1;
-                   --k;
-               } else if (!strcmp(value, "lose-resources")) {
-                   res->LoseResources = 1;
-                   --k;
-               } else if (!strcmp(value, "harvest-from-outside")) {
-                   res->HarvestFromOutside = 1;
-                   --k;
-               } else if (!strcmp(value, "file-when-empty")) {
-                   lua_rawgeti(l, -1, k + 1);
-                   res->FileWhenEmpty = strdup(LuaToString(l, -1));
-                   lua_pop(l, 1);
-               } else if (!strcmp(value, "file-when-loaded")) {
+       } else if (!strcmp(value, "CanGatherResources")) {
+           int args;
+           int j;
+
+           args = luaL_getn(l, -1);
+           for (j = 0; j < args; ++j) {
+               lua_rawgeti(l, -1, j + 1);
+               res = (ResourceInfo*)malloc(sizeof(ResourceInfo));
+               memset(res, 0, sizeof(ResourceInfo));
+               if (!lua_istable(l, -1)) {
+                   lua_pushstring(l, "incorrect argument");
+                   lua_error(l);
+               }
+               subargs = luaL_getn(l, -1);
+               for (k = 0; k < subargs; ++k) {
                    lua_rawgeti(l, -1, k + 1);
-                   res->FileWhenLoaded = strdup(LuaToString(l, -1));
+                   value = LuaToString(l, -1);
                    lua_pop(l, 1);
-               } else {
-                  printf("\n%s\n",type->Name);
-                  lua_pushfstring(l, "Unsupported tag: %s", value);
-                  lua_error(l);
-                  DebugCheck(1);
+                   ++k;
+                   if (!strcmp(value, "resource-id")) {
+                       lua_rawgeti(l, -1, k + 1);
+                       res->ResourceId = CclGetResourceByName(l);
+                       lua_pop(l, 1);
+                       type->ResInfo[res->ResourceId] = res;
+                   } else if (!strcmp(value, "resource-step")) {
+                       lua_rawgeti(l, -1, k + 1);
+                       res->ResourceStep = LuaToNumber(l, -1);
+                       lua_pop(l, 1);
+                   } else if (!strcmp(value, "final-resource")) {
+                       lua_rawgeti(l, -1, k + 1);
+                       res->FinalResource = CclGetResourceByName(l);
+                       lua_pop(l, 1);
+                   } else if (!strcmp(value, "wait-at-resource")) {
+                       lua_rawgeti(l, -1, k + 1);
+                       res->WaitAtResource = LuaToNumber(l, -1);
+                       lua_pop(l, 1);
+                   } else if (!strcmp(value, "wait-at-depot")) {
+                       lua_rawgeti(l, -1, k + 1);
+                       res->WaitAtDepot = LuaToNumber(l, -1);
+                       lua_pop(l, 1);
+                   } else if (!strcmp(value, "resource-capacity")) {
+                       lua_rawgeti(l, -1, k + 1);
+                       res->ResourceCapacity = LuaToNumber(l, -1);
+                       lua_pop(l, 1);
+                   } else if (!strcmp(value, "terrain-harvester")) {
+                       res->TerrainHarvester = 1;
+                       --k;
+                   } else if (!strcmp(value, "lose-resources")) {
+                       res->LoseResources = 1;
+                       --k;
+                   } else if (!strcmp(value, "harvest-from-outside")) {
+                       res->HarvestFromOutside = 1;
+                       --k;
+                   } else if (!strcmp(value, "file-when-empty")) {
+                       lua_rawgeti(l, -1, k + 1);
+                       res->FileWhenEmpty = strdup(LuaToString(l, -1));
+                       lua_pop(l, 1);
+                   } else if (!strcmp(value, "file-when-loaded")) {
+                       lua_rawgeti(l, -1, k + 1);
+                       res->FileWhenLoaded = strdup(LuaToString(l, -1));
+                       lua_pop(l, 1);
+                   } else {
+                      printf("\n%s\n",type->Name);
+                      lua_pushfstring(l, "Unsupported tag: %s", value);
+                      lua_error(l);
+                      DebugCheck(1);
+                   }
+               }
+               if (!res->FinalResource) {
+                   res->FinalResource = res->ResourceId;
                }
+               DebugCheck(!res->ResourceId);
+               lua_pop(l, 1);
            }
            type->Harvester = 1;
-           if (!res->FinalResource) {
-               res->FinalResource = res->ResourceId;
-           }
-           DebugCheck(!res->ResourceId);
        } else if (!strcmp(value, "GivesResource")) {
            lua_pushvalue(l, -1);
            type->GivesResource = CclGetResourceByName(l);




reply via email to

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