New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to FileIO and Network packages #49

Merged
merged 3 commits into from Mar 4, 2018

Conversation

Projects
None yet
3 participants
@SamuelMoriarty
Copy link
Contributor

SamuelMoriarty commented Feb 9, 2018

Changelog:

  • Added ability to suppress error messages with the global suppressErrorMessages variable. This is used in the Execute package, in function try to facilitate a very basic form of exception-handling. Rationale: Persistable relies on the deserialize function to throw an error when a deserialization fails (tampered data, missing file, etc.), but since this is acceptable behaviour, and the error is properly handled upstream with try, there is no need for the player to see the inevitable error message. This shouldn't affect regular errors.
  • Renamed MultiIO to MultifileIO, renamed SimpleIO to PreloadIO. Rationale: PreloadIO is meant to be a simple wrapper around the Preload API, and does no checks for Local Files. The reasoning is that there may be use cases where you want to use the Preload API without having to pull in the LocalFiles dependency, together with Network, which is a very heavy package, such as for simple logging or saving of other data, without reading it back.
  • Added LocalFiles package providing functionality to detect 1.26 version and whether Local Files are enabled, and automatically syncs those results.
  • Added Local Files checks to MultifileIO and Persistable during loading. Now all load callbacks return a mandatory status enum reflecting the status of the operation. Saving, however, works without Local Files anyway, so I don't enforce that check.
  • Added 1.26 fallback support to MultifileIO, moving it outside of PreloadIO.
  • Added disconnection detection to Network. Now the callback returns a status enum depending on whether or not the operation succeeded or not.
  • Updated Network/SyncSimple global hot-docs to apply to the package, instead of enums inside them.
  • Fixed various typos in docs and updated them to reflect latest changes.
  • Added int/string to bool conversions.
This can also happen if the file is empty or doesn't exist.
FAIL_NO_PLAYER - The player has left either during data transfer, or before.
**/
enum LoadStatus

This comment has been minimized.

@Kithio

Kithio Feb 14, 2018

Contributor

Not made public?

FAIL_NOT_ENABLED - Local files have not been enabled for this user.
FAIL_NO_PLAYER - The player is not present.
**/
enum SaveStatus

This comment has been minimized.

@Kithio

Kithio Feb 14, 2018

Contributor

Not made public?


/** Converts this int into a boolean */
public function int.toBool() returns boolean

This comment has been minimized.

@Frotty

Frotty Feb 14, 2018

Member

Overlapping with toIndex functions inside Typecasting

**/
public function try(ForForceCallback c) returns boolean
pushCallback(c)
let suppressErrors = suppressErrorMessages

This comment has been minimized.

@Frotty

Frotty Feb 14, 2018

Member

What's the point of this? I don't see any way the system or the user are changing this variable, or?

This comment has been minimized.

@SamuelMoriarty

SamuelMoriarty Feb 14, 2018

Contributor

This is to preserve previous suppress status on the local stack, so that nested try calls properly preserve the suppress status.

E.g. when calling try() once, this value is initially false, and suppressErrors is false, too, so it will get restored to that value.
On the other hand, when calling try() in another try(), then in the inner call the value will be true, so we need to restore it to true afterwards.

end)

init
doAfter(0, () -> LocalFiles.checkAll())

This comment has been minimized.

@Frotty

Frotty Feb 14, 2018

Member

nullTimer()

@@ -14,7 +15,24 @@ class FilePacket
function getChunkPath(string path, int id) returns string
return path + "/chunk" + id.toString() + ".txt"

public interface FileCallback
function getBasePath() returns string
var path = ""

This comment has been minimized.

@Frotty

Frotty Feb 14, 2018

Member

could be ternary

@Frotty

This comment has been minimized.

Copy link
Member

Frotty commented Mar 4, 2018

Sweet, thanks again for the nice work @SamuelMoriarty 🍭

@Frotty Frotty merged commit a3a7666 into wurstscript:master Mar 4, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment