Skip to content

Commit

Permalink
Merge pull request #1586 from ivan-mogilko/360--warnings
Browse files Browse the repository at this point in the history
Resolving (most) engine compilation warnings
  • Loading branch information
ivan-mogilko authored Mar 26, 2022
2 parents 6a71d85 + 3797204 commit f8a90c3
Show file tree
Hide file tree
Showing 145 changed files with 486 additions and 530 deletions.
6 changes: 3 additions & 3 deletions Common/ac/dynobj/scriptaudioclip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ void ScriptAudioClip::ReadFromFile(Stream *in)
id = in->ReadInt32();
scriptName.ReadCount(in, SCRIPTAUDIOCLIP_SCRIPTNAMELENGTH);
fileName.ReadCount(in, SCRIPTAUDIOCLIP_FILENAMELENGTH);
bundlingType = in->ReadInt8();
type = in->ReadInt8();
fileType = in->ReadInt8();
bundlingType = static_cast<uint8_t>(in->ReadInt8());
type = static_cast<uint8_t>(in->ReadInt8());
fileType = static_cast<AudioFileType>(in->ReadInt8());
defaultRepeat = in->ReadInt8();
defaultPriority = in->ReadInt16();
defaultVolume = in->ReadInt16();
Expand Down
6 changes: 3 additions & 3 deletions Common/ac/dynobj/scriptaudioclip.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ struct ScriptAudioClip {
int id = 0;
Common::String scriptName;
Common::String fileName;
char bundlingType = AUCL_BUNDLE_EXE;
char type = 0;
char fileType = eAudioFileOGG;
uint8_t bundlingType = AUCL_BUNDLE_EXE;
uint8_t type = 0;
AudioFileType fileType = eAudioFileOGG;
char defaultRepeat = 0;
short defaultPriority = 50;
short defaultVolume = 100;
Expand Down
6 changes: 3 additions & 3 deletions Common/ac/gamesetupstruct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void GameSetupStruct::WriteInvInfo_Aligned(Stream *out)
}
}

HGameFileError GameSetupStruct::read_cursors(Common::Stream *in, GameDataVersion data_ver)
HGameFileError GameSetupStruct::read_cursors(Common::Stream *in)
{
ReadMouseCursors_Aligned(in);
return HGameFileError::None();
Expand Down Expand Up @@ -228,9 +228,9 @@ void GameSetupStruct::WriteMouseCursors_Aligned(Stream *out)
//-----------------------------------------------------------------------------
// Reading Part 2

void GameSetupStruct::read_characters(Common::Stream *in, GameDataVersion data_ver)
void GameSetupStruct::read_characters(Common::Stream *in)
{
chars = new CharacterInfo[numcharacters + 5]; // TODO: why +5, is this really needed?
chars = new CharacterInfo[numcharacters];

ReadCharacters_Aligned(in);
}
Expand Down
4 changes: 2 additions & 2 deletions Common/ac/gamesetupstruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ struct GameSetupStruct: public GameSetupStructBase {
// Part 1
void read_savegame_info(Common::Stream *in, GameDataVersion data_ver);
void read_font_infos(Common::Stream *in, GameDataVersion data_ver);
HGameFileError read_cursors(Common::Stream *in, GameDataVersion data_ver);
HGameFileError read_cursors(Common::Stream *in);
void read_interaction_scripts(Common::Stream *in, GameDataVersion data_ver);
void read_words_dictionary(Common::Stream *in);

Expand All @@ -136,7 +136,7 @@ struct GameSetupStruct: public GameSetupStructBase {
void WriteMouseCursors_Aligned(Common::Stream *out);
//------------------------------
// Part 2
void read_characters(Common::Stream *in, GameDataVersion data_ver);
void read_characters(Common::Stream *in);
void read_lipsync(Common::Stream *in, GameDataVersion data_ver);
void read_messages(Common::Stream *in, GameDataVersion data_ver);

Expand Down
5 changes: 3 additions & 2 deletions Common/ac/gamesetupstructbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,9 @@ Size ResolutionTypeToSize(GameResolutionType resolution, bool letterbox)
return Size(1024, 768);
case kGameResolution_1280x720:
return Size(1280,720);
default:
return Size();
}
return Size();
}

const char *GetScriptAPIName(ScriptAPIVersion v)
Expand All @@ -280,6 +281,6 @@ const char *GetScriptAPIName(ScriptAPIVersion v)
case kScriptAPI_v3507: return "v3.5.0-final";
case kScriptAPI_v351: return "v3.5.1";
case kScriptAPI_v360: return "v3.6.0";
default: return "unknown";
}
return "unknown";
}
8 changes: 4 additions & 4 deletions Common/ac/mousecursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ void MouseCursor::WriteToFile(Stream *out)
void MouseCursor::ReadFromSavegame(Stream *in, int cmp_ver)
{
pic = in->ReadInt32();
hotx = in->ReadInt32();
hoty = in->ReadInt32();
view = in->ReadInt32();
flags = in->ReadInt32();
hotx = static_cast<int16_t>(in->ReadInt32());
hoty = static_cast<int16_t>(in->ReadInt32());
view = static_cast<int16_t>(in->ReadInt32());
flags = static_cast<int8_t>(in->ReadInt32());
if (cmp_ver > 0)
animdelay = in->ReadInt32();
}
Expand Down
15 changes: 7 additions & 8 deletions Common/ac/spritefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ typedef ImBufferPtrT<uint8_t*> ImBufferPtr;
typedef ImBufferPtrT<const uint8_t*> ImBufferCPtr;


// Finds the given color's index in the palette, or returns -1 if such color is not there
// Finds the given color's index in the palette, or returns SIZE_MAX if such color is not there
static size_t lookup_palette(uint32_t col, uint32_t palette[256], uint32_t ncols)
{
for (size_t i = 0; i < ncols; ++i)
if (palette[i] == col) return i;
return -1;
return SIZE_MAX;
}

// Converts a 16/32-bit image into the indexed 8-bit pixel data with palette;
Expand Down Expand Up @@ -88,7 +88,7 @@ static bool CreateIndexedBitmap(const Bitmap *image, std::vector<uint8_t> &dst_d
default: assert(0); return false;
}

if (pal_n == -1)
if (pal_n == SIZE_MAX)
{
if (pal_count == 256) return false;
pal_n = pal_count;
Expand Down Expand Up @@ -131,8 +131,8 @@ static inline SpriteFormat PaletteFormatForBPP(int bpp)
case 1: return kSprFmt_PaletteRgb888;
case 2: return kSprFmt_PaletteRgb565;
case 4: return kSprFmt_PaletteArgb8888;
default: return kSprFmt_Undefined;
}
return kSprFmt_Undefined;
}

static inline uint8_t GetPaletteBPP(SpriteFormat fmt)
Expand All @@ -142,8 +142,8 @@ static inline uint8_t GetPaletteBPP(SpriteFormat fmt)
case kSprFmt_PaletteRgb888: return 3;
case kSprFmt_PaletteArgb8888: return 4;
case kSprFmt_PaletteRgb565: return 2;
default: return 0; // means no palette
}
return 0; // means no palette
}


Expand Down Expand Up @@ -232,7 +232,7 @@ HError SpriteFile::OpenFile(const String &filename, const String &sprindex_filen
}

// Failed, index file is invalid; index sprites manually
return RebuildSpriteIndex(_stream.get(), topmost, _version, metrics);
return RebuildSpriteIndex(_stream.get(), topmost, metrics);
}

void SpriteFile::Close()
Expand Down Expand Up @@ -357,8 +357,7 @@ static inline void ReadSprHeader(SpriteDatHeader &hdr, Stream *in,
hdr = SpriteDatHeader(bpp, sformat, pal_count, compress, w, h);
}

HError SpriteFile::RebuildSpriteIndex(Stream *in, sprkey_t topmost,
SpriteFileVersion vers, std::vector<Size> &metrics)
HError SpriteFile::RebuildSpriteIndex(Stream *in, sprkey_t topmost, std::vector<Size> &metrics)
{
topmost = std::min(topmost, (sprkey_t)_spriteData.size() - 1);
for (sprkey_t i = 0; !in->EOS() && (i <= topmost); ++i)
Expand Down
3 changes: 1 addition & 2 deletions Common/ac/spritefile.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ class SpriteFile
bool LoadSpriteIndexFile(const String &filename, int expectedFileID,
soff_t spr_initial_offs, sprkey_t topmost, std::vector<Size> &metrics);
// Rebuilds sprite index from the main sprite file
HError RebuildSpriteIndex(Stream *in, sprkey_t topmost, SpriteFileVersion vers,
std::vector<Size> &metrics);
HError RebuildSpriteIndex(Stream *in, sprkey_t topmost, std::vector<Size> &metrics);

// Loads an image data and creates a ready bitmap
HError LoadSprite(sprkey_t index, Bitmap *&sprite);
Expand Down
8 changes: 4 additions & 4 deletions Common/ac/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void ViewLoopNew::Dispose()

void ViewLoopNew::WriteToFile_v321(Stream *out)
{
out->WriteInt16(numFrames);
out->WriteInt16(static_cast<uint16_t>(numFrames));
out->WriteInt32(flags);
WriteFrames_Aligned(out);
}
Expand All @@ -100,7 +100,7 @@ void ViewLoopNew::WriteFrames_Aligned(Stream *out)

void ViewLoopNew::ReadFromFile_v321(Stream *in)
{
Initialize(in->ReadInt16());
Initialize(static_cast<uint16_t>(in->ReadInt16()));
flags = in->ReadInt32();
ReadFrames_Aligned(in);
}
Expand Down Expand Up @@ -134,7 +134,7 @@ void ViewStruct::Dispose()

void ViewStruct::WriteToFile(Stream *out)
{
out->WriteInt16(numLoops);
out->WriteInt16(static_cast<uint16_t>(numLoops));
for (int i = 0; i < numLoops; i++)
{
loops[i].WriteToFile_v321(out);
Expand All @@ -143,7 +143,7 @@ void ViewStruct::WriteToFile(Stream *out)

void ViewStruct::ReadFromFile(Stream *in)
{
Initialize(in->ReadInt16());
Initialize(static_cast<uint16_t>(in->ReadInt16()));

for (int i = 0; i < numLoops; i++)
{
Expand Down
4 changes: 2 additions & 2 deletions Common/ac/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct ViewFrame {

struct ViewLoopNew
{
short numFrames;
int numFrames;
int flags;
std::vector<ViewFrame> frames;
// NOTE: we still need numFrames for backward compatibility:
Expand All @@ -59,7 +59,7 @@ struct ViewLoopNew

struct ViewStruct
{
short numLoops;
int numLoops;
std::vector<ViewLoopNew> loops;

ViewStruct();
Expand Down
4 changes: 2 additions & 2 deletions Common/debug/out.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ enum MessageType

// This enumeration is a list of common hard-coded groups, but more could
// be added via debugging configuration interface (see 'debug/debug.h').
enum CommonDebugGroup
enum CommonDebugGroup : uint32_t
{
kDbgGroup_None = -1,
kDbgGroup_None = UINT32_MAX,
// Main debug group is for reporting general engine status and issues
kDbgGroup_Main = 0,
// Game group is for logging game logic state and issues
Expand Down
8 changes: 4 additions & 4 deletions Common/font/ttffontrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ using namespace AGS::Common;
extern bool ShouldAntiAliasText();

// ***** TTF RENDERER *****
void TTFFontRenderer::AdjustYCoordinateForFont(int *ycoord, int fontNumber)
void TTFFontRenderer::AdjustYCoordinateForFont(int *ycoord, int /*fontNumber*/)
{
// TTF fonts already have space at the top, so try to remove the gap
// TODO: adding -1 was here before (check the comment above),
Expand All @@ -35,7 +35,7 @@ void TTFFontRenderer::AdjustYCoordinateForFont(int *ycoord, int fontNumber)
ycoord[0]--;
}

void TTFFontRenderer::EnsureTextValidForFont(char *text, int fontNumber)
void TTFFontRenderer::EnsureTextValidForFont(char * /*text*/, int /*fontNumber*/)
{
// do nothing, TTF can handle all characters
}
Expand All @@ -45,7 +45,7 @@ int TTFFontRenderer::GetTextWidth(const char *text, int fontNumber)
return alfont_text_length(_fontData[fontNumber].AlFont, text);
}

int TTFFontRenderer::GetTextHeight(const char *text, int fontNumber)
int TTFFontRenderer::GetTextHeight(const char * /*text*/, int fontNumber)
{
return alfont_get_font_real_height(_fontData[fontNumber].AlFont);
}
Expand Down Expand Up @@ -133,7 +133,7 @@ const char *TTFFontRenderer::GetName(int fontNumber)
return alfont_get_name(_fontData[fontNumber].AlFont);
}

void TTFFontRenderer::AdjustFontForAntiAlias(int fontNumber, bool aa_mode)
void TTFFontRenderer::AdjustFontForAntiAlias(int fontNumber, bool /*aa_mode*/)
{
if (loaded_game_file_version < kGameVersion_341)
{
Expand Down
2 changes: 1 addition & 1 deletion Common/font/ttffontrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TTFFontRenderer : public IAGSFontRenderer, public IAGSFontRenderer2 {
// IAGSFontRenderer implementation
bool LoadFromDisk(int fontNumber, int fontSize) override;
void FreeMemory(int fontNumber) override;
bool SupportsExtendedCharacters(int fontNumber) override { return true; }
bool SupportsExtendedCharacters(int /*fontNumber*/) override { return true; }
int GetTextWidth(const char *text, int fontNumber) override;
int GetTextHeight(const char *text, int fontNumber) override;
void RenderText(const char *text, int fontNumber, BITMAP *destination, int x, int y, int colour) override ;
Expand Down
6 changes: 3 additions & 3 deletions Common/font/wfnfontrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static unsigned char GetCharCode(unsigned char wanted_code, const WFNFont* font)

static int RenderChar(Bitmap *ds, const int at_x, const int at_y, const WFNChar &wfn_char, const int scale, const color_t text_color);

void WFNFontRenderer::AdjustYCoordinateForFont(int *ycoord, int fontNumber)
void WFNFontRenderer::AdjustYCoordinateForFont(int * /*ycoord*/, int /*fontNumber*/)
{
// Do nothing
}
Expand Down Expand Up @@ -134,8 +134,8 @@ bool WFNFontRenderer::IsBitmapFont()
return true;
}

bool WFNFontRenderer::LoadFromDiskEx(int fontNumber, int fontSize,
const FontRenderParams *params, FontMetrics *metrics)
bool WFNFontRenderer::LoadFromDiskEx(int fontNumber, int /*fontSize*/,
const FontRenderParams *params, FontMetrics * /*metrics*/)
{
String file_name;
Stream *ffi = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions Common/font/wfnfontrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class WFNFontRenderer : public IAGSFontRenderer, public IAGSFontRenderer2 {
bool IsBitmapFont() override;
bool LoadFromDiskEx(int fontNumber, int fontSize, const FontRenderParams *params,
FontMetrics *metrics) override;
const char *GetName(int fontNumber) override { return ""; }
void AdjustFontForAntiAlias(int fontNumber, bool aa_mode) override { /* do nothing */}
const char *GetName(int /*fontNumber*/) override { return ""; }
void AdjustFontForAntiAlias(int /*fontNumber*/, bool /*aa_mode*/) override { /* do nothing */}

private:
struct FontData
Expand Down
2 changes: 1 addition & 1 deletion Common/game/interactions.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace AGS
namespace Common
{

enum InterValType
enum InterValType : int8_t
{
kInterValLiteralInt = 1,
kInterValVariable = 2,
Expand Down
13 changes: 7 additions & 6 deletions Common/game/main_game_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ void ReadDialogs(DialogTopic *&dialog,
// Encrypted text on > 2.60
while (1)
{
size_t newlen = in->ReadInt32();
if (static_cast<int32_t>(newlen) == 0xCAFEBEEF) // GUI magic
size_t newlen = static_cast<uint32_t>(in->ReadInt32());
if (newlen == 0xCAFEBEEF) // GUI magic
{
in->Seek(-4);
break;
Expand Down Expand Up @@ -786,9 +786,10 @@ class GameDataExtReader : public DataExtReader
GameDataVersion _dataVer {};
};

HError GameDataExtReader::ReadBlock(int block_id, const String &ext_id,
soff_t block_len, bool &read_next)
HError GameDataExtReader::ReadBlock(int /*block_id*/, const String &ext_id,
soff_t /*block_len*/, bool &read_next)
{
read_next = true;
// Add extensions here checking ext_id, which is an up to 16-chars name, for example:
// if (ext_id.CompareNoCase("GUI_NEWPROPS") == 0)
// {
Expand Down Expand Up @@ -849,7 +850,7 @@ HGameFileError ReadGameData(LoadedGameEntities &ents, Stream *in, GameDataVersio
if (!err)
return err;
game.ReadInvInfo_Aligned(in);
err = game.read_cursors(in, data_ver);
err = game.read_cursors(in);
if (!err)
return err;
game.read_interaction_scripts(in, data_ver);
Expand Down Expand Up @@ -877,7 +878,7 @@ HGameFileError ReadGameData(LoadedGameEntities &ents, Stream *in, GameDataVersio
in->Seek(count * 0x204);
}

game.read_characters(in, data_ver);
game.read_characters(in);
game.read_lipsync(in, data_ver);
game.read_messages(in, data_ver);

Expand Down
Loading

0 comments on commit f8a90c3

Please sign in to comment.