Comments (5)
Hmmm... That does sound strange. I'll look into it.
from binser.
I'm not sure exactly what the problem is, but nil keys should never be serialized. Looking at your code, (which is pretty funny, btw), there seems to be some redundant serialization methods.
Anyways, here is a current snippet, (line 312)
gonker._serialize = function(meme)
local bink = {}
for k, v in pairs(meme) do
bink[k] = binser.serialize(v)
end
return binser.serialize(bink)
end
gonker._deserialize = function(meme)
local bink = binser.deserialize(meme)[1]
for k, v in pairs(bink) do
bink[k] = binser.deserialize(v)[1]
end
print_r(bink)
return bink
end
binser should be able to serialize plain tables, no problem. This probably could be all removed at no performance cost. Internally, binser does pretty much everything you did in these two methods.
As for the quad issue, I'm having trouble replicating your problem. What system are you on? It shouldn't matter, of course, but there are always tiny strange differences between systems. Iwas able to remove the edit you added to binser.lua with no problems relating to quads in your game.
I did find some other bugs, though such as you trying to register 'objectStatic' more than once. (Happens when I mash WASD a lot.) In most cases, you don't need to register objects more than once. If so, try wrapping binser.register in a pcall.
Let me know If your problem persists. If so, It would be nice if you could isolate the problem in an SSCCE (Short, Self Contained, Correct Example). It is quite difficult to isolate the problem from an entire love project that puts everything in main. :)
from binser.
In the original love I posted I was able to serialize (f5), modify the data (f6), but when I loaded (f7) after saving and loading a lot it broke. So I was able to restore the quad, but somehow sometimes loading the saved data was failing.
Sorry for the code, screws come loose when I spend 4 or something hours on a feature and it doesn't work.
If I don't register objects['static']
at all and undo my modifications to binser.lua then it immediately errors out after hitting f5:
Error: libs/binser/binser.lua:309: table index is nil
stack traceback:
libs/binser/binser.lua:309: in function 'deserialize_value'
libs/binser/binser.lua:308: in function 'deserialize_value'
libs/binser/binser.lua:321: in function 'deserialize_value'
libs/binser/binser.lua:302: in function 'deserialize_value'
libs/binser/binser.lua:386: in function 'deserialize'
main.lua:1301: in function <main.lua:1194>
main.lua:1040: in function <main.lua:1017>
[C]: in function 'xpcall'
If I leave it unregistered and apply my patch, then hitting f5 and then f7 errors with:
Error: libs/binser/binser.lua:431: table index is nil
stack traceback:
libs/binser/binser.lua:431: in function <libs/binser/binser.lua:428>
libs/binser/binser.lua:327: in function 'deserialize_value'
libs/binser/binser.lua:302: in function 'deserialize_value'
libs/binser/binser.lua:390: in function 'deserialize'
main.lua:1301: in function <main.lua:1194>
main.lua:1040: in function <main.lua:1017>
[C]: in function 'xpcall'
If I patch line 431 with:
local k = select(i, ...)
if k~=nil then
ret[k] = select(i + 1, ...)
end
Then I can get as far as:
Error: objs/static.lua:28: bad argument #1 to 'setColor' (number expected, got nil)
stack traceback:
[C]: in function 'setColor'
objs/static.lua:28: in function 'draw'
main.lua:934: in function 'draw'
main.lua:1052: in function <main.lua:1017>
[C]: in function 'xpcall'
Which appears to mean that the table color
isn't getting serialized into the object, despite being a registered instance of a middleclass class.
I'm taking this to mean that the default serializer doesn't handle nested tables. (Hence my redundant and flustered code.)
The quad code actually handles fine and doesn't have any issues, as far as I can tell it only has an issue with nested tables or something with the quad code is stunting its ability to handle nested tables.
Keep in mind that middleclass changed its __instanceDict between APIs so I don't know if this code is compliant with the middleclass 4.x API.
from binser.
I think I got it! There was a bug where functions were not keeping track of being seen when deserializing, so if there were multiple references to the same function, later references would fail, and return nil. This is why your table keys were nil. Try pulling the most recent version of binser and see if that fixes your problem.
Thank you for helping me find that actually very serious bug!
from binser.
Whoa! That worked like a charm. Thanks a ton man, I thought I was losing my mind over here. :)
from binser.
Related Issues (19)
- Serialized types get mixed HOT 3
- Deserialize return value HOT 3
- deserialize Registerd Class example ? HOT 2
- Library not working in 5.3 version due to deprecated math functions HOT 7
- Update deserialize/N doc HOT 1
- Having some trouble deserializing a third-party class
- Priting a serialized table gives unicode symbols HOT 1
- fairly simple issue HOT 1
- Table duplicated HOT 18
- Add a version field HOT 1
- Error on malformed input when looking ahead HOT 10
- resource example HOT 2
- Lua 5.3 supported ? HOT 4
- readFile and writeFile do not return an error
- deserialing not have instruction HOT 1
- Is binser safe? HOT 1
- binser.unregister does not work. HOT 1
- float number bug in Lua5.4 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from binser.