Skip to content

Commit

Permalink
Fix level custom blocks not showing up when doing /wunload then /wloa…
Browse files Browse the repository at this point in the history
…d again
  • Loading branch information
UnknownShadow200 committed Nov 13, 2017
1 parent 9dccfe1 commit 0f98250
Showing 1 changed file with 17 additions and 24 deletions.
41 changes: 17 additions & 24 deletions fCraft/World/WorldManager.cs
Expand Up @@ -230,17 +230,6 @@ static void LoadWorldListEntry([NotNull] XElement el)
if (blockEl != null) {
world.BlockDB.LoadSettings(blockEl);
}

// Load CustomBlock settings
string blockDefPath = Path.Combine(Paths.BlockDefsDirectory, world.Name + ".txt");
if (File.Exists(blockDefPath)) {
int count;
BlockDefinition[] defs = BlockDefinition.Load(blockDefPath, out count);
for (int i = 0; i < defs.Length; i++) {
if (defs[i] == null) defs[i] = BlockDefinition.GlobalDefs[i];
}
world.BlockDefs = defs;
}

// load environment settings
XElement envEl = el.Element(EnvironmentXmlTagName);
Expand Down Expand Up @@ -732,6 +721,7 @@ static void LoadWorldListEntry([NotNull] XElement el)
throw new WorldOpException( name, WorldOpExceptionCode.InvalidWorldName );
}

World newWorld;
lock( SyncRoot ) {
if( WorldIndex.ContainsKey( name.ToLower() ) ) {
throw new WorldOpException( name, WorldOpExceptionCode.DuplicateWorldName );
Expand All @@ -741,25 +731,28 @@ static void LoadWorldListEntry([NotNull] XElement el)
throw new WorldOpException( name, WorldOpExceptionCode.Cancelled );
}

World newWorld = new World( name ) {
Map = map
};

if( preload ) {
newWorld.Preload = true;
}

if( map != null ) {
newWorld.SaveMap();
}
newWorld = new World( name ) { Map = map };
if( preload ) newWorld.Preload = true;
if( map != null ) newWorld.SaveMap();

WorldIndex.Add( name.ToLower(), newWorld );
UpdateWorldList();

RaiseWorldCreatedEvent( player, newWorld );

return newWorld;
}

// Load CustomBlock settings
string blockDefPath = Path.Combine(Paths.BlockDefsDirectory, name + ".txt");
if (File.Exists(blockDefPath)) {
int count;
BlockDefinition[] defs = BlockDefinition.Load(blockDefPath, out count);
for (int i = 0; i < defs.Length; i++) {
if (defs[i] == null) defs[i] = BlockDefinition.GlobalDefs[i];
}
newWorld.BlockDefs = defs;
}

return newWorld;
}


Expand Down

0 comments on commit 0f98250

Please sign in to comment.