Reduced number of global variables

This commit is contained in:
2024-02-16 20:04:50 +01:00
parent c228d4e25a
commit d081686275
8 changed files with 29 additions and 33 deletions

View File

@ -9,12 +9,12 @@ func handle_packet(data: PackedByteArray):
var error := buffer.get_8()
if error != 0:
print("[%s] Login failed." % Global.username)
print("[%s] Login failed." % Global.account.name)
failure.emit()
return
Global.account_id = buffer.get_string()
Global.auth_token = buffer.get_string()
Global.account.id = buffer.get_string()
Global.account.auth_token = buffer.get_string()
success.emit()
@ -25,9 +25,9 @@ func send_login():
var password := "password".sha256_text()
var buffer := StreamPeerBuffer.new()
buffer.put_u8(Packet.LOGIN)
buffer.put_data(JSON.stringify([Global.username, password]).to_utf8_buffer())
buffer.put_data(JSON.stringify([Global.account.name, password]).to_utf8_buffer())
%Client.send(buffer.data_array)
print("[%s] Connecting..." % Global.username)
print("[%s] Connecting..." % Global.account.name)
func is_logged_in() -> bool:
return Global.auth_token != ""
return Global.account.auth_token != ""