Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
pointerremap.h
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/***********************************************************************************************
20 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21 ***********************************************************************************************
22 * *
23 * Project Name : WWSaveLoad *
24 * *
25 * $Archive:: /Commando/Code/wwsaveload/pointerremap.h $*
26 * *
27 * Author:: Greg Hjelstrom *
28 * *
29 * $Modtime:: 4/30/01 1:54p $*
30 * *
31 * $Revision:: 6 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36
37
38#if defined(_MSC_VER)
39#pragma once
40#endif
41
42
43#ifndef POINTERREMAP_H
44#define POINTERREMAP_H
45
46#ifdef _UNIX
47#include "osdep/osdep.h"
48#endif
49
50#include "always.h"
51#include "vector.h"
52
53class RefCountClass;
54
55
57{
58 public:
59
62
63 void Reset(void);
64 void Process(void);
65
66 void Register_Pointer (void *old_pointer, void *new_pointer);
67
68#ifdef WWDEBUG
69 void Request_Pointer_Remap (void **pointer_to_convert,const char * file,int line);
70 void Request_Ref_Counted_Pointer_Remap (RefCountClass **pointer_to_convert,const char * file, int line);
71#else
72 void Request_Pointer_Remap (void **pointer_to_convert);
73 void Request_Ref_Counted_Pointer_Remap (RefCountClass **pointer_to_convert);
74#endif
75
76 private:
77
78 struct PtrPairStruct
79 {
80 PtrPairStruct(void) {}
81 PtrPairStruct(void * oldptr,void * newptr) : OldPointer(oldptr),NewPointer(newptr) {}
82 bool operator == (const PtrPairStruct & that) { return ((OldPointer == that.OldPointer) && (NewPointer == that.NewPointer)); }
83 bool operator != (const PtrPairStruct & that) { return !(*this == that); }
84
85 void * OldPointer;
86 void * NewPointer;
87 };
88
89 struct PtrRemapStruct
90 {
91 PtrRemapStruct(void) {}
92 bool operator == (const PtrRemapStruct & that) { return (PointerToRemap == that.PointerToRemap); }
93 bool operator != (const PtrRemapStruct & that) { return !(*this == that); }
94
95 void ** PointerToRemap;
96#ifdef WWDEBUG
97 const char * File;
98 int Line;
99#endif
100 };
101
102 void Process_Request_Table(DynamicVectorClass<PtrRemapStruct> & request_table,bool refcount);
103 static int __cdecl ptr_pair_compare_function(void const * ptr1, void const * ptr2);
104 static int __cdecl ptr_request_compare_function(void const * ptr1, void const * ptr2);
105
106 /*
107 ** Array of pointers associated with ID values to assist in swizzling.
108 */
109 DynamicVectorClass<PtrPairStruct> PointerPairTable;
110 DynamicVectorClass<PtrRemapStruct> PointerRequestTable;
111 DynamicVectorClass<PtrRemapStruct> RefCountRequestTable;
112};
113
114
115#endif
#define __cdecl
Definition IFF.H:44
Definition file.h:83
void Register_Pointer(void *old_pointer, void *new_pointer)
void Request_Ref_Counted_Pointer_Remap(RefCountClass **pointer_to_convert)
void Request_Pointer_Remap(void **pointer_to_convert)