AreaSW and Area2DSW: fix premature return in call_queries
This commit is contained in:
parent
4e44a15176
commit
89ce63a84f
@ -200,76 +200,74 @@ 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()) {
|
||||||
Variant res[5];
|
|
||||||
Variant *resptr[5];
|
|
||||||
for (int i = 0; i < 5; i++) {
|
|
||||||
resptr[i] = &res[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
Object *obj = ObjectDB::get_instance(monitor_callback_id);
|
Object *obj = ObjectDB::get_instance(monitor_callback_id);
|
||||||
if (!obj) {
|
if (obj) {
|
||||||
monitored_bodies.clear();
|
Variant res[5];
|
||||||
monitor_callback_id = 0;
|
Variant *resptr[5];
|
||||||
return;
|
for (int i = 0; i < 5; i++) {
|
||||||
}
|
resptr[i] = &res[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Map<BodyKey, BodyState>::Element *E = monitored_bodies.front(); E;) {
|
||||||
|
if (E->get().state == 0) { // Nothing happened
|
||||||
|
Map<BodyKey, BodyState>::Element *next = E->next();
|
||||||
|
monitored_bodies.erase(E);
|
||||||
|
E = next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
res[0] = E->get().state > 0 ? PhysicsServer::AREA_BODY_ADDED : PhysicsServer::AREA_BODY_REMOVED;
|
||||||
|
res[1] = E->key().rid;
|
||||||
|
res[2] = E->key().instance_id;
|
||||||
|
res[3] = E->key().body_shape;
|
||||||
|
res[4] = E->key().area_shape;
|
||||||
|
|
||||||
for (Map<BodyKey, BodyState>::Element *E = monitored_bodies.front(); E;) {
|
|
||||||
if (E->get().state == 0) { // Nothing happened
|
|
||||||
Map<BodyKey, BodyState>::Element *next = E->next();
|
Map<BodyKey, BodyState>::Element *next = E->next();
|
||||||
monitored_bodies.erase(E);
|
monitored_bodies.erase(E);
|
||||||
E = next;
|
E = next;
|
||||||
continue;
|
|
||||||
|
Variant::CallError ce;
|
||||||
|
obj->call(monitor_callback_method, (const Variant **)resptr, 5, ce);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
res[0] = E->get().state > 0 ? PhysicsServer::AREA_BODY_ADDED : PhysicsServer::AREA_BODY_REMOVED;
|
monitored_bodies.clear();
|
||||||
res[1] = E->key().rid;
|
monitor_callback_id = 0;
|
||||||
res[2] = E->key().instance_id;
|
|
||||||
res[3] = E->key().body_shape;
|
|
||||||
res[4] = E->key().area_shape;
|
|
||||||
|
|
||||||
Map<BodyKey, BodyState>::Element *next = E->next();
|
|
||||||
monitored_bodies.erase(E);
|
|
||||||
E = next;
|
|
||||||
|
|
||||||
Variant::CallError ce;
|
|
||||||
obj->call(monitor_callback_method, (const Variant **)resptr, 5, ce);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (area_monitor_callback_id && !monitored_areas.empty()) {
|
if (area_monitor_callback_id && !monitored_areas.empty()) {
|
||||||
Variant res[5];
|
|
||||||
Variant *resptr[5];
|
|
||||||
for (int i = 0; i < 5; i++) {
|
|
||||||
resptr[i] = &res[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
Object *obj = ObjectDB::get_instance(area_monitor_callback_id);
|
Object *obj = ObjectDB::get_instance(area_monitor_callback_id);
|
||||||
if (!obj) {
|
if (obj) {
|
||||||
monitored_areas.clear();
|
Variant res[5];
|
||||||
area_monitor_callback_id = 0;
|
Variant *resptr[5];
|
||||||
return;
|
for (int i = 0; i < 5; i++) {
|
||||||
}
|
resptr[i] = &res[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Map<BodyKey, BodyState>::Element *E = monitored_areas.front(); E;) {
|
||||||
|
if (E->get().state == 0) { // Nothing happened
|
||||||
|
Map<BodyKey, BodyState>::Element *next = E->next();
|
||||||
|
monitored_areas.erase(E);
|
||||||
|
E = next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
res[0] = E->get().state > 0 ? PhysicsServer::AREA_BODY_ADDED : PhysicsServer::AREA_BODY_REMOVED;
|
||||||
|
res[1] = E->key().rid;
|
||||||
|
res[2] = E->key().instance_id;
|
||||||
|
res[3] = E->key().body_shape;
|
||||||
|
res[4] = E->key().area_shape;
|
||||||
|
|
||||||
for (Map<BodyKey, BodyState>::Element *E = monitored_areas.front(); E;) {
|
|
||||||
if (E->get().state == 0) { // Nothing happened
|
|
||||||
Map<BodyKey, BodyState>::Element *next = E->next();
|
Map<BodyKey, BodyState>::Element *next = E->next();
|
||||||
monitored_areas.erase(E);
|
monitored_areas.erase(E);
|
||||||
E = next;
|
E = next;
|
||||||
continue;
|
|
||||||
|
Variant::CallError ce;
|
||||||
|
obj->call(area_monitor_callback_method, (const Variant **)resptr, 5, ce);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
res[0] = E->get().state > 0 ? PhysicsServer::AREA_BODY_ADDED : PhysicsServer::AREA_BODY_REMOVED;
|
monitored_areas.clear();
|
||||||
res[1] = E->key().rid;
|
area_monitor_callback_id = 0;
|
||||||
res[2] = E->key().instance_id;
|
|
||||||
res[3] = E->key().body_shape;
|
|
||||||
res[4] = E->key().area_shape;
|
|
||||||
|
|
||||||
Map<BodyKey, BodyState>::Element *next = E->next();
|
|
||||||
monitored_areas.erase(E);
|
|
||||||
E = next;
|
|
||||||
|
|
||||||
Variant::CallError ce;
|
|
||||||
obj->call(area_monitor_callback_method, (const Variant **)resptr, 5, ce);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,76 +200,74 @@ 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()) {
|
||||||
Variant res[5];
|
|
||||||
Variant *resptr[5];
|
|
||||||
for (int i = 0; i < 5; i++) {
|
|
||||||
resptr[i] = &res[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
Object *obj = ObjectDB::get_instance(monitor_callback_id);
|
Object *obj = ObjectDB::get_instance(monitor_callback_id);
|
||||||
if (!obj) {
|
if (obj) {
|
||||||
monitored_bodies.clear();
|
Variant res[5];
|
||||||
monitor_callback_id = 0;
|
Variant *resptr[5];
|
||||||
return;
|
for (int i = 0; i < 5; i++) {
|
||||||
}
|
resptr[i] = &res[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Map<BodyKey, BodyState>::Element *E = monitored_bodies.front(); E;) {
|
||||||
|
if (E->get().state == 0) { // Nothing happened
|
||||||
|
Map<BodyKey, BodyState>::Element *next = E->next();
|
||||||
|
monitored_bodies.erase(E);
|
||||||
|
E = next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
res[0] = E->get().state > 0 ? Physics2DServer::AREA_BODY_ADDED : Physics2DServer::AREA_BODY_REMOVED;
|
||||||
|
res[1] = E->key().rid;
|
||||||
|
res[2] = E->key().instance_id;
|
||||||
|
res[3] = E->key().body_shape;
|
||||||
|
res[4] = E->key().area_shape;
|
||||||
|
|
||||||
for (Map<BodyKey, BodyState>::Element *E = monitored_bodies.front(); E;) {
|
|
||||||
if (E->get().state == 0) { // Nothing happened
|
|
||||||
Map<BodyKey, BodyState>::Element *next = E->next();
|
Map<BodyKey, BodyState>::Element *next = E->next();
|
||||||
monitored_bodies.erase(E);
|
monitored_bodies.erase(E);
|
||||||
E = next;
|
E = next;
|
||||||
continue;
|
|
||||||
|
Variant::CallError ce;
|
||||||
|
obj->call(monitor_callback_method, (const Variant **)resptr, 5, ce);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
res[0] = E->get().state > 0 ? Physics2DServer::AREA_BODY_ADDED : Physics2DServer::AREA_BODY_REMOVED;
|
monitored_bodies.clear();
|
||||||
res[1] = E->key().rid;
|
monitor_callback_id = 0;
|
||||||
res[2] = E->key().instance_id;
|
|
||||||
res[3] = E->key().body_shape;
|
|
||||||
res[4] = E->key().area_shape;
|
|
||||||
|
|
||||||
Map<BodyKey, BodyState>::Element *next = E->next();
|
|
||||||
monitored_bodies.erase(E);
|
|
||||||
E = next;
|
|
||||||
|
|
||||||
Variant::CallError ce;
|
|
||||||
obj->call(monitor_callback_method, (const Variant **)resptr, 5, ce);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (area_monitor_callback_id && !monitored_areas.empty()) {
|
if (area_monitor_callback_id && !monitored_areas.empty()) {
|
||||||
Variant res[5];
|
|
||||||
Variant *resptr[5];
|
|
||||||
for (int i = 0; i < 5; i++) {
|
|
||||||
resptr[i] = &res[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
Object *obj = ObjectDB::get_instance(area_monitor_callback_id);
|
Object *obj = ObjectDB::get_instance(area_monitor_callback_id);
|
||||||
if (!obj) {
|
if (obj) {
|
||||||
monitored_areas.clear();
|
Variant res[5];
|
||||||
area_monitor_callback_id = 0;
|
Variant *resptr[5];
|
||||||
return;
|
for (int i = 0; i < 5; i++) {
|
||||||
}
|
resptr[i] = &res[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Map<BodyKey, BodyState>::Element *E = monitored_areas.front(); E;) {
|
||||||
|
if (E->get().state == 0) { // Nothing happened
|
||||||
|
Map<BodyKey, BodyState>::Element *next = E->next();
|
||||||
|
monitored_areas.erase(E);
|
||||||
|
E = next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
res[0] = E->get().state > 0 ? Physics2DServer::AREA_BODY_ADDED : Physics2DServer::AREA_BODY_REMOVED;
|
||||||
|
res[1] = E->key().rid;
|
||||||
|
res[2] = E->key().instance_id;
|
||||||
|
res[3] = E->key().body_shape;
|
||||||
|
res[4] = E->key().area_shape;
|
||||||
|
|
||||||
for (Map<BodyKey, BodyState>::Element *E = monitored_areas.front(); E;) {
|
|
||||||
if (E->get().state == 0) { // Nothing happened
|
|
||||||
Map<BodyKey, BodyState>::Element *next = E->next();
|
Map<BodyKey, BodyState>::Element *next = E->next();
|
||||||
monitored_areas.erase(E);
|
monitored_areas.erase(E);
|
||||||
E = next;
|
E = next;
|
||||||
continue;
|
|
||||||
|
Variant::CallError ce;
|
||||||
|
obj->call(area_monitor_callback_method, (const Variant **)resptr, 5, ce);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
res[0] = E->get().state > 0 ? Physics2DServer::AREA_BODY_ADDED : Physics2DServer::AREA_BODY_REMOVED;
|
monitored_areas.clear();
|
||||||
res[1] = E->key().rid;
|
area_monitor_callback_id = 0;
|
||||||
res[2] = E->key().instance_id;
|
|
||||||
res[3] = E->key().body_shape;
|
|
||||||
res[4] = E->key().area_shape;
|
|
||||||
|
|
||||||
Map<BodyKey, BodyState>::Element *next = E->next();
|
|
||||||
monitored_areas.erase(E);
|
|
||||||
E = next;
|
|
||||||
|
|
||||||
Variant::CallError ce;
|
|
||||||
obj->call(area_monitor_callback_method, (const Variant **)resptr, 5, ce);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user