Merge branch 'develop' into dig_digtype_nohidden

develop
Najeeb Al-Shabibi 2023-09-24 12:15:52 +01:00
commit bf9dbd87a9
4 changed files with 26 additions and 20 deletions

@ -1459,12 +1459,9 @@ void Core::fatal (std::string output)
con.print("\n");
}
fprintf(stderr, "%s\n", out.str().c_str());
#ifndef LINUX_BUILD
out << "Check file stderr.log for details\n";
MessageBox(0,out.str().c_str(),"DFHack error!", MB_OK | MB_ICONERROR);
#else
out << "Check file stderr.log for details.\n";
std::cout << "DFHack fatal error: " << out.str() << std::endl;
#endif
DFSDL::DFSDL_ShowSimpleMessageBox(0x10 /* SDL_MESSAGEBOX_ERROR */, "DFHack error!", out.str().c_str(), NULL);
bool is_headless = bool(getenv("DFHACK_HEADLESS"));
if (is_headless)
@ -1506,6 +1503,12 @@ bool Core::InitMainThread() {
std::cerr << "DFHack build: " << Version::git_description() << "\n"
<< "Starting with working directory: " << Filesystem::getcwd() << std::endl;
std::cerr << "Binding to SDL.\n";
if (!DFSDL::init(con)) {
fatal("cannot bind SDL libraries");
return false;
}
// find out what we are...
#ifdef LINUX_BUILD
const char * path = "hack/symbols.xml";
@ -1692,11 +1695,6 @@ bool Core::InitSimulationThread()
return false;
}
std::cerr << "Binding to SDL.\n";
if (!DFSDL::init(con)) {
fatal("cannot bind SDL libraries");
return false;
}
if (DFSteam::init(con)) {
std::cerr << "Found Steam.\n";
DFSteam::launchSteamDFHackIfNecessary(con);

@ -6,6 +6,7 @@
struct SDL_Surface;
struct SDL_Rect;
struct SDL_PixelFormat;
struct SDL_Window;
union SDL_Event;
namespace DFHack
@ -50,6 +51,7 @@ DFHACK_EXPORT int DFSDL_PushEvent(SDL_Event *event);
DFHACK_EXPORT void DFSDL_free(void *ptr);
DFHACK_EXPORT SDL_PixelFormat* DFSDL_AllocFormat(uint32_t pixel_format);
DFHACK_EXPORT SDL_Surface* DFSDL_CreateRGBSurfaceWithFormat(uint32_t flags, int width, int height, int depth, uint32_t format);
DFHACK_EXPORT int DFSDL_ShowSimpleMessageBox(uint32_t flags, const char *title, const char *message, SDL_Window *window);
// submitted and returned text is UTF-8
// see wrapper functions below for cp-437 variants

@ -43,6 +43,7 @@ char * (*g_SDL_GetClipboardText)();
void (*g_SDL_free)(void *);
SDL_PixelFormat* (*g_SDL_AllocFormat)(uint32_t pixel_format) = nullptr;
SDL_Surface* (*g_SDL_CreateRGBSurfaceWithFormat)(uint32_t flags, int width, int height, int depth, uint32_t format) = nullptr;
int (*g_SDL_ShowSimpleMessageBox)(uint32_t flags, const char *title, const char *message, SDL_Window *window) = nullptr;
bool DFSDL::init(color_ostream &out) {
for (auto &lib_str : SDL_LIBS) {
@ -85,6 +86,7 @@ bool DFSDL::init(color_ostream &out) {
bind(g_sdl_handle, SDL_free);
bind(g_sdl_handle, SDL_AllocFormat);
bind(g_sdl_handle, SDL_CreateRGBSurfaceWithFormat);
bind(g_sdl_handle, SDL_ShowSimpleMessageBox);
#undef bind
DEBUG(dfsdl,out).print("sdl successfully loaded\n");
@ -159,6 +161,11 @@ SDL_Surface* DFSDL::DFSDL_CreateRGBSurfaceWithFormat(uint32_t flags, int width,
return g_SDL_CreateRGBSurfaceWithFormat(flags, width, height, depth, format);
}
int DFSDL::DFSDL_ShowSimpleMessageBox(uint32_t flags, const char *title, const char *message, SDL_Window *window) {
if (!g_SDL_ShowSimpleMessageBox)
return -1;
return g_SDL_ShowSimpleMessageBox(flags, title, message, window);
}
DFHACK_EXPORT std::string DFHack::getClipboardTextCp437() {
if (!g_sdl_handle || g_SDL_HasClipboardText() != SDL_TRUE)

@ -130,7 +130,6 @@
using namespace DFHack;
using namespace df::enums;
using namespace RemoteFortressReader;
using namespace std;
DFHACK_PLUGIN("RemoteFortressReader");
@ -193,7 +192,7 @@ const char* growth_locations[] = {
#include "df/art_image.h"
#include "df/art_image_chunk.h"
#include "df/art_image_ref.h"
command_result loadArtImageChunk(color_ostream &out, vector <string> & parameters)
command_result loadArtImageChunk(color_ostream &out, std::vector<std::string> & parameters)
{
if (parameters.size() != 1)
return CR_WRONG_USAGE;
@ -214,7 +213,7 @@ command_result loadArtImageChunk(color_ostream &out, vector <string> & parameter
return CR_OK;
}
command_result RemoteFortressReader_version(color_ostream &out, vector<string> &parameters)
command_result RemoteFortressReader_version(color_ostream &out, std::vector<std::string> &parameters)
{
out.print(RFR_VERSION);
return CR_OK;
@ -645,7 +644,7 @@ void CopyMat(RemoteFortressReader::MatPair * mat, int type, int index)
}
map<DFCoord, uint16_t> hashes;
std::map<DFCoord, uint16_t> hashes;
bool IsTiletypeChanged(DFCoord pos)
{
@ -663,7 +662,7 @@ bool IsTiletypeChanged(DFCoord pos)
return false;
}
map<DFCoord, uint16_t> waterHashes;
std::map<DFCoord, uint16_t> waterHashes;
bool IsDesignationChanged(DFCoord pos)
{
@ -681,7 +680,7 @@ bool IsDesignationChanged(DFCoord pos)
return false;
}
map<DFCoord, uint8_t> buildingHashes;
std::map<DFCoord, uint8_t> buildingHashes;
bool IsBuildingChanged(DFCoord pos)
{
@ -700,7 +699,7 @@ bool IsBuildingChanged(DFCoord pos)
return changed;
}
map<DFCoord, uint16_t> spatterHashes;
std::map<DFCoord, uint16_t> spatterHashes;
bool IsspatterChanged(DFCoord pos)
{
@ -737,7 +736,7 @@ bool IsspatterChanged(DFCoord pos)
return false;
}
map<int, uint16_t> itemHashes;
std::map<int, uint16_t> itemHashes;
bool isItemChanged(int i)
{
@ -755,7 +754,7 @@ bool isItemChanged(int i)
return false;
}
bool areItemsChanged(vector<int> * items)
bool areItemsChanged(std::vector<int> * items)
{
bool result = false;
for (size_t i = 0; i < items->size(); i++)
@ -766,7 +765,7 @@ bool areItemsChanged(vector<int> * items)
return result;
}
map<int, int> engravingHashes;
std::map<int, int> engravingHashes;
bool isEngravingNew(int index)
{