summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-09-01 21:52:55 +0200
committerGitHub <noreply@github.com>2017-09-01 21:52:55 +0200
commitdac150108ab3c1f41d5fd86cc6853f883064caaf (patch)
tree09195c9dd5e0d651e96b7d26f26985ab5ff6f871 /servers
parent69ac4cbb3764a454194e27a7afe71d98af65c32c (diff)
parentf9467ec1ea6c0dac2ea513b7dfe58d0349788e02 (diff)
Merge pull request #10846 from hpvb/fix-sign-compare
Fix signed and unsigned comparisons
Diffstat (limited to 'servers')
-rw-r--r--servers/audio/audio_rb_resampler.cpp8
-rw-r--r--servers/audio/effects/audio_effect_chorus.cpp2
-rw-r--r--servers/physics_2d/broad_phase_2d_hash_grid.cpp4
-rw-r--r--servers/visual/visual_server_scene.cpp26
4 files changed, 20 insertions, 20 deletions
diff --git a/servers/audio/audio_rb_resampler.cpp b/servers/audio/audio_rb_resampler.cpp
index 2f160fd7cd..113e356612 100644
--- a/servers/audio/audio_rb_resampler.cpp
+++ b/servers/audio/audio_rb_resampler.cpp
@@ -176,7 +176,7 @@ bool AudioRBResampler::mix(int32_t *p_dest, int p_frames) {
{
- uint32_t read = 0;
+ int read = 0;
switch (channels) {
case 1: read = _resample<1>(p_dest, todo, increment); break;
case 2: read = _resample<2>(p_dest, todo, increment); break;
@@ -189,7 +189,7 @@ bool AudioRBResampler::mix(int32_t *p_dest, int p_frames) {
if (remaining && todo > 0) {
//print_line("fadeout");
- for (int c = 0; c < channels; c++) {
+ for (uint32_t c = 0; c < channels; c++) {
for (int i = 0; i < todo; i++) {
@@ -202,7 +202,7 @@ bool AudioRBResampler::mix(int32_t *p_dest, int p_frames) {
}
//zero out what remains there to avoid glitches
- for (int i = todo * channels; i < int(p_frames) * channels; i++) {
+ for (uint32_t i = todo * channels; i < int(p_frames) * channels; i++) {
p_dest[i] = 0;
}
@@ -250,7 +250,7 @@ Error AudioRBResampler::setup(int p_channels, int p_src_mix_rate, int p_target_m
rb_write_pos = 0;
//avoid maybe strange noises upon load
- for (int i = 0; i < (rb_len * channels); i++) {
+ for (unsigned int i = 0; i < (rb_len * channels); i++) {
rb[i] = 0;
read_buf[i] = 0;
diff --git a/servers/audio/effects/audio_effect_chorus.cpp b/servers/audio/effects/audio_effect_chorus.cpp
index 4075bc3e63..76dd585ffa 100644
--- a/servers/audio/effects/audio_effect_chorus.cpp
+++ b/servers/audio/effects/audio_effect_chorus.cpp
@@ -78,7 +78,7 @@ void AudioEffectChorusInstance::_process_chunk(const AudioFrame *p_src_frames, A
uint64_t increment = llrint(cycles_to_mix / (double)p_frame_count * (double)(1 << AudioEffectChorus::CYCLES_FRAC));
//check the LFO doesn't read ahead of the write pos
- if ((((int)max_depth_frames) + 10) > delay_frames) { //10 as some threshold to avoid precision stuff
+ if ((((unsigned int)max_depth_frames) + 10) > delay_frames) { //10 as some threshold to avoid precision stuff
delay_frames += (int)max_depth_frames - delay_frames;
delay_frames += 10; //threshold to avoid precision stuff
}
diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.cpp b/servers/physics_2d/broad_phase_2d_hash_grid.cpp
index 6c800a4b49..db18995bee 100644
--- a/servers/physics_2d/broad_phase_2d_hash_grid.cpp
+++ b/servers/physics_2d/broad_phase_2d_hash_grid.cpp
@@ -640,7 +640,7 @@ BroadPhase2DHashGrid::BroadPhase2DHashGrid() {
cell_size = GLOBAL_DEF("physics/2d/cell_size", 128);
large_object_min_surface = GLOBAL_DEF("physics/2d/large_object_surface_threshold_in_cells", 512);
- for (int i = 0; i < hash_table_size; i++)
+ for (uint32_t i = 0; i < hash_table_size; i++)
hash_table[i] = NULL;
pass = 1;
@@ -649,7 +649,7 @@ BroadPhase2DHashGrid::BroadPhase2DHashGrid() {
BroadPhase2DHashGrid::~BroadPhase2DHashGrid() {
- for (int i = 0; i < hash_table_size; i++) {
+ for (uint32_t i = 0; i < hash_table_size; i++) {
while (hash_table[i]) {
PosBin *pb = hash_table[i];
hash_table[i] = pb->next;
diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp
index 2a6cba453c..61ebc6e6de 100644
--- a/servers/visual/visual_server_scene.cpp
+++ b/servers/visual/visual_server_scene.cpp
@@ -1687,7 +1687,7 @@ bool VisualServerScene::_render_reflection_probe_step(Instance *p_instance, int
void VisualServerScene::_gi_probe_fill_local_data(int p_idx, int p_level, int p_x, int p_y, int p_z, const GIProbeDataCell *p_cell, const GIProbeDataHeader *p_header, InstanceGIProbeData::LocalData *p_local_data, Vector<uint32_t> *prev_cell) {
- if (p_level == p_header->cell_subdiv - 1) {
+ if ((uint32_t)p_level == p_header->cell_subdiv - 1) {
Vector3 emission;
emission.x = (p_cell[p_idx].emission >> 24) / 255.0;
@@ -1798,9 +1798,9 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) {
}
for (int i = 0; i < (int)header->cell_subdiv; i++) {
- uint32_t x = header->width >> i;
- uint32_t y = header->height >> i;
- uint32_t z = header->depth >> i;
+ int x = header->width >> i;
+ int y = header->height >> i;
+ int z = header->depth >> i;
//create and clear mipmap
PoolVector<uint8_t> mipmap;
@@ -1896,7 +1896,7 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) {
uint8_t alpha_block[4][4] = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } };
- for (int j = 0; j < k.source_count; j++) {
+ for (uint32_t j = 0; j < k.source_count; j++) {
int alpha = (cells[k.sources[j]].level_alpha >> 8) & 0xFF;
if (alpha < min_alpha)
@@ -2389,7 +2389,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
Vector3 colors[16];
- for (int j = 0; j < b.source_count; j++) {
+ for (uint32_t j = 0; j < b.source_count; j++) {
colors[j].x = (local_data[b.sources[j]].energy[0] / float(probe_data->dynamic.bake_dynamic_range)) / 1024.0;
colors[j].y = (local_data[b.sources[j]].energy[1] / float(probe_data->dynamic.bake_dynamic_range)) / 1024.0;
@@ -2403,8 +2403,8 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
if (b.source_count == 16) {
//all cells are used so, find minmax between them
int further_apart[2] = { 0, 0 };
- for (int j = 0; j < b.source_count; j++) {
- for (int k = j + 1; k < b.source_count; k++) {
+ for (uint32_t j = 0; j < b.source_count; j++) {
+ for (uint32_t k = j + 1; k < b.source_count; k++) {
float d = colors[j].distance_squared_to(colors[k]);
if (d > distance) {
distance = d;
@@ -2424,12 +2424,12 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
//average all colors first
Vector3 average;
- for (int j = 0; j < b.source_count; j++) {
+ for (uint32_t j = 0; j < b.source_count; j++) {
average += colors[j];
}
average.normalize();
//find max distance in normal from average
- for (int j = 0; j < b.source_count; j++) {
+ for (uint32_t j = 0; j < b.source_count; j++) {
float d = average.dot(colors[j]);
distance = MAX(d, distance);
}
@@ -2459,7 +2459,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
Vector3 dir = (to - from).normalized();
- for (int j = 0; j < b.source_count; j++) {
+ for (uint32_t j = 0; j < b.source_count; j++) {
float d = (colors[j] - from).dot(dir) / distance;
indices[j] = int(d * 3 + 0.5);
@@ -2469,7 +2469,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
indices[j] = index_swap[CLAMP(indices[j], 0, 3)];
}
} else {
- for (int j = 0; j < b.source_count; j++) {
+ for (uint32_t j = 0; j < b.source_count; j++) {
indices[j] = 0;
}
}
@@ -2478,7 +2478,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
uint32_t index_block[16] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
- for (int j = 0; j < b.source_count; j++) {
+ for (uint32_t j = 0; j < b.source_count; j++) {
int x = local_data[b.sources[j]].pos[0] % 4;
int y = local_data[b.sources[j]].pos[1] % 4;