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