summaryrefslogtreecommitdiff
path: root/plugins/versionosd.cpp
diff options
context:
space:
mode:
authorAlexander Gavrilov2012-03-10 15:55:42 +0400
committerAlexander Gavrilov2012-03-10 15:55:42 +0400
commit8cc82d5876c902cbb4f0b3fa6cf15cf268dd942b (patch)
tree4be7625f1bbe15b81d00373316047137d3422464 /plugins/versionosd.cpp
parentb2737e2bed5f013a4dfbf6e19650ca60498a9afd (diff)
downloaddfhack-8cc82d5876c902cbb4f0b3fa6cf15cf268dd942b.tar.gz
dfhack-8cc82d5876c902cbb4f0b3fa6cf15cf268dd942b.tar.bz2
dfhack-8cc82d5876c902cbb4f0b3fa6cf15cf268dd942b.tar.xz
Make plugins accept explicit output stream references.
This is an incompatible change to the plugin ABI. The Console is not thread-safe unless used indirectly via color_ostream_proxy, so everything should use their per-thread stream.
Diffstat (limited to 'plugins/versionosd.cpp')
-rw-r--r--plugins/versionosd.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/plugins/versionosd.cpp b/plugins/versionosd.cpp
index 2aaff49c..7904c46c 100644
--- a/plugins/versionosd.cpp
+++ b/plugins/versionosd.cpp
@@ -15,7 +15,7 @@ using namespace std;
#include "modules/Gui.h"
using namespace DFHack;
-command_result df_versionosd (Core * c, vector <string> & parameters);
+command_result df_versionosd (color_ostream &out, vector <string> & parameters);
static DFSDL_Surface* (*_IMG_LoadPNG_RW)(void* src) = 0;
static vPtr (*_SDL_RWFromFile)(const char* file, const char *mode) = 0;
static int (*_SDL_SetAlpha)(vPtr surface, uint32_t flag, uint8_t alpha) = 0;
@@ -45,7 +45,7 @@ DFTileSurface* createTile(int x, int y)
return tile;
}
-DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
+DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{
commands.clear();
commands.push_back(PluginCommand("versionosd",
@@ -66,7 +66,7 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand>
if ( !surface )
{
- c->con.print("Couldnt load image from file %s", file);
+ out.print("Couldnt load image from file %s", file);
return CR_FAILURE;
}
@@ -99,7 +99,7 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand>
return CR_OK;
}
-DFhackCExport command_result plugin_shutdown ( Core * c )
+DFhackCExport command_result plugin_shutdown ( color_ostream &out )
{
Graphic* g = c->getGraphic();
g->Unregister(gettile);
@@ -114,12 +114,11 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
return CR_OK;
}
-command_result df_versionosd (Core * c, vector <string> & parameters)
+command_result df_versionosd (color_ostream &out, vector <string> & parameters)
{
On = !On;
- c->Suspend();
- c->con.print("Version OSD is %s\n", On ? "On" : "Off");
- c->Resume();
+ CoreSuspender suspend;
+ out.print("Version OSD is %s\n", On ? "On" : "Off");
return CR_OK;
}