diff --git a/scripts/__scr_spacket_exceptions/__scr_spacket_exceptions.gml b/scripts/__scr_spacket_exceptions/__scr_spacket_exceptions.gml index 20acf32..14af14c 100644 --- a/scripts/__scr_spacket_exceptions/__scr_spacket_exceptions.gml +++ b/scripts/__scr_spacket_exceptions/__scr_spacket_exceptions.gml @@ -16,7 +16,7 @@ function __spacket_class_exception_invalid_packet_data(_valueName, _bufferType) function __spacket_class_exception_mismatched_packet_version(_packetId, _otherPacketVersion) : __spacket_class_exception("Mismatched packet version") constructor { - longMessage = __spacket_string_build("Packet #", _packetId, " has mismatched SPACKET_PACKET_VERSION (we are ", __SPACKET_PACKET_VERSION, ", they are ", _otherPacketVersion, ")"); + longMessage = __spacket_string_build("Packet #", _packetId, " has mismatched SPACKET_PACKET_VERSION (we are ", SPACKET_PACKET_VERSION, ", they are ", _otherPacketVersion, ")"); } function __spacket_class_exception_packet_serialization_failed(_errorMessage) diff --git a/scripts/__scr_spacket_macros/__scr_spacket_macros.gml b/scripts/__scr_spacket_macros/__scr_spacket_macros.gml index 19ffdcb..cff5af8 100644 --- a/scripts/__scr_spacket_macros/__scr_spacket_macros.gml +++ b/scripts/__scr_spacket_macros/__scr_spacket_macros.gml @@ -4,8 +4,6 @@ #macro __SPACKET_HEADER_SIZE (string_length(__SPACKET_PACKET_SIGNATURE) + buffer_sizeof(SPACKET_PACKET_VERSION_BUFFER_TYPE) + buffer_sizeof(SPACKET_PACKET_ID_BUFFER_TYPE) + buffer_sizeof(buffer_bool)) // signature + packet version + packet id + is compressed -#macro __SPACKET_PACKET_VERSION string(SPACKET_PACKET_VERSION) - enum __SPACKET_ON_WRONG_PACKET_VERSION { ERROR, // throws an error diff --git a/scripts/__scr_spacket_util/__scr_spacket_util.gml b/scripts/__scr_spacket_util/__scr_spacket_util.gml index 9c374dc..2e89454 100644 --- a/scripts/__scr_spacket_util/__scr_spacket_util.gml +++ b/scripts/__scr_spacket_util/__scr_spacket_util.gml @@ -16,29 +16,4 @@ function __spacket_string_build() _string += string(argument[_i++]); return _string; -} - -function __spacket_ds_list_to_array(_list, _destroyList = true) -{ - var _listSize = ds_list_size(_list); - var _array = array_create(_listSize); - var i = 0; - repeat (_listSize) - { - _array[i] = _list[| i]; - i++; - } - - if (_destroyList) - ds_list_destroy(_list); - - return _array; -} - -function __spacket_string_to_buffer(_string) -{ - var _buffer = buffer_create(string_byte_length(_string), buffer_fixed, 1); - buffer_write(_buffer, buffer_text, _string); - - return _buffer; } \ No newline at end of file diff --git a/scripts/scr_spacket/scr_spacket.gml b/scripts/scr_spacket/scr_spacket.gml index efb0d01..2b13633 100644 --- a/scripts/scr_spacket/scr_spacket.gml +++ b/scripts/scr_spacket/scr_spacket.gml @@ -1,4 +1,4 @@ -///@param {?number} packetId +///@param {number} [packetId] function Packet(_packetId = undefined) constructor { ///@desc Gets the packet version, which is used to tell different game versions from eachother @@ -94,7 +94,7 @@ function Packet(_packetId = undefined) constructor catch (_) throw new __spacket_class_exception_invalid_packet_data("packetId", SPACKET_PACKET_ID_BUFFER_TYPE); - if (_packetVersion != __SPACKET_PACKET_VERSION) + if (_packetVersion != SPACKET_PACKET_VERSION) { switch (SPACKET_ON_WRONG_PACKET_VERSION) { @@ -286,7 +286,7 @@ function Packet(_packetId = undefined) constructor #endregion - __packetVersion = __SPACKET_PACKET_VERSION; + __packetVersion = SPACKET_PACKET_VERSION; __packetId = undefined; __definition = undefined; __values = { }; diff --git a/scripts/scr_spacket_info/scr_spacket_info.gml b/scripts/scr_spacket_info/scr_spacket_info.gml index cf69561..f3056a8 100644 --- a/scripts/scr_spacket_info/scr_spacket_info.gml +++ b/scripts/scr_spacket_info/scr_spacket_info.gml @@ -1,5 +1,5 @@ ///@desc Creates a new definition for a packet -///@param {real} packetId +///@param {number} packetId ///@returns {PacketDefinition} function spacket_define(_packetId) { @@ -11,7 +11,7 @@ function spacket_define(_packetId) } ///@desc Gets an existing packet definition -///@param {real} packetId +///@param {number} packetId ///@returns {PacketDefinition} function spacket_get_definition(_packetId) { diff --git a/scripts/scr_spacket_packet_definition/scr_spacket_packet_definition.gml b/scripts/scr_spacket_packet_definition/scr_spacket_packet_definition.gml index b6f2539..f7c67df 100644 --- a/scripts/scr_spacket_packet_definition/scr_spacket_packet_definition.gml +++ b/scripts/scr_spacket_packet_definition/scr_spacket_packet_definition.gml @@ -8,9 +8,9 @@ function PacketDefinition() constructor ///@desc Adds a value to the packet definition ///@param {string} valueName The name of the value - ///@param {number} bufferType The buffer type (buffer_X) of the value - ///@param {?bool} isArray Whether or not the value is an array of bufferType - ///@param {?number} arraySize The buffer type (buffer_X) to use for the array's size (defaults to SPACKET_ARRAY_SIZE_BUFFER_TYPE_DEFAULT) + ///@param {buffer_type} bufferType The buffer type (buffer_X) of the value + ///@param {bool} [isArray] Whether or not the value is an array of bufferType + ///@param {buffer_type} [arraySizeBufferType] The buffer type (buffer_X) to use for the array's size (defaults to SPACKET_ARRAY_SIZE_BUFFER_TYPE_DEFAULT) static set = function(_valueName, _bufferType, _isArray = false, _arraySize = SPACKET_ARRAY_SIZE_BUFFER_TYPE_DEFAULT) { var _totalValues = array_length(__values);