mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-04-10 05:42:37 +02:00
Removed additional direct script rpc mode query when sending rpcs, in order to simplify that codepath as much as possible. Also removed the remote, remotesync etc. keywords from gdscript, as now they won't work anymore. Node's rpc_config() method should be used instead of marking methods with keywords in scripts.
This commit is contained in:
parent
8809f2b963
commit
88d6ef51eb
@ -270,8 +270,6 @@ void MultiplayerAPI::_process_rpc(Node *p_node, const StringName &p_name, int p_
|
|||||||
const Map<StringName, RPCMode>::Element *E = p_node->get_node_rpc_mode(p_name);
|
const Map<StringName, RPCMode>::Element *E = p_node->get_node_rpc_mode(p_name);
|
||||||
if (E) {
|
if (E) {
|
||||||
rpc_mode = E->get();
|
rpc_mode = E->get();
|
||||||
} else if (p_node->get_script_instance()) {
|
|
||||||
rpc_mode = p_node->get_script_instance()->get_rpc_mode(p_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool can_call = _can_call_mode(p_node, rpc_mode, p_from);
|
bool can_call = _can_call_mode(p_node, rpc_mode, p_from);
|
||||||
@ -572,8 +570,7 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const
|
|||||||
|
|
||||||
int node_id = network_peer->get_unique_id();
|
int node_id = network_peer->get_unique_id();
|
||||||
bool skip_rpc = node_id == p_peer_id;
|
bool skip_rpc = node_id == p_peer_id;
|
||||||
bool call_local_native = false;
|
bool call_local = false;
|
||||||
bool call_local_script = false;
|
|
||||||
bool is_master = p_node->is_network_master();
|
bool is_master = p_node->is_network_master();
|
||||||
|
|
||||||
if (p_peer_id == 0 || p_peer_id == node_id || (p_peer_id < 0 && p_peer_id != -node_id)) {
|
if (p_peer_id == 0 || p_peer_id == node_id || (p_peer_id < 0 && p_peer_id != -node_id)) {
|
||||||
@ -581,15 +578,7 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const
|
|||||||
|
|
||||||
const Map<StringName, RPCMode>::Element *E = p_node->get_node_rpc_mode(p_method);
|
const Map<StringName, RPCMode>::Element *E = p_node->get_node_rpc_mode(p_method);
|
||||||
if (E) {
|
if (E) {
|
||||||
call_local_native = _should_call_local(E->get(), is_master, skip_rpc);
|
call_local = _should_call_local(E->get(), is_master, skip_rpc);
|
||||||
}
|
|
||||||
|
|
||||||
if (call_local_native) {
|
|
||||||
// Done below.
|
|
||||||
} else if (p_node->get_script_instance()) {
|
|
||||||
// Attempt with script.
|
|
||||||
RPCMode rpc_mode = p_node->get_script_instance()->get_rpc_mode(p_method);
|
|
||||||
call_local_script = _should_call_local(rpc_mode, is_master, skip_rpc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -605,7 +594,7 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const
|
|||||||
_send_rpc(p_node, p_peer_id, p_unreliable, p_method, p_arg, p_argcount);
|
_send_rpc(p_node, p_peer_id, p_unreliable, p_method, p_arg, p_argcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (call_local_native) {
|
if (call_local) {
|
||||||
int temp_id = rpc_sender_id;
|
int temp_id = rpc_sender_id;
|
||||||
rpc_sender_id = get_network_unique_id();
|
rpc_sender_id = get_network_unique_id();
|
||||||
Variant::CallError ce;
|
Variant::CallError ce;
|
||||||
@ -619,22 +608,7 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (call_local_script) {
|
ERR_FAIL_COND_MSG(skip_rpc && !(call_local), "RPC '" + p_method + "' on yourself is not allowed by selected mode.");
|
||||||
int temp_id = rpc_sender_id;
|
|
||||||
rpc_sender_id = get_network_unique_id();
|
|
||||||
Variant::CallError ce;
|
|
||||||
ce.error = Variant::CallError::CALL_OK;
|
|
||||||
p_node->get_script_instance()->call(p_method, p_arg, p_argcount, ce);
|
|
||||||
rpc_sender_id = temp_id;
|
|
||||||
if (ce.error != Variant::CallError::CALL_OK) {
|
|
||||||
String error = Variant::get_call_error_text(p_node, p_method, p_arg, p_argcount, ce);
|
|
||||||
error = "rpc() aborted in script local call: - " + error + ".";
|
|
||||||
ERR_PRINT(error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ERR_FAIL_COND_MSG(skip_rpc && !(call_local_native || call_local_script), "RPC '" + p_method + "' on yourself is not allowed by selected mode.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Error MultiplayerAPI::send_bytes(PoolVector<uint8_t> p_data, int p_to, NetworkedMultiplayerPeer::TransferMode p_mode) {
|
Error MultiplayerAPI::send_bytes(PoolVector<uint8_t> p_data, int p_to, NetworkedMultiplayerPeer::TransferMode p_mode) {
|
||||||
|
@ -196,9 +196,6 @@ public:
|
|||||||
virtual void property_set_fallback(const StringName &p_name, const Variant &p_value, bool *r_valid);
|
virtual void property_set_fallback(const StringName &p_name, const Variant &p_value, bool *r_valid);
|
||||||
virtual Variant property_get_fallback(const StringName &p_name, bool *r_valid);
|
virtual Variant property_get_fallback(const StringName &p_name, bool *r_valid);
|
||||||
|
|
||||||
virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const = 0;
|
|
||||||
virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const = 0;
|
|
||||||
|
|
||||||
virtual ScriptLanguage *get_language() = 0;
|
virtual ScriptLanguage *get_language() = 0;
|
||||||
virtual ~ScriptInstance();
|
virtual ~ScriptInstance();
|
||||||
};
|
};
|
||||||
@ -410,9 +407,6 @@ public:
|
|||||||
virtual void property_set_fallback(const StringName &p_name, const Variant &p_value, bool *r_valid = nullptr);
|
virtual void property_set_fallback(const StringName &p_name, const Variant &p_value, bool *r_valid = nullptr);
|
||||||
virtual Variant property_get_fallback(const StringName &p_name, bool *r_valid = nullptr);
|
virtual Variant property_get_fallback(const StringName &p_name, bool *r_valid = nullptr);
|
||||||
|
|
||||||
virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const { return MultiplayerAPI::RPC_MODE_DISABLED; }
|
|
||||||
virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const { return MultiplayerAPI::RPC_MODE_DISABLED; }
|
|
||||||
|
|
||||||
PlaceHolderScriptInstance(ScriptLanguage *p_language, Ref<Script> p_script, Object *p_owner);
|
PlaceHolderScriptInstance(ScriptLanguage *p_language, Ref<Script> p_script, Object *p_owner);
|
||||||
~PlaceHolderScriptInstance();
|
~PlaceHolderScriptInstance();
|
||||||
};
|
};
|
||||||
|
@ -1269,15 +1269,6 @@ ScriptLanguage *CScriptInstance::get_language() {
|
|||||||
return CScriptLanguage::get_singleton();
|
return CScriptLanguage::get_singleton();
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiplayerAPI::RPCMode CScriptInstance::get_rpc_mode(const StringName &p_method) const {
|
|
||||||
//note that methods set up using rpc_config should still work, even if they are declared in scripts.
|
|
||||||
return MultiplayerAPI::RPC_MODE_DISABLED;
|
|
||||||
}
|
|
||||||
|
|
||||||
MultiplayerAPI::RPCMode CScriptInstance::get_rset_mode(const StringName &p_variable) const {
|
|
||||||
return MultiplayerAPI::RPC_MODE_DISABLED;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CScriptInstance::reload_members() {
|
void CScriptInstance::reload_members() {
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
|
|
||||||
|
@ -286,9 +286,6 @@ public:
|
|||||||
|
|
||||||
void reload_members();
|
void reload_members();
|
||||||
|
|
||||||
virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
|
|
||||||
virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
|
|
||||||
|
|
||||||
CScriptInstance();
|
CScriptInstance();
|
||||||
~CScriptInstance();
|
~CScriptInstance();
|
||||||
};
|
};
|
||||||
|
@ -1283,38 +1283,6 @@ ScriptLanguage *GDScriptInstance::get_language() {
|
|||||||
return GDScriptLanguage::get_singleton();
|
return GDScriptLanguage::get_singleton();
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiplayerAPI::RPCMode GDScriptInstance::get_rpc_mode(const StringName &p_method) const {
|
|
||||||
const GDScript *cscript = script.ptr();
|
|
||||||
|
|
||||||
while (cscript) {
|
|
||||||
const Map<StringName, GDScriptFunction *>::Element *E = cscript->member_functions.find(p_method);
|
|
||||||
if (E) {
|
|
||||||
if (E->get()->get_rpc_mode() != MultiplayerAPI::RPC_MODE_DISABLED) {
|
|
||||||
return E->get()->get_rpc_mode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cscript = cscript->_base;
|
|
||||||
}
|
|
||||||
|
|
||||||
return MultiplayerAPI::RPC_MODE_DISABLED;
|
|
||||||
}
|
|
||||||
|
|
||||||
MultiplayerAPI::RPCMode GDScriptInstance::get_rset_mode(const StringName &p_variable) const {
|
|
||||||
const GDScript *cscript = script.ptr();
|
|
||||||
|
|
||||||
while (cscript) {
|
|
||||||
const Map<StringName, GDScript::MemberInfo>::Element *E = cscript->member_indices.find(p_variable);
|
|
||||||
if (E) {
|
|
||||||
if (E->get().rpc_mode) {
|
|
||||||
return E->get().rpc_mode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cscript = cscript->_base;
|
|
||||||
}
|
|
||||||
|
|
||||||
return MultiplayerAPI::RPC_MODE_DISABLED;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GDScriptInstance::reload_members() {
|
void GDScriptInstance::reload_members() {
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
|
|
||||||
@ -1784,14 +1752,6 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const {
|
|||||||
"return",
|
"return",
|
||||||
"match",
|
"match",
|
||||||
"while",
|
"while",
|
||||||
"remote",
|
|
||||||
"sync",
|
|
||||||
"master",
|
|
||||||
"puppet",
|
|
||||||
"slave",
|
|
||||||
"remotesync",
|
|
||||||
"mastersync",
|
|
||||||
"puppetsync",
|
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -60,7 +60,6 @@ class GDScript : public Script {
|
|||||||
int index;
|
int index;
|
||||||
StringName setter;
|
StringName setter;
|
||||||
StringName getter;
|
StringName getter;
|
||||||
MultiplayerAPI::RPCMode rpc_mode;
|
|
||||||
GDScriptDataType data_type;
|
GDScriptDataType data_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -266,9 +265,6 @@ public:
|
|||||||
|
|
||||||
void reload_members();
|
void reload_members();
|
||||||
|
|
||||||
virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
|
|
||||||
virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
|
|
||||||
|
|
||||||
GDScriptInstance();
|
GDScriptInstance();
|
||||||
~GDScriptInstance();
|
~GDScriptInstance();
|
||||||
};
|
};
|
||||||
|
@ -1726,7 +1726,6 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser
|
|||||||
|
|
||||||
if (p_func) {
|
if (p_func) {
|
||||||
gdfunc->_static = p_func->_static;
|
gdfunc->_static = p_func->_static;
|
||||||
gdfunc->rpc_mode = p_func->rpc_mode;
|
|
||||||
gdfunc->argument_types.resize(p_func->argument_types.size());
|
gdfunc->argument_types.resize(p_func->argument_types.size());
|
||||||
for (int i = 0; i < p_func->argument_types.size(); i++) {
|
for (int i = 0; i < p_func->argument_types.size(); i++) {
|
||||||
gdfunc->argument_types.write[i] = _gdtype_from_datatype(p_func->argument_types[i], p_script);
|
gdfunc->argument_types.write[i] = _gdtype_from_datatype(p_func->argument_types[i], p_script);
|
||||||
@ -1734,7 +1733,6 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser
|
|||||||
gdfunc->return_type = _gdtype_from_datatype(p_func->return_type, p_script);
|
gdfunc->return_type = _gdtype_from_datatype(p_func->return_type, p_script);
|
||||||
} else {
|
} else {
|
||||||
gdfunc->_static = false;
|
gdfunc->_static = false;
|
||||||
gdfunc->rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED;
|
|
||||||
gdfunc->return_type = GDScriptDataType();
|
gdfunc->return_type = GDScriptDataType();
|
||||||
gdfunc->return_type.has_type = true;
|
gdfunc->return_type.has_type = true;
|
||||||
gdfunc->return_type.kind = GDScriptDataType::BUILTIN;
|
gdfunc->return_type.kind = GDScriptDataType::BUILTIN;
|
||||||
@ -1941,7 +1939,6 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar
|
|||||||
minfo.index = p_script->member_indices.size();
|
minfo.index = p_script->member_indices.size();
|
||||||
minfo.setter = p_class->variables[i].setter;
|
minfo.setter = p_class->variables[i].setter;
|
||||||
minfo.getter = p_class->variables[i].getter;
|
minfo.getter = p_class->variables[i].getter;
|
||||||
minfo.rpc_mode = p_class->variables[i].rpc_mode;
|
|
||||||
minfo.data_type = _gdtype_from_datatype(p_class->variables[i].data_type, p_script);
|
minfo.data_type = _gdtype_from_datatype(p_class->variables[i].data_type, p_script);
|
||||||
|
|
||||||
PropertyInfo prop_info = minfo.data_type;
|
PropertyInfo prop_info = minfo.data_type;
|
||||||
|
@ -2199,9 +2199,7 @@ static void _find_identifiers(const GDScriptCompletionContext &p_context, bool p
|
|||||||
"and", "in", "not", "or", "false", "PI", "TAU", "INF", "NAN", "self", "true", "as", "assert",
|
"and", "in", "not", "or", "false", "PI", "TAU", "INF", "NAN", "self", "true", "as", "assert",
|
||||||
"breakpoint", "class", "extends", "is", "func", "preload", "setget", "signal", "tool", "yield",
|
"breakpoint", "class", "extends", "is", "func", "preload", "setget", "signal", "tool", "yield",
|
||||||
"const", "enum", "export", "onready", "static", "var", "break", "continue", "if", "elif",
|
"const", "enum", "export", "onready", "static", "var", "break", "continue", "if", "elif",
|
||||||
"else", "for", "pass", "return", "match", "while", "remote", "sync", "master", "puppet", "slave",
|
"else", "for", "pass", "return", "match", "while", nullptr
|
||||||
"remotesync", "mastersync", "puppetsync",
|
|
||||||
nullptr
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const char **kw = _keywords;
|
const char **kw = _keywords;
|
||||||
|
@ -1699,7 +1699,6 @@ GDScriptFunction::GDScriptFunction() :
|
|||||||
function_list(this) {
|
function_list(this) {
|
||||||
_stack_size = 0;
|
_stack_size = 0;
|
||||||
_call_size = 0;
|
_call_size = 0;
|
||||||
rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED;
|
|
||||||
name = "<anonymous>";
|
name = "<anonymous>";
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
_func_cname = nullptr;
|
_func_cname = nullptr;
|
||||||
|
@ -246,7 +246,6 @@ private:
|
|||||||
int _call_size;
|
int _call_size;
|
||||||
int _initial_line;
|
int _initial_line;
|
||||||
bool _static;
|
bool _static;
|
||||||
MultiplayerAPI::RPCMode rpc_mode;
|
|
||||||
|
|
||||||
GDScript *_script;
|
GDScript *_script;
|
||||||
|
|
||||||
@ -345,7 +344,6 @@ public:
|
|||||||
|
|
||||||
Variant call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state = nullptr);
|
Variant call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state = nullptr);
|
||||||
|
|
||||||
_FORCE_INLINE_ MultiplayerAPI::RPCMode get_rpc_mode() const { return rpc_mode; }
|
|
||||||
GDScriptFunction();
|
GDScriptFunction();
|
||||||
~GDScriptFunction();
|
~GDScriptFunction();
|
||||||
};
|
};
|
||||||
|
@ -4035,8 +4035,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
|
|||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
function->arguments_usage = arguments_usage;
|
function->arguments_usage = arguments_usage;
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
function->rpc_mode = rpc_mode;
|
|
||||||
rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED;
|
|
||||||
|
|
||||||
if (name == "_init") {
|
if (name == "_init") {
|
||||||
if (_static) {
|
if (_static) {
|
||||||
@ -4730,9 +4728,9 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
|
|||||||
#undef _ADVANCE_AND_CONSUME_NEWLINES
|
#undef _ADVANCE_AND_CONSUME_NEWLINES
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_ONREADY && tokenizer->get_token() != GDScriptTokenizer::TK_PR_REMOTE && tokenizer->get_token() != GDScriptTokenizer::TK_PR_MASTER && tokenizer->get_token() != GDScriptTokenizer::TK_PR_PUPPET && tokenizer->get_token() != GDScriptTokenizer::TK_PR_SYNC && tokenizer->get_token() != GDScriptTokenizer::TK_PR_REMOTESYNC && tokenizer->get_token() != GDScriptTokenizer::TK_PR_MASTERSYNC && tokenizer->get_token() != GDScriptTokenizer::TK_PR_PUPPETSYNC && tokenizer->get_token() != GDScriptTokenizer::TK_PR_SLAVE) {
|
if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_ONREADY) {
|
||||||
current_export = PropertyInfo();
|
current_export = PropertyInfo();
|
||||||
_set_error("Expected \"var\", \"onready\", \"remote\", \"master\", \"puppet\", \"sync\", \"remotesync\", \"mastersync\", \"puppetsync\".");
|
_set_error("Expected \"var\", \"onready\".");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4748,114 +4746,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
|
|||||||
|
|
||||||
continue;
|
continue;
|
||||||
} break;
|
} break;
|
||||||
case GDScriptTokenizer::TK_PR_REMOTE: {
|
|
||||||
//may be fallthrough from export, ignore if so
|
|
||||||
tokenizer->advance();
|
|
||||||
if (current_export.type) {
|
|
||||||
if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR) {
|
|
||||||
_set_error("Expected \"var\".");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) {
|
|
||||||
_set_error("Expected \"var\" or \"func\".");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rpc_mode = MultiplayerAPI::RPC_MODE_REMOTE;
|
|
||||||
|
|
||||||
continue;
|
|
||||||
} break;
|
|
||||||
case GDScriptTokenizer::TK_PR_MASTER: {
|
|
||||||
//may be fallthrough from export, ignore if so
|
|
||||||
tokenizer->advance();
|
|
||||||
if (current_export.type) {
|
|
||||||
if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR) {
|
|
||||||
_set_error("Expected \"var\".");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) {
|
|
||||||
_set_error("Expected \"var\" or \"func\".");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rpc_mode = MultiplayerAPI::RPC_MODE_MASTER;
|
|
||||||
continue;
|
|
||||||
} break;
|
|
||||||
case GDScriptTokenizer::TK_PR_SLAVE:
|
|
||||||
#ifdef DEBUG_ENABLED
|
|
||||||
_add_warning(GDScriptWarning::DEPRECATED_KEYWORD, tokenizer->get_token_line(), "slave", "puppet");
|
|
||||||
#endif
|
|
||||||
FALLTHROUGH;
|
|
||||||
case GDScriptTokenizer::TK_PR_PUPPET: {
|
|
||||||
//may be fallthrough from export, ignore if so
|
|
||||||
tokenizer->advance();
|
|
||||||
if (current_export.type) {
|
|
||||||
if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR) {
|
|
||||||
_set_error("Expected \"var\".");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) {
|
|
||||||
_set_error("Expected \"var\" or \"func\".");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rpc_mode = MultiplayerAPI::RPC_MODE_PUPPET;
|
|
||||||
continue;
|
|
||||||
} break;
|
|
||||||
case GDScriptTokenizer::TK_PR_REMOTESYNC:
|
|
||||||
case GDScriptTokenizer::TK_PR_SYNC: {
|
|
||||||
//may be fallthrough from export, ignore if so
|
|
||||||
tokenizer->advance();
|
|
||||||
if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) {
|
|
||||||
if (current_export.type) {
|
|
||||||
_set_error("Expected \"var\".");
|
|
||||||
} else {
|
|
||||||
_set_error("Expected \"var\" or \"func\".");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rpc_mode = MultiplayerAPI::RPC_MODE_REMOTESYNC;
|
|
||||||
continue;
|
|
||||||
} break;
|
|
||||||
case GDScriptTokenizer::TK_PR_MASTERSYNC: {
|
|
||||||
//may be fallthrough from export, ignore if so
|
|
||||||
tokenizer->advance();
|
|
||||||
if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) {
|
|
||||||
if (current_export.type) {
|
|
||||||
_set_error("Expected \"var\".");
|
|
||||||
} else {
|
|
||||||
_set_error("Expected \"var\" or \"func\".");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rpc_mode = MultiplayerAPI::RPC_MODE_MASTERSYNC;
|
|
||||||
continue;
|
|
||||||
} break;
|
|
||||||
case GDScriptTokenizer::TK_PR_PUPPETSYNC: {
|
|
||||||
//may be fallthrough from export, ignore if so
|
|
||||||
tokenizer->advance();
|
|
||||||
if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) {
|
|
||||||
if (current_export.type) {
|
|
||||||
_set_error("Expected \"var\".");
|
|
||||||
} else {
|
|
||||||
_set_error("Expected \"var\" or \"func\".");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rpc_mode = MultiplayerAPI::RPC_MODE_PUPPETSYNC;
|
|
||||||
continue;
|
|
||||||
} break;
|
|
||||||
case GDScriptTokenizer::TK_PR_VAR: {
|
case GDScriptTokenizer::TK_PR_VAR: {
|
||||||
// variable declaration and (eventual) initialization
|
// variable declaration and (eventual) initialization
|
||||||
|
|
||||||
@ -4880,7 +4770,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
|
|||||||
member._export.name = member.identifier;
|
member._export.name = member.identifier;
|
||||||
member.line = tokenizer->get_token_line();
|
member.line = tokenizer->get_token_line();
|
||||||
member.usages = 0;
|
member.usages = 0;
|
||||||
member.rpc_mode = rpc_mode;
|
|
||||||
|
|
||||||
if (current_class->constant_expressions.has(member.identifier)) {
|
if (current_class->constant_expressions.has(member.identifier)) {
|
||||||
_set_error("A constant named \"" + String(member.identifier) + "\" already exists in this class (at line: " +
|
_set_error("A constant named \"" + String(member.identifier) + "\" already exists in this class (at line: " +
|
||||||
@ -4918,8 +4807,6 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
|
|||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
tokenizer->advance();
|
tokenizer->advance();
|
||||||
|
|
||||||
rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED;
|
|
||||||
|
|
||||||
if (tokenizer->get_token() == GDScriptTokenizer::TK_COLON) {
|
if (tokenizer->get_token() == GDScriptTokenizer::TK_COLON) {
|
||||||
if (tokenizer->get_token(1) == GDScriptTokenizer::TK_OP_ASSIGN) {
|
if (tokenizer->get_token(1) == GDScriptTokenizer::TK_OP_ASSIGN) {
|
||||||
member.data_type = DataType();
|
member.data_type = DataType();
|
||||||
@ -8894,7 +8781,6 @@ void GDScriptParser::clear() {
|
|||||||
current_class = nullptr;
|
current_class = nullptr;
|
||||||
|
|
||||||
completion_found = false;
|
completion_found = false;
|
||||||
rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED;
|
|
||||||
|
|
||||||
current_function = nullptr;
|
current_function = nullptr;
|
||||||
|
|
||||||
|
@ -164,7 +164,6 @@ public:
|
|||||||
int line;
|
int line;
|
||||||
Node *expression;
|
Node *expression;
|
||||||
OperatorNode *initial_assignment;
|
OperatorNode *initial_assignment;
|
||||||
MultiplayerAPI::RPCMode rpc_mode;
|
|
||||||
int usages;
|
int usages;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -204,7 +203,6 @@ public:
|
|||||||
|
|
||||||
struct FunctionNode : public Node {
|
struct FunctionNode : public Node {
|
||||||
bool _static;
|
bool _static;
|
||||||
MultiplayerAPI::RPCMode rpc_mode;
|
|
||||||
bool has_yield;
|
bool has_yield;
|
||||||
bool has_unreachable_code;
|
bool has_unreachable_code;
|
||||||
StringName name;
|
StringName name;
|
||||||
@ -224,7 +222,6 @@ public:
|
|||||||
FunctionNode() {
|
FunctionNode() {
|
||||||
type = TYPE_FUNCTION;
|
type = TYPE_FUNCTION;
|
||||||
_static = false;
|
_static = false;
|
||||||
rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED;
|
|
||||||
has_yield = false;
|
has_yield = false;
|
||||||
has_unreachable_code = false;
|
has_unreachable_code = false;
|
||||||
}
|
}
|
||||||
@ -587,8 +584,6 @@ private:
|
|||||||
|
|
||||||
PropertyInfo current_export;
|
PropertyInfo current_export;
|
||||||
|
|
||||||
MultiplayerAPI::RPCMode rpc_mode;
|
|
||||||
|
|
||||||
void _set_error(const String &p_error, int p_line = -1, int p_column = -1);
|
void _set_error(const String &p_error, int p_line = -1, int p_column = -1);
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
void _add_warning(int p_code, int p_line = -1, const String &p_symbol1 = String(), const String &p_symbol2 = String(), const String &p_symbol3 = String(), const String &p_symbol4 = String());
|
void _add_warning(int p_code, int p_line = -1, const String &p_symbol1 = String(), const String &p_symbol2 = String(), const String &p_symbol3 = String(), const String &p_symbol4 = String());
|
||||||
|
@ -106,14 +106,6 @@ const char *GDScriptTokenizer::token_names[TK_MAX] = {
|
|||||||
"yield",
|
"yield",
|
||||||
"signal",
|
"signal",
|
||||||
"breakpoint",
|
"breakpoint",
|
||||||
"rpc",
|
|
||||||
"sync",
|
|
||||||
"master",
|
|
||||||
"puppet",
|
|
||||||
"slave",
|
|
||||||
"remotesync",
|
|
||||||
"mastersync",
|
|
||||||
"puppetsync",
|
|
||||||
"'['",
|
"'['",
|
||||||
"']'",
|
"']'",
|
||||||
"'{'",
|
"'{'",
|
||||||
@ -216,14 +208,6 @@ static const _kws _keyword_list[] = {
|
|||||||
{ GDScriptTokenizer::TK_PR_YIELD, "yield" },
|
{ GDScriptTokenizer::TK_PR_YIELD, "yield" },
|
||||||
{ GDScriptTokenizer::TK_PR_SIGNAL, "signal" },
|
{ GDScriptTokenizer::TK_PR_SIGNAL, "signal" },
|
||||||
{ GDScriptTokenizer::TK_PR_BREAKPOINT, "breakpoint" },
|
{ GDScriptTokenizer::TK_PR_BREAKPOINT, "breakpoint" },
|
||||||
{ GDScriptTokenizer::TK_PR_REMOTE, "remote" },
|
|
||||||
{ GDScriptTokenizer::TK_PR_MASTER, "master" },
|
|
||||||
{ GDScriptTokenizer::TK_PR_SLAVE, "slave" },
|
|
||||||
{ GDScriptTokenizer::TK_PR_PUPPET, "puppet" },
|
|
||||||
{ GDScriptTokenizer::TK_PR_SYNC, "sync" },
|
|
||||||
{ GDScriptTokenizer::TK_PR_REMOTESYNC, "remotesync" },
|
|
||||||
{ GDScriptTokenizer::TK_PR_MASTERSYNC, "mastersync" },
|
|
||||||
{ GDScriptTokenizer::TK_PR_PUPPETSYNC, "puppetsync" },
|
|
||||||
{ GDScriptTokenizer::TK_PR_CONST, "const" },
|
{ GDScriptTokenizer::TK_PR_CONST, "const" },
|
||||||
{ GDScriptTokenizer::TK_PR_ENUM, "enum" },
|
{ GDScriptTokenizer::TK_PR_ENUM, "enum" },
|
||||||
//controlflow
|
//controlflow
|
||||||
@ -262,13 +246,6 @@ bool GDScriptTokenizer::is_token_literal(int p_offset, bool variable_safe) const
|
|||||||
case TK_PR_EXPORT:
|
case TK_PR_EXPORT:
|
||||||
case TK_PR_SETGET:
|
case TK_PR_SETGET:
|
||||||
case TK_PR_SIGNAL:
|
case TK_PR_SIGNAL:
|
||||||
case TK_PR_REMOTE:
|
|
||||||
case TK_PR_MASTER:
|
|
||||||
case TK_PR_PUPPET:
|
|
||||||
case TK_PR_SYNC:
|
|
||||||
case TK_PR_REMOTESYNC:
|
|
||||||
case TK_PR_MASTERSYNC:
|
|
||||||
case TK_PR_PUPPETSYNC:
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Literal for non-variables only:
|
// Literal for non-variables only:
|
||||||
|
@ -111,14 +111,6 @@ public:
|
|||||||
TK_PR_YIELD,
|
TK_PR_YIELD,
|
||||||
TK_PR_SIGNAL,
|
TK_PR_SIGNAL,
|
||||||
TK_PR_BREAKPOINT,
|
TK_PR_BREAKPOINT,
|
||||||
TK_PR_REMOTE,
|
|
||||||
TK_PR_SYNC,
|
|
||||||
TK_PR_MASTER,
|
|
||||||
TK_PR_SLAVE, // Deprecated by TK_PR_PUPPET, to remove in 4.0
|
|
||||||
TK_PR_PUPPET,
|
|
||||||
TK_PR_REMOTESYNC,
|
|
||||||
TK_PR_MASTERSYNC,
|
|
||||||
TK_PR_PUPPETSYNC,
|
|
||||||
TK_BRACKET_OPEN,
|
TK_BRACKET_OPEN,
|
||||||
TK_BRACKET_CLOSE,
|
TK_BRACKET_CLOSE,
|
||||||
TK_CURLY_BRACKET_OPEN,
|
TK_CURLY_BRACKET_OPEN,
|
||||||
|
Loading…
Reference in New Issue
Block a user