# HG changeset patch
# User Ritor1
# Date 1385666208 -21600
# Node ID bf89a2e9eea19d61b2b0df2084ae2425b33b58fa
# Parent 73ee77d482f8eb7042c10df50e75c6cf8c9a8c7a
LuaClass.h
diff -r 73ee77d482f8 -r bf89a2e9eea1 Build/Visual Studio 2012/World of Might and Magic.vcxproj
--- a/Build/Visual Studio 2012/World of Might and Magic.vcxproj Thu Nov 28 21:49:06 2013 +0600
+++ b/Build/Visual Studio 2012/World of Might and Magic.vcxproj Fri Nov 29 01:16:48 2013 +0600
@@ -325,6 +325,7 @@
+
diff -r 73ee77d482f8 -r bf89a2e9eea1 Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters
--- a/Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters Thu Nov 28 21:49:06 2013 +0600
+++ b/Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters Fri Nov 29 01:16:48 2013 +0600
@@ -593,6 +593,7 @@
+
diff -r 73ee77d482f8 -r bf89a2e9eea1 Events.cpp
--- a/Events.cpp Thu Nov 28 21:49:06 2013 +0600
+++ b/Events.cpp Fri Nov 29 01:16:48 2013 +0600
@@ -33,6 +33,7 @@
#include "Log.h"
#include "MM7.h"
#include "Level/Decoration.h"
+#include "LuaClass.h"
@@ -428,6 +429,11 @@
v133 = 0;
EvtTargetObj = targetObj;
dword_5B65C4_cancelEventProcessing = 0;
+ if ( uEventID == 114 )
+ {
+ if ( pMM_lua->DoFile("out01.lua") )
+ Log::Warning(L"Error opening out01.lua\n");
+ }
if ( !uEventID )
{
if ( !GameUI_Footer_TimeLeft )
diff -r 73ee77d482f8 -r bf89a2e9eea1 mm7_2.cpp
--- a/mm7_2.cpp Thu Nov 28 21:49:06 2013 +0600
+++ b/mm7_2.cpp Fri Nov 29 01:16:48 2013 +0600
@@ -69,13 +69,15 @@
#include "Level/Decoration.h"
#include "lib/lua/lua.h"
-#include "TestClass.h"
+#include "LuaClass.h"
int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam);
int __stdcall InsertMM7CDDialogFunc(HWND hDlg, int a2, __int16 a3, int a4);
bool __fastcall FindMM7CD(HWND hWnd, char *pCDDrive);
bool __fastcall Initialize(HINSTANCE hInst, char *pCmdLine);
+class LuaVM *pMM_lua;
+
//----- (004A1780) mm6_chinese---------------------------------------------
__int64 fixpoint_div(int a1, int a2)
{
@@ -4310,21 +4312,6 @@
-const char *GetScriptFileLocation(const char *script_name)
-{
- static char buf[2048];
- strcpy(buf, "Data/scripts/lua/core/");
- strcat(buf, script_name);
- return buf;
-}
-
-
-extern "C" int luaopen_UIControl(lua_State *L); // declare the wrapped module
-void LoadLuaSWIGLibraries(lua_State *L)
-{
- luaopen_UIControl(L);
-}
-
//----- (00462C94) --------------------------------------------------------
bool MM_Main(const wchar_t *pCmdLine)
{
@@ -4333,21 +4320,8 @@
char test[1024];
sprintfex(test, "^Pi[%s]: знахар^R[ь;ка;]", "Золтан");
- char dir[256];
- GetCurrentDirectoryA(256, dir);
-
- lua_State *L = luaL_newstate();
- if ( L == NULL )
- Log::Warning(L"Error creating Lua context.\n");
- luaL_openlibs(L);
- if ( luaL_dofile(L,GetScriptFileLocation("script.lua")))
- Log::Warning(L"Error opening script.lua\n");
-
- LoadLuaSWIGLibraries(L);
-
- if (luaL_dofile(L,GetScriptFileLocation("UIControl.lua")))
- Log::Warning(L"unable to load UIControl.lua\n");
- //lua_close(l);
+ pMM_lua = new LuaVM;
+ pMM_lua->Initialize();
bool bNoMargareth = false;
if (pCmdLine && *pCmdLine)
@@ -4527,7 +4501,7 @@
AIL_redbook_play(pAudioPlayer->hAILRedbook, startms + 1, end_ms);
}
}
- lua_close(L);
+ //lua_close(L);
pGame->Deinitialize();
return 1;
}