Skip to content

Commit

Permalink
chore: improve ids, and some print tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
georgejecook committed Aug 5, 2021
1 parent 9d2fb25 commit 6283bc3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/source/core/AssetBundle.bs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace mc
'// cspell:disable-next-line
if not fs.exists("cachefs:/" + filename)
'// cspell:disable-next-line
? "assetKey " ; assetKey ; " is not in cachefs"
' ? "assetKey " ; assetKey ; " is not in cachefs"
missingAssets[assetKey] = m.json.files[assetKey]
end if
end for
Expand Down Expand Up @@ -53,7 +53,7 @@ namespace mc
end if
ba = createObject("roByteArray")
ba.fromBase64String(assetData[assetKey])
? "writing to : " + "cachefs:/" + filename
' ? "writing to : " + "cachefs:/" + filename
ba.writeFile("cachefs:/" + filename)
end for
end function
Expand Down
11 changes: 6 additions & 5 deletions src/source/core/ComponentPool.bs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace mc
for i = 0 to number
component = createObject("roSGNode", componentType)
if component <> invalid
component.id = str(pool.numberOfComponentsInPool).trim()
component.id = rnd(2147483647).toStr()
component.isPrebaked = true
pool.numberOfComponentsInPool++
pool.freeComponentsById[component.id] = component
Expand All @@ -77,6 +77,7 @@ namespace mc
pool = m.getComponentPool(componentType)

if pool.freeComponentsById.count() = 0
' ? ">>>> RAN OUT OF " ; componentType
m.log.warn("ran out of components getting type :", componentType)

if m.isCreateMoreEnabled
Expand Down Expand Up @@ -121,12 +122,12 @@ namespace mc

function releaseComponent(component as mc.types.node)
if component <> invalid
' ? "releasing component "; component.id
pool = m.getComponentPool(component.subType())
pool.usedComponentsById.delete(component.id)
' ? ">>>>releasing component "; mc.dv(component)
if component.getParent() <> invalid
component.getParent().removeChild(component)
end if
pool = m.getComponentPool(component.subType())
pool.usedComponentsById.delete(component.id)
pool.freeComponentsById[component.id] = component
m.numberOfComponentsInUse--
end if
Expand All @@ -146,7 +147,7 @@ namespace mc
pool = m.getComponentPool(componentType)
component = createObject("roSGNode", componentType)
if component <> invalid
component.id = str(pool.numberOfComponentsInPool).trim()
component.id = rnd(2147483647).toStr()
pool.allComponents.push(component)
pool.freeComponentsById[component.id] = component
else
Expand Down
2 changes: 1 addition & 1 deletion src/source/core/Map.bs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace mc.collections
end function

private function onDebugChange(value as dynamic)
? "dumping contents"
' ? "dumping contents"
m.top.__contents = m.data
end function
end class
Expand Down
4 changes: 2 additions & 2 deletions src/source/core/Tasks.bs
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ namespace mc.tasks
context.node = node

if node._oid = invalid
node.addFields({ "_oid": StrI(rnd(2147483647)).trim() })
node.addFields({ "_oid": rnd(2147483647).toStr() })
end if
if scope._oid = invalid
mc.setOrAddNodeField(scope, "_oid", StrI(rnd(2147483647)).trim())
mc.setOrAddNodeField(scope, "_oid", rnd(2147483647).toStr())
end if

context.key = mc.tasks._getContextKey(node, fieldName, callback, targetField, context.instance)
Expand Down
2 changes: 1 addition & 1 deletion src/source/core/Utils.bs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ namespace mc

if node <> invalid
if id = invalid
id = StrI(rnd(2147483647)).trim()
id = rnd(2147483647).toStr()
end if

node.id = id
Expand Down

0 comments on commit 6283bc3

Please sign in to comment.