Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove CoreSuspender from interpose functions #5157

Merged
merged 3 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions library/include/VTableInterpose.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ namespace DFHack
// You may define additional methods here, but NOT non-static fields

DEFINE_VMETHOD_INTERPOSE(int, foo, (int arg)) {
// If needed by the code, claim the suspend lock.
// CoreSuspender suspend;
...
... this->field ... // access fields of the df::someclass object
...
int orig_retval = INTERPOSE_NEXT(foo)(arg); // call the original method
Expand Down
1 change: 0 additions & 1 deletion plugins/building-hacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ struct work_hook : df::building_workshopst{
{
if(world->frame_counter % def->skip_updates == 0)
{
CoreSuspender suspend;
color_ostream_proxy out(Core::getInstance().getConsole());
onUpdateAction(out,this);
}
Expand Down
1 change: 0 additions & 1 deletion plugins/devel/eventExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ struct my_contaminate : df::item_actual {
typedef df::item_actual interpose_base;
DEFINE_VMETHOD_INTERPOSE(void, contaminateWound, (df::unit* unit, df::unit_wound* wound, uint8_t unk1, int16_t unk2)) {
INTERPOSE_NEXT(contaminateWound)(unit,wound,unk1,unk2);
CoreSuspender suspend;
Core::getInstance().print("contaminateWound: item=%d, unit=%d, wound attacker = %d, unk1 = %d, unk2 = %d\n", this->id, unit->id, wound->unit_id, (int32_t)unk1, (int32_t)unk2);
}
};
Expand Down
17 changes: 2 additions & 15 deletions plugins/eventful.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#include "Error.h"
#include "Console.h"
#include "Export.h"
#include "LuaTools.h"
#include "MiscUtils.h"
#include "PluginManager.h"
#include "VTableInterpose.h"

#include "modules/EventManager.h"

#include "df/building.h"
#include "df/building_furnacest.h"
#include "df/building_workshopst.h"
Expand All @@ -23,8 +21,6 @@
#include "df/unit_wound.h"
#include "df/world.h"

#include "modules/EventManager.h"

#include <string.h>
#include <stdexcept>
#include <array>
Expand All @@ -33,7 +29,6 @@ using std::vector;
using std::string;
using std::stack;
using namespace DFHack;
using namespace df::enums;

DFHACK_PLUGIN("eventful");
REQUIRE_GLOBAL(gps);
Expand Down Expand Up @@ -304,7 +299,6 @@ struct workshop_hook : df::building_workshopst{
typedef df::building_workshopst interpose_base;
DEFINE_VMETHOD_INTERPOSE(void,fillSidebarMenu,())
{
CoreSuspender suspend;
color_ostream_proxy out(Core::getInstance().getConsole());
bool call_native=true;
onWorkshopFillSidebarMenu(out,this,&call_native);
Expand All @@ -319,7 +313,6 @@ struct furnace_hook : df::building_furnacest{
typedef df::building_furnacest interpose_base;
DEFINE_VMETHOD_INTERPOSE(void,fillSidebarMenu,())
{
CoreSuspender suspend;
color_ostream_proxy out(Core::getInstance().getConsole());
bool call_native=true;
onWorkshopFillSidebarMenu(out,this,&call_native);
Expand Down Expand Up @@ -350,7 +343,6 @@ struct product_hook : item_product {
return;
}
df::reaction* this_reaction=product->react;
CoreSuspender suspend;
bool call_native=true;
onReactionCompleting(out,this_reaction,(df::reaction_product_itemst*)this,unit,in_items,in_reag,out_items,&call_native);
if(!call_native)
Expand All @@ -374,7 +366,6 @@ struct item_hooks :df::item_actual {

DEFINE_VMETHOD_INTERPOSE(void, contaminateWound,(df::unit* unit, df::unit_wound* wound, int32_t a1, int16_t a2))
{
CoreSuspender suspend;
color_ostream_proxy out(Core::getInstance().getConsole());
onItemContaminateWound(out,this,unit,wound,a1,a2);
INTERPOSE_NEXT(contaminateWound)(unit,wound,a1,a2);
Expand All @@ -387,14 +378,12 @@ struct proj_item_hook: df::proj_itemst{
typedef df::proj_itemst interpose_base;
DEFINE_VMETHOD_INTERPOSE(bool,checkImpact,(bool mode))
{
CoreSuspender suspend;
color_ostream_proxy out(Core::getInstance().getConsole());
onProjItemCheckImpact(out,this,mode);
return INTERPOSE_NEXT(checkImpact)(mode); //returns destroy item or not?
}
DEFINE_VMETHOD_INTERPOSE(bool,checkMovement,())
{
CoreSuspender suspend;
color_ostream_proxy out(Core::getInstance().getConsole());
onProjItemCheckMovement(out,this);
return INTERPOSE_NEXT(checkMovement)();
Expand All @@ -407,14 +396,12 @@ struct proj_unit_hook: df::proj_unitst{
typedef df::proj_unitst interpose_base;
DEFINE_VMETHOD_INTERPOSE(bool,checkImpact,(bool mode))
{
CoreSuspender suspend;
color_ostream_proxy out(Core::getInstance().getConsole());
onProjUnitCheckImpact(out,this,mode);
return INTERPOSE_NEXT(checkImpact)(mode); //returns destroy item or not?
}
DEFINE_VMETHOD_INTERPOSE(bool,checkMovement,())
{
CoreSuspender suspend;
color_ostream_proxy out(Core::getInstance().getConsole());
onProjUnitCheckMovement(out,this);
return INTERPOSE_NEXT(checkMovement)();
Expand Down
2 changes: 0 additions & 2 deletions plugins/overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ static void overlay_interpose_lua(const char *fn_name, int nargs = 0, int nres =
Lua::LuaLambda && res_lambda = Lua::DEFAULT_LUA_LAMBDA) {
DEBUG(event).print("calling overlay lua function: '%s'\n", fn_name);

CoreSuspender guard;

color_ostream & out = Core::getInstance().getConsole();
auto L = Lua::Core::State;

Expand Down
3 changes: 0 additions & 3 deletions plugins/rendermax/rendermax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ struct dwarmode_render_hook : viewscreen_dwarfmodest{
typedef df::viewscreen_dwarfmodest interpose_base;
DEFINE_VMETHOD_INTERPOSE(void,render,())
{
CoreSuspender suspend;
engine->preRender();
INTERPOSE_NEXT(render)();
engine->calculate();
Expand All @@ -71,7 +70,6 @@ struct dungeon_render_hook : viewscreen_dungeonmodest{
typedef df::viewscreen_dungeonmodest interpose_base;
DEFINE_VMETHOD_INTERPOSE(void,render,())
{
CoreSuspender suspend;
engine->preRender();
INTERPOSE_NEXT(render)();
engine->calculate();
Expand Down Expand Up @@ -296,7 +294,6 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan
{
case SC_VIEWSCREEN_CHANGED:
{
CoreSuspender suspender;
if(current_mode==MODE_LIGHT)
{
engine->clear();
Expand Down
1 change: 0 additions & 1 deletion plugins/siege-engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,6 @@ struct projectile_hook : df::proj_itemst {
return;

auto L = Lua::Core::State;
CoreSuspender suspend;
color_ostream_proxy out(Core::getInstance().getConsole());

df::unit *op_unit = getOperatorUnit(engine->bld, true);
Expand Down
2 changes: 0 additions & 2 deletions plugins/stockflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ class LuaHelper {
bool stockpile_method(const char *method, building_stockpilest *sp) {
// Combines the select_order and toggle_trigger method calls,
// because they share the same signature.
CoreSuspender suspend;

auto L = Lua::Core::State;
color_ostream_proxy out(Core::getInstance().getConsole());

Expand Down
Loading