forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 202
Expand file tree
/
Copy pathGhostObject.h
More file actions
126 lines (110 loc) · 4.85 KB
/
GhostObject.h
File metadata and controls
126 lines (110 loc) · 4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
** 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/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
// FILE: GhostObject.h ////////////////////////////////////////////////////////////
// Placeholder for objects that have been deleted but need to be maintained because
// a player can see them fogged.
// Author: Mark Wilczynski, August 2002
#pragma once
#include "Lib/BaseType.h"
#include "Common/Snapshot.h"
// #define DEBUG_FOG_MEMORY ///< this define is used to force object snapshots for all players, not just local player.
class Object;
class PartitionData;
enum GeometryType CPP_11(: Int);
enum ObjectID CPP_11(: Int);
class GhostObject : public Snapshot
{
public:
GhostObject();
virtual ~GhostObject();
virtual void snapShot(int playerIndex)=0;
virtual void updateParentObject(Object *object, PartitionData *mod)=0;
virtual void freeSnapShot(int playerIndex)=0;
PartitionData *friend_getPartitionData() const {return m_partitionData;}
GeometryType getGeometryType() const {return m_parentGeometryType;}
Bool getGeometrySmall() const {return m_parentGeometryIsSmall;}
Real getGeometryMajorRadius() const {return m_parentGeometryMajorRadius;}
Real getGeometryMinorRadius() const {return m_parentGeometryminorRadius;}
Real getParentAngle() const {return m_parentAngle;}
const Coord3D *getParentPosition() const {return &m_parentPosition;}
protected:
virtual void crc( Xfer *xfer );
virtual void xfer( Xfer *xfer );
virtual void loadPostProcess();
Object *m_parentObject; ///< object which we are ghosting
GeometryType m_parentGeometryType;
Bool m_parentGeometryIsSmall;
Real m_parentGeometryMajorRadius;
Real m_parentGeometryminorRadius;
Real m_parentAngle;
Coord3D m_parentPosition;
PartitionData *m_partitionData; ///< our PartitionData
};
class GhostObjectManager : public Snapshot
{
public:
GhostObjectManager();
virtual ~GhostObjectManager();
virtual void reset();
virtual GhostObject *addGhostObject(Object *object, PartitionData *pd);
virtual void removeGhostObject(GhostObject *mod);
virtual void setLocalPlayerIndex(int playerIndex) { m_localPlayer = playerIndex; }
int getLocalPlayerIndex() { return m_localPlayer; }
virtual void updateOrphanedObjects(int *playerIndexList, int playerIndexCount);
virtual void releasePartitionData(); ///<saves data needed to later rebuild partition manager data.
virtual void restorePartitionData(); ///<restores ghost objects into the partition manager.
void lockGhostObjects(Bool enableLock) {m_lockGhostObjects=enableLock;} ///<temporary lock on creating new ghost objects. Only used by map border resizing!
void saveLockGhostObjects(Bool enableLock) {m_saveLockGhostObjects=enableLock;}
inline Bool trackAllPlayers() const; ///< returns whether the ghost object status is tracked for all players or for the local player only
protected:
virtual void crc( Xfer *xfer );
virtual void xfer( Xfer *xfer );
virtual void loadPostProcess();
Int m_localPlayer;
Bool m_lockGhostObjects;
Bool m_saveLockGhostObjects; ///< used to lock the ghost object system during a save/load
Bool m_trackAllPlayers; ///< if enabled, tracks ghost object status for all players, otherwise for the local player only
};
inline Bool GhostObjectManager::trackAllPlayers() const
{
#ifdef DEBUG_FOG_MEMORY
return true;
#else
return m_trackAllPlayers;
#endif
}
// TheSuperHackers @feature bobtista 19/01/2026
// GhostObjectManager that does nothing for headless mode.
// Note: Does NOT override crc/xfer/loadPostProcess to maintain save compatibility.
class GhostObjectManagerDummy : public GhostObjectManager
{
public:
virtual void reset(void) {}
virtual GhostObject *addGhostObject(Object *object, PartitionData *pd) { return nullptr; }
virtual void removeGhostObject(GhostObject *mod) {}
virtual void updateOrphanedObjects(int *playerIndexList, int playerIndexCount) {}
virtual void releasePartitionData(void) {}
virtual void restorePartitionData(void) {}
};
// the singleton
extern GhostObjectManager *TheGhostObjectManager;