Add proper initializations and remove manual memory management in remaining classes
Except CBot-related stuff of coursemaster
parent
736f90955d
commit
efedb44cce
|
@ -43,6 +43,6 @@ template<typename T>
|
|||
inline std::unique_ptr<T[]> MakeUniqueArray(std::size_t size)
|
||||
{
|
||||
//@colobot-lint-exclude NakedNewRule
|
||||
return std::unique_ptr<T[]>(new T[size]);
|
||||
return std::unique_ptr<T[]>(new T[size]());
|
||||
//@end-colobot-lint-exclude
|
||||
}
|
||||
|
|
|
@ -45,6 +45,11 @@ CMainMovie::CMainMovie()
|
|||
m_camera = m_main->GetCamera();
|
||||
m_sound = CApplication::GetInstancePointer()->GetSound();
|
||||
|
||||
m_progress = 0.0f;
|
||||
m_stopType = MM_NONE;
|
||||
m_type = MM_NONE;
|
||||
m_speed = 0.0f;
|
||||
|
||||
Flush();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,18 +25,18 @@
|
|||
#include "level/parser/parser.h"
|
||||
|
||||
CLevelParserLine::CLevelParserLine(std::string command)
|
||||
{
|
||||
m_command = command;
|
||||
m_levelFilename = "";
|
||||
m_lineNumber = 0;
|
||||
}
|
||||
: m_level(nullptr),
|
||||
m_levelFilename(""),
|
||||
m_lineNumber(0),
|
||||
m_command(command)
|
||||
{}
|
||||
|
||||
CLevelParserLine::CLevelParserLine(int lineNumber, std::string command)
|
||||
{
|
||||
m_command = command;
|
||||
m_levelFilename = "";
|
||||
m_lineNumber = lineNumber;
|
||||
}
|
||||
: m_level(nullptr),
|
||||
m_levelFilename(""),
|
||||
m_lineNumber(lineNumber),
|
||||
m_command(command)
|
||||
{}
|
||||
|
||||
int CLevelParserLine::GetLineNumber()
|
||||
{
|
||||
|
|
|
@ -83,6 +83,8 @@ CPlayerProfile::CPlayerProfile(std::string playerName)
|
|||
GetConfigFile().Save();
|
||||
|
||||
m_freegameLoaded = false;
|
||||
m_freegameBuild = 0;
|
||||
m_freegameResearch = 0;
|
||||
|
||||
for(int i = 0; i < static_cast<int>(LevelCategory::Max); i++)
|
||||
{
|
||||
|
|
|
@ -28,14 +28,14 @@
|
|||
|
||||
struct LevelInfo
|
||||
{
|
||||
int numTry;
|
||||
bool bPassed;
|
||||
int numTry = 0;
|
||||
bool bPassed = false;
|
||||
};
|
||||
|
||||
struct PlayerApperance
|
||||
{
|
||||
int face; // face
|
||||
int glasses; // glasses
|
||||
int face = 0; // face
|
||||
int glasses = 0; // glasses
|
||||
Gfx::Color colorHair; // hair color
|
||||
Gfx::Color colorCombi; // spacesuit volor
|
||||
Gfx::Color colorBand; // strips color
|
||||
|
@ -48,11 +48,9 @@ struct SavedScene
|
|||
std::string path;
|
||||
std::string name;
|
||||
|
||||
SavedScene(std::string _path = "", std::string _name = "")
|
||||
{
|
||||
path = _path;
|
||||
name = _name;
|
||||
}
|
||||
SavedScene(std::string path = "", std::string name = "")
|
||||
: path(path), name(name)
|
||||
{}
|
||||
};
|
||||
|
||||
class CPlayerProfile
|
||||
|
|
|
@ -142,7 +142,6 @@ CRobotMain::CRobotMain()
|
|||
|
||||
m_engine = Gfx::CEngine::GetInstancePointer();
|
||||
m_oldModelManager = m_engine->GetModelManager();
|
||||
m_modelManager = MakeUnique<Gfx::CModelManager>();
|
||||
m_lightMan = m_engine->GetLightManager();
|
||||
m_particle = m_engine->GetParticle();
|
||||
m_water = m_engine->GetWater();
|
||||
|
@ -151,23 +150,24 @@ CRobotMain::CRobotMain()
|
|||
m_planet = m_engine->GetPlanet();
|
||||
m_pause = CPauseManager::GetInstancePointer();
|
||||
m_input = CInput::GetInstancePointer();
|
||||
m_settings = new CSettings();
|
||||
|
||||
m_interface = new Ui::CInterface();
|
||||
m_terrain = new Gfx::CTerrain();
|
||||
m_camera = new Gfx::CCamera();
|
||||
m_displayText = new Ui::CDisplayText();
|
||||
m_movie = new CMainMovie();
|
||||
m_modelManager = MakeUnique<Gfx::CModelManager>();
|
||||
m_settings = MakeUnique<CSettings>();
|
||||
m_interface = MakeUnique<Ui::CInterface>();
|
||||
m_terrain = MakeUnique<Gfx::CTerrain>();
|
||||
m_camera = MakeUnique<Gfx::CCamera>();
|
||||
m_displayText = MakeUnique<Ui::CDisplayText>();
|
||||
m_movie = MakeUnique<CMainMovie>();
|
||||
m_ui = MakeUnique<Ui::CMainUserInterface>();
|
||||
m_short = new Ui::CMainShort();
|
||||
m_map = new Ui::CMainMap();
|
||||
m_displayInfo = nullptr;
|
||||
m_short = MakeUnique<Ui::CMainShort>();
|
||||
m_map = MakeUnique<Ui::CMainMap>();
|
||||
|
||||
m_objMan = new CObjectManager(m_engine,
|
||||
m_terrain,
|
||||
m_oldModelManager,
|
||||
m_modelManager.get(),
|
||||
m_particle);
|
||||
m_objMan = MakeUnique<CObjectManager>(
|
||||
m_engine,
|
||||
m_terrain.get(),
|
||||
m_oldModelManager,
|
||||
m_modelManager.get(),
|
||||
m_particle);
|
||||
|
||||
m_time = 0.0f;
|
||||
m_gameTime = 0.0f;
|
||||
|
@ -266,7 +266,7 @@ CRobotMain::CRobotMain()
|
|||
m_showLimit[i].link = 0;
|
||||
}
|
||||
|
||||
m_engine->SetTerrain(m_terrain);
|
||||
m_engine->SetTerrain(m_terrain.get());
|
||||
|
||||
m_app->SetMouseMode(MOUSE_ENGINE);
|
||||
|
||||
|
@ -286,55 +286,26 @@ CRobotMain::CRobotMain()
|
|||
//! Destructor of robot application
|
||||
CRobotMain::~CRobotMain()
|
||||
{
|
||||
delete m_settings;
|
||||
m_settings = nullptr;
|
||||
|
||||
delete m_displayText;
|
||||
m_displayText = nullptr;
|
||||
|
||||
delete m_interface;
|
||||
m_interface = nullptr;
|
||||
|
||||
delete m_terrain;
|
||||
m_terrain = nullptr;
|
||||
|
||||
delete m_camera;
|
||||
m_camera = nullptr;
|
||||
|
||||
delete m_displayText;
|
||||
m_displayText = nullptr;
|
||||
|
||||
delete m_movie;
|
||||
m_movie = nullptr;
|
||||
|
||||
delete m_short;
|
||||
m_short = nullptr;
|
||||
|
||||
delete m_map;
|
||||
m_map = nullptr;
|
||||
|
||||
delete m_objMan;
|
||||
m_objMan = nullptr;
|
||||
}
|
||||
|
||||
Gfx::CCamera* CRobotMain::GetCamera()
|
||||
{
|
||||
return m_camera;
|
||||
return m_camera.get();
|
||||
}
|
||||
|
||||
Gfx::CTerrain* CRobotMain::GetTerrain()
|
||||
{
|
||||
return m_terrain;
|
||||
return m_terrain.get();
|
||||
}
|
||||
|
||||
Ui::CInterface* CRobotMain::GetInterface()
|
||||
{
|
||||
return m_interface;
|
||||
return m_interface.get();
|
||||
}
|
||||
|
||||
Ui::CDisplayText* CRobotMain::GetDisplayText()
|
||||
{
|
||||
return m_displayText;
|
||||
return m_displayText.get();
|
||||
}
|
||||
|
||||
void CRobotMain::ResetAfterDeviceChanged()
|
||||
|
@ -1415,7 +1386,7 @@ void CRobotMain::StartDisplayInfo(const std::string& filename, int index)
|
|||
|
||||
bool soluce = m_ui->GetSceneSoluce();
|
||||
|
||||
m_displayInfo = new Ui::CDisplayInfo();
|
||||
m_displayInfo = MakeUnique<Ui::CDisplayInfo>();
|
||||
m_displayInfo->StartDisplayInfo(filename, index, soluce);
|
||||
|
||||
m_infoIndex = index;
|
||||
|
@ -1436,8 +1407,7 @@ void CRobotMain::StopDisplayInfo()
|
|||
|
||||
m_displayInfo->StopDisplayInfo();
|
||||
|
||||
delete m_displayInfo;
|
||||
m_displayInfo = nullptr;
|
||||
m_displayInfo.reset();
|
||||
|
||||
if (!m_editLock)
|
||||
{
|
||||
|
@ -4978,9 +4948,8 @@ CObject* CRobotMain::IOReadScene(std::string filename, std::string filecbot)
|
|||
assert(obj->Implements(ObjectInterfaceType::Carrier)); // TODO: exception?
|
||||
assert(obj->Implements(ObjectInterfaceType::Old));
|
||||
dynamic_cast<CCarrierObject*>(obj)->SetCargo(cargo);
|
||||
CTaskManip* task = new CTaskManip(dynamic_cast<COldObject*>(obj));
|
||||
auto task = MakeUnique<CTaskManip>(dynamic_cast<COldObject*>(obj));
|
||||
task->Start(TMO_AUTO, TMA_GRAB); // holds the object!
|
||||
delete task;
|
||||
}
|
||||
|
||||
if (power != nullptr)
|
||||
|
|
|
@ -113,9 +113,9 @@ const int MAXNEWSCRIPTNAME = 20;
|
|||
|
||||
struct NewScriptName
|
||||
{
|
||||
bool used;
|
||||
ObjectType type;
|
||||
char name[40];
|
||||
bool used = false;
|
||||
ObjectType type = OBJECT_NULL;
|
||||
char name[40] = {0};
|
||||
};
|
||||
|
||||
|
||||
|
@ -127,14 +127,14 @@ const int MAXSCENE = 999;
|
|||
|
||||
struct ShowLimit
|
||||
{
|
||||
bool used;
|
||||
bool used = false;
|
||||
Math::Vector pos;
|
||||
float radius;
|
||||
int total;
|
||||
int parti[MAXSHOWPARTI];
|
||||
CObject* link;
|
||||
float duration;
|
||||
float time;
|
||||
float radius = 0.0f;
|
||||
int total = 0;
|
||||
int parti[MAXSHOWPARTI] = {0};
|
||||
CObject* link = nullptr;
|
||||
float duration = 0.0f;
|
||||
float time = 0.0f;
|
||||
};
|
||||
|
||||
|
||||
|
@ -417,156 +417,156 @@ protected:
|
|||
|
||||
|
||||
protected:
|
||||
CController* m_ctrl;
|
||||
CApplication* m_app;
|
||||
CObjectManager* m_objMan;
|
||||
CEventQueue* m_eventQueue;
|
||||
CMainMovie* m_movie;
|
||||
Gfx::CEngine* m_engine;
|
||||
Gfx::CParticle* m_particle;
|
||||
Gfx::CWater* m_water;
|
||||
Gfx::CCloud* m_cloud;
|
||||
Gfx::CLightning* m_lightning;
|
||||
Gfx::CPlanet* m_planet;
|
||||
Gfx::COldModelManager* m_oldModelManager;
|
||||
CController* m_ctrl = nullptr;
|
||||
CApplication* m_app = nullptr;
|
||||
CEventQueue* m_eventQueue = nullptr;
|
||||
Gfx::CEngine* m_engine = nullptr;
|
||||
Gfx::CParticle* m_particle = nullptr;
|
||||
Gfx::CWater* m_water = nullptr;
|
||||
Gfx::CCloud* m_cloud = nullptr;
|
||||
Gfx::CLightning* m_lightning = nullptr;
|
||||
Gfx::CPlanet* m_planet = nullptr;
|
||||
Gfx::COldModelManager* m_oldModelManager = nullptr;
|
||||
Gfx::CLightManager* m_lightMan = nullptr;
|
||||
CSoundInterface* m_sound = nullptr;
|
||||
CPauseManager* m_pause = nullptr;
|
||||
CInput* m_input = nullptr;
|
||||
std::unique_ptr<CObjectManager> m_objMan;
|
||||
std::unique_ptr<CMainMovie> m_movie;
|
||||
std::unique_ptr<Gfx::CModelManager> m_modelManager;
|
||||
Gfx::CLightManager* m_lightMan;
|
||||
Gfx::CTerrain* m_terrain;
|
||||
Gfx::CCamera* m_camera;
|
||||
std::unique_ptr<Gfx::CTerrain> m_terrain;
|
||||
std::unique_ptr<Gfx::CCamera> m_camera;
|
||||
std::unique_ptr<Ui::CMainUserInterface> m_ui;
|
||||
Ui::CMainShort* m_short;
|
||||
Ui::CMainMap* m_map;
|
||||
Ui::CInterface* m_interface;
|
||||
Ui::CDisplayText* m_displayText;
|
||||
Ui::CDisplayInfo* m_displayInfo;
|
||||
CSoundInterface* m_sound;
|
||||
CPauseManager* m_pause;
|
||||
CInput* m_input;
|
||||
CSettings* m_settings;
|
||||
std::unique_ptr<Ui::CMainShort> m_short;
|
||||
std::unique_ptr<Ui::CMainMap> m_map;
|
||||
std::unique_ptr<Ui::CInterface> m_interface;
|
||||
std::unique_ptr<Ui::CDisplayInfo> m_displayInfo;
|
||||
std::unique_ptr<Ui::CDisplayText> m_displayText;
|
||||
std::unique_ptr<CSettings> m_settings;
|
||||
|
||||
//! Progress of loaded player
|
||||
std::unique_ptr<CPlayerProfile> m_playerProfile;
|
||||
|
||||
|
||||
//! Time since level start, including pause and intro movie
|
||||
float m_time;
|
||||
float m_time = 0.0f;
|
||||
//! Playing time since level start
|
||||
float m_gameTime;
|
||||
float m_gameTime = 0.0f;
|
||||
//! Playing time since level start, not dependent on simulation speed
|
||||
float m_gameTimeAbsolute;
|
||||
float m_gameTimeAbsolute = 0.0f;
|
||||
|
||||
LevelCategory m_levelCategory;
|
||||
int m_levelChap;
|
||||
int m_levelRank;
|
||||
int m_levelChap = 0;
|
||||
int m_levelRank = 0;
|
||||
std::string m_sceneReadPath;
|
||||
|
||||
float m_winDelay;
|
||||
float m_lostDelay;
|
||||
bool m_fixScene; // scene fixed, no interraction
|
||||
CObject* m_base; // OBJECT_BASE exists in mission
|
||||
float m_winDelay = 0.0f;
|
||||
float m_lostDelay = 0.0f;
|
||||
bool m_fixScene = false; // scene fixed, no interraction
|
||||
CObject* m_base = nullptr; // OBJECT_BASE exists in mission
|
||||
Math::Point m_lastMousePos;
|
||||
CObject* m_selectObject;
|
||||
CObject* m_selectObject = nullptr;
|
||||
|
||||
Phase m_phase;
|
||||
int m_cameraRank;
|
||||
Phase m_phase = PHASE_WELCOME1;
|
||||
int m_cameraRank = 0;
|
||||
Gfx::Color m_color;
|
||||
bool m_freePhoto;
|
||||
bool m_cmdEdit;
|
||||
bool m_selectInsect;
|
||||
bool m_showSoluce;
|
||||
bool m_showAll;
|
||||
bool m_cheatRadar;
|
||||
bool m_shortCut;
|
||||
bool m_freePhoto = false;
|
||||
bool m_cmdEdit = false;
|
||||
bool m_selectInsect = false;
|
||||
bool m_showSoluce = false;
|
||||
bool m_showAll = false;
|
||||
bool m_cheatRadar = false;
|
||||
bool m_shortCut = false;
|
||||
std::string m_audioTrack;
|
||||
bool m_audioRepeat;
|
||||
bool m_audioRepeat = false;
|
||||
std::string m_satcomTrack;
|
||||
bool m_satcomRepeat;
|
||||
bool m_satcomRepeat = false;
|
||||
std::string m_editorTrack;
|
||||
bool m_editorRepeat;
|
||||
int m_movieInfoIndex;
|
||||
bool m_editorRepeat = false;
|
||||
int m_movieInfoIndex = 0;
|
||||
|
||||
CObject* m_controller;
|
||||
CObject* m_controller = nullptr;
|
||||
|
||||
MissionType m_missionType;
|
||||
bool m_immediatSatCom; // SatCom immediately?
|
||||
bool m_beginSatCom; // messages SatCom poster?
|
||||
bool m_lockedSatCom; // SatCom locked?
|
||||
bool m_movieLock; // movie in progress?
|
||||
bool m_satComLock; // call of SatCom is possible?
|
||||
bool m_editLock; // edition in progress?
|
||||
bool m_editFull; // edition in full screen?
|
||||
bool m_hilite;
|
||||
bool m_trainerPilot; // remote trainer?
|
||||
bool m_friendAim;
|
||||
bool m_resetCreate;
|
||||
bool m_mapShow;
|
||||
bool m_mapImage;
|
||||
char m_mapFilename[100];
|
||||
MissionType m_missionType = MISSION_NORMAL;
|
||||
bool m_immediatSatCom = false; // SatCom immediately?
|
||||
bool m_beginSatCom = false; // messages SatCom poster?
|
||||
bool m_lockedSatCom = false; // SatCom locked?
|
||||
bool m_movieLock = false; // movie in progress?
|
||||
bool m_satComLock = false; // call of SatCom is possible?
|
||||
bool m_editLock = false; // edition in progress?
|
||||
bool m_editFull = false; // edition in full screen?
|
||||
bool m_hilite = false;
|
||||
bool m_trainerPilot = false; // remote trainer?
|
||||
bool m_friendAim = false;
|
||||
bool m_resetCreate = false;
|
||||
bool m_mapShow = false;
|
||||
bool m_mapImage = false;
|
||||
char m_mapFilename[100] = {};
|
||||
|
||||
bool m_suspend;
|
||||
PauseType m_suspendInitPause;
|
||||
Gfx::CameraType m_suspendInitCamera;
|
||||
bool m_suspend = false;
|
||||
PauseType m_suspendInitPause = PAUSE_NONE;
|
||||
Gfx::CameraType m_suspendInitCamera = Gfx::CAM_TYPE_NULL;
|
||||
|
||||
Math::Point m_tooltipPos;
|
||||
std::string m_tooltipName;
|
||||
float m_tooltipTime;
|
||||
float m_tooltipTime = 0.0f;
|
||||
|
||||
char m_infoFilename[SATCOM_MAX][100]; // names of text files
|
||||
CObject* m_infoObject;
|
||||
int m_infoIndex;
|
||||
int m_infoPos[SATCOM_MAX];
|
||||
int m_infoUsed;
|
||||
char m_infoFilename[SATCOM_MAX][100] = {}; // names of text files
|
||||
CObject* m_infoObject = nullptr;
|
||||
int m_infoIndex = 0;
|
||||
int m_infoPos[SATCOM_MAX] = {};
|
||||
int m_infoUsed = 0;
|
||||
|
||||
char m_title[100];
|
||||
char m_resume[500];
|
||||
char m_scriptName[100];
|
||||
char m_scriptFile[100];
|
||||
int m_endingWinRank;
|
||||
int m_endingLostRank;
|
||||
bool m_winTerminate;
|
||||
char m_title[100] = {};
|
||||
char m_resume[500] = {};
|
||||
char m_scriptName[100] = {};
|
||||
char m_scriptFile[100] = {};
|
||||
int m_endingWinRank = 0;
|
||||
int m_endingLostRank = 0;
|
||||
bool m_winTerminate = false;
|
||||
|
||||
float m_globalMagnifyDamage;
|
||||
float m_globalMagnifyDamage = 0.0f;
|
||||
|
||||
bool m_exitAfterMission;
|
||||
bool m_exitAfterMission = false;
|
||||
|
||||
bool m_codeBattleInit;
|
||||
bool m_codeBattleStarted;
|
||||
bool m_codeBattleInit = false;
|
||||
bool m_codeBattleStarted = false;
|
||||
|
||||
std::map<int, std::string> m_teamNames;
|
||||
|
||||
NewScriptName m_newScriptName[MAXNEWSCRIPTNAME];
|
||||
|
||||
float m_cameraPan;
|
||||
float m_cameraZoom;
|
||||
float m_cameraPan = 0.0f;
|
||||
float m_cameraZoom = 0.0f;
|
||||
|
||||
EventType m_visitLast;
|
||||
CObject* m_visitObject;
|
||||
CObject* m_visitArrow;
|
||||
float m_visitTime;
|
||||
float m_visitParticle;
|
||||
EventType m_visitLast = EVENT_NULL;
|
||||
CObject* m_visitObject = nullptr;
|
||||
CObject* m_visitArrow = nullptr;
|
||||
float m_visitTime = 0.0f;
|
||||
float m_visitParticle = 0.0f;
|
||||
Math::Vector m_visitPos;
|
||||
Math::Vector m_visitPosArrow;
|
||||
|
||||
std::vector<std::unique_ptr<CSceneEndCondition>> m_endTake;
|
||||
long m_endTakeResearch;
|
||||
float m_endTakeWinDelay;
|
||||
float m_endTakeLostDelay;
|
||||
long m_endTakeResearch = 0;
|
||||
float m_endTakeWinDelay = 0.0f;
|
||||
float m_endTakeLostDelay = 0.0f;
|
||||
|
||||
std::vector<std::unique_ptr<CAudioChangeCondition>> m_audioChange;
|
||||
|
||||
int m_obligatoryTotal;
|
||||
char m_obligatoryToken[100][20];
|
||||
int m_prohibitedTotal;
|
||||
char m_prohibitedToken[100][20];
|
||||
int m_obligatoryTotal = 0;
|
||||
char m_obligatoryToken[100][20] = {};
|
||||
int m_prohibitedTotal = 0;
|
||||
char m_prohibitedToken[100][20] = {};
|
||||
|
||||
//! Enabled buildings
|
||||
int m_build;
|
||||
int m_build = 0;
|
||||
//! Available researches
|
||||
long m_researchEnable;
|
||||
long m_researchEnable = 0;
|
||||
//! Done researches for each team
|
||||
std::map<int, int> m_researchDone;
|
||||
|
||||
Error m_missionResult;
|
||||
Error m_missionResult = ERR_OK;
|
||||
|
||||
ShowLimit m_showLimit[MAXSHOWLIMIT];
|
||||
|
||||
|
@ -578,18 +578,18 @@ protected:
|
|||
Gfx::Color m_colorNewGreen;
|
||||
Gfx::Color m_colorRefWater;
|
||||
Gfx::Color m_colorNewWater;
|
||||
float m_colorShiftWater;
|
||||
float m_colorShiftWater = 0.0f;
|
||||
|
||||
bool m_missionTimerEnabled;
|
||||
bool m_missionTimerStarted;
|
||||
float m_missionTimer;
|
||||
bool m_missionTimerEnabled = false;
|
||||
bool m_missionTimerStarted = false;
|
||||
float m_missionTimer = 0.0f;
|
||||
|
||||
bool m_autosave;
|
||||
int m_autosaveInterval;
|
||||
int m_autosaveSlots;
|
||||
float m_autosaveLast;
|
||||
bool m_autosave = false;
|
||||
int m_autosaveInterval = 0;
|
||||
int m_autosaveSlots = 0;
|
||||
float m_autosaveLast = 0.0f;
|
||||
|
||||
int m_shotSaving;
|
||||
int m_shotSaving = 0;
|
||||
|
||||
std::deque<CObject*> m_selectionHistory;
|
||||
};
|
||||
|
|
|
@ -70,14 +70,16 @@ struct Matrix
|
|||
float m[16];
|
||||
|
||||
//! Creates the indentity matrix
|
||||
inline Matrix()
|
||||
Matrix()
|
||||
: m()
|
||||
{
|
||||
LoadIdentity();
|
||||
}
|
||||
|
||||
//! Creates the matrix from 1D array
|
||||
/** \a m matrix values in column-major order */
|
||||
inline explicit Matrix(const float (&_m)[16])
|
||||
explicit Matrix(const float (&_m)[16])
|
||||
: m()
|
||||
{
|
||||
for (int i = 0; i < 16; ++i)
|
||||
m[i] = _m[i];
|
||||
|
@ -88,7 +90,8 @@ struct Matrix
|
|||
* The array's first index is row, second is column.
|
||||
* \param m array with values
|
||||
*/
|
||||
inline explicit Matrix(const float (&_m)[4][4])
|
||||
explicit Matrix(const float (&_m)[4][4])
|
||||
: m()
|
||||
{
|
||||
for (int c = 0; c < 4; ++c)
|
||||
{
|
||||
|
@ -105,7 +108,7 @@ struct Matrix
|
|||
* \param col column (1 to 4)
|
||||
* \param value value
|
||||
*/
|
||||
inline void Set(int row, int col, float value)
|
||||
void Set(int row, int col, float value)
|
||||
{
|
||||
m[(col-1)*4+(row-1)] = value;
|
||||
}
|
||||
|
@ -116,20 +119,20 @@ struct Matrix
|
|||
* \param col column (1 to 4)
|
||||
* \returns value
|
||||
*/
|
||||
inline float Get(int row, int col)
|
||||
float Get(int row, int col)
|
||||
{
|
||||
return m[(col-1)*4+(row-1)];
|
||||
}
|
||||
|
||||
//! Loads the zero matrix
|
||||
inline void LoadZero()
|
||||
void LoadZero()
|
||||
{
|
||||
for (int i = 0; i < 16; ++i)
|
||||
m[i] = 0.0f;
|
||||
}
|
||||
|
||||
//! Loads the identity matrix
|
||||
inline void LoadIdentity()
|
||||
void LoadIdentity()
|
||||
{
|
||||
LoadZero();
|
||||
/* (1,1) */ m[0 ] = 1.0f;
|
||||
|
@ -139,13 +142,13 @@ struct Matrix
|
|||
}
|
||||
|
||||
//! Returns the struct cast to \c float* array; use with care!
|
||||
inline float* Array()
|
||||
float* Array()
|
||||
{
|
||||
return reinterpret_cast<float*>(this);
|
||||
}
|
||||
|
||||
//! Transposes the matrix
|
||||
inline void Transpose()
|
||||
void Transpose()
|
||||
{
|
||||
/* (2,1) <-> (1,2) */ Swap(m[1 ], m[4 ]);
|
||||
/* (3,1) <-> (1,3) */ Swap(m[2 ], m[8 ]);
|
||||
|
@ -157,7 +160,7 @@ struct Matrix
|
|||
|
||||
//! Calculates the determinant of the matrix
|
||||
/** \returns the determinant */
|
||||
inline float Det() const
|
||||
float Det() const
|
||||
{
|
||||
float result = 0.0f;
|
||||
for (int i = 0; i < 4; ++i)
|
||||
|
@ -173,7 +176,7 @@ struct Matrix
|
|||
* \param c column (0 to 3)
|
||||
* \returns the cofactor
|
||||
*/
|
||||
inline float Cofactor(int r, int c) const
|
||||
float Cofactor(int r, int c) const
|
||||
{
|
||||
assert(r >= 0 && r <= 3);
|
||||
assert(c >= 0 && c <= 3);
|
||||
|
@ -356,7 +359,7 @@ struct Matrix
|
|||
* The determinant of the matrix must not be zero.
|
||||
* \returns the inverted matrix
|
||||
*/
|
||||
inline Matrix Inverse() const
|
||||
Matrix Inverse() const
|
||||
{
|
||||
float d = Det();
|
||||
assert(! IsZero(d));
|
||||
|
@ -380,7 +383,7 @@ struct Matrix
|
|||
* \param right right-hand matrix
|
||||
* \returns multiplication result
|
||||
*/
|
||||
inline Matrix Multiply(const Matrix &right) const
|
||||
Matrix Multiply(const Matrix &right) const
|
||||
{
|
||||
float result[16] = { 0.0f };
|
||||
|
||||
|
|
|
@ -98,26 +98,26 @@ protected:
|
|||
void UpdateInterface(float rTime);
|
||||
|
||||
protected:
|
||||
CEventQueue* m_eventQueue;
|
||||
Gfx::CEngine* m_engine;
|
||||
Gfx::CParticle* m_particle;
|
||||
Gfx::CTerrain* m_terrain;
|
||||
Gfx::CWater* m_water;
|
||||
Gfx::CCloud* m_cloud;
|
||||
Gfx::CPlanet* m_planet;
|
||||
Gfx::CLightning* m_lightning;
|
||||
Gfx::CCamera* m_camera;
|
||||
Ui::CInterface* m_interface;
|
||||
CRobotMain* m_main;
|
||||
COldObject* m_object;
|
||||
CSoundInterface* m_sound;
|
||||
CEventQueue* m_eventQueue = nullptr;
|
||||
Gfx::CEngine* m_engine = nullptr;
|
||||
Gfx::CParticle* m_particle = nullptr;
|
||||
Gfx::CTerrain* m_terrain = nullptr;
|
||||
Gfx::CWater* m_water = nullptr;
|
||||
Gfx::CCloud* m_cloud = nullptr;
|
||||
Gfx::CPlanet* m_planet = nullptr;
|
||||
Gfx::CLightning* m_lightning = nullptr;
|
||||
Gfx::CCamera* m_camera = nullptr;
|
||||
Ui::CInterface* m_interface = nullptr;
|
||||
CRobotMain* m_main = nullptr;
|
||||
COldObject* m_object = nullptr;
|
||||
CSoundInterface* m_sound = nullptr;
|
||||
|
||||
ObjectType m_type;
|
||||
bool m_bBusy;
|
||||
bool m_bMotor;
|
||||
float m_time;
|
||||
float m_lastUpdateTime;
|
||||
float m_progressTime;
|
||||
float m_progressTotal;
|
||||
ObjectType m_type = OBJECT_NULL;
|
||||
bool m_bBusy = false;
|
||||
bool m_bMotor = false;
|
||||
float m_time = 0.0f;
|
||||
float m_lastUpdateTime = 0.0f;
|
||||
float m_progressTime = 0.0f;
|
||||
float m_progressTotal = 0.0f;
|
||||
};
|
||||
|
||||
|
|
|
@ -95,21 +95,21 @@ protected:
|
|||
void EndTransit();
|
||||
|
||||
protected:
|
||||
AutoBasePhase m_phase;
|
||||
bool m_bOpen;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_lastParticle;
|
||||
float m_lastMotorParticle;
|
||||
float m_fogStart;
|
||||
float m_deepView;
|
||||
AutoBasePhase m_phase = ABP_WAIT;
|
||||
bool m_bOpen = false;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
float m_lastMotorParticle = 0.0f;
|
||||
float m_fogStart = 0.0f;
|
||||
float m_deepView = 0.0f;
|
||||
Math::Vector m_pos;
|
||||
Math::Vector m_posSound;
|
||||
Math::Vector m_finalPos;
|
||||
Math::Vector m_lastPos;
|
||||
int m_param;
|
||||
int m_soundChannel;
|
||||
int m_partiChannel[8];
|
||||
int m_param = 0;
|
||||
int m_soundChannel = 0;
|
||||
int m_partiChannel[8] = {};
|
||||
|
||||
std::string m_bgBack;
|
||||
std::string m_bgName;
|
||||
|
|
|
@ -62,12 +62,12 @@ protected:
|
|||
void CreateMetal();
|
||||
|
||||
protected:
|
||||
AutoConvertPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_timeVirus;
|
||||
float m_lastParticle;
|
||||
bool m_bSoundClose;
|
||||
int m_soundChannel;
|
||||
AutoConvertPhase m_phase = ACP_STOP;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_timeVirus = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
bool m_bSoundClose = false;
|
||||
int m_soundChannel = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -62,14 +62,14 @@ protected:
|
|||
bool ExistKey();
|
||||
|
||||
protected:
|
||||
AutoDerrickPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_timeVirus;
|
||||
float m_lastParticle;
|
||||
float m_lastTrack;
|
||||
AutoDerrickPhase m_phase = ADP_WAIT;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_timeVirus = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
float m_lastTrack = 0.0f;
|
||||
Math::Vector m_cargoPos;
|
||||
int m_soundChannel;
|
||||
bool m_bSoundFall;
|
||||
int m_soundChannel = 0;
|
||||
bool m_bSoundFall = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -62,11 +62,11 @@ protected:
|
|||
void EnableInterface(Ui::CWindow *pw, EventType event, bool bState);
|
||||
|
||||
protected:
|
||||
AutoDestroyerPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_timeVirus;
|
||||
float m_lastParticle;
|
||||
bool m_bExplo;
|
||||
AutoDestroyerPhase m_phase = ADEP_WAIT;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_timeVirus = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
bool m_bExplo = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -65,12 +65,12 @@ protected:
|
|||
CObject* SearchAlien();
|
||||
|
||||
protected:
|
||||
ObjectType m_type;
|
||||
float m_value;
|
||||
ObjectType m_type = OBJECT_NULL;
|
||||
float m_value = 0.0f;
|
||||
std::string m_alienProgramName;
|
||||
int m_param;
|
||||
AutoEggPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
int m_param = 0;
|
||||
AutoEggPhase m_phase = AEP_NULL;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
};
|
||||
|
||||
|
|
|
@ -70,12 +70,12 @@ protected:
|
|||
void SoundManip(float time, float amplitude, float frequency);
|
||||
|
||||
protected:
|
||||
AutoFactoryPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_lastParticle;
|
||||
AutoFactoryPhase m_phase = AFP_WAIT;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
Math::Vector m_cargoPos;
|
||||
int m_channelSound;
|
||||
int m_channelSound = 0;
|
||||
|
||||
std::string m_program;
|
||||
};
|
||||
|
|
|
@ -40,10 +40,8 @@ public:
|
|||
Error GetError();
|
||||
|
||||
protected:
|
||||
|
||||
protected:
|
||||
float m_strong;
|
||||
int m_param;
|
||||
float m_progress;
|
||||
float m_strong = 0.0f;
|
||||
int m_param = 0;
|
||||
float m_progress = 0.0f;
|
||||
};
|
||||
|
||||
|
|
|
@ -30,12 +30,12 @@
|
|||
|
||||
struct HustonLens
|
||||
{
|
||||
int parti;
|
||||
Gfx::ParticleType type;
|
||||
int parti = 0;
|
||||
Gfx::ParticleType type = {};
|
||||
Math::Vector pos;
|
||||
float dim;
|
||||
float total;
|
||||
float off;
|
||||
float dim = 0.0f;
|
||||
float total = 0.0f;
|
||||
float off = 0.0f;
|
||||
};
|
||||
|
||||
|
||||
|
@ -59,11 +59,9 @@ public:
|
|||
bool CreateInterface(bool bSelect);
|
||||
|
||||
protected:
|
||||
|
||||
protected:
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
HustonLens m_lens[HUSTONMAXLENS];
|
||||
int m_lensTotal;
|
||||
int m_lensTotal = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -44,10 +44,10 @@ private:
|
|||
void Start(int param) override;
|
||||
|
||||
protected:
|
||||
float m_force;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_lastParticle;
|
||||
Error m_error;
|
||||
float m_force = 0.0f;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
Error m_error = ERR_OK;
|
||||
};
|
||||
|
||||
|
|
|
@ -66,13 +66,13 @@ protected:
|
|||
void SoundManip(float time, float amplitude, float frequency);
|
||||
|
||||
protected:
|
||||
AutoLaboPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_timeVirus;
|
||||
float m_lastParticle;
|
||||
ResearchType m_research;
|
||||
int m_partiRank[3];
|
||||
int m_partiSphere;
|
||||
int m_soundChannel;
|
||||
AutoLaboPhase m_phase = ALAP_WAIT;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_timeVirus = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
ResearchType m_research = {};
|
||||
int m_partiRank[3] = {};
|
||||
int m_partiSphere = 0;
|
||||
int m_soundChannel = 0;
|
||||
};
|
||||
|
|
|
@ -56,9 +56,9 @@ protected:
|
|||
bool SearchTarget();
|
||||
|
||||
protected:
|
||||
AutoMushPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_lastParticle;
|
||||
AutoMushPhase m_phase = AMP_WAIT;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
};
|
||||
|
||||
|
|
|
@ -56,10 +56,10 @@ protected:
|
|||
CObject* SearchCargo();
|
||||
|
||||
protected:
|
||||
AutoNestPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_lastParticle;
|
||||
AutoNestPhase m_phase = ANP_WAIT;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
Math::Vector m_cargoPos;
|
||||
};
|
||||
|
||||
|
|
|
@ -61,12 +61,12 @@ protected:
|
|||
void CreatePower();
|
||||
|
||||
protected:
|
||||
AutoNuclearPlantPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_timeVirus;
|
||||
float m_lastParticle;
|
||||
AutoNuclearPlantPhase m_phase = ANUP_STOP;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_timeVirus = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
Math::Vector m_pos;
|
||||
int m_channelSound;
|
||||
int m_channelSound = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -57,16 +57,16 @@ protected:
|
|||
void UpdateTrackMapping(float left, float right);
|
||||
|
||||
protected:
|
||||
AutoPorticoPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_cameraProgress;
|
||||
float m_cameraSpeed;
|
||||
float m_lastParticle;
|
||||
AutoPorticoPhase m_phase = APOP_WAIT;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_cameraProgress = 0.0f;
|
||||
float m_cameraSpeed = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
Math::Vector m_finalPos;
|
||||
Math::Vector m_startPos;
|
||||
float m_posTrack;
|
||||
int m_param;
|
||||
int m_soundChannel;
|
||||
float m_posTrack = 0.0f;
|
||||
int m_param = 0;
|
||||
int m_soundChannel = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -57,12 +57,12 @@ protected:
|
|||
void ChargeObject(float rTime);
|
||||
|
||||
protected:
|
||||
AutoPowerCaptorPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_timeVirus;
|
||||
float m_lastParticle;
|
||||
AutoPowerCaptorPhase m_phase = APAP_WAIT;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_timeVirus = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
Math::Vector m_pos;
|
||||
int m_channelSound;
|
||||
int m_channelSound = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -65,12 +65,12 @@ protected:
|
|||
CObject* SearchPower();
|
||||
|
||||
protected:
|
||||
AutoPowerPlantPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_timeVirus;
|
||||
float m_lastUpdateTime;
|
||||
float m_lastParticle;
|
||||
int m_partiSphere;
|
||||
AutoPowerPlantPhase m_phase = AENP_STOP;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0;
|
||||
float m_timeVirus = 0.0f;
|
||||
float m_lastUpdateTime = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
int m_partiSphere = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -47,14 +47,14 @@ protected:
|
|||
CObject* SearchVehicle();
|
||||
|
||||
protected:
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_timeVirus;
|
||||
float m_lastUpdateTime;
|
||||
float m_lastParticle;
|
||||
int m_soundChannel;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_timeVirus = 0.0f;
|
||||
float m_lastUpdateTime = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
int m_soundChannel = 0;
|
||||
Math::Vector m_cargoPos;
|
||||
bool m_bLastVirus;
|
||||
float m_energyVirus;
|
||||
bool m_bLastVirus = false;
|
||||
float m_energyVirus = 0.0f;
|
||||
};
|
||||
|
||||
|
|
|
@ -54,14 +54,14 @@ protected:
|
|||
bool SearchEnemy(Math::Vector &pos);
|
||||
|
||||
protected:
|
||||
AutoRadarPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_aTime;
|
||||
float m_timeVirus;
|
||||
float m_lastParticle;
|
||||
float m_angle;
|
||||
float m_start;
|
||||
int m_totalDetect;
|
||||
AutoRadarPhase m_phase = ARAP_WAIT;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_aTime = 0.0f;
|
||||
float m_timeVirus = 0.0f;
|
||||
float m_lastParticle =0.0f;
|
||||
float m_angle = 0.0f;
|
||||
float m_start = 0.0f;
|
||||
int m_totalDetect = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -59,10 +59,10 @@ protected:
|
|||
CObject* SearchVehicle();
|
||||
|
||||
protected:
|
||||
AutoRepairPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_timeVirus;
|
||||
float m_lastParticle;
|
||||
AutoRepairPhase m_phase = ARP_WAIT;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_timeVirus = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
};
|
||||
|
||||
|
|
|
@ -59,14 +59,14 @@ protected:
|
|||
void FireStopUpdate(float progress, bool bLightOn);
|
||||
|
||||
protected:
|
||||
AutoResearchPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_timeVirus;
|
||||
float m_lastUpdateTime;
|
||||
float m_lastParticle;
|
||||
ResearchType m_research;
|
||||
int m_partiStop[6];
|
||||
int m_channelSound;
|
||||
AutoResearchPhase m_phase = ALP_WAIT;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_timeVirus = 0.0f;
|
||||
float m_lastUpdateTime = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
ResearchType m_research = {};
|
||||
int m_partiStop[6] = {};
|
||||
int m_channelSound = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
protected:
|
||||
|
||||
protected:
|
||||
float m_lastParticle;
|
||||
float m_lastParticle = 0.0f;
|
||||
Math::Vector m_center;
|
||||
};
|
||||
|
||||
|
|
|
@ -62,17 +62,17 @@ protected:
|
|||
void FireStopUpdate(float progress, bool bLightOn);
|
||||
|
||||
protected:
|
||||
AutoTowerPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_timeVirus;
|
||||
float m_lastUpdateTime;
|
||||
float m_lastParticle;
|
||||
AutoTowerPhase m_phase = ATP_WAIT;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_timeVirus = 0.0f;
|
||||
float m_lastUpdateTime = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
Math::Vector m_targetPos;
|
||||
float m_angleYactual;
|
||||
float m_angleZactual;
|
||||
float m_angleYfinal;
|
||||
float m_angleZfinal;
|
||||
int m_partiStop[4];
|
||||
float m_angleYactual = 0.0f;
|
||||
float m_angleZactual = 0.0f;
|
||||
float m_angleYfinal = 0.0f;
|
||||
float m_angleZfinal = 0.0f;
|
||||
int m_partiStop[4] = {};
|
||||
};
|
||||
|
||||
|
|
|
@ -61,18 +61,18 @@ protected:
|
|||
CObject* SearchVehicle();
|
||||
|
||||
protected:
|
||||
AutoVaultPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_timeVirus;
|
||||
float m_lastParticle;
|
||||
int m_channelSound;
|
||||
bool m_bLock;
|
||||
int m_countKeys;
|
||||
float m_actualAngle;
|
||||
float m_finalAngle;
|
||||
bool m_bKey[4];
|
||||
AutoVaultPhase m_phase = ASAP_WAIT;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_timeVirus = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
int m_channelSound = 0;
|
||||
bool m_bLock = false;
|
||||
int m_countKeys = 0;
|
||||
float m_actualAngle = 0.0f;
|
||||
float m_finalAngle = 0.0f;
|
||||
bool m_bKey[4] = {};
|
||||
Math::Vector m_keyPos[4];
|
||||
int m_keyParti[4];
|
||||
int m_keyParti[4] = {};
|
||||
};
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "object/implementation/power_container_impl.h"
|
||||
|
||||
CPowerContainerObjectImpl::CPowerContainerObjectImpl(ObjectInterfaceTypes& types, CObject* object)
|
||||
CPowerContainerObjectImpl::CPowerContainerObjectImpl(ObjectInterfaceTypes& types)
|
||||
: CPowerContainerObject(types)
|
||||
, m_energyLevel(1.0f)
|
||||
{}
|
||||
|
|
|
@ -26,7 +26,7 @@ class CObject;
|
|||
class CPowerContainerObjectImpl : public CPowerContainerObject
|
||||
{
|
||||
public:
|
||||
explicit CPowerContainerObjectImpl(ObjectInterfaceTypes& types, CObject* object);
|
||||
explicit CPowerContainerObjectImpl(ObjectInterfaceTypes& types);
|
||||
virtual ~CPowerContainerObjectImpl();
|
||||
|
||||
void SetEnergyLevel(float level) override;
|
||||
|
|
|
@ -42,16 +42,20 @@
|
|||
#include <iomanip>
|
||||
|
||||
CProgrammableObjectImpl::CProgrammableObjectImpl(ObjectInterfaceTypes& types, CObject* object)
|
||||
: CProgrammableObject(types)
|
||||
, m_object(object)
|
||||
, m_activity(true)
|
||||
, m_cmdLine()
|
||||
, m_program()
|
||||
, m_currentProgram(nullptr)
|
||||
, m_activeVirus(false)
|
||||
, m_scriptRun(nullptr)
|
||||
, m_soluceName("")
|
||||
, m_traceRecord(false)
|
||||
: CProgrammableObject(types),
|
||||
m_object(object),
|
||||
m_activity(true),
|
||||
m_cmdLine(),
|
||||
m_program(),
|
||||
m_currentProgram(nullptr),
|
||||
m_activeVirus(false),
|
||||
m_scriptRun(nullptr),
|
||||
m_soluceName(""),
|
||||
m_traceRecord(false),
|
||||
m_traceOper(TO_STOP),
|
||||
m_traceAngle(0.0f),
|
||||
m_traceColor(TraceColor::Default),
|
||||
m_traceRecordIndex(0)
|
||||
{
|
||||
//assert(m_object->Implements(ObjectInterfaceType::TaskExecutor));
|
||||
}
|
||||
|
@ -208,11 +212,10 @@ Program* CProgrammableObjectImpl::CloneProgram(Program* program)
|
|||
Program* newprog = AddProgram();
|
||||
|
||||
// TODO: Is there any reason CScript doesn't have a function to get the program code directly?
|
||||
Ui::CEdit* edit = new Ui::CEdit();
|
||||
auto edit = MakeUnique<Ui::CEdit>();
|
||||
edit->SetMaxChar(Ui::EDITSTUDIOMAX);
|
||||
program->script->PutScript(edit, "");
|
||||
newprog->script->GetScript(edit);
|
||||
delete edit;
|
||||
program->script->PutScript(edit.get(), "");
|
||||
newprog->script->GetScript(edit.get());
|
||||
|
||||
return newprog;
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@ enum TraceOper
|
|||
|
||||
struct TraceRecord
|
||||
{
|
||||
TraceOper oper;
|
||||
float param;
|
||||
TraceOper oper = TO_STOP;
|
||||
float param = 0.0f;
|
||||
};
|
||||
|
||||
class CProgrammableObjectImpl : public CProgrammableObject
|
||||
|
|
|
@ -31,8 +31,8 @@ struct Program
|
|||
{
|
||||
std::unique_ptr<CScript> script;
|
||||
std::string filename;
|
||||
bool readOnly;
|
||||
bool runnable;
|
||||
bool readOnly = false;
|
||||
bool runnable = false;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,7 +39,9 @@ const float START_TIME = 1000.0f; // beginning of the relative time
|
|||
|
||||
// Object's constructor.
|
||||
|
||||
CMotionAnt::CMotionAnt(COldObject* object) : CMotion(object)
|
||||
CMotionAnt::CMotionAnt(COldObject* object)
|
||||
: CMotion(object),
|
||||
m_armAngles()
|
||||
{
|
||||
m_armMember = START_TIME;
|
||||
m_armTimeAbs = START_TIME;
|
||||
|
|
|
@ -38,7 +38,9 @@ const float START_TIME = 1000.0f; // beginning of the relative time
|
|||
|
||||
// Object's constructor.
|
||||
|
||||
CMotionBee::CMotionBee(COldObject* object) : CMotion(object)
|
||||
CMotionBee::CMotionBee(COldObject* object)
|
||||
: CMotion(object),
|
||||
m_armAngles()
|
||||
{
|
||||
m_armMember = START_TIME;
|
||||
m_armTimeAbs = START_TIME;
|
||||
|
|
|
@ -50,7 +50,9 @@ const float START_TIME = 1000.0f; // beginning of the relative time
|
|||
|
||||
// Object's constructor.
|
||||
|
||||
CMotionHuman::CMotionHuman(COldObject* object) : CMotion(object)
|
||||
CMotionHuman::CMotionHuman(COldObject* object)
|
||||
: CMotion(object),
|
||||
m_armAngles()
|
||||
{
|
||||
m_partiReactor = -1;
|
||||
m_armMember = START_TIME;
|
||||
|
|
|
@ -38,7 +38,9 @@ const float START_TIME = 1000.0f; // beginning of the relative time
|
|||
|
||||
// Object's constructor.
|
||||
|
||||
CMotionQueen::CMotionQueen(COldObject* object) : CMotion(object)
|
||||
CMotionQueen::CMotionQueen(COldObject* object)
|
||||
: CMotion(object),
|
||||
m_armAngles()
|
||||
{
|
||||
m_armMember = START_TIME;
|
||||
m_armTimeAbs = START_TIME;
|
||||
|
|
|
@ -39,7 +39,9 @@ const float START_TIME = 1000.0f; // beginning of the relative time
|
|||
|
||||
// Object's constructor.
|
||||
|
||||
CMotionSpider::CMotionSpider(COldObject* object) : CMotion(object)
|
||||
CMotionSpider::CMotionSpider(COldObject* object)
|
||||
: CMotion(object),
|
||||
m_armAngles()
|
||||
{
|
||||
m_armMember = START_TIME;
|
||||
m_armTimeAbs = START_TIME;
|
||||
|
|
|
@ -48,16 +48,11 @@
|
|||
|
||||
// Object's constructor.
|
||||
|
||||
CMotionVehicle::CMotionVehicle(COldObject* object) : CMotion(object)
|
||||
CMotionVehicle::CMotionVehicle(COldObject* object)
|
||||
: CMotion(object),
|
||||
m_wheelTurn(),
|
||||
m_flyPaw()
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
m_wheelTurn[i] = 0.0f;
|
||||
}
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
m_flyPaw[i] = 0.0f;
|
||||
}
|
||||
m_posTrackLeft = 0.0f;
|
||||
m_posTrackRight = 0.0f;
|
||||
m_partiReactor = -1;
|
||||
|
|
|
@ -47,7 +47,9 @@ const int WORM_PART = 7; // number of parts of a worm
|
|||
|
||||
// Object's constructor.
|
||||
|
||||
CMotionWorm::CMotionWorm(COldObject* object) : CMotion(object)
|
||||
CMotionWorm::CMotionWorm(COldObject* object)
|
||||
: CMotion(object),
|
||||
m_armAngles()
|
||||
{
|
||||
m_timeUp = 18.0f;
|
||||
m_timeDown = 18.0f;
|
||||
|
@ -62,6 +64,7 @@ CMotionWorm::CMotionWorm(COldObject* object) : CMotion(object)
|
|||
m_armCirSpeed = 0.0f;
|
||||
m_armLastAction = -1;
|
||||
m_specAction = -1;
|
||||
m_specTime = 0.0f;
|
||||
m_lastParticle = 0.0f;
|
||||
m_bArmStop = false;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "object/object_manager.h"
|
||||
|
||||
#include "common/make_unique.h"
|
||||
|
||||
#include "math/all.h"
|
||||
|
||||
|
@ -43,7 +44,7 @@ CObjectManager::CObjectManager(Gfx::CEngine* engine,
|
|||
Gfx::COldModelManager* oldModelManager,
|
||||
Gfx::CModelManager* modelManager,
|
||||
Gfx::CParticle* particle)
|
||||
: m_objectFactory(new CObjectFactory(engine, terrain, oldModelManager, modelManager, particle))
|
||||
: m_objectFactory(MakeUnique<CObjectFactory>(engine, terrain, oldModelManager, modelManager, particle))
|
||||
, m_nextId(0)
|
||||
, m_shouldCleanRemovedObjects(false)
|
||||
{
|
||||
|
|
|
@ -75,20 +75,21 @@ const float VIRUS_DELAY = 60.0f; // duration of virus infection
|
|||
// Object's constructor.
|
||||
|
||||
COldObject::COldObject(int id)
|
||||
: CObject(id, OBJECT_NULL)
|
||||
, CInteractiveObject(m_implementedInterfaces)
|
||||
, CTransportableObject(m_implementedInterfaces)
|
||||
, CTaskExecutorObjectImpl(m_implementedInterfaces, this)
|
||||
, CProgrammableObjectImpl(m_implementedInterfaces, this)
|
||||
, CJostleableObject(m_implementedInterfaces)
|
||||
, CCarrierObject(m_implementedInterfaces)
|
||||
, CPoweredObject(m_implementedInterfaces)
|
||||
, CJetFlyingObject(m_implementedInterfaces)
|
||||
, CControllableObject(m_implementedInterfaces)
|
||||
, CPowerContainerObjectImpl(m_implementedInterfaces, this)
|
||||
, CRangedObject(m_implementedInterfaces)
|
||||
, CTraceDrawingObject(m_implementedInterfaces)
|
||||
, CShieldedAutoRegenObject(m_implementedInterfaces)
|
||||
: CObject(id, OBJECT_NULL),
|
||||
CInteractiveObject(m_implementedInterfaces),
|
||||
CTransportableObject(m_implementedInterfaces),
|
||||
CTaskExecutorObjectImpl(m_implementedInterfaces, this),
|
||||
CProgrammableObjectImpl(m_implementedInterfaces, this),
|
||||
CJostleableObject(m_implementedInterfaces),
|
||||
CCarrierObject(m_implementedInterfaces),
|
||||
CPoweredObject(m_implementedInterfaces),
|
||||
CJetFlyingObject(m_implementedInterfaces),
|
||||
CControllableObject(m_implementedInterfaces),
|
||||
CPowerContainerObjectImpl(m_implementedInterfaces),
|
||||
CRangedObject(m_implementedInterfaces),
|
||||
CTraceDrawingObject(m_implementedInterfaces),
|
||||
CShieldedAutoRegenObject(m_implementedInterfaces),
|
||||
m_partiSel()
|
||||
{
|
||||
// A bit of a hack since we don't have subclasses yet, set externally in SetProgrammable()
|
||||
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::Programmable)] = false;
|
||||
|
@ -111,7 +112,9 @@ COldObject::COldObject(int id)
|
|||
m_option = 0;
|
||||
m_name = "";
|
||||
m_shadowLight = -1;
|
||||
m_shadowHeight = 0.0f;
|
||||
m_effectLight = -1;
|
||||
m_effectHeight = 0.0f;
|
||||
m_linVibration = Math::Vector(0.0f, 0.0f, 0.0f);
|
||||
m_cirVibration = Math::Vector(0.0f, 0.0f, 0.0f);
|
||||
m_tilt = Math::Vector(0.0f, 0.0f, 0.0f);
|
||||
|
|
|
@ -51,16 +51,16 @@ const int OBJECTMAXPART = 40;
|
|||
|
||||
struct ObjectPart
|
||||
{
|
||||
bool bUsed;
|
||||
int object; // number of the object in CEngine
|
||||
int parentPart; // number of father part
|
||||
int masterParti; // master canal of the particle
|
||||
bool bUsed = false;
|
||||
int object = -1; // number of the object in CEngine
|
||||
int parentPart = -1; // number of father part
|
||||
int masterParti = -1; // master canal of the particle
|
||||
Math::Vector position;
|
||||
Math::Vector angle;
|
||||
Math::Vector zoom;
|
||||
bool bTranslate;
|
||||
bool bRotate;
|
||||
bool bZoom;
|
||||
bool bTranslate = false;
|
||||
bool bRotate = false;
|
||||
bool bZoom = false;
|
||||
Math::Matrix matTranslate;
|
||||
Math::Matrix matRotate;
|
||||
Math::Matrix matTransform;
|
||||
|
|
|
@ -255,8 +255,14 @@ enum class CAutoInfo::Phase : unsigned int
|
|||
// Object's constructor.
|
||||
|
||||
CAutoInfo::CAutoInfo(CExchangePost* object)
|
||||
: CAuto(object)
|
||||
, m_exchangePost(object)
|
||||
: CAuto(object),
|
||||
m_exchangePost(object),
|
||||
m_phase(Phase::Wait),
|
||||
m_progress(0.0f),
|
||||
m_speed(0.0f),
|
||||
m_timeVirus(0.0f),
|
||||
m_lastParticle(0.0f),
|
||||
m_lastVirus(0.0f)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
|
|
@ -74,17 +74,17 @@ public:
|
|||
virtual bool Abort();
|
||||
|
||||
protected:
|
||||
Gfx::CEngine* m_engine;
|
||||
Gfx::CLightManager* m_lightMan;
|
||||
Gfx::CParticle* m_particle;
|
||||
Gfx::CTerrain* m_terrain;
|
||||
Gfx::CWater* m_water;
|
||||
Gfx::CCamera* m_camera;
|
||||
CRobotMain* m_main;
|
||||
CSoundInterface* m_sound;
|
||||
Gfx::CEngine* m_engine = nullptr;
|
||||
Gfx::CLightManager* m_lightMan = nullptr;
|
||||
Gfx::CParticle* m_particle = nullptr;
|
||||
Gfx::CTerrain* m_terrain = nullptr;
|
||||
Gfx::CWater* m_water = nullptr;
|
||||
Gfx::CCamera* m_camera = nullptr;
|
||||
CRobotMain* m_main = nullptr;
|
||||
CSoundInterface* m_sound = nullptr;
|
||||
|
||||
COldObject* m_object;
|
||||
CProgrammableObject* m_programmable;
|
||||
CMotion* m_motion;
|
||||
CPhysics* m_physics;
|
||||
COldObject* m_object = nullptr;
|
||||
CProgrammableObject* m_programmable = nullptr;
|
||||
CMotion* m_motion = nullptr;
|
||||
CPhysics* m_physics = nullptr;
|
||||
};
|
||||
|
|
|
@ -40,15 +40,13 @@ public:
|
|||
Error IsEnded();
|
||||
|
||||
protected:
|
||||
|
||||
protected:
|
||||
float m_totalLength;
|
||||
float m_advanceLength;
|
||||
float m_direction;
|
||||
float m_timeLimit;
|
||||
float m_totalLength = 0.0f;
|
||||
float m_advanceLength = 0.0f;
|
||||
float m_direction = 0.0f;
|
||||
float m_timeLimit = 0.0f;
|
||||
Math::Vector m_startPos;
|
||||
float m_lastDist;
|
||||
float m_fixTime;
|
||||
bool m_bError;
|
||||
float m_lastDist = 0.0f;
|
||||
float m_fixTime = 0.0f;
|
||||
bool m_bError = 0.0f;
|
||||
};
|
||||
|
||||
|
|
|
@ -70,23 +70,23 @@ protected:
|
|||
void DeleteMark(Math::Vector pos, float radius);
|
||||
|
||||
protected:
|
||||
ObjectType m_type; // type of construction
|
||||
CObject* m_metal; // transforms metal object
|
||||
CObject* m_power; // the vehicle battery
|
||||
CObject* m_building; // building built
|
||||
TaskBuildPhase m_phase; // phase of the operation
|
||||
bool m_bError; // true -> operation impossible
|
||||
bool m_bBuild; // true -> building built
|
||||
bool m_bBlack; // true -> lights black -> white
|
||||
float m_time; // absolute time
|
||||
float m_lastParticle; // time of generation last particle
|
||||
float m_progress; // progression (0..1)
|
||||
float m_speed; // speed of progression
|
||||
float m_angleY; // rotation angle of the vehicle
|
||||
float m_angleZ; // angle of rotation of the gun
|
||||
ObjectType m_type = OBJECT_NULL; // type of construction
|
||||
CObject* m_metal = nullptr; // transforms metal object
|
||||
CObject* m_power = nullptr; // the vehicle battery
|
||||
CObject* m_building = nullptr; // building built
|
||||
TaskBuildPhase m_phase = TBP_STOP; // phase of the operation
|
||||
bool m_bError = false; // true -> operation impossible
|
||||
bool m_bBuild = false; // true -> building built
|
||||
bool m_bBlack = false; // true -> lights black -> white
|
||||
float m_time = 0.0f; // absolute time
|
||||
float m_lastParticle = 0.0f; // time of generation last particle
|
||||
float m_progress = 0.0f; // progression (0..1)
|
||||
float m_speed = 0.0f; // speed of progression
|
||||
float m_angleY = 0.0f; // rotation angle of the vehicle
|
||||
float m_angleZ = 0.0f; // angle of rotation of the gun
|
||||
Math::Vector m_buildingPos; // initial position of the building
|
||||
float m_buildingHeight; // height of the building
|
||||
int m_lightRank[TBMAXLIGHT]; // lights for the effects
|
||||
int m_soundChannel;
|
||||
float m_buildingHeight = 0.0f; // height of the building
|
||||
int m_lightRank[TBMAXLIGHT] = {}; // lights for the effects
|
||||
int m_soundChannel = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ public:
|
|||
|
||||
protected:
|
||||
void DeleteMark();
|
||||
|
||||
protected:
|
||||
bool m_bExecuted;
|
||||
bool m_bExecuted = false;
|
||||
};
|
||||
|
|
|
@ -39,17 +39,15 @@ public:
|
|||
bool Abort();
|
||||
|
||||
protected:
|
||||
|
||||
protected:
|
||||
float m_delay;
|
||||
float m_progress;
|
||||
bool m_bError;
|
||||
bool m_bRay;
|
||||
bool m_bOrganic;
|
||||
float m_time;
|
||||
float m_speed;
|
||||
float m_lastParticle;
|
||||
float m_lastSound;
|
||||
int m_soundChannel;
|
||||
float m_delay = 0.0f;
|
||||
float m_progress = 0.0f;
|
||||
bool m_bError = false;
|
||||
bool m_bRay = false;
|
||||
bool m_bOrganic = false;
|
||||
float m_time = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
float m_lastSound = 0.0f;
|
||||
int m_soundChannel = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -54,13 +54,13 @@ protected:
|
|||
|
||||
protected:
|
||||
Math::Vector m_impact;
|
||||
TaskFireAnt m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_angle;
|
||||
bool m_bError;
|
||||
bool m_bFire;
|
||||
float m_time;
|
||||
float m_lastParticle;
|
||||
TaskFireAnt m_phase = TFA_NULL;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_angle = 0.0f;
|
||||
bool m_bError = false;
|
||||
bool m_bFire = false;
|
||||
float m_time = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
};
|
||||
|
||||
|
|
|
@ -56,8 +56,8 @@ protected:
|
|||
int CountObject(ObjectType type);
|
||||
|
||||
protected:
|
||||
TaskFlagOrder m_order;
|
||||
float m_time;
|
||||
bool m_bError;
|
||||
TaskFlagOrder m_order = TFL_CREATE;
|
||||
float m_time = 0.0f;
|
||||
bool m_bError = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "object/task/taskgoto.h"
|
||||
|
||||
#include "common/event.h"
|
||||
#include "common/make_unique.h"
|
||||
|
||||
#include "graphics/engine/terrain.h"
|
||||
#include "graphics/engine/water.h"
|
||||
|
@ -1965,7 +1966,7 @@ bool CTaskGoto::BitmapOpen()
|
|||
BitmapClose();
|
||||
|
||||
m_bmSize = static_cast<int>(3200.0f/BM_DIM_STEP);
|
||||
m_bmArray = new unsigned char[m_bmSize*m_bmSize/8*2]();
|
||||
m_bmArray = MakeUniqueArray<unsigned char>(m_bmSize*m_bmSize/8*2);
|
||||
|
||||
m_bmOffset = m_bmSize/2;
|
||||
m_bmLine = m_bmSize/8;
|
||||
|
@ -1982,8 +1983,7 @@ bool CTaskGoto::BitmapOpen()
|
|||
|
||||
bool CTaskGoto::BitmapClose()
|
||||
{
|
||||
delete[] m_bmArray;
|
||||
m_bmArray = 0;
|
||||
m_bmArray.reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
#include "math/vector.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
class CObject;
|
||||
|
||||
|
@ -118,44 +120,44 @@ protected:
|
|||
protected:
|
||||
Math::Vector m_goal;
|
||||
Math::Vector m_goalObject;
|
||||
float m_angle;
|
||||
float m_altitude;
|
||||
TaskGotoCrash m_crashMode;
|
||||
TaskGotoGoal m_goalMode;
|
||||
TaskGotoPhase m_phase;
|
||||
int m_try;
|
||||
Error m_error;
|
||||
bool m_bTake;
|
||||
float m_stopLength; // braking distance
|
||||
float m_time;
|
||||
float m_angle = 0.0f;
|
||||
float m_altitude = 0.0f;
|
||||
TaskGotoCrash m_crashMode = TGC_DEFAULT;
|
||||
TaskGotoGoal m_goalMode = TGG_DEFAULT;
|
||||
TaskGotoPhase m_phase = TGP_ADVANCE;
|
||||
int m_try = 0;
|
||||
Error m_error = ERR_OK;
|
||||
bool m_bTake = false;
|
||||
float m_stopLength = 0.0f; // braking distance
|
||||
float m_time = 0.0f;
|
||||
Math::Vector m_pos;
|
||||
bool m_bWorm;
|
||||
bool m_bApprox;
|
||||
float m_wormLastTime;
|
||||
float m_lastDistance;
|
||||
bool m_bWorm = false;
|
||||
bool m_bApprox = false;
|
||||
float m_wormLastTime = 0.0f;
|
||||
float m_lastDistance = 0.0f;
|
||||
|
||||
int m_bmSize; // width or height of the table
|
||||
int m_bmOffset; // m_bmSize/2
|
||||
int m_bmLine; // increment line m_bmSize/8
|
||||
unsigned char* m_bmArray; // bit table
|
||||
int m_bmMinX, m_bmMinY;
|
||||
int m_bmMaxX, m_bmMaxY;
|
||||
int m_bmTotal; // number of points in m_bmPoints
|
||||
int m_bmIndex; // index in m_bmPoints
|
||||
int m_bmSize = 0; // width or height of the table
|
||||
int m_bmOffset = 0; // m_bmSize/2
|
||||
int m_bmLine = 0; // increment line m_bmSize/8
|
||||
std::unique_ptr<unsigned char[]> m_bmArray; // bit table
|
||||
int m_bmMinX = 0, m_bmMinY = 0;
|
||||
int m_bmMaxX = 0, m_bmMaxY = 0;
|
||||
int m_bmTotal = 0; // number of points in m_bmPoints
|
||||
int m_bmIndex = 0; // index in m_bmPoints
|
||||
Math::Vector m_bmPoints[MAXPOINTS+2];
|
||||
char m_bmIter[MAXPOINTS+2];
|
||||
int m_bmIterCounter;
|
||||
CObject* m_bmCargoObject;
|
||||
float m_bmFinalMove; // final advance distance
|
||||
float m_bmFinalDist; // effective distance to advance
|
||||
char m_bmIter[MAXPOINTS+2] = {};
|
||||
int m_bmIterCounter = 0;
|
||||
CObject* m_bmCargoObject = nullptr;
|
||||
float m_bmFinalMove = 0.0f; // final advance distance
|
||||
float m_bmFinalDist = 0.0f; // effective distance to advance
|
||||
Math::Vector m_bmFinalPos; // initial position before advance
|
||||
float m_bmTimeLimit;
|
||||
int m_bmStep;
|
||||
float m_bmTimeLimit = 0.0f;
|
||||
int m_bmStep = 0;
|
||||
Math::Vector m_bmWatchDogPos;
|
||||
float m_bmWatchDogTime;
|
||||
float m_bmWatchDogTime = 0.0f;
|
||||
Math::Vector m_leakPos; // initial position leak
|
||||
float m_leakDelay;
|
||||
float m_leakTime;
|
||||
bool m_bLeakRecede;
|
||||
float m_leakDelay = 0.0f;
|
||||
float m_leakTime = 0.0f;
|
||||
bool m_bLeakRecede = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -39,15 +39,13 @@ public:
|
|||
bool Abort();
|
||||
|
||||
protected:
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_initialDirV = 0.0f; // initial direction
|
||||
float m_finalDirV = 0.0f; // direction to reach
|
||||
float m_initialDirH = 0.0f; // initial direction
|
||||
float m_finalDirH = 0.0f; // direction to reach
|
||||
|
||||
protected:
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_initialDirV; // initial direction
|
||||
float m_finalDirV; // direction to reach
|
||||
float m_initialDirH; // initial direction
|
||||
float m_finalDirH; // direction to reach
|
||||
|
||||
bool m_aimImpossible; // set to true if impossible aim was set
|
||||
bool m_aimImpossible = false; // set to true if impossible aim was set
|
||||
};
|
||||
|
||||
|
|
|
@ -42,9 +42,9 @@ protected:
|
|||
CExchangePost* FindExchangePost(float power);
|
||||
|
||||
protected:
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_time;
|
||||
bool m_error;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_time = 0.0f;
|
||||
bool m_error = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "object/task/taskmanager.h"
|
||||
|
||||
#include "common/make_unique.h"
|
||||
|
||||
#include "object/old_object.h"
|
||||
|
||||
#include "object/task/taskadvance.h"
|
||||
|
@ -42,99 +44,95 @@
|
|||
// Object's constructor.
|
||||
|
||||
CTaskManager::CTaskManager(COldObject* object)
|
||||
: m_object(object),
|
||||
m_bPilot(false)
|
||||
{
|
||||
m_task = nullptr;
|
||||
m_object = object;
|
||||
m_bPilot = false;
|
||||
}
|
||||
|
||||
// Object's destructor.
|
||||
|
||||
CTaskManager::~CTaskManager()
|
||||
{
|
||||
delete m_task;
|
||||
}
|
||||
|
||||
template<typename TaskType, typename... Args>
|
||||
Error CTaskManager::StartTask(Args&&... args)
|
||||
{
|
||||
auto task = MakeUnique<TaskType>(m_object);
|
||||
auto* taskPtr = task.get();
|
||||
m_task = std::move(task);
|
||||
return taskPtr->Start(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
||||
// Waits for a while.
|
||||
|
||||
Error CTaskManager::StartTaskWait(float time)
|
||||
{
|
||||
m_task = new CTaskWait(m_object);
|
||||
return (static_cast<CTaskWait*>(m_task))->Start(time);
|
||||
return StartTask<CTaskWait>(time);
|
||||
}
|
||||
|
||||
// Advance straight ahead a certain distance.
|
||||
|
||||
Error CTaskManager::StartTaskAdvance(float length)
|
||||
{
|
||||
m_task = new CTaskAdvance(m_object);
|
||||
return (static_cast<CTaskAdvance*>(m_task))->Start(length);
|
||||
return StartTask<CTaskAdvance>(length);
|
||||
}
|
||||
|
||||
// Turns through an certain angle.
|
||||
|
||||
Error CTaskManager::StartTaskTurn(float angle)
|
||||
{
|
||||
m_task = new CTaskTurn(m_object);
|
||||
return (static_cast<CTaskTurn*>(m_task))->Start(angle);
|
||||
return StartTask<CTaskTurn>(angle);
|
||||
}
|
||||
|
||||
// Reaches a given position.
|
||||
|
||||
Error CTaskManager::StartTaskGoto(Math::Vector pos, float altitude, TaskGotoGoal goalMode, TaskGotoCrash crashMode)
|
||||
{
|
||||
m_task = new CTaskGoto(m_object);
|
||||
return (static_cast<CTaskGoto*>(m_task))->Start(pos, altitude, goalMode, crashMode);
|
||||
return StartTask<CTaskGoto>(pos, altitude, goalMode, crashMode);
|
||||
}
|
||||
|
||||
// Move the manipulator arm.
|
||||
|
||||
Error CTaskManager::StartTaskTake()
|
||||
{
|
||||
m_task = new CTaskTake(m_object);
|
||||
return (static_cast<CTaskTake*>(m_task))->Start();
|
||||
return StartTask<CTaskTake>();
|
||||
}
|
||||
|
||||
// Move the manipulator arm.
|
||||
|
||||
Error CTaskManager::StartTaskManip(TaskManipOrder order, TaskManipArm arm)
|
||||
{
|
||||
m_task = new CTaskManip(m_object);
|
||||
return (static_cast<CTaskManip*>(m_task))->Start(order, arm);
|
||||
return StartTask<CTaskManip>(order, arm);
|
||||
}
|
||||
|
||||
// Puts or removes a flag.
|
||||
|
||||
Error CTaskManager::StartTaskFlag(TaskFlagOrder order, int rank)
|
||||
{
|
||||
m_task = new CTaskFlag(m_object);
|
||||
return (static_cast<CTaskFlag*>(m_task))->Start(order, rank);
|
||||
return StartTask<CTaskFlag>(order, rank);
|
||||
}
|
||||
|
||||
// Builds a building.
|
||||
|
||||
Error CTaskManager::StartTaskBuild(ObjectType type)
|
||||
{
|
||||
m_task = new CTaskBuild(m_object);
|
||||
return (static_cast<CTaskBuild*>(m_task))->Start(type);
|
||||
return StartTask<CTaskBuild>(type);
|
||||
}
|
||||
|
||||
// Probe the ground.
|
||||
|
||||
Error CTaskManager::StartTaskSearch()
|
||||
{
|
||||
m_task = new CTaskSearch(m_object);
|
||||
return (static_cast<CTaskSearch*>(m_task))->Start();
|
||||
return StartTask<CTaskSearch>();
|
||||
}
|
||||
|
||||
// Delete mark on ground
|
||||
|
||||
Error CTaskManager::StartTaskDeleteMark()
|
||||
{
|
||||
m_task = new CTaskDeleteMark(m_object);
|
||||
return (static_cast<CTaskDeleteMark*>(m_task))->Start();
|
||||
return StartTask<CTaskDeleteMark>();
|
||||
}
|
||||
|
||||
|
||||
|
@ -142,46 +140,42 @@ Error CTaskManager::StartTaskDeleteMark()
|
|||
|
||||
Error CTaskManager::StartTaskInfo(const char *name, float value, float power, bool bSend)
|
||||
{
|
||||
m_task = new CTaskInfo(m_object);
|
||||
return (static_cast<CTaskInfo*>(m_task))->Start(name, value, power, bSend);
|
||||
return StartTask<CTaskInfo>(name, value, power, bSend);
|
||||
}
|
||||
|
||||
// Terraforms the ground.
|
||||
|
||||
Error CTaskManager::StartTaskTerraform()
|
||||
{
|
||||
m_task = new CTaskTerraform(m_object);
|
||||
return (static_cast<CTaskTerraform*>(m_task))->Start();
|
||||
return StartTask<CTaskTerraform>();
|
||||
}
|
||||
|
||||
// Changes the pencil.
|
||||
|
||||
Error CTaskManager::StartTaskPen(bool bDown, TraceColor color)
|
||||
{
|
||||
m_task = new CTaskPen(m_object);
|
||||
return (static_cast<CTaskPen*>(m_task))->Start(bDown, color);
|
||||
return StartTask<CTaskPen>(bDown, color);
|
||||
}
|
||||
|
||||
// Recovers a ruin.
|
||||
|
||||
Error CTaskManager::StartTaskRecover()
|
||||
{
|
||||
m_task = new CTaskRecover(m_object);
|
||||
return (static_cast<CTaskRecover*>(m_task))->Start();
|
||||
return StartTask<CTaskRecover>();
|
||||
}
|
||||
|
||||
// Deploys the shield.
|
||||
|
||||
Error CTaskManager::StartTaskShield(TaskShieldMode mode, float delay)
|
||||
{
|
||||
if ( mode == TSM_UP || mode == TSM_START )
|
||||
if (mode == TSM_UP || mode == TSM_START)
|
||||
{
|
||||
m_task = new CTaskShield(m_object);
|
||||
return (static_cast<CTaskShield*>(m_task))->Start(mode, delay);
|
||||
return StartTask<CTaskShield>(mode, delay);
|
||||
}
|
||||
else if ( m_task != 0 )
|
||||
else if (m_task != nullptr)
|
||||
{
|
||||
return (static_cast<CTaskShield*>(m_task))->Start(mode, delay);
|
||||
// TODO: is this static_cast really safe?
|
||||
return (static_cast<CTaskShield*>(m_task.get()))->Start(mode, delay);
|
||||
}
|
||||
return ERR_UNKNOWN;
|
||||
}
|
||||
|
@ -190,33 +184,29 @@ Error CTaskManager::StartTaskShield(TaskShieldMode mode, float delay)
|
|||
|
||||
Error CTaskManager::StartTaskFire(float delay)
|
||||
{
|
||||
m_bPilot = true;
|
||||
m_task = new CTaskFire(m_object);
|
||||
return (static_cast<CTaskFire*>(m_task))->Start(delay);
|
||||
m_bPilot = true; // TODO: this is set here, but never unset - is this right?
|
||||
return StartTask<CTaskFire>(delay);
|
||||
}
|
||||
|
||||
// Shoots with the ant.
|
||||
|
||||
Error CTaskManager::StartTaskFireAnt(Math::Vector impact)
|
||||
{
|
||||
m_task = new CTaskFireAnt(m_object);
|
||||
return (static_cast<CTaskFireAnt*>(m_task))->Start(impact);
|
||||
return StartTask<CTaskFireAnt>(impact);
|
||||
}
|
||||
|
||||
// Adjusts higher.
|
||||
|
||||
Error CTaskManager::StartTaskGunGoal(float dirV, float dirH)
|
||||
{
|
||||
m_task = new CTaskGunGoal(m_object);
|
||||
return (static_cast<CTaskGunGoal*>(m_task))->Start(dirV, dirH);
|
||||
return StartTask<CTaskGunGoal>(dirV, dirH);
|
||||
}
|
||||
|
||||
// Suicide of the spider.
|
||||
|
||||
Error CTaskManager::StartTaskSpiderExplo()
|
||||
{
|
||||
m_task = new CTaskSpiderExplo(m_object);
|
||||
return (static_cast<CTaskSpiderExplo*>(m_task))->Start();
|
||||
return StartTask<CTaskSpiderExplo>();
|
||||
}
|
||||
|
||||
|
||||
|
@ -224,7 +214,9 @@ Error CTaskManager::StartTaskSpiderExplo()
|
|||
|
||||
bool CTaskManager::EventProcess(const Event &event)
|
||||
{
|
||||
if ( m_task == 0 ) return false;
|
||||
if (m_task == nullptr)
|
||||
return false;
|
||||
|
||||
return m_task->EventProcess(event);
|
||||
}
|
||||
|
||||
|
@ -233,7 +225,9 @@ bool CTaskManager::EventProcess(const Event &event)
|
|||
|
||||
Error CTaskManager::IsEnded()
|
||||
{
|
||||
if ( m_task == 0 ) return ERR_UNKNOWN;
|
||||
if (m_task == nullptr)
|
||||
return ERR_UNKNOWN;
|
||||
|
||||
return m_task->IsEnded();
|
||||
}
|
||||
|
||||
|
@ -242,7 +236,9 @@ Error CTaskManager::IsEnded()
|
|||
|
||||
bool CTaskManager::IsBusy()
|
||||
{
|
||||
if ( m_task == 0 ) return false;
|
||||
if (m_task == nullptr)
|
||||
return false;
|
||||
|
||||
return m_task->IsBusy();
|
||||
}
|
||||
|
||||
|
@ -260,6 +256,8 @@ bool CTaskManager::IsPilot()
|
|||
|
||||
bool CTaskManager::Abort()
|
||||
{
|
||||
if ( m_task == 0 ) return false;
|
||||
if (m_task == nullptr)
|
||||
return false;
|
||||
|
||||
return m_task->Abort();
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "object/task/taskmanip.h"
|
||||
#include "object/task/taskshield.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
class CTaskManager
|
||||
|
@ -64,7 +65,11 @@ public:
|
|||
bool Abort();
|
||||
|
||||
protected:
|
||||
CTask* m_task;
|
||||
COldObject* m_object;
|
||||
bool m_bPilot;
|
||||
template<typename TaskType, typename... Args>
|
||||
Error StartTask(Args&&... args);
|
||||
|
||||
protected:
|
||||
std::unique_ptr<CTask> m_task;
|
||||
COldObject* m_object = nullptr;
|
||||
bool m_bPilot = false;
|
||||
};
|
||||
|
|
|
@ -82,25 +82,25 @@ protected:
|
|||
void SoundManip(float time, float amplitude=1.0f, float frequency=1.0f);
|
||||
|
||||
protected:
|
||||
TaskManipOrder m_order;
|
||||
TaskManipArm m_arm;
|
||||
TaskManipHand m_hand;
|
||||
int m_step;
|
||||
float m_speed;
|
||||
float m_progress;
|
||||
float m_initialAngle[5];
|
||||
float m_finalAngle[5];
|
||||
float m_height;
|
||||
float m_advanceLength;
|
||||
float m_energy;
|
||||
bool m_bError;
|
||||
bool m_bTurn;
|
||||
bool m_bSubm;
|
||||
bool m_bBee;
|
||||
float m_angle;
|
||||
float m_move;
|
||||
TaskManipOrder m_order = TMO_AUTO;
|
||||
TaskManipArm m_arm = TMA_NEUTRAL;
|
||||
TaskManipHand m_hand = TMH_OPEN;
|
||||
int m_step = 0;
|
||||
float m_speed = 0.0f;
|
||||
float m_progress = 0.0f;
|
||||
float m_initialAngle[5] = {};
|
||||
float m_finalAngle[5] = {};
|
||||
float m_height = 0.0f;
|
||||
float m_advanceLength = 0.0f;
|
||||
float m_energy = 0.0f;
|
||||
bool m_bError = false;
|
||||
bool m_bTurn = false;
|
||||
bool m_bSubm = false;
|
||||
bool m_bBee = false;
|
||||
float m_angle = false;
|
||||
float m_move = false;
|
||||
Math::Vector m_targetPos;
|
||||
float m_timeLimit;
|
||||
ObjectType m_cargoType;
|
||||
float m_timeLimit = false;
|
||||
ObjectType m_cargoType = OBJECT_NULL;
|
||||
};
|
||||
|
||||
|
|
|
@ -57,16 +57,16 @@ protected:
|
|||
int ColorToRank(TraceColor color);
|
||||
|
||||
protected:
|
||||
bool m_bError;
|
||||
TaskPenPhase m_phase;
|
||||
float m_progress;
|
||||
float m_delay;
|
||||
float m_time;
|
||||
float m_lastParticle;
|
||||
bool m_bError = false;
|
||||
TaskPenPhase m_phase = TPP_UP;
|
||||
float m_progress = 0.0f;
|
||||
float m_delay = 0.0f;
|
||||
float m_time = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
Math::Vector m_supportPos;
|
||||
|
||||
float m_timeUp;
|
||||
float m_oldAngle;
|
||||
float m_newAngle;
|
||||
float m_timeDown;
|
||||
float m_timeUp = 0.0f;
|
||||
float m_oldAngle = 0.0f;
|
||||
float m_newAngle = 0.0f;
|
||||
float m_timeDown = 0.0f;
|
||||
};
|
||||
|
|
|
@ -55,16 +55,16 @@ protected:
|
|||
CObject* SearchRuin();
|
||||
|
||||
protected:
|
||||
TaskRecoverPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_time;
|
||||
float m_angle;
|
||||
float m_lastParticle;
|
||||
bool m_bError;
|
||||
CObject* m_ruin;
|
||||
CObject* m_metal;
|
||||
TaskRecoverPhase m_phase = TRP_TURN;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_time = 0.0f;
|
||||
float m_angle = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
bool m_bError = false;
|
||||
CObject* m_ruin = nullptr;
|
||||
CObject* m_metal = nullptr;
|
||||
Math::Vector m_recoverPos;
|
||||
int m_soundChannel;
|
||||
int m_soundChannel = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -61,14 +61,14 @@ protected:
|
|||
void DeleteMark(ObjectType type);
|
||||
|
||||
protected:
|
||||
TaskSearchHand m_hand;
|
||||
TaskSearchPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_time;
|
||||
float m_lastParticle;
|
||||
float m_initialAngle[3];
|
||||
float m_finalAngle[3];
|
||||
bool m_bError;
|
||||
TaskSearchHand m_hand = TSH_UP;
|
||||
TaskSearchPhase m_phase = TSP_DOWN;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_time = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
float m_initialAngle[3] = {};
|
||||
float m_finalAngle[3] = {};
|
||||
bool m_bError = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -71,19 +71,19 @@ protected:
|
|||
float GetRadius();
|
||||
|
||||
protected:
|
||||
TaskShieldPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_time;
|
||||
float m_delay;
|
||||
float m_lastParticle;
|
||||
float m_lastRay;
|
||||
float m_lastIncrease;
|
||||
float m_energyUsed;
|
||||
bool m_bError;
|
||||
TaskShieldPhase m_phase = TS_UP1;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_time = 0.0f;
|
||||
float m_delay = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
float m_lastRay = 0.0f;
|
||||
float m_lastIncrease = 0.0f;
|
||||
float m_energyUsed = 0.0f;
|
||||
bool m_bError = false;
|
||||
Math::Vector m_shieldPos;
|
||||
int m_rankSphere;
|
||||
int m_soundChannel;
|
||||
int m_effectLight;
|
||||
int m_rankSphere = 0;
|
||||
int m_soundChannel = 0;
|
||||
int m_effectLight = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -39,9 +39,7 @@ public:
|
|||
bool Abort();
|
||||
|
||||
protected:
|
||||
|
||||
protected:
|
||||
float m_time;
|
||||
bool m_bError;
|
||||
float m_time = 0.0f;
|
||||
bool m_bError = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -64,15 +64,15 @@ protected:
|
|||
bool IsFreeDeposeObject(Math::Vector pos);
|
||||
|
||||
protected:
|
||||
TaskTakeOrder m_order;
|
||||
TaskTakeArm m_arm;
|
||||
int m_step;
|
||||
float m_speed;
|
||||
float m_progress;
|
||||
float m_height;
|
||||
bool m_bError;
|
||||
bool m_bTurn;
|
||||
float m_angle;
|
||||
ObjectType m_cargoType;
|
||||
TaskTakeOrder m_order = TTO_TAKE;
|
||||
TaskTakeArm m_arm = TTA_NEUTRAL;
|
||||
int m_step = 0;
|
||||
float m_speed = 0.0f;
|
||||
float m_progress = 0.0f;
|
||||
float m_height = 0.0f;
|
||||
bool m_bError = false;
|
||||
bool m_bTurn = false;
|
||||
float m_angle = 0.0f;
|
||||
ObjectType m_cargoType = OBJECT_NULL;
|
||||
};
|
||||
|
||||
|
|
|
@ -53,13 +53,13 @@ protected:
|
|||
bool Terraform();
|
||||
|
||||
protected:
|
||||
TaskTerraPhase m_phase;
|
||||
float m_progress;
|
||||
float m_speed;
|
||||
float m_time;
|
||||
float m_lastParticle;
|
||||
int m_soundChannel;
|
||||
bool m_bError;
|
||||
TaskTerraPhase m_phase = TTP_CHARGE;
|
||||
float m_progress = 0.0f;
|
||||
float m_speed = 0.0f;
|
||||
float m_time = 0.0f;
|
||||
float m_lastParticle = 0.0f;
|
||||
int m_soundChannel = 0;
|
||||
bool m_bError = false;
|
||||
Math::Vector m_terraPos;
|
||||
};
|
||||
|
||||
|
|
|
@ -38,12 +38,10 @@ public:
|
|||
Error IsEnded();
|
||||
|
||||
protected:
|
||||
|
||||
protected:
|
||||
float m_angle;
|
||||
float m_startAngle;
|
||||
float m_finalAngle;
|
||||
bool m_bLeft;
|
||||
bool m_bError;
|
||||
float m_angle = 0.0f;
|
||||
float m_startAngle = 0.0f;
|
||||
float m_finalAngle = 0.0f;
|
||||
bool m_bLeft = false;
|
||||
bool m_bError = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -38,10 +38,8 @@ public:
|
|||
Error IsEnded();
|
||||
|
||||
protected:
|
||||
|
||||
protected:
|
||||
float m_waitTime;
|
||||
float m_passTime;
|
||||
bool m_bEnded;
|
||||
float m_waitTime = 0.0f;
|
||||
float m_passTime = 0.0f;
|
||||
bool m_bEnded = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -118,6 +118,7 @@ CPhysics::CPhysics(COldObject* object)
|
|||
m_fallingHeight = 0.0f;
|
||||
m_minFallingHeight = 20.0f;
|
||||
m_fallDamageFraction = 0.007f;
|
||||
m_floorLevel = 0.0f;
|
||||
}
|
||||
|
||||
// Object's destructor.
|
||||
|
|
|
@ -66,12 +66,9 @@ CScript::CScript(COldObject* object)
|
|||
m_interface = m_main->GetInterface();
|
||||
m_pause = CPauseManager::GetInstancePointer();
|
||||
|
||||
m_botProg = nullptr;
|
||||
|
||||
m_ipf = CBOT_IPF;
|
||||
m_errMode = ERM_STOP;
|
||||
m_len = 0;
|
||||
m_script = nullptr;
|
||||
m_bRun = false;
|
||||
m_bStepMode = false;
|
||||
m_bCompile = false;
|
||||
|
@ -86,12 +83,6 @@ CScript::CScript(COldObject* object)
|
|||
|
||||
CScript::~CScript()
|
||||
{
|
||||
delete m_botProg;
|
||||
m_botProg = nullptr;
|
||||
|
||||
delete[] m_script;
|
||||
m_script = nullptr;
|
||||
|
||||
m_len = 0;
|
||||
}
|
||||
|
||||
|
@ -106,7 +97,7 @@ void CScript::PutScript(Ui::CEdit* edit, const char* name)
|
|||
}
|
||||
else
|
||||
{
|
||||
edit->SetText(m_script);
|
||||
edit->SetText(m_script.get());
|
||||
edit->SetCursor(m_cursor2, m_cursor1);
|
||||
edit->ShowSelect();
|
||||
}
|
||||
|
@ -117,17 +108,12 @@ void CScript::PutScript(Ui::CEdit* edit, const char* name)
|
|||
|
||||
bool CScript::GetScript(Ui::CEdit* edit)
|
||||
{
|
||||
int len;
|
||||
int len = edit->GetTextLength();
|
||||
m_script = MakeUniqueArray<char>(len+1);
|
||||
|
||||
delete[] m_script;
|
||||
m_script = nullptr;
|
||||
|
||||
len = edit->GetTextLength();
|
||||
m_script = new char[len+1];
|
||||
|
||||
edit->GetText(m_script, len+1);
|
||||
edit->GetText(m_script.get(), len+1);
|
||||
edit->GetCursor(m_cursor2, m_cursor1);
|
||||
m_len = strlen(m_script);
|
||||
m_len = strlen(m_script.get());
|
||||
|
||||
if ( !CheckToken() )
|
||||
{
|
||||
|
@ -159,9 +145,7 @@ bool CScript::GetCompile()
|
|||
|
||||
bool CScript::IsEmpty()
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i=0 ; i<m_len ; i++ )
|
||||
for (int i = 0; i < m_len; i++)
|
||||
{
|
||||
if ( m_script[i] != ' ' &&
|
||||
m_script[i] != '\n' ) return false;
|
||||
|
@ -194,7 +178,7 @@ bool CScript::CheckToken()
|
|||
used[i] = 0; // token not used
|
||||
}
|
||||
|
||||
allBt = CBotToken::CompileTokens(m_script, error);
|
||||
allBt = CBotToken::CompileTokens(m_script.get(), error);
|
||||
bt = allBt;
|
||||
while ( bt != 0 )
|
||||
{
|
||||
|
@ -259,17 +243,16 @@ bool CScript::Compile()
|
|||
|
||||
if ( IsEmpty() ) // program exist?
|
||||
{
|
||||
delete m_botProg;
|
||||
m_botProg = 0;
|
||||
m_botProg.reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( m_botProg == 0 )
|
||||
if (m_botProg == nullptr)
|
||||
{
|
||||
m_botProg = new CBotProgram(m_object->GetBotVar());
|
||||
m_botProg = MakeUnique<CBotProgram>(m_object->GetBotVar());
|
||||
}
|
||||
|
||||
if ( m_botProg->Compile(m_script, liste, this) )
|
||||
if ( m_botProg->Compile(m_script.get(), liste, this) )
|
||||
{
|
||||
if ( liste.GetSize() == 0 )
|
||||
{
|
||||
|
@ -344,7 +327,7 @@ void CScript::SetStepMode(bool bStep)
|
|||
|
||||
bool CScript::Run()
|
||||
{
|
||||
if( m_botProg == 0 ) return false;
|
||||
if (m_botProg == nullptr) return false;
|
||||
if ( m_script == nullptr || m_len == 0 ) return false;
|
||||
if ( m_mainFunction[0] == 0 ) return false;
|
||||
|
||||
|
@ -368,7 +351,7 @@ bool CScript::Run()
|
|||
|
||||
bool CScript::Continue()
|
||||
{
|
||||
if( m_botProg == 0 ) return true;
|
||||
if (m_botProg == nullptr) return true;
|
||||
if ( !m_bRun ) return true;
|
||||
|
||||
if ( m_bStepMode ) // step by step mode?
|
||||
|
@ -440,7 +423,7 @@ bool CScript::Continue()
|
|||
|
||||
bool CScript::Step()
|
||||
{
|
||||
if( m_botProg == 0 ) return true;
|
||||
if (m_botProg == nullptr) return true;
|
||||
if ( !m_bRun ) return true;
|
||||
if ( !m_bStepMode ) return false;
|
||||
|
||||
|
@ -490,7 +473,7 @@ void CScript::Stop()
|
|||
|
||||
m_taskExecutor->StopForegroundTask();
|
||||
|
||||
if( m_botProg != 0 )
|
||||
if (m_botProg != nullptr)
|
||||
{
|
||||
m_botProg->Stop();
|
||||
}
|
||||
|
@ -521,7 +504,7 @@ bool CScript::GetCursor(int &cursor1, int &cursor2)
|
|||
|
||||
cursor1 = cursor2 = 0;
|
||||
|
||||
if( m_botProg == 0 ) return false;
|
||||
if (m_botProg == nullptr) return false;
|
||||
if ( !m_bRun ) return false;
|
||||
|
||||
m_botProg->GetRunPos(funcName, cursor1, cursor2);
|
||||
|
@ -631,7 +614,7 @@ void CScript::UpdateList(Ui::CList* list)
|
|||
const char *progName, *funcName;
|
||||
int total, select, level, cursor1, cursor2, rank;
|
||||
|
||||
if( m_botProg == 0 ) return;
|
||||
if (m_botProg == nullptr) return;
|
||||
|
||||
total = list->GetTotal();
|
||||
select = list->GetSelect();
|
||||
|
@ -800,7 +783,7 @@ bool CScript::IntroduceVirus()
|
|||
int found[11*2];
|
||||
for ( int i=0 ; i<11 ; i++ )
|
||||
{
|
||||
int start = SearchToken(m_script, names[i*2]);
|
||||
int start = SearchToken(m_script.get(), names[i*2]);
|
||||
if ( start != -1 )
|
||||
{
|
||||
found[iFound++] = i*2;
|
||||
|
@ -813,14 +796,13 @@ bool CScript::IntroduceVirus()
|
|||
int start = found[i+1];
|
||||
i = found[i+0];
|
||||
|
||||
char* newScript = new char[m_len+strlen(names[i+1])+1];
|
||||
strcpy(newScript, m_script);
|
||||
delete[] m_script;
|
||||
m_script = newScript;
|
||||
auto newScript = MakeUniqueArray<char>(m_len + strlen(names[i+1]) + 1);
|
||||
strcpy(newScript.get(), m_script.get());
|
||||
m_script = std::move(newScript);
|
||||
|
||||
DeleteToken(m_script, start, strlen(names[i]));
|
||||
InsertToken(m_script, start, names[i+1]);
|
||||
m_len = strlen(m_script);
|
||||
DeleteToken(m_script.get(), start, strlen(names[i]));
|
||||
InsertToken(m_script.get(), start, names[i+1]);
|
||||
m_len = strlen(m_script.get());
|
||||
Compile(); // recompile with the virus
|
||||
|
||||
return true;
|
||||
|
@ -1000,8 +982,7 @@ bool CScript::ReadScript(const char* filename)
|
|||
|
||||
if (!CResourceManager::Exists(filename)) return false;
|
||||
|
||||
delete[] m_script;
|
||||
m_script = nullptr;
|
||||
m_script.reset();
|
||||
|
||||
edit = m_interface->CreateEdit(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 0, EVENT_EDIT9);
|
||||
edit->SetMaxChar(Ui::EDITSTUDIOMAX);
|
||||
|
@ -1016,18 +997,16 @@ bool CScript::ReadScript(const char* filename)
|
|||
|
||||
bool CScript::WriteScript(const char* filename)
|
||||
{
|
||||
Ui::CEdit* edit;
|
||||
|
||||
if ( m_script == nullptr )
|
||||
{
|
||||
CResourceManager::Remove(filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
edit = m_interface->CreateEdit(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 0, EVENT_EDIT9);
|
||||
Ui::CEdit* edit = m_interface->CreateEdit(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 0, EVENT_EDIT9);
|
||||
edit->SetMaxChar(Ui::EDITSTUDIOMAX);
|
||||
edit->SetAutoIndent(m_engine->GetEditIndentMode());
|
||||
edit->SetText(m_script);
|
||||
edit->SetText(m_script.get());
|
||||
edit->WriteText(filename);
|
||||
m_interface->DeleteControl(EVENT_EDIT9);
|
||||
return true;
|
||||
|
@ -1044,7 +1023,7 @@ bool CScript::ReadStack(FILE *file)
|
|||
fRead(&m_ipf, sizeof(int), 1, file);
|
||||
fRead(&m_errMode, sizeof(int), 1, file);
|
||||
|
||||
if ( m_botProg == 0 ) return false;
|
||||
if (m_botProg == nullptr) return false;
|
||||
if ( !m_botProg->RestoreState(file) ) return false;
|
||||
|
||||
m_bRun = true;
|
||||
|
@ -1073,7 +1052,7 @@ bool CScript::Compare(CScript* other)
|
|||
{
|
||||
if ( m_len != other->m_len ) return false;
|
||||
|
||||
return ( strcmp(m_script, other->m_script) == 0 );
|
||||
return ( strcmp(m_script.get(), other->m_script.get()) == 0 );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "common/global.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
|
||||
|
@ -101,31 +102,31 @@ protected:
|
|||
bool Compile();
|
||||
|
||||
protected:
|
||||
COldObject* m_object;
|
||||
CTaskExecutorObject* m_taskExecutor;
|
||||
COldObject* m_object = nullptr;
|
||||
CTaskExecutorObject* m_taskExecutor = nullptr;
|
||||
|
||||
Gfx::CEngine* m_engine;
|
||||
Ui::CInterface* m_interface;
|
||||
CBotProgram* m_botProg;
|
||||
CRobotMain* m_main;
|
||||
Gfx::CTerrain* m_terrain;
|
||||
Gfx::CWater* m_water;
|
||||
CPauseManager* m_pause;
|
||||
Gfx::CEngine* m_engine = nullptr;
|
||||
Ui::CInterface* m_interface = nullptr;
|
||||
std::unique_ptr<CBotProgram> m_botProg;
|
||||
CRobotMain* m_main = nullptr;
|
||||
Gfx::CTerrain* m_terrain = nullptr;
|
||||
Gfx::CWater* m_water = nullptr;
|
||||
CPauseManager* m_pause = nullptr;
|
||||
|
||||
int m_ipf; // number of instructions/second
|
||||
int m_errMode; // what to do in case of error
|
||||
int m_len; // length of the script (without <0>)
|
||||
char* m_script; // script ends with <0>
|
||||
bool m_bRun; // program during execution?
|
||||
bool m_bStepMode; // step by step
|
||||
bool m_bContinue; // external function to continue
|
||||
bool m_bCompile; // compilation ok?
|
||||
char m_title[50]; // script title
|
||||
char m_mainFunction[50];
|
||||
char m_filename[50]; // file name
|
||||
char m_token[50]; // missing instruction
|
||||
int m_error; // error (0=ok)
|
||||
int m_cursor1;
|
||||
int m_cursor2;
|
||||
float m_returnValue;
|
||||
int m_ipf = 0; // number of instructions/second
|
||||
int m_errMode = 0; // what to do in case of error
|
||||
int m_len = 0; // length of the script (without <0>)
|
||||
std::unique_ptr<char[]> m_script; // script ends with <0>
|
||||
bool m_bRun = false; // program during execution?
|
||||
bool m_bStepMode = false; // step by step
|
||||
bool m_bContinue = false; // external function to continue
|
||||
bool m_bCompile = false; // compilation ok?
|
||||
char m_title[50] = {}; // script title
|
||||
char m_mainFunction[50] = {};
|
||||
char m_filename[50] = {}; // file name
|
||||
char m_token[50] = {}; // missing instruction
|
||||
int m_error = 0; // error (0=ok)
|
||||
int m_cursor1 = 0;
|
||||
int m_cursor2 = 0;
|
||||
float m_returnValue = 0.0f;
|
||||
};
|
||||
|
|
|
@ -38,7 +38,8 @@ class LightManagerUT : public testing::Test
|
|||
protected:
|
||||
LightManagerUT() :
|
||||
m_engine(nullptr),
|
||||
m_device(nullptr)
|
||||
m_device(nullptr),
|
||||
m_maxLightsCount(0)
|
||||
{}
|
||||
~LightManagerUT() NOEXCEPT
|
||||
{}
|
||||
|
|
Loading…
Reference in New Issue