Few fixes

This commit is contained in:
BernardoGiordano 2019-07-24 19:35:27 +02:00
parent 88a0bbcbe3
commit 64059b21ed
13 changed files with 71 additions and 68 deletions

View file

@ -78,7 +78,8 @@ CFLAGS := -g -Wall -Wextra -Wno-psabi -O3 -mword-relocations -flto \
-DVERSION_MAJOR=${VERSION_MAJOR} \
-DVERSION_MINOR=${VERSION_MINOR} \
-DVERSION_MICRO=${VERSION_MICRO} \
-DGIT_REV=\"${GIT_REV}\"
-DGIT_REV=\"${GIT_REV}\" \
-DCHEAT_SIZE_DECOMPRESSED=${CHEAT_SIZE_DECOMPRESSED}
CFLAGS += $(INCLUDE) -DARM11 -D_3DS -D_GNU_SOURCE=1
@ -179,17 +180,11 @@ ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
endif
.PHONY: all clean format
.PHONY: all clean format cheats
#---------------------------------------------------------------------------------
all:
@mkdir -p $(BUILD) $(GFXBUILD) $(OUTDIR) $(ROMFS)/$(CHEATS)
ifeq ($(OS),Windows_NT)
@cd $(SHARKIVE) && py -3 joiner.py 3ds
else
@cd $(SHARKIVE) && python3 joiner.py 3ds
endif
@cd $(SHARKIVE)/$(BUILD) && mv 3ds.json.bz2 ../../3ds/$(ROMFS)/$(CHEATS)/$(CHEATS).json.bz2
all: cheats
@mkdir -p $(BUILD) $(GFXBUILD) $(OUTDIR)
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile $(OUTPUT).3dsx
@bannertool makebanner -i "$(BANNER_IMAGE)" -a "$(BANNER_AUDIO)" -o $(BUILD)/banner.bnr
@bannertool makesmdh -s "$(APP_TITLE)" -l "$(APP_DESCRIPTION)" -p "$(APP_AUTHOR)" -i "$(APP_ICON)" -f "$(ICON_FLAGS)" -o $(BUILD)/icon.icn
@ -199,6 +194,15 @@ clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTDIR)
#---------------------------------------------------------------------------------
cheats:
@mkdir -p $(BUILD) $(ROMFS)/$(CHEATS)
ifeq ($(OS),Windows_NT)
@cd $(SHARKIVE) && py -3 joiner.py 3ds
else
@cd $(SHARKIVE) && python3 joiner.py 3ds
endif
@cd $(SHARKIVE)/$(BUILD) && mv 3ds.json.bz2 ../../3ds/$(ROMFS)/$(CHEATS)/$(CHEATS).json.bz2
#---------------------------------------------------------------------------------
format:
clang-format -i -style=file $(foreach dir,$(FORMATSOURCES),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cpp)) $(foreach dir,$(FORMATINCLUDES),$(wildcard $(dir)/*.h) $(wildcard $(dir)/*.hpp))
#---------------------------------------------------------------------------------

View file

@ -28,6 +28,7 @@
#define MAIN_HPP
#include "Screen.hpp"
#include "logger.hpp"
#include <citro2d.h>
#include <memory>
#include <vector>

View file

@ -103,13 +103,11 @@ bool Archive::setPlayCoins(void)
if (R_SUCCEEDED(res)) {
FSStream s(archive, StringUtils::UTF8toUTF16("/gamecoin.dat"), FS_OPEN_READ | FS_OPEN_WRITE);
if (s.good()) {
u8 buf[2];
int coinAmount = KeyboardManager::get().numericPad();
if (coinAmount >= 0) {
coinAmount = coinAmount > 300 ? 300 : coinAmount;
s.offset(4);
buf[0] = (u8)coinAmount;
buf[1] = coinAmount >> 8;
u8 buf[2] = {(u8)coinAmount, (u8)(coinAmount >> 8)};
s.write(buf, 2);
}

View file

@ -36,6 +36,9 @@ CheatManager::CheatManager(void)
mCheats = std::make_shared<nlohmann::json>(nlohmann::json::parse(in, nullptr, false));
fclose(in);
}
else {
Logger::getInstance().log(Logger::WARN, "Failed to open " + path + " with errno %d", errno);
}
}
else {
const std::string path = "romfs:/cheats/cheats.json.bz2";
@ -44,7 +47,7 @@ CheatManager::CheatManager(void)
if (f != NULL) {
fseek(f, 0, SEEK_END);
u32 size = ftell(f);
unsigned int destLen = 2 * 1024 * 1024;
unsigned int destLen = CHEAT_SIZE_DECOMPRESSED;
char* s = new char[size];
char* d = new char[destLen]();
rewind(f);
@ -59,6 +62,9 @@ CheatManager::CheatManager(void)
delete[] d;
fclose(f);
}
else {
Logger::getInstance().log(Logger::WARN, "Failed to open " + path + " with errno %d", errno);
}
}
}

View file

@ -80,8 +80,7 @@ void Clickable::draw(float size, u32 overlay)
C2D_DrawRectSolid(mx, my, 0.5f, mw, mh, C2D_Color32(r, g, b, 100));
}
int offset = ceilf(mx + (mw - messageWidth) / 2) + (!mCentered ? 8 : 0);
C2D_DrawText(&mC2dText, C2D_WithColor, offset, ceilf(my + (mh - messageHeight) / 2), 0.5f,
size, size, mColorText);
C2D_DrawText(&mC2dText, C2D_WithColor, offset, ceilf(my + (mh - messageHeight) / 2), 0.5f, size, size, mColorText);
}
void Clickable::drawOutline(u32 color)

View file

@ -50,13 +50,13 @@ Result servicesInit(void)
sdmcInit();
ATEXIT(sdmcExit);
Logger::getInstance().info("Checkpoint loading started...");
Logger::getInstance().log(Logger::INFO, "Checkpoint loading started...");
Result res = 0;
Handle hbldrHandle;
if (R_FAILED(res = svcConnectToPort(&hbldrHandle, "hb:ldr"))) {
Logger::getInstance().error("Error during startup with result %llX. Rosalina not found on this system", res);
Logger::getInstance().log(Logger::ERROR, "Error during startup with result %llX. Rosalina not found on this system", res);
return consoleDisplayError("Rosalina not found on this system.\nAn updated CFW is required to launch Checkpoint.", res);
}
@ -73,7 +73,7 @@ Result servicesInit(void)
ATEXIT(pxiDevExit);
if (R_FAILED(res = Archive::init())) {
Logger::getInstance().error("Archive::init failed with result %llX", res);
Logger::getInstance().log(Logger::ERROR, "Archive::init failed with result %llX", res);
return consoleDisplayError("Archive::init failed.", res);
}
ATEXIT(Archive::exit);
@ -93,7 +93,7 @@ Result servicesInit(void)
Configuration::getInstance();
Logger::getInstance().info("Checkpoint loading finished!");
Logger::getInstance().log(Logger::INFO, "Checkpoint loading finished!");
return 0;
}

View file

@ -11,10 +11,12 @@ clean:
@for dir in $(SUBDIRS); do $(MAKE) clean -C $$dir; done
3ds:
@$(MAKE) -C 3ds VERSION_MAJOR=${VERSION_MAJOR} VERSION_MINOR=${VERSION_MINOR} VERSION_MICRO=${VERSION_MICRO} GIT_REV=${GIT_REV}
@$(MAKE) -C 3ds cheats
@$(MAKE) -C 3ds VERSION_MAJOR=${VERSION_MAJOR} VERSION_MINOR=${VERSION_MINOR} VERSION_MICRO=${VERSION_MICRO} GIT_REV=${GIT_REV} CHEAT_SIZE_DECOMPRESSED=$(shell stat -t "sharkive/build/3ds.json" | awk '{print $$2}')
switch:
@$(MAKE) -C switch VERSION_MAJOR=${VERSION_MAJOR} VERSION_MINOR=${VERSION_MINOR} VERSION_MICRO=${VERSION_MICRO} GIT_REV=${GIT_REV}
@$(MAKE) -C switch cheats
@$(MAKE) -C switch VERSION_MAJOR=${VERSION_MAJOR} VERSION_MINOR=${VERSION_MINOR} VERSION_MICRO=${VERSION_MICRO} GIT_REV=${GIT_REV} CHEAT_SIZE_DECOMPRESSED=$(shell stat -t "sharkive/build/switch.json" | awk '{print $$2}')
format:
@for dir in $(SUBDIRS); do $(MAKE) -C $$dir format; done

View file

@ -39,22 +39,17 @@ public:
return mLogger;
}
template <typename... Args>
void info(const std::string& format, Args... args)
{
log(INFO, format, args...);
}
inline static const std::string INFO = "[ INFO]";
inline static const std::string DEBUG = "[DEBUG]";
inline static const std::string ERROR = "[ERROR]";
inline static const std::string WARN = "[ WARN]";
template <typename... Args>
void error(const std::string& format, Args... args)
void log(const std::string& level, const std::string& format = {}, Args... args)
{
log(ERROR, format, args...);
}
template <typename... Args>
void debug(const std::string& format, Args... args)
{
log(DEBUG, format, args...);
if (mFile != NULL) {
fprintf(mFile, ("[" + DateTime::logDateTime() + "] " + level + " " + format + "\n").c_str(), args...);
}
}
private:
@ -69,18 +64,6 @@ private:
Logger(Logger const&) = delete;
void operator=(Logger const&) = delete;
inline static const std::string INFO = "[ INFO]";
inline static const std::string DEBUG = "[DEBUG]";
inline static const std::string ERROR = "[ERROR]";
template <typename... Args>
void log(const std::string& level, const std::string& format = {}, Args... args)
{
if (mFile != NULL) {
fprintf(mFile, ("[" + DateTime::logDateTime() + "] " + level + " " + format + "\n").c_str(), args...);
}
}
#if defined(_3DS)
const std::string mPath = "sdmc:/3ds/Checkpoint/checkpoint.log";
#elif defined(__SWITCH__)

@ -1 +1 @@
Subproject commit 33a3b150b3b07fb5c7eca41a3907ca914a63cc9d
Subproject commit 59213e4ba830d46ebacc4ba9aabaded6e7e3c0cf

View file

@ -62,7 +62,8 @@ CFLAGS := -g -Wall -Wextra -O3 -ffunction-sections -flto \
-DCS_PLATFORM=CS_P_CUSTOM \
`freetype-config --cflags` \
`sdl2-config --cflags` \
-DMG_ENABLE_FILESYSTEM
-DMG_ENABLE_FILESYSTEM \
-DCHEAT_SIZE_DECOMPRESSED=${CHEAT_SIZE_DECOMPRESSED}
CFLAGS += $(INCLUDE) -D__SWITCH__ -D_GNU_SOURCE=1
@ -162,10 +163,10 @@ endif
.PHONY: $(BUILD) clean all format
#---------------------------------------------------------------------------------
all: $(BUILD)
all: cheats $(BUILD)
$(BUILD):
@[ -d $@ ] || mkdir -p $@ $(BUILD) $(OUTDIR) $(ROMFS)/$(CHEATS)
@[ -d $@ ] || mkdir -p $@ $(BUILD) $(OUTDIR)
ifeq ($(OS),Windows_NT)
@cd $(SHARKIVE) && py -3 joiner.py switch
else
@ -179,6 +180,15 @@ clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTDIR)
#---------------------------------------------------------------------------------
cheats:
@mkdir -p $@ $(ROMFS)/$(CHEATS)
ifeq ($(OS),Windows_NT)
@cd $(SHARKIVE) && py -3 joiner.py switch
else
@cd $(SHARKIVE) && python3 joiner.py switch
endif
@cd $(SHARKIVE)/$(BUILD) && mv switch.json.bz2 ../../switch/$(ROMFS)/$(CHEATS)/$(CHEATS).json.bz2
#---------------------------------------------------------------------------------
format:
clang-format -i -style=file $(foreach dir,$(FORMATSOURCES),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cpp)) $(foreach dir,$(FORMATINCLUDES),$(wildcard $(dir)/*.h) $(wildcard $(dir)/*.hpp))
#---------------------------------------------------------------------------------

View file

@ -24,17 +24,17 @@ static FC_Font* getFontFromMap(int size)
bool SDLH_Init(void)
{
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) {
Logger::getInstance().error("SDL_Init: %s\n", SDL_GetError());
Logger::getInstance().log(Logger::ERROR, "SDL_Init: %s\n", SDL_GetError());
return false;
}
s_window = SDL_CreateWindow("Checkpoint", 0, 0, 1280, 720, SDL_WINDOW_FULLSCREEN);
if (!s_window) {
Logger::getInstance().error("SDL_CreateWindow: %s\n", SDL_GetError());
Logger::getInstance().log(Logger::ERROR, "SDL_CreateWindow: %s\n", SDL_GetError());
return false;
}
s_renderer = SDL_CreateRenderer(s_window, 0, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (!s_renderer) {
Logger::getInstance().error("SDL_CreateRenderer: %s\n", SDL_GetError());
Logger::getInstance().log(Logger::ERROR, "SDL_CreateRenderer: %s\n", SDL_GetError());
return false;
}
SDL_SetRenderDrawBlendMode(s_renderer, SDL_BLENDMODE_BLEND);
@ -42,7 +42,7 @@ bool SDLH_Init(void)
const int img_flags = IMG_INIT_PNG | IMG_INIT_JPG;
if ((IMG_Init(img_flags) & img_flags) != img_flags) {
Logger::getInstance().error("IMG_Init: %s\n", IMG_GetError());
Logger::getInstance().log(Logger::ERROR, "IMG_Init: %s\n", IMG_GetError());
return false;
}
SDLH_LoadImage(&s_star, "romfs:/star.png");

View file

@ -44,7 +44,7 @@ CheatManager::CheatManager(void)
if (f != NULL) {
fseek(f, 0, SEEK_END);
u32 size = ftell(f);
unsigned int destLen = 1024 * 1024;
unsigned int destLen = CHEAT_SIZE_DECOMPRESSED;
char* s = new char[size];
char* d = new char[destLen]();
rewind(f);

View file

@ -45,11 +45,11 @@ void servicesExit(void)
Result servicesInit(void)
{
Logger::getInstance().info("Starting Checkpoint loading...");
Logger::getInstance().log(Logger::INFO, "Starting Checkpoint loading...");
int appletType = (int)appletGetAppletType();
if (appletType != AppletType_Application) {
Logger::getInstance().error("Please run Checkpoint under Atmosphére title takeover. AppletType is %d", appletType);
Logger::getInstance().log(Logger::ERROR, "Please run Checkpoint under Atmosphére title takeover. AppletType is %d", appletType);
return -1;
}
@ -59,7 +59,7 @@ Result servicesInit(void)
// nxlinkStdio();
}
else {
Logger::getInstance().info("Unable to socketInitialize. Result code %X", socinit);
Logger::getInstance().log(Logger::INFO, "Unable to socketInitialize. Result code %X", socinit);
}
g_shouldExitNetworkLoop = R_FAILED(socinit);
@ -72,22 +72,22 @@ Result servicesInit(void)
io::createDirectory("sdmc:/switch/Checkpoint/cheats");
if (R_FAILED(res = plInitialize())) {
Logger::getInstance().error("plInitialize failed. Result code %X", res);
Logger::getInstance().log(Logger::ERROR, "plInitialize failed. Result code %X", res);
return res;
}
if (R_FAILED(res = Account::init())) {
Logger::getInstance().error("Account::init failed. Result code %X", res);
Logger::getInstance().log(Logger::ERROR, "Account::init failed. Result code %X", res);
return res;
}
if (R_FAILED(res = nsInitialize())) {
Logger::getInstance().error("nsInitialize failed. Result code %X", res);
Logger::getInstance().log(Logger::ERROR, "nsInitialize failed. Result code %X", res);
return res;
}
if (!SDLH_Init()) {
Logger::getInstance().error("SDLH_Init failed. Result code %X", res);
Logger::getInstance().log(Logger::ERROR, "SDLH_Init failed. Result code %X", res);
return -1;
}
@ -95,7 +95,7 @@ Result servicesInit(void)
g_notificationLedAvailable = true;
}
else {
Logger::getInstance().info("Notification led not available. Result code %X", res);
Logger::getInstance().log(Logger::INFO, "Notification led not available. Result code %X", res);
}
Configuration::getInstance();
@ -103,17 +103,17 @@ Result servicesInit(void)
if (R_SUCCEEDED(socinit) && R_SUCCEEDED(res = nifmInitialize())) {
if (R_SUCCEEDED(res = ftp_init())) {
g_ftpAvailable = true;
Logger::getInstance().info("FTP Server successfully loaded.");
Logger::getInstance().log(Logger::INFO, "FTP Server successfully loaded.");
}
else {
Logger::getInstance().info("FTP Server failed to load. Result code %X", res);
Logger::getInstance().log(Logger::INFO, "FTP Server failed to load. Result code %X", res);
}
}
else {
Logger::getInstance().info("Socket not initialized or nifmInitialize error. Result code %X", res);
Logger::getInstance().log(Logger::INFO, "Socket not initialized or nifmInitialize error. Result code %X", res);
}
Logger::getInstance().info("Checkpoint loading completed!");
Logger::getInstance().log(Logger::INFO, "Checkpoint loading completed!");
return 0;
}