Some fixups, mainly to support MinGW builds

This commit is contained in:
2017-08-27 23:29:00 -04:00
parent b624841bea
commit a31797582a
19 changed files with 46 additions and 15 deletions

View File

@@ -34,7 +34,7 @@ elif str(platform) == "win32":
game_sources.extend(Split("""
boe.menus.win.cpp
"""))
game_sources.append(env.RES('#build/obj/BladesOfExile.res', '#rsrc/menus/BladesOfExile.rc'))
game_sources.append(env.RES('#rsrc/menus/BladesOfExile.rc'))
boe = env.Program("#build/bin/Blades of Exile", common_sources + party_classes + game_sources)

View File

@@ -321,7 +321,7 @@ void add_outdoor_maps() {
void start_data_dump() {
fs::path path = progDir/"Data Dump.txt";
std::ofstream fout(path.c_str());
std::ofstream fout(path.string().c_str());
fout << "Begin data dump:\n";
fout << " Overall mode " << overall_mode << "\n";

View File

@@ -9,6 +9,11 @@
#ifndef BoE_boe_menus_h
#define BoE_boe_menus_h
// Needed for MinGW builds for some reason
#ifdef FILE_OPEN
#undef FILE_OPEN
#endif
void init_menubar();
void adjust_monst_menu();
void init_spell_menus();

View File

@@ -17,6 +17,7 @@
#include <windows.h>
#include <gl/GL.h>
#undef HELP_INDEX // Except this one
#undef FILE_OPEN
// This is the index of each menu on the menubar
enum {

View File

@@ -423,7 +423,9 @@ void cPlayer::sort_items() {
item_priority[items[i].variety]) {
no_swaps = false;
std::swap(items[i + 1], items[i]);
std::swap(equip[i + 1], equip[i]);
auto temp_equip = equip[i];
equip[i] = equip[i + 1];
equip[i + 1] = temp_equip;
if(weap_poisoned.slot == i + 1)
weap_poisoned.slot--;
else if(weap_poisoned.slot == i)

View File

@@ -1,6 +1,8 @@
Import("env")
env = env.Clone()
env.Append(CXXFLAGS="-fpermissive")
dlog_util = env.StaticLibrary("#build/lib/dlogutil", Glob("*.cpp") + Glob("xml-parser/*.cpp"))
Return("dlog_util")

View File

@@ -51,7 +51,7 @@ Cursor::Cursor(fs::path imgPath, float hotSpotX, float hotSpotY) {
sf::Image gif;
if(!gif.loadFromFile(imgPath.string())) {
std::string error = "Error loading cursor from " + imgPath.string();
throw std::exception(error.c_str());
throw error;
}
// Calculate the AND and XOR masks
HBITMAP cursorAnd = CreateCompatibleBitmap(GetDC(NULL), gif.getSize().x, gif.getSize().y);

View File

@@ -1,4 +1,6 @@
#if defined(_MSC_VER) && !defined(NDEBUG)
#include <sstream>
#include <iostream>
#include <windows.h>
@@ -36,3 +38,5 @@ void set_debug_buffers() {
std::cout.rdbuf(&dbg_buf);
std::cerr.rdbuf(&dbg_err_buf);
}
#endif

View File

@@ -132,7 +132,7 @@ bool load_party(fs::path file_to_load, cUniverse& univ){
}
bool load_party_v1(fs::path file_to_load, cUniverse& real_univ, bool town_restore, bool in_scen, bool maps_there, bool must_port){
std::ifstream fin(file_to_load.c_str(), std::ios_base::binary);
std::ifstream fin(file_to_load.string().c_str(), std::ios_base::binary);
fin.seekg(3*sizeof(short),std::ios_base::beg); // skip the header, which is 6 bytes in the old format
legacy::party_record_type store_party;

View File

@@ -968,11 +968,13 @@ bool operator==(const tessel_ref_t& a, const tessel_ref_t& b) {
return a.key == b.key;
}
template<> struct std::hash<tessel_ref_t> {
namespace std {
template<> struct hash<tessel_ref_t> {
size_t operator()(tessel_ref_t key) const {
return key.key;
}
};
}
std::unordered_map<tessel_ref_t, tessel_t> tiling_reservoir;
static int tessel_index = 0;

View File

@@ -10,6 +10,7 @@
#include <fstream>
#include <cctype>
#include <cstring>
#include <iterator>
#include <numeric>

View File

@@ -38,7 +38,7 @@ void erase_if(ContainerT& items, const PredicateT& predicate) {
// Case-insensitive string comparison seems to be semi-standard, but with different names.
#if defined(__APPLE__)
#define strnicmp strncasecmp
#elif defined(_MSC_VER)
#elif defined(_WIN32)
#define strnicmp _strnicmp
#else
#error Missing strnicmp / strncasecmp

View File

@@ -1,6 +1,7 @@
#include <windows.h>
#include <vector>
#include <string>
struct accel_table_t {
std::vector<ACCEL> table;

View File

@@ -11,6 +11,7 @@
#include <string>
#include <vector>
#include <algorithm>
void set_pref(std::string keypath, bool value);
bool get_bool_pref(std::string keypath, bool fallback = false);

View File

@@ -41,7 +41,7 @@ void append_iarray_pref(std::string keypath, int value) {
if(prefs.find(keypath) == prefs.end() || prefs[keypath].type() != typeid(iarray))
prefs[keypath] = iarray{value};
else {
iarray& arr = boost::any_cast<iarray>(prefs[keypath]);
iarray& arr = boost::any_cast<iarray&>(prefs[keypath]);
arr.push_back(value);
prefs[keypath] = arr;
}
@@ -49,7 +49,7 @@ void append_iarray_pref(std::string keypath, int value) {
std::vector<int> get_iarray_pref(std::string keypath) {
if(prefs.find(keypath) == prefs.end()) return {};
if(prefs[keypath].type() == typeid(iarray)) return boost::any_cast<iarray>(prefs[keypath]);
if(prefs[keypath].type() == typeid(iarray)) return boost::any_cast<iarray&>(prefs[keypath]);
return {};
}
@@ -65,7 +65,7 @@ static bool save_prefs(fs::path fpath) {
std::ofstream fout(fpath.string().c_str());
for(auto& kv : prefs) {
if(kv.second.type() == typeid(iarray)) {
iarray& arr = boost::any_cast<iarray>(kv.second);
const iarray& arr = boost::any_cast<iarray&>(kv.second);
fout << kv.first << " = [";
for(int i : arr) fout << i << ' ';
fout.seekp(-1,std::ios::cur); // To overwrite the final space written in the loop

View File

@@ -47,7 +47,7 @@ namespace ResMgr {
if(!fs::exists(fpath))
throw xResMgrErr("Failed to load GIF cursor: " + fpath.string());
int x = 0, y = 0, f_sz;
std::ifstream fin(fpath.c_str(), std::ios::binary);
std::ifstream fin(fpath.string().c_str(), std::ios::binary);
fin.seekg(0, std::ios::end);
f_sz = fin.tellg();
fin.clear();
@@ -99,7 +99,7 @@ namespace ResMgr {
/// Each line in the file becomes one string in the resulting list.
/// (Empty lines are included too.)
template<> inline StringRsrc* resLoader<StringRsrc>::operator() (fs::path fpath) {
std::ifstream fin(fpath.c_str());
std::ifstream fin(fpath.string().c_str());
if(fin.fail()) {
std::cerr << std_fmterr << ": Error opening file";
throw xResMgrErr("Failed to load string list: " + fpath.string());

View File

@@ -10,6 +10,7 @@
#include <algorithm>
#include <cstdio>
#include <ctime>
#include <cstring>
#ifdef _MSC_VER
// For some bizarre reason, Visual Studio doesn't declare snprintf in <cstdio>

View File

@@ -5,6 +5,7 @@
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Image.hpp>
#include <sstream>
#include <cmath>
extern sf::RenderWindow mainPtr;
OPENFILENAMEA getParty, getScen, getRsrc, putParty, putScen, putRsrc;