/* ** Command & Conquer Generals Zero Hour(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 . */ //////////////////////////////////////////////////////////////////////////////// // // // (c) 2001-2003 Electronic Arts Inc. // // // //////////////////////////////////////////////////////////////////////////////// // SidesList.h // Class to encapsulate Sides and Build Lists for maps. // Author: John Ahlquist, November 2001 #pragma once #ifndef SIDESLIST_H #define SIDESLIST_H #include "Common/Dict.h" #include "Common/Errors.h" #include "Common/GameType.h" #include "Common/Snapshot.h" #include "Common/GameMemory.h" #include "Common/STLTypedefs.h" class DataChunkInput; struct DataChunkInfo; class DataChunkOutput; class BuildListInfo; class RenderObjClass; class ScriptList; class Shadow; // ---------------------------------------------------------------------------------------------- /** This is a class that describes a Side, including build list. Note that a side corresponds to a Player in the game. The lightweight Side is used to give the WB Editor somewhere to hang build lists. */ class SidesInfo { protected: BuildListInfo* m_pBuildList; ///< linked list. Dict m_dict; ///< general player dict. ScriptList *m_scripts; ///< linked list. public: SidesInfo(void); SidesInfo(const SidesInfo& thatref); ~SidesInfo(void); void init(const Dict* d); void clear() { init(NULL); } Dict* getDict() { return &m_dict; } void addToBuildList(BuildListInfo *pBuildList, Int position); Int removeFromBuildList(BuildListInfo *pBuildList); void reorderInBuildList(BuildListInfo *pBuildList, Int newPosition); BuildListInfo* getBuildList(void) {return m_pBuildList;} ///< Gets the build list. void releaseBuildList(void) {m_pBuildList=NULL;} ///< Used when the build list is passed to class Player. ScriptList *getScriptList(void) {return(m_scripts);}; void setScriptList(ScriptList *pScriptList) {m_scripts = pScriptList;}; // ug, I hate having to overload stuff, but this makes it a lot easier to make copies safely SidesInfo& operator=(const SidesInfo& that); }; // ---------------------------------------------------------------------------------------------- class TeamsInfo { private: Dict m_dict; public: Dict* getDict() { return &m_dict; } void init(const Dict* d) { m_dict.clear(); if (d) m_dict = *d; } void clear() { init(NULL); } }; // ---------------------------------------------------------------------------------------------- // a wrapper class to make this a little cleaner. class TeamsInfoRec { private: Int m_numTeams; Int m_numTeamsAllocated; TeamsInfo* m_teams; public: TeamsInfoRec(); TeamsInfoRec(const TeamsInfoRec& thatref); ~TeamsInfoRec(); TeamsInfoRec& operator=(const TeamsInfoRec& thatref); void clear(); TeamsInfo *findTeamInfo(AsciiString name, Int* index); void addTeam(const Dict* d); void removeTeam(Int i); Int getNumTeams() const { return m_numTeams; } TeamsInfo * getTeamInfo(Int team) { if (team>=0&&team=0&&side=0&&side=0 && ndx < MAX_RESOURCE_GATHERERS) return m_resourceGatherers[ndx]; return INVALID_ID;} void setGathererID(Int ndx, ObjectID id) {if (ndx>=0 && ndx < MAX_RESOURCE_GATHERERS) m_resourceGatherers[ndx] = id;} Int getDesiredGatherers(void) {return m_desiredGatherers;}; void setDesiredGatherers(Int desired) {m_desiredGatherers = desired;} Int getCurrentGatherers(void) {return m_currentGatherers;}; void setCurrentGatherers(Int cur) {m_currentGatherers = cur;} BuildListInfo *duplicate(void); }; inline void BuildListInfo::decrementNumRebuilds(void) { if (m_numRebuilds > 0 && m_numRebuilds != UNLIMITED_REBUILDS) m_numRebuilds--; } inline void BuildListInfo::incrementNumRebuilds(void) { if (m_numRebuilds != UNLIMITED_REBUILDS) m_numRebuilds++; } inline Bool BuildListInfo::isBuildable( void ) { if (getNumRebuilds() > 0 || getNumRebuilds() == BuildListInfo::UNLIMITED_REBUILDS) return true; return false; } #endif