Subversion Repositories spk

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 cycrow 1
// X3Data.h: interface for the CX3Data class.
2
//
3
//////////////////////////////////////////////////////////////////////
4
 
5
#if !defined(AFX_X3DATA_H__491F0DBE_1AE5_4956_B262_F2D1B0D0E9FF__INCLUDED_)
6
#define AFX_X3DATA_H__491F0DBE_1AE5_4956_B262_F2D1B0D0E9FF__INCLUDED_
7
 
8
#include <CyString.h>
9
#include <StringList.h>
10
 
11
#if _MSC_VER > 1000
12
#pragma once
13
#endif // _MSC_VER > 1000
14
 
15
#define DATA_LOCKED  m_bLocked = true;
16
#define DATA_UNLOCKED m_bLocked = false;
17
 
18
enum Rep { REP_TRADE, REP_FIGHT, REP_ARGON, REP_BORON, REP_SPLIT, REP_PARANID, REP_TELADI, REP_GONER, REP_TERRAN, REP_ATF, REP_PIRATES, REP_YAKI };
19
enum ShipClass { CLASS_M1, CLASS_M2, CLASS_M3, CLASS_M4, CLASS_M5, CLASS_M6, CLASS_M7, CLASS_M8, CLASS_TP, CLASS_TS, CLASS_TM, CLASS_TL };
20
#define MAXRACEREP		12
21
#define MAXSHIPCLASS	12
22
 
23
typedef struct SShip {
24
	void Reset() { sName = sID = sClass = sEnv = ""; iSpeed = 0; }
25
	CyString sName;
26
	CyString sID;
27
	CyString sClass;
28
	CyString sEnv;
29
	int		 iSpeed;
30
} SShip;
31
 
32
typedef struct STarget : public SShip {
33
	void Reset() { SShip::Reset(); iShields = iHull = iDist = 0; sRelation = ""; }
34
	int			iShields;
35
	int			iHull;
36
	CyString	sRelation;
37
	int			iDist;
38
} STarget;
39
 
40
typedef struct SRaceRep {
41
	void Reset() { sRace = ""; iRep = 0; iRepPct = 0; sRank = ""; bIncludeRace = false; }
42
	CyString	sRace;
43
	CyString	sRank;
44
	int			iRep;
45
	int			iRepPct;
46
	bool		bIncludeRace;
47
} SRaceRep;
48
 
49
class CX3Data  
50
{
51
public:
52
	bool ReadFile ( CyString, CyString );
53
 
54
	// get strings
55
	bool	IsLocked			() { return m_bLocked; }
56
	SShip	 &GetShipData		() { return m_shipData; }
57
	STarget  &GetTargetData		() { return m_targetData; }
58
	CyString &GetPilot		() { return m_sPilot; }
59
	CyString &GetShipID			() { return m_shipData.sID; }
60
	int		  GetShipsNum		() { return m_iShips; }
61
	int		  GetStations		() { return m_iStations; }
62
	CyString &GetCredits	    () { return m_sAccount; }
63
	CyString &GetGameTime		() { return m_sGametime; }
64
	CyString &GetShipName		() { return m_shipData.sName; }
65
	CyString &GetShipEnv		() { return m_shipData.sEnv; }
66
	int GetShipClass (int s_class) { return m_iShipClass[s_class]; }
67
	SRaceRep &GetRaceRep	(int race) { return m_Rep[race]; }
68
	bool	 HasTarget		() { return (m_targetData.sName.Empty()) ? false : true; }
69
	CyString  GetTarget		() { return (!HasTarget()) ? "No Target" : m_targetData.sName; }
70
	CyString GetTargetRelation() { return m_targetData.sRelation; }
71
	CyString GetTargetDistanceStr()
72
	{
73
		int dist = m_targetData.iDist;
74
		if ( dist > 900 )
75
		{
76
			float fDist = (float)dist / 1000.0f;
77
			return CyString::CreateFromFloat(fDist, 1) + "Km";
78
		}
79
		return CyString::Number(dist) + "m";
80
	}
81
	int     GetHull			() { return m_iHull; }
82
	int     GetShields      () { return m_iShields; }
83
	int     GetWeaponEnergy () { return m_iLaserProgress; }
84
	int		GetMySpeed		() { return m_shipData.iSpeed; }
85
	int		GetTargetSpeed  () { return m_targetData.iSpeed; }
86
	int		GetTargetDistance  () { return m_targetData.iDist; }
87
	int		GetTargetHull	() { return m_targetData.iHull; }
88
	int		GetTargetShield	() { return m_targetData.iShields;  }
89
	int		GetEnemies		() { return m_iEnemies; }
90
	int		GetEnemies2		() { return m_iEnemies2; }
91
	int		GetMissiles		() { return m_iMissiles; }
92
	int		GetInsurance	() { return m_iInsurance; }
93
	int		GetVersion		() { return m_iVersion; }
94
	CyString	GetMyShip		() { return (m_shipData.sName.Empty()) ? "No Ship" : (m_shipData.sName + " (" + m_shipData.sID + ") [" + m_shipData.sClass + "] / " + m_shipData.sEnv); }
95
	CyString	GetMyTarget		() { return (!HasTarget()) ? "No Target" : (m_targetData.sName + " (" + m_targetData.sID + ") [" + m_targetData.sClass + "]"); }
96
 
97
	CyStringList *GetCustomFiles () { return &m_lCustomFile; }
98
	CyStringList *GetCustomList () { return &m_lCustomList; }
99
 
100
	// set strings
101
	void Reset ();
102
	void SetGameName(CyString &name) { m_sGameName = name; }
103
	void SetGameDirectory(CyString &name) { m_sGameDir = name; }
104
 
105
	CyString &GetGameName() { return m_sGameName; }
106
	CyString &GetProgDir()  { return m_sProgDir; }
107
	CyString &GetGameDirectory()  { return m_sGameDir; }
108
 
109
	CX3Data(CyString &progDir);
110
	virtual ~CX3Data();
111
 
112
	void SetRaceRep(int rep, CyString race, CyString &rest, bool old = false);
113
 
114
private:
115
	CyString GetRepPercentage ( CyString &rank );
116
	CyString GetRankPercentage ( CyString &rank );
117
 
118
	// data locking
119
	bool		m_bLocked;
120
 
121
	// my ship data
122
	SShip		m_shipData;
123
	// my targets data
124
	STarget		m_targetData;
125
 
126
	// pilot info
127
	CyString	m_sPilot;
128
	int			m_iShips;
129
	int			m_iStations;
130
	int			m_iAccount;
131
	int			m_iInsurance;
132
	int			m_iShipClass[MAXSHIPCLASS];
133
	// main ship information
134
	int			m_iHull;
135
	int			m_iShields;
136
	int			m_iLaser;
137
	int			m_iMaxLaser;
138
	int			m_iLaserProgress;
139
	int			m_iMissiles;
140
	int			m_iEnemies;
141
	int			m_iEnemies2;
142
	int			m_iVersion;
143
	int			m_iLastUpdate;
144
 
145
	CyString	m_sAccount;
146
	CyString	m_sGametime;
147
	CyString	m_sShipEnv;
148
	SRaceRep	m_Rep[MAXRACEREP];
149
	CyString	m_sGameName;
150
	CyString	m_sGameDir;
151
	CyString	m_sProgDir;
152
 
153
	bool		m_bLoaded;
154
 
155
	CyStringList m_lCustomList;
156
	CyStringList m_lCustomFile;
157
};
158
 
159
#endif // !defined(AFX_X3DATA_H__491F0DBE_1AE5_4956_B262_F2D1B0D0E9FF__INCLUDED_)