-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements initial ScenarioClass extension.
- Loading branch information
Showing
6 changed files
with
568 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
/******************************************************************************* | ||
/* O P E N S O U R C E -- V I N I F E R A ** | ||
/******************************************************************************* | ||
* | ||
* @project Vinifera | ||
* | ||
* @file SCENARIOEXT.CPP | ||
* | ||
* @author CCHyper | ||
* | ||
* @brief Extended ScenarioClass class. | ||
* | ||
* @license Vinifera is free software: you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation, either version | ||
* 3 of the License, or (at your option) any later version. | ||
* | ||
* Vinifera is distributed in the hope that it will be | ||
* useful, but WITHOUT ANY WARRANTY; without even the implied | ||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
* PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program. | ||
* If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
******************************************************************************/ | ||
#include "scenarioext.h" | ||
#include "asserthandler.h" | ||
#include "debughandler.h" | ||
|
||
|
||
ScenarioClassExtension *ScenarioExtension = nullptr; | ||
|
||
|
||
/** | ||
* Class constructor. | ||
* | ||
* @author: CCHyper | ||
*/ | ||
ScenarioClassExtension::ScenarioClassExtension(ScenarioClass *this_ptr) : | ||
Extension(this_ptr) | ||
{ | ||
ASSERT(ThisPtr != nullptr); | ||
//DEV_DEBUG_TRACE("ScenarioClassExtension constructor - 0x%08X\n", (uintptr_t)(ThisPtr)); | ||
//DEV_DEBUG_WARNING("ScenarioClassExtension constructor - 0x%08X\n", (uintptr_t)(ThisPtr)); | ||
|
||
/** | ||
* This copies the behavior of the games ScenarioClass. | ||
*/ | ||
Init_Clear(); | ||
|
||
IsInitialized = true; | ||
} | ||
|
||
|
||
/** | ||
* Class no-init constructor. | ||
* | ||
* @author: CCHyper | ||
*/ | ||
ScenarioClassExtension::ScenarioClassExtension(const NoInitClass &noinit) : | ||
Extension(noinit) | ||
{ | ||
IsInitialized = false; | ||
} | ||
|
||
|
||
/** | ||
* Class deconstructor. | ||
* | ||
* @author: CCHyper | ||
*/ | ||
ScenarioClassExtension::~ScenarioClassExtension() | ||
{ | ||
//DEV_DEBUG_TRACE("ScenarioClassExtension deconstructor - 0x%08X\n", (uintptr_t)(ThisPtr)); | ||
//DEV_DEBUG_WARNING("ScenarioClassExtension deconstructor - 0x%08X\n", (uintptr_t)(ThisPtr)); | ||
|
||
IsInitialized = false; | ||
} | ||
|
||
|
||
/** | ||
* Initializes an object from the stream where it was saved previously. | ||
* | ||
* @author: CCHyper | ||
*/ | ||
HRESULT ScenarioClassExtension::Load(IStream *pStm) | ||
{ | ||
ASSERT(ThisPtr != nullptr); | ||
//DEV_DEBUG_TRACE("ScenarioClassExtension::Load - 0x%08X\n", (uintptr_t)(ThisPtr)); | ||
|
||
HRESULT hr = Extension::Load(pStm); | ||
if (FAILED(hr)) { | ||
return E_FAIL; | ||
} | ||
|
||
new (this) ScenarioClassExtension(NoInitClass()); | ||
|
||
return hr; | ||
} | ||
|
||
|
||
/** | ||
* Saves an object to the specified stream. | ||
* | ||
* @author: CCHyper | ||
*/ | ||
HRESULT ScenarioClassExtension::Save(IStream *pStm, BOOL fClearDirty) | ||
{ | ||
ASSERT(ThisPtr != nullptr); | ||
//DEV_DEBUG_TRACE("ScenarioClassExtension::Save - 0x%08X\n", (uintptr_t)(ThisPtr)); | ||
|
||
HRESULT hr = Extension::Save(pStm, fClearDirty); | ||
if (FAILED(hr)) { | ||
return hr; | ||
} | ||
|
||
return hr; | ||
} | ||
|
||
|
||
/** | ||
* Return the raw size of class data for save/load purposes. | ||
* | ||
* @author: CCHyper | ||
*/ | ||
int ScenarioClassExtension::Size_Of() const | ||
{ | ||
ASSERT(ThisPtr != nullptr); | ||
//DEV_DEBUG_TRACE("ScenarioClassExtension::Size_Of - 0x%08X\n", (uintptr_t)(ThisPtr)); | ||
|
||
return sizeof(*this); | ||
} | ||
|
||
|
||
/** | ||
* Removes the specified target from any targeting and reference trackers. | ||
* | ||
* @author: CCHyper | ||
*/ | ||
void ScenarioClassExtension::Detach(TARGET target, bool all) | ||
{ | ||
ASSERT(ThisPtr != nullptr); | ||
//DEV_DEBUG_TRACE("ScenarioClassExtension::Detach - 0x%08X\n", (uintptr_t)(ThisPtr)); | ||
|
||
} | ||
|
||
|
||
/** | ||
* Compute a unique crc value for this instance. | ||
* | ||
* @author: CCHyper | ||
*/ | ||
void ScenarioClassExtension::Compute_CRC(WWCRCEngine &crc) const | ||
{ | ||
ASSERT(ThisPtr != nullptr); | ||
//DEV_DEBUG_TRACE("ScenarioClassExtension::Compute_CRC - 0x%08X\n", (uintptr_t)(ThisPtr)); | ||
|
||
} | ||
|
||
|
||
/** | ||
* Initialises any values for this instance. | ||
* | ||
* @author: CCHyper | ||
*/ | ||
void ScenarioClassExtension::Init_Clear() | ||
{ | ||
ASSERT(ThisPtr != nullptr); | ||
//DEV_DEBUG_TRACE("ScenarioClassExtension::Init - 0x%08X\n", (uintptr_t)(ThisPtr)); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/******************************************************************************* | ||
/* O P E N S O U R C E -- V I N I F E R A ** | ||
/******************************************************************************* | ||
* | ||
* @project Vinifera | ||
* | ||
* @file SCENARIOEXT.H | ||
* | ||
* @author CCHyper | ||
* | ||
* @brief Extended ScenarioClass class. | ||
* | ||
* @license Vinifera is free software: you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation, either version | ||
* 3 of the License, or (at your option) any later version. | ||
* | ||
* Vinifera is distributed in the hope that it will be | ||
* useful, but WITHOUT ANY WARRANTY; without even the implied | ||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
* PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program. | ||
* If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
******************************************************************************/ | ||
#pragma once | ||
|
||
#include "extension.h" | ||
#include "container.h" | ||
|
||
#include "noinit.h" | ||
|
||
|
||
class ScenarioClass; | ||
|
||
|
||
class ScenarioClassExtension final : public Extension<ScenarioClass> | ||
{ | ||
public: | ||
ScenarioClassExtension(ScenarioClass *this_ptr); | ||
ScenarioClassExtension(const NoInitClass &noinit); | ||
~ScenarioClassExtension(); | ||
|
||
virtual HRESULT Load(IStream *pStm) override; | ||
virtual HRESULT Save(IStream *pStm, BOOL fClearDirty) override; | ||
virtual int Size_Of() const override; | ||
|
||
virtual void Detach(TARGET target, bool all = true) override; | ||
virtual void Compute_CRC(WWCRCEngine &crc) const override; | ||
|
||
void Init_Clear(); | ||
|
||
public: | ||
|
||
}; | ||
|
||
|
||
/** | ||
* Global instance of the extended class. | ||
*/ | ||
extern ScenarioClassExtension *ScenarioExtension; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.