Subversion Repositories spk

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

// X3Data.h: interface for the CX3Data class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_X3DATA_H__491F0DBE_1AE5_4956_B262_F2D1B0D0E9FF__INCLUDED_)
#define AFX_X3DATA_H__491F0DBE_1AE5_4956_B262_F2D1B0D0E9FF__INCLUDED_

#include <CyString.h>
#include <StringList.h>

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define DATA_LOCKED  m_bLocked = true;
#define DATA_UNLOCKED m_bLocked = false;

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 };
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 };
#define MAXRACEREP              12
#define MAXSHIPCLASS    12

typedef struct SShip {
        void Reset() { sName = sID = sClass = sEnv = ""; iSpeed = 0; }
        CyString sName;
        CyString sID;
        CyString sClass;
        CyString sEnv;
        int              iSpeed;
} SShip;

typedef struct STarget : public SShip {
        void Reset() { SShip::Reset(); iShields = iHull = iDist = 0; sRelation = ""; }
        int                     iShields;
        int                     iHull;
        CyString        sRelation;
        int                     iDist;
} STarget;

typedef struct SRaceRep {
        void Reset() { sRace = ""; iRep = 0; iRepPct = 0; sRank = ""; bIncludeRace = false; }
        CyString        sRace;
        CyString        sRank;
        int                     iRep;
        int                     iRepPct;
        bool            bIncludeRace;
} SRaceRep;

class CX3Data  
{
public:
        bool ReadFile ( CyString, CyString );

        // get strings
        bool    IsLocked                        () { return m_bLocked; }
        SShip    &GetShipData           () { return m_shipData; }
        STarget  &GetTargetData         () { return m_targetData; }
        CyString &GetPilot              () { return m_sPilot; }
        CyString &GetShipID                     () { return m_shipData.sID; }
        int               GetShipsNum           () { return m_iShips; }
        int               GetStations           () { return m_iStations; }
        CyString &GetCredits        () { return m_sAccount; }
        CyString &GetGameTime           () { return m_sGametime; }
        CyString &GetShipName           () { return m_shipData.sName; }
        CyString &GetShipEnv            () { return m_shipData.sEnv; }
        int GetShipClass (int s_class) { return m_iShipClass[s_class]; }
        SRaceRep &GetRaceRep    (int race) { return m_Rep[race]; }
        bool     HasTarget              () { return (m_targetData.sName.Empty()) ? false : true; }
        CyString  GetTarget             () { return (!HasTarget()) ? "No Target" : m_targetData.sName; }
        CyString GetTargetRelation() { return m_targetData.sRelation; }
        CyString GetTargetDistanceStr()
        {
                int dist = m_targetData.iDist;
                if ( dist > 900 )
                {
                        float fDist = (float)dist / 1000.0f;
                        return CyString::CreateFromFloat(fDist, 1) + "Km";
                }
                return CyString::Number(dist) + "m";
        }
        int     GetHull                 () { return m_iHull; }
        int     GetShields      () { return m_iShields; }
        int     GetWeaponEnergy () { return m_iLaserProgress; }
        int             GetMySpeed              () { return m_shipData.iSpeed; }
        int             GetTargetSpeed  () { return m_targetData.iSpeed; }
        int             GetTargetDistance  () { return m_targetData.iDist; }
        int             GetTargetHull   () { return m_targetData.iHull; }
        int             GetTargetShield () { return m_targetData.iShields;  }
        int             GetEnemies              () { return m_iEnemies; }
        int             GetEnemies2             () { return m_iEnemies2; }
        int             GetMissiles             () { return m_iMissiles; }
        int             GetInsurance    () { return m_iInsurance; }
        int             GetVersion              () { return m_iVersion; }
        CyString        GetMyShip               () { return (m_shipData.sName.Empty()) ? "No Ship" : (m_shipData.sName + " (" + m_shipData.sID + ") [" + m_shipData.sClass + "] / " + m_shipData.sEnv); }
        CyString        GetMyTarget             () { return (!HasTarget()) ? "No Target" : (m_targetData.sName + " (" + m_targetData.sID + ") [" + m_targetData.sClass + "]"); }

        CyStringList *GetCustomFiles () { return &m_lCustomFile; }
        CyStringList *GetCustomList () { return &m_lCustomList; }

        // set strings
        void Reset ();
        void SetGameName(CyString &name) { m_sGameName = name; }
        void SetGameDirectory(CyString &name) { m_sGameDir = name; }

        CyString &GetGameName() { return m_sGameName; }
        CyString &GetProgDir()  { return m_sProgDir; }
        CyString &GetGameDirectory()  { return m_sGameDir; }

        CX3Data(CyString &progDir);
        virtual ~CX3Data();

        void SetRaceRep(int rep, CyString race, CyString &rest, bool old = false);

private:
        CyString GetRepPercentage ( CyString &rank );
        CyString GetRankPercentage ( CyString &rank );

        // data locking
        bool            m_bLocked;

        // my ship data
        SShip           m_shipData;
        // my targets data
        STarget         m_targetData;

        // pilot info
        CyString        m_sPilot;
        int                     m_iShips;
        int                     m_iStations;
        int                     m_iAccount;
        int                     m_iInsurance;
        int                     m_iShipClass[MAXSHIPCLASS];
        // main ship information
        int                     m_iHull;
        int                     m_iShields;
        int                     m_iLaser;
        int                     m_iMaxLaser;
        int                     m_iLaserProgress;
        int                     m_iMissiles;
        int                     m_iEnemies;
        int                     m_iEnemies2;
        int                     m_iVersion;
        int                     m_iLastUpdate;

        CyString        m_sAccount;
        CyString        m_sGametime;
        CyString        m_sShipEnv;
        SRaceRep        m_Rep[MAXRACEREP];
        CyString        m_sGameName;
        CyString        m_sGameDir;
        CyString        m_sProgDir;

        bool            m_bLoaded;

        CyStringList m_lCustomList;
        CyStringList m_lCustomFile;
};

#endif // !defined(AFX_X3DATA_H__491F0DBE_1AE5_4956_B262_F2D1B0D0E9FF__INCLUDED_)