Skip to content

(release_30)compatibilityHack: restore empty string response on no room user data#341

Merged
SlySven merged 1 commit intoMudlet:release_30from
SlySven:(release_30)compatibilityHack_restoreEmptyStringResponseOnNoRoomUserData
Nov 7, 2016
Merged

(release_30)compatibilityHack: restore empty string response on no room user data#341
SlySven merged 1 commit intoMudlet:release_30from
SlySven:(release_30)compatibilityHack_restoreEmptyStringResponseOnNoRoomUserData

Conversation

@SlySven
Copy link
Copy Markdown
Member

@SlySven SlySven commented Oct 26, 2016

When I introduced area and map user data storage I also revised the room user data code - specifically TLuaInterpreter::getRoomUserData(...) to provide informative error messages on various failures, unintentionally though, this introduced an incompatibility with the documented behaviour for this function in that, as of commit-79a8905 it was expected to return an empty string if the given room id (first argument) number did not exist or the data key (second argument) string was not found for that room.

As it happens the past and current code DOES allow an empty string to be stored against a given key but the past code did not allow the user to differentiate it from the case where the room didn't exist (though that could be found out with other code) or the case where the key was not present - no workaround.

This commit adds an optional third argument (bool) enableFullErrorReporting that enables a nil + error message if provided and is true, but which is false otherwise so that previous scripts retain their expected results from using the two-argument usage.

Obviously new scripts should use the third option and set it to be true but they may wish to check for the availability of getAreaUserData() as an indication that they will get a nil response if the room does not exist or does not contain the requested key if they anticipate being used on older version of Mudlet with the non-ideal getRoomUserData() code.

Signed-off-by: Stephen Lyons slysven@virginmedia.com

When I introduce area and map user data storage I also revised the room
user data code - specifically TLuaInterpreter::getRoomUserData(...) to
provide informative error messages on various failures, unintentionally
though, this introduced an incompatibility with the documented behaviour
for this function in that, as of commit-79a8905c it was expected to return
an empty string if the given room id (first argument) number did not exist
or the data key (second argument) string was not found for that room.

As it happens the past and current code DOES allow an empty string to be
stored against a given key but the past code did not allow the user to
differentiate it from the case where the room didn't exist (though that
could be found out with other code) or the case where the key was not
present - no workaround.

This commit adds an optional third argument (bool) enableFullErrorReporting
that enables a nil + error message if provided and is true, but which is
false otherwise so that previous scripts retain their expected results from
using the two-argument usage.

Obviously new scripts should use the third option and set it to be true but
they may wish to check for the availability of getAreaUserData() as an
indication that they will get a nil response if the room does not exist or
does not contain the requested key if they anticipate being used on older
version of Mudlet with the non-ideal getRoomUserData() code.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
@SlySven SlySven merged commit ed0258d into Mudlet:release_30 Nov 7, 2016
@SlySven SlySven deleted the (release_30)compatibilityHack_restoreEmptyStringResponseOnNoRoomUserData branch November 7, 2016 17:17
@SlySven SlySven restored the (release_30)compatibilityHack_restoreEmptyStringResponseOnNoRoomUserData branch June 22, 2020 18:02
@SlySven SlySven deleted the (release_30)compatibilityHack_restoreEmptyStringResponseOnNoRoomUserData branch June 22, 2020 18:24
mehulmathur16 pushed a commit to mehulmathur16/Mudlet that referenced this pull request Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants