Skip to content

Commit c29488c

Browse files
committed
Fixed crash when removing objects and removed useless includes.
1 parent 762ac97 commit c29488c

6 files changed

Lines changed: 65 additions & 60 deletions

File tree

core/net_utilities.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,15 @@ void NS::SyncGroup::remove_all_nodes() {
242242
void NS::SyncGroup::notify_new_variable(ObjectData *p_object_data, const std::string &p_var_name) {
243243
int index = simulated_sync_objects.find(p_object_data);
244244
if (index >= 0) {
245-
simulated_sync_objects[index].change.vars.insert(p_var_name);
246-
simulated_sync_objects[index].change.uknown_vars.insert(p_var_name);
245+
VecFunc::insert_unique(simulated_sync_objects[index].change.vars, p_var_name);
246+
VecFunc::insert_unique(simulated_sync_objects[index].change.uknown_vars, p_var_name);
247247
}
248248
}
249249

250250
void NS::SyncGroup::notify_variable_changed(ObjectData *p_object_data, const std::string &p_var_name) {
251251
int index = simulated_sync_objects.find(p_object_data);
252252
if (index >= 0) {
253-
simulated_sync_objects[index].change.vars.insert(p_var_name);
253+
VecFunc::insert_unique(simulated_sync_objects[index].change.vars, p_var_name);
254254
}
255255
}
256256

core/net_utilities.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#pragma once
22

3-
#include "core/config/project_settings.h"
43
#include "core/templates/local_vector.h"
54

65
#include "core.h"
76
#include "processor.h"
87
#include "var_data.h"
8+
#include <math.h>
99
#include <chrono>
1010
#include <map>
1111
#include <string>
@@ -361,7 +361,7 @@ T StatisticalRingBuffer<T>::average() const {
361361
a = a / T(data.size());
362362
T b = avg_sum / T(data.size());
363363
const T difference = a > b ? a - b : b - a;
364-
ERR_FAIL_COND_V_MSG(difference > (CMP_EPSILON * 4.0), b, "The `avg_sum` accumulated a sensible precision loss: " + rtos(difference));
364+
ERR_FAIL_COND_V_MSG(difference > (std::numeric_limits<T>::epsilon() * 4.0), b, "The `avg_sum` accumulated a sensible precision loss: " + rtos(difference));
365365
return b;
366366
#else
367367
// Divide it by the buffer size is wrong when the buffer is not yet fully
@@ -381,10 +381,10 @@ T StatisticalRingBuffer<T>::average_rounded() const {
381381
for (uint32_t i = 1; i < data.size(); i += 1) {
382382
a += data[i];
383383
}
384-
a = Math::round(double(a) / double(data.size()));
385-
T b = Math::round(double(avg_sum) / double(data.size()));
384+
a = round(double(a) / double(data.size()));
385+
T b = round(double(avg_sum) / double(data.size()));
386386
const T difference = a > b ? a - b : b - a;
387-
ERR_FAIL_COND_V_MSG(difference > (CMP_EPSILON * 4.0), b, "The `avg_sum` accumulated a sensible precision loss: " + rtos(difference));
387+
ERR_FAIL_COND_V_MSG(difference > (std::numeric_limits<T>::epsilon() * 4.0), b, "The `avg_sum` accumulated a sensible precision loss: " + rtos(difference));
388388
return b;
389389
#else
390390
// Divide it by the buffer size is wrong when the buffer is not yet fully
@@ -403,10 +403,10 @@ T StatisticalRingBuffer<T>::get_deviation(T p_mean) const {
403403

404404
double r = 0;
405405
for (uint32_t i = 0; i < data.size(); i += 1) {
406-
r += Math::pow(double(data[i]) - double(p_mean), 2.0);
406+
r += pow(double(data[i]) - double(p_mean), 2.0);
407407
}
408408

409-
return Math::sqrt(r / double(data.size()));
409+
return sqrt(r / double(data.size()));
410410
}
411411

412412
template <class T>
@@ -474,8 +474,8 @@ struct SyncGroup {
474474
public:
475475
struct Change {
476476
bool unknown = false;
477-
RBSet<std::string> uknown_vars;
478-
RBSet<std::string> vars;
477+
std::vector<std::string> uknown_vars;
478+
std::vector<std::string> vars;
479479
};
480480

481481
struct SimulatedObjectInfo {

core/peer_networked_controller.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "peer_networked_controller.h"
22

3+
#include "core/config/project_settings.h"
34
#include "core/io/marshalls.h"
45
#include "core/os/os.h"
56
#include "core/templates/vector.h"

godot4/gd_scene_synchronizer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "gd_scene_synchronizer.h"
22

3+
#include "core/config/project_settings.h"
34
#include "core/object/object.h"
45
#include "core/string/string_name.h"
56
#include "core/string/ustring.h"

0 commit comments

Comments
 (0)