This commit is contained in:
Struma 2021-05-23 21:55:02 -04:00 committed by Roza
parent 84c4f97c6c
commit ca596cbaf9
9 changed files with 1164 additions and 1160 deletions

View file

@ -48,7 +48,7 @@ extern "C" {
#endif #endif
} }
#ifdef __WINDOWS__ #ifdef __WIN32__
#include <fcntl.h> #include <fcntl.h>
#endif #endif
@ -447,7 +447,7 @@ RB_METHOD(mkxpUserName) {
// Using the Windows API isn't working with usernames that involve Unicode // Using the Windows API isn't working with usernames that involve Unicode
// characters for some dumb reason // characters for some dumb reason
#ifdef __WINDOWS__ #ifdef __WIN32__
VALUE env = rb_const_get(rb_mKernel, rb_intern("ENV")); VALUE env = rb_const_get(rb_mKernel, rb_intern("ENV"));
return rb_funcall(env, rb_intern("[]"), 1, rb_str_new_cstr("USERNAME")); return rb_funcall(env, rb_intern("[]"), 1, rb_str_new_cstr("USERNAME"));
#else #else
@ -919,7 +919,7 @@ static void configureWindowsStreams() {
#undef HANDLE_VALID #undef HANDLE_VALID
} }
#endif // #ifdef __WINDOWS__ #endif // #ifdef __WIN32__
static void showExc(VALUE exc, const BacktraceData &btData) { static void showExc(VALUE exc, const BacktraceData &btData) {
VALUE bt = rb_funcall2(exc, rb_intern("backtrace"), 0, NULL); VALUE bt = rb_funcall2(exc, rb_intern("backtrace"), 0, NULL);
@ -996,13 +996,13 @@ static void mriBindingExecute() {
/* Normally only a ruby executable would do a sysinit, /* Normally only a ruby executable would do a sysinit,
* but not doing it will lead to crashes due to closed * but not doing it will lead to crashes due to closed
* stdio streams on some platforms (eg. Windows) */ * stdio streams on some platforms (eg. Windows) */
#ifdef __WINDOWS__ #ifdef __WIN32__
if (!conf.editor.debug) { if (!conf.editor.debug) {
#endif #endif
int argc = 0; int argc = 0;
char **argv = 0; char **argv = 0;
ruby_sysinit(&argc, &argv); ruby_sysinit(&argc, &argv);
#ifdef __WINDOWS__ #ifdef __WIN32__
} }
#endif #endif

View file

@ -78,7 +78,7 @@ endif
# ==================== # ====================
# Suppress warnings # Suppress warnings
global_args += ['-Wno-non-virtual-dtor', '-Wno-reorder', '-Wno-uninitialized', '-Wno-unknown-pragmas'] global_args += ['-Wno-non-virtual-dtor', '-Wno-reorder', '-Wno-uninitialized', '-Wno-unknown-pragmas', '-Wno-stringop-truncation']
if compilers['cpp'].get_id() == 'clang' if compilers['cpp'].get_id() == 'clang'
global_args += ['-Wno-undefined-var-template', '-Wno-delete-non-abstract-non-virtual-dtor'] global_args += ['-Wno-undefined-var-template', '-Wno-delete-non-abstract-non-virtual-dtor']
endif endif

View file

@ -12,7 +12,7 @@
#define FLUID_LIB "@rpath/libfluidsynth.dylib" #define FLUID_LIB "@rpath/libfluidsynth.dylib"
#elif __APPLE__ #elif __APPLE__
#define FLUID_LIB "libfluidsynth.3.dylib" #define FLUID_LIB "libfluidsynth.3.dylib"
#elif __WINDOWS__ #elif __WIN32__
#define FLUID_LIB "fluidsynth.dll" #define FLUID_LIB "fluidsynth.dll"
#else #else
#error "platform not recognized" #error "platform not recognized"

View file

@ -1,23 +1,23 @@
/* /*
** bitmap.cpp ** bitmap.cpp
** **
** This file is part of mkxp. ** This file is part of mkxp.
** **
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com> ** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** **
** mkxp is free software: you can redistribute it and/or modify ** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 2 of the License, or ** the Free Software Foundation, either version 2 of the License, or
** (at your option) any later version. ** (at your option) any later version.
** **
** mkxp is distributed in the hope that it will be useful, ** mkxp is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
** **
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with mkxp. If not, see <http://www.gnu.org/licenses/>. ** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "bitmap.h" #include "bitmap.h"
@ -59,24 +59,24 @@ extern "C" {
} }
#define GUARD_MEGA \ #define GUARD_MEGA \
{ \ { \
if (p->megaSurface) \ if (p->megaSurface) \
throw Exception(Exception::MKXPError, \ throw Exception(Exception::MKXPError, \
"Operation not supported for mega surfaces"); \ "Operation not supported for mega surfaces"); \
} }
#define GUARD_ANIMATED \ #define GUARD_ANIMATED \
{ \ { \
if (p->animation.enabled) \ if (p->animation.enabled) \
throw Exception(Exception::MKXPError, \ throw Exception(Exception::MKXPError, \
"Operation not supported for animated bitmaps"); \ "Operation not supported for animated bitmaps"); \
} }
#define GUARD_UNANIMATED \ #define GUARD_UNANIMATED \
{ \ { \
if (!p->animation.enabled) \ if (!p->animation.enabled) \
throw Exception(Exception::MKXPError, \ throw Exception(Exception::MKXPError, \
"Operation not supported for static bitmaps"); \ "Operation not supported for static bitmaps"); \
} }
#define OUTLINE_SIZE 1 #define OUTLINE_SIZE 1

View file

@ -46,7 +46,7 @@
#include <iconv.h> #include <iconv.h>
#endif #endif
#ifdef __WINDOWS__ #ifdef __WIN32__
#include <direct.h> #include <direct.h>
#endif #endif

View file

@ -79,7 +79,7 @@ std::string filesystemImpl::normalizePath(const char *path, bool preferred, bool
for (size_t i = 0; i < ret.length(); i++) { for (size_t i = 0; i < ret.length(); i++) {
char sep; char sep;
char sep_alt; char sep_alt;
#ifdef __WINDOWS__ #ifdef __WIN32__
if (preferred) { if (preferred) {
sep = '\\'; sep = '\\';
sep_alt = '/'; sep_alt = '/';

View file

@ -47,7 +47,7 @@
#include "system/system.h" #include "system/system.h"
#if defined(__WINDOWS__) #if defined(__WIN32__)
#include "resource.h" #include "resource.h"
#include <Winsock2.h> #include <Winsock2.h>
#include "util/win-consoleutils.h" #include "util/win-consoleutils.h"
@ -276,7 +276,7 @@ int main(int argc, char *argv[]) {
return 0; return 0;
} }
#if defined(__WINDOWS__) #if defined(__WIN32__)
WSAData wsadata = {0}; WSAData wsadata = {0};
if (WSAStartup(0x101, &wsadata) || wsadata.wVersion != 0x101) { if (WSAStartup(0x101, &wsadata) || wsadata.wVersion != 0x101) {
char buf[200]; char buf[200];
@ -443,7 +443,7 @@ int main(int argc, char *argv[]) {
alcCloseDevice(alcDev); alcCloseDevice(alcDev);
SDL_DestroyWindow(win); SDL_DestroyWindow(win);
#if defined(__WINDOWS__) #if defined(__WIN32__)
if (wsadata.wVersion) if (wsadata.wVersion)
WSACleanup(); WSACleanup();
#endif #endif

View file

@ -14,7 +14,7 @@
#define MKXPZ_PLATFORM_MACOS 1 #define MKXPZ_PLATFORM_MACOS 1
#define MKXPZ_PLATFORM_LINUX 2 #define MKXPZ_PLATFORM_LINUX 2
#ifdef __WINDOWS__ #ifdef __WIN32__
#define MKXPZ_PLATFORM MKXPZ_PLATFORM_WINDOWS #define MKXPZ_PLATFORM MKXPZ_PLATFORM_WINDOWS
#elif defined __APPLE__ #elif defined __APPLE__
#define MKXPZ_PLATFORM MKXPZ_PLATFORM_MACOS #define MKXPZ_PLATFORM MKXPZ_PLATFORM_MACOS

View file

@ -14,6 +14,7 @@
#include <locale> #include <locale>
#endif #endif
#include <SDL_loadso.h>
#include <cstring> #include <cstring>
#include <string> #include <string>
@ -43,10 +44,13 @@ std::string systemImpl::getSystemLanguage() {
} }
std::string systemImpl::getUserName() { std::string systemImpl::getUserName() {
char ret[30];
#ifdef __WINDOWS__ #ifdef __WIN32__
GetUserName(ret, sizeof(ret)); // The Ruby binding gets the username from the environment loaded
// with Ruby instead, should fix getting it from WinAPI at some point
return std::string("unused");
#else #else
char ret[30];
char *username = getenv("USER"); char *username = getenv("USER");
if (username) if (username)
strncpy(ret, username, sizeof(ret)); strncpy(ret, username, sizeof(ret));