Skip to content

Commit

Permalink
Fixes + vs2022 build
Browse files Browse the repository at this point in the history
  • Loading branch information
alicealys committed Mar 18, 2022
1 parent bd1ddf6 commit 2ab7caa
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 113 deletions.
3 changes: 2 additions & 1 deletion generate.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
@echo off
tools\windows\premake5.exe vs2019
call git submodule update --init --recursive
tools\windows\premake5.exe vs2022
21 changes: 12 additions & 9 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,35 @@ workspace "iw5-script"
targetdir "%{wks.location}/bin/%{cfg.buildcfg}"
targetname "%{prj.name}"

configurations { "Debug", "Release", }

language "C++"
cppdialect "C++20"

architecture "x86"

buildoptions "/std:c++latest"
systemversion "latest"
symbols "On"
staticruntime "On"
editandcontinue "Off"
warnings "Extra"
characterset "ASCII"

flags
{
"NoIncrementalLink",
"MultiProcessorCompile",
}

configurations { "Debug", "Release", }

symbols "On"

configuration "Release"
filter "configurations:Release"
optimize "Full"
defines { "NDEBUG" }
configuration{}
filter {}

configuration "Debug"
filter "configurations:Debug"
optimize "Debug"
defines { "DEBUG", "_DEBUG" }
configuration {}
filter {}

startproject "iw5-script"

Expand Down
18 changes: 0 additions & 18 deletions src/component/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

namespace scheduler
{
std::thread::id async_thread_id;

namespace
{
struct task
Expand All @@ -29,15 +27,6 @@ namespace scheduler
});
}

void clear()
{
callbacks_.access([&](task_list& tasks)
{
this->merge_callbacks();
tasks.clear();
});
}

void execute()
{
callbacks_.access([&](task_list& tasks)
Expand Down Expand Up @@ -103,11 +92,6 @@ namespace scheduler
}
}

void clear_tasks(const pipeline type)
{
return pipelines[type].clear();
}

void schedule(const std::function<bool()>& callback, const pipeline type,
const std::chrono::milliseconds delay)
{
Expand Down Expand Up @@ -157,8 +141,6 @@ namespace scheduler
}
});

async_thread_id = thread.get_id();

utils::hook::call(0x50CEDC, server_frame_stub);
}
};
Expand Down
2 changes: 0 additions & 2 deletions src/component/scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ namespace scheduler
static const bool cond_continue = false;
static const bool cond_end = true;

void clear_tasks(const pipeline type);

void schedule(const std::function<bool()>& callback, pipeline type = pipeline::server,
std::chrono::milliseconds delay = 0ms);
void loop(const std::function<void()>& callback, pipeline type = pipeline::server,
Expand Down
4 changes: 1 addition & 3 deletions src/component/scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace scripting
e.arguments.emplace_back(*value);
}

if (e.name == "connected")
if (e.name == "entitydeleted")
{
const auto entity = e.arguments[0].as<scripting::entity>();

Expand Down Expand Up @@ -80,8 +80,6 @@ namespace scripting

void g_shutdown_game_stub(const int free_scripts)
{
scheduler::clear_tasks(scheduler::pipeline::async);

lua::engine::stop();
g_shutdown_game_hook.invoke<void>(free_scripts);
}
Expand Down
2 changes: 0 additions & 2 deletions src/game/scripting/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,6 @@ namespace scripting
void array::set(const std::string& key, const script_value& _value) const
{
const auto value = _value.get_raw();

const auto string_value = game::SL_GetString(key.data(), 0);
const auto variable_id = this->get_value_id(key);

if (!variable_id)
Expand Down
35 changes: 1 addition & 34 deletions src/game/scripting/execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace scripting

auto v6 = game::scr_VmPub->top;
auto v7 = game::scr_VmPub->inparamcount - paramcount;
auto v8 = &game::scr_VmPub->top[-paramcount];
auto v8 = &game::scr_VmPub->top[-1 * static_cast<int>(paramcount)];

if (id)
{
Expand Down Expand Up @@ -86,11 +86,6 @@ namespace scripting

void notify(const entity& entity, const std::string& event, const std::vector<script_value>& arguments)
{
if (std::this_thread::get_id() == scheduler::async_thread_id)
{
throw std::runtime_error("Not in server thread");
}

stack_isolation _;
for (auto i = arguments.rbegin(); i != arguments.rend(); ++i)
{
Expand All @@ -104,11 +99,6 @@ namespace scripting
script_value call_function(const std::string& name, const entity& entity,
const std::vector<script_value>& arguments)
{
if (std::this_thread::get_id() == scheduler::async_thread_id)
{
throw std::runtime_error("Not in server thread");
}

const auto entref = entity.get_entity_reference();

const auto is_method_call = *reinterpret_cast<const int*>(&entref) != -1;
Expand Down Expand Up @@ -149,11 +139,6 @@ namespace scripting

script_value exec_ent_thread(const entity& entity, unsigned int pos, const std::vector<script_value>& arguments)
{
if (std::this_thread::get_id() == scheduler::async_thread_id)
{
throw std::runtime_error("Not in server thread");
}

const auto id = entity.get_entity_id();

stack_isolation _;
Expand Down Expand Up @@ -237,11 +222,6 @@ namespace scripting

void set_entity_field(const entity& entity, const std::string& field, const script_value& value)
{
if (std::this_thread::get_id() == scheduler::async_thread_id)
{
throw std::runtime_error("Not in server thread");
}

const auto entref = entity.get_entity_reference();
const int id = get_field_id(entref.classnum, field);

Expand All @@ -266,11 +246,6 @@ namespace scripting

script_value get_entity_field(const entity& entity, const std::string& field)
{
if (std::this_thread::get_id() == scheduler::async_thread_id)
{
throw std::runtime_error("Not in server thread");
}

const auto entref = entity.get_entity_reference();
const auto id = get_field_id(entref.classnum, field);

Expand Down Expand Up @@ -299,14 +274,6 @@ namespace scripting
return {};
}

void check_thread()
{
if (std::this_thread::get_id() == scheduler::async_thread_id)
{
throw std::runtime_error("Not in server thread");
}
}

unsigned int make_array()
{
unsigned int index = 0;
Expand Down
2 changes: 0 additions & 2 deletions src/game/scripting/execution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,5 @@ namespace scripting

void notify(const entity& entity, const std::string& event, const std::vector<script_value>& arguments);

void check_thread();

unsigned int make_array();
}
Loading

0 comments on commit 2ab7caa

Please sign in to comment.