Skip to content

Commit

Permalink
fix: Compiler warnings, OSX+Android Build
Browse files Browse the repository at this point in the history
Signed-off-by: David Li <[email protected]>
  • Loading branch information
randombk committed Dec 31, 2024
1 parent cdf82c3 commit c500571
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Setup build and dependencies
run: |
sudo apt-get update
sudo apt-get install gettext
sudo apt-get install gettext libsqlite3-dev zlib1g-dev
- name: Build
working-directory: ./android
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:

- name: Install build dependencies
run: |
HOMEBREW_NO_AUTO_UPDATE=yes HOMEBREW_NO_INSTALL_CLEANUP=yes brew install sdl2 sdl2_image sdl2_ttf sdl2_mixer gettext ccache parallel llvm astyle
HOMEBREW_NO_AUTO_UPDATE=yes HOMEBREW_NO_INSTALL_CLEANUP=yes brew install sdl2 sdl2_image sdl2_ttf sdl2_mixer gettext ccache parallel llvm astyle sqlite3 zlib
python3 -m venv ./venv
source ./venv/bin/activate
pip3 install mac_alias==2.2.0 dmgbuild==1.6.1 biplist polib luaparser
Expand Down
2 changes: 1 addition & 1 deletion src/compress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void zlib_compress( const std::string &input, std::vector<std::byte> &output )
void zlib_decompress( const void *compressed_data, int compressed_size, std::string &output )
{
// We need to guess at the decompressed size - we expect things to compress fairly well.
uLongf decompressedSize = compressed_size * 8;
uLongf decompressedSize = static_cast<uLongf>( compressed_size ) * 8;
output.resize( decompressedSize );

int result;
Expand Down
21 changes: 11 additions & 10 deletions src/world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
#include "compress.h"

#define dbg(x) DebugLogFL((x),DC::Main)

static sqlite3 *open_db( const std::string &path )
{
sqlite3 *db = nullptr;
int ret;

if( SQLITE_OK != ( ret = sqlite3_initialize() ) ) {
ret = sqlite3_initialize();
if( ret != SQLITE_OK ) {
dbg( DL::Error ) << "Failed to initialize sqlite3 (Error " << ret << ")";
throw std::runtime_error( "Failed to initialize sqlite3" );
}

if( SQLITE_OK != ( ret = sqlite3_open_v2( path.c_str(), &db,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL ) ) ) {
ret = sqlite3_open_v2( path.c_str(), &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL );
if( ret != SQLITE_OK ) {
dbg( DL::Error ) << "Failed to open db" << path << " (Error " << ret << ")";
throw std::runtime_error( "Failed to open db" );
}
Expand All @@ -45,7 +45,8 @@ static sqlite3 *open_db( const std::string &path )
)sql";

char *sqlErrMsg = 0;
if( SQLITE_OK != ( ret = sqlite3_exec( db, sql, NULL, NULL, &sqlErrMsg ) ) ) {
ret = sqlite3_exec( db, sql, NULL, NULL, &sqlErrMsg );
if( ret != SQLITE_OK ) {
dbg( DL::Error ) << "Failed to init db" << path << " (" << sqlErrMsg << ")";
throw std::runtime_error( "Failed to open db" );
}
Expand Down Expand Up @@ -569,7 +570,7 @@ bool world::read_overmap( const point_abs_om &p, file_read_fn reader ) const
bool world::read_overmap_player_visibility( const point_abs_om &p, file_read_fn reader )
{
if( info->world_save_format == save_format::V2_COMPRESSED_SQLITE3 ) {
auto playerdb = get_player_db();
sqlite3 *playerdb = get_player_db();
return read_from_db( playerdb, overmap_player_filename( p ), reader, true );
} else {
return read_from_player_file( overmap_player_filename( p ), reader, true );
Expand All @@ -589,7 +590,7 @@ bool world::write_overmap( const point_abs_om &p, file_write_fn writer ) const
bool world::write_overmap_player_visibility( const point_abs_om &p, file_write_fn writer )
{
if( info->world_save_format == save_format::V2_COMPRESSED_SQLITE3 ) {
auto playerdb = get_player_db();
sqlite3 *playerdb = get_player_db();
write_to_db( playerdb, overmap_player_filename( p ), writer );
return true;
} else {
Expand All @@ -608,7 +609,7 @@ static std::string get_mm_filename( const tripoint &p )
bool world::read_player_mm_quad( const tripoint &p, file_read_json_fn reader )
{
if( info->world_save_format == save_format::V2_COMPRESSED_SQLITE3 ) {
auto playerdb = get_player_db();
sqlite3 *playerdb = get_player_db();
return read_from_db_json( playerdb, get_mm_filename( p ), reader, true );
} else {
return read_from_player_file_json( ".mm1/" + get_mm_filename( p ), reader, true );
Expand All @@ -618,7 +619,7 @@ bool world::read_player_mm_quad( const tripoint &p, file_read_json_fn reader )
bool world::write_player_mm_quad( const tripoint &p, file_write_fn writer )
{
if( info->world_save_format == save_format::V2_COMPRESSED_SQLITE3 ) {
auto playerdb = get_player_db();
sqlite3 *playerdb = get_player_db();
write_to_db( playerdb, get_mm_filename( p ), writer );
return true;
} else {
Expand Down Expand Up @@ -709,7 +710,7 @@ bool world::read_from_file_json( const std::string &path, file_read_json_fn read
return ::read_from_file_json( info->folder_path() + "/" + path, reader, optional );
}

void replaceBackslashes( std::string &input )
static void replaceBackslashes( std::string &input )
{
std::size_t pos = 0;
while( ( pos = input.find( '\\', pos ) ) != std::string::npos ) {
Expand Down

0 comments on commit c500571

Please sign in to comment.