diff --git a/streams/voxel_block_serializer.cpp b/streams/voxel_block_serializer.cpp index 202eb781..ed464841 100644 --- a/streams/voxel_block_serializer.cpp +++ b/streams/voxel_block_serializer.cpp @@ -5,7 +5,7 @@ #include namespace { -const int BLOCK_TRAILING_MAGIC = 0x900df00d; +const unsigned int BLOCK_TRAILING_MAGIC = 0x900df00d; const int BLOCK_TRAILING_MAGIC_SIZE = 4; } // namespace @@ -155,7 +155,7 @@ bool VoxelBlockSerializer::decompress_and_deserialize(const std::vector _data.resize(decompressed_size); - int actually_decompressed_size = LZ4_decompress_safe( + unsigned int actually_decompressed_size = LZ4_decompress_safe( (const char *)p_data.data() + header_size, (char *)_data.data(), p_data.size() - header_size, @@ -175,7 +175,7 @@ bool VoxelBlockSerializer::decompress_and_deserialize(FileAccess *f, unsigned in ERR_FAIL_COND_V(f == nullptr, false); _compressed_data.resize(size_to_read); - int read_size = f->get_buffer(_compressed_data.data(), size_to_read); + unsigned int read_size = f->get_buffer(_compressed_data.data(), size_to_read); ERR_FAIL_COND_V(read_size != size_to_read, false); return decompress_and_deserialize(_compressed_data, out_voxel_buffer); diff --git a/streams/voxel_stream_region_files.cpp b/streams/voxel_stream_region_files.cpp index 1845e9f3..eff5ada2 100644 --- a/streams/voxel_stream_region_files.cpp +++ b/streams/voxel_stream_region_files.cpp @@ -136,15 +136,15 @@ VoxelStreamRegionFiles::EmergeResult VoxelStreamRegionFiles::_emerge_block(Reffile_access; f->seek(blocks_begin_offset + sector_index * _meta.sector_size); - int block_data_size = f->get_32(); + unsigned int block_data_size = f->get_32(); CRASH_COND(f->eof_reached()); ERR_FAIL_COND_V_MSG(!_block_serializer.decompress_and_deserialize(f, block_data_size, **out_buffer), EMERGE_FAILED, @@ -217,7 +217,7 @@ void VoxelStreamRegionFiles::_immerge_block(Ref voxel_buffer, Vecto block_info.set_sector_index((block_offset - blocks_begin_offset) / _meta.sector_size); block_info.set_sector_count(get_sector_count_from_bytes(written_size)); - for (int i = 0; i < block_info.get_sector_count(); ++i) { + for (unsigned int i = 0; i < block_info.get_sector_count(); ++i) { cache->sectors.push_back(block_rpos); } @@ -288,7 +288,7 @@ void VoxelStreamRegionFiles::_immerge_block(Ref voxel_buffer, Vecto } } -void VoxelStreamRegionFiles::remove_sectors_from_block(CachedRegion *p_region, Vector3i block_rpos, int p_sector_count) { +void VoxelStreamRegionFiles::remove_sectors_from_block(CachedRegion *p_region, Vector3i block_rpos, unsigned int p_sector_count) { VOXEL_PROFILE_SCOPE(profile_scope); // Removes sectors from a block, starting from the last ones. @@ -342,7 +342,7 @@ void VoxelStreamRegionFiles::remove_sectors_from_block(CachedRegion *p_region, V p_region->sectors.begin() + (block_info.get_sector_index() + block_info.get_sector_count() - p_sector_count), p_region->sectors.begin() + (block_info.get_sector_index() + block_info.get_sector_count())); - int old_sector_index = block_info.get_sector_index(); + unsigned int old_sector_index = block_info.get_sector_index(); // Reduce sectors of current block in header. if (block_info.get_sector_count() > p_sector_count) { @@ -355,7 +355,7 @@ void VoxelStreamRegionFiles::remove_sectors_from_block(CachedRegion *p_region, V // Shift sector index of following blocks if (old_sector_index < p_region->sectors.size()) { RegionHeader &header = p_region->header; - for (int i = 0; i < header.blocks.size(); ++i) { + for (unsigned int i = 0; i < header.blocks.size(); ++i) { BlockInfo &b = header.blocks[i]; if (b.data != 0 && b.get_sector_index() > old_sector_index) { b.set_sector_index(b.get_sector_index() - p_sector_count); @@ -516,7 +516,7 @@ Vector3i VoxelStreamRegionFiles::get_region_position_from_blocks(const Vector3i } void VoxelStreamRegionFiles::close_all_regions() { - for (int i = 0; i < _region_cache.size(); ++i) { + for (unsigned int i = 0; i < _region_cache.size(); ++i) { CachedRegion *cache = _region_cache[i]; close_region(cache); memdelete(cache); @@ -539,7 +539,7 @@ String VoxelStreamRegionFiles::get_region_file_path(const Vector3i ®ion_pos, VoxelStreamRegionFiles::CachedRegion *VoxelStreamRegionFiles::get_region_from_cache(const Vector3i pos, int lod) const { // A linear search might be better than a Map data structure, // because it's unlikely to have more than about 10 regions cached at a time - for (int i = 0; i < _region_cache.size(); ++i) { + for (unsigned int i = 0; i < _region_cache.size(); ++i) { CachedRegion *r = _region_cache[i]; if (r->position == pos && r->lod == lod) { return r; @@ -642,7 +642,7 @@ VoxelStreamRegionFiles::CachedRegion *VoxelStreamRegionFiles::open_region(const // Filter only present blocks and keep the index around because it represents the 3D position of the block RegionHeader &header = cache->header; std::vector blocks_sorted_by_offset; - for (int i = 0; i < header.blocks.size(); ++i) { + for (unsigned int i = 0; i < header.blocks.size(); ++i) { const BlockInfo b = header.blocks[i]; if (b.data != 0) { BlockInfoAndIndex p; @@ -657,10 +657,10 @@ VoxelStreamRegionFiles::CachedRegion *VoxelStreamRegionFiles::open_region(const return a.b.get_sector_index() < b.b.get_sector_index(); }); - for (int i = 0; i < blocks_sorted_by_offset.size(); ++i) { + for (unsigned int i = 0; i < blocks_sorted_by_offset.size(); ++i) { const BlockInfoAndIndex b = blocks_sorted_by_offset[i]; Vector3i bpos = get_block_position_from_index(b.i); - for (int j = 0; j < b.b.get_sector_count(); ++j) { + for (unsigned int j = 0; j < b.b.get_sector_count(); ++j) { cache->sectors.push_back(bpos); } } @@ -711,7 +711,7 @@ void VoxelStreamRegionFiles::close_oldest_region() { uint64_t oldest_time = 0; uint64_t now = OS::get_singleton()->get_ticks_usec(); - for (int i = 0; i < _region_cache.size(); ++i) { + for (unsigned int i = 0; i < _region_cache.size(); ++i) { CachedRegion *r = _region_cache[i]; uint64_t time = now - r->last_opened; if (time >= oldest_time) { @@ -861,7 +861,7 @@ void VoxelStreamRegionFiles::_convert_files(Meta new_meta) { // Read all blocks from the old stream and write them into the new one - for (int i = 0; i < old_region_list.size(); ++i) { + for (unsigned int i = 0; i < old_region_list.size(); ++i) { PositionAndLod region_info = old_region_list[i]; const CachedRegion *region = old_stream->open_region(region_info.position, region_info.lod, false); @@ -872,7 +872,7 @@ void VoxelStreamRegionFiles::_convert_files(Meta new_meta) { print_line(String("Converting region lod{0}/{1}").format(varray(region_info.lod, region_info.position.to_vec3()))); const RegionHeader &header = region->header; - for (int j = 0; j < header.blocks.size(); ++j) { + for (unsigned int j = 0; j < header.blocks.size(); ++j) { const BlockInfo bi = header.blocks[j]; if (bi.data == 0) { continue; diff --git a/streams/voxel_stream_region_files.h b/streams/voxel_stream_region_files.h index f81e69c7..3a202e13 100644 --- a/streams/voxel_stream_region_files.h +++ b/streams/voxel_stream_region_files.h @@ -72,7 +72,7 @@ private: int get_sector_count_from_bytes(int size_in_bytes) const; int get_region_header_size() const; CachedRegion *get_region_from_cache(const Vector3i pos, int lod) const; - void remove_sectors_from_block(CachedRegion *p_region, Vector3i block_rpos, int p_sector_count); + void remove_sectors_from_block(CachedRegion *p_region, Vector3i block_rpos, unsigned int p_sector_count); int get_sectors_count(const RegionHeader &header) const; void close_oldest_region(); void save_header(CachedRegion *p_region); @@ -160,7 +160,7 @@ private: bool _meta_loaded = false; bool _meta_saved = false; std::vector _region_cache; - int _max_open_regions = MIN(8, FOPEN_MAX); + unsigned int _max_open_regions = MIN(8, FOPEN_MAX); }; #endif // VOXEL_STREAM_REGION_H diff --git a/terrain/block_thread_manager.h b/terrain/block_thread_manager.h index 867688a2..d7971301 100644 --- a/terrain/block_thread_manager.h +++ b/terrain/block_thread_manager.h @@ -345,12 +345,12 @@ private: if (index) { // The block is already in the update queue, replace it ++replaced_blocks; - CRASH_COND(*index < 0 || *index >= job.shared_input.blocks.size()); + CRASH_COND(*index < 0 || *index >= (int)job.shared_input.blocks.size()); job.shared_input.blocks[*index] = block; } else { // Append new block request - int j = job.shared_input.blocks.size(); + unsigned int j = job.shared_input.blocks.size(); job.shared_input.blocks.push_back(block); job.shared_input_block_indexes[block.lod][block.position] = j; } @@ -393,8 +393,8 @@ private: }); } - int input_begin = queue_index; - int batch_count = data.batch_count; + unsigned int input_begin = queue_index; + unsigned int batch_count = data.batch_count; if (input_begin + batch_count > data.input.blocks.size()) { batch_count = data.input.blocks.size() - input_begin; @@ -404,10 +404,10 @@ private: uint64_t time_before = OS::get_singleton()->get_ticks_usec(); - int output_begin = data.output.blocks.size(); + unsigned int output_begin = data.output.blocks.size(); data.output.blocks.resize(data.output.blocks.size() + batch_count); - for (int i = 0; i < batch_count; ++i) { + for (unsigned int i = 0; i < batch_count; ++i) { CRASH_COND(input_begin + i < 0 || input_begin + i >= data.input.blocks.size()); InputBlock &ib = data.input.blocks[input_begin + i]; OutputBlock &ob = data.output.blocks.write[output_begin + i]; diff --git a/terrain/voxel_block.cpp b/terrain/voxel_block.cpp index a1210e1a..4a55873a 100644 --- a/terrain/voxel_block.cpp +++ b/terrain/voxel_block.cpp @@ -16,7 +16,6 @@ static Ref create_concave_polygon_shape(Array surface_array ERR_FAIL_COND_V(indices.size() % 3 != 0, Ref()); int face_points_count = indices.size(); - int face_count = face_points_count / 3; PoolVector face_points; face_points.resize(face_points_count); diff --git a/terrain/voxel_data_loader.cpp b/terrain/voxel_data_loader.cpp index 5df085a6..f911418f 100644 --- a/terrain/voxel_data_loader.cpp +++ b/terrain/voxel_data_loader.cpp @@ -2,7 +2,7 @@ #include "../streams/voxel_stream.h" #include "../util/utility.h" -VoxelDataLoader::VoxelDataLoader(int thread_count, Ref stream, int block_size_pow2) { +VoxelDataLoader::VoxelDataLoader(unsigned int thread_count, Ref stream, unsigned int block_size_pow2) { print_line("Constructing VoxelDataLoader"); CRASH_COND(stream.is_null()); @@ -26,7 +26,7 @@ VoxelDataLoader::VoxelDataLoader(int thread_count, Ref stream, int // Note: more than one thread can make sense for generators, // but won't be as useful for file and network streams - for (int i = 1; i < thread_count; ++i) { + for (unsigned int i = 1; i < thread_count; ++i) { stream = stream->duplicate(); processors[i] = [this, stream](ArraySlice inputs, ArraySlice outputs, Mgr::ProcessorStats &stats) { this->process_blocks_thread_func(inputs, outputs, stream, stats); diff --git a/terrain/voxel_data_loader.h b/terrain/voxel_data_loader.h index c6e59df7..fdb2c4be 100644 --- a/terrain/voxel_data_loader.h +++ b/terrain/voxel_data_loader.h @@ -29,7 +29,7 @@ public: typedef Mgr::Output Output; typedef Mgr::Stats Stats; - VoxelDataLoader(int thread_count, Ref stream, int block_size_pow2); + VoxelDataLoader(unsigned int thread_count, Ref stream, unsigned int block_size_pow2); ~VoxelDataLoader(); void push(const Input &input) { _mgr->push(input); } diff --git a/terrain/voxel_lod_terrain.cpp b/terrain/voxel_lod_terrain.cpp index 7b6c2964..76292264 100644 --- a/terrain/voxel_lod_terrain.cpp +++ b/terrain/voxel_lod_terrain.cpp @@ -621,7 +621,7 @@ void VoxelLodTerrain::send_block_data_requests() { lod.blocks_to_load.clear(); } - for (int i = 0; i < _blocks_to_save.size(); ++i) { + for (unsigned int i = 0; i < _blocks_to_save.size(); ++i) { print_line(String("Requesting save of block {0} lod {1}") .format(varray(_blocks_to_save[i].position.to_vec3(), _blocks_to_save[i].lod))); input.blocks.push_back(_blocks_to_save[i]); @@ -1186,7 +1186,7 @@ void VoxelLodTerrain::flush_pending_lod_edits() { // Make sure LOD0 gets updates even if _lod_count is 1 Lod &lod0 = _lods[0]; - for (int i = 0; i < lod0.blocks_pending_lodding.size(); ++i) { + for (unsigned int i = 0; i < lod0.blocks_pending_lodding.size(); ++i) { Vector3i bpos = lod0.blocks_pending_lodding[i]; VoxelBlock *block = lod0.map->get_block(bpos); block->set_needs_lodding(false); @@ -1202,7 +1202,7 @@ void VoxelLodTerrain::flush_pending_lod_edits() { Lod &src_lod = _lods[dst_lod_index - 1]; Lod &dst_lod = _lods[dst_lod_index]; - for (int i = 0; i < src_lod.blocks_pending_lodding.size(); ++i) { + for (unsigned int i = 0; i < src_lod.blocks_pending_lodding.size(); ++i) { Vector3i src_bpos = src_lod.blocks_pending_lodding[i]; Vector3i dst_bpos = src_bpos >> 1; @@ -1312,7 +1312,7 @@ Dictionary VoxelLodTerrain::get_statistics() const { d["time_request_blocks_to_update"] = _stats.time_request_blocks_to_update; d["time_process_update_responses"] = _stats.time_process_update_responses; - d["remaining_main_thread_blocks"] = _blocks_pending_main_thread_update.size(); + d["remaining_main_thread_blocks"] = (int)_blocks_pending_main_thread_update.size(); d["dropped_block_loads"] = _stats.dropped_block_loads; d["dropped_block_meshs"] = _stats.dropped_block_meshs; d["updated_blocks"] = _stats.updated_blocks; diff --git a/terrain/voxel_mesh_updater.cpp b/terrain/voxel_mesh_updater.cpp index a84c6546..bd2ad212 100644 --- a/terrain/voxel_mesh_updater.cpp +++ b/terrain/voxel_mesh_updater.cpp @@ -95,7 +95,7 @@ void VoxelMeshUpdater::process_blocks_thread_func( CRASH_COND(inputs.size() != outputs.size()); - for (int i = 0; i < inputs.size(); ++i) { + for (unsigned int i = 0; i < inputs.size(); ++i) { const InputBlock &ib = inputs[i]; const InputBlockData &block = ib.data; diff --git a/terrain/voxel_terrain.cpp b/terrain/voxel_terrain.cpp index 458e5488..e1661a83 100644 --- a/terrain/voxel_terrain.cpp +++ b/terrain/voxel_terrain.cpp @@ -349,7 +349,7 @@ Dictionary VoxelTerrain::get_statistics() const { d["time_request_blocks_to_update"] = _stats.time_request_blocks_to_update; d["time_process_update_responses"] = _stats.time_process_update_responses; - d["remaining_main_thread_blocks"] = _blocks_pending_main_thread_update.size(); + d["remaining_main_thread_blocks"] = (int)_blocks_pending_main_thread_update.size(); d["dropped_block_loads"] = _stats.dropped_block_loads; d["dropped_block_meshs"] = _stats.dropped_block_meshs; d["updated_blocks"] = _stats.updated_blocks; @@ -714,7 +714,7 @@ void VoxelTerrain::send_block_data_requests() { input.blocks.push_back(input_block); } - for (int i = 0; i < _blocks_to_save.size(); ++i) { + for (unsigned int i = 0; i < _blocks_to_save.size(); ++i) { print_line(String("Requesting save of block {0}").format(varray(_blocks_to_save[i].position.to_vec3()))); input.blocks.push_back(_blocks_to_save[i]); }