stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus/src/ai ai_local.h new_ai.c


From: address@hidden
Subject: [Stratagus-CVS] stratagus/src/ai ai_local.h new_ai.c
Date: 16 Dec 2003 16:57:49 +1100

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

Modified files:
        src/ai         : ai_local.h new_ai.c 

Log message:
        Updates to lua

Patches:
Index: stratagus/src/ai/ai_local.h
diff -u stratagus/src/ai/ai_local.h:1.49 stratagus/src/ai/ai_local.h:1.50
--- stratagus/src/ai/ai_local.h:1.49    Sun Dec 14 20:45:38 2003
+++ stratagus/src/ai/ai_local.h Tue Dec 16 16:57:48 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: ai_local.h,v 1.49 2003/12/14 09:45:38 wizzard Exp $
+//      $Id: ai_local.h,v 1.50 2003/12/16 05:57:48 jsalmon3 Exp $
 
 #ifndef __AI_LOCAL_H__
 #define __AI_LOCAL_H__
@@ -68,8 +68,9 @@
 #endif
 
 #if defined(USE_GUILE) || defined(USE_SIOD)
-       SCM Script; /// Main script (gc-protected!)
+       SCM Script;   /// Main script (gc-protected!)
 #elif defined(USE_LUA)
+       char* Script; /// Main script
 #endif
 };
 
@@ -185,6 +186,7 @@
 #if defined(USE_GUILE) || defined(USE_SIOD)
        SCM           Script;      /// Script executed
 #elif defined(USE_LUA)
+       char*         Script;      /// Script executed
 #endif
        unsigned long SleepCycles; /// Cycles to sleep
        char          ident[10];   /// Debugging !
Index: stratagus/src/ai/new_ai.c
diff -u stratagus/src/ai/new_ai.c:1.99 stratagus/src/ai/new_ai.c:1.100
--- stratagus/src/ai/new_ai.c:1.99      Sat Dec 13 17:06:10 2003
+++ stratagus/src/ai/new_ai.c   Tue Dec 16 16:57:48 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//      $Id: new_ai.c,v 1.99 2003/12/13 06:06:10 jsalmon3 Exp $
+//      $Id: new_ai.c,v 1.100 2003/12/16 05:57:48 jsalmon3 Exp $
 
 
 //@{
@@ -273,12 +273,42 @@
                CclGcProtectedAssign(&AiScript->Script, 
gh_cdr(AiScript->Script));
            }
 
-           if ((gh_null_p(AiScript->Script)) && (AiScript->ownForce)) {
+           if (gh_null_p(AiScript->Script) && AiScript->ownForce) {
                AiEraseForce(AiScript->ownForce);
            }
        }
     }
 #elif defined(USE_LUA)
+    int i;
+    PlayerAi* pai;
+
+    pai = AiPlayer;
+
+    // Debugging
+    if (pai->ScriptDebug) {
+       debugForces();
+    }
+
+    for (i = 0; i < AI_MAX_RUNNING_SCRIPTS; ++i) {
+       AiScript = pai->Scripts + i;
+       if (AiScript->Script) {
+           /*DebugLevel3Fn("%d.%d (%12s) @ %3d.%3d :" _C_
+               pai->Player->Player _C_ i _C_ AiScript->ident _C_
+               AiScript->HotSpotX _C_ AiScript->HotSpotY);
+           gh_display(AiScript->Script);
+           gh_newline();*/
+
+           lua_pushstring(Lua, "_ai_scripts_");
+           lua_gettable(Lua, LUA_GLOBALSINDEX);
+           lua_pushstring(Lua, AiScript->Script);
+           lua_rawget(Lua, 1);
+           LuaCall(0, 1);
+
+           if (/*gh_null_p(AiScript->Script)*/0 && AiScript->ownForce) {
+               AiEraseForce(AiScript->ownForce);
+           }
+       }
+    }
 #endif
 }
 
@@ -787,7 +817,7 @@
 {
     CLprintf(file, "\n;;; -----------------------------------------\n");
     CLprintf(file,
-       ";;; MODULE: AI $Id: new_ai.c,v 1.99 2003/12/13 06:06:10 jsalmon3 Exp 
$\n\n");
+       ";;; MODULE: AI $Id: new_ai.c,v 1.100 2003/12/16 05:57:48 jsalmon3 Exp 
$\n\n");
 
     SaveAiTypesWcName(file);
     SaveAiHelper(file);
@@ -831,6 +861,7 @@
        pai->Scripts[i].Script = NIL;
        CclGcProtect(&pai->Scripts[i].Script);
 #elif defined(USE_LUA)
+       pai->Scripts[i].Script = NULL;
 #endif
        snprintf(pai->Scripts[i].ident, 10, "Empty");
     }
@@ -901,6 +932,7 @@
 #if defined(USE_GUILE) || defined(USE_SIOD)
     CclGcProtectedAssign(&pai->Scripts[0].Script, ait->Script);
 #elif defined(USE_LUA)
+    pai->Scripts[0].Script = ait->Script;
 #endif
 
     pai->Collect[TimeCost] = 0;
@@ -1012,6 +1044,7 @@
 #if defined(USE_GUILE) || defined(USE_SIOD)
        CclGcUnprotect(&aitype->Script);
 #elif defined(USE_LUA)
+       free(aitype->Script);
 #endif
 
        temp = aitype->Next;




reply via email to

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