Ares
Classes | Static Public Member Functions | Static Public Attributes

Ares Class Reference

#include <src/Ares.h>

List of all members.

Classes

class  GlobalControls
class  UISettings

Static Public Member Functions

static void UpdateStability ()
static void InitOwnResources ()
static void UninitOwnResources ()
static CCINIClass * OpenConfig (const char *)
static void CloseConfig (CCINIClass **)
static void InitNoCDMode ()
static void __stdcall CmdLineParse (char **, int)
static void __stdcall ExeRun ()
static void __stdcall ExeTerminate ()
static void __stdcall PostGameInit ()
static void __stdcall RegisterCommands ()
static void SendPDPlane (HouseClass *pOwner, CellClass *pDestination, AircraftTypeClass *pPlaneType, TypeList< TechnoTypeClass * > *pTypes, TypeList< int > *pNums)
static bool RunningOnWindows7OrVista ()

Static Public Attributes

static HANDLE hInstance = 0
static bool bNoLogo = false
static bool bNoCD = false
static bool bTestingRun = false
static bool bLog
static FILE * pLogFile
static bool bStrictParser = false
static bool bAllowAIControl = false
static int TrackIndex
static bool bStable = false
static bool bStableNotification = false
static const wchar_t StabilityWarning [BUFLEN] = ") is not considered stable."
static DWORD readLength = BUFLEN
static char readBuffer [BUFLEN]
static const char readDelims [4] = ","
static const char readDefval [4] = ""
static MixFileClass * aresMIX = NULL

Member Function Documentation

void Ares::CloseConfig ( CCINIClass **  ppINI) [static]
                                         {
        if(ppINI && *ppINI) {
                GAME_DEALLOC(*ppINI);
                *ppINI = NULL;
        }
}
void __stdcall Ares::CmdLineParse ( char **  ppArgs,
int  nNumArgs 
) [static]
{
        char* pArg;

        Debug::bLog = false;
        bNoCD = false;
        bNoLogo = false;
        EMPulse::verbose = false;

        // > 1 because the exe path itself counts as an argument, too!
        if(nNumArgs > 1) {
                for(int i = 1; i < nNumArgs; i++) {
                        pArg = ppArgs[i];
                        _strupr(pArg);

                        if(strcmp(pArg,"-LOG") == 0) {
                                Debug::bLog = true;
                        } else if(strcmp(pArg,"-CD") == 0) {
                                bNoCD = true;
                        } else if(strcmp(pArg,"-NOLOGO") == 0) {
                                bNoLogo = true;
                        } else if(strcmp(pArg, "-TESTRUN") == 0) {
                                bTestingRun = true;
                        } else if(strcmp(pArg, "-STRICT") == 0) {
                                bStrictParser = true;
                        } else if(strcmp(pArg, "-LOG-EMP") == 0) {
                                EMPulse::verbose = true;
                        } else if(strcmp(pArg,"-AI-CONTROL") == 0) {
                                bAllowAIControl = true;
                        }
                }
        }

        if(Debug::bLog) {
                Debug::LogFileOpen();
                Debug::Log("Initialized " VERSION_STRVER "\n");
        }

        InitNoCDMode();
}
void __stdcall Ares::ExeRun ( ) [static]
{
        Ares::readLength = BUFLEN;

        Unsorted::Savegame_Magic = SAVEGAME_MAGIC;
        Game::bVideoBackBuffer = false;
        Game::bAllowVRAMSidebar = false;
}
void __stdcall Ares::ExeTerminate ( ) [static]
void Ares::InitNoCDMode ( ) [static]
                        {
        if(!GetCDClass::Instance->Count) {
                Debug::Log("No CD drives detected. Switching to NoCD mode.\n");
                bNoCD = true;
        }
        
        if(bNoCD) {
                Debug::Log("Optimizing list of CD drives for NoCD mode.\n");
                memset(GetCDClass::Instance->Drives, -1, 26);

                char drv[] = "a:\\";
                for(int i=0; i<26; ++i) {
                        drv[0] = 'a' + (i + 2) % 26;
                        if(GetDriveTypeA(drv) == DRIVE_FIXED) {
                                GetCDClass::Instance->Drives[0] = (i + 2) % 26;
                                GetCDClass::Instance->Count = 1;
                                break;
                        }
                }
        }
}
void Ares::InitOwnResources ( ) [static]
{
        UninitOwnResources();
        GAME_ALLOC(MixFileClass, aresMIX, "ares.mix");
}
CCINIClass * Ares::OpenConfig ( const char *  file) [static]
                                             {
        CCINIClass* pINI;
        GAME_ALLOC(CCINIClass, pINI);
        CCFileClass *cfg;
        GAME_ALLOC(CCFileClass, cfg, file);
        if(cfg->Exists(NULL)) {
                pINI->ReadCCFile(cfg);
        }
        GAME_DEALLOC(cfg);

        return pINI;
}
void __stdcall Ares::PostGameInit ( ) [static]
{

}
void __stdcall Ares::RegisterCommands ( ) [static]
{
        if(bAllowAIControl) {
                MakeCommand<AIControlCommandClass>();
        }
        MakeCommand<MapSnapshotCommandClass>();
        MakeCommand<TestSomethingCommandClass>();
        MakeCommand<DumperTypesCommandClass>();
        MakeCommand<MemoryDumperCommandClass>();
        MakeCommand<DebuggingCommandClass>();
        MakeCommand<AIBasePlanCommandClass>();
}
bool Ares::RunningOnWindows7OrVista ( ) [static]
                                    {
        static bool W7 = false;
        static bool Checked = false;
        if(!Checked) {
                Checked = true;
                OSVERSIONINFO osvi;

                ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
                osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
                GetVersionEx(&osvi);

                W7 = (osvi.dwMajorVersion == 6)/* && (osvi.dwMinorVersion >= 1)*/;
        }
        return W7;
}
void Ares::SendPDPlane ( HouseClass *  pOwner,
CellClass *  pDestination,
AircraftTypeClass *  pPlaneType,
TypeList< TechnoTypeClass * > *  pTypes,
TypeList< int > *  pNums 
) [static]
{
        if(pNums && pTypes &&
                pNums->Count == pTypes->Count &&
                pNums->Count > 0 &&
                pOwner && pPlaneType && pTarget)
        {
                ++Unsorted::IKnowWhatImDoing;
                AircraftClass* pPlane = reinterpret_cast<AircraftClass*>(pPlaneType->CreateObject(pOwner));
                --Unsorted::IKnowWhatImDoing;

                pPlane->Spawned = true;

                //Get edge (direction for plane to come from)
                int edge = pOwner->StartingEdge;
                if(edge < edge_NORTH || edge > edge_WEST) {
                        edge = pOwner->Edge;
                        if(edge < edge_NORTH || edge > edge_WEST) {
                                edge = edge_NORTH;
                        }
                }

                //some ASM magic, seems to retrieve a random cell struct at a given edge
                CellStruct spawn_cell;

                MapClass::Instance->PickCellOnEdge(&spawn_cell, edge, (CellStruct *)0xB04C38, (CellStruct *)0xB04C38, 4, 1, 0);

                pPlane->QueueMission(mission_ParadropApproach, false);

                if(pTarget) {
                        pPlane->SetTarget(pTarget);
                }

                CoordStruct spawn_crd = {(spawn_cell.X << 8) + 128, (spawn_cell.Y << 8) + 128, 0};

                ++Unsorted::IKnowWhatImDoing;
                bool bSpawned = pPlane->Put(&spawn_crd, Direction::North);
                --Unsorted::IKnowWhatImDoing;

                if(bSpawned) {
                        pPlane->HasPassengers = true;
                        for(int i = 0; i < pTypes->Count; i++) {
                                TechnoTypeClass* pTechnoType = pTypes->GetItem(i);

                                //only allow infantry and vehicles
                                eAbstractType WhatAmI = pTechnoType->WhatAmI();
                                if(WhatAmI == abs_UnitType || WhatAmI == abs_InfantryType) {
                                        for(int k = 0; k < pNums->Items[i]; k++) {
                                                FootClass* pNew = reinterpret_cast<FootClass*>(pTechnoType->CreateObject(pOwner));
                                                pNew->Remove();
                                                pPlane->Passengers.AddPassenger(pNew);
                                        }
                                }
                        }
                        pPlane->NextMission();
                } else {
                        if(pPlane) {
                                GAME_DEALLOC(pPlane);
                        }
                }
        }
}
void Ares::UninitOwnResources ( ) [static]
{
        if(aresMIX) {
                GAME_DEALLOC(aresMIX);
                aresMIX = NULL;
        }
}
void Ares::UpdateStability ( ) [static]
                           {
        if(Ares::bStable) {
                return;
        }
        if(Unsorted::CurrentFrame < 900) {
                return;
        }
        if(!Ares::bStableNotification) {
                Debug::FatalErrorAndExit("This version of Ares is not considered stable, but for some reason the warning text isn't showing.\n"
                        "This suggests that your version of Ares has been tampered with "
                        "and the original developers cannot be held responsible for any problems you might experience.");
        }
}

Member Data Documentation

MixFileClass * Ares::aresMIX = NULL [static]
bool Ares::bAllowAIControl = false [static]
bool Ares::bLog [static]
bool Ares::bNoCD = false [static]
bool Ares::bNoLogo = false [static]
bool Ares::bStable = false [static]
bool Ares::bStableNotification = false [static]
bool Ares::bStrictParser = false [static]
bool Ares::bTestingRun = false [static]
HANDLE Ares::hInstance = 0 [static]
FILE* Ares::pLogFile [static]
char Ares::readBuffer [static]
const char Ares::readDefval = "" [static]
const char Ares::readDelims = "," [static]
DWORD Ares::readLength = BUFLEN [static]
const wchar_t Ares::StabilityWarning = ") is not considered stable." [static]
int Ares::TrackIndex [static]

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines