| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400 |
- /*
- ** Command & Conquer Renegade(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program 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.
- **
- ** This program 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/>.
- */
- /***********************************************************************************************
- *** Confidential - Westwood Studios ***
- ***********************************************************************************************
- * *
- * Project Name : Commando *
- * *
- * $Archive:: /Commando/Code/Combat/soldierfactorygameobj.cpp $*
- * *
- * $Author:: Patrick $*
- * *
- * $Modtime:: 8/22/01 4:54p $*
- * *
- * $Revision:: 5 $*
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "soldierfactorygameobj.h"
- #include "basecontroller.h"
- #include "wwhack.h"
- #include "simpledefinitionfactory.h"
- #include "persistfactory.h"
- #include "definitionmgr.h"
- #include "combatchunkid.h"
- #include "debug.h"
- #include "wwprofile.h"
- #include "basecontroller.h"
- #include "combat.h"
- ////////////////////////////////////////////////////////////////
- // Hacks
- ////////////////////////////////////////////////////////////////
- DECLARE_FORCE_LINK (SoldierFactory)
- ////////////////////////////////////////////////////////////////
- // Editable and persist factories
- ////////////////////////////////////////////////////////////////
- SimplePersistFactoryClass <SoldierFactoryGameObjDef, CHUNKID_GAME_OBJECT_DEF_SOLDIER_FACTORY> _SoldierFactoryGameObjDefPersistFactory;
- SimplePersistFactoryClass <SoldierFactoryGameObj, CHUNKID_GAME_OBJECT_SOLDIER_FACTORY> _SoldierFactoryGameObjPersistFactory;
- DECLARE_DEFINITION_FACTORY (SoldierFactoryGameObjDef, CLASSID_GAME_OBJECT_DEF_SOLDIER_FACTORY, "Soldier Factory") _SoldierFactoryGameObjDefDefFactory;
- ////////////////////////////////////////////////////////////////
- // Save/Load constants
- ////////////////////////////////////////////////////////////////
- enum
- {
- CHUNKID_DEF_PARENT = 0x02211153,
- CHUNKID_DEF_VARIABLES,
- MICROCHUNKID_DEF_UNUSED = 1,
- };
- enum
- {
- CHUNKID_PARENT = 0x02211154,
- CHUNKID_VARIABLES,
- MICROCHUNKID_UNUSED = 1,
- };
- ////////////////////////////////////////////////////////////////
- //
- // SoldierFactoryGameObjDef
- //
- ////////////////////////////////////////////////////////////////
- SoldierFactoryGameObjDef::SoldierFactoryGameObjDef (void)
- {
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // ~SoldierFactoryGameObjDef
- //
- ////////////////////////////////////////////////////////////////
- SoldierFactoryGameObjDef::~SoldierFactoryGameObjDef (void)
- {
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Get_Class_ID
- //
- ////////////////////////////////////////////////////////////////
- uint32
- SoldierFactoryGameObjDef::Get_Class_ID (void) const
- {
- return CLASSID_GAME_OBJECT_DEF_SOLDIER_FACTORY;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Create
- //
- ////////////////////////////////////////////////////////////////
- PersistClass *
- SoldierFactoryGameObjDef::Create (void) const
- {
- SoldierFactoryGameObj *building = new SoldierFactoryGameObj;
- building->Init (*this);
- return building;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Create
- //
- ////////////////////////////////////////////////////////////////
- bool
- SoldierFactoryGameObjDef::Save (ChunkSaveClass &csave)
- {
- csave.Begin_Chunk (CHUNKID_DEF_PARENT);
- BuildingGameObjDef::Save (csave);
- csave.End_Chunk ();
- csave.Begin_Chunk (CHUNKID_DEF_VARIABLES);
- csave.End_Chunk ();
- return true;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Load
- //
- ////////////////////////////////////////////////////////////////
- bool
- SoldierFactoryGameObjDef::Load (ChunkLoadClass &cload)
- {
- while (cload.Open_Chunk ())
- {
- switch (cload.Cur_Chunk_ID ())
- {
- case CHUNKID_DEF_PARENT:
- BuildingGameObjDef::Load (cload);
- break;
- case CHUNKID_DEF_VARIABLES:
- Load_Variables (cload);
- break;
-
- default:
- Debug_Say (("Unrecognized Com Center Def chunkID\n"));
- break;
- }
- cload.Close_Chunk ();
- }
- return true;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Load_Variables
- //
- ////////////////////////////////////////////////////////////////
- void
- SoldierFactoryGameObjDef::Load_Variables (ChunkLoadClass &cload)
- {
- while (cload.Open_Micro_Chunk ()) {
-
- /*switch (cload.Cur_Micro_Chunk_ID ())
- {
- default:
- Debug_Say (("Unrecognized Com Center Def Variable chunkID\n"));
- break;
- }*/
- cload.Close_Micro_Chunk();
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Get_Factory
- //
- ////////////////////////////////////////////////////////////////
- const PersistFactoryClass &
- SoldierFactoryGameObjDef::Get_Factory (void) const
- {
- return _SoldierFactoryGameObjDefPersistFactory;
- }
- ////////////////////////////////////////////////////////////////
- //
- // SoldierFactoryGameObj
- //
- ////////////////////////////////////////////////////////////////
- SoldierFactoryGameObj::SoldierFactoryGameObj (void)
- {
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // ~SoldierFactoryGameObj
- //
- ////////////////////////////////////////////////////////////////
- SoldierFactoryGameObj::~SoldierFactoryGameObj (void)
- {
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Get_Factory
- //
- ////////////////////////////////////////////////////////////////
- const PersistFactoryClass &
- SoldierFactoryGameObj::Get_Factory (void) const
- {
- return _SoldierFactoryGameObjPersistFactory;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Init
- //
- ////////////////////////////////////////////////////////////////
- void SoldierFactoryGameObj::Init (void)
- {
- Init (Get_Definition ());
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Init
- //
- ////////////////////////////////////////////////////////////////
- void
- SoldierFactoryGameObj::Init (const SoldierFactoryGameObjDef &definition)
- {
- BuildingGameObj::Init (definition);
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Get_Definition
- //
- ////////////////////////////////////////////////////////////////
- const SoldierFactoryGameObjDef &
- SoldierFactoryGameObj::Get_Definition (void) const
- {
- return (const SoldierFactoryGameObjDef &)BaseGameObj::Get_Definition ();
- }
- ////////////////////////////////////////////////////////////////
- //
- // Save
- //
- ////////////////////////////////////////////////////////////////
- bool
- SoldierFactoryGameObj::Save (ChunkSaveClass &csave)
- {
- csave.Begin_Chunk (CHUNKID_PARENT);
- BuildingGameObj::Save (csave);
- csave.End_Chunk ();
- csave.Begin_Chunk (CHUNKID_VARIABLES);
- csave.End_Chunk ();
- return true;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Load
- //
- ////////////////////////////////////////////////////////////////
- bool
- SoldierFactoryGameObj::Load (ChunkLoadClass &cload)
- {
- while (cload.Open_Chunk ()) {
- switch (cload.Cur_Chunk_ID ()) {
- case CHUNKID_PARENT:
- BuildingGameObj::Load (cload);
- break;
-
- case CHUNKID_VARIABLES:
- Load_Variables (cload);
- break;
- default:
- Debug_Say (("Unrecognized Com Center chunkID\n"));
- break;
- }
- cload.Close_Chunk();
- }
- return true;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Load_Variables
- //
- ////////////////////////////////////////////////////////////////
- void
- SoldierFactoryGameObj::Load_Variables (ChunkLoadClass &cload)
- {
- while (cload.Open_Micro_Chunk ()) {
-
- /*switch (cload.Cur_Micro_Chunk_ID ())
- {
- default:
- Debug_Say (("Unrecognized Com Center Variable chunkID\n"));
- break;
- }*/
- cload.Close_Micro_Chunk();
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Destroyed
- //
- ////////////////////////////////////////////////////////////////
- void
- SoldierFactoryGameObj::On_Destroyed (void)
- {
- BuildingGameObj::On_Destroyed ();
- //
- // Switch off the radar for each player on this team
- //
- if (BaseController != NULL && CombatManager::I_Am_Server ()) {
- BaseController->Set_Can_Generate_Soldiers (false);
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // CnC_Initialize
- //
- ////////////////////////////////////////////////////////////////
- void
- SoldierFactoryGameObj::CnC_Initialize (BaseControllerClass *base)
- {
- BuildingGameObj::CnC_Initialize (base);
- //
- // Let the base know it can generate soldiers
- //
- if (BaseController != NULL) {
- BaseController->Set_Can_Generate_Soldiers (true);
- }
- return ;
- }
|