Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: do YYC check before accessing CODE chunk #1536

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions UndertaleModCli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,15 @@
return EXIT_FAILURE;
}

if (program.Data.IsYYC())
{
Console.WriteLine("The game was made with YYC (YoYo Compiler), which means that the code was compiled into the executable. " +
"There is thus no code to dump. Exiting.");
return EXIT_SUCCESS;
}

// If user provided code to dump, dump code
if ((options.Code?.Length > 0) && (program.Data.Code.Count > 0))
if ((options.Code?.Length > 0) && (program.Data.Code?.Count > 0))
{
// If user wanted to dump everything, do that, otherwise only dump what user provided
string[] codeArray;
Expand Down Expand Up @@ -572,8 +579,17 @@
Console.WriteLine($"{Data.Paths.Count} Paths, {Data.Scripts.Count} Scripts, {Data.Shaders.Count} Shaders");
Console.WriteLine($"{Data.Fonts.Count} Fonts, {Data.Timelines.Count} Timelines, {Data.GameObjects.Count} Game Objects");
Console.WriteLine($"{Data.Rooms.Count} Rooms, {Data.Extensions.Count} Extensions, {Data.TexturePageItems.Count} Texture Page Items");
Console.WriteLine($"{Data.Code.Count} Code Entries, {Data.Variables.Count} Variables, {Data.Functions.Count} Functions");
Console.WriteLine($"{Data.CodeLocals.Count} Code locals, {Data.Strings.Count} Strings, {Data.EmbeddedTextures.Count} Embedded Textures");
if (!Data.IsYYC())
{
Console.WriteLine($"{Data.Code.Count} Code Entries, {Data.Variables.Count} Variables, {Data.Functions.Count} Functions");
Console.WriteLine($"{Data.CodeLocals.Count} Code locals, {Data.Strings.Count} Strings, {Data.EmbeddedTextures.Count} Embedded Textures");
}
else
{
Console.WriteLine("Unknown amount of Code entries and Code locals");
}
Miepee marked this conversation as resolved.
Show resolved Hide resolved
Console.WriteLine($"{Data.Strings.Count} Strings");
Console.WriteLine($"{Data.EmbeddedTextures.Count} Embedded Textures");
Console.WriteLine($"{Data.EmbeddedAudio.Count} Embedded Audio");

if (IsInteractive) Pause();
Expand Down Expand Up @@ -712,7 +728,7 @@
/// Evaluates and executes given C# code.
/// </summary>
/// <param name="code">The C# string to execute</param>
/// <param name="scriptFile">The path to the script file where <see cref="code"/> was executed from.

Check warning on line 731 in UndertaleModCli/Program.cs

View workflow job for this annotation

GitHub Actions / publish_cli (ubuntu-latest, Debug, false)

XML comment has cref attribute 'code' that could not be resolved

Check warning on line 731 in UndertaleModCli/Program.cs

View workflow job for this annotation

GitHub Actions / publish_cli (ubuntu-latest, Debug, false)

XML comment has cref attribute 'code' that could not be resolved

Check warning on line 731 in UndertaleModCli/Program.cs

View workflow job for this annotation

GitHub Actions / publish_cli (macOS-latest, Debug, false)

XML comment has cref attribute 'code' that could not be resolved

Check warning on line 731 in UndertaleModCli/Program.cs

View workflow job for this annotation

GitHub Actions / publish_cli (macOS-latest, Debug, false)

XML comment has cref attribute 'code' that could not be resolved

Check warning on line 731 in UndertaleModCli/Program.cs

View workflow job for this annotation

GitHub Actions / publish_cli (windows-latest, Debug, false)

XML comment has cref attribute 'code' that could not be resolved

Check warning on line 731 in UndertaleModCli/Program.cs

View workflow job for this annotation

GitHub Actions / publish_cli (windows-latest, Debug, false)

XML comment has cref attribute 'code' that could not be resolved
/// Leave as null, if it wasn't executed from a script file</param>
private void RunCSharpCode(string code, string scriptFile = null)
{
Expand Down
Loading