Skip to content

Commit

Permalink
Fix #793 - Relative pathing for interface and fileexists check (#882)
Browse files Browse the repository at this point in the history
* relative path and file exists check

* Update DMCompiler/Compiler/DMPreprocessor/DMPreprocessor.cs

Co-authored-by: wixoa <[email protected]>

* code review

* get rid of dead var

* clear up whitespace

* Update DMCompiler/DMCompiler.cs

Co-authored-by: wixoa <[email protected]>

* Tmp fix for no interface specified. See #851

Co-authored-by: wixoa <[email protected]>
  • Loading branch information
amylizzle and wixoaGit authored Oct 29, 2022
1 parent 00d5697 commit baa5589
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DMCompiler/DMCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ private static string SaveJson(List<DreamMapJson> maps, string interfaceFile, st
DreamCompiledJson compiledDream = new DreamCompiledJson();
compiledDream.Strings = DMObjectTree.StringTable;
compiledDream.Maps = maps;
compiledDream.Interface = interfaceFile;
compiledDream.Interface = string.IsNullOrEmpty(interfaceFile) ? "" : Path.GetRelativePath(Path.GetDirectoryName(outputFile), interfaceFile);
var jsonRep = DMObjectTree.CreateJsonRepresentation();
compiledDream.Types = jsonRep.Item1;
compiledDream.Procs = jsonRep.Item2;
Expand Down
4 changes: 3 additions & 1 deletion OpenDreamRuntime/DreamManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ public bool LoadJson(string? jsonPath)

_compiledJson = json;
_dreamResourceManager.SetDirectory(Path.GetDirectoryName(jsonPath));

if(!string.IsNullOrEmpty(_compiledJson.Interface) && !_dreamResourceManager.DoesFileExist(_compiledJson.Interface))
throw new FileNotFoundException("Interface DMF not found at "+Path.Join(Path.GetDirectoryName(jsonPath),_compiledJson.Interface));
//TODO: Empty or invalid _compiledJson.Interface should return default interface - see issue #851
ObjectTree.LoadJson(json);

SetMetaObjects();
Expand Down

0 comments on commit baa5589

Please sign in to comment.