1
0
mirror of https://github.com/JohnBreaux/Boat-Battle.git synced 2025-02-04 12:28:35 +00:00

All: General code cleanup

This commit is contained in:
2021-11-28 02:26:00 -06:00
parent 8239c133fc
commit ff45799305
6 changed files with 26 additions and 36 deletions

View File

@@ -17,7 +17,7 @@ func _on_peers_updated():
pass
func set_IP_Address_text(show):
# Print the IP address and port
# Show the IP address (or nothing)
if show:
# ip_address.text = "IP: %sPort:%s" % [Net.get_ip(), Net.DEFAULT_PORT]
ip_address.text = "IP: %s" % Net.get_ip()

View File

@@ -38,12 +38,13 @@ var local_info = {"name": ""}
# mail: The message received from the sender (implicitly JSON-decoded by JSONRPC)
# mail_type: Type of mail (see "Mail Types" enum above)
remote func receive(mail):
print_debug("recv: %s" % mail)
# Unpack the mail
# Uses json parser of unknown stability, how fun
mail = parse_json(mail)
# Get the sender's ID and force letter to be properly addressed
mail[0] = get_tree().get_rpc_sender_id()
# print_debug it, for posterity
print_debug("recv: ", mail)
# Add the mail to the inbox (so it can be read back later if necessary
inbox.append(mail)
# Sent it off to anything that expects mail
@@ -54,7 +55,7 @@ remote func receive(mail):
# mail: Variant of a json-encodable type (non-Object) to send
# mail_type: Type of mail (see "Mail Types" enum above)
func send(id, mail, mail_type = REPLY):
print_debug("send: %d, %s, %d" % [id, mail, mail_type])
print_debug("send: [%d, %s, %d]" % [id, mail, mail_type])
# Make the recipient receive the mail
rpc_id(id, "receive", to_json([-1, mail, mail_type]))