Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Include/Painters.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ class CHoverDescriptionPainter
mutable RECT m_rcText; // Rect of text area
mutable CTextBlock m_DescriptionRTF; // Rich text to draw
};

class CStargateEffectPainter
class ITransitionEffectPainter
{
public:
virtual void Paint (CG32bitImage &Dest, const RECT &rcRect) { };
virtual void Update (void) { };
};
class CStargateEffectPainter : public ITransitionEffectPainter
{
public:
CStargateEffectPainter (void);
Expand Down Expand Up @@ -105,7 +110,7 @@ class CStargateEffectPainter
Metric m_rGlowVel;
Metric m_rGlowRadius;
};
class CAutomataEffectPainter
class CAutomataEffectPainter : public ITransitionEffectPainter
{
public:
CAutomataEffectPainter (int width, int height);
Expand Down
7 changes: 6 additions & 1 deletion Include/TSEDeviceClassesImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ class CReactorClass : public CDeviceClass

const CReactorDesc *GetReactorDesc (CItemCtx &Ctx, DWORD dwFlags = 0) const;
int GetMaxPower (CItemCtx &ItemCtx, const CReactorDesc &Desc) const;
Metric GetMaxFuel (CItemCtx &ItemCtx, const CReactorDesc &Desc) const;
void InitDamagedDesc (void) const;
void InitEnhancedDesc (void) const;

Expand All @@ -308,6 +309,7 @@ class CReactorClass : public CDeviceClass
// Other properties

int m_iExtraPowerPerCharge; // Adds to max power
int m_iExtraFuelPerCharge; // Adds to max fuel

// Damaged/enhanced
// We allocate these as needed; the array matches m_pDesc
Expand Down Expand Up @@ -545,8 +547,9 @@ class CWeaponClass : public CDeviceClass
{
evtOnFireWeapon = 0,
evtGetAmmoToConsume = 1,
evtOnCounterCooldown = 2,

evtCount = 2,
evtCount = 3,
};

struct SBalance
Expand Down Expand Up @@ -746,6 +749,7 @@ class CWeaponClass : public CDeviceClass
int FireGetAmmoToConsume(CItemCtx &ItemCtx,
CWeaponFireDesc *pShot,
int iRepeatingCount);
void FireOnCounterCooldown (CItemCtx &ItemCtx);
EOnFireWeaponResults FireOnFireWeapon (CItemCtx &ItemCtx,
CWeaponFireDesc *pShot,
const CVector &vSource,
Expand Down Expand Up @@ -812,6 +816,7 @@ class CWeaponClass : public CDeviceClass
int m_iCounterUpdateRate; // Ticks to update counter
int m_iCounterUpdate; // Inc/dec value per update
int m_iCounterActivate; // Inc/dec value per shot
int m_iCounterPowerUse; // Power use when counter is updating

bool m_bTargetStationsOnly; // Do not target ships

Expand Down
8 changes: 4 additions & 4 deletions Include/TSEDevices.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,10 @@ class CInstalledDevice
inline int GetRotation (void) const { return AngleMiddle(m_iMinFireArc, m_iMaxFireArc); }
inline const CEnhancementDesc &GetSlotEnhancements (void) const { return m_SlotEnhancements; }
inline int GetSlotPosIndex (void) const { return m_iSlotPosIndex; }
inline int GetTemperature (void) const { return m_iTemperature; }
inline int GetCounter (void) const { return m_iCounter; }
inline int GetTimeUntilReady (void) const { return m_iTimeUntilReady; }
inline bool Has3DPos (void) const { return m_f3DPosition; }
inline void IncTemperature (int iChange) { m_iTemperature += iChange; }
inline void IncCounter (int iChange) { m_iCounter += iChange; }
inline bool IsDirectional (void) const { return (m_iMinFireArc != m_iMaxFireArc); }
inline bool IsDuplicate (void) const { return (m_fDuplicate ? true : false); }
inline bool IsEmpty (void) const { return m_pClass == NULL; }
Expand Down Expand Up @@ -522,7 +522,7 @@ class CInstalledDevice
inline void SetRegenerating (bool bRegenerating) { m_fRegenerating = bRegenerating; }
inline void SetSecondary (bool bSecondary = true) { m_fSecondaryWeapon = bSecondary; }
inline void SetSlotPosIndex (int iIndex) { m_iSlotPosIndex = iIndex; }
inline void SetTemperature (int iTemperature) { m_iTemperature = iTemperature; }
inline void SetTemperature (int iTemperature) { m_iCounter = iTemperature; }
inline void SetTimeUntilReady (int iDelay) { m_iTimeUntilReady = iDelay; }
inline void SetTriggered (bool bTriggered) { m_fTriggered = bTriggered; }
inline void SetWaiting (bool bWaiting) { m_fWaiting = bWaiting; }
Expand Down Expand Up @@ -630,7 +630,7 @@ class CInstalledDevice
int m_iTimeUntilReady:16; // Timer counting down until ready to activate
int m_iFireAngle:16; // Last fire angle

int m_iTemperature:16; // Temperature for weapons
int m_iCounter:16; // Temperature/Capacitor for weapons
int m_iActivateDelay:16; // Cached activation delay
int m_iExtraPowerUse:16; // Additional power use per tick
int m_iSlotPosIndex:16; // Slot placement
Expand Down
2 changes: 2 additions & 0 deletions Include/TSEShipSystems.h
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,12 @@ class CReactorDesc
CString GetFuelCriteriaString (void) const;
void GetFuelLevel (int *retiMin, int *retiMax) const;
inline int GetMaxPower (void) const { return m_iMaxPower; }
inline Metric GetMaxFuel (void) const { return m_rMaxFuel; }
ALERROR InitFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc, DWORD dwUNID, bool bShipClass = false);
ALERROR InitScaled (SDesignLoadCtx &Ctx, const CReactorDesc &Src, int iBaseLevel, int iScaledLevel);
bool IsFuelCompatible (const CItem &FuelItem) const;
inline void SetMaxPower (int iPower) { m_iMaxPower = iPower; }
inline void SetMaxFuel (Metric rMaxFuel) { m_rMaxFuel = rMaxFuel; }
inline bool UsesFuel (void) const { return (m_fNoFuel ? false : true); }

static const SStdStats &GetStdStats (int iLevel);
Expand Down
7 changes: 7 additions & 0 deletions Include/TSEStationType.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ class CStationType : public CDesignType
worldSizeL = 12, // 75,000-149,999 km
worldSizeM = 13, // 150,000+ km
};
enum ETransitionEffectType
{
transitionStargate = 0,
transitionAutomata = 1,
};

CStationType (void);
virtual ~CStationType (void);
Expand Down Expand Up @@ -330,6 +335,7 @@ class CStationType : public CDesignType
inline CG32bitPixel GetSpaceColor (void) { return m_rgbSpaceColor; }
inline int GetStealth (void) const { return m_iStealth; }
inline int GetTempChance (void) const { return m_iChance; }
inline ETransitionEffectType GetTransitionEffectType(void) { return m_pTransitionEffect; }
inline bool HasAnimations (void) const { return (m_pAnimations != NULL); }
inline bool HasGravity (void) const { return (m_rGravityRadius > 0.0); }
inline bool HasWreckImage (void) const { return m_HullDesc.CanBeWrecked(); }
Expand Down Expand Up @@ -539,6 +545,7 @@ class CStationType : public CDesignType
CString m_sStargateDestNode; // Dest node
CString m_sStargateDestEntryPoint; // Dest entry point
CEffectCreatorRef m_pGateEffect; // Effect when object gates in/out of station
ETransitionEffectType m_pTransitionEffect; // Effect type when transitioning between systems after gating

// Miscellaneous
CEffectCreatorRef m_pBarrierEffect; // Effect when object hits station
Expand Down
1 change: 1 addition & 0 deletions Include/TSEWeaponFireDesc.h
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ class CWeaponFireDesc

// Missile stuff (m_iFireType == ftMissile)
int m_iAccelerationFactor; // % increase in speed per 10 ticks
int m_iAccelerationInc; // Numerical increase in speed per 10 ticks
Metric m_rMaxMissileSpeed; // Max speed.
int m_iStealth; // Missile stealth
int m_iHitPoints; // HP before dissipating (0 = destroyed by any hit)
Expand Down
8 changes: 4 additions & 4 deletions TSE/CInstalledDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CInstalledDevice::CInstalledDevice (void) :

m_iTimeUntilReady(0),
m_iFireAngle(0),
m_iTemperature(0),
m_iCounter(0),
m_iActivateDelay(0),
m_iExtraPowerUse(0),
m_iSlotPosIndex(-1),
Expand Down Expand Up @@ -381,8 +381,8 @@ void CInstalledDevice::Install (CSpaceObject *pObj, CItemListManipulator &ItemLi
m_iSlotPosIndex = -1;
m_pOverlay = NULL;
m_dwData = 0;
m_iCounter = 0;
m_iExtraPowerUse = 0;
m_iTemperature = 0;
m_fWaiting = false;
m_fEnabled = true;
m_fTriggered = false;
Expand Down Expand Up @@ -657,7 +657,7 @@ void CInstalledDevice::ReadFromStream (CSpaceObject *pSource, SLoadCtx &Ctx)
m_iFireAngle = (int)HIWORD(dwLoad);

Ctx.pStream->Read((char *)&dwLoad, sizeof(DWORD));
m_iTemperature = (int)HIWORD(dwLoad);
m_iCounter = (int)HIWORD(dwLoad);

if (Ctx.dwVersion < 92)
{
Expand Down Expand Up @@ -1278,7 +1278,7 @@ void CInstalledDevice::WriteToStream (IWriteStream *pStream)
dwSave = MAKELONG(m_iTimeUntilReady, m_iFireAngle);
pStream->Write((char *)&dwSave, sizeof(DWORD));

dwSave = MAKELONG(m_iSlotPosIndex, m_iTemperature);
dwSave = MAKELONG(m_iSlotPosIndex, m_iCounter);
pStream->Write((char *)&dwSave, sizeof(DWORD));

dwSave = MAKELONG(m_iExtraPowerUse, m_iDeviceSlot);
Expand Down
25 changes: 25 additions & 0 deletions TSE/CReactorClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "PreComp.h"

#define MAX_POWER_BONUS_PER_CHARGE_ATTRIB CONSTLIT("maxPowerBonusPerCharge")
#define MAX_FUEL_BONUS_PER_CHARGE_ATTRIB CONSTLIT("maxFuelBonusPerCharge")

#define PROPERTY_MAX_POWER CONSTLIT("maxPower")
#define PROPERTY_POWER CONSTLIT("power")
Expand Down Expand Up @@ -74,6 +75,7 @@ ALERROR CReactorClass::CreateFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc, C
// Some properties are not scaled (OK if negative).

pDevice->m_iExtraPowerPerCharge = pDesc->GetAttributeInteger(MAX_POWER_BONUS_PER_CHARGE_ATTRIB);
pDevice->m_iExtraFuelPerCharge = pDesc->GetAttributeInteger(MAX_FUEL_BONUS_PER_CHARGE_ATTRIB);

// Done

Expand Down Expand Up @@ -146,6 +148,25 @@ int CReactorClass::GetPowerOutput (CItemCtx &Ctx, DWORD dwFlags) const
return GetMaxPower(Ctx, *pDesc);
}

Metric CReactorClass::GetMaxFuel (CItemCtx &ItemCtx, const CReactorDesc &Desc) const

// GetMaxFuel
//
// Returns max fuel

{
Metric rMaxFuel = Desc.GetMaxFuel();

// Adjust for charges

if (m_iExtraFuelPerCharge > 0)
rMaxFuel += m_iExtraFuelPerCharge * ItemCtx.GetItemCharges();

// Done

return Max(0.0, rMaxFuel);
}

int CReactorClass::GetMaxPower (CItemCtx &ItemCtx, const CReactorDesc &Desc) const

// GetMaxPower
Expand Down Expand Up @@ -315,6 +336,10 @@ bool CReactorClass::OnAccumulatePerformance (CItemCtx &ItemCtx, SShipPerformance

Ctx.ReactorDesc.SetMaxPower(GetMaxPower(ItemCtx, *pDesc));

// Also increase max fuel based on charges

Ctx.ReactorDesc.SetMaxFuel(GetMaxFuel(ItemCtx, *pDesc));

// Done

return true;
Expand Down
13 changes: 13 additions & 0 deletions TSE/CStationType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,19 @@ ALERROR CStationType::OnCreateFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc)
if (error = m_pGateEffect.LoadUNID(Ctx, pDesc->GetAttribute(GATE_EFFECT_ATTRIB)))
return error;

CString sTransitionEffect;
if (pDesc->FindAttribute("transitionEffect", &sTransitionEffect))
{
if (strEquals(sTransitionEffect, CONSTLIT("stargate")))
m_pTransitionEffect = transitionStargate;
else if (strEquals(sTransitionEffect, CONSTLIT("automata")))
m_pTransitionEffect = transitionAutomata;
else
return ComposeLoadError(Ctx, strPatternSubst(CONSTLIT("Invalid transitionEffect attribute: %s. Valid values are \"stargate\" and \"automata\""), sTransitionEffect));
}
else
m_pTransitionEffect = transitionStargate;

// Miscellaneous

if (error = m_pBarrierEffect.LoadUNID(Ctx, pDesc->GetAttribute(BARRIER_EFFECT_ATTRIB)))
Expand Down
Loading