Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
PointerRemapClass.h
1/* Renegade Scripts.dll
2 Copyright 2013 Tiberian Technologies
3
4 This file is part of the Renegade scripts.dll
5 The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 2, or (at your option) any later
8 version. See the file COPYING for more details.
9 In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence.
10 Only the source code to the module(s) containing the licenced code has to be released.
11*/
12#ifndef TT_INCLUDE__POINTERREMAPCLASS_H
13#define TT_INCLUDE__POINTERREMAPCLASS_H
14#include "engine_vector.h"
15
16class PointerRemapClass
17{
18 struct PtrPairStruct {
19 void* OldPointer;
20 void* NewPointer;
21 PtrPairStruct(void* oldptr, void* newptr) : OldPointer(oldptr), NewPointer(newptr)
22 {
23 }
24 PtrPairStruct() : OldPointer(0), NewPointer(0)
25 {
26 }
27 bool operator==(const PtrPairStruct &that)
28 {
29 return (OldPointer == that.OldPointer) && (NewPointer == that.NewPointer);
30 }
31 bool operator!=(const PtrPairStruct &that)
32 {
33 return (OldPointer != that.OldPointer) || (NewPointer != that.NewPointer);
34 }
35 };
36 struct PtrRemapStruct {
37 void** PointerToRemap;
38 PtrRemapStruct() : PointerToRemap(0)
39 {
40 }
41 bool operator==(const PtrRemapStruct &that)
42 {
43 return PointerToRemap == that.PointerToRemap;
44 }
45 bool operator!=(const PtrRemapStruct &that)
46 {
47 return PointerToRemap != that.PointerToRemap;
48 }
49 };
50 DynamicVectorClass<PtrPairStruct> PointerPairTable;
51 DynamicVectorClass<PtrRemapStruct> PointerRequestTable;
52 DynamicVectorClass<PtrRemapStruct> RefCountRequestTable;
53 static int ptr_pair_compare_function(const void* ptr1,const void* ptr2);
54 static int ptr_request_compare_function(const void* ptr1,const void* ptr2);
55public:
56 PointerRemapClass()
57 {
58 PointerPairTable.Set_Growth_Step(4096);
59 PointerRequestTable.Set_Growth_Step(4096);
60 RefCountRequestTable.Set_Growth_Step(4096);
61 }
62 ~PointerRemapClass()
63 {
64 }
65 void Reset();
66 void Process();
67 void Register_Pointer(void* old_pointer,void* new_pointer);
68 void Request_Pointer_Remap(void** pointer_to_convert);
69 void Request_Ref_Counted_Pointer_Remap(RefCountClass** pointer_to_convert);
70 void Process_Request_Table(DynamicVectorClass<PtrRemapStruct>& request_table,bool refcount);
71};
72
73
74#endif