mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-11-22 00:48:09 +01:00
Fixed more potential issues found by the tool.
This commit is contained in:
parent
0a5ed34bb7
commit
e55f856fa2
@ -40,7 +40,9 @@ int SpeciesInstance::get_species_id() const {
|
||||
void SpeciesInstance::set_species_id(int value) {
|
||||
_id = value;
|
||||
|
||||
_species = ESS::get_singleton()->get_resource_db()->get_entity_species_data(_id);
|
||||
if (ESS::get_singleton()) {
|
||||
_species = ESS::get_singleton()->get_resource_db()->get_entity_species_data(_id);
|
||||
}
|
||||
}
|
||||
|
||||
StringName SpeciesInstance::get_species_path() const {
|
||||
@ -49,7 +51,9 @@ StringName SpeciesInstance::get_species_path() const {
|
||||
void SpeciesInstance::set_species_path(const StringName &value) {
|
||||
_path = value;
|
||||
|
||||
_species = ESS::get_singleton()->get_resource_db()->get_entity_species_data_path(_path);
|
||||
if (ESS::get_singleton()) {
|
||||
_species = ESS::get_singleton()->get_resource_db()->get_entity_species_data_path(_path);
|
||||
}
|
||||
}
|
||||
|
||||
Ref<EntitySpeciesData> SpeciesInstance::get_species() {
|
||||
|
@ -1796,6 +1796,9 @@ Spell::~Spell() {
|
||||
}
|
||||
|
||||
void Spell::_cast_starts(Ref<SpellCastInfo> info) {
|
||||
ERR_FAIL_COND(!info.is_valid());
|
||||
ERR_FAIL_COND(!info->caster_get());
|
||||
|
||||
if (info->caster_get()->cast_is_castings()) {
|
||||
return;
|
||||
}
|
||||
@ -1831,6 +1834,9 @@ void Spell::_cast_starts(Ref<SpellCastInfo> info) {
|
||||
}
|
||||
|
||||
void Spell::_cast_finishs(Ref<SpellCastInfo> info) {
|
||||
ERR_FAIL_COND(!info.is_valid());
|
||||
ERR_FAIL_COND(!info->caster_get());
|
||||
|
||||
info->caster_get()->notification_scast(SpellEnums::NOTIFICATION_CAST_FINISHED, info);
|
||||
info->caster_get()->cast_spell_successs(info);
|
||||
|
||||
@ -1848,40 +1854,55 @@ void Spell::_cast_finishs(Ref<SpellCastInfo> info) {
|
||||
}
|
||||
|
||||
void Spell::_son_cast_player_moved(Ref<SpellCastInfo> info) {
|
||||
ERR_FAIL_COND(!info.is_valid());
|
||||
ERR_FAIL_COND(!info->caster_get());
|
||||
|
||||
if (get_can_move_while_casting()) {
|
||||
info->caster_get()->cast_fails();
|
||||
}
|
||||
}
|
||||
|
||||
void Spell::_son_spell_hit(Ref<SpellCastInfo> info) {
|
||||
ERR_FAIL_COND(!info.is_valid());
|
||||
|
||||
handle_effect(info);
|
||||
}
|
||||
|
||||
void Spell::_calculate_initial_damage(Ref<SpellDamageInfo> data) {
|
||||
ERR_FAIL_COND(!data.is_valid());
|
||||
|
||||
Math::randomize();
|
||||
|
||||
data->damage_set(damage_get_min() + (damage_get_max() - damage_get_min()) * Math::randf());
|
||||
}
|
||||
|
||||
void Spell::_handle_spell_damage(Ref<SpellDamageInfo> data) {
|
||||
ERR_FAIL_COND(!data.is_valid());
|
||||
|
||||
calculate_initial_damage(data);
|
||||
|
||||
data->dealer_get()->sdeal_damage_to(data);
|
||||
}
|
||||
|
||||
void Spell::_calculate_initial_heal(Ref<SpellHealInfo> data) {
|
||||
ERR_FAIL_COND(!data.is_valid());
|
||||
|
||||
Math::randomize();
|
||||
|
||||
data->heal_set(heal_get_min() + (heal_get_max() - heal_get_min()) * Math::randf());
|
||||
}
|
||||
|
||||
void Spell::_handle_spell_heal(Ref<SpellHealInfo> data) {
|
||||
ERR_FAIL_COND(!data.is_valid());
|
||||
|
||||
calculate_initial_heal(data);
|
||||
|
||||
data->dealer_get()->sdeal_heal_to(data);
|
||||
}
|
||||
|
||||
void Spell::_handle_projectile(Ref<SpellCastInfo> info) {
|
||||
ERR_FAIL_COND(!info.is_valid());
|
||||
|
||||
if (_projectile_scene.is_valid()) {
|
||||
Node *projectile = _projectile_scene->instance();
|
||||
|
||||
@ -1897,6 +1918,8 @@ void Spell::_handle_projectile(Ref<SpellCastInfo> info) {
|
||||
}
|
||||
|
||||
void Spell::_handle_effect(Ref<SpellCastInfo> info) {
|
||||
ERR_FAIL_COND(!info.is_valid());
|
||||
|
||||
/*
|
||||
# var ok : bool = false
|
||||
|
||||
@ -2001,6 +2024,7 @@ void Spell::_handle_effect(Ref<SpellCastInfo> info) {
|
||||
}
|
||||
|
||||
void Spell::_aura_sapply(Ref<AuraApplyInfo> info) {
|
||||
ERR_FAIL_COND(!info.is_valid());
|
||||
ERR_FAIL_COND(info->target_get() == NULL || info->caster_get() == NULL || !info->get_aura().is_valid());
|
||||
|
||||
Ref<AuraData> ad = info->target_get()->aura_gets_by(info->caster_get(), _id);
|
||||
@ -2033,6 +2057,7 @@ void Spell::_aura_sapply(Ref<AuraApplyInfo> info) {
|
||||
}
|
||||
|
||||
void Spell::_aura_sdeapply(Ref<AuraData> data) {
|
||||
ERR_FAIL_COND(!data.is_valid());
|
||||
ERR_FAIL_COND(data->get_owner() == NULL || data->caster_get() == NULL || !data->get_aura().is_valid());
|
||||
|
||||
Entity *owner = data->get_owner();
|
||||
@ -2053,6 +2078,7 @@ void Spell::_aura_sdeapply(Ref<AuraData> data) {
|
||||
}
|
||||
|
||||
void Spell::_aura_sadd(Ref<AuraData> aura) {
|
||||
ERR_FAIL_COND(!aura.is_valid());
|
||||
ERR_FAIL_COND(aura->get_owner() == NULL);
|
||||
|
||||
//sapply(aura);
|
||||
@ -2062,6 +2088,7 @@ void Spell::_aura_sadd(Ref<AuraData> aura) {
|
||||
}
|
||||
|
||||
void Spell::_aura_sremove(Ref<AuraData> aura) {
|
||||
ERR_FAIL_COND(!aura.is_valid());
|
||||
ERR_FAIL_COND(aura->get_owner() == NULL);
|
||||
|
||||
aura_sdeapply(aura);
|
||||
@ -2070,6 +2097,7 @@ void Spell::_aura_sremove(Ref<AuraData> aura) {
|
||||
}
|
||||
|
||||
void Spell::_aura_removes_expired(Ref<AuraData> aura) {
|
||||
ERR_FAIL_COND(!aura.is_valid());
|
||||
ERR_FAIL_COND(aura->get_owner() == NULL);
|
||||
|
||||
aura_sdeapply(aura);
|
||||
@ -2078,6 +2106,7 @@ void Spell::_aura_removes_expired(Ref<AuraData> aura) {
|
||||
}
|
||||
|
||||
void Spell::_aura_removes_dispell(Ref<AuraData> aura) {
|
||||
ERR_FAIL_COND(!aura.is_valid());
|
||||
ERR_FAIL_COND(aura->get_owner() == NULL);
|
||||
|
||||
aura_sdeapply(aura);
|
||||
@ -2086,6 +2115,8 @@ void Spell::_aura_removes_dispell(Ref<AuraData> aura) {
|
||||
}
|
||||
|
||||
void Spell::_aura_supdate(Ref<AuraData> aura, float delta) {
|
||||
ERR_FAIL_COND(!aura.is_valid());
|
||||
|
||||
bool remove = false;
|
||||
|
||||
remove = aura->update(delta);
|
||||
@ -2121,6 +2152,8 @@ void Spell::_aura_supdate(Ref<AuraData> aura, float delta) {
|
||||
}
|
||||
|
||||
void Spell::_setup_aura_data(Ref<AuraData> data, Ref<AuraApplyInfo> info) {
|
||||
ERR_FAIL_COND(!data.is_valid());
|
||||
ERR_FAIL_COND(!info.is_valid());
|
||||
ERR_FAIL_COND(!ObjectDB::instance_validate(info->caster_get()));
|
||||
|
||||
data->set_aura(Ref<Spell>(this));
|
||||
@ -2153,20 +2186,32 @@ void Spell::_aura_sapply_passives_damage_deal(Ref<SpellDamageInfo> info) {
|
||||
}
|
||||
|
||||
void Spell::_aura_calculate_initial_damage(Ref<AuraData> aura_data, Ref<AuraApplyInfo> info) {
|
||||
ERR_FAIL_COND(!aura_data.is_valid());
|
||||
ERR_FAIL_COND(!info.is_valid());
|
||||
|
||||
int min_damage = aura_damage_get_min();
|
||||
int max_damage = aura_damage_get_max();
|
||||
int mmm = (max_damage - min_damage);
|
||||
|
||||
Math::randomize();
|
||||
int damage = min_damage + Math::rand() % (max_damage - min_damage);
|
||||
int damage = min_damage;
|
||||
|
||||
if (aura_get_scale_with_level()) {
|
||||
damage = static_cast<int>(damage * static_cast<float>(info->caster_get()->gets_level()) / static_cast<float>(ESS::get_singleton()->get_max_character_level()));
|
||||
if (mmm > 0) {
|
||||
Math::randomize();
|
||||
damage = min_damage + (Math::rand() % mmm);
|
||||
|
||||
if (aura_get_scale_with_level()) {
|
||||
damage = static_cast<int>(damage * static_cast<float>(info->caster_get()->gets_level()) / static_cast<float>(ESS::get_singleton()->get_max_character_level()));
|
||||
}
|
||||
}
|
||||
|
||||
aura_data->damage_set(damage);
|
||||
}
|
||||
|
||||
void Spell::_handle_aura_damage(Ref<AuraData> aura_data, Ref<SpellDamageInfo> info) {
|
||||
ERR_FAIL_COND(!aura_data.is_valid());
|
||||
ERR_FAIL_COND(!info.is_valid());
|
||||
ERR_FAIL_COND(!info->receiver_get());
|
||||
|
||||
if (info->dealer_get() && !ObjectDB::instance_validate(info->dealer_get())) {
|
||||
info->dealer_set(NULL);
|
||||
}
|
||||
@ -2190,20 +2235,32 @@ void Spell::_aura_sapply_passives_heal_deal(Ref<SpellHealInfo> data) {
|
||||
}
|
||||
|
||||
void Spell::_aura_calculate_initial_heal(Ref<AuraData> aura_data, Ref<AuraApplyInfo> info) {
|
||||
ERR_FAIL_COND(!aura_data.is_valid());
|
||||
ERR_FAIL_COND(!info.is_valid());
|
||||
|
||||
int min_heal = aura_heal_get_min();
|
||||
int max_heal = aura_heal_get_max();
|
||||
int mmm = (max_heal - min_heal);
|
||||
|
||||
Math::randomize();
|
||||
int heal = min_heal + Math::rand() % (max_heal - min_heal);
|
||||
int heal = min_heal;
|
||||
|
||||
if (aura_get_scale_with_level()) {
|
||||
heal = static_cast<int>(heal * static_cast<float>(info->caster_get()->gets_level()) / static_cast<float>(ESS::get_singleton()->get_max_character_level()));
|
||||
if (mmm > 0) {
|
||||
Math::randomize();
|
||||
heal = min_heal + (Math::rand() % mmm);
|
||||
|
||||
if (aura_get_scale_with_level()) {
|
||||
heal = static_cast<int>(heal * static_cast<float>(info->caster_get()->gets_level()) / static_cast<float>(ESS::get_singleton()->get_max_character_level()));
|
||||
}
|
||||
}
|
||||
|
||||
aura_data->heal_set(heal);
|
||||
}
|
||||
|
||||
void Spell::_handle_aura_heal(Ref<AuraData> aura_data, Ref<SpellHealInfo> info) {
|
||||
ERR_FAIL_COND(!aura_data.is_valid());
|
||||
ERR_FAIL_COND(!info.is_valid());
|
||||
ERR_FAIL_COND(!info->receiver_get());
|
||||
|
||||
if (info->dealer_get() && !ObjectDB::instance_validate(info->dealer_get())) {
|
||||
info->dealer_set(NULL);
|
||||
}
|
||||
|
@ -25,18 +25,18 @@ SOFTWARE.
|
||||
#include "../../singletons/ess.h"
|
||||
|
||||
int SimpleLevelStatData::get_stat_per_level(int main_stat) {
|
||||
ERR_FAIL_INDEX_V(main_stat, ESS::get_singleton()->stat_get_main_stat_count(), 0);
|
||||
ERR_FAIL_INDEX_V(main_stat, _stat_per_level.size(), 0);
|
||||
|
||||
return _stat_per_level[main_stat];
|
||||
}
|
||||
void SimpleLevelStatData::set_stat_per_level(int main_stat, int value) {
|
||||
ERR_FAIL_INDEX(main_stat, ESS::get_singleton()->stat_get_main_stat_count());
|
||||
ERR_FAIL_INDEX(main_stat, _stat_per_level.size());
|
||||
|
||||
_stat_per_level.set(main_stat, value);
|
||||
}
|
||||
|
||||
int SimpleLevelStatData::_get_stat_diff(int main_stat, int old_level, int new_level) {
|
||||
ERR_FAIL_INDEX_V(main_stat, ESS::get_singleton()->stat_get_main_stat_count(), 0);
|
||||
ERR_FAIL_INDEX_V(main_stat, _stat_per_level.size(), 0);
|
||||
|
||||
int s = _stat_per_level[main_stat];
|
||||
|
||||
@ -60,7 +60,7 @@ SimpleLevelStatData::~SimpleLevelStatData() {
|
||||
}
|
||||
|
||||
bool SimpleLevelStatData::_set(const StringName &p_name, const Variant &p_value) {
|
||||
if (ESS::get_singleton()->stat_is_property(p_name)) {
|
||||
if (ESS::get_singleton() && ESS::get_singleton()->stat_is_property(p_name)) {
|
||||
int stat_id = ESS::get_singleton()->stat_get_property_id(p_name);
|
||||
|
||||
if (stat_id >= ESS::get_singleton()->stat_get_main_stat_count()) {
|
||||
@ -76,7 +76,7 @@ bool SimpleLevelStatData::_set(const StringName &p_name, const Variant &p_value)
|
||||
}
|
||||
|
||||
bool SimpleLevelStatData::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
if (ESS::get_singleton()->stat_is_property(p_name)) {
|
||||
if (ESS::get_singleton() && ESS::get_singleton()->stat_is_property(p_name)) {
|
||||
int stat_id = ESS::get_singleton()->stat_get_property_id(p_name);
|
||||
|
||||
if (stat_id >= ESS::get_singleton()->stat_get_main_stat_count()) {
|
||||
@ -95,8 +95,10 @@ void SimpleLevelStatData::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
//int property_usange = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL;
|
||||
int property_usange = PROPERTY_USAGE_DEFAULT;
|
||||
|
||||
for (int i = 0; i < ESS::get_singleton()->stat_get_main_stat_count(); ++i) {
|
||||
p_list->push_back(PropertyInfo(Variant::INT, ESS::get_singleton()->stat_get_property_name(i), PROPERTY_HINT_NONE, "", property_usange));
|
||||
if (ESS::get_singleton()) {
|
||||
for (int i = 0; i < ESS::get_singleton()->stat_get_main_stat_count(); ++i) {
|
||||
p_list->push_back(PropertyInfo(Variant::INT, ESS::get_singleton()->stat_get_property_name(i), PROPERTY_HINT_NONE, "", property_usange));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,6 +208,8 @@ void PropInstancePropJob::_reset() {
|
||||
}
|
||||
|
||||
void PropInstancePropJob::phase_physics_process() {
|
||||
ERR_FAIL_COND(!_prop_instace);
|
||||
|
||||
//TODO this should only update the differences
|
||||
//for (int i = 0; i < _prop_instace->collider_get_num(); ++i) {
|
||||
// PhysicsServer::get_singleton()->free(_prop_instace->collider_body_get(i));
|
||||
|
@ -1093,10 +1093,14 @@ void PropMesher::add_vertex(const Vector3 &vertex) {
|
||||
}
|
||||
|
||||
Vector3 PropMesher::get_vertex(const int idx) const {
|
||||
ERR_FAIL_INDEX_V(idx, _vertices.size(), Vector3());
|
||||
|
||||
return _vertices.get(idx).vertex;
|
||||
}
|
||||
|
||||
void PropMesher::remove_vertex(const int idx) {
|
||||
ERR_FAIL_INDEX(idx, _vertices.size());
|
||||
|
||||
_vertices.remove(idx);
|
||||
}
|
||||
|
||||
@ -1128,6 +1132,8 @@ void PropMesher::add_normal(const Vector3 &normal) {
|
||||
}
|
||||
|
||||
Vector3 PropMesher::get_normal(int idx) const {
|
||||
ERR_FAIL_INDEX_V(idx, _vertices.size(), Vector3());
|
||||
|
||||
return _vertices.get(idx).normal;
|
||||
}
|
||||
|
||||
@ -1159,6 +1165,8 @@ void PropMesher::add_color(const Color &color) {
|
||||
}
|
||||
|
||||
Color PropMesher::get_color(const int idx) const {
|
||||
ERR_FAIL_INDEX_V(idx, _vertices.size(), Color());
|
||||
|
||||
return _vertices.get(idx).color;
|
||||
}
|
||||
|
||||
@ -1190,6 +1198,8 @@ void PropMesher::add_uv(const Vector2 &uv) {
|
||||
}
|
||||
|
||||
Vector2 PropMesher::get_uv(const int idx) const {
|
||||
ERR_FAIL_INDEX_V(idx, _vertices.size(), Vector2());
|
||||
|
||||
return _vertices.get(idx).uv;
|
||||
}
|
||||
|
||||
@ -1221,6 +1231,8 @@ void PropMesher::add_uv2(const Vector2 &uv) {
|
||||
}
|
||||
|
||||
Vector2 PropMesher::get_uv2(const int idx) const {
|
||||
ERR_FAIL_INDEX_V(idx, _vertices.size(), Vector2());
|
||||
|
||||
return _vertices.get(idx).uv2;
|
||||
}
|
||||
|
||||
@ -1241,10 +1253,14 @@ void PropMesher::add_indices(const int index) {
|
||||
}
|
||||
|
||||
int PropMesher::get_index(const int idx) const {
|
||||
ERR_FAIL_INDEX_V(idx, _indices.size(), 0);
|
||||
|
||||
return _indices.get(idx);
|
||||
}
|
||||
|
||||
void PropMesher::remove_index(const int idx) {
|
||||
ERR_FAIL_INDEX(idx, _vertices.size());
|
||||
|
||||
_indices.remove(idx);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user