Skip to content

Commit

Permalink
more logging and slightly more helpful error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
akifle47 committed Dec 12, 2024
1 parent 984e2f0 commit 5ab3981
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/ResourceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bool ResourceLoader::Load(std::filesystem::path filePath, uint32_t expectedVersi

if(!std::filesystem::exists(filePath))
{
Log::Error("File \"%s\" does not exist.", absolutePath.Get());
Log::Error("Resource file \"%s\" does not exist.", absolutePath.Get());
return false;
}

Expand All @@ -36,7 +36,7 @@ bool ResourceLoader::Load(std::filesystem::path filePath, uint32_t expectedVersi

if(rscHeader.Magic != rage::datResourceFileHeader::MAGIC_RSC5)
{
Log::Error("File \"%s\" uses an unsupported version or is not a resource file.", absolutePath.Get());
Log::Error("Resource file \"%s\" uses an unsupported version or is not a resource file.", absolutePath.Get());
return false;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ int main(int32_t argc, char** argv)
else if(argc == 2)
{
ProcessParticleList(argv[1], "");
Log::Info("Done.");
std::ignore = getc(stdin);
}

Expand Down Expand Up @@ -297,6 +296,7 @@ void ProcessParticleList(std::filesystem::path filePathIn, std::filesystem::path

ptxList.SaveToJson(filePathOut);
rsc.Map->FreeAllChunks();
Log::Info("Done.");
}
//json to wpfl
else if(filePathIn.extension() == ".json")
Expand All @@ -308,6 +308,7 @@ void ProcessParticleList(std::filesystem::path filePathIn, std::filesystem::path
{
RSC5Layout layout;
layout.Save(ptxList, filePathOut, 36);
Log::Info("Done.");
}
}
}
2 changes: 1 addition & 1 deletion src/rage/grcore/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void rage::grcTexturePC::LoadFromDDS(const DDS_HEADER& header, const void* pixel
mStride = mWidth;
else
{
Log::Error("grcTexturePC::LoadFromDDS: Unsupported texture format: %d.", (uint32_t)mFormat);
Log::Error("Can't load texture \"%s\" because it uses an unsupported format: %d.", mName ? mName : "null", (uint32_t)mFormat);
return;
}

Expand Down
5 changes: 4 additions & 1 deletion src/rage/rmptfx/PtxEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ namespace rage
break;

default:
Log::Error("Invalid ptx domain type - %d", type);
return nullptr;
}
}
Expand Down Expand Up @@ -323,6 +322,10 @@ namespace rage
mEmitterDomain = { CreateDomain(0, type) };
if(mEmitterDomain.Get())
mEmitterDomain->LoadFromJson(domainObj);
else
{
Log::Error("ptxEventEffect \"%s\"'s EmitterDomain uses an invalid domain type - %d", mEffectName ? mEffectName : "null", type);
}
}

field_A4 = object["field_A4"].GetInt();
Expand Down
2 changes: 1 addition & 1 deletion src/rage/rmptfx/PtxList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace rage
rapidjson::Document document;
if(document.Parse(fileData.data()).HasParseError())
{
Log::Error("Error parsing \"%s\". %d", filePath.string().c_str(), (uint32_t)document.GetParseError());
Log::Error("Error parsing \"%s\". Code: %d. Offset: %d", filePath.string().c_str(), (uint32_t)document.GetParseError(), document.GetErrorOffset());
return {};
}

Expand Down
2 changes: 2 additions & 0 deletions src/rage/rmptfx/PtxList.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ namespace rage

Log::Info("Saving effect rules...");
mEffectRules.AddToLayout(layout, depth);

Log::Info("Saving resource...");
}

void SerializePtrs(RSC5Layout& layout, datResource& rsc, uint32_t depth)
Expand Down
6 changes: 3 additions & 3 deletions src/rage/rmptfx/PtxRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace rage
}
else
{
Log::Error("Invalid ptxRule type - %s", mClassName);
Log::Error("ptxRule \"%s\" uses an invalid type - %s", mName ? mName : "null", mClassName);
}
}

Expand All @@ -51,7 +51,7 @@ namespace rage
}
else
{
Log::Error("Invalid ptxRule type - %s", mClassName);
Log::Error("ptxRule \"%s\" uses an invalid type - %s", mName ? mName : "null", mClassName);
}
}

Expand All @@ -67,7 +67,7 @@ namespace rage
}
else
{
Log::Error("Invalid ptxRule type - %s", mClassName);
Log::Error("ptxRule \"%s\" uses an invalid type - %s", mName ? mName : "null", mClassName);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/rage/rmptfx/RmPtfxShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ namespace rage
break;

default:
Log::Error("Invalid rmptfx shader var type - %d", (uint32_t)varType);
Log::Error("Shader variable \"%s\" in shader \"%s\" uses an invalid type - %d",
varValue.HasMember("Name") ? varValue["Name"].GetString() : "null", mName ? mName : "null", (uint32_t)varType);
}

auto varObject = varValue.GetObject();
Expand Down
4 changes: 2 additions & 2 deletions src/rage/rmptfx/RmPtfxShaderVar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace rage
break;

default:
Log::Error("Invalid rmptfx shader var type - %d", mType);
Log::Error("Shader variable \"%s\" uses an invalid type - %d", mName ? mName : "null", mType);
}
}

Expand Down Expand Up @@ -108,7 +108,7 @@ namespace rage
break;

default:
Log::Error("Invalid rmptfx shader var type - %d", mType);
Log::Error("Shader variable \"%s\" uses an invalid type - %d", mName ? mName : "null", mType);
return 0;
}
}
Expand Down

0 comments on commit 5ab3981

Please sign in to comment.