From b25a995c55d031d41f45686ed2561b87ba14fac2 Mon Sep 17 00:00:00 2001 From: godotg Date: Sun, 6 Apr 2025 16:29:06 +0800 Subject: [PATCH] fix[protocol]: avoid the constant has the same name as a global class defined in gdscript --- .../main/resources/gdscript/ProtocolRegistrationTemplate.gd | 6 +++--- protocol/src/main/resources/gdscript/ProtocolTemplate.gd | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/protocol/src/main/resources/gdscript/ProtocolRegistrationTemplate.gd b/protocol/src/main/resources/gdscript/ProtocolRegistrationTemplate.gd index 1bd31fd7..7fe54194 100644 --- a/protocol/src/main/resources/gdscript/ProtocolRegistrationTemplate.gd +++ b/protocol/src/main/resources/gdscript/ProtocolRegistrationTemplate.gd @@ -1,17 +1,17 @@ class ${protocol_name}Registration: - func write(buffer: ByteBuffer, packet: ${protocol_name}): + func write(buffer: ByteBuffer, packet: _${protocol_name}): if (packet == null): buffer.writeInt(0) return ${protocol_write_serialization} pass - func read(buffer: ByteBuffer) -> ${protocol_name}: + func read(buffer: ByteBuffer) -> _${protocol_name}: var length = buffer.readInt() if (length == 0): return null var beforeReadIndex = buffer.getReadOffset() - var packet: ${protocol_name} = buffer.newInstance(${protocol_id}) + var packet: _${protocol_name} = buffer.newInstance(${protocol_id}) ${protocol_read_deserialization} if (length > 0): buffer.setReadOffset(beforeReadIndex + length) diff --git a/protocol/src/main/resources/gdscript/ProtocolTemplate.gd b/protocol/src/main/resources/gdscript/ProtocolTemplate.gd index 635d3842..43f16bbb 100644 --- a/protocol/src/main/resources/gdscript/ProtocolTemplate.gd +++ b/protocol/src/main/resources/gdscript/ProtocolTemplate.gd @@ -1,4 +1,4 @@ -class_name ${protocol_name} +class_name _${protocol_name} ${protocol_imports}