Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

3.4 KB
Raw Blame
/*
**	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 <http://www.gnu.org/licenses/>.
*/
// Modified 2025-2026 by Olcay Seygan for Zero Hour Reforged; see the git history.

////////////////////////////////////////////////////////////////////////////////
//																																						//
//  (c) 2001-2003 Electronic Arts Inc.																				//
//																																						//
////////////////////////////////////////////////////////////////////////////////

// FILE: ResourceGatheringManager.h ///////////////////////////////////////////////////////////
// The part of a Player's brain that keeps track of all Resource type Objects and makes
// gathering type decisions based on them.
// Author: Graham Smallwood, January, 2002
///////////////////////////////////////////////////////////////////////////////////////////////////

#pragma once

#ifndef RESOURCE_GATHER_MANAGER_H
#define RESOURCE_GATHER_MANAGER_H

#include "Common/GameType.h"
#include "Common/Snapshot.h"

class Object;
class Player;

// ------------------------------------------------------------------------------------------------
class ResourceGatheringManager : public MemoryPoolObject,
																 public Snapshot
{
	MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( ResourceGatheringManager, "ResourceGatheringManager" );

public:
	ResourceGatheringManager();

	Object *findBestSupplyWarehouse( Object *queryObject );		///< What Warehouse should this truck go to?
	Object *findBestSupplyCenter( Object *queryObject );			///< What Center should this truck return to?

	void addSupplyCenter( Object *newCenter );					///< I captured or built a Supply Center, so record it
	void removeSupplyCenter( Object *oldCenter );				///< Lost a supply center

	void addSupplyWarehouse( Object *newWarehouse );		///< Warehouse created, or this is starrt of game recording
	void removeSupplyWarehouse( Object *oldWarehouse );	///< Warehouse that doesn't replinish has run out of Supply

	Bool claimSuppliesDepletedVoice();	///< TRUE only the first time a gatherer asks, so the depleted voice plays once a game

	static Bool isPileOfAnotherPlayer( const Player *player, const Object *warehouse );	///< Is the supply center nearest this pile someone else's?

protected:

	Object *findBestSupplyCenterInList(Object *queryObject);

	// snapshot methods
	virtual void crc( Xfer *xfer );
	virtual void xfer( Xfer *xfer );
	virtual void loadPostProcess( void );

private:
	/// @todo Make sure the allocator for std::list<> is a good one.  Otherwise override it.
	typedef std::list<ObjectID> objectIDList;
	typedef std::list<ObjectID>::iterator objectIDListIterator;

	objectIDList m_supplyWarehouses;
	objectIDList m_supplyCenters;

	// Audio only: left out of crc, and xfer so a save format stays unchanged; a loaded game may play it once more.
	Bool m_suppliesDepletedVoicePlayed;

};

#endif