mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-02-20 17:14:44 +01:00
Update vrpc's syntax in Entity.
This commit is contained in:
parent
f6958acd6c
commit
951ae259e2
@ -5767,33 +5767,28 @@ int Entity::seen_by_gets_count() {
|
|||||||
return _s_seen_by.size();
|
return _s_seen_by.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::vrpc(const StringName &p_method, VARIANT_ARG_DECLARE) {
|
Error Entity::_vrpc(const StringName &p_method, const Variant **p_arg, int p_argcount) {
|
||||||
VARIANT_ARGPTRS;
|
|
||||||
|
|
||||||
int argc = 0;
|
|
||||||
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
|
|
||||||
if (argptr[i]->get_type() == Variant::NIL)
|
|
||||||
break;
|
|
||||||
argc++;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < _s_seen_by.size(); ++i) {
|
for (int i = 0; i < _s_seen_by.size(); ++i) {
|
||||||
Entity *e = _s_seen_by.get(i);
|
Entity *e = _s_seen_by.get(i);
|
||||||
|
|
||||||
if (unlikely(!INSTANCE_VALIDATE(e))) {
|
if (unlikely(!INSTANCE_VALIDATE(e))) {
|
||||||
_s_seen_by.remove(i);
|
_s_seen_by.remove_at(i);
|
||||||
--i;
|
--i;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int netm = e->get_network_master();
|
int netm = e->get_multiplayer_authority();
|
||||||
|
|
||||||
if (netm != 1)
|
if (netm != 1) {
|
||||||
rpcp(netm, false, p_method, argptr, argc);
|
rpcp(netm, p_method, p_arg, p_argcount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_network_master() != 1)
|
if (get_multiplayer_authority() != 1) {
|
||||||
rpcp(get_network_master(), false, p_method, argptr, argc);
|
rpcp(get_multiplayer_authority(), p_method, p_arg, p_argcount);
|
||||||
|
}
|
||||||
|
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VERSION_MAJOR < 4
|
#if VERSION_MAJOR < 4
|
||||||
|
@ -1082,7 +1082,10 @@ public:
|
|||||||
void seen_by_adds_bind(Node *entity);
|
void seen_by_adds_bind(Node *entity);
|
||||||
int seen_by_gets_count();
|
int seen_by_gets_count();
|
||||||
|
|
||||||
void vrpc(const StringName &p_method, VARIANT_ARG_LIST);
|
template <typename... VarArgs>
|
||||||
|
Error vrpc(const StringName &p_method, VarArgs... p_args);
|
||||||
|
|
||||||
|
Error _vrpc(const StringName &p_method, const Variant **p_arg, int p_argcount);
|
||||||
#if VERSION_MAJOR < 4
|
#if VERSION_MAJOR < 4
|
||||||
Variant _vrpc_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
|
Variant _vrpc_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
|
||||||
#else
|
#else
|
||||||
@ -1346,4 +1349,14 @@ private:
|
|||||||
Vector<Ref<SpellCastInfo>> _physics_process_scis;
|
Vector<Ref<SpellCastInfo>> _physics_process_scis;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename... VarArgs>
|
||||||
|
Error Entity::vrpc(const StringName &p_method, VarArgs... p_args) {
|
||||||
|
Variant args[sizeof...(p_args) + 1] = { p_args..., Variant() }; // +1 makes sure zero sized arrays are also supported.
|
||||||
|
const Variant *argptrs[sizeof...(p_args) + 1];
|
||||||
|
for (uint32_t i = 0; i < sizeof...(p_args); i++) {
|
||||||
|
argptrs[i] = &args[i];
|
||||||
|
}
|
||||||
|
return _vrpc(p_method, sizeof...(p_args) == 0 ? nullptr : (const Variant **)argptrs, sizeof...(p_args));
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user