{"id":521,"date":"2011-07-12T09:53:08","date_gmt":"2011-07-12T09:53:08","guid":{"rendered":"http:\/\/www.qcfdesign.com\/?p=521"},"modified":"2011-07-12T10:56:55","modified_gmt":"2011-07-12T10:56:55","slug":"saving-and-loading","status":"publish","type":"post","link":"http:\/\/www.qcfdesign.com\/?p=521","title":{"rendered":"Saving and Loading"},"content":{"rendered":"<p>As any game coder will tell you, saving and loading are horrible things. They make your life miserable, and people only notice them if they fail spectacularly. So I&#8217;ve snuck onto the blog to get some appreciation for my toil, and also give you a little &#8220;behind the scenes&#8221; idea of what&#8217;s going on when DD saves\/loads.<!--more--><\/p>\n<p>When we were building the initial versions of the full, we got an XML serializer, made things we wanted to save serializable (this means you can convert them into text to store in a file), and simply created a bunch of lists.<\/p>\n<p>Now, this seems like it would work out great, but as it turns out, when making changes to the actual game design, the system would fall on its face more often than not. The reason behind this mostly boils down to changes in the objects that are being saved, and not being able to load them because either they no longer exist or they have fundamentally different internal structures. This of course prompts the game to give you a &#8220;fresh&#8221; save game, erasing all your hard work &#8230; not ideal.<\/p>\n<p>So we went back to the drawing board, and came up with this:<\/p>\n<p>To begin with, you need to understand that DD is a system of Events and Handlers. Handlers subscribe to Events, and Events are fired when different things happen in the game (you click, an enemy attacks you, you upgrade a building, etc). Certain events represent decisions that the player has made about the structure of the Kingdom. Events like: Upgrading a building, selecting a preparation, finishing a quest, etc.<\/p>\n<p>We now round up these events as they happen, and if they succeed, we add them to a big list of events. Because the information in Events is the bare minimum needed to re-create the player choice, they&#8217;re the perfect candidate for saving. Their internal structure is unlikely to change, and the structure of the quest tree\/building hierarchy can change without the events being affected.<\/p>\n<p>What this means for you is that there&#8217;s a good chance your progress (even in the beta) will never get reset &#8230; and for us, that&#8217;s worth it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As any game coder will tell you, saving and loading are horrible things. They make your life miserable, and people only notice them if they fail spectacularly. So I&#8217;ve snuck onto the blog to get some appreciation for my toil, and also give you a little &#8220;behind the scenes&#8221; idea of what&#8217;s going on when [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[19,18],"_links":{"self":[{"href":"http:\/\/www.qcfdesign.com\/index.php?rest_route=\/wp\/v2\/posts\/521"}],"collection":[{"href":"http:\/\/www.qcfdesign.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.qcfdesign.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.qcfdesign.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.qcfdesign.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=521"}],"version-history":[{"count":0,"href":"http:\/\/www.qcfdesign.com\/index.php?rest_route=\/wp\/v2\/posts\/521\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.qcfdesign.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.qcfdesign.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=521"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.qcfdesign.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}