Remove bloat

This commit is contained in:
Varun Patil 2020-05-02 16:38:55 +05:30
parent 9dc42914de
commit 776564d583
3 changed files with 43 additions and 29 deletions

View File

@ -22,8 +22,8 @@
#ifndef BOOSTHASH_H #ifndef BOOSTHASH_H
#define BOOSTHASH_H #define BOOSTHASH_H
#include <boost/unordered/unordered_map.hpp> #include <map>
#include <boost/unordered/unordered_set.hpp> #include <set>
#include <utility> #include <utility>
@ -34,7 +34,7 @@ template<typename K, typename V>
class BoostHash class BoostHash
{ {
private: private:
typedef boost::unordered_map<K, V> BoostType; typedef std::map<K, V> BoostType;
typedef std::pair<K, V> PairType; typedef std::pair<K, V> PairType;
BoostType p; BoostType p;
@ -98,7 +98,7 @@ template<typename K>
class BoostSet class BoostSet
{ {
private: private:
typedef boost::unordered_set<K> BoostType; typedef std::set<K> BoostType;
BoostType p; BoostType p;
public: public:

View File

@ -21,9 +21,9 @@
#include "config.h" #include "config.h"
#include <boost/program_options/options_description.hpp> //#include <boost/program_options/options_description.hpp>
#include <boost/program_options/parsers.hpp> //#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp> //#include <boost/program_options/variables_map.hpp>
#include <SDL_filesystem.h> #include <SDL_filesystem.h>
@ -33,7 +33,6 @@
#include "debugwriter.h" #include "debugwriter.h"
#include "util.h" #include "util.h"
#include "sdl-util.h" #include "sdl-util.h"
#include "iniconfig.h"
#ifdef INI_ENCODING #ifdef INI_ENCODING
extern "C" { extern "C" {
@ -141,8 +140,8 @@ std::set<T> setFromVec(const std::vector<T> &vec)
return std::set<T>(vec.begin(), vec.end()); return std::set<T>(vec.begin(), vec.end());
} }
typedef std::vector<std::string> StringVec; //typedef std::vector<std::string> StringVec;
namespace po = boost::program_options; //namespace po = boost::program_options;
#define CONF_FILE "mkxp.conf" #define CONF_FILE "mkxp.conf"
@ -151,6 +150,14 @@ Config::Config()
void Config::read(int argc, char *argv[]) void Config::read(int argc, char *argv[])
{ {
gameFolder = "game";
defScreenW = 640;
defScreenH = 480;
enableBlitting = true;
smoothScaling = true;
subImageFix = false;
#if 0
#define PO_DESC_ALL \ #define PO_DESC_ALL \
PO_DESC(rgssVersion, int, 0) \ PO_DESC(rgssVersion, int, 0) \
PO_DESC(debugMode, bool, false) \ PO_DESC(debugMode, bool, false) \
@ -267,6 +274,8 @@ void Config::read(int argc, char *argv[])
#undef PO_DESC #undef PO_DESC
#undef PO_DESC_ALL #undef PO_DESC_ALL
#endif
preloadScripts.insert("win32_wrap.rb");
rgssVersion = clamp(rgssVersion, 0, 3); rgssVersion = clamp(rgssVersion, 0, 3);
@ -299,6 +308,7 @@ static void setupScreenSize(Config &conf)
void Config::readGameINI() void Config::readGameINI()
{ {
if (!customScript.empty()) if (!customScript.empty())
{ {
game.title = baseName(customScript); game.title = baseName(customScript);
@ -310,33 +320,29 @@ void Config::readGameINI()
return; return;
} }
#if 0
po::options_description podesc;
podesc.add_options()
("Game.Title", po::value<std::string>())
("Game.Scripts", po::value<std::string>())
;
po::variables_map vm;
#endif
std::string iniFilename = execName + ".ini"; std::string iniFilename = execName + ".ini";
SDLRWStream iniFile(iniFilename.c_str(), "r"); SDLRWStream iniFile(iniFilename.c_str(), "r");
#if 0
if (iniFile) if (iniFile)
{ {
INIConfiguration ic; try
if(ic.load(iniFile.stream()))
{ {
GUARD_ALL( game.title = ic.getStringProperty("Game", "Title"); ); po::store(po::parse_config_file(iniFile.stream(), podesc, true), vm);
GUARD_ALL( game.scripts = ic.getStringProperty("Game", "Scripts"); ); po::notify(vm);
strReplace(game.scripts, '\\', '/');
if (game.title.empty())
{
Debug() << iniFilename + ": Could not find Game.Title property";
} }
catch (po::error &error)
if (game.scripts.empty())
{ {
Debug() << iniFilename + ": Could not find Game.Scripts property"; Debug() << iniFilename + ":" << error.what();
}
}
else
{
Debug() << iniFilename + ": Failed to parse ini file";
} }
} }
else else
@ -344,6 +350,13 @@ void Config::readGameINI()
Debug() << "FAILED to open" << iniFilename; Debug() << "FAILED to open" << iniFilename;
} }
GUARD_ALL( game.title = vm["Game.Title"].as<std::string>(); );
GUARD_ALL( game.scripts = vm["Game.Scripts"].as<std::string>(); );
#endif
game.scripts = "Data/Scripts.rxdata";
strReplace(game.scripts, '\\', '/');
#ifdef INI_ENCODING #ifdef INI_ENCODING
/* Can add more later */ /* Can add more later */
const char *languages[] = const char *languages[] =

View File

@ -38,6 +38,7 @@
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include <stack> #include <stack>
#include <cassert>
#ifdef __APPLE__ #ifdef __APPLE__
#include <iconv.h> #include <iconv.h>