redssu / Harmony-Tools

A collection of tools to help translate Danganronpa V3: Killing Harmony video game.
GNU General Public License v3.0
9 stars 1 forks source link

Problems with editing / repacking minigame data #5

Closed Colfieldd closed 1 year ago

Colfieldd commented 1 year ago

First off, thank you for this tool. Without it, work on the V3 German Fan-Translation wouldn't have been possible at all.

So my issue is this:

I don't know if it's just me, but I cannot properly edit "Hangman's Gambit" (anagram) files under minigame/anagram/anagram.US.spc. Let's take answer000.dat, VENT, as an example. If I unpack the .dat file, it gives me a .csv Excel file, just like you showed in your wiki. But the format is different for some reason. It looks like this:

Issue 1

Every row of text is cramped into the A column. It looks different from the format / structure of your Brain Drive Excel files. Just to check, I also did the same with Brain Drive and it's the same issue: the text is not properly divided into ABC sections. When I edit this file and pack it as .dat again, when I load up the game, it crashes to desktop when Hangman's Gambit starts.

I wanted to check why this happens and I noticed that, after having edited the .csv file IN ANY WAY, the binary code of the .dat file is broken after repacking:

Issue 2

So yeah, I don't know how to fix this. Directly editing the .dat file through binary code editing does not really work either. Also, something weird I noticed is that, after unpacking the .dat file, when I try to immediately pack the Excel as .dat again WITHOUT editing it in any way, I get an error message:

Issue 3

I tried to explain my problem in the best way but if something is unclear, please let me know. I'm sorry if you posted this solution somewhere in the wiki. I may have overlooked something, but maybe you can help? Thank you in advance!

redssu commented 1 year ago

Hey,

Regarding the issue of opening .CSV files in Excel - the problem is that if you open a .CSV file directly by double-clicking on it (or using "Open with"), Excel treats the file as plain text.

To correctly open a .CSV file in Excel, you need to create a new spreadsheet, go to the "Data" tab, and click on the "From Text/CSV" button. This should open a simple CSV file import wizard. Once you go through all the steps, the data should be imported in a format similar to the screenshot on the Wiki.

Of course, this probably still won't solve the main issue because, as you noticed, something is wrong with packing the .DAT files. I'll definitely look into it.

I'd just like to ask you for additional information: are you still using the older version of the tools (1.0.x) or the new one (2.0.x) that I released in February?

Colfieldd commented 1 year ago

I'm using your latest version, 2.0.3 released on March 19.

I actually imported the data now instead of opening the file directly and yes, it helped! It now looks like it's supposed to.

I tried to edit the file but the problem is unfortunately still there. The game crashes at the minigame after repacking. But I noticed that the .dat file after repacking is now "less broken". It definitely resembles the code before repacking the .dat, but it's still not the same. For example, the word "monokuma" is missing after repacking.

(By the way, what I mean with code is that I'm opening the .dat file with Notepad++ to look at the code. I'm basically comparing the .dat before and after the repack.)

redssu commented 1 year ago

Okay, thanks, I'll look into it and let you know in this thread when the issue is resolved.

redssu commented 1 year ago

Hey @Colfieldd,

I apologize for it taking so long (where did those 3 weeks go?!), but I've been really busy lately. It turns out that the bug has been present in the DAT file tool from the very beginning 😮.

I believe the issue should be resolved now, but I'd appreciate it if you could confirm that if you can. I've released version 2.0.4 (you can find it in "Releases"), which includes the fix.

Colfieldd commented 1 year ago

Thanks for the update!

Okay, so I managed to actually repack the Excel to DAT and the minigame works. But this only works if I don't edit the file. The game still crashes when I change the characters. But I'm not sure if this problem is coming from the program. That's why I have a few questions regarding the Excel to make sure I'm doing it correctly:

Issue 01

  1. I notice that the quotation marks ("") disappear in Excel. When I'm looking at the Excel through Notepad, you can see the quotation marks, but they disappear there as well after editing the Excel. I'm pretty sure that's why the following error happens:

Issue 04

This error does NOT happen anymore when I manually add the quotation marks in Notepad after having edited the Excel. (But the game still crashes when changing the characters.)

  1. Regarding importing the data, what options should I use here? Is it okay to use the default settings? I notice that you can actually see "UTF16" in the data, but it's not an option here.

Issue 02

  1. How do I actually save the imported data so that the formatting etc. is right? As you can see in the screenshot, there are multiple possibilities for saving the Excel. Does it make a difference?

Issue 03

... Yeah, so it's definitely working. But I still have some trouble actually editing the Excel so it works in-game. I don't actually think that this is related to the program, but maybe you have an idea?

redssu commented 1 year ago

1.

Regarding the disappearing quotation marks in Excel - it's absolutely fine.

However, what I didn't notice is that Excel doesn't save columns with quotation marks - and actually, there's no need for it, so it's hard to blame Excel. It's just me preventively enclose every column value in quotation marks.

Nonetheless, this shouldn't affect the process of packing the CSV file into DAT; I tried to support both cases.

However, as seen in your console screenshot, another issue occurred: if a column is empty, not surrounded by quotation marks, and located at the end, it won't be taken into account, causing the tools to complain about the column count mismatch.

I've fixed the program in 2.0.5 release that processes the CSV file to handle this specific situation.

2.

Yes, the default settings are perfectly fine.

3.

It doesn't make much difference; personally, I use "CSV UTF-8 (Comma delimited)."

You also mentioned another issue:

(But the game still crashes when changing the characters.)

Does this mean that even if you edit the file in Notepad, then pack and run it in the game, the game still crashes?

I'd also like to apologize for the process of error resolution, but honestly, I don't have the means to verify the correctness of the file data in the game (since I don't have it downloaded and I can't download it right now). At the same time, I want to thank you for the detailed description of the errors and your efforts.

I'd also appreciate it if you could confirm that the problem has been resolved in 2.0.5.

PS. Maybe it's time for me to write a proper CSV parser or use an external library... and add automated tests for this program

Colfieldd commented 1 year ago

Okay, so the issue with the repacking has been resolved, so I can repack the Excel as ".DAT" without adding the quotation marks, that's good!

Screenshot (106)

I'm trying to repack this Excel. It should be okay. (Note: This isn't the actual word for "Vent". Before trying anything fancy with adding new characters, I want to make sure simply replacing the current characters works.)

But yeah, I still can't change the actual minigame password without the game crashing. BUT I did some testing and found out that I can change PARTS of the word without it crashing. Here's a short summary:

Changing ONLY the first character = working Changing the first TWO characters = crash Changing ONLY the second character = crash

20230624153549_1

So, I think the crash occurs because something goes wrong after the first character. (I did not check the other possibilities because it gets confusing.)

I hope this helps! And don't worry, I know how hard it is to fix something without actually testing it in-game. ^^

Colfieldd commented 1 year ago

UPDATE:

So I checked the rest of the characters and I found out that every letter works EXCEPT the second letter. If this is changed, the game crashes, and only then. I honestly don't know why.

I tried to be creative with the Excel and replace the second letter with a new line, but nothing worked yet. It actually crashes during the minigame now. (Progress, I guess?)

Anyway, I believe it has something to do with how the "DAT" is structured:

Screenshot (107)

Aside from the first letter, the second letter is the only one who is a bit "different" from the other letters. It's hard to explain, but I marked it for you.

For the record, I looked at a "DAT" with only the second character changed and nothing is different from the original aside from the letter itself (in my case, E->U). This makes it kind of confusing for me.

At least now we know what the problem is. Maybe you have an idea.

Colfieldd commented 1 year ago

Alright, so big news! I managed to get it working.

The problem was actually tied to the font the game uses for "Hangman's Gambit", this being "v3_font20.stx". As it turns out, the font was missing the letter "U". It doesn't know what to display, so it crashes. When I added the missing letter, everything worked! I didn't realize "Hangman's Gambit" uses a special font.

So as you can see, the program has nothing to do with this. It actually works like it's supposed to now.

I wanted to thank you again for the troubleshooting and you can close this thread now if you want. If any more problems turn up, I will let you know, but I think I'm set for the chapter 1 release! ^^

(And yes, German words are indeed this long.)

20230625161936_1

redssu commented 1 year ago

Ouh, so that was the problem...

I'm glad you managed to solve it!

I'll close this thread, but feel free to create a new one or contact me via email if needed.

Cheers.