<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: The trouble with storing binary data structures</title>
	<atom:link href="http://blog.linuxgamepublishing.com/2009/01/29/the-trouble-with-storing-binary-data-structures/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.linuxgamepublishing.com/2009/01/29/the-trouble-with-storing-binary-data-structures/</link>
	<description>Commercial gaming for Linux</description>
	<lastBuildDate>Thu, 26 Aug 2010 09:00:14 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Mike Phillips</title>
		<link>http://blog.linuxgamepublishing.com/2009/01/29/the-trouble-with-storing-binary-data-structures/comment-page-1/#comment-21</link>
		<dc:creator>Mike Phillips</dc:creator>
		<pubDate>Thu, 29 Jan 2009 19:13:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.linuxgamepublishing.com/?p=20#comment-21</guid>
		<description>Actually, that problem was the very first major problem in the Majesty port &quot;Way Back When&quot; -- a packing/alignment issue was causing a crash because the data was being used as an index.  (...and I could tell you stories about some similar fun at Loki :-) )

Glad to see the torch was picked up and the binary will be updated :-)</description>
		<content:encoded><![CDATA[<p>Actually, that problem was the very first major problem in the Majesty port &#8220;Way Back When&#8221; &#8212; a packing/alignment issue was causing a crash because the data was being used as an index.  (&#8230;and I could tell you stories about some similar fun at Loki :-) )</p>
<p>Glad to see the torch was picked up and the binary will be updated :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harald Nikolisin</title>
		<link>http://blog.linuxgamepublishing.com/2009/01/29/the-trouble-with-storing-binary-data-structures/comment-page-1/#comment-20</link>
		<dc:creator>Harald Nikolisin</dc:creator>
		<pubDate>Thu, 29 Jan 2009 18:44:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.linuxgamepublishing.com/?p=20#comment-20</guid>
		<description>I do not begrudge the LGP folks for porting the quick&amp;dirty stuff, which rules the windows world.

@doomwarriorx: I don&#039;t think that there much space to change things without breaking compatibility with existing windows version (a saved game on linux should be playable on windows)..
@michael: and a mac saved game on linux ;-)

besides this is very unlikely that a commercial game will have a more exotic plattform than Linux/x86</description>
		<content:encoded><![CDATA[<p>I do not begrudge the LGP folks for porting the quick&amp;dirty stuff, which rules the windows world.</p>
<p>@doomwarriorx: I don&#8217;t think that there much space to change things without breaking compatibility with existing windows version (a saved game on linux should be playable on windows)..<br />
@michael: and a mac saved game on linux ;-)</p>
<p>besides this is very unlikely that a commercial game will have a more exotic plattform than Linux/x86</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: michael</title>
		<link>http://blog.linuxgamepublishing.com/2009/01/29/the-trouble-with-storing-binary-data-structures/comment-page-1/#comment-19</link>
		<dc:creator>michael</dc:creator>
		<pubDate>Thu, 29 Jan 2009 17:34:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.linuxgamepublishing.com/?p=20#comment-19</guid>
		<description>We do know this issue, as we said at the start, this is something we solved ages ago, but we thought it would make an interesting read for people. we bumped into it again yesterday when we had some bad data reads, and that turned out to be the issue.

I could&#039;t agree more about the idea of saving data as a raw dump of a struct, it is a terrible idea if you ever want portability, but when something has been written without portability originally, and you have to then port it, this is the kind of thing you have to live with.

The solution offered is the only one that makes sense, in our case, as if packed data has been saved into a datafile which cannot be changed, well, the only other option would be to memcpy into each element of the array one at a time. This is fine, but slower, and the example was for use in porting where you really do not want to change the original code too much. And if, for example, you are reading in a data structure with 300 elements (they exist) you really do not want to do sit there for 3 hours writing 300 memcpy instructions! If you are copying to an architecture that does not handle packed data, then you are going to have to do that, but the idea of the article was to illustrate the problem, and how we solved it for the architecture we are porting to, rather than to be all things to all people.</description>
		<content:encoded><![CDATA[<p>We do know this issue, as we said at the start, this is something we solved ages ago, but we thought it would make an interesting read for people. we bumped into it again yesterday when we had some bad data reads, and that turned out to be the issue.</p>
<p>I could&#8217;t agree more about the idea of saving data as a raw dump of a struct, it is a terrible idea if you ever want portability, but when something has been written without portability originally, and you have to then port it, this is the kind of thing you have to live with.</p>
<p>The solution offered is the only one that makes sense, in our case, as if packed data has been saved into a datafile which cannot be changed, well, the only other option would be to memcpy into each element of the array one at a time. This is fine, but slower, and the example was for use in porting where you really do not want to change the original code too much. And if, for example, you are reading in a data structure with 300 elements (they exist) you really do not want to do sit there for 3 hours writing 300 memcpy instructions! If you are copying to an architecture that does not handle packed data, then you are going to have to do that, but the idea of the article was to illustrate the problem, and how we solved it for the architecture we are porting to, rather than to be all things to all people.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: doomwarriorx</title>
		<link>http://blog.linuxgamepublishing.com/2009/01/29/the-trouble-with-storing-binary-data-structures/comment-page-1/#comment-18</link>
		<dc:creator>doomwarriorx</dc:creator>
		<pubDate>Thu, 29 Jan 2009 17:24:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.linuxgamepublishing.com/?p=20#comment-18</guid>
		<description>hopefully this sounds not to harsh. How could you port several games without not knowing this issue? It is a common problem for e.g. opensource games which were closed source before. 
Your solution isn&#039;t good at all, because there are several cpu architectures which doesn&#039;t support &quot;packing&quot; of data. It&#039;s more a works for me, hopefully nobody other have to port my stuff to some exotic platform. So for platform independent communication it is a bad practice to memset into a structure and vice versa.</description>
		<content:encoded><![CDATA[<p>hopefully this sounds not to harsh. How could you port several games without not knowing this issue? It is a common problem for e.g. opensource games which were closed source before.<br />
Your solution isn&#8217;t good at all, because there are several cpu architectures which doesn&#8217;t support &#8220;packing&#8221; of data. It&#8217;s more a works for me, hopefully nobody other have to port my stuff to some exotic platform. So for platform independent communication it is a bad practice to memset into a structure and vice versa.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harald Nikolisin</title>
		<link>http://blog.linuxgamepublishing.com/2009/01/29/the-trouble-with-storing-binary-data-structures/comment-page-1/#comment-12</link>
		<dc:creator>Harald Nikolisin</dc:creator>
		<pubDate>Thu, 29 Jan 2009 13:42:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.linuxgamepublishing.com/?p=20#comment-12</guid>
		<description>good article, I&#039;m going to appreciate this blog, and now another use-case

I have X2-The Threat on Linux (your product) and on Mac OS X (PPC - ported by VP).
If I save a game on Linux, I can load it into the Mac OS X game and proceed.
If I save the game on Mac OS X and load it into the Linux Version, X2 crashes. Can you provide a bug fix? to improve the alignmen ;-))
I can send you a saved gamed from Mac OS X......</description>
		<content:encoded><![CDATA[<p>good article, I&#8217;m going to appreciate this blog, and now another use-case</p>
<p>I have X2-The Threat on Linux (your product) and on Mac OS X (PPC &#8211; ported by VP).<br />
If I save a game on Linux, I can load it into the Mac OS X game and proceed.<br />
If I save the game on Mac OS X and load it into the Linux Version, X2 crashes. Can you provide a bug fix? to improve the alignmen ;-))<br />
I can send you a saved gamed from Mac OS X&#8230;&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: michael</title>
		<link>http://blog.linuxgamepublishing.com/2009/01/29/the-trouble-with-storing-binary-data-structures/comment-page-1/#comment-11</link>
		<dc:creator>michael</dc:creator>
		<pubDate>Thu, 29 Jan 2009 13:40:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.linuxgamepublishing.com/?p=20#comment-11</guid>
		<description>Yep, it means we have a new majesty patch on the way, its been on the way for a while, but its closer now.</description>
		<content:encoded><![CDATA[<p>Yep, it means we have a new majesty patch on the way, its been on the way for a while, but its closer now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: basement cat</title>
		<link>http://blog.linuxgamepublishing.com/2009/01/29/the-trouble-with-storing-binary-data-structures/comment-page-1/#comment-9</link>
		<dc:creator>basement cat</dc:creator>
		<pubDate>Thu, 29 Jan 2009 11:42:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.linuxgamepublishing.com/?p=20#comment-9</guid>
		<description>I believe the best way to handle this is by writing an abstraction layer that takes care of reading and writing file data, and does so in a way which is consistent across different platforms.

This library seems to be a pretty good example of how the issue can be solved: http://www.leonerd.org.uk/code/libpack/</description>
		<content:encoded><![CDATA[<p>I believe the best way to handle this is by writing an abstraction layer that takes care of reading and writing file data, and does so in a way which is consistent across different platforms.</p>
<p>This library seems to be a pretty good example of how the issue can be solved: <a href="http://www.leonerd.org.uk/code/libpack/" rel="nofollow">http://www.leonerd.org.uk/code/libpack/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://blog.linuxgamepublishing.com/2009/01/29/the-trouble-with-storing-binary-data-structures/comment-page-1/#comment-8</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Thu, 29 Jan 2009 11:18:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.linuxgamepublishing.com/?p=20#comment-8</guid>
		<description>Hi Michael,

That&#039;s very interesting. It means also we will get a new patch for Majesty ? I love this game, I continue to play it from time to time.

I hope to read more programming articles in your blog.

Regards,
Eric</description>
		<content:encoded><![CDATA[<p>Hi Michael,</p>
<p>That&#8217;s very interesting. It means also we will get a new patch for Majesty ? I love this game, I continue to play it from time to time.</p>
<p>I hope to read more programming articles in your blog.</p>
<p>Regards,<br />
Eric</p>
]]></content:encoded>
	</item>
</channel>
</rss>
