About Store Forum Documentation Contact



Post Reply 
How to save Memc full of pointers?
Author Message
molokki Offline
Member

Post: #1
How to save Memc full of pointers?
I have Memc full of pointers to characters but is it possible to save it? Can I save pointers? I tried to use references but if I understood it right they can only be used with world objects.
I have it like this:
Code:
struct Party
{
    Memc<Chr*>    partyMembers;    
    Chr*        partyLeader;    

   void save(File &f);
   Bool load(File &f);
};
09-10-2012 09:49 PM
Find all posts by this user Quote this message in a reply
Ogniok Offline
Member

Post: #2
RE: How to save Memc full of pointers?
Look how save function works in Memc header.

It calls for function "save()" in every element. So if you want to save this container you can't use pointers. Better user references, then it will work.

Your code should look like:
Code:
struct Party
{
    Memc<Reference<Chr>> partyMembers;    
    Chr* partyLeader;    

   void save(File &f);
   Bool load(File &f);
};
(This post was last modified: 09-10-2012 09:58 PM by Ogniok.)
09-10-2012 09:58 PM
Find all posts by this user Quote this message in a reply
molokki Offline
Member

Post: #3
RE: How to save Memc full of pointers?
Great, thanks grin
09-11-2012 07:56 AM
Find all posts by this user Quote this message in a reply
molokki Offline
Member

Post: #4
RE: How to save Memc full of pointers?
Now I have a new problem smile
Every character should have reference to his party. How can I add reference to that Party if my Party is not Game::obj?
09-11-2012 09:02 AM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #5
RE: How to save Memc full of pointers?
Maybe add Party member to character class?
09-11-2012 09:13 AM
Visit this user's website Find all posts by this user Quote this message in a reply
molokki Offline
Member

Post: #6
RE: How to save Memc full of pointers?
I'm not sure what do you mean smile
Could you specify that a little bit?
09-11-2012 05:35 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #7
RE: How to save Memc full of pointers?
Code:
struct Party
{
    Memc<Reference<Chr>> partyMembers;    
    Chr* partyLeader;    

   void save(File &f);
   Bool load(File &f);
};
struct Chr:Game::Chr
{
Party party;
}

I mean something like that. I hope that this is what you want to get?
(This post was last modified: 09-11-2012 09:15 PM by Harry.)
09-11-2012 09:14 PM
Visit this user's website Find all posts by this user Quote this message in a reply
molokki Offline
Member

Post: #8
RE: How to save Memc full of pointers?
Ok, thank you grin
09-11-2012 10:03 PM
Find all posts by this user Quote this message in a reply
Post Reply