Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various warning fixes #663

Merged
merged 4 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/libultraship/libultra/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#define CONT_JOYPORT 0x0004
#define CONT_EEPROM 0x8000
#define CONT_EEP16K 0x4000
#define CONT_TYPE_MASK 0x1f07
#define CONT_TYPE_MASK 0x1F07
#define CONT_TYPE_NORMAL 0x0005
#define CONT_TYPE_MOUSE 0x0002
#define CONT_TYPE_VOICE 0x0100
Expand Down Expand Up @@ -148,4 +148,4 @@ u32 osAiGetLength(void);
};
#endif

#endif
#endif
2 changes: 1 addition & 1 deletion src/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ std::shared_ptr<Context> Context::CreateUninitializedInstance(const std::string
}

Context::Context(std::string name, std::string shortName, std::string configFilePath)
: mName(std::move(name)), mShortName(std::move(shortName)), mConfigFilePath(std::move(configFilePath)) {
: mConfigFilePath(std::move(configFilePath)), mName(std::move(name)), mShortName(std::move(shortName)) {
}

void Context::Init(const std::vector<std::string>& otrFiles, const std::unordered_set<uint32_t>& validHashes,
Expand Down
2 changes: 1 addition & 1 deletion src/config/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void Config::EraseBlock(const std::string& key) {
nlohmann::json& gjson2 = gjson;
std::vector<std::string> dots = StringHelper::Split(key, ".");
if (dots.size() > 1) {
int curDot = 0;
size_t curDot = 0;
for (auto& dot : dots) {
if (gjson2.contains(dot)) {
if (curDot == dots.size()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
namespace Ship {
KeyboardKeyToAxisDirectionMapping::KeyboardKeyToAxisDirectionMapping(uint8_t portIndex, Stick stick,
Direction direction, KbScancode scancode)
: ControllerInputMapping(ShipDeviceIndex::Keyboard),
ControllerAxisDirectionMapping(ShipDeviceIndex::Keyboard, portIndex, stick, direction),
KeyboardKeyToAnyMapping(scancode) {
: ControllerInputMapping(ShipDeviceIndex::Keyboard), KeyboardKeyToAnyMapping(scancode),
ControllerAxisDirectionMapping(ShipDeviceIndex::Keyboard, portIndex, stick, direction) {
}

float KeyboardKeyToAxisDirectionMapping::GetNormalizedAxisDirectionValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
namespace Ship {
KeyboardKeyToButtonMapping::KeyboardKeyToButtonMapping(uint8_t portIndex, CONTROLLERBUTTONS_T bitmask,
KbScancode scancode)
: ControllerInputMapping(ShipDeviceIndex::Keyboard),
ControllerButtonMapping(ShipDeviceIndex::Keyboard, portIndex, bitmask), KeyboardKeyToAnyMapping(scancode) {
: ControllerInputMapping(ShipDeviceIndex::Keyboard), KeyboardKeyToAnyMapping(scancode),
ControllerButtonMapping(ShipDeviceIndex::Keyboard, portIndex, bitmask) {
}

void KeyboardKeyToButtonMapping::UpdatePad(CONTROLLERBUTTONS_T& padButtons) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
#ifdef __cplusplus
namespace Ship {
#endif

typedef enum KbEventType {
LUS_KB_EVENT_KEY_DOWN = 0,
LUS_KB_EVENT_KEY_UP = 1,
LUS_KB_EVENT_ALL_KEYS_UP = 2,
LUS_KB_EVENT_MAX
};
} KbEventType;

typedef enum KbScancode {
LUS_KB_UNKNOWN = 0,
Expand Down Expand Up @@ -115,8 +116,8 @@ typedef enum KbScancode {
LUS_KB_ARROWKEY_RIGHT = 333,
LUS_KB_ARROWKEY_DOWN = 336,
LUS_KB_MAX
} KbScancode;

};
#ifdef __cplusplus
} // namespace Ship
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ std::string SDLAxisDirectionToAnyMapping::GetPhysicalInputName() {
return "R";
}
break;
default:
break;
}

return StringHelper::Sprintf("Axis %d %s", mControllerAxis,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ std::string SDLButtonToAnyMapping::GetGameCubeButtonName() {
return StringHelper::Sprintf("D-Pad %s", ICON_FA_ARROW_LEFT);
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT:
return StringHelper::Sprintf("D-Pad %s", ICON_FA_ARROW_RIGHT);
default:
break;
}

return GetGenericButtonName();
Expand Down Expand Up @@ -112,6 +114,8 @@ std::string SDLButtonToAnyMapping::GetPlaystationButtonName() {
return StringHelper::Sprintf("%s", ICON_FA_MICROPHONE_SLASH);
}
break;
default:
break;
}

return GetGenericButtonName();
Expand Down Expand Up @@ -152,6 +156,8 @@ std::string SDLButtonToAnyMapping::GetSwitchButtonName() {
case SDL_CONTROLLER_BUTTON_MISC1:
return "Capture"; /* Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button,
Amazon Luna microphone button */
default:
break;
}

return GetGenericButtonName();
Expand Down Expand Up @@ -206,6 +212,8 @@ std::string SDLButtonToAnyMapping::GetXboxButtonName() {
return "P3";
case SDL_CONTROLLER_BUTTON_PADDLE4:
return "P4";
default:
break;
}

return GetGenericButtonName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
namespace Ship {
SDLButtonToButtonMapping::SDLButtonToButtonMapping(ShipDeviceIndex shipDeviceIndex, uint8_t portIndex,
CONTROLLERBUTTONS_T bitmask, int32_t sdlControllerButton)
: ControllerInputMapping(shipDeviceIndex), ControllerButtonMapping(shipDeviceIndex, portIndex, bitmask),
SDLButtonToAnyMapping(shipDeviceIndex, sdlControllerButton) {
: ControllerInputMapping(shipDeviceIndex), SDLButtonToAnyMapping(shipDeviceIndex, sdlControllerButton),
ControllerButtonMapping(shipDeviceIndex, portIndex, bitmask) {
}

void SDLButtonToButtonMapping::UpdatePad(CONTROLLERBUTTONS_T& padButtons) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Ship {
SDLGyroMapping::SDLGyroMapping(ShipDeviceIndex shipDeviceIndex, uint8_t portIndex, float sensitivity,
float neutralPitch, float neutralYaw, float neutralRoll)
: ControllerInputMapping(shipDeviceIndex), ControllerGyroMapping(shipDeviceIndex, portIndex, sensitivity),
mNeutralPitch(neutralPitch), SDLMapping(shipDeviceIndex), mNeutralYaw(neutralYaw), mNeutralRoll(neutralRoll) {
SDLMapping(shipDeviceIndex), mNeutralPitch(neutralPitch), mNeutralYaw(neutralYaw), mNeutralRoll(neutralRoll) {
}

void SDLGyroMapping::Recalibrate() {
Expand Down
7 changes: 6 additions & 1 deletion src/graphic/Fast3D/gfx_pc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3848,9 +3848,12 @@ const char* GfxGetOpcodeName(int8_t opcode) {
} else {
SPDLOG_CRITICAL("Unhandled OP code: 0x{:X}, for loaded ucode: {}", (uint8_t)opcode,
(uint32_t)ucode_handler_index);
return nullptr;
}
} else {
SPDLOG_CRITICAL("Unhandled OP code: 0x{:X}, invalid ucode: {}", (uint8_t)opcode, (uint32_t)ucode_handler_index);
}

return nullptr;
}
Archez marked this conversation as resolved.
Show resolved Hide resolved

// TODO, implement a system where we can get the current opcode handler by writing to the GWords. If the powers that be
Expand Down Expand Up @@ -3890,6 +3893,8 @@ static void gfx_step() {
SPDLOG_CRITICAL("Unhandled OP code: 0x{:X}, for loaded ucode: {}", (uint8_t)opcode,
(uint32_t)ucode_handler_index);
}
} else {
SPDLOG_CRITICAL("Unhandled OP code: 0x{:X}, invalid ucode: {}", (uint8_t)opcode, (uint32_t)ucode_handler_index);
}

++cmd;
Expand Down
2 changes: 1 addition & 1 deletion src/graphic/Fast3D/gfx_pc.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ typedef enum Attribute {
CULL_BOTH,
MV_VIEWPORT,
MV_LIGHT,
};
} Attribute;

extern RDP g_rdp;
extern RSP g_rsp;
Expand Down
2 changes: 1 addition & 1 deletion src/resource/archive/Archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Ship {
Archive::Archive(const std::string& path)
: mHasGameVersion(false), mGameVersion(UNKNOWN_GAME_VERSION), mPath(path), mIsLoaded(false) {
: mIsLoaded(false), mHasGameVersion(false), mGameVersion(UNKNOWN_GAME_VERSION), mPath(path) {
mHashes = std::make_shared<std::unordered_map<uint64_t, std::string>>();
}

Expand Down
9 changes: 5 additions & 4 deletions src/window/gui/ConsoleWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ int32_t ConsoleWindow::HelpCommand(std::shared_ptr<Console> console, const std::

if (!cmd.second.Arguments.empty()) {
*output += "\n - Arguments:";
for (int i = 0; i < cmd.second.Arguments.size(); i += 1) {
for (size_t i = 0; i < cmd.second.Arguments.size(); i += 1) {
const CommandArgument& argument = cmd.second.Arguments[i];

*output += "\n - Info=" + argument.Info;
Expand Down Expand Up @@ -399,7 +399,7 @@ void ConsoleWindow::DrawElement() {
}

const std::vector<ConsoleLine> channel = mLog[mCurrentChannel];
for (size_t i = 0; i < static_cast<int32_t>(channel.size()); i++) {
for (size_t i = 0; i < channel.size(); i++) {
ConsoleLine line = channel[i];
if (!mFilter.empty() && line.Text.find(mFilter) == std::string::npos) {
continue;
Expand All @@ -410,8 +410,9 @@ void ConsoleWindow::DrawElement() {
std::string id = line.Text + "##" + std::to_string(i);
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
const bool isSelected = (mSelectedId == i) || std::find(mSelectedEntries.begin(), mSelectedEntries.end(),
i) != mSelectedEntries.end();
const bool isSelected =
(mSelectedId == (int32_t)i) ||
std::find(mSelectedEntries.begin(), mSelectedEntries.end(), i) != mSelectedEntries.end();
ImGui::PushStyleColor(ImGuiCol_Text, mPriorityColours[line.Priority]);
if (ImGui::Selectable(id.c_str(), isSelected)) {
if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_LeftCtrl)) && !isSelected) {
Expand Down
4 changes: 2 additions & 2 deletions src/window/gui/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,12 +548,12 @@ int16_t Gui::GetIntegerScaleFactor() {
// The same comparison as below, but checked against the configured factor
if (((float)gfx_current_game_window_viewport.height / gfx_current_game_window_viewport.width) <
((float)gfx_current_dimensions.height / gfx_current_dimensions.width)) {
if (factor > gfx_current_game_window_viewport.height / gfx_current_dimensions.height) {
if ((uint32_t)factor > gfx_current_game_window_viewport.height / gfx_current_dimensions.height) {
// Scale to window height
factor = gfx_current_game_window_viewport.height / gfx_current_dimensions.height;
}
} else {
if (factor > gfx_current_game_window_viewport.width / gfx_current_dimensions.width) {
if ((uint32_t)factor > gfx_current_game_window_viewport.width / gfx_current_dimensions.width) {
// Scale to window width
factor = gfx_current_game_window_viewport.width / gfx_current_dimensions.width;
}
Expand Down
2 changes: 1 addition & 1 deletion src/window/gui/GuiElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "libultraship/libultraship.h"

namespace Ship {
GuiElement::GuiElement(bool isVisible) : mIsInitialized(false), mIsVisible(isVisible) {
GuiElement::GuiElement(bool isVisible) : mIsVisible(isVisible), mIsInitialized(false) {
}

GuiElement::GuiElement() : GuiElement(false) {
Expand Down
2 changes: 1 addition & 1 deletion src/window/gui/GuiMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Ship {
GuiMenuBar::GuiMenuBar(const std::string& visibilityConsoleVariable, bool isVisible)
: mVisibilityConsoleVariable(visibilityConsoleVariable), GuiElement(isVisible) {
: GuiElement(isVisible), mVisibilityConsoleVariable(visibilityConsoleVariable) {
if (!mVisibilityConsoleVariable.empty()) {
mIsVisible = CVarGetInteger(mVisibilityConsoleVariable.c_str(), mIsVisible);
SyncVisibilityConsoleVariable();
Expand Down
4 changes: 2 additions & 2 deletions src/window/gui/GuiWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace Ship {
GuiWindow::GuiWindow(const std::string& consoleVariable, bool isVisible, const std::string& name, ImVec2 originalSize,
uint32_t windowFlags)
: mName(name), mVisibilityConsoleVariable(consoleVariable), mOriginalSize(originalSize), mWindowFlags(windowFlags),
GuiElement(isVisible) {
: GuiElement(isVisible), mName(name), mVisibilityConsoleVariable(consoleVariable), mOriginalSize(originalSize),
mWindowFlags(windowFlags) {
if (!mVisibilityConsoleVariable.empty()) {
mIsVisible = CVarGetInteger(mVisibilityConsoleVariable.c_str(), mIsVisible);
SyncVisibilityConsoleVariable();
Expand Down
2 changes: 1 addition & 1 deletion src/window/gui/GuiWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class GuiWindow : public GuiElement {
void SyncVisibilityConsoleVariable();

private:
std::string mVisibilityConsoleVariable;
std::string mName;
std::string mVisibilityConsoleVariable;
ImVector<ImRect> mGroupPanelLabelStack;
ImVec2 mOriginalSize;
uint32_t mWindowFlags;
Expand Down
6 changes: 3 additions & 3 deletions src/window/gui/InputEditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ void InputEditorWindow::DrawButtonLineEditMappingButton(uint8_t port, CONTROLLER
ImGui::OpenPopup(popupId.c_str());
}
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal | ImGuiHoveredFlags_NoSharedDelay)) {
ImGui::SetTooltip(mapping->GetPhysicalDeviceName().c_str());
ImGui::SetTooltip("%s", mapping->GetPhysicalDeviceName().c_str());
}
ImGui::PopStyleColor();
ImGui::PopStyleColor();
Expand Down Expand Up @@ -538,7 +538,7 @@ void InputEditorWindow::DrawStickDirectionLineEditMappingButton(uint8_t port, ui
ImGui::OpenPopup(popupId.c_str());
}
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal | ImGuiHoveredFlags_NoSharedDelay)) {
ImGui::SetTooltip(mapping->GetPhysicalDeviceName().c_str());
ImGui::SetTooltip("%s", mapping->GetPhysicalDeviceName().c_str());
}
ImGui::PopStyleColor();
ImGui::PopStyleColor();
Expand Down Expand Up @@ -1100,7 +1100,7 @@ void InputEditorWindow::DrawGyroSection(uint8_t port) {
auto id = mapping->GetGyroMappingId();
ImGui::AlignTextToFramePadding();
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
ImGui::BulletText(mapping->GetPhysicalDeviceName().c_str());
ImGui::BulletText("%s", mapping->GetPhysicalDeviceName().c_str());
DrawRemoveGyroMappingButton(port, id);

static float sPitch, sYaw = 0.0f;
Expand Down
Loading