mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-28 13:50:07 -04:00
Fixed System deserialization.
This commit is contained in:
parent
bf4011044f
commit
7f1f0fadff
2 changed files with 7 additions and 8 deletions
app/lib/world
|
@ -36,7 +36,7 @@ module.exports = class Thang
|
|||
Thang.lastIDNums[spriteName] = if Thang.lastIDNums[spriteName]? then Thang.lastIDNums[spriteName] + 1 else 0
|
||||
id = spriteName + (Thang.lastIDNums[spriteName] or '')
|
||||
id
|
||||
|
||||
|
||||
@resetThangIDs: -> Thang.lastIDNums = {}
|
||||
|
||||
constructor: (@world, @spriteName, @id) ->
|
||||
|
@ -157,12 +157,10 @@ module.exports = class Thang
|
|||
# TODO: take some (but not all) of deserialize logic from ThangState to handle other types
|
||||
t[prop] = val
|
||||
t
|
||||
|
||||
|
||||
getSpriteOptions: ->
|
||||
colorConfigs = @world?.getTeamColors() or {}
|
||||
options = {}
|
||||
if @team and colorConfigs[@team]
|
||||
options.colorConfig = {team: colorConfigs[@team]}
|
||||
if @spriteName is 'Tharin'
|
||||
console.log 'THARIN made options', options, colorConfigs, @world
|
||||
options
|
||||
|
|
|
@ -252,10 +252,9 @@ module.exports = class World
|
|||
# Code hotspot; optimize it
|
||||
if @frames.length < @totalFrames then worldShouldBeOverBeforeSerialization
|
||||
[transferableObjects, nontransferableObjects] = [0, 0]
|
||||
o = {name: @name, totalFrames: @totalFrames, maxTotalFrames: @maxTotalFrames, frameRate: @frameRate, dt: @dt, victory: @victory, userCodeMap: {}}
|
||||
o = {name: @name, totalFrames: @totalFrames, maxTotalFrames: @maxTotalFrames, frameRate: @frameRate, dt: @dt, victory: @victory, userCodeMap: {}, trackedProperties: {}}
|
||||
o.trackedProperties[prop] = @[prop] for prop in @trackedProperties or []
|
||||
|
||||
o[prop] = @[prop] for prop in @trackedProperties or []
|
||||
|
||||
for thangID, methods of @userCodeMap
|
||||
serializedMethods = o.userCodeMap[thangID] = {}
|
||||
for methodName, method of methods
|
||||
|
@ -348,6 +347,8 @@ module.exports = class World
|
|||
perf.t0 = now()
|
||||
w = new World o.name, o.userCodeMap, classMap
|
||||
[w.totalFrames, w.maxTotalFrames, w.frameRate, w.dt, w.scriptNotes, w.victory] = [o.totalFrames, o.maxTotalFrames, o.frameRate, o.dt, o.scriptNotes ? [], o.victory]
|
||||
w[prop] = val for prop, val of o.trackedProperties
|
||||
|
||||
[w.showCoordinates, w.showGrid, w.showPaths, w.indieSprites] = [o.showCoordinates, o.showGrid, o.showPaths, o.indieSprites]
|
||||
perf.t1 = now()
|
||||
w.thangs = (Thang.deserialize(thang, w, classMap) for thang in o.thangs)
|
||||
|
@ -462,4 +463,4 @@ module.exports = class World
|
|||
teamConfigs = @teamConfigs or {}
|
||||
colorConfigs = {}
|
||||
colorConfigs[teamName] = config.color for teamName, config of teamConfigs
|
||||
colorConfigs
|
||||
colorConfigs
|
||||
|
|
Loading…
Add table
Reference in a new issue