stratagus-cvs
[Top][All Lists]
Advanced

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

[Stratagus-CVS] stratagus/src/pathfinder ccl_pathfinder.c


From: Jimmy Salmon
Subject: [Stratagus-CVS] stratagus/src/pathfinder ccl_pathfinder.c
Date: Wed, 12 Nov 2003 15:25:42 -0500

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Jimmy Salmon <address@hidden>   03/11/12 15:25:42

Modified files:
        src/pathfinder : ccl_pathfinder.c 

Log message:
        Started lua support

Patches:
Index: stratagus/src/pathfinder/ccl_pathfinder.c
diff -u stratagus/src/pathfinder/ccl_pathfinder.c:1.22 
stratagus/src/pathfinder/ccl_pathfinder.c:1.23
--- stratagus/src/pathfinder/ccl_pathfinder.c:1.22      Sun Sep 14 02:53:08 2003
+++ stratagus/src/pathfinder/ccl_pathfinder.c   Wed Nov 12 15:25:41 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_pathfinder.c,v 1.22 2003/09/14 06:53:08 mr-russ Exp $
+//     $Id: ccl_pathfinder.c,v 1.23 2003/11/12 20:25:41 jsalmon3 Exp $
 
 //@{
 
@@ -55,8 +55,9 @@
 ----------------------------------------------------------------------------*/
 
 /**
- **    Enable a*.
+**     Enable a*.
 */
+#if defined(USE_GUILE) || defined(USE_SIOD)
 local SCM CclAStar(SCM list)
 {
     SCM value;
@@ -103,6 +104,73 @@
                                          
     return SCM_UNSPECIFIED;
 }
+#elif defined(USE_LUA)
+local int CclAStar(lua_State* l)
+{
+    const char* value;
+    int i;
+    int j;
+    int args;
+
+    args = lua_gettop(l);
+    for (j = 0; j < args; ++j) {
+       if (!lua_isstring(l, j + 1)) {
+           lua_pushstring(l, "incorrect argument");
+           lua_error(l);
+       }
+       value = lua_tostring(l, j + 1);
+       if (!strcmp(value, "fixed-unit-cost")) {
+           ++j;
+           if (!lua_isnumber(l, j + 1)) {
+               lua_pushstring(l, "incorrect argument");
+               lua_error(l);
+           }
+           i = lua_tonumber(l, j + 1);
+           if (i <= 3) {
+               PrintFunction();
+               fprintf(stdout, "Fixed unit crossing cost must be strictly > 
3\n");
+           } else {
+               AStarFixedUnitCrossingCost = i;
+           }
+       } else if (!strcmp(value, "moving-unit-cost")) {
+           ++j;
+           if (!lua_isnumber(l, j + 1)) {
+               lua_pushstring(l, "incorrect argument");
+               lua_error(l);
+           }
+           i = lua_tonumber(l, j + 1);
+           if (i <= 3) {
+               PrintFunction();
+               fprintf(stdout, "Moving unit crossing cost must be strictly > 
3\n");
+           } else {
+               AStarMovingUnitCrossingCost = i;
+           }
+       } else if (!strcmp(value, "know-unseen-terrain")) {
+           AStarKnowUnknown = 1;
+       } else if (!strcmp(value, "dont-know-unseen-terrain")) {
+           AStarKnowUnknown = 0;
+       } else if (!strcmp(value, "unseen-terrain-cost")) {
+           ++j;
+           if (!lua_isnumber(l, j + 1)) {
+               lua_pushstring(l, "incorrect argument");
+               lua_error(l);
+           }
+           i = lua_tonumber(l, j + 1);
+           if (i < 0) {
+               PrintFunction();
+               fprintf(stdout, "Unseen Terrain Cost must be non-negative\n");
+           } else {
+               AStarUnknownTerrainCost = i;
+           }
+       } else {
+           lua_pushfstring(l, "Unsupported tag: %s", value);
+           lua_error(l);
+       }
+    }
+
+    return 0;
+}
+#endif
 
 #ifdef HIERARCHIC_PATHFINDER
 local SCM CclPfHierShowRegIds (SCM flag)
@@ -117,6 +185,7 @@
     return SCM_UNSPECIFIED;
 }
 #else
+#if defined(USE_GUILE) || defined(USE_SIOD)
 local SCM CclPfHierShowRegIds (SCM flag __attribute__((unused)))
 {
     return SCM_UNSPECIFIED;
@@ -126,6 +195,8 @@
 {
     return SCM_UNSPECIFIED;
 }
+#elif defined(USE_LUA)
+#endif
 #endif
 
 
@@ -134,9 +205,15 @@
 */
 global void PathfinderCclRegister(void)
 {
+#if defined(USE_GUILE) || defined(USE_SIOD)
     gh_new_procedureN("a-star",CclAStar);
     gh_new_procedure1_0 ("pf-show-regids!", CclPfHierShowRegIds);
     gh_new_procedure1_0 ("pf-show-groupids!", CclPfHierShowGroupIds);
+#elif defined(USE_LUA)
+    lua_register(Lua, "AStar",CclAStar);
+//    lua_register(Lua, "PfShowRegids", CclPfHierShowRegIds);
+//    lua_register(Lua, "PfShowGroupids", CclPfHierShowGroupIds);
+#endif
 }
 
 //@}




reply via email to

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