Revert "RPCMode refactor, more sync modes"

This commit is contained in:
Max Hilbrunner 2018-05-29 11:47:52 +02:00 committed by GitHub
parent d0b62ce155
commit 4c69a495c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 333 additions and 319 deletions

View file

@ -1220,7 +1220,7 @@ ScriptLanguage *GDScriptInstance::get_language() {
return GDScriptLanguage::get_singleton();
}
MultiplayerAPI::RPCMode GDScriptInstance::get_rpc_mode(const StringName &p_method) const {
GDScriptInstance::RPCMode GDScriptInstance::get_rpc_mode(const StringName &p_method) const {
const GDScript *cscript = script.ptr();
@ -1228,17 +1228,17 @@ MultiplayerAPI::RPCMode GDScriptInstance::get_rpc_mode(const StringName &p_metho
const Map<StringName, GDScriptFunction *>::Element *E = cscript->member_functions.find(p_method);
if (E) {
if (E->get()->get_rpc_mode() != MultiplayerAPI::RPC_MODE_DISABLED) {
if (E->get()->get_rpc_mode() != RPC_MODE_DISABLED) {
return E->get()->get_rpc_mode();
}
}
cscript = cscript->_base;
}
return MultiplayerAPI::RPC_MODE_DISABLED;
return RPC_MODE_DISABLED;
}
MultiplayerAPI::RPCMode GDScriptInstance::get_rset_mode(const StringName &p_variable) const {
GDScriptInstance::RPCMode GDScriptInstance::get_rset_mode(const StringName &p_variable) const {
const GDScript *cscript = script.ptr();
@ -1253,7 +1253,7 @@ MultiplayerAPI::RPCMode GDScriptInstance::get_rset_mode(const StringName &p_vari
cscript = cscript->_base;
}
return MultiplayerAPI::RPC_MODE_DISABLED;
return RPC_MODE_DISABLED;
}
void GDScriptInstance::reload_members() {
@ -1769,9 +1769,6 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const {
"sync",
"master",
"slave",
"remotesync",
"mastersync",
"slavesync",
0
};

View file

@ -63,7 +63,7 @@ class GDScript : public Script {
int index;
StringName setter;
StringName getter;
MultiplayerAPI::RPCMode rpc_mode;
ScriptInstance::RPCMode rpc_mode;
};
friend class GDScriptInstance;
@ -248,8 +248,8 @@ public:
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;
virtual RPCMode get_rpc_mode(const StringName &p_method) const;
virtual RPCMode get_rset_mode(const StringName &p_variable) const;
GDScriptInstance();
~GDScriptInstance();

View file

@ -1455,7 +1455,7 @@ GDScriptFunction::GDScriptFunction() :
_stack_size = 0;
_call_size = 0;
rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED;
rpc_mode = ScriptInstance::RPC_MODE_DISABLED;
name = "<anonymous>";
#ifdef DEBUG_ENABLED
_func_cname = NULL;

View file

@ -96,6 +96,14 @@ public:
ADDR_TYPE_NIL = 9
};
enum RPCMode {
RPC_DISABLED,
RPC_ENABLED,
RPC_SYNC,
RPC_SYNC_MASTER,
RPC_SYNC_SLAVE
};
struct StackDebug {
int line;
@ -127,7 +135,7 @@ private:
int _call_size;
int _initial_line;
bool _static;
MultiplayerAPI::RPCMode rpc_mode;
ScriptInstance::RPCMode rpc_mode;
GDScript *_script;
@ -222,7 +230,7 @@ public:
Variant call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state = NULL);
_FORCE_INLINE_ MultiplayerAPI::RPCMode get_rpc_mode() const { return rpc_mode; }
_FORCE_INLINE_ ScriptInstance::RPCMode get_rpc_mode() const { return rpc_mode; }
GDScriptFunction();
~GDScriptFunction();
};

View file

@ -3373,7 +3373,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
function->line = fnline;
function->rpc_mode = rpc_mode;
rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED;
rpc_mode = ScriptInstance::RPC_MODE_DISABLED;
if (_static)
p_class->static_functions.push_back(function);
@ -3931,10 +3931,10 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
}
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_SLAVE && 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_SLAVESYNC) {
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_SLAVE && tokenizer->get_token() != GDScriptTokenizer::TK_PR_SYNC) {
current_export = PropertyInfo();
_set_error("Expected 'var', 'onready', 'remote', 'master', 'slave', 'sync', 'remotesync', 'mastersync', 'slavesync'.");
_set_error("Expected 'var', 'onready', 'remote', 'master', 'slave' or 'sync'.");
return;
}
@ -3967,7 +3967,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
return;
}
}
rpc_mode = MultiplayerAPI::RPC_MODE_REMOTE;
rpc_mode = ScriptInstance::RPC_MODE_REMOTE;
continue;
} break;
@ -3988,7 +3988,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
}
rpc_mode = MultiplayerAPI::RPC_MODE_MASTER;
rpc_mode = ScriptInstance::RPC_MODE_MASTER;
continue;
} break;
case GDScriptTokenizer::TK_PR_SLAVE: {
@ -4008,10 +4008,9 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
}
}
rpc_mode = MultiplayerAPI::RPC_MODE_SLAVE;
rpc_mode = ScriptInstance::RPC_MODE_SLAVE;
continue;
} break;
case GDScriptTokenizer::TK_PR_REMOTESYNC:
case GDScriptTokenizer::TK_PR_SYNC: {
//may be fallthrough from export, ignore if so
@ -4024,37 +4023,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
return;
}
rpc_mode = MultiplayerAPI::RPC_MODE_SYNC;
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_SLAVESYNC: {
//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_SLAVESYNC;
rpc_mode = ScriptInstance::RPC_MODE_SYNC;
continue;
} break;
case GDScriptTokenizer::TK_PR_VAR: {
@ -4084,7 +4053,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED;
rpc_mode = ScriptInstance::RPC_MODE_DISABLED;
if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) {
@ -4509,7 +4478,7 @@ void GDScriptParser::clear() {
current_class = NULL;
completion_found = false;
rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED;
rpc_mode = ScriptInstance::RPC_MODE_DISABLED;
current_function = NULL;

View file

@ -89,7 +89,7 @@ public:
StringName getter;
int line;
Node *expression;
MultiplayerAPI::RPCMode rpc_mode;
ScriptInstance::RPCMode rpc_mode;
};
struct Constant {
StringName identifier;
@ -125,7 +125,7 @@ public:
struct FunctionNode : public Node {
bool _static;
MultiplayerAPI::RPCMode rpc_mode;
ScriptInstance::RPCMode rpc_mode;
StringName name;
Vector<StringName> arguments;
Vector<Node *> default_values;
@ -134,7 +134,7 @@ public:
FunctionNode() {
type = TYPE_FUNCTION;
_static = false;
rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED;
rpc_mode = ScriptInstance::RPC_MODE_DISABLED;
}
};
@ -493,7 +493,7 @@ private:
PropertyInfo current_export;
MultiplayerAPI::RPCMode rpc_mode;
ScriptInstance::RPCMode rpc_mode;
void _set_error(const String &p_error, int p_line = -1, int p_column = -1);
bool _recover_from_completion();

View file

@ -110,9 +110,6 @@ const char *GDScriptTokenizer::token_names[TK_MAX] = {
"sync",
"master",
"slave",
"remotesync",
"mastersync",
"slavesync",
"'['",
"']'",
"'{'",
@ -204,9 +201,6 @@ static const _kws _keyword_list[] = {
{ GDScriptTokenizer::TK_PR_MASTER, "master" },
{ GDScriptTokenizer::TK_PR_SLAVE, "slave" },
{ GDScriptTokenizer::TK_PR_SYNC, "sync" },
{ GDScriptTokenizer::TK_PR_REMOTESYNC, "remotesync" },
{ GDScriptTokenizer::TK_PR_MASTERSYNC, "mastersync" },
{ GDScriptTokenizer::TK_PR_SLAVESYNC, "slavesync" },
{ GDScriptTokenizer::TK_PR_CONST, "const" },
{ GDScriptTokenizer::TK_PR_ENUM, "enum" },
//controlflow
@ -253,9 +247,6 @@ bool GDScriptTokenizer::is_token_literal(int p_offset, bool variable_safe) const
case TK_PR_MASTER:
case TK_PR_SLAVE:
case TK_PR_SYNC:
case TK_PR_REMOTESYNC:
case TK_PR_MASTERSYNC:
case TK_PR_SLAVESYNC:
return true;
// Literal for non-variables only:

View file

@ -115,9 +115,6 @@ public:
TK_PR_SYNC,
TK_PR_MASTER,
TK_PR_SLAVE,
TK_PR_REMOTESYNC,
TK_PR_MASTERSYNC,
TK_PR_SLAVESYNC,
TK_BRACKET_OPEN,
TK_BRACKET_CLOSE,
TK_CURLY_BRACKET_OPEN,