diff --git a/app/lib/LevelLoader.coffee b/app/lib/LevelLoader.coffee index 3a1bb39c3..24feca40f 100644 --- a/app/lib/LevelLoader.coffee +++ b/app/lib/LevelLoader.coffee @@ -478,7 +478,7 @@ module.exports = class LevelLoader extends CocoClass @world.difficulty = @session?.get('state')?.difficulty ? 0 if @observing @world.difficulty = Math.max 0, @world.difficulty - 1 # Show the difficulty they won, not the next one. - serializedLevel = @level.serialize(@supermodel, @session, @opponentSession) + serializedLevel = @level.serialize {@supermodel, @session, @opponentSession, @headless, @sessionless} @world.loadFromLevel serializedLevel, false console.log 'World has been initialized from level loader.' if LOG diff --git a/app/lib/simulator/Simulator.coffee b/app/lib/simulator/Simulator.coffee index 473ea06af..16e48dd6a 100644 --- a/app/lib/simulator/Simulator.coffee +++ b/app/lib/simulator/Simulator.coffee @@ -226,7 +226,7 @@ module.exports = class Simulator extends CocoClass @levelLoader = null setupGod: -> - @god.setLevel @level.serialize(@supermodel, @session, @otherSession) + @god.setLevel @level.serialize {@supermodel, @session, @otherSession, headless: true, sessionless: false} @god.setLevelSessionIDs (session.sessionID for session in @task.getSessions()) @god.setWorldClassMap @world.classMap @god.setGoalManager new GoalManager @world, @level.get('goals'), null, {headless: true} diff --git a/app/models/Level.coffee b/app/models/Level.coffee index 8df696750..77c4ff84c 100644 --- a/app/models/Level.coffee +++ b/app/models/Level.coffee @@ -12,7 +12,8 @@ module.exports = class Level extends CocoModel urlRoot: '/db/level' editableByArtisans: true - serialize: (supermodel, session, otherSession, cached=false) -> + serialize: (options) -> + {supermodel, session, otherSession, @headless, @sessionless, cached=false} = options o = @denormalize supermodel, session, otherSession # hot spot to optimize # Figure out Components @@ -146,7 +147,7 @@ module.exports = class Level extends CocoModel levelThang.components.push placeholderComponent # Load the user's chosen hero AFTER getting stats from default char - if /Hero Placeholder/.test(levelThang.id) and @get('type', true) in ['course'] + if /Hero Placeholder/.test(levelThang.id) and @get('type', true) in ['course'] and not @headless and not @sessionless heroThangType = me.get('heroConfig')?.thangType or ThangType.heroes.captain levelThang.thangType = heroThangType if heroThangType diff --git a/app/views/editor/level/thangs/ThangsTabView.coffee b/app/views/editor/level/thangs/ThangsTabView.coffee index 4dd28b836..1e794a40d 100644 --- a/app/views/editor/level/thangs/ThangsTabView.coffee +++ b/app/views/editor/level/thangs/ThangsTabView.coffee @@ -595,7 +595,7 @@ module.exports = class ThangsTabView extends CocoView @level.set 'thangs', thangs return if @editThangView return if skipSerialization - serializedLevel = @level.serialize @supermodel, null, null, true + serializedLevel = @level.serialize {@supermodel, session: null, otherSession: null, headless: false, sessionless: true, cached: true} try @world.loadFromLevel serializedLevel, false catch error diff --git a/app/views/editor/verifier/VerifierTest.coffee b/app/views/editor/verifier/VerifierTest.coffee index 4fad8d0e3..926ed1dee 100644 --- a/app/views/editor/verifier/VerifierTest.coffee +++ b/app/views/editor/verifier/VerifierTest.coffee @@ -62,7 +62,7 @@ module.exports = class VerifierTest extends CocoClass @solution = @levelLoader.session.solution setupGod: -> - @god.setLevel @level.serialize @supermodel, @session + @god.setLevel @level.serialize {@supermodel, @session, otherSession: null, headless: true, sessionless: false} @god.setLevelSessionIDs [@session.id] @god.setWorldClassMap @world.classMap @god.lastFlagHistory = @session.get('state').flagHistory diff --git a/app/views/ladder/LadderView.coffee b/app/views/ladder/LadderView.coffee index b2bb6e9c6..d192a892a 100644 --- a/app/views/ladder/LadderView.coffee +++ b/app/views/ladder/LadderView.coffee @@ -42,6 +42,7 @@ module.exports = class LadderView extends RootView initialize: (options, @levelID, @leagueType, @leagueID) -> @level = @supermodel.loadModel(new Level(_id: @levelID)).model @level.once 'sync', => + return if @destroyed @levelDescription = marked(@level.get('description')) if @level.get('description') @teams = teamDataFromLevel @level @sessions = @supermodel.loadCollection(new LevelSessionsCollection(@levelID), 'your_sessions', {cache: false}).model diff --git a/app/views/play/SpectateView.coffee b/app/views/play/SpectateView.coffee index 769f75324..272b69d5b 100644 --- a/app/views/play/SpectateView.coffee +++ b/app/views/play/SpectateView.coffee @@ -69,7 +69,7 @@ module.exports = class SpectateLevelView extends RootView @load() setLevel: (@level, @supermodel) -> - serializedLevel = @level.serialize @supermodel, @session, @otherSession + serializedLevel = @level.serialize {@supermodel, @session, @otherSession, headless: false, sessionless: false} @god?.setLevel serializedLevel if @world @world.loadFromLevel serializedLevel, false @@ -106,7 +106,7 @@ module.exports = class SpectateLevelView extends RootView #at this point, all requisite data is loaded, and sessions are not denormalized team = @world.teamForPlayer(0) @loadOpponentTeam(team) - @god.setLevel @level.serialize @supermodel, @session, @otherSession + @god.setLevel @level.serialize {@supermodel, @session, @otherSession, headless: false, sessionless: false} @god.setLevelSessionIDs if @otherSession then [@session.id, @otherSession.id] else [@session.id] @god.setWorldClassMap @world.classMap @setTeam team diff --git a/app/views/play/level/PlayLevelView.coffee b/app/views/play/level/PlayLevelView.coffee index ef48795d7..45340f0d7 100644 --- a/app/views/play/level/PlayLevelView.coffee +++ b/app/views/play/level/PlayLevelView.coffee @@ -128,7 +128,7 @@ module.exports = class PlayLevelView extends RootView @supermodel.collections = givenSupermodel.collections @supermodel.shouldSaveBackups = givenSupermodel.shouldSaveBackups - serializedLevel = @level.serialize @supermodel, @session, @otherSession + serializedLevel = @level.serialize {@supermodel, @session, @otherSession, headless: false, sessionless: false} @god?.setLevel serializedLevel if @world @world.loadFromLevel serializedLevel, false @@ -244,7 +244,7 @@ module.exports = class PlayLevelView extends RootView @session.set 'multiplayer', false setupGod: -> - @god.setLevel @level.serialize @supermodel, @session, @otherSession + @god.setLevel @level.serialize {@supermodel, @session, @otherSession, headless: false, sessionless: false} @god.setLevelSessionIDs if @otherSession then [@session.id, @otherSession.id] else [@session.id] @god.setWorldClassMap @world.classMap