|
@@ -43,7 +43,7 @@
|
|
|
#include "CPathfinder.h"
|
|
|
#include "CGameState.h"
|
|
|
#include "CCallback.h"
|
|
|
-
|
|
|
+#include "CLuaHandler.h"
|
|
|
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
|
|
|
# include <fcntl.h>
|
|
|
# include <io.h>
|
|
@@ -58,25 +58,6 @@ const char * NAME = "VCMI 0.3 \"Tol Galen\"";
|
|
|
SDL_Surface * ekran, * screen, * screen2;
|
|
|
TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX, *GEORM;
|
|
|
|
|
|
-#include "lua.h"
|
|
|
-#include "lualib.h"
|
|
|
-#include "lauxlib.h"
|
|
|
-#include <luabind/luabind.hpp>
|
|
|
-#include <luabind/function.hpp>
|
|
|
-#include <luabind/class.hpp>
|
|
|
-
|
|
|
-#if (LUA_VERSION_NUM < 500)
|
|
|
-# define LUA_OPEN_LIB(L, lib) lib(L)
|
|
|
-#else
|
|
|
-# define LUA_OPEN_LIB(L, lib) \
|
|
|
- lua_pushcfunction((L), lib); \
|
|
|
- lua_pcall((L), 0, 0, 0);
|
|
|
-#endif
|
|
|
-void piszpowitanie2(std::string i)
|
|
|
-{
|
|
|
- std::cout<<"powitanie2zc++. Liczba dnia to " << i;
|
|
|
-}
|
|
|
-
|
|
|
void initGameState(CGameInfo * cgi)
|
|
|
{
|
|
|
cgi->state->day=1;
|
|
@@ -170,7 +151,8 @@ void initGameState(CGameInfo * cgi)
|
|
|
{
|
|
|
CTownInstance * vti = new CTownInstance();
|
|
|
(*vti)=*(cgi->townh->townInstances[i]);
|
|
|
-
|
|
|
+ if (vti->name.length()==0) // if town hasn't name we draw it
|
|
|
+ vti->name=vti->town->names[rand()%vti->town->names.size()];
|
|
|
|
|
|
cgi->state->players[vti->owner].towns.push_back(vti);
|
|
|
}
|
|
@@ -178,41 +160,8 @@ void initGameState(CGameInfo * cgi)
|
|
|
|
|
|
int _tmain(int argc, _TCHAR* argv[])
|
|
|
{
|
|
|
-
|
|
|
- int iErr = 0;
|
|
|
- lua_State *lua = lua_open (); // Open Lua
|
|
|
- LUA_OPEN_LIB(lua, luaopen_base);
|
|
|
- LUA_OPEN_LIB(lua, luaopen_io);
|
|
|
-
|
|
|
- if ((iErr = luaL_loadfile (lua, "test.lua")) == 0)
|
|
|
- {
|
|
|
-
|
|
|
-
|
|
|
- // Call main...
|
|
|
- if ((iErr = lua_pcall (lua, 0, LUA_MULTRET, 0)) == 0)
|
|
|
- {
|
|
|
- luabind::open(lua);
|
|
|
- luabind::module(lua)
|
|
|
- [
|
|
|
- luabind::def("powitanie",&piszpowitanie2)
|
|
|
-
|
|
|
- ];
|
|
|
-
|
|
|
- //int ret = luabind::call_function<int>(lua, "helloWorld2");
|
|
|
-
|
|
|
- lua_pushstring (lua, "helloWorld2");
|
|
|
- lua_gettable (lua, LUA_GLOBALSINDEX);
|
|
|
- lua_pcall (lua, 0, 0, 0);
|
|
|
-
|
|
|
- // Push the function name onto the stack
|
|
|
- lua_pushstring (lua, "helloWorld");
|
|
|
- lua_gettable (lua, LUA_GLOBALSINDEX);
|
|
|
- lua_pcall (lua, 0, 0, 0);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- lua_close (lua);
|
|
|
-
|
|
|
+ CLuaHandler luatest;
|
|
|
+ luatest.test();
|
|
|
|
|
|
//CBIKHandler cb;
|
|
|
//cb.open("CSECRET.BIK");
|