mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 16:17:57 -05:00
Fixed array / string ThangState key serialization conflicts. Fixed #333.
This commit is contained in:
parent
a03403de94
commit
40a32d7b43
1 changed files with 4 additions and 2 deletions
|
@ -51,7 +51,8 @@ module.exports = class ThangState
|
|||
else if type is 'array'
|
||||
specialKey = storage[@frameIndex]
|
||||
value = @specialKeysToValues[specialKey]
|
||||
value = value.split('\x1E') # Record Separator
|
||||
# Remove leading and trailing Group Separators and split by any Record Separators to restore the array of strings
|
||||
value = value.substring(1, value.length - 1).split('\x1E') if value
|
||||
else
|
||||
value = storage[@frameIndex]
|
||||
value
|
||||
|
@ -133,7 +134,8 @@ module.exports = class ThangState
|
|||
storage[frameIndex] = specialKey
|
||||
storage[frameIndex] = specialKey
|
||||
else if type is 'array'
|
||||
value = value.join '\x1E' # Record Separator
|
||||
# We make sure the array keys won't collide with any string keys by using some unprintable characters.
|
||||
value = '\x1D' + value.join('\x1E') + '\x1D' # Group Separator, Record Separator(s), Group Separator
|
||||
specialKey = specialValuesToKeys[value]
|
||||
unless specialKey
|
||||
specialKey = specialKeysToValues.length
|
||||
|
|
Loading…
Reference in a new issue