diff --git a/assets/oneshot.desktop b/assets/oneshot.desktop old mode 100644 new mode 100755 diff --git a/scripts/Window_Settings.rb b/scripts/Window_Settings.rb index 90eb5fe..8fa7ad3 100644 --- a/scripts/Window_Settings.rb +++ b/scripts/Window_Settings.rb @@ -155,7 +155,7 @@ class Window_Settings tr('Frameskip'), tr('In-Game Timer'), tr('Language'), - tr('Debug mode(DEVS ONLY!)'), + tr('Debug mode(!)'), tr('One Shot Mode(!)'), ] diff --git a/src/config.cpp b/src/config.cpp index b3ddaf2..624cbef 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -35,20 +35,16 @@ #include "util.h" #include "sdl-util.h" -namespace std -{ - std::ostream& operator<<(std::ostream &os, const std::vector &vec) - { - for (auto item : vec) - { +namespace std{ + std::ostream& operator<<(std::ostream &os, const std::vector &vec){ + for (auto item : vec){ os << item << " "; } return os; } } -static std::string prefPath(const char *org, const char *app) -{ +static std::string prefPath(const char *org, const char *app){ const char *path = PHYSFS_getPrefDir(org, app); if (!path) @@ -71,8 +67,7 @@ namespace po = boost::program_options; Config::Config() {} -void Config::read(int argc, char *argv[]) -{ +void Config::read(int argc, char *argv[]){ #define PO_DESC_ALL \ PO_DESC(debugMode, bool, false) \ PO_DESC(screenMode, bool, false) \ @@ -104,8 +99,7 @@ void Config::read(int argc, char *argv[]) editor.battleTest = false; /* Read arguments sent from the editor */ - if (argc > 1) - { + if (argc > 1){ std::string argv1 = argv[1]; /* RGSS1 uses "debug", 2 and 3 use "test" */ if (argv1 == "debug" || argv1 == "test") @@ -114,8 +108,7 @@ void Config::read(int argc, char *argv[]) editor.battleTest = true; /* Fix offset */ - if (editor.debug || editor.battleTest) - { + if (editor.debug || editor.battleTest){ argc--; argv++; } @@ -134,29 +127,24 @@ void Config::read(int argc, char *argv[]) po::variables_map vm; /* Parse command line options */ - try - { + try{ po::parsed_options cmdPo = po::command_line_parser(argc, argv).options(podesc).run(); po::store(cmdPo, vm); } - catch (po::error &error) - { + catch (po::error &error){ Debug() << "Command line:" << error.what(); } /* Parse configuration file */ SDLRWStream confFile(CONF_FILE, "r"); - if (confFile) - { - try - { + if (confFile){ + try{ po::store(po::parse_config_file(confFile.stream(), podesc, true), vm); po::notify(vm); } - catch (po::error &error) - { + catch (po::error &error){ Debug() << CONF_FILE":" << error.what(); } } @@ -188,8 +176,7 @@ void Config::read(int argc, char *argv[]) #ifdef STEAM /* Override fullscreen config if Big Picture */ - if (const char *env = std::getenv("SteamTenfoot")) - { + if (const char *env = std::getenv("SteamTenfoot")){ if (!strcmp(env, "1")) fullscreen = true; } diff --git a/src/filesystem.cpp b/src/filesystem.cpp index 546cc4f..c1aaeac 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -66,34 +66,28 @@ struct SDLRWIoContext static PHYSFS_Io *createSDLRWIo(const char *filename); -static SDL_IOStream *getSDLRWops(PHYSFS_Io *io) -{ +static SDL_IOStream *getSDLRWops(PHYSFS_Io *io){ return static_cast(io->opaque)->ops; } -static PHYSFS_sint64 SDLRWIoRead(struct PHYSFS_Io *io, void *buf, PHYSFS_uint64 len) -{ +static PHYSFS_sint64 SDLRWIoRead(struct PHYSFS_Io *io, void *buf, PHYSFS_uint64 len){ // return SDL_ReadIO(getSDLRWops(io), buf, 1, len); return SDL_ReadIO(getSDLRWops(io), buf, len); } -static int SDLRWIoSeek(struct PHYSFS_Io *io, PHYSFS_uint64 offset) -{ +static int SDLRWIoSeek(struct PHYSFS_Io *io, PHYSFS_uint64 offset){ return (SDL_SeekIO(getSDLRWops(io), offset, SDL_IOWhence::SDL_IO_SEEK_SET) != -1); } -static PHYSFS_sint64 SDLRWIoTell(struct PHYSFS_Io *io) -{ +static PHYSFS_sint64 SDLRWIoTell(struct PHYSFS_Io *io){ return SDL_SeekIO(getSDLRWops(io), 0, SDL_IOWhence::SDL_IO_SEEK_CUR); } -static PHYSFS_sint64 SDLRWIoLength(struct PHYSFS_Io *io) -{ +static PHYSFS_sint64 SDLRWIoLength(struct PHYSFS_Io *io){ return SDL_GetIOSize(getSDLRWops(io)); } -static struct PHYSFS_Io *SDLRWIoDuplicate(struct PHYSFS_Io *io) -{ +static struct PHYSFS_Io *SDLRWIoDuplicate(struct PHYSFS_Io *io){ SDLRWIoContext *ctx = static_cast(io->opaque); int64_t offset = io->tell(io); PHYSFS_Io *dup = createSDLRWIo(ctx->filename.c_str()); @@ -104,14 +98,12 @@ static struct PHYSFS_Io *SDLRWIoDuplicate(struct PHYSFS_Io *io) return dup; } -static void SDLRWIoDestroy(struct PHYSFS_Io *io) -{ +static void SDLRWIoDestroy(struct PHYSFS_Io *io){ delete static_cast(io->opaque); delete io; } -static PHYSFS_Io SDLRWIoTemplate = -{ +static PHYSFS_Io SDLRWIoTemplate ={ 0, 0, /* version, opaque */ SDLRWIoRead, 0, /* write */ @@ -123,16 +115,12 @@ static PHYSFS_Io SDLRWIoTemplate = SDLRWIoDestroy }; -static PHYSFS_Io *createSDLRWIo(const char *filename) -{ +static PHYSFS_Io *createSDLRWIo(const char *filename){ SDLRWIoContext *ctx; - try - { + try{ ctx = new SDLRWIoContext(filename); - } - catch (const Exception &e) - { + }catch (const Exception &e){ Debug() << "Failed mounting" << filename; return 0; } @@ -144,13 +132,11 @@ static PHYSFS_Io *createSDLRWIo(const char *filename) return io; } -static inline PHYSFS_File *sdlPHYS(void *userdata) -{ +static inline PHYSFS_File *sdlPHYS(void *userdata){ return static_cast(userdata); } -static Sint64 SDL_RWopsSize(void *userdata) -{ +static Sint64 SDL_RWopsSize(void *userdata){ PHYSFS_File *f = sdlPHYS(userdata); if (!f) @@ -159,8 +145,7 @@ static Sint64 SDL_RWopsSize(void *userdata) return PHYSFS_fileLength(f); } -static Sint64 SDL_RWopsSeek(void *userdata, Sint64 offset, SDL_IOWhence whence) -{ +static Sint64 SDL_RWopsSeek(void *userdata, Sint64 offset, SDL_IOWhence whence){ PHYSFS_File *f = sdlPHYS(userdata); if (!f) @@ -187,8 +172,7 @@ static Sint64 SDL_RWopsSeek(void *userdata, Sint64 offset, SDL_IOWhence whence) return (result != 0) ? PHYSFS_tell(f) : -1; } -static size_t SDL_RWopsRead(void *userdata, void *ptr, size_t size, SDL_IOStatus *status) -{ +static size_t SDL_RWopsRead(void *userdata, void *ptr, size_t size, SDL_IOStatus *status){ PHYSFS_File *f = sdlPHYS(userdata); if (!f) @@ -204,8 +188,7 @@ static size_t SDL_RWopsRead(void *userdata, void *ptr, size_t size, SDL_IOStatus return (result != -1) ? (result) : 0; } -static size_t SDL_RWopsWrite(void *userdata, const void *ptr, size_t size, SDL_IOStatus *status) -{ +static size_t SDL_RWopsWrite(void *userdata, const void *ptr, size_t size, SDL_IOStatus *status){ PHYSFS_File *f = sdlPHYS(userdata); if (!f) @@ -219,8 +202,7 @@ static size_t SDL_RWopsWrite(void *userdata, const void *ptr, size_t size, SDL_I return (result != -1) ? (result) : 0; } -static bool SDL_RWopsClose(void *userdata) -{ +static bool SDL_RWopsClose(void *userdata){ PHYSFS_File *f = sdlPHYS(userdata); if (!f) @@ -269,13 +251,10 @@ strcpySafe(char *dst, const char *src, /* Attempt to locate an extension string in a filename. * Either a pointer into the input string pointing at the * extension, or null is returned */ -static const char * -findExt(const char *filename) -{ +static const char *findExt(const char *filename){ size_t len; - for (len = strlen(filename); len > 0; --len) - { + for (len = strlen(filename); len > 0; --len){ if (filename[len] == '/') return 0; @@ -310,16 +289,14 @@ initReadOps(PHYSFS_File *handle, ops = SDL_OpenIO(&iface, handle); } -static void strTolower(std::string &str) -{ +static void strTolower(std::string &str){ for (size_t i = 0; i < str.size(); ++i) str[i] = tolower(str[i]); } // const Uint32 SDL_RWOPS_PHYSFS = SDL_RWOPS_UNKNOWN+10; -struct FileSystemPrivate -{ +struct FileSystemPrivate{ /* Maps: lower case full filepath, * To: mixed case full filepath */ BoostHash pathCache; @@ -345,16 +322,14 @@ FileSystem::FileSystem(bool allowSymlinks) PHYSFS_permitSymbolicLinks(1); } -FileSystem::~FileSystem() -{ +FileSystem::~FileSystem(){ delete p; if (PHYSFS_deinit() == 0) Debug() << "PhyFS failed to deinit."; } -void FileSystem::addPath(const char *path) -{ +void FileSystem::addPath(const char *path){ /* Try the normal mount first */ if (!PHYSFS_mount(path, 0, 1)) { @@ -367,8 +342,7 @@ void FileSystem::addPath(const char *path) } } -struct CacheEnumData -{ +struct CacheEnumData{ FileSystemPrivate *p; std::stack*> fileLists; @@ -393,8 +367,7 @@ struct CacheEnumData } /* Converts in-place */ - void toNFC(char *inout) - { + void toNFC(char *inout){ #ifdef OS_OSX size_t srcSize = strlen(inout); size_t bufSize = sizeof(buf); @@ -417,8 +390,7 @@ struct CacheEnumData }; static PHYSFS_EnumerateCallbackResult -cacheEnumCB(void *d, const char *origdir, const char *fname) -{ +cacheEnumCB(void *d, const char *origdir, const char *fname){ CacheEnumData &data = *static_cast(d); char fullPath[512]; @@ -437,8 +409,7 @@ cacheEnumCB(void *d, const char *origdir, const char *fname) PHYSFS_Stat stat; PHYSFS_stat(fullPath, &stat); - if (stat.filetype == PHYSFS_FILETYPE_DIRECTORY) - { + if (stat.filetype == PHYSFS_FILETYPE_DIRECTORY){ /* Create a new list for this directory */ std::vector &list = data.p->fileLists[lowerCase]; @@ -446,9 +417,7 @@ cacheEnumCB(void *d, const char *origdir, const char *fname) data.fileLists.push(&list); PHYSFS_enumerate(fullPath, cacheEnumCB, d); data.fileLists.pop(); - } - else - { + }else{ /* Get the file list for the directory we're currently * traversing and append this filename to it */ std::vector &list = *data.fileLists.top(); @@ -463,8 +432,7 @@ cacheEnumCB(void *d, const char *origdir, const char *fname) return PHYSFS_ENUM_OK; } -void FileSystem::createPathCache() -{ +void FileSystem::createPathCache(){ CacheEnumData data(p); data.fileLists.push(&p->fileLists[""]); PHYSFS_enumerate("", cacheEnumCB, &data); @@ -472,15 +440,13 @@ void FileSystem::createPathCache() p->havePathCache = true; } -struct FontSetsCBData -{ +struct FontSetsCBData{ FileSystemPrivate *p; SharedFontState *sfs; }; static PHYSFS_EnumerateCallbackResult -fontSetEnumCB (void *data, const char *dir, const char *fname) -{ +fontSetEnumCB (void *data, const char *dir, const char *fname){ FontSetsCBData *d = static_cast(data); /* Only consider filenames with font extensions */ @@ -516,15 +482,13 @@ fontSetEnumCB (void *data, const char *dir, const char *fname) return PHYSFS_ENUM_OK; } -void FileSystem::initFontSets(SharedFontState &sfs) -{ +void FileSystem::initFontSets(SharedFontState &sfs){ FontSetsCBData d = { p, &sfs }; PHYSFS_enumerate("Fonts", fontSetEnumCB, &d); } -struct OpenReadEnumData -{ +struct OpenReadEnumData{ FileSystem::OpenHandler &handler; SDL_IOStream* ops; @@ -554,8 +518,7 @@ struct OpenReadEnumData }; static PHYSFS_EnumerateCallbackResult -openReadEnumCB(void *d, const char *dirpath, const char *filename) -{ +openReadEnumCB(void *d, const char *dirpath, const char *filename){ OpenReadEnumData &data = *static_cast(d); char buffer[512]; const char *fullPath; @@ -567,12 +530,10 @@ openReadEnumCB(void *d, const char *dirpath, const char *filename) if (strncmp(filename, data.filename, data.filenameN) != 0) return PHYSFS_ENUM_OK; - if (!*dirpath) - { + if (!*dirpath){ fullPath = filename; } - else - { + else{ snprintf(buffer, sizeof(buffer), "%s/%s", dirpath, filename); fullPath = buffer; } @@ -592,8 +553,7 @@ openReadEnumCB(void *d, const char *dirpath, const char *filename) PHYSFS_File *phys = PHYSFS_openRead(fullPath); - if (!phys) - { + if (!phys){ /* Failing to open this file here means there must * be a deeper rooted problem somewhere within PhysFS. * Just abort alltogether. */ @@ -614,8 +574,7 @@ openReadEnumCB(void *d, const char *dirpath, const char *filename) return PHYSFS_ENUM_OK; } -void FileSystem::openRead(OpenHandler &handler, const char *filename) -{ +void FileSystem::openRead(OpenHandler &handler, const char *filename){ char buffer[512]; size_t len = strcpySafe(buffer, filename, sizeof(buffer), -1); char *delim; @@ -634,8 +593,7 @@ void FileSystem::openRead(OpenHandler &handler, const char *filename) const char *file = buffer; const char *dir = ""; - if (!root) - { + if (!root){ /* Cut the buffer in half so we can use it * for both filename and directory path */ *delim = '\0'; @@ -646,17 +604,14 @@ void FileSystem::openRead(OpenHandler &handler, const char *filename) OpenReadEnumData data(handler, file, len + buffer - delim - !root, p->havePathCache ? &p->pathCache : 0); - if (p->havePathCache) - { + if (p->havePathCache){ /* Get the list of files contained in this directory * and manually iterate over them */ const std::vector &fileList = p->fileLists[dir]; for (size_t i = 0; i < fileList.size(); ++i) openReadEnumCB(&data, dir, fileList[i].c_str()); - } - else - { + }else{ PHYSFS_enumerate(dir, openReadEnumCB, &data); } @@ -678,7 +633,6 @@ void FileSystem::openReadRaw(SDL_IOStream* &stream, initReadOps(handle, stream); } -bool FileSystem::exists(const char *filename) -{ +bool FileSystem::exists(const char *filename){ return PHYSFS_exists(filename); } diff --git a/src/main.cpp b/src/main.cpp index d41c1c8..78c5c6c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -389,8 +389,7 @@ int main(int argc, char *argv[]){ if (rtData.rqTermAck) SDL_WaitThread(rgssThread, 0); else - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, conf.windowTitle.c_str(), - "The RGSS script seems to be stuck and OneShot will now force quit", win); + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, conf.windowTitle.c_str(), "The RGSS script seems to be stuck and OneShot: sunshine will now force quit", win); if (!rtData.rgssErrorMsg.empty()){ Debug() << rtData.rgssErrorMsg; diff --git a/src/oneshot.cpp b/src/oneshot.cpp index 4d0ec02..fd77b99 100644 --- a/src/oneshot.cpp +++ b/src/oneshot.cpp @@ -22,7 +22,6 @@ #include #include #include - #include #elif defined __APPLE__ || __linux__ #include #include @@ -164,8 +163,7 @@ static WCHAR *w32_toWide(const char *str){ #endif Oneshot::Oneshot(RGSSThreadData &threadData) : - threadData(threadData) -{ + threadData(threadData){ p = new OneshotPrivate(); p->window = threadData.window; p->savePath = threadData.config.commonDataPath.substr(0, threadData.config.commonDataPath.size() - 1); diff --git a/windows/icon.ico b/windows/icon.ico index 2a10780..4ba96df 100644 Binary files a/windows/icon.ico and b/windows/icon.ico differ