Dessyreqt / alttprandomizer

The Legend of Zelda: A Link to the Past Randomizer
178 stars 30 forks source link

Seed generation when using <seed> and <date> crashes client. #279

Closed thatguycore closed 7 years ago

thatguycore commented 7 years ago

Whenever I try to use and to create directories the client will crash. This only happens when trying to use those identifiers to create a directory. This does not happen when only using them to generate a file name..

Example: D:\SNES\ROMS\rando\v7\unplayed\\\ALttP Random - .sfc will cause a crash. D:\SNES\ROMS\rando\v7\unplayed\ALttP Random - .sfc will not cause a crash.

Since I have Microsoft Visual Studio installed it ask me if I would like to try and debug the problem, in doing so gives me this information.

https://i.gyazo.com/6736948835251d4f86f325aa84ced74b.png

BlueViper85 commented 7 years ago

As indicated in the screenshot, a RandomizationException is being thrown. Looking further at the process, when it hits this line in Randomizer.cs:

Directory.CreateDirectory(options.Filename.Substring(0, options.Filename.LastIndexOf('\\')));

It is attempting to create the file path using "" and "" as literal strings, and < and > are not valid characters in folder names in Windows.

Using the already existing function to fix the file name, I added a line to run the replacement when evaluating the path as a whole. So the line above becomes these two lines:

String filePath = FileName.Fix(options.Filename, string.Format(romLocations.SeedFileString, seed), complexity); Directory.CreateDirectory(filePath.Substring(0, filePath.LastIndexOf('\\')));

I can submit this as a Pull request, but currently am testing a few other ideas from other recent issues that I may want to submit at the same time.

BlueViper85 commented 7 years ago

The fix for this issue has been applied to the base code and will be available when the next version is released (no ETA). Closing this issue since a fix has been applied.