LookingForAPath wrote:We all know that when you save information a pointer points to in a file, it does not mean that the pointer will point to that exact data, when it is reloaded, anymore, because it doesn't know to point to it. Although this is a pain, it is something that cannot be avoided, because although what the pointer points to IS data, the pointer itself isn't data.

class Item
{
Player* Owner;
int ItemCost;
public:
Item();
Item(Player* TheOwner);
~Item();
};
LookingForAPath wrote:When you try to save this "item" and reload it, the item won't know what "player" owned it when it is reloaded.

<entity name="Level2" id="1" groupid="0">
<components>
<component type="1" family="1">
<properties>
<property name="mesh_file" type="6" value="./media/mymap.obj" />
<property name="position" type="8" x="0" y="0" z="0" />
<property name="rotation" type="8" x="0" y="0" z="0" />
<property name="scale" type="8" x="1" y="1" z="1" />
<property name="use_lights" type="5" value="0" />
</properties>
</component>
</components>
</entity>
<entity name="Level3" id="2" groupid="123">
<components>
<component type="1" family="1">
<properties>
<property name="mesh_file" type="6" value="./media/mymap.obj" />
<property name="position" type="8" x="0" y="0" z="230" />
<property name="rotation" type="8" x="0" y="0" z="0" />
<property name="scale" type="8" x="1" y="1" z="1" />
<property name="use_lights" type="5" value="0" />
</properties>
</component>
</components>
</entity>
<entity name="Level3" id="3" groupid="123">
<components>
<component type="1" family="1">
<properties>
<property name="mesh_file" type="6" value="./media/mymap.obj" />
<property name="position" type="8" x="0" y="0" z="460" />
<property name="rotation" type="8" x="0" y="0" z="0" />
<property name="scale" type="8" x="1" y="1" z="1" />
<property name="use_lights" type="5" value="0" />
</properties>
</component>
</components>
</entity>
LookingForAPath wrote:True, but saves cannot always be that small. Especially when it comes to worlds, you have to save where all the props have moved to and reload them, or lets say
you have a first person shooter and the player is surrounded by 10 bad guys and 20 more are looking for him. You'd have to save all their positions, the mesh and texture they use(Not save the ACTUAL mesh or texture, but like a link to them. So when they are reloaded the know which ones to use.) and that they are "currently searching for the player".
So as to what you "need to save", the list can get quite large, even in "somewhat" small type games.
LookingForAPath wrote:@serengeor: That would actually be faster, I think I'm going to go about this scheme if I can. Just not using XML.
It still kinda looks like the ID, thing I was talking about though, in a way.
Could you give me a example of how you would save parented objects? (then I can determine for sure..sorry if that sounds stupid, but sometimes
I have to look at it from the basis, I am thinking).

Player:setLife(30)
Player:setPosition(4,5);
Level:setProgress(0.4)

teto wrote:You forgot another solution: Resorting to scripts. If you use Lua for example, you might juste create a file :
- cpp Code: Select all
Player:setLife(30)
Player:setPosition(4,5);
Level:setProgress(0.4)

Users browsing this forum: No registered users and 1 guest