1. cubeia
  2. Cubeia Styx
  3. Issues
Issue #4 resolved

Styx java protocol packets does not support null in enum fields

Lars J. Nilsson
created an issue

Styx generated protocol code like:

{{{

!java

ps.saveUnsignedByte(errorCode.ordinal()); }}}

This won't work if errorCode is null.

Comments (2)

  1. Lars J. Nilsson reporter

    Problem was previously that there currently is no safe way to load variables to check them. This bug is now solved with the addition of a "peek" on the incoming packet stream. Load now looks like this:

    if (ps.peek() == -1) {
      this.type = null;
    } else {
      this.type = Enums.makeEnumType(ps.loadUnsignedByte());
    }
    

    And save like this:

    if (this.type == null) {
      ps.saveUnsignedByte(-1);
    } else {
      ps.saveUnsignedByte(this.type.ordinal());
    }
    
  2. Log in to comment