[Stream] Add pointer interface to the reader
This commit is contained in:
parent
bfe1c335af
commit
b4fd5a11d1
@ -2948,8 +2948,8 @@ namespace Game
|
|||||||
|
|
||||||
struct GfxPortalWritable
|
struct GfxPortalWritable
|
||||||
{
|
{
|
||||||
bool isQueued;
|
char isQueued;
|
||||||
bool isAncestor;
|
char isAncestor;
|
||||||
char recursionDepth;
|
char recursionDepth;
|
||||||
char hullPointCount;
|
char hullPointCount;
|
||||||
float(*hullPoints)[2];
|
float(*hullPoints)[2];
|
||||||
@ -2959,6 +2959,7 @@ namespace Game
|
|||||||
{
|
{
|
||||||
float coeffs[4];
|
float coeffs[4];
|
||||||
char side[3];
|
char side[3];
|
||||||
|
char pad;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GfxPortal
|
struct GfxPortal
|
||||||
|
@ -59,6 +59,29 @@ namespace Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* Stream::Reader::readPointer()
|
||||||
|
{
|
||||||
|
void* pointer = this->read<void*>();
|
||||||
|
if (!this->hasPointer(pointer))
|
||||||
|
{
|
||||||
|
this->pointerMap[pointer] = 0;
|
||||||
|
}
|
||||||
|
return pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Stream::Reader::mapPointer(void* oldPointer, void* newPointer)
|
||||||
|
{
|
||||||
|
if (this->hasPointer(oldPointer))
|
||||||
|
{
|
||||||
|
this->pointerMap[oldPointer] = newPointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Stream::Reader::hasPointer(void* pointer)
|
||||||
|
{
|
||||||
|
return this->pointerMap.find(pointer) != this->pointerMap.end();
|
||||||
|
}
|
||||||
|
|
||||||
Stream::Stream() : criticalSectionState(0)
|
Stream::Stream() : criticalSectionState(0)
|
||||||
{
|
{
|
||||||
memset(this->blockSize, 0, sizeof(this->blockSize));
|
memset(this->blockSize, 0, sizeof(this->blockSize));
|
||||||
|
@ -49,9 +49,14 @@ namespace Utils
|
|||||||
bool end();
|
bool end();
|
||||||
void seek(unsigned int position);
|
void seek(unsigned int position);
|
||||||
|
|
||||||
|
void* readPointer();
|
||||||
|
void mapPointer(void* oldPointer, void* newPointer);
|
||||||
|
bool hasPointer(void* pointer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned int position;
|
unsigned int position;
|
||||||
std::string buffer;
|
std::string buffer;
|
||||||
|
std::map<void*, void*> pointerMap;
|
||||||
Utils::Memory::Allocator* allocator;
|
Utils::Memory::Allocator* allocator;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user