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

chore: remove redundant Ship:: usage inside Ship namespaced files #631

Merged
merged 1 commit into from
Jun 2, 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
10 changes: 5 additions & 5 deletions src/config/ConsoleVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void ConsoleVariable::RegisterColor24(const char* name, Color_RGB8 defaultValue)
}

void ConsoleVariable::ClearVariable(const char* name) {
std::shared_ptr<Config> conf = Ship::Context::GetInstance()->GetConfig();
std::shared_ptr<Config> conf = Context::GetInstance()->GetConfig();
auto var = Get(name);
if (var != nullptr) {
bool color = var->Type == ConsoleVariableType::Color || var->Type == ConsoleVariableType::Color24;
Expand All @@ -192,7 +192,7 @@ void ConsoleVariable::ClearVariable(const char* name) {
}

void ConsoleVariable::ClearBlock(const char* name) {
std::shared_ptr<Config> conf = Ship::Context::GetInstance()->GetConfig();
std::shared_ptr<Config> conf = Context::GetInstance()->GetConfig();
conf->EraseBlock(StringHelper::Sprintf("CVars.%s", name));
Load();
}
Expand Down Expand Up @@ -228,7 +228,7 @@ void ConsoleVariable::CopyVariable(const char* from, const char* to) {
}

void ConsoleVariable::Save() {
std::shared_ptr<Config> conf = Ship::Context::GetInstance()->GetConfig();
std::shared_ptr<Config> conf = Context::GetInstance()->GetConfig();

for (const auto& variable : mVariables) {
const std::string key = StringHelper::Sprintf("CVars.%s", variable.first.c_str());
Expand Down Expand Up @@ -264,7 +264,7 @@ void ConsoleVariable::Save() {
}

void ConsoleVariable::Load() {
std::shared_ptr<Config> conf = Ship::Context::GetInstance()->GetConfig();
std::shared_ptr<Config> conf = Context::GetInstance()->GetConfig();
conf->Reload();
if (!mVariables.empty()) {
mVariables.clear();
Expand Down Expand Up @@ -324,7 +324,7 @@ void ConsoleVariable::LoadFromPath(
}
}
void ConsoleVariable::LoadLegacy() {
auto conf = Ship::Context::GetPathRelativeToAppDirectory("cvars.cfg");
auto conf = Context::GetPathRelativeToAppDirectory("cvars.cfg");
if (DiskFile::Exists(conf)) {
const auto lines = DiskFile::ReadAllLines(conf);

Expand Down
2 changes: 1 addition & 1 deletion src/controller/controldeck/ControlDeck.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ControlDeck {
void SetSinglePlayerMappingMode(bool singlePlayer);
bool IsSinglePlayerMappingMode();

bool ProcessKeyboardEvent(Ship::KbEventType eventType, Ship::KbScancode scancode);
bool ProcessKeyboardEvent(KbEventType eventType, KbScancode scancode);

std::shared_ptr<ShipDeviceIndexMappingManager> GetDeviceIndexMappingManager();

Expand Down
2 changes: 1 addition & 1 deletion src/controller/controldevice/controller/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void Controller::ReadToPad(OSContPad* pad) {
}
}

bool Controller::ProcessKeyboardEvent(Ship::KbEventType eventType, Ship::KbScancode scancode) {
bool Controller::ProcessKeyboardEvent(KbEventType eventType, KbScancode scancode) {
bool result = false;
for (auto [bitmask, button] : GetAllButtons()) {
result = button->ProcessKeyboardEvent(eventType, scancode) || result;
Expand Down
2 changes: 1 addition & 1 deletion src/controller/controldevice/controller/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Controller : public ControlDevice {
uint8_t GetPortIndex();
std::vector<std::shared_ptr<ControllerMapping>> GetAllMappings();

bool ProcessKeyboardEvent(Ship::KbEventType eventType, Ship::KbScancode scancode);
bool ProcessKeyboardEvent(KbEventType eventType, KbScancode scancode);

bool HasMappingsForShipDeviceIndex(ShipDeviceIndex lusIndex);
void MoveMappingsToDifferentController(std::shared_ptr<Controller> newController, ShipDeviceIndex lusIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ bool ControllerButton::AddOrEditButtonMappingFromRawPress(CONTROLLERBUTTONS_T bi
return true;
}

bool ControllerButton::ProcessKeyboardEvent(Ship::KbEventType eventType, Ship::KbScancode scancode) {
bool ControllerButton::ProcessKeyboardEvent(KbEventType eventType, KbScancode scancode) {
if (mUseKeydownEventToCreateNewMapping && eventType == LUS_KB_EVENT_KEY_DOWN) {
mKeyboardScancodeForNewMapping = scancode;
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/controller/controldevice/controller/ControllerButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ControllerButton {

void UpdatePad(CONTROLLERBUTTONS_T& padButtons);

bool ProcessKeyboardEvent(Ship::KbEventType eventType, Ship::KbScancode scancode);
bool ProcessKeyboardEvent(KbEventType eventType, KbScancode scancode);

bool HasMappingsForShipDeviceIndex(ShipDeviceIndex lusIndex);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ void ControllerStick::UpdatePad(int8_t& x, int8_t& y) {
Process(x, y);
}

bool ControllerStick::ProcessKeyboardEvent(Ship::KbEventType eventType, Ship::KbScancode scancode) {
bool ControllerStick::ProcessKeyboardEvent(KbEventType eventType, KbScancode scancode) {
if (mUseKeydownEventToCreateNewMapping && eventType == LUS_KB_EVENT_KEY_DOWN) {
mKeyboardScancodeForNewMapping = scancode;
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/controller/controldevice/controller/ControllerStick.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ControllerStick {
uint8_t GetNotchSnapAngle();
bool NotchSnapAngleIsDefault();

bool ProcessKeyboardEvent(Ship::KbEventType eventType, Ship::KbScancode scancode);
bool ProcessKeyboardEvent(KbEventType eventType, KbScancode scancode);

bool HasMappingsForShipDeviceIndex(ShipDeviceIndex lusIndex);
Stick LeftOrRightStick();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ std::string KeyboardKeyToAnyMapping::GetPhysicalInputName() {
return Context::GetInstance()->GetWindow()->GetKeyName(mKeyboardScancode);
}

bool KeyboardKeyToAnyMapping::ProcessKeyboardEvent(Ship::KbEventType eventType, Ship::KbScancode scancode) {
bool KeyboardKeyToAnyMapping::ProcessKeyboardEvent(KbEventType eventType, KbScancode scancode) {
if (eventType == KbEventType::LUS_KB_EVENT_ALL_KEYS_UP) {
mKeyPressed = false;
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class KeyboardKeyToAnyMapping : virtual public ControllerInputMapping {
KeyboardKeyToAnyMapping(KbScancode scancode);
~KeyboardKeyToAnyMapping();
std::string GetPhysicalInputName() override;
bool ProcessKeyboardEvent(Ship::KbEventType eventType, Ship::KbScancode scancode);
bool ProcessKeyboardEvent(KbEventType eventType, KbScancode scancode);
std::string GetPhysicalDeviceName() override;
bool PhysicalDeviceIsConnected() override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SDLMapping::~SDLMapping() {

bool SDLMapping::OpenController() {
auto deviceIndexMapping = std::static_pointer_cast<ShipDeviceIndexToSDLDeviceIndexMapping>(
Ship::Context::GetInstance()
Context::GetInstance()
->GetControlDeck()
->GetDeviceIndexMappingManager()
->GetDeviceIndexMappingFromShipDeviceIndex(mShipDeviceIndex));
Expand Down Expand Up @@ -116,7 +116,7 @@ bool SDLMapping::UsesGameCubeLayout() {

int32_t SDLMapping::GetSDLDeviceIndex() {
auto deviceIndexMapping = std::static_pointer_cast<ShipDeviceIndexToSDLDeviceIndexMapping>(
Ship::Context::GetInstance()
Context::GetInstance()
->GetControlDeck()
->GetDeviceIndexMappingManager()
->GetDeviceIndexMappingFromShipDeviceIndex(mShipDeviceIndex));
Expand All @@ -130,7 +130,7 @@ int32_t SDLMapping::GetSDLDeviceIndex() {
}

std::string SDLMapping::GetSDLControllerName() {
return Ship::Context::GetInstance()
return Context::GetInstance()
->GetControlDeck()
->GetDeviceIndexMappingManager()
->GetSDLControllerNameFromShipDeviceIndex(mShipDeviceIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ void ShipDeviceIndexMappingManager::HandlePhysicalDeviceConnect(int32_t sdlDevic
}

if (Context::GetInstance()->GetControlDeck()->IsSinglePlayerMappingMode()) {
std::set<Ship::ShipDeviceIndex> alreadyConnectedDevices;
std::set<ShipDeviceIndex> alreadyConnectedDevices;
for (auto mapping : Context::GetInstance()->GetControlDeck()->GetControllerByPort(0)->GetAllMappings()) {
auto sdlMapping = std::dynamic_pointer_cast<SDLMapping>(mapping);
if (sdlMapping == nullptr) {
Expand Down
28 changes: 14 additions & 14 deletions src/debug/CrashHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void CrashHandler::PrintRegisters(ucontext_t* ctx) {
}

static void ErrorHandler(int sig, siginfo_t* sigInfo, void* data) {
std::shared_ptr<CrashHandler> crashHandler = Ship::Context::GetInstance()->GetCrashHandler();
std::shared_ptr<CrashHandler> crashHandler = Context::GetInstance()->GetCrashHandler();
char intToCharBuffer[16];

std::array<void*, 4096> arr;
Expand Down Expand Up @@ -189,15 +189,15 @@ static void ErrorHandler(int sig, siginfo_t* sigInfo, void* data) {
snprintf(intToCharBuffer, sizeof(intToCharBuffer), "%i ", (int)i);
WRITE_VAR_LINE(crashHandler, intToCharBuffer, functionName.c_str());
}
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, (Ship::Context::GetInstance()->GetName() + " has crashed").c_str(),
(Ship::Context::GetInstance()->GetName() +
" has crashed. Please upload the logs to the support channel in discord.")
.c_str(),
nullptr);
SDL_ShowSimpleMessageBox(
SDL_MESSAGEBOX_ERROR, (Context::GetInstance()->GetName() + " has crashed").c_str(),
(Context::GetInstance()->GetName() + " has crashed. Please upload the logs to the support channel in discord.")
.c_str(),
nullptr);
free(symbols);
crashHandler->PrintCommon();

Ship::Context::GetInstance()->GetLogger()->flush();
Context::GetInstance()->GetLogger()->flush();
spdlog::shutdown();
exit(1);
}
Expand Down Expand Up @@ -385,23 +385,23 @@ void CrashHandler::PrintStack(CONTEXT* ctx) {
}
}
PrintCommon();
Ship::Context::GetInstance()->GetLogger()->flush();
Context::GetInstance()->GetLogger()->flush();
spdlog::shutdown();
}

extern "C" LONG WINAPI seh_filter(PEXCEPTION_POINTERS ex) {
char exceptionString[20];
std::shared_ptr<CrashHandler> crashHandler = Ship::Context::GetInstance()->GetCrashHandler();
std::shared_ptr<CrashHandler> crashHandler = Context::GetInstance()->GetCrashHandler();

snprintf(exceptionString, std::size(exceptionString), "0x%x", ex->ExceptionRecord->ExceptionCode);

WRITE_VAR_LINE(crashHandler, "Exception: ", exceptionString);
crashHandler->PrintStack(ex->ContextRecord);
MessageBoxA(nullptr,
(Ship::Context::GetInstance()->GetName() +
" has crashed. Please upload the logs to the support channel in discord.")
.c_str(),
"Crash", MB_OK | MB_ICONERROR);
MessageBoxA(
nullptr,
(Context::GetInstance()->GetName() + " has crashed. Please upload the logs to the support channel in discord.")
.c_str(),
"Crash", MB_OK | MB_ICONERROR);

return EXCEPTION_EXECUTE_HANDLER;
}
Expand Down
4 changes: 2 additions & 2 deletions src/resource/File.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ struct ResourceInitData {

struct File {
std::shared_ptr<Archive> Parent;
std::shared_ptr<Ship::ResourceInitData> InitData;
std::shared_ptr<ResourceInitData> InitData;
std::shared_ptr<std::vector<char>> Buffer;
std::variant<std::shared_ptr<tinyxml2::XMLDocument>, std::shared_ptr<Ship::BinaryReader>> Reader;
std::variant<std::shared_ptr<tinyxml2::XMLDocument>, std::shared_ptr<BinaryReader>> Reader;
bool IsLoaded = false;
};
} // namespace Ship
4 changes: 2 additions & 2 deletions src/resource/Resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <spdlog/spdlog.h>

namespace Ship {
IResource::IResource(std::shared_ptr<Ship::ResourceInitData> initData) : mInitData(initData) {
IResource::IResource(std::shared_ptr<ResourceInitData> initData) : mInitData(initData) {
}

IResource::~IResource() {
Expand All @@ -17,7 +17,7 @@ void IResource::Dirty() {
mIsDirty = true;
}

std::shared_ptr<Ship::ResourceInitData> IResource::GetInitData() {
std::shared_ptr<ResourceInitData> IResource::GetInitData() {
return mInitData;
}
} // namespace Ship
6 changes: 3 additions & 3 deletions src/resource/Resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ class IResource {
public:
inline static const std::string gAltAssetPrefix = "alt/";

IResource(std::shared_ptr<Ship::ResourceInitData> initData);
IResource(std::shared_ptr<ResourceInitData> initData);
virtual ~IResource();

virtual void* GetRawPointer() = 0;
virtual size_t GetPointerSize() = 0;

bool IsDirty();
void Dirty();
std::shared_ptr<Ship::ResourceInitData> GetInitData();
std::shared_ptr<ResourceInitData> GetInitData();

private:
std::shared_ptr<Ship::ResourceInitData> mInitData;
std::shared_ptr<ResourceInitData> mInitData;
bool mIsDirty = false;
};

Expand Down
4 changes: 2 additions & 2 deletions src/resource/ResourceFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
namespace Ship {
class ResourceFactory {
public:
virtual std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) = 0;
virtual std::shared_ptr<IResource> ReadResource(std::shared_ptr<File> file) = 0;

protected:
virtual bool FileHasValidFormatAndReader(std::shared_ptr<Ship::File> file) = 0;
virtual bool FileHasValidFormatAndReader(std::shared_ptr<File> file) = 0;
};
} // namespace Ship
4 changes: 2 additions & 2 deletions src/resource/ResourceFactoryBinary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
#include "spdlog/spdlog.h"

namespace Ship {
bool ResourceFactoryBinary::FileHasValidFormatAndReader(std::shared_ptr<Ship::File> file) {
bool ResourceFactoryBinary::FileHasValidFormatAndReader(std::shared_ptr<File> file) {
if (file->InitData->Format != RESOURCE_FORMAT_BINARY) {
SPDLOG_ERROR("resource file format does not match factory format.");
return false;
}

if (!std::holds_alternative<std::shared_ptr<Ship::BinaryReader>>(file->Reader)) {
if (!std::holds_alternative<std::shared_ptr<BinaryReader>>(file->Reader)) {
SPDLOG_ERROR("Failed to load resource: File has Reader ({} - {})", file->InitData->Type, file->InitData->Path);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/resource/ResourceFactoryBinary.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
namespace Ship {
class ResourceFactoryBinary : public ResourceFactory {
protected:
bool FileHasValidFormatAndReader(std::shared_ptr<Ship::File> file) override;
bool FileHasValidFormatAndReader(std::shared_ptr<File> file) override;
};
} // namespace Ship
2 changes: 1 addition & 1 deletion src/resource/ResourceFactoryXML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "spdlog/spdlog.h"

namespace Ship {
bool ResourceFactoryXML::FileHasValidFormatAndReader(std::shared_ptr<Ship::File> file) {
bool ResourceFactoryXML::FileHasValidFormatAndReader(std::shared_ptr<File> file) {
if (file->InitData->Format != RESOURCE_FORMAT_XML) {
SPDLOG_ERROR("resource file format does not match factory format.");
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/resource/ResourceFactoryXML.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
namespace Ship {
class ResourceFactoryXML : public ResourceFactory {
protected:
bool FileHasValidFormatAndReader(std::shared_ptr<Ship::File> file) override;
bool FileHasValidFormatAndReader(std::shared_ptr<File> file) override;
};
} // namespace Ship
6 changes: 3 additions & 3 deletions src/resource/ResourceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ ResourceLoader::~ResourceLoader() {
}

void ResourceLoader::RegisterGlobalResourceFactories() {
RegisterResourceFactory(std::make_shared<Ship::ResourceFactoryBinaryJsonV0>(), RESOURCE_FORMAT_BINARY, "Json",
static_cast<uint32_t>(Ship::ResourceType::Json), 0);
RegisterResourceFactory(std::make_shared<ResourceFactoryBinaryJsonV0>(), RESOURCE_FORMAT_BINARY, "Json",
static_cast<uint32_t>(ResourceType::Json), 0);
}

bool ResourceLoader::RegisterResourceFactory(std::shared_ptr<ResourceFactory> factory, uint32_t format,
Expand Down Expand Up @@ -76,7 +76,7 @@ std::shared_ptr<ResourceFactory> ResourceLoader::GetFactory(uint32_t format, std
return GetFactory(format, mResourceTypes[typeName], version);
}

std::shared_ptr<Ship::IResource> ResourceLoader::LoadResource(std::shared_ptr<Ship::File> fileToLoad) {
std::shared_ptr<IResource> ResourceLoader::LoadResource(std::shared_ptr<File> fileToLoad) {
if (fileToLoad == nullptr) {
SPDLOG_ERROR("Failed to load resource: File not loaded");
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/resource/ResourceLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ResourceLoader {
ResourceLoader();
~ResourceLoader();

std::shared_ptr<Ship::IResource> LoadResource(std::shared_ptr<Ship::File> fileToLoad);
std::shared_ptr<IResource> LoadResource(std::shared_ptr<File> fileToLoad);
bool RegisterResourceFactory(std::shared_ptr<ResourceFactory> factory, uint32_t format, std::string typeName,
uint32_t type, uint32_t version);

Expand Down
Loading
Loading