Fixed compilation errors (Android)/warnings

This commit is contained in:
Sour 2018-07-08 20:19:21 -04:00
parent 1556c1c70a
commit 5c23fa61c7
7 changed files with 43 additions and 32 deletions

View file

@ -54,7 +54,7 @@ GameSystem NESHeader::GetGameSystem()
case 1: return GameSystem::VsSystem;
case 2: return GameSystem::Playchoice;
default:
MessageManager::Log("[iNES] Unsupported console type detected (using NES NTSC instead)");
MessageManager::Log("[iNes] Unsupported console type detected (using NES NTSC instead)");
return GameSystem::NesNtsc;
}
@ -81,23 +81,28 @@ RomHeaderVersion NESHeader::GetRomHeaderVersion()
}
}
uint64_t NESHeader::GetSizeValue(uint32_t exponent, uint32_t multiplier)
uint32_t NESHeader::GetSizeValue(uint32_t exponent, uint32_t multiplier)
{
if(exponent > 32) {
//Restrict max size to 28GB (mosty to be able to return the size in a 64-bit int)
exponent = 32;
if(exponent > 60) {
//Restrict max size to avoid overflow in a 64-bit value
exponent = 60;
MessageManager::Log("[iNes] Unsupported size value.");
}
multiplier = multiplier * 2 + 1;
return multiplier * (uint64_t)1 << exponent;
uint64_t size = multiplier * (uint64_t)1 << exponent;
if(size >= ((uint64_t)1 << 32)) {
MessageManager::Log("[iNes] Unsupported size value.");
}
return (uint32_t)size;
}
uint32_t NESHeader::GetPrgSize()
{
if(GetRomHeaderVersion() == RomHeaderVersion::Nes2_0) {
if((Byte9 & 0x0F) == 0x0F) {
return GetSizeValue(PrgCount >> 2, PrgCount & 0x03);
return (uint32_t)GetSizeValue(PrgCount >> 2, PrgCount & 0x03);
} else {
return (((Byte9 & 0x0F) << 8) | PrgCount) * 0x4000;
}
@ -114,7 +119,7 @@ uint32_t NESHeader::GetChrSize()
{
if(GetRomHeaderVersion() == RomHeaderVersion::Nes2_0) {
if((Byte9 & 0xF0) == 0xF0) {
return GetSizeValue(ChrCount >> 2, ChrCount & 0x03);
return (uint32_t)GetSizeValue(ChrCount >> 2, ChrCount & 0x03);
} else {
return (((Byte9 & 0xF0) << 4) | ChrCount) * 0x2000;
}
@ -196,7 +201,7 @@ GameInputType NESHeader::GetInputType()
return (GameInputType)Byte15;
}
MessageManager::Log("[iNES] Unknown controller type.");
MessageManager::Log("[iNes] Unknown controller type.");
return GameInputType::Default;
}
@ -206,7 +211,7 @@ VsSystemType NESHeader::GetVsSystemType()
if((Byte13 >> 4) <= 0x06) {
return (VsSystemType)(Byte13 >> 4);
}
MessageManager::Log("[iNES] Unknown VS System Type specified.");
MessageManager::Log("[iNes] Unknown VS System Type specified.");
}
return VsSystemType::Default;
}
@ -217,7 +222,7 @@ PpuModel NESHeader::GetVsSystemPpuModel()
switch(Byte13 & 0x0F) {
case 0: return PpuModel::Ppu2C03;
case 1:
MessageManager::Log("[iNES] Unsupport VS System Palette specified (2C03G).");
MessageManager::Log("[iNes] Unsupport VS System Palette specified (2C03G).");
return PpuModel::Ppu2C03;
case 2: return PpuModel::Ppu2C04A;
@ -233,7 +238,7 @@ PpuModel NESHeader::GetVsSystemPpuModel()
case 12: return PpuModel::Ppu2C05E;
default:
MessageManager::Log("[iNES] Unknown VS System Palette specified.");
MessageManager::Log("[iNes] Unknown VS System Palette specified.");
break;
}
}
@ -242,6 +247,9 @@ PpuModel NESHeader::GetVsSystemPpuModel()
void NESHeader::SanitizeHeader(size_t romLength)
{
uint32_t originalPrgSize = GetPrgSize();
uint32_t originalChrSize = GetChrSize();
size_t calculatedLength = sizeof(NESHeader) + GetPrgSize();
while(calculatedLength > romLength) {
Byte9 = 0;
@ -255,4 +263,11 @@ void NESHeader::SanitizeHeader(size_t romLength)
ChrCount--;
calculatedLength = sizeof(NESHeader) + GetPrgSize() + GetChrSize();
}
if(originalPrgSize != GetPrgSize()) {
MessageManager::Log("[iNes] Invalid ROM file length - PRG data has been truncated.");
}
if(originalChrSize != GetChrSize()) {
MessageManager::Log("[iNes] Invalid ROM file length - CHR data has been truncated.");
}
}

View file

@ -36,7 +36,7 @@ struct NESHeader
GameSystem GetNesGameSystem();
GameSystem GetGameSystem();
RomHeaderVersion GetRomHeaderVersion();
uint64_t GetSizeValue(uint32_t exponent, uint32_t multiplier);
uint32_t GetSizeValue(uint32_t exponent, uint32_t multiplier);
uint32_t GetPrgSize();
uint32_t GetChrSize();
uint32_t GetWorkRamSize();

View file

@ -5,12 +5,13 @@
class PlayerListMessage : public NetMessage
{
private:
static constexpr uint32_t PlayerNameMaxLength = 50;
vector<PlayerInfo> _playerList;
protected:
virtual void ProtectedStreamState()
{
constexpr uint32_t PlayerNameMaxLength = 50;
uint32_t nameLength = PlayerNameMaxLength + 1;
char playerName[PlayerNameMaxLength + 1];
uint8_t playerPort = 0;

View file

@ -25,13 +25,13 @@ protected:
Stream(_resetCounter);
}
void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType)
void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType) override
{
page = (_resetCounter << 7) | (page & 0x7F);
MMC3::SelectCHRPage(slot, page, memoryType);
}
void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType)
void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType) override
{
page = (_resetCounter << 4) | (page & 0x0F);
MMC3::SelectPRGPage(slot, page, memoryType);

View file

@ -606,7 +606,7 @@ int PNGHelper::DecodePNG(vector<unsigned char>& out_image, unsigned long& image_
return (unsigned char)((pa <= pb && pa <= pc) ? a : pb <= pc ? b : c);
}
};
PNG decoder; decoder.decode(out_image, in_png, in_size, convert_to_rgba32);
PNG decoder = { }; decoder.decode(out_image, in_png, in_size, convert_to_rgba32);
image_width = decoder.info.width; image_height = decoder.info.height;
return decoder.error;
}

View file

@ -727,7 +727,10 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex
{
mz_uint8 *p = r->m_tables[0].m_code_size; mz_uint i;
r->m_table_sizes[0] = 288; r->m_table_sizes[1] = 32; TINFL_MEMSET(r->m_tables[1].m_code_size, 5, 32);
for ( i = 0; i <= 143; ++i) *p++ = 8; for ( ; i <= 255; ++i) *p++ = 9; for ( ; i <= 279; ++i) *p++ = 7; for ( ; i <= 287; ++i) *p++ = 8;
for ( i = 0; i <= 143; ++i) *p++ = 8;
for ( ; i <= 255; ++i) *p++ = 9;
for ( ; i <= 279; ++i) *p++ = 7;
for ( ; i <= 287; ++i) *p++ = 8;
}
else
{
@ -1511,7 +1514,10 @@ static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahe
if (TDEFL_READ_UNALIGNED_WORD(&d->m_dict[probe_pos + match_len - 1]) == c01) break;
TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE;
}
if (!dist) break; q = (const mz_uint16*)(d->m_dict + probe_pos); if (TDEFL_READ_UNALIGNED_WORD(q) != s01) continue; p = s; probe_len = 32;
if (!dist) break;
q = (const mz_uint16*)(d->m_dict + probe_pos);
if (TDEFL_READ_UNALIGNED_WORD(q) != s01) continue;
p = s; probe_len = 32;
do { } while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) &&
(TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) );
if (!probe_len)

View file

@ -549,11 +549,6 @@ static int error(vorb *f, enum STBVorbisError e)
#define array_size_required(count,size) (count*(sizeof(void *)+(size)))
#define temp_alloc(f,size) (f->alloc.alloc_buffer ? setup_temp_malloc(f,size) : alloca(size))
#ifdef dealloca
#define temp_free(f,p) (f->alloc.alloc_buffer ? 0 : dealloca(size))
#else
#define temp_free(f,p) 0
#endif
#define temp_alloc_save(f) ((f)->temp_offset)
#define temp_alloc_restore(f,p) ((f)->temp_offset = (p))
@ -1922,11 +1917,6 @@ static void decode_residue(vorb *f, float *residue_buffers[], int ch, int n, int
}
done:
CHECK(f);
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
temp_free(f,part_classdata);
#else
temp_free(f,classifications);
#endif
temp_alloc_restore(f,temp_alloc_point);
}
@ -2572,7 +2562,6 @@ static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype)
}
}
temp_free(f,buf2);
temp_alloc_restore(f,save_point);
}
@ -3584,7 +3573,7 @@ static int start_decoder(vorb *f)
g->sorted_order[j] = (uint8) p[j].id;
// precompute the neighbors
for (j=2; j < g->values; ++j) {
int low,hi;
int low=0,hi=0;
neighbors(g->Xlist, j, &low,&hi);
g->neighbors[j][0] = low;
g->neighbors[j][1] = hi;
@ -4256,7 +4245,7 @@ static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number)
ProbedPage left, right, mid;
int i, start_seg_with_known_loc, end_pos, page_start;
uint32 delta, stream_length, padding;
double offset, bytes_per_sample;
double offset = 0, bytes_per_sample = 0;
int probe = 0;
// find the last page and validate the target sample