Standardise fixed-width integer usage in touched files

This commit is contained in:
notmatthewbeshay
2026-03-11 15:38:42 +11:00
parent 83ba8d8384
commit 0ab0fd9209
64 changed files with 229 additions and 229 deletions
@@ -10,7 +10,7 @@ void ConsoleSaveFileConverter::ProcessSimpleFile(ConsoleSaveFile *sourceSave, Fi
unsigned int numberOfBytesRead = 0;
unsigned int numberOfBytesWritten = 0;
uint8_t *data = new uint8_t[sourceFileEntry->getFileSize()];
std::uint8_t *data = new std::uint8_t[sourceFileEntry->getFileSize()];
// Read from source
sourceSave->readFile(sourceFileEntry, data, sourceFileEntry->getFileSize(), &numberOfBytesRead);
@@ -25,7 +25,7 @@ ConsoleSaveFileInputStream::ConsoleSaveFileInputStream(ConsoleSaveFile *saveFile
//the next byte of data, or -1 if the end of the file is reached.
int ConsoleSaveFileInputStream::read()
{
uint8_t byteRead = static_cast<uint8_t>(0);
std::uint8_t byteRead = static_cast<std::uint8_t>(0);
unsigned int numberOfBytesRead;
bool result = m_saveFile->readFile(
@@ -38,7 +38,7 @@ void ConsoleSaveFileOutputStream::write(unsigned int b)
{
unsigned int numberOfBytesWritten;
uint8_t value = (uint8_t) b;
std::uint8_t value = (std::uint8_t) b;
bool result = m_saveFile->writeFile(
m_file,
+2 -2
View File
@@ -410,7 +410,7 @@ std::vector<File *> *File::listFiles() const
CellFsErrno err = cellFsOpendir(filePath , &fd);
CellFsDirectoryEntry de;
uint32_t count = 0;
std::uint32_t count = 0;
err = cellFsGetDirectoryEntries(fd, &de, sizeof(CellFsDirectoryEntry), &count);
if(count != 0)
{
@@ -572,7 +572,7 @@ std::vector<File *> *File::listFiles(FileFilter *filter) const
CellFsErrno err = cellFsOpendir(filePath, &fd);
CellFsDirectoryEntry de;
uint32_t count = 0;
std::uint32_t count = 0;
err = cellFsGetDirectoryEntries(fd, &de, sizeof(CellFsDirectoryEntry), &count);
if(count != 0)
{
+1 -1
View File
@@ -75,7 +75,7 @@ int FileInputStream::read()
return -1;
}
uint8_t byteRead = static_cast<uint8_t>(0);
std::uint8_t byteRead = static_cast<std::uint8_t>(0);
const size_t numberOfBytesRead = std::fread(&byteRead, 1, 1, m_fileHandle);
if( std::ferror(m_fileHandle) != 0 )
@@ -51,7 +51,7 @@ void FileOutputStream::write(unsigned int b)
return;
}
uint8_t value = (uint8_t) b;
std::uint8_t value = (std::uint8_t) b;
const size_t numberOfBytesWritten = std::fwrite(&value, 1, 1, m_fileHandle);
const int result = std::ferror(m_fileHandle);
+4 -4
View File
@@ -312,7 +312,7 @@ HRESULT Compression::Compress(void *pDestination, unsigned int *pDestSize, void
*pDestSize = (unsigned int)destSize;
return ( ( res == Z_OK ) ? S_OK : -1 );
#elif defined __PS3__
uint32_t destSize = (uint32_t)(*pDestSize);
std::uint32_t destSize = (std::uint32_t)(*pDestSize);
bool res = EdgeZLib::Compress(pDestination, &destSize, pSource, SrcSize);
*pDestSize = (unsigned int)destSize;
return ( ( res ) ? S_OK : -1 );
@@ -340,7 +340,7 @@ HRESULT Compression::Decompress(void *pDestination, unsigned int *pDestSize, voi
*pDestSize = (unsigned int)destSize;
return ( ( res == Z_OK ) ? S_OK : -1 );
#elif defined __PS3__
uint32_t destSize = (uint32_t)(*pDestSize);
std::uint32_t destSize = (std::uint32_t)(*pDestSize);
bool res = EdgeZLib::Decompress(pDestination, &destSize, pSource, SrcSize);
*pDestSize = (unsigned int)destSize;
return ( ( res ) ? S_OK : -1 );
@@ -356,11 +356,11 @@ HRESULT Compression::Decompress(void *pDestination, unsigned int *pDestSize, voi
#ifndef _XBOX
void Compression::VitaVirtualDecompress(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize) // (LPVOID buf, SIZE_T dwSize, LPVOID dst)
{
uint8_t *pSrc = (uint8_t *)pSource;
std::uint8_t *pSrc = (std::uint8_t *)pSource;
int Offset = 0;
int Page = 0;
int Index = 0;
uint8_t* Data = (uint8_t*)pDestination;
std::uint8_t* Data = (std::uint8_t*)pDestination;
while( Index != SrcSize )
{
// is this a normal value
+10 -10
View File
@@ -164,11 +164,11 @@ void CustomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks)
// 4J - this comparison used to just be with 0.0f but is now varied by block above
if (yc * CHUNK_HEIGHT + y < mapHeight)
{
tileId = (uint8_t) Tile::rock_Id;
tileId = (std::uint8_t) Tile::rock_Id;
}
else if (yc * CHUNK_HEIGHT + y < waterHeight)
{
tileId = (uint8_t) Tile::calmWater_Id;
tileId = (std::uint8_t) Tile::calmWater_Id;
}
// 4J - more extra code to make sure that the column at the edge of the world is just water & rock, to match the infinite sea that
@@ -226,8 +226,8 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi
int run = -1;
uint8_t top = b->topMaterial;
uint8_t material = b->material;
std::uint8_t top = b->topMaterial;
std::uint8_t material = b->material;
LevelGenerationOptions *lgo = app.getLevelGenerationOptions();
if(lgo != NULL)
@@ -250,7 +250,7 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi
if (y <= 1 + random->nextInt(2)) // 4J - changed to make the bedrock not have bits you can get stuck in
// if (y <= 0 + random->nextInt(5))
{
blocks[offs] = (uint8_t) Tile::unbreakable_Id;
blocks[offs] = (std::uint8_t) Tile::unbreakable_Id;
}
else
{
@@ -267,7 +267,7 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi
if (runDepth <= 0)
{
top = 0;
material = (uint8_t) Tile::rock_Id;
material = (std::uint8_t) Tile::rock_Id;
}
else if (y >= waterHeight - 4 && y <= waterHeight + 1)
{
@@ -281,8 +281,8 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi
if (y < waterHeight && top == 0)
{
if (temp < 0.15f) top = (uint8_t) Tile::ice_Id;
else top = (uint8_t) Tile::calmWater_Id;
if (temp < 0.15f) top = (std::uint8_t) Tile::ice_Id;
else top = (std::uint8_t) Tile::calmWater_Id;
}
run = runDepth;
@@ -299,7 +299,7 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi
if (run == 0 && material == Tile::sand_Id)
{
run = random->nextInt(4);
material = (uint8_t) Tile::sandStone_Id;
material = (std::uint8_t) Tile::sandStone_Id;
}
}
}
@@ -328,7 +328,7 @@ LevelChunk *CustomLevelSource::getChunk(int xOffs, int zOffs)
// 4J - now allocating this with a physical alloc & bypassing general memory management so that it will get cleanly freed
int blocksSize = Level::maxBuildHeight * 16 * 16;
uint8_t *tileData = (uint8_t *)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE);
std::uint8_t *tileData = (std::uint8_t *)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE);
XMemSet128(tileData,0,blocksSize);
byteArray blocks = byteArray(tileData,blocksSize);
// byteArray blocks = byteArray(16 * level->depth * 16);
@@ -19,7 +19,7 @@ _MapDataMappings::_MapDataMappings()
#ifndef _DURANGO
ZeroMemory(xuids,sizeof(PlayerUID)*MAXIMUM_MAP_SAVE_DATA);
#endif
ZeroMemory(dimensions,sizeof(uint8_t)*(MAXIMUM_MAP_SAVE_DATA/4));
ZeroMemory(dimensions,sizeof(std::uint8_t)*(MAXIMUM_MAP_SAVE_DATA/4));
}
int _MapDataMappings::getDimension(int id)
@@ -84,7 +84,7 @@ _MapDataMappings_old::_MapDataMappings_old()
#ifndef _DURANGO
ZeroMemory(xuids,sizeof(PlayerUID)*MAXIMUM_MAP_SAVE_DATA);
#endif
ZeroMemory(dimensions,sizeof(uint8_t)*(MAXIMUM_MAP_SAVE_DATA/8));
ZeroMemory(dimensions,sizeof(std::uint8_t)*(MAXIMUM_MAP_SAVE_DATA/8));
}
int _MapDataMappings_old::getDimension(int id)
+8 -8
View File
@@ -57,10 +57,10 @@ RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path)
//if ((GetFileSize(file,NULL) & 0xfff) != 0)
if ((fileEntry->getFileSize() & 0xfff) != 0)
{
//uint8_t zero = 0;
//std::uint8_t zero = 0;
unsigned int numberOfBytesWritten = 0;
unsigned int bytesToWrite = 0x1000 - (fileEntry->getFileSize() & 0xfff);
uint8_t *zeroBytes = new uint8_t[ bytesToWrite ];
std::uint8_t *zeroBytes = new std::uint8_t[ bytesToWrite ];
ZeroMemory(zeroBytes, bytesToWrite);
/* the file size is not a multiple of 4KB, grow it */
@@ -233,8 +233,8 @@ DataInputStream *RegionFile::getChunkDataInputStream(int x, int z) // TODO - was
}
MemSect(50);
uint8_t *data = new uint8_t[length];
uint8_t *decomp = new uint8_t[decompLength];
std::uint8_t *data = new std::uint8_t[length];
std::uint8_t *decomp = new std::uint8_t[decompLength];
MemSect(0);
readDecompLength = decompLength;
m_saveFile->readFile(fileEntry,data,length,&numberOfBytesRead);
@@ -273,10 +273,10 @@ DataOutputStream *RegionFile::getChunkDataOutputStream(int x, int z)
}
/* write a chunk at (x,z) with length bytes of data to disk */
void RegionFile::write(int x, int z, uint8_t *data, int length) // TODO - was synchronized
void RegionFile::write(int x, int z, std::uint8_t *data, int length) // TODO - was synchronized
{
// 4J Stu - Do the compression here so that we know how much space we need to store the compressed data
uint8_t *compData = new uint8_t[length + 2048]; // presuming compression is going to make this smaller... UPDATE - for some really small things this isn't the case. Added 2K on here to cover those.
std::uint8_t *compData = new std::uint8_t[length + 2048]; // presuming compression is going to make this smaller... UPDATE - for some really small things this isn't the case. Added 2K on here to cover those.
unsigned int compLength = length;
Compression::getCompression()->CompressLZXRLE(compData,&compLength,data,length);
@@ -403,7 +403,7 @@ void RegionFile::write(int x, int z, uint8_t *data, int length) // TODO - was s
}
/* write a chunk data to the region file at specified sector number */
void RegionFile::write(int sectorNumber, uint8_t *data, int length, unsigned int compLength)
void RegionFile::write(int sectorNumber, std::uint8_t *data, int length, unsigned int compLength)
{
unsigned int numberOfBytesWritten = 0;
//SetFilePointer(file,sectorNumber * SECTOR_BYTES,0,FILE_BEGIN);
@@ -451,7 +451,7 @@ void RegionFile::insertInitialSectors()
{
m_saveFile->setFilePointer( fileEntry, 0, SaveFileSeekOrigin::Begin );
unsigned int numberOfBytesWritten = 0;
uint8_t zeroBytes[ SECTOR_BYTES ];
std::uint8_t zeroBytes[ SECTOR_BYTES ];
ZeroMemory(zeroBytes, SECTOR_BYTES);
/* we need to write the chunk offset table */
@@ -45,9 +45,9 @@ AddPlayerPacket::AddPlayerPacket(std::shared_ptr<Player> player, PlayerUID xuid,
// 4J - changed - send current "previously sent" value of rotations to put this in sync with other clients
yRot = yRotp;
xRot = xRotp;
yHeadRot = static_cast<uint8_t>(yHeadRotp); // 4J Added
// yRot = (uint8_t) (player->yRot * 256 / 360);
// xRot = (uint8_t) (player->xRot * 256 / 360);
yHeadRot = static_cast<std::uint8_t>(yHeadRotp); // 4J Added
// yRot = (std::uint8_t) (player->yRot * 256 / 360);
// xRot = (std::uint8_t) (player->xRot * 256 / 360);
//printf("%d: New add player (%f,%f,%f) : (%d,%d,%d) : xRot %d, yRot %d\n",id,player->x,player->y,player->z,x,y,z,xRot,yRot);
@@ -97,13 +97,13 @@ void AddPlayerPacket::write(DataOutputStream *dos) //throws IOException
dos->writeInt(x);
dos->writeInt(y);
dos->writeInt(z);
dos->writeByte(static_cast<uint8_t>(yRot));
dos->writeByte(static_cast<uint8_t>(xRot));
dos->writeByte(static_cast<uint8_t>(m_playerIndex)); // 4J Added
dos->writeByte(static_cast<std::uint8_t>(yRot));
dos->writeByte(static_cast<std::uint8_t>(xRot));
dos->writeByte(static_cast<std::uint8_t>(m_playerIndex)); // 4J Added
dos->writeShort(carriedItem);
dos->writePlayerUID(xuid);
dos->writePlayerUID(OnlineXuid);
dos->writeByte(static_cast<uint8_t>(m_playerIndex)); // 4J Added
dos->writeByte(static_cast<std::uint8_t>(m_playerIndex)); // 4J Added
int skinId = 0;
std::memcpy(&skinId, &m_skinId, sizeof(m_skinId));
dos->writeInt(skinId);
@@ -122,7 +122,7 @@ void AddPlayerPacket::handle(PacketListener *listener)
int AddPlayerPacket::getEstimatedSize()
{
int iSize= sizeof(int) + Player::MAX_NAME_LENGTH + sizeof(int) + sizeof(int) + sizeof(int) + sizeof(std::uint8_t) + sizeof(std::uint8_t) +sizeof(short) + sizeof(PlayerUID) + sizeof(PlayerUID) + sizeof(int) + sizeof(std::uint8_t) + sizeof(unsigned int) + sizeof(uint8_t);
int iSize= sizeof(int) + Player::MAX_NAME_LENGTH + sizeof(int) + sizeof(int) + sizeof(int) + sizeof(std::uint8_t) + sizeof(std::uint8_t) +sizeof(short) + sizeof(PlayerUID) + sizeof(PlayerUID) + sizeof(int) + sizeof(std::uint8_t) + sizeof(unsigned int) + sizeof(std::uint8_t);
if( entityData != NULL )
{
@@ -26,7 +26,7 @@ public:
std::uint32_t m_skinId; // 4J Added
std::uint32_t m_capeId; // 4J Added
unsigned int m_uiGamePrivileges; // 4J Added
uint8_t yHeadRot; // 4J Added
std::uint8_t yHeadRot; // 4J Added
AddPlayerPacket();
~AddPlayerPacket();
@@ -28,7 +28,7 @@ void KickPlayerPacket::read(DataInputStream *dis) //throws IOException
void KickPlayerPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeByte((uint8_t)m_networkSmallId);
dos->writeByte((std::uint8_t)m_networkSmallId);
}
int KickPlayerPacket::getEstimatedSize()
@@ -146,18 +146,18 @@ void LoginPacket::write(DataOutputStream *dos) //throws IOException
}
dos->writeLong(seed);
dos->writeInt(gameType);
dos->writeByte((uint8_t)dimension);
dos->writeByte((uint8_t)mapHeight);
dos->writeByte((uint8_t)maxPlayers);
dos->writeByte((std::uint8_t)dimension);
dos->writeByte((std::uint8_t)mapHeight);
dos->writeByte((std::uint8_t)maxPlayers);
dos->writePlayerUID(m_offlineXuid);
dos->writePlayerUID(m_onlineXuid);
dos->writeBoolean(m_friendsOnlyUGC);
int ugcPlayersVersion = 0;
std::memcpy(&ugcPlayersVersion, &m_ugcPlayersVersion, sizeof(m_ugcPlayersVersion));
dos->writeInt(ugcPlayersVersion);
dos->writeByte((uint8_t)difficulty);
dos->writeByte((std::uint8_t)difficulty);
dos->writeInt(m_multiplayerInstanceId);
dos->writeByte((uint8_t)m_playerIndex);
dos->writeByte((std::uint8_t)m_playerIndex);
int skinId = 0;
std::memcpy(&skinId, &m_playerSkinId, sizeof(m_playerSkinId));
dos->writeInt(skinId);
@@ -96,7 +96,7 @@ void PreLoginPacket::write(DataOutputStream *dos) //throws IOException
std::int32_t ugcPlayersVersion = 0;
std::memcpy(&ugcPlayersVersion, &m_ugcPlayersVersion, sizeof(m_ugcPlayersVersion));
dos->writeInt(ugcPlayersVersion);
dos->writeByte((uint8_t)m_dwPlayerCount);
dos->writeByte((std::uint8_t)m_dwPlayerCount);
for(std::uint32_t i = 0; i < m_dwPlayerCount; ++i)
{
dos->writePlayerUID( m_playerXuids[i] );
+9 -9
View File
@@ -11,7 +11,7 @@
// link, the end (0 or 1) is passed as a parameter to the ctor.
CRITICAL_SECTION Socket::s_hostQueueLock[2];
std::queue<uint8_t> Socket::s_hostQueue[2];
std::queue<std::uint8_t> Socket::s_hostQueue[2];
Socket::SocketOutputStreamLocal *Socket::s_hostOutStream[2];
Socket::SocketInputStreamLocal *Socket::s_hostInStream[2];
ServerConnection *Socket::s_serverConnection = NULL;
@@ -49,7 +49,7 @@ void Socket::Initialise(ServerConnection *serverConnection)
if(TryEnterCriticalSection(&s_hostQueueLock[i]))
{
// Clear the queue
std::queue<uint8_t> empty;
std::queue<std::uint8_t> empty;
std::swap( s_hostQueue[i], empty );
LeaveCriticalSection(&s_hostQueueLock[i]);
}
@@ -298,7 +298,7 @@ int Socket::SocketInputStreamLocal::read()
{
if( s_hostQueue[m_queueIdx].size() )
{
uint8_t retval = s_hostQueue[m_queueIdx].front();
std::uint8_t retval = s_hostQueue[m_queueIdx].front();
s_hostQueue[m_queueIdx].pop();
LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]);
return retval;
@@ -344,7 +344,7 @@ void Socket::SocketInputStreamLocal::close()
{
m_streamOpen = false;
EnterCriticalSection(&s_hostQueueLock[m_queueIdx]);
std::queue<uint8_t>().swap(s_hostQueue[m_queueIdx]);
std::queue<std::uint8_t>().swap(s_hostQueue[m_queueIdx]);
LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]);
}
@@ -363,7 +363,7 @@ void Socket::SocketOutputStreamLocal::write(unsigned int b)
return;
}
EnterCriticalSection(&s_hostQueueLock[m_queueIdx]);
s_hostQueue[m_queueIdx].push((uint8_t)b);
s_hostQueue[m_queueIdx].push((std::uint8_t)b);
LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]);
}
@@ -392,7 +392,7 @@ void Socket::SocketOutputStreamLocal::close()
{
m_streamOpen = false;
EnterCriticalSection(&s_hostQueueLock[m_queueIdx]);
std::queue<uint8_t>().swap(s_hostQueue[m_queueIdx]);
std::queue<std::uint8_t>().swap(s_hostQueue[m_queueIdx]);
LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]);
}
@@ -414,7 +414,7 @@ int Socket::SocketInputStreamNetwork::read()
{
if( m_socket->m_queueNetwork[m_queueIdx].size() )
{
uint8_t retval = m_socket->m_queueNetwork[m_queueIdx].front();
std::uint8_t retval = m_socket->m_queueNetwork[m_queueIdx].front();
m_socket->m_queueNetwork[m_queueIdx].pop();
LeaveCriticalSection(&m_socket->m_queueLockNetwork[m_queueIdx]);
return retval;
@@ -474,8 +474,8 @@ void Socket::SocketOutputStreamNetwork::write(unsigned int b)
{
if( m_streamOpen != true ) return;
byteArray barray;
uint8_t bb;
bb = (uint8_t)b;
std::uint8_t bb;
bb = (std::uint8_t)b;
barray.data = &bb;
barray.length = 1;
write(barray, 0, 1);
+2 -2
View File
@@ -97,12 +97,12 @@ private:
// For local connections between the host player and the server
static CRITICAL_SECTION s_hostQueueLock[2];
static std::queue<uint8_t> s_hostQueue[2];
static std::queue<std::uint8_t> s_hostQueue[2];
static SocketOutputStreamLocal *s_hostOutStream[2];
static SocketInputStreamLocal *s_hostInStream[2];
// For network connections
std::queue<uint8_t> m_queueNetwork[2]; // For input data
std::queue<std::uint8_t> m_queueNetwork[2]; // For input data
CRITICAL_SECTION m_queueLockNetwork[2]; // For input data
SocketInputStreamNetwork *m_inputStream[2];
SocketOutputStreamNetwork *m_outputStream[2];
+6 -6
View File
@@ -183,8 +183,8 @@ void Player::defineSynchedData()
{
this->Mob::defineSynchedData();
entityData->define(DATA_PLAYER_FLAGS_ID, (uint8_t) 0);
entityData->define(DATA_PLAYER_RUNNING_ID, (uint8_t) 0);
entityData->define(DATA_PLAYER_FLAGS_ID, (std::uint8_t) 0);
entityData->define(DATA_PLAYER_RUNNING_ID, (std::uint8_t) 0);
}
std::shared_ptr<ItemInstance> Player::getUseItem()
@@ -572,7 +572,7 @@ void Player::completeUsingItem()
}
}
void Player::handleEntityEvent(uint8_t id)
void Player::handleEntityEvent(std::uint8_t id)
{
if (id == EntityEvent::USE_ITEM_COMPLETE)
{
@@ -1979,14 +1979,14 @@ bool Player::getPlayerFlag(int flag)
void Player::setPlayerFlag(int flag, bool value)
{
uint8_t currentValue = entityData->getByte(DATA_PLAYER_FLAGS_ID);
std::uint8_t currentValue = entityData->getByte(DATA_PLAYER_FLAGS_ID);
if (value)
{
entityData->set(DATA_PLAYER_FLAGS_ID, (uint8_t) (currentValue | (1 << flag)));
entityData->set(DATA_PLAYER_FLAGS_ID, (std::uint8_t) (currentValue | (1 << flag)));
}
else
{
entityData->set(DATA_PLAYER_FLAGS_ID, (uint8_t) (currentValue & ~(1 << flag)));
entityData->set(DATA_PLAYER_FLAGS_ID, (std::uint8_t) (currentValue & ~(1 << flag)));
}
}
+1 -1
View File
@@ -161,7 +161,7 @@ protected:
virtual void completeUsingItem();
public:
virtual void handleEntityEvent(uint8_t id);
virtual void handleEntityEvent(std::uint8_t id);
protected:
bool isImmobile();