From 2fd585393db6b7349875897a56cd990a0e7efbe0 Mon Sep 17 00:00:00 2001 From: Struma Date: Mon, 22 Feb 2021 01:22:26 -0500 Subject: [PATCH] the not-so-great warning purge --- binding/disposable-binding.h | 6 ++- binding/filesystem-binding.cpp | 2 + binding/http-binding.cpp | 6 +++ macos/mkxp-z.xcodeproj/project.pbxproj | 5 +- macos/views/SettingsMenuController.mm | 69 ++++++++++++++++---------- src/config.cpp | 10 ++-- src/display/graphics.cpp | 2 - src/display/tilemap.cpp | 4 +- src/filesystem/filesystemImpl.cpp | 2 +- src/filesystem/filesystemImplApple.mm | 1 - src/input/input.cpp | 6 --- src/input/input.h | 3 -- 12 files changed, 64 insertions(+), 52 deletions(-) diff --git a/binding/disposable-binding.h b/binding/disposable-binding.h index 7c249e2..6a4c50e 100644 --- a/binding/disposable-binding.h +++ b/binding/disposable-binding.h @@ -31,8 +31,9 @@ inline void disposableAddChild(VALUE disp, VALUE child) { - if (NIL_P(disp) || NIL_P(child)) + if (NIL_P(disp) || NIL_P(child)) { return; + } VALUE children = rb_iv_get(disp, "children"); @@ -54,8 +55,9 @@ disposableAddChild(VALUE disp, VALUE child) inline void disposableRemoveChild(VALUE disp, VALUE child) { - if (NIL_P(disp) || NIL_P(child)) + if (NIL_P(disp) || NIL_P(child)) { return; + } VALUE children = rb_iv_get(disp, "children"); if (NIL_P(children)) diff --git a/binding/filesystem-binding.cpp b/binding/filesystem-binding.cpp index 2baa704..6297b4b 100644 --- a/binding/filesystem-binding.cpp +++ b/binding/filesystem-binding.cpp @@ -126,12 +126,14 @@ RB_METHOD(fileIntBinmode) { return Qnil; } +#if RAPI_FULL <= 187 RB_METHOD(fileIntPos) { SDL_RWops *ops = getPrivateData(self); long long pos = SDL_RWtell(ops); // Will return -1 if it doesn't work return LL2NUM(pos); } +#endif VALUE kernelLoadDataInt(const char *filename, bool rubyExc, bool raw) { diff --git a/binding/http-binding.cpp b/binding/http-binding.cpp index b624163..0f793fb 100644 --- a/binding/http-binding.cpp +++ b/binding/http-binding.cpp @@ -156,6 +156,9 @@ VALUE json2rb(json5pp::value const &v) { } return ret; } + + // This should be unreachable + return Qnil; } json5pp::value rb2json(VALUE v) { @@ -200,6 +203,9 @@ json5pp::value rb2json(VALUE v) { } raiseRbExc(Exception(Exception::MKXPError, "Invalid value for JSON: %s", RSTRING_PTR(rb_inspect(v)))); + + // This should be unreachable + return json5pp::value(0); } RB_METHOD(httpJsonParse) { diff --git a/macos/mkxp-z.xcodeproj/project.pbxproj b/macos/mkxp-z.xcodeproj/project.pbxproj index 3771c04..b19c8bc 100644 --- a/macos/mkxp-z.xcodeproj/project.pbxproj +++ b/macos/mkxp-z.xcodeproj/project.pbxproj @@ -3376,10 +3376,7 @@ "$(PROJECT_DIR)/Dependencies/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.12; - OTHER_CFLAGS = ( - "-fdeclspec", - "-w", - ); + OTHER_CFLAGS = "-fdeclspec"; OTHER_CODE_SIGN_FLAGS = "--ignore-resources"; PRODUCT_BUNDLE_IDENTIFIER = "org.zoro.mkxp-z"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/macos/views/SettingsMenuController.mm b/macos/views/SettingsMenuController.mm index c44c5be..fb5919a 100644 --- a/macos/views/SettingsMenuController.mm +++ b/macos/views/SettingsMenuController.mm @@ -50,6 +50,9 @@ typedef NSMutableArray BindingIndexArray; __weak IBOutlet NSButton *bindingButton3; __weak IBOutlet NSButton *bindingButton4; + // For keeping track of which buttons to check for + int sysver; + // MKXP Keybindings BDescVec *binds; @@ -84,9 +87,10 @@ typedef NSMutableArray BindingIndexArray; return s; } --(void)raise { +-(SettingsMenu*)raise { if (_window) [_window orderFront:self]; + return self; } -(void)closeWindow { @@ -96,6 +100,7 @@ typedef NSMutableArray BindingIndexArray; -(SettingsMenu*)setWindow:(NSWindow*)window { _window = window; + return self; } - (IBAction)acceptButton:(NSButton *)sender { @@ -117,6 +122,11 @@ typedef NSMutableArray BindingIndexArray; - (void)viewDidLoad { [super viewDidLoad]; + sysver = 12; + if (@available(macOS 10.14, *)) sysver += 2; + if (@available(macOS 10.15, *)) sysver++; + if (@available(macOS 11.0, *)) sysver++; + isListening = false; keepCurrentButtonSelection = false; @@ -146,15 +156,15 @@ typedef NSMutableArray BindingIndexArray; #define checkButtonStart if (0) {} #define checkButtonEnd else { return; } -#define checkButtonElement(e, b, n) \ -else if (element == gamepad.e && gamepad.b.isPressed) { \ +#define checkButtonElement(e, b, n, min) \ +else if (sysver >= min && element == gamepad.e && gamepad.b.isPressed) { \ s.type = JButton; \ s.d.jb = n; \ } -#define checkButtonAlt(b, n) checkButtonElement(b, b, n) +#define checkButtonAlt(b, n, min) checkButtonElement(b, b, n, min) -#define checkButton(b, n) checkButtonAlt(button##b, n) +#define checkButton(b, n, min) checkButtonAlt(button##b, n, min) #define setAxisData(a, n) \ GCControllerAxisInput *axis = gamepad.a; \ @@ -170,23 +180,31 @@ s.d.ja.dir = (axis.value >= 0) ? AxisDir::Positive : AxisDir::Negative; BindingDesc d; d.target = (Input::ButtonCode)currentButtonCode; SourceDesc s; - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunguarded-availability-new" checkButtonStart - checkButton(A, 0) - checkButton(B, 1) - checkButton(X, 2) - checkButton(Y, 3) - checkButtonElement(dpad, dpad.up, 11) - checkButtonElement(dpad, dpad.down, 12) - checkButtonElement(dpad, dpad.left, 13) - checkButtonElement(dpad, dpad.right, 14) - checkButtonAlt(leftShoulder, 9) - checkButtonAlt(rightShoulder, 10) - checkButtonAlt(leftThumbstickButton, 7) - checkButtonAlt(rightThumbstickButton, 8) - checkButton(Home, 5) - checkButton(Menu, 6) - checkButton(Options, 4) + checkButton(A, 0, 12) + checkButton(B, 1, 12) + checkButton(X, 2, 12) + checkButton(Y, 3, 12) + checkButtonElement(dpad, dpad.up, 11, 12) + checkButtonElement(dpad, dpad.down, 12, 12) + checkButtonElement(dpad, dpad.left, 13, 12) + checkButtonElement(dpad, dpad.right, 14, 12) + checkButtonAlt(leftShoulder, 9, 12) + checkButtonAlt(rightShoulder, 10, 12) + + // Requires macOS 10.14.1+ + checkButtonAlt(leftThumbstickButton, 7, 14) + checkButtonAlt(rightThumbstickButton, 8, 14) + + // Requires macOS 10.15+ + checkButton(Menu, 6, 15) + checkButton(Options, 4, 15) + + // Requires macOS 11.0+ + checkButton(Home, 5, 16) checkAxis(leftThumbstick, xAxis, 0) checkAxis(leftThumbstick, yAxis, 1) @@ -194,14 +212,12 @@ s.d.ja.dir = (axis.value >= 0) ? AxisDir::Positive : AxisDir::Negative; checkAxis(rightThumbstick, yAxis, 3) else if (element == gamepad.leftTrigger && (gamepad.leftTrigger.value >= 0.5 || gamepad.leftTrigger.value <= -0.5)) { - GCControllerButtonInput *trigger = gamepad.leftTrigger; s.type = JAxis; s.d.ja.axis = 4; s.d.ja.dir = AxisDir::Positive; } else if (element == gamepad.rightTrigger && (gamepad.rightTrigger.value >= 0.5 || gamepad.rightTrigger.value <= -0.5)) { - GCControllerButtonInput *trigger = gamepad.rightTrigger; s.type = JAxis; s.d.ja.axis = 5; s.d.ja.dir = AxisDir::Positive; @@ -209,6 +225,7 @@ s.d.ja.dir = (axis.value >= 0) ? AxisDir::Positive : AxisDir::Negative; checkButtonEnd; +#pragma clang diagnostic pop d.src = s; binds->push_back(d); [self setNotListening:true]; @@ -330,7 +347,7 @@ if (!data.config.kbActionNames.value.empty()) bindingNames[@(Input::code)] = \ return cell; } - int col = tableID.integerValue; + long col = tableID.integerValue; if (nsbinds[@(buttonCode)].count < col) { cell.textField.stringValue = @""; @@ -351,7 +368,7 @@ if (!data.config.kbActionNames.value.empty()) bindingNames[@(Input::code)] = \ return @(buttonCode); } - int col = tableID.integerValue; + long col = tableID.integerValue; if (nsbinds[@(buttonCode)].count < col) { return 0; @@ -414,7 +431,7 @@ if (!data.config.kbActionNames.value.empty()) bindingNames[@(Input::code)] = \ bindingButton4.title = pnames[3]; [self enableButtons:true]; - return pnames.count; + return (int)pnames.count; } - (void)enableButtons:(bool)defaultSetting { diff --git a/src/config.cpp b/src/config.cpp index 863fb6d..905da97 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -40,7 +40,7 @@ void fillStringVec(json::value &item, std::vector &vector) { return; } auto &array = item.as_array(); - for (int i = 0; i < array.size(); i++) { + for (size_t i = 0; i < array.size(); i++) { if (!array[i].is_string()) continue; @@ -64,10 +64,10 @@ bool copyObject(json::value &dest, json::value &src, const char *objectName = "" if (it.second.is_object() && destVec[it.first].is_object()) continue; - if (it.second.is_array() && destVec[it.first].is_array() || - it.second.is_number() && destVec[it.first].is_number() || - it.second.is_string() && destVec[it.first].is_string() || - it.second.is_boolean() && destVec[it.first].is_boolean()) + if ((it.second.is_array() && destVec[it.first].is_array()) || + (it.second.is_number() && destVec[it.first].is_number()) || + (it.second.is_string() && destVec[it.first].is_string()) || + (it.second.is_boolean() && destVec[it.first].is_boolean()) ) { destVec[it.first] = it.second; } diff --git a/src/display/graphics.cpp b/src/display/graphics.cpp index a3056a8..ac4cea6 100644 --- a/src/display/graphics.cpp +++ b/src/display/graphics.cpp @@ -838,7 +838,6 @@ void Graphics::resizeScreen(int width, int height) { glState.scissorBox.set(IntRect(0, 0, p->scRes.x, p->scRes.y)); - int cur_sz = p->scSize.x; shState->eThread().requestWindowResize(width, height); usleep(50000); update(); @@ -922,7 +921,6 @@ void Graphics::setScale(double factor) { int widthpx = p->scRes.x * factor; int heightpx = p->scRes.y * factor; - int cur_sz = p->scSize.x; shState->eThread().requestWindowResize(widthpx, heightpx); usleep(50000); update(); diff --git a/src/display/tilemap.cpp b/src/display/tilemap.cpp index 78ac5d6..35e9938 100644 --- a/src/display/tilemap.cpp +++ b/src/display/tilemap.cpp @@ -61,7 +61,7 @@ static const int autotileCount = 7; static const int atFrames = 8; static const int atFrameDur = 15; static const int atAreaW = autotileW * atFrames; -static const int atAreaH = autotileH * autotileCount; +//static const int atAreaH = autotileH * autotileCount; static const int tsLaneW = tilesetW / 1; @@ -737,7 +737,7 @@ struct TilemapPrivate else { int layerInd = y + prio; - if (layerInd >= zlayersMax) + if ((size_t)layerInd >= zlayersMax) return; targetArray = &zlayerVert[layerInd]; } diff --git a/src/filesystem/filesystemImpl.cpp b/src/filesystem/filesystemImpl.cpp index 79b7170..baada63 100644 --- a/src/filesystem/filesystemImpl.cpp +++ b/src/filesystem/filesystemImpl.cpp @@ -76,7 +76,7 @@ std::string filesystemImpl::normalizePath(const char *path, bool preferred, bool stdPath = stdPath.lexically_normal(); std::string ret(stdPath); - for (int i = 0; i < ret.length(); i++) { + for (size_t i = 0; i < ret.length(); i++) { char sep; char sep_alt; #ifdef __WINDOWS__ diff --git a/src/filesystem/filesystemImplApple.mm b/src/filesystem/filesystemImplApple.mm index b39d51d..975de8e 100644 --- a/src/filesystem/filesystemImplApple.mm +++ b/src/filesystem/filesystemImplApple.mm @@ -22,7 +22,6 @@ #define NSTOPATH(str) [NSFileManager.defaultManager fileSystemRepresentationWithPath:str] bool filesystemImpl::fileExists(const char *path) { - NSString *nspath = PATHTONS(path); BOOL isDir; return [NSFileManager.defaultManager fileExistsAtPath:PATHTONS(path) isDirectory: &isDir] && !isDir; } diff --git a/src/input/input.cpp b/src/input/input.cpp index 58cfe34..3c2a6f6 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -1161,12 +1161,6 @@ std::vector Input::getBindings(ButtonCode code) { return ret; } -std::string &Input::getActionName(int button) { - for (const auto &b : p->kbBindings) { - - } -} - bool Input::isPressed(int button) { return p->getStateCheck(button).pressed; diff --git a/src/input/input.h b/src/input/input.h index 2e7f9fe..da644d7 100644 --- a/src/input/input.h +++ b/src/input/input.h @@ -57,9 +57,6 @@ public: std::vector getBindings(ButtonCode code); - std::string &getActionName(int button); - void setActionName(int button, const char *name); - bool isPressed(int button); bool isTriggered(int button); bool isRepeated(int button);