From deeea15889dd9a00ff24266dfcba190a11fcf87a Mon Sep 17 00:00:00 2001 From: Allanis <allanis@saracraft.net> Date: Wed, 22 Jan 2014 15:38:19 +0000 Subject: [PATCH] [Change] Only have ai land once. --- scripts/ai/include/basic.lua | 8 ++++++++ src/land.c | 4 +++- src/lfile.c | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/ai/include/basic.lua b/scripts/ai/include/basic.lua index 30c8eee..95a327b 100644 --- a/scripts/ai/include/basic.lua +++ b/scripts/ai/include/basic.lua @@ -9,6 +9,12 @@ -- Attempt to land on a planet. --]] function land() + -- Only want to land once, prevents guys fomr never leaving. + if mem.landed then + ai.poptask() + return + end + target = mem.land dir = ai.face(target) dist = ai.dist(target) @@ -45,6 +51,7 @@ function landwait() ai.pushtask(0, "land") elseif ai.timeup(0) then + mem.landed = true -- Mark as landed so they don't spend time forever floating around. ai.poptask() -- Ready to do whatever we were doing before. end end @@ -55,6 +62,7 @@ end function runaway() target = ai.target() + -- Target must exist. if not ai.exists(target) then ai.poptask() return diff --git a/src/land.c b/src/land.c index 41ce996..6f54095 100644 --- a/src/land.c +++ b/src/land.c @@ -1273,8 +1273,10 @@ void land_cleanup(void) { land_visited = 0; /* Destroy window. */ - if(land_wid > 0) + if(land_wid > 0) { window_destroy(land_wid); + land_wid = 0; + } /* Clean up possible stray graphic. */ if(gfx_exterior != NULL) { diff --git a/src/lfile.c b/src/lfile.c index 83323fe..b73be31 100644 --- a/src/lfile.c +++ b/src/lfile.c @@ -35,10 +35,10 @@ char* lfile_basePath(void) { if(lephisto_base[0] == '\0') { #ifdef LINUX home = getenv("HOME"); + snprintf(lephisto_base, PATH_MAX, "%s/.lephisto/", home); #else #error "Needs implentation." #endif - snprintf(lephisto_base, PATH_MAX, "%s/.lephisto/", home); } return lephisto_base;