Jump to content


Photo

Player Class


  • This topic is locked This topic is locked
2 replies to this topic

#1 Beetle

Beetle

    Programming Department

  • Xenocide Inactive
  • 350 posts

Posted 17 April 2005 - 02:04 PM

Hi
I think that we should talking about player class. Place where we put all player stuff, money, bases, craft, etc...

Waiting from comments from senior :) (Red Knight, Rincewind :Poke: )

Greetings,
Beetle
Posted Image

#2 rincewind

rincewind

    Programming Department

  • Xenocide Programming Department
  • 541 posts

Posted 17 April 2005 - 10:05 PM

Hi
  I think that we should talking about player class.  Place where we put all player stuff, money, bases, craft, etc...

Waiting from comments from senior :) (Red Knight, Rincewind  :Poke: )

Greetings,
Beetle

<{POST_SNAPBACK}>

Thats pretty much what I've been working on yesterday. Still have some problems with the serialization (serialization and shared_ptr to base classes still pose some problems) but I will post a working draft very soon.
Basicly, it contains all the data that is dynamic to the game. Current Planetview-Simulation (Alien-AI including current Alien-missions), players bases (which I extended with a geoposition and a name, btw).
Also included are save and load methods.

So just a little more patience (as I'm on my way to work now). :Coffee:

Rincewind

P.S: On another thing: while including HumanBase in there, I noticed your interface to iterate over the facilities, you might want to take a look at the file iterator.h in xenocommon. It provides a nice little wrapper for this functionality, including helper functions for binding it to Lua.
Posted Image

I love boost!!! The next best thing since the invention of C++.

#3 rincewind

rincewind

    Programming Department

  • Xenocide Programming Department
  • 541 posts

Posted 19 April 2005 - 07:21 AM

Ok, preliminary draft in SVN now :Deal: , please comment (but be gentle with me) :-)

class GameState : public TSingleton<GameState>
{
private:
	TScopedPtr<Xenocide::Common::Simulation::Simulation> simulationSingleton;
	typedef TList< TSharedPtr<HumanBase> > HumanBaseList;
	typedef Iterator<HumanBaseList::iterator> HumanBaseListIterator;
	HumanBaseList humanBases;

public:
	/** 
  \brief constructs a new and empty GameState (effectively "New Game")
	*/
	GameState();
	~GameState();
	
	/**
  \brief loads the GameState from the indicated file into this GameState
	*/
	void loadGame(const ::String & fileName);

	/**
  \brief saves the current GameState into the indicated file
	*/
	void saveGame(const ::String & fileName);

	/**
  \brief return an iterator over all the human bases in the current gamestate

	*/
	HumanBaseListIterator getHumanBases();
};

Serialization is not working right now, but hopefully I'll get it fixed soon.

Rincewind
Posted Image

I love boost!!! The next best thing since the invention of C++.