Skip to content

Commit

Permalink
README + non-existent files don't cause crash
Browse files Browse the repository at this point in the history
  • Loading branch information
NefariousTechSupport committed Jul 31, 2022
1 parent e11f2df commit 30be227
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.obj
*.dds
.vscode
.vs
*/bin
Expand Down
18 changes: 13 additions & 5 deletions LibLunacy/FileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ public class FileManager
{
public string folderPath = string.Empty;

public Dictionary<string, IGFile> igfiles = new Dictionary<string, IGFile>(); //Actual IGFiles
public Dictionary<string, Stream> rawfiles = new Dictionary<string, Stream>(); //Raw data, includes files containing nothing but IGFiles
public Dictionary<string, IGFile?> igfiles = new Dictionary<string, IGFile?>(); //Actual IGFiles
public Dictionary<string, Stream?> rawfiles = new Dictionary<string, Stream?>(); //Raw data, includes files containing nothing but IGFiles

public bool isOld { get; private set; } //if true, old filesystem, else new filesystem

Expand Down Expand Up @@ -42,7 +42,7 @@ public void LoadFolder(string folderPath)
}
}

public object LoadFile(string name, bool isRaw)
public object? LoadFile(string name, bool isRaw)
{
//If anyone's wondering, the following basically doubles ram usage but doesn't latch onto files, useful for debugging
/*FileStream fs = File.Open($"{folderPath}/{name}", FileMode.Open, FileAccess.Read);
Expand All @@ -51,7 +51,11 @@ public object LoadFile(string name, bool isRaw)
fs.Close();*/

//The following doesn't use as much ram but holds onto files
FileStream ms = File.Open($"{folderPath}/{name}", FileMode.Open, FileAccess.Read);
FileStream? ms = null;
if(File.Exists($"{folderPath}/{name}"))
{
ms = File.Open($"{folderPath}/{name}", FileMode.Open, FileAccess.Read);
}

if(isRaw)
{
Expand All @@ -60,7 +64,11 @@ public object LoadFile(string name, bool isRaw)
}
else
{
IGFile file = new IGFile(ms);
IGFile? file = null;
if(ms != null)
{
file = new IGFile(ms);
}
igfiles.Add(name, file);
return file;
}
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Lunacy Level Editor

Level editor for the Ratchet and Clank PS3 games along with the Resistance series

## Building

* cd into the directory with Lunacy.sln
* Run `dotnet build`

## Running

* Run `Lunacy.exe <path to folder>`, where the folder contains either the main.dat file or the assetlookup.dat file
* Controls are as such:
* hold right click + move mouse to look around
* wasd to move, shift to move faster
* p shows the names of all objects that the mouse is hovering over
* select an object in either the regions or zones windows to teleport to that object

0 comments on commit 30be227

Please sign in to comment.