~proyvind/doonlunacy/od2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#ifndef	__OD2SRC_OD2_H__
#define	__OD2SRC_OD2_H__	1

/* OD2 - Dune II Clone
 *  
 * Copyright (C) 2009 Robert Crossfield		<robert.crossfield@strobs.com>
 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *  
 * 
 * $Id$
 * 
 */

#include "stdafx.h"

class cScenario;
class cScreen;
class cHouse;
class cUnit;
class cStructure;
class cTeam;
class cObject;
class cMapCellAnimSingle;

class cOD2 : public cEngine {
private:
	uint32_t					 _language;
	eHouse					 _missionHouse;
	uint32_t					 _missionNumber, _missionNumberPrevious;

	bool						 _gameImmediateBuild, _gameFreeBuild;
	word						 _gameSpeed;

	map< eHouse, cHouse* >		 _houses;											// Game houses	
	map< uint32_t, cUnit* >	  	 _units;											// Unit Index and Unit Pointer
	map< uint32_t, cStructure*>	 _structures;										// Struct Index and Struct Pointer
	
	map< uint32_t, cTeam* >		 _teams;											// Teams

	map< uint32_t, cMapCellAnimSingle*>	_mapCellAnimSingles;
	uint32_t								_mapCellAnimTimer;

	cScreen						*_screen;
	cScenario					*_scenario;											// Current Mission
	cResources					*_resources;
	
	

	void					 houseCycle();									// Do house events
	void					 houseReset();									// Prep a house for mission start
	

public:
					 cOD2( string pDataPath );
					~cOD2();

	bool			 execute( eHouse pHouse );								// Main execution loop

	void			 animSingleCellCycle();

	cMapCellAnimSingle*							 mapCellAnimGet( uint32_t pMapIndex );
	map< uint32_t, cMapCellAnimSingle*>			*mapCellAnimGet();

	cHouse			*houseGet( eHouse pHouse );
	inline void		 houseSet( eHouse pHouse )	{ _missionHouse = pHouse; }
	inline cHouse	*houseHumanGet()			{ return houseGet( missionHouseGet() ); }

	void			 houseMapPrepare();
	void			 houseChange( cObject *pObject, cHouse *pHouse );
	
	void			 missionBriefing( );									// Start mission briefing
	void			 missionStart(	eHouse pHouse, uint32_t pNumber );		// Start new mission
	
	inline void		 gameFreeBuild( bool pVal ) { _gameFreeBuild = pVal; }
	inline bool		 gameFreeBuild()			{ return _gameFreeBuild; }

	inline void		 gameImmediateBuild( bool pVal) { _gameImmediateBuild = pVal; }
	inline bool		 gameImmediateBuild()			{ return _gameImmediateBuild; }
	
	virtual void	 screenScaleSet( word pValue );
	word			 speedCalc( word speed, word arg_2, word arg_4, word arg_6 );

	//  Unit handling functions

	uint32_t			 unitIDFreeGet( uint32_t pStartID = 0);
	uint32_t			 unitAdd( cUnit *pUnit );
	void			 unitRemove( cUnit *pUnit );
	cUnit			*unitGet( uint32_t pIndex );
	

	//  Structure handling functions
	uint32_t			 structureIDFreeGet( uint32_t pStartID = 0);
	uint32_t			 structureAdd( cStructure *pStructure );
	void			 structureRemove( cStructure *pStructure );
	cStructure		*structureGet( uint32_t pIndex );

	uint32_t			 teamIDFreeGet( uint32_t pStartID = 0);
	uint32_t			 teamAdd( cTeam *pTeam );
	void			 teamRemove( cTeam *pTeam );
	
	inline map< eHouse, cHouse* >		*housesGet()	 { return &_houses; }				// Get a ptr to the houses map
	inline map< uint32_t, cUnit* >		*unitsGet()		 { return &_units; }
	inline map< uint32_t, cStructure*>	*structuresGet() { return &_structures; }
	inline map< uint32_t, cTeam* >		*teamsGet()		 { return &_teams; }

	inline	uint32_t			 languageGet()		{ return _language; }				// Current language

	void					 mapCellAnimAdd( word pMapIndex, cMapCellAnimSingle *pMapCellAnimSingle );
	void					 mapCellAnimRemove( word pMapIndex );

	inline void				 missionHouseSet( eHouse pVal )  { _missionHouse = pVal; }
	inline eHouse			 missionHouseGet()  { return _missionHouse; }			// Get the human players house
	inline uint32_t			 missionNumberGet() { return _missionNumber; }			// Get current mission number
	inline uint32_t			 missionNumberPreviousGet() { return _missionNumberPrevious; }

	inline cScenario		*scenarioGet()		{ return _scenario; }				// Get the scenario
	inline cScreen			*screenGet()		{ return _screen; }					// Get the screen
	inline cResources		*resourcesGet()		{ return _resources; }				// Get the resources


};

#endif // __OD2SRC_OD2_H__