mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
AreaSW and Area2DSW: fix premature return in call_queries
(cherry picked from commit 89ce63a84f
)
This commit is contained in:
parent
93efa57823
commit
8e5a3a3019
2 changed files with 104 additions and 108 deletions
|
@ -199,19 +199,14 @@ void AreaSW::set_monitorable(bool p_monitorable) {
|
||||||
|
|
||||||
void AreaSW::call_queries() {
|
void AreaSW::call_queries() {
|
||||||
if (monitor_callback_id && !monitored_bodies.empty()) {
|
if (monitor_callback_id && !monitored_bodies.empty()) {
|
||||||
|
Object *obj = ObjectDB::get_instance(monitor_callback_id);
|
||||||
|
if (obj) {
|
||||||
Variant res[5];
|
Variant res[5];
|
||||||
Variant *resptr[5];
|
Variant *resptr[5];
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
resptr[i] = &res[i];
|
resptr[i] = &res[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
Object *obj = ObjectDB::get_instance(monitor_callback_id);
|
|
||||||
if (!obj) {
|
|
||||||
monitored_bodies.clear();
|
|
||||||
monitor_callback_id = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Map<BodyKey, BodyState>::Element *E = monitored_bodies.front(); E;) {
|
for (Map<BodyKey, BodyState>::Element *E = monitored_bodies.front(); E;) {
|
||||||
if (E->get().state == 0) { // Nothing happened
|
if (E->get().state == 0) { // Nothing happened
|
||||||
Map<BodyKey, BodyState>::Element *next = E->next();
|
Map<BodyKey, BodyState>::Element *next = E->next();
|
||||||
|
@ -233,22 +228,21 @@ void AreaSW::call_queries() {
|
||||||
Variant::CallError ce;
|
Variant::CallError ce;
|
||||||
obj->call(monitor_callback_method, (const Variant **)resptr, 5, ce);
|
obj->call(monitor_callback_method, (const Variant **)resptr, 5, ce);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
monitored_bodies.clear();
|
||||||
|
monitor_callback_id = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (area_monitor_callback_id && !monitored_areas.empty()) {
|
if (area_monitor_callback_id && !monitored_areas.empty()) {
|
||||||
|
Object *obj = ObjectDB::get_instance(area_monitor_callback_id);
|
||||||
|
if (obj) {
|
||||||
Variant res[5];
|
Variant res[5];
|
||||||
Variant *resptr[5];
|
Variant *resptr[5];
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
resptr[i] = &res[i];
|
resptr[i] = &res[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
Object *obj = ObjectDB::get_instance(area_monitor_callback_id);
|
|
||||||
if (!obj) {
|
|
||||||
monitored_areas.clear();
|
|
||||||
area_monitor_callback_id = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Map<BodyKey, BodyState>::Element *E = monitored_areas.front(); E;) {
|
for (Map<BodyKey, BodyState>::Element *E = monitored_areas.front(); E;) {
|
||||||
if (E->get().state == 0) { // Nothing happened
|
if (E->get().state == 0) { // Nothing happened
|
||||||
Map<BodyKey, BodyState>::Element *next = E->next();
|
Map<BodyKey, BodyState>::Element *next = E->next();
|
||||||
|
@ -270,6 +264,10 @@ void AreaSW::call_queries() {
|
||||||
Variant::CallError ce;
|
Variant::CallError ce;
|
||||||
obj->call(area_monitor_callback_method, (const Variant **)resptr, 5, ce);
|
obj->call(area_monitor_callback_method, (const Variant **)resptr, 5, ce);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
monitored_areas.clear();
|
||||||
|
area_monitor_callback_id = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,19 +199,14 @@ void Area2DSW::set_monitorable(bool p_monitorable) {
|
||||||
|
|
||||||
void Area2DSW::call_queries() {
|
void Area2DSW::call_queries() {
|
||||||
if (monitor_callback_id && !monitored_bodies.empty()) {
|
if (monitor_callback_id && !monitored_bodies.empty()) {
|
||||||
|
Object *obj = ObjectDB::get_instance(monitor_callback_id);
|
||||||
|
if (obj) {
|
||||||
Variant res[5];
|
Variant res[5];
|
||||||
Variant *resptr[5];
|
Variant *resptr[5];
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
resptr[i] = &res[i];
|
resptr[i] = &res[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
Object *obj = ObjectDB::get_instance(monitor_callback_id);
|
|
||||||
if (!obj) {
|
|
||||||
monitored_bodies.clear();
|
|
||||||
monitor_callback_id = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Map<BodyKey, BodyState>::Element *E = monitored_bodies.front(); E;) {
|
for (Map<BodyKey, BodyState>::Element *E = monitored_bodies.front(); E;) {
|
||||||
if (E->get().state == 0) { // Nothing happened
|
if (E->get().state == 0) { // Nothing happened
|
||||||
Map<BodyKey, BodyState>::Element *next = E->next();
|
Map<BodyKey, BodyState>::Element *next = E->next();
|
||||||
|
@ -233,22 +228,21 @@ void Area2DSW::call_queries() {
|
||||||
Variant::CallError ce;
|
Variant::CallError ce;
|
||||||
obj->call(monitor_callback_method, (const Variant **)resptr, 5, ce);
|
obj->call(monitor_callback_method, (const Variant **)resptr, 5, ce);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
monitored_bodies.clear();
|
||||||
|
monitor_callback_id = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (area_monitor_callback_id && !monitored_areas.empty()) {
|
if (area_monitor_callback_id && !monitored_areas.empty()) {
|
||||||
|
Object *obj = ObjectDB::get_instance(area_monitor_callback_id);
|
||||||
|
if (obj) {
|
||||||
Variant res[5];
|
Variant res[5];
|
||||||
Variant *resptr[5];
|
Variant *resptr[5];
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
resptr[i] = &res[i];
|
resptr[i] = &res[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
Object *obj = ObjectDB::get_instance(area_monitor_callback_id);
|
|
||||||
if (!obj) {
|
|
||||||
monitored_areas.clear();
|
|
||||||
area_monitor_callback_id = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Map<BodyKey, BodyState>::Element *E = monitored_areas.front(); E;) {
|
for (Map<BodyKey, BodyState>::Element *E = monitored_areas.front(); E;) {
|
||||||
if (E->get().state == 0) { // Nothing happened
|
if (E->get().state == 0) { // Nothing happened
|
||||||
Map<BodyKey, BodyState>::Element *next = E->next();
|
Map<BodyKey, BodyState>::Element *next = E->next();
|
||||||
|
@ -270,6 +264,10 @@ void Area2DSW::call_queries() {
|
||||||
Variant::CallError ce;
|
Variant::CallError ce;
|
||||||
obj->call(area_monitor_callback_method, (const Variant **)resptr, 5, ce);
|
obj->call(area_monitor_callback_method, (const Variant **)resptr, 5, ce);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
monitored_areas.clear();
|
||||||
|
area_monitor_callback_id = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue