Skip to content

Commit 7e99c8d

Browse files
committed
fully remove squall and replace with sqrat
1 parent 2262e22 commit 7e99c8d

File tree

9 files changed

+41
-32
lines changed

9 files changed

+41
-32
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@
5050
[submodule "3rdParty/squirrel"]
5151
path = 3rdParty/squirrel
5252
url = https://github.com/paulsapps/squirrel
53-
[submodule "3rdParty/squall"]
54-
path = 3rdParty/squall
55-
url = https://github.com/paulsapps/squall.git
5653
[submodule "3rdParty/sqrat"]
5754
path = 3rdParty/sqrat
5855
url = https://github.com/paulsapps/sqrat

3rdParty/squall

Lines changed: 0 additions & 1 deletion
This file was deleted.

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ include_directories(
8383
${CMAKE_CURRENT_BINARY_DIR}/packaging
8484
${OPENGL_INCLUDE_DIRS}
8585
${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/squirrel/include
86-
${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/squall
8786
${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/sqrat/include
8887
${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/boost_1_63_mini
8988
${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/gl3w/include

include/engine.hpp

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include "resourcemapper.hpp"
99
#include "proxy_sol.hpp"
1010
#include "bitutils.hpp"
11-
#include "proxy_squall.hpp"
1211

1312
class StateMachine;
1413
class InputState;
@@ -153,7 +152,7 @@ class Actions
153152
public:
154153
Actions()
155154
{
156-
LOG_INFO("Get down with the sickness");
155+
TRACE_ENTRYEXIT;
157156
}
158157

159158
static bool Left(u32 state) { return IsBitOn(state, eLeft); }
@@ -511,6 +510,30 @@ class InputState final
511510
InputMapping mInputMapping;
512511
};
513512

513+
class SquirrelVm
514+
{
515+
public:
516+
SquirrelVm(const SquirrelVm&) = delete;
517+
SquirrelVm& operator = (const SquirrelVm&) = delete;
518+
519+
SquirrelVm(int stackSize = 1024)
520+
{
521+
mVm = sq_open(stackSize);
522+
}
523+
524+
~SquirrelVm()
525+
{
526+
if (mVm)
527+
{
528+
sq_close(mVm);
529+
}
530+
}
531+
532+
HSQUIRRELVM Handle() const { return mVm; }
533+
private:
534+
HSQUIRRELVM mVm = 0;
535+
};
536+
514537
class Engine final
515538
{
516539
public:
@@ -554,5 +577,5 @@ class Engine final
554577
StateMachine mStateMachine;
555578

556579
sol::state mLuaState;
557-
squall::VMStd mSquirrelVm;
580+
SquirrelVm mSquirrelVm;
558581
};

include/gridmap.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "proxy_sol.hpp"
1414
#include "renderer.hpp"
1515
#include "collisionline.hpp"
16-
#include "proxy_squall.hpp"
1716
#include "proxy_sqrat.hpp"
1817

1918
struct GuiContext;
@@ -42,6 +41,7 @@ struct ObjRect
4241
.Var("w", &ObjRect::h)
4342
.Var("h", &ObjRect::h)
4443
.Ctor();
44+
Sqrat::RootTable().Bind("ObjRect", c);
4545

4646
state.new_usertype<ObjRect>("ObjRect",
4747
"x", &ObjRect::x,

include/oddlib/stream.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ namespace Oddlib
143143
Sqrat::Class<IStream, Sqrat::NoConstructor<IStream>> c(Sqrat::DefaultVM::Get(), "IStream");
144144
c.StaticFunc("ReadU32", &ReadU32);
145145
c.StaticFunc("ReadU16", &ReadU16);
146+
Sqrat::RootTable().Bind("IStream", c);
146147

147148
state.new_usertype<IStream>("IStream",
148149
"ReadU32", &ReadU32,

include/proxy_squall.hpp

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/engine.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,23 +313,26 @@ void Engine::InitSubSystems()
313313
// Get lua to look for scripts in the correction location
314314
mLuaState.script("package.path = '" + mFileSystem->FsPath() + "data/scripts/?.lua'");
315315

316-
mSquirrelVm.defun("log_info", LuaLogInfo);
317-
mSquirrelVm.defun("log_trace", LuaLogTrace);
318-
mSquirrelVm.defun("log_warning", LuaLogWarning);
319-
mSquirrelVm.defun("log_error", LuaLogError);
316+
Sqrat::DefaultVM::Set(mSquirrelVm.Handle());
320317

321-
Sqrat::DefaultVM::Set(mSquirrelVm.handle());
318+
Sqrat::RootTable().Func("log_info", LuaLogInfo);
319+
Sqrat::RootTable().Func("log_trace", LuaLogTrace);
320+
Sqrat::RootTable().Func("log_warning", LuaLogWarning);
321+
Sqrat::RootTable().Func("log_error", LuaLogError);
322322

323323
Oddlib::IStream::RegisterScriptBindings(mLuaState);
324324
Actions::RegisterScriptBindings(mLuaState);
325325
MapObject::RegisterScriptBindings(mLuaState);
326326
ObjRect::RegisterScriptBindings(mLuaState);
327327

328328
// TODO: Override the stdout/stderr/compile error functions to LOG's
329-
mSquirrelVm.dostring(mResourceLocator->LocateScript("main.nut").c_str());
329+
Sqrat::Script script;
330+
script.CompileString(mResourceLocator->LocateScript("main.nut"));
331+
script.Run();
330332

331333
LOG_INFO("Calling script init()");
332-
mSquirrelVm.call<void>("init");
334+
Sqrat::Function initFunc(Sqrat::RootTable(), "init");
335+
initFunc.Execute();
333336
}
334337

335338
// TODO: Using averaging value or anything that is more accurate than this
@@ -577,7 +580,8 @@ void Engine::Update()
577580
Debugging().Update(mInputState);
578581

579582
// HACK: Should be called from within the "init/starting" state
580-
mSquirrelVm.call<void>("update");
583+
Sqrat::Function initFunc(Sqrat::RootTable(), "update");
584+
initFunc.Execute();
581585

582586
mStateMachine.Update(mInputState, *mRenderer);
583587
}

src/gridmap.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ MapObject::MapObject(IMap& map, sol::state& luaState, ResourceLocator& locator,
4949
c.Var("states", &MapObject::mStates);
5050
c.Var("mXPos", &MapObject::mXPos);
5151
c.Var("mYPos", &MapObject::mYPos);
52+
Sqrat::RootTable().Bind("MapObject", c);
5253

5354
state.new_usertype<MapObject>("MapObject",
5455
"SetAnimation", &MapObject::SetAnimation,

0 commit comments

Comments
 (0)