Skip to content

Commit

Permalink
remove now-unneeded CoreSuspender guards
Browse files Browse the repository at this point in the history
  • Loading branch information
myk002 committed Dec 20, 2024
1 parent 7346fa2 commit d08863a
Show file tree
Hide file tree
Showing 84 changed files with 138 additions and 346 deletions.
2 changes: 0 additions & 2 deletions plugins/3dveins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1627,8 +1627,6 @@ command_result cmd_3dveins(color_ostream &con, std::vector<std::string> & parame
return CR_WRONG_USAGE;
}

CoreSuspender suspend;

if (!Maps::IsValid())
{
con.printerr("Map is not available!\n");
Expand Down
2 changes: 0 additions & 2 deletions plugins/aquifer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ DFhackCExport command_result plugin_init(color_ostream &out, std::vector <Plugin
}

static command_result do_command(color_ostream &out, vector<string> &parameters) {
CoreSuspender suspend;

if (!Core::getInstance().isMapLoaded()) {
out.printerr("Cannot run %s without a loaded map.\n", plugin_name);
return CR_FAILURE;
Expand Down
2 changes: 0 additions & 2 deletions plugins/autobutcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,6 @@ static void autobutcher_target(color_ostream &out, const autobutcher_options &op
static void autobutcher_modify_watchlist(color_ostream &out, const autobutcher_options &opts);

static command_result df_autobutcher(color_ostream &out, vector<string> &parameters) {
CoreSuspender suspend;

if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) {
out.printerr("Cannot run %s without a loaded fort.\n", plugin_name);
return CR_FAILURE;
Expand Down
2 changes: 0 additions & 2 deletions plugins/autochop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ DFhackCExport command_result plugin_onupdate(color_ostream &out) {
}

static command_result do_command(color_ostream &out, vector<string> &parameters) {
CoreSuspender suspend;

if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) {
out.printerr("Cannot run %s without a loaded fort.\n", plugin_name);
return CR_FAILURE;
Expand Down
4 changes: 1 addition & 3 deletions plugins/autoclothing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,7 @@ static bool validateMaterialCategory(ClothingRequirement *requirement) {

// A command! It sits around and looks pretty. And it's nice and friendly.
command_result autoclothing(color_ostream &out, vector<string> &parameters)
{ // Be sure to suspend the core if any DF state is read or modified
CoreSuspender suspend;

{
if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) {
out.printerr("Cannot run %s without a loaded fort.\n", plugin_name);
return CR_FAILURE;
Expand Down
4 changes: 0 additions & 4 deletions plugins/autodump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ static command_result autodump_main(color_ostream &out, vector<string> &paramete
}

command_result df_autodump(color_ostream &out, vector<string> &parameters) {
CoreSuspender suspend;
return autodump_main(out, parameters);
}

Expand All @@ -201,7 +200,6 @@ command_result df_autodump_destroy_here(color_ostream &out, vector<string> &para
vector<string> args;
args.push_back("destroy-here");

CoreSuspender suspend;
return autodump_main(out, args);
}

Expand All @@ -213,8 +211,6 @@ command_result df_autodump_destroy_item(color_ostream &out, vector<string> &para
if (!parameters.empty())
return CR_WRONG_USAGE;

CoreSuspender suspend;

df::item *item = Gui::getSelectedItem(out);
if (!item)
return CR_FAILURE;
Expand Down
2 changes: 0 additions & 2 deletions plugins/autofarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,6 @@ static command_result autofarm(color_ostream& out, std::vector<std::string>& par
return CR_FAILURE;
}

CoreSuspender suspend;

if (parameters.size() == 1 && parameters[0] == "runonce")
{
if (autofarmInstance) autofarmInstance->process(out);
Expand Down
2 changes: 0 additions & 2 deletions plugins/autolabor/autolabor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1094,8 +1094,6 @@ DFhackCExport command_result plugin_enable ( color_ostream &out, bool enable )

command_result autolabor (color_ostream &out, std::vector <std::string> & parameters)
{
CoreSuspender suspend;

if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) {
out.printerr("Cannot run %s without a loaded fort.\n", plugin_name);
return CR_FAILURE;
Expand Down
2 changes: 0 additions & 2 deletions plugins/autolabor/labormanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1977,8 +1977,6 @@ DFhackCExport command_result plugin_enable(color_ostream &out, bool enable)

command_result labormanager(color_ostream &out, std::vector <std::string> & parameters)
{
CoreSuspender suspend;

if (!Core::getInstance().isWorldLoaded()) {
out.printerr("World is not loaded: please load a game first.\n");
return CR_FAILURE;
Expand Down
2 changes: 0 additions & 2 deletions plugins/autonestbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ static const struct_field_info autonestbox_options_fields[] = {
struct_identity autonestbox_options::_identity(sizeof(autonestbox_options), &df::allocator_fn<autonestbox_options>, NULL, "autonestbox_options", NULL, autonestbox_options_fields);

static command_result df_autonestbox(color_ostream &out, vector<string> &parameters) {
CoreSuspender suspend;

if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) {
out.printerr("Cannot run %s without a loaded fort.\n", plugin_name);
return CR_FAILURE;
Expand Down
2 changes: 0 additions & 2 deletions plugins/blueprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1591,8 +1591,6 @@ static bool do_transform(color_ostream &out,
static command_result do_blueprint(color_ostream &out,
const vector<string> &parameters,
vector<string> &files) {
CoreSuspender suspend;

if (parameters.size() >= 1 && parameters[0] == "gui") {
ostringstream command;
command << "gui/blueprint";
Expand Down
2 changes: 0 additions & 2 deletions plugins/buildingplan/buildingplan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,6 @@ DFhackCExport command_result plugin_onupdate(color_ostream &out) {
}

static command_result do_command(color_ostream &out, vector<string> &parameters) {
CoreSuspender suspend;

if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) {
out.printerr("Cannot configure %s without a loaded fort.\n", plugin_name);
return CR_FAILURE;
Expand Down
2 changes: 0 additions & 2 deletions plugins/burrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan
}

static command_result do_command(color_ostream &out, vector<string> &parameters) {
CoreSuspender suspend;

if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) {
out.printerr("Cannot run %s without a loaded fort.\n", plugin_name);
return CR_FAILURE;
Expand Down
2 changes: 0 additions & 2 deletions plugins/changeitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ command_result changeitem_execute(

command_result df_changeitem(color_ostream &out, vector <string> & parameters)
{
CoreSuspender suspend;

bool here = false;
bool info = false;
bool force = false;
Expand Down
2 changes: 0 additions & 2 deletions plugins/changelayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ static bool warned = false;

command_result changelayer (color_ostream &out, std::vector <std::string> & parameters)
{
CoreSuspender suspend;

string material;
bool force = false;
bool all_biomes = false;
Expand Down
2 changes: 0 additions & 2 deletions plugins/changevein.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ command_result df_changevein (color_ostream &out, vector <string> & parameters)
if (parameters.size() != 1)
return CR_WRONG_USAGE;

CoreSuspender suspend;

if (!Maps::IsValid())
{
out.printerr("Map is not available!\n");
Expand Down
2 changes: 0 additions & 2 deletions plugins/channel-safely/channel-safely-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ namespace CSP {
}

void UnpauseEvent(bool full_scan = false){
CoreSuspender suspend; // we need exclusive access to df memory and this call stack doesn't already have a lock
DEBUG(plugin).print("UnpauseEvent()\n");
ChannelManager::Get().build_groups(full_scan);
ChannelManager::Get().manage_groups();
Expand Down Expand Up @@ -361,7 +360,6 @@ namespace CSP {
}

void OnUpdate(color_ostream &out) {
CoreSuspender suspend;
if (World::ReadPauseState())
return;

Expand Down
2 changes: 0 additions & 2 deletions plugins/cleanconst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ REQUIRE_GLOBAL(world);

command_result df_cleanconst(color_ostream &out, vector <string> & parameters)
{
CoreSuspender suspend;

if (!Maps::IsValid())
{
out.printerr("Map is not available!\n");
Expand Down
3 changes: 0 additions & 3 deletions plugins/cleaners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ command_result cleanplants (color_ostream &out)

command_result spotclean (color_ostream &out, vector <string> & parameters)
{
// HOTKEY COMMAND: CORE ALREADY SUSPENDED
if (cursor->x < 0)
{
out.printerr("The cursor is not active.\n");
Expand Down Expand Up @@ -236,8 +235,6 @@ command_result clean (color_ostream &out, vector <string> & parameters)
if(!map && !units && !items && !plants)
return CR_WRONG_USAGE;

CoreSuspender suspend;

if(map)
cleanmap(out,snow,mud,item_spatter);
if(units)
Expand Down
2 changes: 0 additions & 2 deletions plugins/cleanowned.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ command_result df_cleanowned (color_ostream &out, vector <string> & parameters)
return CR_WRONG_USAGE;
}

CoreSuspender suspend;

if (!Translation::IsValid())
{
out.printerr("Translation data unavailable!\n");
Expand Down
2 changes: 0 additions & 2 deletions plugins/createitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ command_result df_createitem (color_ostream &out, vector<string> &parameters) {

if (parameters.size() == 1) {
if (parameters[0] == "inspect") {
CoreSuspender suspend;
auto item = Gui::getSelectedItem(out);
if (!item)
return CR_FAILURE;
Expand Down Expand Up @@ -394,7 +393,6 @@ command_result df_createitem (color_ostream &out, vector<string> &parameters) {
out.printerr("Map is not available.\n");
return CR_FAILURE;
}
CoreSuspender suspend;

auto unit = Gui::getSelectedUnit(out, true);
if (!unit) {
Expand Down
1 change: 0 additions & 1 deletion plugins/cursecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ curses determineCurse(df::unit * unit)

command_result cursecheck (color_ostream &out, vector <string> & parameters)
{
CoreSuspender suspend;
df::unit* selected_unit = Gui::getSelectedUnit(out, true);

bool giveDetails = false;
Expand Down
2 changes: 0 additions & 2 deletions plugins/deramp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ command_result df_deramp (color_ostream &out, vector <string> & parameters)
if (!parameters.empty())
return CR_WRONG_USAGE;

CoreSuspender suspend;

if (!Maps::IsValid())
{
out.printerr("Map is not available!\n");
Expand Down
4 changes: 0 additions & 4 deletions plugins/devel/buildprobe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out )

command_result readFlag (color_ostream &out, vector <string> & parameters)
{
CoreSuspender suspend;

// init the map
if(!Maps::IsValid())
{
Expand Down Expand Up @@ -98,8 +96,6 @@ command_result writeFlag (color_ostream &out, vector <string> & parameters)
break; //Redundant.
}

CoreSuspender suspend;

// init the map
if(!Maps::IsValid())
{
Expand Down
2 changes: 0 additions & 2 deletions plugins/devel/check-structures-sanity/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ static command_result command(color_ostream & out, std::vector<std::string> & pa
if (!perturb_byte)
out.printerr("check-structures-sanity: MALLOC_PERTURB_ not set. Some checks may be bypassed or fail.\n");

CoreSuspender suspend;

Checker checker(out);
checker.perturb_byte = perturb_byte;

Expand Down
2 changes: 0 additions & 2 deletions plugins/devel/counters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ using namespace df::enums;

command_result df_counters (color_ostream &out, vector <string> & parameters)
{
CoreSuspender suspend;

df::unit *unit = Gui::getSelectedUnit(out);
if (!unit)
return CR_WRONG_USAGE;
Expand Down
2 changes: 0 additions & 2 deletions plugins/devel/dumpmats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ command_result df_dumpmats (color_ostream &out, vector<string> &parameters)
if (!parameters.empty())
return CR_WRONG_USAGE;

CoreSuspender suspend;

out.print("hardcoded_materials\n\n");
out.print("[OBJECT:MATERIAL]\n");

Expand Down
4 changes: 0 additions & 4 deletions plugins/devel/frozen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ command_result df_frozenlava (color_ostream &out, vector <string> & parameters)
if (parameters.size())
return CR_WRONG_USAGE;

CoreSuspender suspend;

if (!Maps::IsValid())
{
out.printerr("Map is not available!\n");
Expand All @@ -67,8 +65,6 @@ command_result df_frozenwater (color_ostream &out, vector <string> & parameters)
if (parameters.size())
return CR_WRONG_USAGE;

CoreSuspender suspend;

if (!Maps::IsValid())
{
out.printerr("Map is not available!\n");
Expand Down
2 changes: 0 additions & 2 deletions plugins/devel/kittens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ command_result trackstate ( color_ostream& out, vector< string >& parameters )

command_result colormods (color_ostream &out, vector <string> & parameters)
{
CoreSuspender suspend;
auto & vec = world->raws.creatures.alphabetic;
for(df::creature_raw* rawlion : vec)
{
Expand All @@ -202,7 +201,6 @@ command_result ktimer (color_ostream &out, vector <string> & parameters)
}
uint64_t timestart = GetTimeMs64();
{
CoreSuspender suspend;
uint64_t timeend = GetTimeMs64();
timeLast = timeend;
timering = true;
Expand Down
1 change: 0 additions & 1 deletion plugins/devel/renderer-msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ DFhackCExport command_result plugin_enable (color_ostream &out, bool enable)
{
if (is_enabled == enable)
return CR_OK;
CoreSuspender s;
is_enabled = enable;
if (enable)
w = Renderer::AddRenderer(new renderer_msg, true);
Expand Down
3 changes: 0 additions & 3 deletions plugins/devel/rprobe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,8 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out )
return CR_OK;
}


command_result rprobe (color_ostream &out, vector <string> & parameters)
{
CoreSuspender suspend;

bool set = false;
int to_set = -1, set_field = -1, set_val = -1;

Expand Down
2 changes: 0 additions & 2 deletions plugins/devel/stockcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ struct StockpileInfo {

static command_result stockcheck(color_ostream &out, vector <string> & parameters)
{
CoreSuspender suspend;

std::vector<StockpileInfo*> stockpiles;

for (df::building *build : world->buildings.all)
Expand Down
1 change: 0 additions & 1 deletion plugins/devel/stripcaged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out )

command_result df_stripcaged(color_ostream &out, vector <string> & parameters)
{
CoreSuspender suspend;
bool keeparmor = true;

if (parameters.size() == 1 && parameters[0] == "dumparmor")
Expand Down
2 changes: 0 additions & 2 deletions plugins/devel/tilesieve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ struct xyz

command_result tilesieve(color_ostream &out, std::vector<std::string> & params)
{
CoreSuspender suspend;

if (!Maps::IsValid())
{
out.printerr("Map is not available!\n");
Expand Down
4 changes: 0 additions & 4 deletions plugins/devel/vectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@ command_result df_vectors (color_ostream &con, vector <string> & parameters)
while (start % 4 != 0)
start++;

CoreSuspender suspend;

std::vector<t_memrange> ranges;

if (!getRanges(con, ranges))
Expand Down Expand Up @@ -289,8 +287,6 @@ command_result df_clearvec (color_ostream &con, vector <string> & parameters)
return CR_FAILURE;
}

CoreSuspender suspend;

std::vector<t_memrange> ranges;

if (!getRanges(con, ranges))
Expand Down
1 change: 0 additions & 1 deletion plugins/devel/zoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ command_result df_gzoom (color_ostream &out, std::vector<std::string> & paramete
int y = atoi( parameters[1].c_str());
int z = atoi( parameters[2].c_str());
int xi, yi, zi;
CoreSuspender cs;
if(Gui::getCursorCoords(xi, yi, zi))
{
Gui::setCursorCoords(x,y,z);
Expand Down
Loading

0 comments on commit d08863a

Please sign in to comment.