Skip to content

Commit

Permalink
Merge pull request #149 from igor725/trophies
Browse files Browse the repository at this point in the history
Trophies system
  • Loading branch information
SysRay authored May 5, 2024
2 parents 27b308f + 456a92d commit 4953e3e
Show file tree
Hide file tree
Showing 30 changed files with 1,520 additions and 186 deletions.
4 changes: 1 addition & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"-fexceptions"
],
"ccls.index.threads": 0,

"cmake.parallelJobs": 0,
"cmake.generator": "Ninja",
"cmake.sourceDirectory": "${workspaceFolder}",
Expand All @@ -25,15 +24,14 @@
"CMAKE_C_COMPILER": "clang-cl.exe",
"CMAKE_CXX_COMPILER": "clang-cl.exe"
},

"C_Cpp.formatting": "clangFormat",
"C_Cpp.clang_format_style": "file:${workspaceRoot}/.clang-format",
"C_Cpp.clang_format_fallbackStyle": "LLVM",
"C_Cpp.clang_format_path": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\Llvm\\x64\\bin\\clang-format.exe",
"C_Cpp.default.compilerPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\Llvm\\bin\\clang-cl.exe",
"C_Cpp.default.intelliSenseMode": "windows-clang-x64",
"C_Cpp.default.cppStandard": "c++20",
"C_Cpp.autoAddFileAssociations": false,

"editor.tabSize": 2,
"editor.insertSpaces": true,
}
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.24)
include(ExternalProject)

set(PSOFF_LIB_VERSION v.0.2)
set(PSOFF_LIB_VERSION v.0.3)
set(PSOFF_RENDER_VERSION v.0.5-nightly_04.05.24)

set(ProjectName psOff_${CMAKE_BUILD_TYPE})
Expand Down Expand Up @@ -117,6 +117,7 @@ add_dependencies(psoff logging core psOff_utility)
target_link_libraries(psoff PRIVATE
core.lib
psOff_utility
libboost_filesystem
$<TARGET_OBJECTS:asmHelper>
)

Expand Down
6 changes: 6 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ add_subdirectory(initParams)
add_subdirectory(timer)
add_subdirectory(systemContent)
add_subdirectory(networking)
add_subdirectory(trophies)
add_subdirectory(fileManager)
add_subdirectory(memory)
add_subdirectory(dmem)
Expand All @@ -23,6 +24,7 @@ add_library(core SHARED
$<TARGET_OBJECTS:timer>
$<TARGET_OBJECTS:systemContent>
$<TARGET_OBJECTS:networking>
$<TARGET_OBJECTS:trophies>
$<TARGET_OBJECTS:videoout>
$<TARGET_OBJECTS:fileManager>
$<TARGET_OBJECTS:memory>
Expand All @@ -37,6 +39,7 @@ target_link_libraries(core PRIVATE
libboost_thread
libboost_chrono
libboost_program_options
libboost_filesystem
sdl2
psoff_render.lib
gamereport.lib
Expand All @@ -47,6 +50,9 @@ target_link_libraries(core PRIVATE
IPHLPAPI.lib
wepoll.lib
Ws2_32.lib
libcrypto.lib
libssl.lib
pugixml.lib
ntdll.dll
imgui
VulkanMemoryAllocator
Expand Down
15 changes: 8 additions & 7 deletions core/runtime/runtimeLinker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "util/moduleLoader.h"
#include "util/plt.h"
#include "util/virtualmemory.h"
#include "utility/progloc.h"
#include "utility/utility.h"

#include <boost/uuid/detail/sha1.hpp>
Expand Down Expand Up @@ -489,17 +490,17 @@ void RuntimeLinker::loadModules(std::string_view libName) {
LOG_DEBUG(L"Needs library %S", name.data());

// 1/2 Sepcial case: old->new, build filepath
std::string filepath = std::string("modules/");
auto filepath = std::format(L"{}/modules/", util::getProgramLoc());
if (name == "libSceGnmDriver") {
filepath += "libSceGraphicsDriver";
filepath += L"libSceGraphicsDriver";
} else {
filepath += std::string(name);
filepath += std::wstring(name.begin(), name.end());
}
filepath += ".dll";
filepath += L".dll";
//- filepath

if (std::filesystem::exists(filepath) && !m_libHandles.contains(name)) {
LOG_DEBUG(L" load library %S", filepath.c_str());
LOG_DEBUG(L" load library %s", filepath.c_str());
auto [handle, symbols] = loadModule(name.data(), filepath.c_str(), 1);

// 2/2 Sepcial case: old->new
Expand Down Expand Up @@ -828,7 +829,7 @@ uintptr_t RuntimeLinker::execute() {
// Get and load additional Modules needed
{
for (auto const& prog: m_programList) {
LOG_DEBUG(L"Load for %S", prog.first->filename.string().c_str());
LOG_DEBUG(L"Load for %s", prog.first->filename.c_str());
for (auto const& impLib: prog.second->getImportedLibs()) {
loadModules(impLib.first);
}
Expand All @@ -853,4 +854,4 @@ uintptr_t RuntimeLinker::execute() {
IRuntimeLinker& accessRuntimeLinker() {
static RuntimeLinker inst;
return inst;
}
}
6 changes: 3 additions & 3 deletions core/runtime/util/moduleLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

LOG_DEFINE_MODULE(ModuleLoader);

std::pair<void*, std::unique_ptr<Symbols::SymbolExport>> loadModule(const char* libName, const char* filepath, int libVersion) {
std::pair<void*, std::unique_ptr<Symbols::SymbolExport>> loadModule(const char* libName, const wchar_t* filepath, int libVersion) {
LOG_USE_MODULE(ModuleLoader);

HMODULE hModule = LoadLibrary(filepath);
HMODULE hModule = LoadLibraryW(filepath);
if (hModule == NULL) {
LOG_ERR(L"Couldn't load library %S, err:%d", filepath, GetLastError());
return {};
Expand Down Expand Up @@ -66,4 +66,4 @@ std::pair<void*, std::unique_ptr<Symbols::SymbolExport>> loadModule(const char*

void unloadModule(void* handle) {
FreeLibrary((HMODULE)handle);
}
}
4 changes: 2 additions & 2 deletions core/runtime/util/moduleLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
#include <utility>
#include <vector>

std::pair<void*, std::unique_ptr<Symbols::SymbolExport>> loadModule(const char* name, const char* filepath, int libVersion);
std::pair<void*, std::unique_ptr<Symbols::SymbolExport>> loadModule(const char* name, const wchar_t* filepath, int libVersion);

void unloadModule(void* handle);
void unloadModule(void* handle);
5 changes: 5 additions & 0 deletions core/trophies/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
add_library(trophies OBJECT
trophies.cpp
)

add_dependencies(trophies third_party)
Loading

0 comments on commit 4953e3e

Please sign in to comment.