Skip to content

Commit

Permalink
Merge pull request #6 from stoozey/dev
Browse files Browse the repository at this point in the history
removed old __SPACKET_PACKET_VERSION; updated jsdoc; removed unused u…
  • Loading branch information
stoozey authored Aug 8, 2023
2 parents 8fd7996 + 2998046 commit edacc6c
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions scripts/__scr_spacket_macros/__scr_spacket_macros.gml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 0 additions & 25 deletions scripts/__scr_spacket_util/__scr_spacket_util.gml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
6 changes: 3 additions & 3 deletions scripts/scr_spacket/scr_spacket.gml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -286,7 +286,7 @@ function Packet(_packetId = undefined) constructor

#endregion

__packetVersion = __SPACKET_PACKET_VERSION;
__packetVersion = SPACKET_PACKET_VERSION;
__packetId = undefined;
__definition = undefined;
__values = { };
Expand Down
4 changes: 2 additions & 2 deletions scripts/scr_spacket_info/scr_spacket_info.gml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///@desc Creates a new definition for a packet
///@param {real} packetId
///@param {number} packetId
///@returns {PacketDefinition}
function spacket_define(_packetId)
{
Expand All @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit edacc6c

Please sign in to comment.