Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
VisTableClass.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__VISTABLECLASS_H
13#define TT_INCLUDE__VISTABLECLASS_H
14
15
16
17#include "engine_vector.h"
18#include "multilist.h"
19
20
21class CompressedVisTableClass;
22class VisTableClass :
23 public RefCountClass,
24 public MultiListObjectClass
25{
26
27 int bitCount; // 0010 0028
28 union
29 {
30 byte* bytes; // 0014 002C
31 uint32* longs; // 0014 002C
32 };
33
34 int visSectorId; // 0018 0030
35 int timeStamp; // 001C 0034
36
37public:
38
39 VisTableClass(uint, int);
40 VisTableClass(CompressedVisTableClass*, int, int);
41 VisTableClass(const VisTableClass& that);
42 ~VisTableClass();
43 const VisTableClass& operator =(const VisTableClass& that);
44
45 void Alloc_Buffer(int);
46 byte* Get_Bytes() const { return bytes; }
47 int Get_Byte_Count() const { return 4 * Get_Long_Count(); }
48 uint32* Get_Longs() const { return longs; }
49 int Get_Long_Count() const;
50 void Reset_All();
51 void Set_All();
52 void Delete_Bit(int);
53 void Merge(const VisTableClass &that);
54 void Invert();
55 bool Is_Equal_To(const VisTableClass &that) const;
56 int Count_Differences(const VisTableClass &that) const;
57 int Count_True_Bits() const;
58 float Match_Fraction(const VisTableClass &that) const;
59 int Get_Bit_Count() const { return bitCount; }
60 void Set_Vis_Sector_ID(int _visSectorId) { visSectorId = _visSectorId; }
61 int Get_Vis_Sector_ID() const { return visSectorId; }
62 void Set_Time_Stamp(int _timeStamp) { timeStamp = _timeStamp; }
63 int Get_Time_Stamp() const { return timeStamp; }
64 bool Get_Bit(int) const;
65 void Set_Bit(int, bool);
66
67}; // 0020 0038
68
69class CompressedVisTableClass
70{
71public:
72 CompressedVisTableClass() : BufferSize(0), Buffer(0)
73 {
74 }
75 CompressedVisTableClass(VisTableClass *bits) : BufferSize(0), Buffer(0)
76 {
77 Compress(bits->Get_Bytes(),bits->Get_Byte_Count());
78 }
79 CompressedVisTableClass(CompressedVisTableClass &that) : BufferSize(0), Buffer(0)
80 {
81 *this = that;
82 }
83 ~CompressedVisTableClass()
84 {
85 if (Buffer)
86 {
87 delete[] Buffer;
88 }
89 }
90 CompressedVisTableClass& operator=(const CompressedVisTableClass& that)
91 {
92 if (Buffer)
93 {
94 delete[] Buffer;
95 }
96 BufferSize = that.BufferSize;
97 Buffer = new unsigned char[BufferSize];
98 memcpy(Buffer,that.Buffer,BufferSize);
99 return *this;
100 }
101 unsigned char *Get_Bytes()
102 {
103 return Buffer;
104 }
105 int Get_Byte_Count()
106 {
107 return BufferSize;
108 }
109 void Load(ChunkLoadClass &cload);
110 void Save(ChunkSaveClass &csave);
111 void Compress(unsigned char *bytes,int src_size);
112 void Decompress(unsigned char *bytes,int src_size);
113private:
114 int BufferSize;
115 unsigned char *Buffer;
116};
117
118#endif