Fix to make soldier continue towards destination if previous path ended with a special move

Re-integrated LUA and console.  Still many things to finish though.


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1048 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Overhaul
2007-07-14 04:25:07 +00:00
parent 0c6b247cf5
commit 99e45d697e
6 changed files with 74 additions and 13 deletions
+1 -1
View File
@@ -14,6 +14,6 @@ typedef struct {
} LuaAttrib;
void InitializeLua( );
void EvalLua (STR8 buff) ;
int EvalLua (const wchar_t* buff) ; // The return value is whether to clear the input line, not whether the call succeeded.
void ShutdownLua( );
+25 -3
View File
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <string.h>
#include <iostream>
#include "Lua Interpreter.h"
#include "lwstring.h"
@@ -317,14 +318,35 @@ void InitializeLua( )
lua_setglobal( L, "Soldiers" );
}
void EvalLua (STR8 buff) {
int EvalLua (const wchar_t* buff) {
int error;
error = luaL_loadbuffer(L, buff, strlen(buff), "line") ||
int newlen;
STR8 newstr = NULL;
// Since we get wide chars coming in, we need to convert to UTF8
newlen = WideCharToMultiByte( CP_UTF8, 0, buff, -1, newstr, 0, NULL, NULL);
newstr = (STR8) MemAlloc( newlen);
WideCharToMultiByte( CP_UTF8, 0, buff, -1, newstr, newlen, NULL, NULL);
error = luaL_loadbuffer(L, newstr, newlen-1, "line") ||
lua_pcall(L, 0, 0, 0);
MemFree( newstr);
if (error) {
fprintf(stderr, "%s", lua_tostring(L, -1));
const char *error = lua_tostring(L, -1);
int len = strlen( error);
if (len >= 7 && !strcmp( error + len - 7, "'<eof>'"))
{
lua_pop(L, 1); /* pop error message from the stack */
return FALSE;
}
cout << lua_tostring(L, -1) << endl;
lua_pop(L, 1); /* pop error message from the stack */
return TRUE;
}
return TRUE;
}
void ShutdownLua( ) {