Apply clang-format to files (#5273)

This commit is contained in:
Archez
2025-04-01 22:33:38 -04:00
committed by GitHub
parent e8389e0b2e
commit 8f126344a4
885 changed files with 40384 additions and 36263 deletions
+39 -46
View File
@@ -25,7 +25,8 @@ extern "C" uint32_t ResourceMgr_GetGameVersion(int index) {
}
extern "C" uint32_t ResourceMgr_GetGamePlatform(int index) {
uint32_t version = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index];
uint32_t version =
Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index];
switch (version) {
case OOT_NTSC_US_10:
@@ -49,7 +50,8 @@ extern "C" uint32_t ResourceMgr_GetGamePlatform(int index) {
}
extern "C" uint32_t ResourceMgr_GetGameRegion(int index) {
uint32_t version = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index];
uint32_t version =
Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index];
switch (version) {
case OOT_NTSC_US_10:
@@ -158,7 +160,7 @@ extern "C" char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize)
extern "C" uint8_t ResourceMgr_FileExists(const char* filePath) {
std::string path = filePath;
if(path.substr(0, 7) == "__OTR__"){
if (path.substr(0, 7) == "__OTR__") {
path = path.substr(7);
}
@@ -186,7 +188,7 @@ extern "C" bool ResourceMgr_IsAltAssetsEnabled() {
// The resource is only removed from the internal cache to prevent it from used in the next resource lookup
extern "C" void ResourceMgr_UnloadOriginalWhenAltExists(const char* resName) {
if (ResourceMgr_IsAltAssetsEnabled() && ResourceMgr_FileAltExists((char*)resName)) {
ResourceMgr_UnloadResource((char*) resName);
ResourceMgr_UnloadResource((char*)resName);
}
}
@@ -232,8 +234,10 @@ extern "C" char* ResourceMgr_LoadJPEG(char* data, size_t dataSize) {
int h;
int comp;
unsigned char* pixels = stbi_load_from_memory((const unsigned char*)data, 320 * 240 * 2, &w, &h, &comp, STBI_rgb_alpha);
//unsigned char* pixels = stbi_load_from_memory((const unsigned char*)data, 480 * 240 * 2, &w, &h, &comp, STBI_rgb_alpha);
unsigned char* pixels =
stbi_load_from_memory((const unsigned char*)data, 320 * 240 * 2, &w, &h, &comp, STBI_rgb_alpha);
// unsigned char* pixels = stbi_load_from_memory((const unsigned char*)data, 480 * 240 * 2, &w, &h, &comp,
// STBI_rgb_alpha);
int idx = 0;
for (int y = 0; y < h; y++) {
@@ -313,8 +317,8 @@ typedef struct {
std::unordered_map<std::string, std::unordered_map<std::string, GfxPatch>> originalGfx;
// Attention! This is primarily for cosmetics & bug fixes. For things like mods and model replacement you should be using OTRs
// instead (When that is available). Index can be found using the commented out section below.
// Attention! This is primarily for cosmetics & bug fixes. For things like mods and model replacement you should be
// using OTRs instead (When that is available). Index can be found using the commented out section below.
extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction) {
auto res = std::static_pointer_cast<Fast::DisplayList>(
Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path));
@@ -327,7 +331,8 @@ extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchNa
// SPDLOG_INFO("index:{} command:{}", i, gfx->words.w0 >> 24);
// Log only SetPrimColors
if (gfx->words.w0 >> 24 == 250) {
SPDLOG_INFO("index:{} r:{} g:{} b:{} a:{}", i, _SHIFTR(gfx->words.w1, 24, 8), _SHIFTR(gfx->words.w1, 16, 8), _SHIFTR(gfx->words.w1, 8, 8), _SHIFTR(gfx->words.w1, 0, 8));
SPDLOG_INFO("index:{} r:{} g:{} b:{} a:{}", i, _SHIFTR(gfx->words.w1, 24, 8), _SHIFTR(gfx->words.w1, 16,
8), _SHIFTR(gfx->words.w1, 8, 8), _SHIFTR(gfx->words.w1, 0, 8));
}
}
}*/
@@ -345,16 +350,14 @@ extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchNa
Gfx* gfx = (Gfx*)&res->Instructions[index];
if (!originalGfx.contains(path) || !originalGfx[path].contains(patchName)) {
originalGfx[path][patchName] = {
index,
*gfx
};
originalGfx[path][patchName] = { index, *gfx };
}
*gfx = instruction;
}
extern "C" void ResourceMgr_PatchGfxCopyCommandByName(const char* path, const char* patchName, int destinationIndex, int sourceIndex) {
extern "C" void ResourceMgr_PatchGfxCopyCommandByName(const char* path, const char* patchName, int destinationIndex,
int sourceIndex) {
auto res = std::static_pointer_cast<Fast::DisplayList>(
Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path));
@@ -367,10 +370,7 @@ extern "C" void ResourceMgr_PatchGfxCopyCommandByName(const char* path, const ch
Gfx sourceGfx = *(Gfx*)&res->Instructions[sourceIndex];
if (!originalGfx.contains(path) || !originalGfx[path].contains(patchName)) {
originalGfx[path][patchName] = {
destinationIndex,
*destinationGfx
};
originalGfx[path][patchName] = { destinationIndex, *destinationGfx };
}
*destinationGfx = sourceGfx;
@@ -402,59 +402,52 @@ extern "C" char* ResourceMgr_LoadArrayByNameAsVec3s(const char* path) {
// return (char*)res->CachedGameAsset;
// else
// {
Vec3s* data = (Vec3s*)malloc(sizeof(Vec3s) * res->Scalars.size());
Vec3s* data = (Vec3s*)malloc(sizeof(Vec3s) * res->Scalars.size());
for (size_t i = 0; i < res->Scalars.size(); i += 3) {
data[(i / 3)].x = res->Scalars[i + 0].s16;
data[(i / 3)].y = res->Scalars[i + 1].s16;
data[(i / 3)].z = res->Scalars[i + 2].s16;
}
for (size_t i = 0; i < res->Scalars.size(); i += 3) {
data[(i / 3)].x = res->Scalars[i + 0].s16;
data[(i / 3)].y = res->Scalars[i + 1].s16;
data[(i / 3)].z = res->Scalars[i + 2].s16;
}
// res->CachedGameAsset = data;
// res->CachedGameAsset = data;
return (char*)data;
return (char*)data;
// }
}
extern "C" CollisionHeader* ResourceMgr_LoadColByName(const char* path) {
return (CollisionHeader*) ResourceGetDataByName(path);
return (CollisionHeader*)ResourceGetDataByName(path);
}
extern "C" Vtx* ResourceMgr_LoadVtxByName(char* path) {
return (Vtx*) ResourceGetDataByName(path);
return (Vtx*)ResourceGetDataByName(path);
}
extern "C" SequenceData ResourceMgr_LoadSeqByName(const char* path) {
SequenceData* sequence = (SequenceData*) ResourceGetDataByName(path);
SequenceData* sequence = (SequenceData*)ResourceGetDataByName(path);
return *sequence;
}
extern "C" SoundFontSample* ResourceMgr_LoadAudioSample(const char* path) {
return (SoundFontSample*) ResourceGetDataByName(path);
return (SoundFontSample*)ResourceGetDataByName(path);
}
extern "C" SoundFont* ResourceMgr_LoadAudioSoundFont(const char* path) {
return (SoundFont*) ResourceGetDataByName(path);
return (SoundFont*)ResourceGetDataByName(path);
}
extern "C" int ResourceMgr_OTRSigCheck(char* imgData) {
uintptr_t i = (uintptr_t)(imgData);
uintptr_t i = (uintptr_t)(imgData);
// if (i == 0xD9000000 || i == 0xE7000000 || (i & 1) == 1)
// if (i == 0xD9000000 || i == 0xE7000000 || (i & 1) == 1)
if ((i & 1) == 1)
return 0;
// if ((i & 0xFF000000) != 0xAB000000 && (i & 0xFF000000) != 0xCD000000 && i != 0) {
// if ((i & 0xFF000000) != 0xAB000000 && (i & 0xFF000000) != 0xCD000000 && i != 0) {
if (i != 0) {
if (
imgData[0] == '_' &&
imgData[1] == '_' &&
imgData[2] == 'O' &&
imgData[3] == 'T' &&
imgData[4] == 'R' &&
imgData[5] == '_' &&
imgData[6] == '_'
) {
if (imgData[0] == '_' && imgData[1] == '_' && imgData[2] == 'O' && imgData[3] == 'T' && imgData[4] == 'R' &&
imgData[5] == '_' && imgData[6] == '_') {
return 1;
}
}
@@ -463,7 +456,7 @@ extern "C" int ResourceMgr_OTRSigCheck(char* imgData) {
}
extern "C" AnimationHeaderCommon* ResourceMgr_LoadAnimByName(const char* path) {
return (AnimationHeaderCommon*) ResourceGetDataByName(path);
return (AnimationHeaderCommon*)ResourceGetDataByName(path);
}
extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, SkelAnime* skelAnime) {
@@ -480,11 +473,11 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel
pathStr = Ship::IResource::gAltAssetPrefix + pathStr;
}
SkeletonHeader* skelHeader = (SkeletonHeader*) ResourceGetDataByName(pathStr.c_str());
SkeletonHeader* skelHeader = (SkeletonHeader*)ResourceGetDataByName(pathStr.c_str());
// If there isn't an alternate model, load the regular one
if (isAlt && skelHeader == NULL) {
skelHeader = (SkeletonHeader*) ResourceGetDataByName(path);
skelHeader = (SkeletonHeader*)ResourceGetDataByName(path);
}
// This function is only called when a skeleton is initialized.