Format the code via clang-format

This commit is contained in:
Maschell 2022-02-04 15:51:17 +01:00
parent b75edb5863
commit d493bc3424
12 changed files with 333 additions and 243 deletions

67
.clang-format Normal file
View File

@ -0,0 +1,67 @@
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignOperands: Align
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 0
CompactNamespaces: false
ContinuationIndentWidth: 8
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Right
ReflowComments: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: Never

View File

@ -6,8 +6,16 @@ on:
- main - main
jobs: jobs:
clang-format:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src
build-binary: build-binary:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
needs: clang-format
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: build binary - name: build binary

View File

@ -3,8 +3,16 @@ name: CI-PR
on: [pull_request] on: [pull_request]
jobs: jobs:
clang-format:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src
build-binary: build-binary:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
needs: clang-format
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: build binary - name: build binary

View File

@ -1,3 +1,5 @@
[![CI-Release](https://github.com/wiiu-env/region_free_plugin/actions/workflows/ci.yml/badge.svg)](https://github.com/wiiu-env/region_free_plugin/actions/workflows/ci.yml)
# Region Free Plugin # Region Free Plugin
This plugin allows you to launch an title of an other region and / or force a language of an title. This plugin allows you to launch an title of an other region and / or force a language of an title.
@ -44,3 +46,7 @@ docker run -it --rm -v ${PWD}:/project regionfree_plugin-builder make
# make clean # make clean
docker run -it --rm -v ${PWD}:/project regionfree_plugin-builder make clean docker run -it --rm -v ${PWD}:/project regionfree_plugin-builder make clean
``` ```
## Format the code via docker
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src -i`

View File

@ -1,17 +1,17 @@
#include "ConfigUtils.h" #include "ConfigUtils.h"
#include "utils/logger.h"
#include "DrawUtils.h" #include "DrawUtils.h"
#include "utils/logger.h"
#include "globals.h"
#include <coreinit/mcp.h>
#include <coreinit/screen.h>
#include <map>
#include <memory/mappedmemory.h>
#include <padscore/kpad.h>
#include <string> #include <string>
#include <vector> #include <vector>
#include <coreinit/screen.h>
#include <memory/mappedmemory.h>
#include <vpad/input.h> #include <vpad/input.h>
#include <padscore/kpad.h>
#include <coreinit/mcp.h>
#include <map>
#include "globals.h"
#define COLOR_BACKGROUND Color(238, 238, 238, 255) #define COLOR_BACKGROUND Color(238, 238, 238, 255)
#define COLOR_TEXT Color(51, 51, 51, 255) #define COLOR_TEXT Color(51, 51, 51, 255)
@ -311,7 +311,6 @@ void ConfigUtils::displayMenu() {
DrawUtils::beginDraw(); DrawUtils::beginDraw();
DrawUtils::clear(COLOR_BLACK); DrawUtils::clear(COLOR_BLACK);
DrawUtils::endDraw(); DrawUtils::endDraw();
} }
void ConfigUtils::openConfigMenu() { void ConfigUtils::openConfigMenu() {
@ -348,7 +347,7 @@ void ConfigUtils::openConfigMenu() {
DrawUtils::deinitFont(); DrawUtils::deinitFont();
error_exit: error_exit:
if (screenbuffer0) { if (screenbuffer0) {
MEMFreeToMappedMemory(screenbuffer0); MEMFreeToMappedMemory(screenbuffer0);

View File

@ -189,7 +189,8 @@ void DrawUtils::print(uint32_t x, uint32_t y, const char *string, bool alignRigh
buffer[num] = 0; buffer[num] = 0;
} else { } else {
wchar_t *tmp = buffer; wchar_t *tmp = buffer;
while ((*tmp++ = *string++)); while ((*tmp++ = *string++))
;
} }
print(x, y, buffer, alignRight); print(x, y, buffer, alignRight);
@ -229,7 +230,8 @@ uint32_t DrawUtils::getTextWidth(const char *string) {
buffer[num] = 0; buffer[num] = 0;
} else { } else {
wchar_t *tmp = buffer; wchar_t *tmp = buffer;
while ((*tmp++ = *string++)); while ((*tmp++ = *string++))
;
} }
uint32_t width = getTextWidth(buffer); uint32_t width = getTextWidth(buffer);

View File

@ -1,22 +1,22 @@
#include <wups.h>
#include <nn/acp.h>
#include <coreinit/title.h>
#include <coreinit/mcp.h>
#include <coreinit/userconfig.h>
#include <coreinit/filesystem.h>
#include <sysapp/title.h>
#include <coreinit/thread.h>
#include "utils/logger.h"
#include "ConfigUtils.h" #include "ConfigUtils.h"
#include <malloc.h>
#include <cstdio>
#include <wups/config/WUPSConfigItemMultipleValues.h>
#include <map>
#include <coreinit/screen.h>
#include <vpad/input.h>
#include <padscore/kpad.h>
#include <wups/config/WUPSConfigItemBoolean.h>
#include "globals.h" #include "globals.h"
#include "utils/logger.h"
#include <coreinit/filesystem.h>
#include <coreinit/mcp.h>
#include <coreinit/screen.h>
#include <coreinit/thread.h>
#include <coreinit/title.h>
#include <coreinit/userconfig.h>
#include <cstdio>
#include <malloc.h>
#include <map>
#include <nn/acp.h>
#include <padscore/kpad.h>
#include <sysapp/title.h>
#include <vpad/input.h>
#include <wups.h>
#include <wups/config/WUPSConfigItemBoolean.h>
#include <wups/config/WUPSConfigItemMultipleValues.h>
WUPS_PLUGIN_NAME("Region Free Plugin"); WUPS_PLUGIN_NAME("Region Free Plugin");
WUPS_PLUGIN_DESCRIPTION("Allows the user to load titles from other regions"); WUPS_PLUGIN_DESCRIPTION("Allows the user to load titles from other regions");
@ -101,16 +101,17 @@ DECL_FUNCTION(int32_t, ACPGetTitleMetaXmlByDevice, uint32_t titleid_upper, uint3
ON_FUNCTIONS_PATCHED() { ON_FUNCTIONS_PATCHED() {
MCPRegion real_product_area; MCPRegion real_product_area;
auto real_product_area_valid = getRealProductArea(&real_product_area); auto real_product_area_valid = getRealProductArea(&real_product_area);
if(real_product_area_valid){ if (real_product_area_valid) {
if(real_product_area == MCP_REGION_EUROPE){ if (real_product_area == MCP_REGION_EUROPE) {
gDefaultProductArea = MCP_REGION_EUROPE; gDefaultProductArea = MCP_REGION_EUROPE;
gDefaultLanguage = gDefaultLangForEUR; gDefaultLanguage = gDefaultLangForEUR;
gDefaultCountry = gDefaultCountryForEUR; gDefaultCountry = gDefaultCountryForEUR;
} else if(real_product_area == MCP_REGION_JAPAN){ } else if (real_product_area == MCP_REGION_JAPAN) {
gDefaultProductArea = MCP_REGION_JAPAN; gDefaultProductArea = MCP_REGION_JAPAN;
gDefaultLanguage = gDefaultLangForJPN; gDefaultLanguage = gDefaultLangForJPN;
gDefaultCountry = gDefaultCountryForJPN; gDefaultCountry = gDefaultCountryForJPN;
}if(real_product_area == MCP_REGION_USA){ }
if (real_product_area == MCP_REGION_USA) {
gDefaultProductArea = MCP_REGION_USA; gDefaultProductArea = MCP_REGION_USA;
gDefaultLanguage = gDefaultLangForUSA; gDefaultLanguage = gDefaultLangForUSA;
gDefaultCountry = gDefaultCountryForUSA; gDefaultCountry = gDefaultCountryForUSA;
@ -372,7 +373,7 @@ void default_lang_changed(ConfigItemMultipleValues *item, uint32_t newValue) {
void getConfigInfoForLangMap(std::map<Lanuages, const char *> &curLangMap, ConfigItemMultipleValuesPair *pair, uint32_t default_lang, uint32_t *default_index, uint32_t *len) { void getConfigInfoForLangMap(std::map<Lanuages, const char *> &curLangMap, ConfigItemMultipleValuesPair *pair, uint32_t default_lang, uint32_t *default_index, uint32_t *len) {
uint32_t i = 0; uint32_t i = 0;
for (auto &curEntry: curLangMap) { for (auto &curEntry : curLangMap) {
if (default_lang == curEntry.first) { if (default_lang == curEntry.first) {
*default_index = i; *default_index = i;
} }
@ -411,8 +412,7 @@ WUPS_GET_CONFIG() {
{LANG_ENGLISH, "English"}, {LANG_ENGLISH, "English"},
{LANG_FRANCAIS, "Francais"}, {LANG_FRANCAIS, "Francais"},
{LANG_ESPANOL, "Espanol"}, {LANG_ESPANOL, "Espanol"},
{LANG_PORTUGUES, "Portugues"} {LANG_PORTUGUES, "Portugues"}};
};
ConfigItemMultipleValuesPair lang_eur_pair[eur_lang_map.size()]; ConfigItemMultipleValuesPair lang_eur_pair[eur_lang_map.size()];
uint32_t number_lang_eur_values = 0; uint32_t number_lang_eur_values = 0;
@ -543,7 +543,7 @@ static const uint64_t
0x0005001010062100ull, 0x0005001010062100ull,
0x0005001010062200ull, 0x0005001010062200ull,
}, },
}; };
bool getRealProductArea(MCPRegion *out) { bool getRealProductArea(MCPRegion *out) {
if (out == nullptr) { if (out == nullptr) {
@ -587,4 +587,3 @@ WUPS_MUST_REPLACE(ACPGetLaunchMetaXml, WUPS_LOADER_LIBRARY_NN_ACP, ACPGetLaunchM
WUPS_MUST_REPLACE(MCP_GetSysProdSettings, WUPS_LOADER_LIBRARY_COREINIT, MCP_GetSysProdSettings); WUPS_MUST_REPLACE(MCP_GetSysProdSettings, WUPS_LOADER_LIBRARY_COREINIT, MCP_GetSysProdSettings);
WUPS_MUST_REPLACE(UCReadSysConfig, WUPS_LOADER_LIBRARY_COREINIT, UCReadSysConfig); WUPS_MUST_REPLACE(UCReadSysConfig, WUPS_LOADER_LIBRARY_COREINIT, UCReadSysConfig);
WUPS_MUST_REPLACE(_SYSGetSystemApplicationTitleIdByProdArea, WUPS_LOADER_LIBRARY_SYSAPP, _SYSGetSystemApplicationTitleIdByProdArea); WUPS_MUST_REPLACE(_SYSGetSystemApplicationTitleIdByProdArea, WUPS_LOADER_LIBRARY_SYSAPP, _SYSGetSystemApplicationTitleIdByProdArea);

View File

@ -1,8 +1,8 @@
#ifdef DEBUG #ifdef DEBUG
#include <stdint.h> #include <stdint.h>
#include <whb/log_udp.h>
#include <whb/log_cafe.h> #include <whb/log_cafe.h>
#include <whb/log_module.h> #include <whb/log_module.h>
#include <whb/log_udp.h>
uint32_t moduleLogInit = false; uint32_t moduleLogInit = false;
uint32_t cafeLogInit = false; uint32_t cafeLogInit = false;

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <whb/log.h>
#include <string.h> #include <string.h>
#include <whb/log.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -14,12 +14,14 @@ extern "C" {
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0) #define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \ #define DEBUG_FUNCTION_LINE(FMT, ARGS...) \
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \ do { \
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0) } while (0)
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \ #define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) \
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \ do { \
WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0) } while (0)
#else #else
@ -39,4 +41,3 @@ void deinitLogging();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif