Files
source/Strategic/ASD.h
T
00fb898600 Delete builddefines.h
Nothing was left in it but the include of profiler.h, and 132 translation units
were including it for that alone. Fifteen files were leaning on profiler.h to
drag in <set>, <vector> and <ostream> for them; those now include what they use.

This is the commit that moves line numbers. Removing an include line shifts
__LINE__ by one for everything below it, and __LINE__ is an immediate operand in
every Assert() and DebugMsg() call, so the four game executables differ from
their predecessors by roughly a thousand 32-bit constants each. Every one of
those is accounted for: each is a single immediate that moved by -1 where the
builddefines.h include went away, or +1 where a <set>/<vector> include was
added. Nothing else in .text, .rdata or .data moves, no object file's section
sizes change, and symbolize_crash and Ja2Export stay bit-identical.

The one non-immediate difference is that the 24 Editor translation units of the
non-editor apps stop emitting __Avx2WmemEnabledWeakValue, a 4-byte weak COMDAT
they only ever instantiated through profiler.h's <vector>. It is a UCRT weak
default that other translation units still provide.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-22 01:07:26 -03:00

130 lines
4.8 KiB
C++

#ifndef __ASD_H
#define __ASD_H
/**
* @file
* @author Flugente (bears-pit.com)
*/
#include <vector>
#include <set>
#include "types.h"
/** Flugente: Arulco special division decision code
*
* As I do not want to alter the current strategic AI (fragile and obscure as it is),
* I am leaving the control over a number of new toys to a second 'AI' - the 'Arulco Special Division'.
* This should control if, how and when new features are used by the AI.
*
* It has its own 'budget', which allows it to purchase new actions. This serves to limit the amount of the AIs actions.
* It also gives the player a way to compete with the AI - lower the AI budget, and the AI can do less harm.
* For example, part of the AI budget might come from mine income, which the player can take away.
*
* If possible, the AI should have to buy and maintain its assets.
* This way the player could harm the AI by specifically targetting those assets if he chooses so.
* Ideally this gives the player another immersive way to do sth. in the game.
* For example, enemy helicopters have to be bought, fuelled and repaired.
* In order to stop enemy heli raids, the player could
* - shoot them down
* - steal enemy fuel deliveries
* - sabotage enemy helis in their airfield
*
* There is a cyclic update of this AI. Each time the AI decides whether it wants (and can afford) new assets.
* These assets then have to be ordered and can only be used once arrived.
* The AI also decides how to use these assets.
*/
void InitASD( );
BOOLEAN SaveASDData( HWFILE hwFile );
BOOLEAN LoadASDData( HWFILE hwFile );
// when called, evaluate the current situation, and perform actions to harm the player if necessary
void UpdateASD( );
// decide whether to purchase something
void ASDDecideOnPurchases();
// decide in what to do with helicopters
void ASDDecideHeliOperations();
// various flags for the AI to remember
#define ASDFACT_HELI_UNLOCKED 0x00000001 // AI is allowed to purchase helicopters
#define ASDFACT_JEEP_UNLOCKED 0x00000002 // AI is allowed to purchase jeeps
#define ASDFACT_TANK_UNLOCKED 0x00000004 // AI is allowed to purchase tanks
#define ASDFACT_ROBOT_UNLOCKED 0x00000008 // AI is allowed to purchase robots
void SetASDFlag( UINT32 aFlag );
UINT32 ASDResourceDeliveryTime( UINT8 aType );
UINT32 ASDResourceCostMoney( UINT8 aType );
INT32 GetStrategicAIResourceCount( UINT8 aType );
// add resources to the AIs resource pool
void AddStrategicAIResources( UINT8 aType, INT32 aAmount );
// when we receive an ordered shipment, reduce our backlog
void ASDReduceOrderedStrategicResources( UINT8 aType, INT32 aAmount );
// enemy helis
class ENEMY_HELI
{
public:
// determine best heli flight path (minimising contact to hostile SAM sectors) and return number of possible SAM contacts
UINT8 SetHeliFlightPath( UINT8 aDest );
void Destroy( );
public:
UINT32 flagmask; // flags: destroyed, refueling...
UINT8 sector_current; // we are here
UINT8 sector_destination; // we want to fly here
UINT8 sector_waypoint; // a sector we travel to between our starting point and our destiantion. Choosing this gives us a way to plot a path minimising SAM-exposure
UINT8 sector_home; // this is where our base is
UINT8 troopcount; // number of troops we carry
UINT8 hp;
UINT8 fuel;
};
extern std::vector<ENEMY_HELI> gEnemyHeliVector;
void EnemyHeliInit( );
void AddNewHeli( );
// all enemy helis carrying troops in this sector drop these into combat, and get the order to head home
void EnemyHeliTroopDrop( UINT8 aSector );
std::set<UINT8> GetEnemyHeliSectors( BOOLEAN afKnownToPlayer );
// returns vector of all helis, -1 if known to player, id otherwise
std::vector<INT16> GetEnemyHeliIDKnowledgeStatus();
void BuyHeliInfoWithIntel( INT16 id );
void UpdateEnemyHeliRepair( INT16 id );
void UpdateEnemyHeliRefuel( INT16 id );
void UpdateEnemyHeli( INT16 id );
void EnemyHeliSAMCheck( INT16 id );
void EnemyHeliMANPADSCheck( INT16 id );
void EnemyHeliCheckPlayerKnowledge( INT16 id );
UINT8 NumPlayerAirSpaceOnHeliPath( UINT8 aStart, UINT8 aEnd );
// get the next sector in an enemy heli flight path.
UINT8 GetNextEnemyHeliSector( UINT8 aStart, UINT8 aDest );
void HandleEnemyHelicopterOnGroundGraphic( );
void UpdateAndDamageEnemyHeliIfFound( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ, INT32 sGridNo, UINT8 ubDamage, BOOLEAN aDestroyed = FALSE );
// enemy tanks (how and when they are used)
UINT32 ASDResourceCostFuel( UINT8 aType );
// if ASD is used, any tanks the queen uses in mobile attacks come from its pool, and we have to account for that
BOOLEAN ASDSoldierUpgradeToTank( );
BOOLEAN ASDSoldierUpgradeToJeep( );
BOOLEAN ASDSoldierUpgradeToRobot( );
#endif //__ASD_H