From faa3e3c44d46e30ab94417f3531621414b1bdf52 Mon Sep 17 00:00:00 2001 From: orengg <16946404+orengg@users.noreply.github.com> Date: Tue, 12 May 2020 13:03:41 +0300 Subject: [PATCH 01/10] quick fix for crash on ending of metagame matches and metagame arena scans, done in MetagameGUI.cpp. --- Menus/MetagameGUI.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Menus/MetagameGUI.cpp b/Menus/MetagameGUI.cpp index be348416a..feeb6a8ab 100644 --- a/Menus/MetagameGUI.cpp +++ b/Menus/MetagameGUI.cpp @@ -3011,11 +3011,11 @@ void MetagameGUI::CompletedActivity() pAlteredScene->RetrieveActorsAndDevices(winningTeam, autoResolved); // Save out the altered scene before clearing out its data from memory pAlteredScene->SaveData(METASAVEPATH + string(AUTOSAVENAME) + " - " + pAlteredScene->GetPresetName()); - // Clear the bitmap data etc of the altered scene, we don't need to copy that over - pAlteredScene->ClearData(); // Deep copy over all the edits made to the newly played Scene m_pPlayingScene->Destroy(); m_pPlayingScene->Create(*pAlteredScene); + // Clear the bitmap data etc of the altered scene, we don't need to copy that over + m_pPlayingScene->ClearData(); // Scrub the module ID so the migration goes well.. this is a bit hacky, but ok in this special case m_pPlayingScene->SetModuleID(-1); m_pPlayingScene->GetTerrain()->SetModuleID(-1); From ea71300ce95d6a3714b7be6a1a32c9f7bda73fe2 Mon Sep 17 00:00:00 2001 From: orengg <16946404+orengg@users.noreply.github.com> Date: Tue, 12 May 2020 13:04:51 +0300 Subject: [PATCH 02/10] in SceneMan.cpp i changed the assert to be more reasonable and also commented it out, hopefully helping performance. --- Managers/SceneMan.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Managers/SceneMan.cpp b/Managers/SceneMan.cpp index 256bb0eca..3f595329c 100644 --- a/Managers/SceneMan.cpp +++ b/Managers/SceneMan.cpp @@ -441,8 +441,8 @@ void SceneMan::Destroy() Vector SceneMan::GetSceneDim() const { - RTEAssert(m_pCurrentScene && m_pCurrentScene->GetTerrain() && m_pCurrentScene->GetTerrain()->GetBitmap(), "Trying to get terrain info before there is a scene or terrain!"); if (m_pCurrentScene) + //RTEAssert(m_pCurrentScene->GetTerrain() && m_pCurrentScene->GetTerrain()->GetBitmap(), "Trying to get terrain info before there is a scene or terrain!"); return m_pCurrentScene->GetDimensions(); return Vector(); } From 0bbb8d0a916433686fd663221abb37527cb2f43b Mon Sep 17 00:00:00 2001 From: orengg <16946404+orengg@users.noreply.github.com> Date: Tue, 12 May 2020 13:09:50 +0300 Subject: [PATCH 03/10] update comment --- Menus/MetagameGUI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Menus/MetagameGUI.cpp b/Menus/MetagameGUI.cpp index feeb6a8ab..75b11ea4c 100644 --- a/Menus/MetagameGUI.cpp +++ b/Menus/MetagameGUI.cpp @@ -3014,7 +3014,7 @@ void MetagameGUI::CompletedActivity() // Deep copy over all the edits made to the newly played Scene m_pPlayingScene->Destroy(); m_pPlayingScene->Create(*pAlteredScene); - // Clear the bitmap data etc of the altered scene, we don't need to copy that over + // Clear the bitmap data etc of the scene, we don't need it m_pPlayingScene->ClearData(); // Scrub the module ID so the migration goes well.. this is a bit hacky, but ok in this special case m_pPlayingScene->SetModuleID(-1); From 25a01f9c9c235232741da9ac68ad8c8a012ad981 Mon Sep 17 00:00:00 2001 From: orengg <16946404+orengg@users.noreply.github.com> Date: Tue, 12 May 2020 20:42:18 +0300 Subject: [PATCH 04/10] fix crash by nulling scene at end of metagame match. also safety checks on SceneMan::Update() and SceneMan::Draw(). --- Managers/SceneMan.cpp | 16 ++++++++++++++-- Managers/SceneMan.h | 6 +++++- Menus/MetagameGUI.cpp | 6 ++++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Managers/SceneMan.cpp b/Managers/SceneMan.cpp index 3f595329c..102ee67aa 100644 --- a/Managers/SceneMan.cpp +++ b/Managers/SceneMan.cpp @@ -3432,7 +3432,10 @@ bool SceneMan::AddSceneObject(SceneObject *pObject) void SceneMan::Update(int screen) { - RTEAssert(m_pCurrentScene, "Trying to access scene before there is one!"); + if (m_pCurrentScene == nullptr) { + return; + } + //RTEAssert(m_pCurrentScene, "Trying to access scene before there is one!"); // Record screen was the last updated screen m_LastUpdatedScreen = screen; @@ -3572,7 +3575,10 @@ void SceneMan::Update(int screen) void SceneMan::Draw(BITMAP *pTargetBitmap, BITMAP *pTargetGUIBitmap, const Vector &targetPos, bool skipSkybox, bool skipTerrain) { - RTEAssert(m_pCurrentScene, "Trying to access scene before there is one!"); + if (m_pCurrentScene == nullptr) { + return; + } + //RTEAssert(m_pCurrentScene, "Trying to access scene before there is one!"); // Handy SLTerrain *pTerrain = m_pCurrentScene->GetTerrain(); @@ -3689,4 +3695,10 @@ void SceneMan::ClearSeenPixels() m_pCurrentScene->ClearSeenPixels(team); } +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void SceneMan::ClearCurrentScene() { + m_pCurrentScene = nullptr; +} + } // namespace RTE \ No newline at end of file diff --git a/Managers/SceneMan.h b/Managers/SceneMan.h index ca2035080..97f7c1cec 100644 --- a/Managers/SceneMan.h +++ b/Managers/SceneMan.h @@ -1714,6 +1714,10 @@ class SceneMan: bool back; }; + /// + /// Sets the current scene pointer to null + /// + void SceneMan::ClearCurrentScene(); ////////////////////////////////////////////////////////////////////////////////////////// // Protected member variable and method declarations @@ -1821,7 +1825,7 @@ class SceneMan: void Clear(); - + // Disallow the use of some implicit methods. SceneMan(const SceneMan &reference); SceneMan & operator=(const SceneMan &rhs); diff --git a/Menus/MetagameGUI.cpp b/Menus/MetagameGUI.cpp index 75b11ea4c..702362fed 100644 --- a/Menus/MetagameGUI.cpp +++ b/Menus/MetagameGUI.cpp @@ -3011,11 +3011,13 @@ void MetagameGUI::CompletedActivity() pAlteredScene->RetrieveActorsAndDevices(winningTeam, autoResolved); // Save out the altered scene before clearing out its data from memory pAlteredScene->SaveData(METASAVEPATH + string(AUTOSAVENAME) + " - " + pAlteredScene->GetPresetName()); + // Clear the bitmap data etc of the altered scene, we don't need to copy that over + pAlteredScene->ClearData(); // Deep copy over all the edits made to the newly played Scene m_pPlayingScene->Destroy(); m_pPlayingScene->Create(*pAlteredScene); - // Clear the bitmap data etc of the scene, we don't need it - m_pPlayingScene->ClearData(); + // Null the current scene, which is pointed to by pAlteredScene. + g_SceneMan.ClearCurrentScene(); // Scrub the module ID so the migration goes well.. this is a bit hacky, but ok in this special case m_pPlayingScene->SetModuleID(-1); m_pPlayingScene->GetTerrain()->SetModuleID(-1); From 5f8a4eea17b64cb1e475398d6f297250163e8bdf Mon Sep 17 00:00:00 2001 From: orengg <16946404+orengg@users.noreply.github.com> Date: Tue, 12 May 2020 21:28:22 +0300 Subject: [PATCH 05/10] convert old comment format to new for some items. --- Managers/SceneMan.h | 339 ++++++++++++++++---------------------------- 1 file changed, 119 insertions(+), 220 deletions(-) diff --git a/Managers/SceneMan.h b/Managers/SceneMan.h index 97f7c1cec..99d15c94b 100644 --- a/Managers/SceneMan.h +++ b/Managers/SceneMan.h @@ -75,7 +75,9 @@ enum // Description: A simple rectangle with integer coordinates. // Parent(s): None. // Class history: 8/4/2007 IntRect created. - +/// +/// A simple rectangle with integer coordinates. +/// struct IntRect { int m_Left; @@ -87,16 +89,11 @@ struct IntRect IntRect(int left, int top, int right, int bottom) { m_Left = left; m_Top = top; m_Right = right; m_Bottom = bottom; } bool Intersects(const IntRect &rhs) { return m_Left < rhs.m_Right && m_Right > rhs.m_Left && m_Top < rhs.m_Bottom && m_Bottom > rhs.m_Top; } - -////////////////////////////////////////////////////////////////////////////////////////// -// Method: IntersectionCut -////////////////////////////////////////////////////////////////////////////////////////// -// Description: If this and the passed in IntRect intersect, this will be modified to -// represent the boolean AND of the two. If it doens't intersect, nothing -// happens and false is returned. -// Arguments: The other IntRect to cut against. -// Return value: Whether an intersection was detected and this was cut down to the AND. - + /// + /// If this and the passed in IntRect intersect, this will be modified to represent the boolean AND of the two. If it doens't intersect, nothing happens and false is returned. + /// + /// The other IntRect to cut against. + /// Whether an intersection was detected and this was cut down to the AND. bool IntersectionCut(const IntRect &rhs); @@ -121,14 +118,9 @@ class SceneMan: public: - -////////////////////////////////////////////////////////////////////////////////////////// -// Constructor: SceneMan -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Constructor method used to instantiate a SceneMan object in system -// memory. Create() should be called before using the object. -// Arguments: None. - + /// + /// Constructor method used to instantiate a SceneMan object in system memory. Create() should be called before using the object. + /// SceneMan() { m_pOrphanSearchBitmap = 0; Clear(); } @@ -138,7 +130,9 @@ class SceneMan: // Description: Destructor method used to clean up a SceneMan object before deletion // from system memory. // Arguments: None. - + /// + /// Destructor method used to clean up a SceneMan object before deletion from system memory. + /// virtual ~SceneMan() { Destroy(); } /* @@ -153,245 +147,146 @@ class SceneMan: virtual int Create(); */ -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Create -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Makes the SceneMan object ready for use. -// Arguments: A string with the filepath to a Reader file from screen this SceneMan's -// data should be created. -// Return value: An error return value signaling sucess or any particular failure. -// Anything below 0 is an error signal. - + /// + /// Makes the SceneMan object ready for use. + /// + /// A string with the filepath to a Reader file from screen this SceneMan's data should be created. + /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. virtual int Create(std::string readerFile); - -////////////////////////////////////////////////////////////////////////////////////////// -// Method: SetDefaultSceneName -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets the instance name of the default Scene to be loaded if nothing -// else is available. -// Arguments: The default scene instance name. -// Return value: None. - + /// + /// Sets the instance name of the default Scene to be loaded if nothing else is available. + /// + /// The default scene instance name. void SetDefaultSceneName(std::string defaultSceneName) { m_DefaultSceneName = defaultSceneName; } - -////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetDefaultSceneName -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Gets the name of the default A to be loaded if nothing -// else is available. -// Arguments: None. -// Return value: The default Scene instance name. - + /// + /// Gets the name of the default A to be loaded if nothing else is available. + /// + /// The default Scene instance name. std::string GetDefaultSceneName() const { return m_DefaultSceneName; } - -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual method: LoadScene -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Actually loads a new Scene into memory. has to be done before using -// this object. -// Arguments: The instance of the Scene, ownership IS transferred! -// Whether the scene should actually apply all its SceneObject:s placed -// in its definition. -// Return value: An error return value signaling sucess or any particular failure. -// Anything below 0 is an error signal. - + /// + /// Actually loads a new Scene into memory. has to be done before using this object. + /// + /// The instance of the Scene, ownership IS transferred! + /// Whether the scene should actually apply all its SceneObject:s placed in its definition. + /// Whether the scene should actually deploy all units placed in its definition. + /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. virtual int LoadScene(Scene *pNewScene, bool placeObjects = true, bool placeUnits = true); - -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual method: SetSceneToLoad -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Stores a Scene reference to be loaded later into the SceneMan. -// Arguments: The instance reference of the Scene, ownership IS NOT (!!) transferred! -// Whether the scene should actually apply all its SceneObject:s placed -// in its definition. -// Return value: None. - + /// + /// Stores a Scene reference to be loaded later into the SceneMan. + /// + /// The instance reference of the Scene, ownership IS NOT (!!) transferred! + /// Whether the scene should actually apply all its SceneObject:s placed in its definition. + /// Whether the scene should actually deploy all units placed in its definition. virtual void SetSceneToLoad(const Scene *pLoadScene, bool placeObjects = true, bool placeUnits = true) { m_pSceneToLoad = pLoadScene; m_PlaceObjects = placeObjects; m_PlaceUnits = placeUnits; } - -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual method: SetSceneToLoad -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Sets a scene to load later, by preset name. -// Arguments: The name of the Scene preset instance to load. -// Whether the scene should actually apply all its SceneObject:s placed -// in its definition. -// Return value: An error return value signaling sucess or any particular failure. -// Anything below 0 is an error signal. - + /// + /// Sets a scene to load later, by preset name. + /// + /// The name of the Scene preset instance to load. + /// Whether the scene should actually apply all its SceneObject:s placed in its definition. + /// Whether the scene should actually deploy all units placed in its definition. + /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. virtual int SetSceneToLoad(std::string sceneName, bool placeObjects = true, bool placeUnits = true); - -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual method: GetSceneToLoad -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Gets the stored Scene reference to be loaded later into the SceneMan. -// Arguments: None. -// Return value: The instance reference of the Scene, ownership IS NOT (!!) transferred! - + /// + /// Gets the stored Scene reference to be loaded later into the SceneMan. + /// + /// The instance reference of the Scene, ownership IS NOT (!!) transferred! virtual const Scene * GetSceneToLoad() { return m_pSceneToLoad; } - -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual method: LoadScene -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Actually loads the Scene set to be loaded in SetSceneToLoad. -// Arguments: None. -// Return value: An error return value signaling sucess or any particular failure. -// Anything below 0 is an error signal. - + /// + /// Actually loads the Scene set to be loaded in SetSceneToLoad. + /// + /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. virtual int LoadScene(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual method: LoadScene -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Loads a Scene right now, by preset name. -// Arguments: The name of the Scene preset instance to load. -// Whether the scene should actually apply all its SceneObject:s placed -// in its definition. -// Whether the scene should actually deploy all units placed in its definition. -// Return value: An error return value signaling sucess or any particular failure. -// Anything below 0 is an error signal. - + /// + /// Loads a Scene right now, by preset name. + /// + /// The name of the Scene preset instance to load. + /// Whether the scene should actually apply all its SceneObject:s placed in its definition. + /// Whether the scene should actually deploy all units placed in its definition. + /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. virtual int LoadScene(std::string sceneName, bool placeObjects = true, bool placeUnits = true); - -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual method: LoadScene -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Loads a Scene right now, by preset name. -// Arguments: The name of the Scene preset instance to load. -// Whether the scene should actually apply all its SceneObject:s placed -// in its definition. -// Return value: An error return value signaling sucess or any particular failure. -// Anything below 0 is an error signal. - + /// + /// Loads a Scene right now, by preset name. + /// + /// The name of the Scene preset instance to load. + /// Whether the scene should actually apply all its SceneObject:s placed in its definition. + /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. virtual int LoadScene(std::string sceneName, bool placeObjects = true) { return LoadScene(sceneName, placeObjects, true); } - -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual method: ReadProperty -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Reads a property value from a Reader stream. If the name isn't -// recognized by this class, then ReadProperty of the parent class -// is called. If the property isn't recognized by any of the base classes, -// false is returned, and the Reader's position is untouched. -// Arguments: The name of the property to be read. -// A Reader lined up to the value of the property to be read. -// Return value: An error return value signaling whether the property was successfully -// read or not. 0 means it was read successfully, and any nonzero indicates -// that a property of that name could not be found in this or base classes. - + /// + /// Reads a property value from a Reader stream. If the name isn't recognized by this class, then ReadProperty of the parent class is called. If the property isn't recognized by any of the base classes, false is returned, and the Reader's position is untouched. + /// + /// The name of the property to be read. + /// A Reader lined up to the value of the property to be read. + /// An error return value signaling whether the property was successfully read or not. 0 means it was read successfully, and any nonzero indicates that a property of that name could not be found in this or base classes. virtual int ReadProperty(std::string propName, Reader &reader); - -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual method: Reset -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Resets the entire SceneMan, including its inherited members, to -// their default settings or values. -// Arguments: None. -// Return value: None. - + /// + /// Resets the entire SceneMan, including its inherited members, to their default settings or values. + /// virtual void Reset() { Clear(); } - -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual method: Save -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Saves the complete state of this SceneMan to an output stream for -// later recreation with Create(Reader &reader); -// Arguments: A Writer that the SceneMan will save itself with. -// Return value: An error return value signaling sucess or any particular failure. -// Anything below 0 is an error signal. - + /// + /// Saves the complete state of this SceneMan to an output stream for later recreation with Create(Reader &reader); + /// + /// A Writer that the SceneMan will save itself with. + /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. virtual int Save(Writer &writer) const; - -////////////////////////////////////////////////////////////////////////////////////////// -// Method: Destroy -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Destroys and resets (through Clear()) the SceneMan object. -// Arguments: None. -// Return value: None. - + /// + /// Destroys and resets (through Clear()) the SceneMan object. + /// void Destroy(); - -////////////////////////////////////////////////////////////////////////////////////////// -// Virtual method: GetClassName -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Gets the class name of this Entity. -// Arguments: None. -// Return value: A string with the friendly-formatted type name of this object. - + /// + /// Gets the class name of this Entity. + /// + /// A string with the friendly-formatted type name of this object. virtual const std::string & GetClassName() const { return m_ClassName; } - -////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetScene -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Gets the currently loaded scene, if any. -// Arguments: None. -// Return value: The scene, ownership IS NOT TRANSFERRED! - + /// + /// Gets the currently loaded scene, if any. + /// + /// The scene, ownership IS NOT TRANSFERRED! Scene * GetScene() const { return m_pCurrentScene; } - -////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetSceneDim -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Gets the total dimensions (width and height) of the scene, in pixels. -// Arguments: None. -// Return value: A Vector describing the scene dimensions. - + /// + /// Gets the total dimensions (width and height) of the scene, in pixels. + /// + /// A Vector describing the scene dimensions. Vector GetSceneDim() const; - -////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetSceneWidth -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Gets the total width of the scene, in pixels. -// Arguments: None. -// Return value: An int describing the scene width. - + /// + /// Gets the total width of the scene, in pixels. + /// + /// An int describing the scene width. int GetSceneWidth() const; - -////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetSceneHeight -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Gets the total height of the scene, in pixels. -// Arguments: None. -// Return value: An int describing the scene width. - + /// + /// Gets the total height of the scene, in pixels. + /// + /// An int describing the scene width. int GetSceneHeight() const; - -////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetMaterialPalette -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Gets access to the whole material palette array of 256 entries. -// Arguments: None. -// Return value: A pointer to the first Material in the palette. Index into it up to -// 255 to access the other Material:s in it. - + /// + /// Gets access to the whole material palette array of 256 entries. + /// + /// A pointer to the first Material in the palette. Index into it up to 255 to access the other Material:s in it. Material ** GetMaterialPalette() { return m_apMatPalette; } - -////////////////////////////////////////////////////////////////////////////////////////// -// Method: GetMaterial -////////////////////////////////////////////////////////////////////////////////////////// -// Description: Gets a specific material by name. Ownership is NOT transferred! -// Arguments: The string name of the Material to get. -// Return value: A pointer to the requested material, or 0 if no material with that -// name was found. - +/// +/// Gets a specific material by name. Ownership is NOT transferred! +/// +/// The string name of the Material to get. +/// A pointer to the requested material, or 0 if no material with that name was found. Material const * GetMaterial(const std::string &matName); @@ -402,7 +297,11 @@ class SceneMan: // transferred! // Arguments: The unsigned char index specifying screen material to get (0-255). // Return value: A reference to the requested material. OINT! - + /// + /// Gets a specific material from the material palette. Ownership is NOT transferred! + /// + /// The unsigned char index specifying screen material to get (0-255). + /// A reference to the requested material. OINT! Material const * GetMaterialFromID(unsigned char screen) { return screen >= 0 && screen < c_PaletteEntriesNumber && m_apMatPalette[screen] ? m_apMatPalette[screen] : m_apMatPalette[g_MaterialAir]; } From 38c588ec614018f6bac10f65ff6ab38a4d6da80d Mon Sep 17 00:00:00 2001 From: orengg <16946404+orengg@users.noreply.github.com> Date: Wed, 13 May 2020 18:29:38 +0300 Subject: [PATCH 06/10] Revert "convert old comment format to new for some items." This reverts commit 5f8a4eea17b64cb1e475398d6f297250163e8bdf. --- Managers/SceneMan.h | 339 ++++++++++++++++++++++++++++---------------- 1 file changed, 220 insertions(+), 119 deletions(-) diff --git a/Managers/SceneMan.h b/Managers/SceneMan.h index 99d15c94b..97f7c1cec 100644 --- a/Managers/SceneMan.h +++ b/Managers/SceneMan.h @@ -75,9 +75,7 @@ enum // Description: A simple rectangle with integer coordinates. // Parent(s): None. // Class history: 8/4/2007 IntRect created. -/// -/// A simple rectangle with integer coordinates. -/// + struct IntRect { int m_Left; @@ -89,11 +87,16 @@ struct IntRect IntRect(int left, int top, int right, int bottom) { m_Left = left; m_Top = top; m_Right = right; m_Bottom = bottom; } bool Intersects(const IntRect &rhs) { return m_Left < rhs.m_Right && m_Right > rhs.m_Left && m_Top < rhs.m_Bottom && m_Bottom > rhs.m_Top; } - /// - /// If this and the passed in IntRect intersect, this will be modified to represent the boolean AND of the two. If it doens't intersect, nothing happens and false is returned. - /// - /// The other IntRect to cut against. - /// Whether an intersection was detected and this was cut down to the AND. + +////////////////////////////////////////////////////////////////////////////////////////// +// Method: IntersectionCut +////////////////////////////////////////////////////////////////////////////////////////// +// Description: If this and the passed in IntRect intersect, this will be modified to +// represent the boolean AND of the two. If it doens't intersect, nothing +// happens and false is returned. +// Arguments: The other IntRect to cut against. +// Return value: Whether an intersection was detected and this was cut down to the AND. + bool IntersectionCut(const IntRect &rhs); @@ -118,9 +121,14 @@ class SceneMan: public: - /// - /// Constructor method used to instantiate a SceneMan object in system memory. Create() should be called before using the object. - /// + +////////////////////////////////////////////////////////////////////////////////////////// +// Constructor: SceneMan +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Constructor method used to instantiate a SceneMan object in system +// memory. Create() should be called before using the object. +// Arguments: None. + SceneMan() { m_pOrphanSearchBitmap = 0; Clear(); } @@ -130,9 +138,7 @@ class SceneMan: // Description: Destructor method used to clean up a SceneMan object before deletion // from system memory. // Arguments: None. - /// - /// Destructor method used to clean up a SceneMan object before deletion from system memory. - /// + virtual ~SceneMan() { Destroy(); } /* @@ -147,146 +153,245 @@ class SceneMan: virtual int Create(); */ - /// - /// Makes the SceneMan object ready for use. - /// - /// A string with the filepath to a Reader file from screen this SceneMan's data should be created. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. +////////////////////////////////////////////////////////////////////////////////////////// +// Method: Create +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Makes the SceneMan object ready for use. +// Arguments: A string with the filepath to a Reader file from screen this SceneMan's +// data should be created. +// Return value: An error return value signaling sucess or any particular failure. +// Anything below 0 is an error signal. + virtual int Create(std::string readerFile); - /// - /// Sets the instance name of the default Scene to be loaded if nothing else is available. - /// - /// The default scene instance name. + +////////////////////////////////////////////////////////////////////////////////////////// +// Method: SetDefaultSceneName +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Sets the instance name of the default Scene to be loaded if nothing +// else is available. +// Arguments: The default scene instance name. +// Return value: None. + void SetDefaultSceneName(std::string defaultSceneName) { m_DefaultSceneName = defaultSceneName; } - /// - /// Gets the name of the default A to be loaded if nothing else is available. - /// - /// The default Scene instance name. + +////////////////////////////////////////////////////////////////////////////////////////// +// Method: GetDefaultSceneName +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Gets the name of the default A to be loaded if nothing +// else is available. +// Arguments: None. +// Return value: The default Scene instance name. + std::string GetDefaultSceneName() const { return m_DefaultSceneName; } - /// - /// Actually loads a new Scene into memory. has to be done before using this object. - /// - /// The instance of the Scene, ownership IS transferred! - /// Whether the scene should actually apply all its SceneObject:s placed in its definition. - /// Whether the scene should actually deploy all units placed in its definition. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + +////////////////////////////////////////////////////////////////////////////////////////// +// Virtual method: LoadScene +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Actually loads a new Scene into memory. has to be done before using +// this object. +// Arguments: The instance of the Scene, ownership IS transferred! +// Whether the scene should actually apply all its SceneObject:s placed +// in its definition. +// Return value: An error return value signaling sucess or any particular failure. +// Anything below 0 is an error signal. + virtual int LoadScene(Scene *pNewScene, bool placeObjects = true, bool placeUnits = true); - /// - /// Stores a Scene reference to be loaded later into the SceneMan. - /// - /// The instance reference of the Scene, ownership IS NOT (!!) transferred! - /// Whether the scene should actually apply all its SceneObject:s placed in its definition. - /// Whether the scene should actually deploy all units placed in its definition. + +////////////////////////////////////////////////////////////////////////////////////////// +// Virtual method: SetSceneToLoad +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Stores a Scene reference to be loaded later into the SceneMan. +// Arguments: The instance reference of the Scene, ownership IS NOT (!!) transferred! +// Whether the scene should actually apply all its SceneObject:s placed +// in its definition. +// Return value: None. + virtual void SetSceneToLoad(const Scene *pLoadScene, bool placeObjects = true, bool placeUnits = true) { m_pSceneToLoad = pLoadScene; m_PlaceObjects = placeObjects; m_PlaceUnits = placeUnits; } - /// - /// Sets a scene to load later, by preset name. - /// - /// The name of the Scene preset instance to load. - /// Whether the scene should actually apply all its SceneObject:s placed in its definition. - /// Whether the scene should actually deploy all units placed in its definition. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + +////////////////////////////////////////////////////////////////////////////////////////// +// Virtual method: SetSceneToLoad +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Sets a scene to load later, by preset name. +// Arguments: The name of the Scene preset instance to load. +// Whether the scene should actually apply all its SceneObject:s placed +// in its definition. +// Return value: An error return value signaling sucess or any particular failure. +// Anything below 0 is an error signal. + virtual int SetSceneToLoad(std::string sceneName, bool placeObjects = true, bool placeUnits = true); - /// - /// Gets the stored Scene reference to be loaded later into the SceneMan. - /// - /// The instance reference of the Scene, ownership IS NOT (!!) transferred! + +////////////////////////////////////////////////////////////////////////////////////////// +// Virtual method: GetSceneToLoad +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Gets the stored Scene reference to be loaded later into the SceneMan. +// Arguments: None. +// Return value: The instance reference of the Scene, ownership IS NOT (!!) transferred! + virtual const Scene * GetSceneToLoad() { return m_pSceneToLoad; } - /// - /// Actually loads the Scene set to be loaded in SetSceneToLoad. - /// - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + +////////////////////////////////////////////////////////////////////////////////////////// +// Virtual method: LoadScene +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Actually loads the Scene set to be loaded in SetSceneToLoad. +// Arguments: None. +// Return value: An error return value signaling sucess or any particular failure. +// Anything below 0 is an error signal. + virtual int LoadScene(); - /// - /// Loads a Scene right now, by preset name. - /// - /// The name of the Scene preset instance to load. - /// Whether the scene should actually apply all its SceneObject:s placed in its definition. - /// Whether the scene should actually deploy all units placed in its definition. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + +////////////////////////////////////////////////////////////////////////////////////////// +// Virtual method: LoadScene +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Loads a Scene right now, by preset name. +// Arguments: The name of the Scene preset instance to load. +// Whether the scene should actually apply all its SceneObject:s placed +// in its definition. +// Whether the scene should actually deploy all units placed in its definition. +// Return value: An error return value signaling sucess or any particular failure. +// Anything below 0 is an error signal. + virtual int LoadScene(std::string sceneName, bool placeObjects = true, bool placeUnits = true); - /// - /// Loads a Scene right now, by preset name. - /// - /// The name of the Scene preset instance to load. - /// Whether the scene should actually apply all its SceneObject:s placed in its definition. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + +////////////////////////////////////////////////////////////////////////////////////////// +// Virtual method: LoadScene +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Loads a Scene right now, by preset name. +// Arguments: The name of the Scene preset instance to load. +// Whether the scene should actually apply all its SceneObject:s placed +// in its definition. +// Return value: An error return value signaling sucess or any particular failure. +// Anything below 0 is an error signal. + virtual int LoadScene(std::string sceneName, bool placeObjects = true) { return LoadScene(sceneName, placeObjects, true); } - /// - /// Reads a property value from a Reader stream. If the name isn't recognized by this class, then ReadProperty of the parent class is called. If the property isn't recognized by any of the base classes, false is returned, and the Reader's position is untouched. - /// - /// The name of the property to be read. - /// A Reader lined up to the value of the property to be read. - /// An error return value signaling whether the property was successfully read or not. 0 means it was read successfully, and any nonzero indicates that a property of that name could not be found in this or base classes. + +////////////////////////////////////////////////////////////////////////////////////////// +// Virtual method: ReadProperty +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Reads a property value from a Reader stream. If the name isn't +// recognized by this class, then ReadProperty of the parent class +// is called. If the property isn't recognized by any of the base classes, +// false is returned, and the Reader's position is untouched. +// Arguments: The name of the property to be read. +// A Reader lined up to the value of the property to be read. +// Return value: An error return value signaling whether the property was successfully +// read or not. 0 means it was read successfully, and any nonzero indicates +// that a property of that name could not be found in this or base classes. + virtual int ReadProperty(std::string propName, Reader &reader); - /// - /// Resets the entire SceneMan, including its inherited members, to their default settings or values. - /// + +////////////////////////////////////////////////////////////////////////////////////////// +// Virtual method: Reset +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Resets the entire SceneMan, including its inherited members, to +// their default settings or values. +// Arguments: None. +// Return value: None. + virtual void Reset() { Clear(); } - /// - /// Saves the complete state of this SceneMan to an output stream for later recreation with Create(Reader &reader); - /// - /// A Writer that the SceneMan will save itself with. - /// An error return value signaling success or any particular failure. Anything below 0 is an error signal. + +////////////////////////////////////////////////////////////////////////////////////////// +// Virtual method: Save +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Saves the complete state of this SceneMan to an output stream for +// later recreation with Create(Reader &reader); +// Arguments: A Writer that the SceneMan will save itself with. +// Return value: An error return value signaling sucess or any particular failure. +// Anything below 0 is an error signal. + virtual int Save(Writer &writer) const; - /// - /// Destroys and resets (through Clear()) the SceneMan object. - /// + +////////////////////////////////////////////////////////////////////////////////////////// +// Method: Destroy +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Destroys and resets (through Clear()) the SceneMan object. +// Arguments: None. +// Return value: None. + void Destroy(); - /// - /// Gets the class name of this Entity. - /// - /// A string with the friendly-formatted type name of this object. + +////////////////////////////////////////////////////////////////////////////////////////// +// Virtual method: GetClassName +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Gets the class name of this Entity. +// Arguments: None. +// Return value: A string with the friendly-formatted type name of this object. + virtual const std::string & GetClassName() const { return m_ClassName; } - /// - /// Gets the currently loaded scene, if any. - /// - /// The scene, ownership IS NOT TRANSFERRED! + +////////////////////////////////////////////////////////////////////////////////////////// +// Method: GetScene +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Gets the currently loaded scene, if any. +// Arguments: None. +// Return value: The scene, ownership IS NOT TRANSFERRED! + Scene * GetScene() const { return m_pCurrentScene; } - /// - /// Gets the total dimensions (width and height) of the scene, in pixels. - /// - /// A Vector describing the scene dimensions. + +////////////////////////////////////////////////////////////////////////////////////////// +// Method: GetSceneDim +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Gets the total dimensions (width and height) of the scene, in pixels. +// Arguments: None. +// Return value: A Vector describing the scene dimensions. + Vector GetSceneDim() const; - /// - /// Gets the total width of the scene, in pixels. - /// - /// An int describing the scene width. + +////////////////////////////////////////////////////////////////////////////////////////// +// Method: GetSceneWidth +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Gets the total width of the scene, in pixels. +// Arguments: None. +// Return value: An int describing the scene width. + int GetSceneWidth() const; - /// - /// Gets the total height of the scene, in pixels. - /// - /// An int describing the scene width. + +////////////////////////////////////////////////////////////////////////////////////////// +// Method: GetSceneHeight +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Gets the total height of the scene, in pixels. +// Arguments: None. +// Return value: An int describing the scene width. + int GetSceneHeight() const; - /// - /// Gets access to the whole material palette array of 256 entries. - /// - /// A pointer to the first Material in the palette. Index into it up to 255 to access the other Material:s in it. + +////////////////////////////////////////////////////////////////////////////////////////// +// Method: GetMaterialPalette +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Gets access to the whole material palette array of 256 entries. +// Arguments: None. +// Return value: A pointer to the first Material in the palette. Index into it up to +// 255 to access the other Material:s in it. + Material ** GetMaterialPalette() { return m_apMatPalette; } -/// -/// Gets a specific material by name. Ownership is NOT transferred! -/// -/// The string name of the Material to get. -/// A pointer to the requested material, or 0 if no material with that name was found. + +////////////////////////////////////////////////////////////////////////////////////////// +// Method: GetMaterial +////////////////////////////////////////////////////////////////////////////////////////// +// Description: Gets a specific material by name. Ownership is NOT transferred! +// Arguments: The string name of the Material to get. +// Return value: A pointer to the requested material, or 0 if no material with that +// name was found. + Material const * GetMaterial(const std::string &matName); @@ -297,11 +402,7 @@ class SceneMan: // transferred! // Arguments: The unsigned char index specifying screen material to get (0-255). // Return value: A reference to the requested material. OINT! - /// - /// Gets a specific material from the material palette. Ownership is NOT transferred! - /// - /// The unsigned char index specifying screen material to get (0-255). - /// A reference to the requested material. OINT! + Material const * GetMaterialFromID(unsigned char screen) { return screen >= 0 && screen < c_PaletteEntriesNumber && m_apMatPalette[screen] ? m_apMatPalette[screen] : m_apMatPalette[g_MaterialAir]; } From 55d7808adc606f7aeb5610c1727814c791df4422 Mon Sep 17 00:00:00 2001 From: orengg <16946404+orengg@users.noreply.github.com> Date: Wed, 13 May 2020 19:39:08 +0300 Subject: [PATCH 07/10] remove redundant asserts. uncomment GetSceneDim() assert. --- Managers/SceneMan.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Managers/SceneMan.cpp b/Managers/SceneMan.cpp index 102ee67aa..7496c48c9 100644 --- a/Managers/SceneMan.cpp +++ b/Managers/SceneMan.cpp @@ -442,7 +442,7 @@ void SceneMan::Destroy() Vector SceneMan::GetSceneDim() const { if (m_pCurrentScene) - //RTEAssert(m_pCurrentScene->GetTerrain() && m_pCurrentScene->GetTerrain()->GetBitmap(), "Trying to get terrain info before there is a scene or terrain!"); + RTEAssert(m_pCurrentScene->GetTerrain() && m_pCurrentScene->GetTerrain()->GetBitmap(), "Trying to get terrain info before there is a scene or terrain!"); return m_pCurrentScene->GetDimensions(); return Vector(); } @@ -3435,7 +3435,6 @@ void SceneMan::Update(int screen) if (m_pCurrentScene == nullptr) { return; } - //RTEAssert(m_pCurrentScene, "Trying to access scene before there is one!"); // Record screen was the last updated screen m_LastUpdatedScreen = screen; @@ -3578,7 +3577,6 @@ void SceneMan::Draw(BITMAP *pTargetBitmap, BITMAP *pTargetGUIBitmap, const Vecto if (m_pCurrentScene == nullptr) { return; } - //RTEAssert(m_pCurrentScene, "Trying to access scene before there is one!"); // Handy SLTerrain *pTerrain = m_pCurrentScene->GetTerrain(); From d057204ca2cb43681244071237bf0a20f697181b Mon Sep 17 00:00:00 2001 From: orengg <16946404+orengg@users.noreply.github.com> Date: Sun, 28 Jun 2020 19:46:20 +0300 Subject: [PATCH 08/10] a --- Main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Main.cpp b/Main.cpp index 1746a8206..900e41c33 100644 --- a/Main.cpp +++ b/Main.cpp @@ -10,7 +10,7 @@ \/_____/ \/_____/ \/_/ \/_/ \/_/ \/_/ \/_____/ \/_/ \/_/ \/_/ \/_/ \/_____/ \/_/ \/_/ /_/ \/_____/\/_____/ \/_____/ \/_____/ \/_/ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\*/ - +a /// /// Main driver implementation of the Retro Terrain Engine. /// Data Realms, LLC - http://www.datarealms.com From b222768a39abd4ef7f75416dd9d467d54b1f7b65 Mon Sep 17 00:00:00 2001 From: orengg <16946404+orengg@users.noreply.github.com> Date: Sun, 28 Jun 2020 19:46:29 +0300 Subject: [PATCH 09/10] b --- Main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Main.cpp b/Main.cpp index 900e41c33..31bf947e6 100644 --- a/Main.cpp +++ b/Main.cpp @@ -11,6 +11,7 @@ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\*/ a +b /// /// Main driver implementation of the Retro Terrain Engine. /// Data Realms, LLC - http://www.datarealms.com From 8dd7a69873247cd2300d3ef569f0c4f7147d29d2 Mon Sep 17 00:00:00 2001 From: orengg <16946404+orengg@users.noreply.github.com> Date: Sun, 28 Jun 2020 19:46:34 +0300 Subject: [PATCH 10/10] c --- Main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Main.cpp b/Main.cpp index 31bf947e6..524c7bac0 100644 --- a/Main.cpp +++ b/Main.cpp @@ -12,6 +12,7 @@ /////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\*/ a b +c /// /// Main driver implementation of the Retro Terrain Engine. /// Data Realms, LLC - http://www.datarealms.com