Fix compile for 4.0.

This commit is contained in:
Relintai 2020-05-16 21:32:33 +02:00
parent f92758ce3d
commit 9fd0c23f5b
5 changed files with 76 additions and 44 deletions

View File

@ -27,6 +27,12 @@ SOFTWARE.
#include "core/version.h" #include "core/version.h"
#if VERSION_MAJOR >= 4
#define PoolStringArray PackedStringArray
#define POOL_STRING_ARRAY PACKED_STRING_ARRAY
#endif
int Aura::get_id() const { int Aura::get_id() const {
return _id; return _id;
} }
@ -1053,14 +1059,12 @@ void Aura::_removes_dispell(Ref<AuraData> aura) {
} }
void Aura::_supdate(Ref<AuraData> aura, float delta) { void Aura::_supdate(Ref<AuraData> aura, float delta) {
bool remove = false; bool remove = false;
remove = aura->update(delta); remove = aura->update(delta);
//ontick //ontick
while (aura->get_unhandled_ticks() > 0) { while (aura->get_unhandled_ticks() > 0) {
if (aura->get_damage() != 0) { if (aura->get_damage() != 0) {
Ref<SpellDamageInfo> dpd = Ref<SpellDamageInfo>(memnew(SpellDamageInfo())); Ref<SpellDamageInfo> dpd = Ref<SpellDamageInfo>(memnew(SpellDamageInfo()));
@ -1090,7 +1094,6 @@ void Aura::_supdate(Ref<AuraData> aura, float delta) {
} }
void Aura::_setup_aura_data(Ref<AuraData> data, Ref<AuraApplyInfo> info) { void Aura::_setup_aura_data(Ref<AuraData> data, Ref<AuraApplyInfo> info) {
#if VERSION_MAJOR < 4 #if VERSION_MAJOR < 4
ERR_FAIL_COND(!ObjectDB::instance_validate(info->get_caster())); ERR_FAIL_COND(!ObjectDB::instance_validate(info->get_caster()));
#else #else
@ -1131,7 +1134,6 @@ void Aura::_calculate_initial_damage(Ref<AuraData> aura_data, Ref<AuraApplyInfo>
} }
void Aura::_handle_aura_damage(Ref<AuraData> aura_data, Ref<SpellDamageInfo> info) { void Aura::_handle_aura_damage(Ref<AuraData> aura_data, Ref<SpellDamageInfo> info) {
#if VERSION_MAJOR < 4 #if VERSION_MAJOR < 4
ERR_FAIL_COND(!ObjectDB::instance_validate(info->get_dealer())); ERR_FAIL_COND(!ObjectDB::instance_validate(info->get_dealer()));
#else #else
@ -1186,7 +1188,6 @@ void Aura::_handle_aura_heal(Ref<AuraData> aura_data, Ref<SpellHealInfo> info) {
} }
void Aura::_validate_property(PropertyInfo &property) const { void Aura::_validate_property(PropertyInfo &property) const {
String prop = property.name; String prop = property.name;
if (prop.begins_with("StatModAttribute_")) { if (prop.begins_with("StatModAttribute_")) {
int frame = prop.get_slicec('/', 0).get_slicec('_', 1).to_int(); int frame = prop.get_slicec('/', 0).get_slicec('_', 1).to_int();

View File

@ -40,7 +40,6 @@ SOFTWARE.
#include "./resources/entity_resource_speed.h" #include "./resources/entity_resource_speed.h"
#include "./skills/entity_skill.h" #include "./skills/entity_skill.h"
#include "scene/2d/node_2d.h" #include "scene/2d/node_2d.h"
#include "scene/3d/spatial.h"
#include "core/script_language.h" #include "core/script_language.h"
@ -114,7 +113,11 @@ void Entity::setc_guid(int value) {
//Transforms //Transforms
Transform Entity::get_transform_3d(bool only_stored) const { Transform Entity::get_transform_3d(bool only_stored) const {
if (!only_stored && _body_3d) { if (!only_stored && _body_3d) {
#if VERSION_MAJOR < 4
ERR_FAIL_COND_V(!ObjectDB::instance_validate(_body_3d), _transform); ERR_FAIL_COND_V(!ObjectDB::instance_validate(_body_3d), _transform);
#else
ERR_FAIL_COND_V(!_body_3d, _transform);
#endif
return _body_3d->get_transform(); return _body_3d->get_transform();
} }
@ -123,7 +126,11 @@ Transform Entity::get_transform_3d(bool only_stored) const {
} }
void Entity::set_transform_3d(const Transform &transform, bool only_stored) { void Entity::set_transform_3d(const Transform &transform, bool only_stored) {
if (!only_stored && _body_3d) { if (!only_stored && _body_3d) {
#if VERSION_MAJOR < 4
ERR_FAIL_COND(!ObjectDB::instance_validate(_body_3d)); ERR_FAIL_COND(!ObjectDB::instance_validate(_body_3d));
#else
ERR_FAIL_COND(!_body_3d);
#endif
return _body_3d->set_transform(transform); return _body_3d->set_transform(transform);
} }
@ -133,7 +140,11 @@ void Entity::set_transform_3d(const Transform &transform, bool only_stored) {
Transform2D Entity::get_transform_2d(bool only_stored) const { Transform2D Entity::get_transform_2d(bool only_stored) const {
if (!only_stored && _body_2d) { if (!only_stored && _body_2d) {
#if VERSION_MAJOR < 4
ERR_FAIL_COND_V(!ObjectDB::instance_validate(_body_2d), _transform_2d); ERR_FAIL_COND_V(!ObjectDB::instance_validate(_body_2d), _transform_2d);
#else
ERR_FAIL_COND_V(!_body_2d, _transform_2d);
#endif
return _body_2d->get_transform(); return _body_2d->get_transform();
} }
@ -142,7 +153,11 @@ Transform2D Entity::get_transform_2d(bool only_stored) const {
} }
void Entity::set_transform_2d(const Transform2D &transform, bool only_stored) { void Entity::set_transform_2d(const Transform2D &transform, bool only_stored) {
if (!only_stored && _body_2d) { if (!only_stored && _body_2d) {
#if VERSION_MAJOR < 4
ERR_FAIL_COND(!ObjectDB::instance_validate(_body_2d)); ERR_FAIL_COND(!ObjectDB::instance_validate(_body_2d));
#else
ERR_FAIL_COND(!_body_2d);
#endif
return _body_2d->set_transform(_transform_2d); return _body_2d->set_transform(_transform_2d);
} }
@ -225,7 +240,6 @@ EntityEnums::EntityRelationType Entity::getc_relation_to_bind(Node *to) {
return getc_relation_to(e); return getc_relation_to(e);
} }
EntityEnums::EntityRelationType Entity::getc_relation_to(Entity *to) { EntityEnums::EntityRelationType Entity::getc_relation_to(Entity *to) {
#if VERSION_MAJOR < 4 #if VERSION_MAJOR < 4
ERR_FAIL_COND_V(!ObjectDB::instance_validate(to), EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL); ERR_FAIL_COND_V(!ObjectDB::instance_validate(to), EntityEnums::ENTITY_RELATION_TYPE_NEUTRAL);
#else #else
@ -462,7 +476,6 @@ void Entity::sets_entity_data(Ref<EntityData> value) {
if (get_body() == NULL && value.is_valid() && value->get_entity_species_data().is_valid() && if (get_body() == NULL && value.is_valid() && value->get_entity_species_data().is_valid() &&
value->get_entity_species_data()->get_model_data().is_valid() && value->get_entity_species_data()->get_model_data().is_valid() &&
value->get_entity_species_data()->get_model_data()->get_body().is_valid()) { value->get_entity_species_data()->get_model_data()->get_body().is_valid()) {
Node *node = value->get_entity_species_data()->get_model_data()->get_body()->instance(); Node *node = value->get_entity_species_data()->get_model_data()->get_body()->instance();
add_child(node); add_child(node);
@ -484,7 +497,6 @@ void Entity::setc_entity_data(Ref<EntityData> value) {
if (get_body() == NULL && value.is_valid() && value->get_entity_species_data().is_valid() && if (get_body() == NULL && value.is_valid() && value->get_entity_species_data().is_valid() &&
value->get_entity_species_data()->get_model_data().is_valid() && value->get_entity_species_data()->get_model_data().is_valid() &&
value->get_entity_species_data()->get_model_data()->get_body().is_valid()) { value->get_entity_species_data()->get_model_data()->get_body().is_valid()) {
Node *node = value->get_entity_species_data()->get_model_data()->get_body()->instance(); Node *node = value->get_entity_species_data()->get_model_data()->get_body()->instance();
add_child(node); add_child(node);
@ -769,7 +781,6 @@ void Entity::setup_actionbars() {
return; return;
if (is_deserialized()) { if (is_deserialized()) {
return; return;
} }
@ -791,7 +802,6 @@ void Entity::setup_actionbars() {
//} //}
if (!gets_bag().is_valid()) { if (!gets_bag().is_valid()) {
Ref<Bag> bag; Ref<Bag> bag;
bag.instance(); bag.instance();
@ -4656,7 +4666,6 @@ void Entity::aura_removess_with_group(Ref<AuraGroup> aura_group) {
Ref<AuraData> ad = _s_auras.get(i); Ref<AuraData> ad = _s_auras.get(i);
if (ad->get_aura()->get_aura_group() == aura_group) { if (ad->get_aura()->get_aura_group() == aura_group) {
aura_removec(ad); aura_removec(ad);
_s_auras.remove(i); _s_auras.remove(i);
@ -4989,7 +4998,8 @@ void Entity::talents_sclear() {
} }
void Entity::talent_addc(int talent) { void Entity::talent_addc(int talent) {
if (talent_hasc(talent)) return; if (talent_hasc(talent))
return;
_c_talents.push_back(talent); _c_talents.push_back(talent);

View File

@ -60,6 +60,13 @@ SOFTWARE.
#include "core/version.h" #include "core/version.h"
#if VERSION_MAJOR < 4
#include "scene/3d/spatial.h"
#else
#include "scene/3d/node_3d.h"
#define Spatial Node3D
#endif
class EntityData; class EntityData;
class AuraData; class AuraData;
class Spell; class Spell;

View File

@ -28,6 +28,12 @@ SOFTWARE.
#include "level_stat_data.h" #include "level_stat_data.h"
#include "core/version.h"
#if VERSION_MAJOR >= 4
#define REAL FLOAT
#endif
class StatData : public Resource { class StatData : public Resource {
GDCLASS(StatData, Resource); GDCLASS(StatData, Resource);

View File

@ -33,6 +33,14 @@ SOFTWARE.
#include "core/bind/core_bind.h" #include "core/bind/core_bind.h"
#include "core/version.h"
#if VERSION_MAJOR >= 4
#define PoolStringArray PackedStringArray
#define POOL_STRING_ARRAY PACKED_STRING_ARRAY
#endif
class ESSResourceDB; class ESSResourceDB;
class ESSEntitySpawner; class ESSEntitySpawner;
class EntityCreateInfo; class EntityCreateInfo;