Repository: godotengine/godot
File: core/io/multiplayer_api.h (C/C++)

Code before:
/*                                                                       */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
/*************************************************************************/

#ifndef MULTIPLAYER_API_H
#define MULTIPLAYER_API_H

#include "core/io/multiplayer_peer.h"
#include "core/io/resource_uid.h"
#include "core/object/ref_counted.h"

class MultiplayerReplicator;

class MultiplayerAPI : public RefCounted {
	GDCLASS(MultiplayerAPI, RefCounted);

public:
	enum RPCMode {
		RPC_MODE_DISABLED, // No rpc for this method, calls to this will be blocked (default)
		RPC_MODE_REMOTE, // Using rpc() on it will call method in all remote peers
		RPC_MODE_MASTER, // Using rpc() on it will call method on wherever the master is, be it local or remote
		RPC_MODE_PUPPET, // Using rpc() on it will call method for all puppets
	};

	struct RPCConfig {
		StringName name;
		RPCMode rpc_mode = RPC_MODE_DISABLED;
		bool sync = false;
		MultiplayerPeer::TransferMode transfer_mode = MultiplayerPeer::TRANSFER_MODE_RELIABLE;
		int channel = 0;

		bool operator==(RPCConfig const &p_other) const {
			return name == p_other.name;
		}
	};

	struct SortRPCConfig {
		StringName::AlphCompare compare;
		bool operator()(const RPCConfig &p_a, const RPCConfig &p_b) const {
			return compare(p_a.name, p_b.name);
		}
	};

	enum NetworkCommands {
		NETWORK_COMMAND_REMOTE_CALL = 0,

Review comment (suggestion):
Should this be renamed `RPC_MODE_ANY` to match the annotation?
It also seems tautological for a "Remote Procedure Call Mode" to be "Remote" :)

Code after:
/*                                                                       */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
/*************************************************************************/

#ifndef MULTIPLAYER_API_H
#define MULTIPLAYER_API_H

#include "core/io/multiplayer_peer.h"
#include "core/io/resource_uid.h"
#include "core/object/ref_counted.h"

class MultiplayerReplicator;

class MultiplayerAPI : public RefCounted {
	GDCLASS(MultiplayerAPI, RefCounted);

public:
	enum RPCMode {
		RPC_MODE_DISABLED, // No rpc for this method, calls to this will be blocked (default)
		RPC_MODE_ANY, // Any peer can call this rpc()
		RPC_MODE_AUTHORITY, // Only the node's network authority (server by default) can call this rpc()
	};

	struct RPCConfig {
		StringName name;
		RPCMode rpc_mode = RPC_MODE_DISABLED;
		bool sync = false;
		MultiplayerPeer::TransferMode transfer_mode = MultiplayerPeer::TRANSFER_MODE_RELIABLE;
		int channel = 0;

		bool operator==(RPCConfig const &p_other) const {
			return name == p_other.name;
		}
	};

	struct SortRPCConfig {
		StringName::AlphCompare compare;
		bool operator()(const RPCConfig &p_a, const RPCConfig &p_b) const {
			return compare(p_a.name, p_b.name);
		}
	};

	enum NetworkCommands {
		NETWORK_COMMAND_REMOTE_CALL = 0,
		NETWORK_COMMAND_SIMPLIFY_PATH,