Logistics Pipes

Logistics Pipes

13M Downloads

Computer conversion code returns the same value

SquidDev opened this issue · 3 comments

commented

Consider the following OpenComputers code, working with an LP request pipe:

local a_pipe = -- Wrap a "logisticspipe" component
local pipe = a_pipe.getPipe() -- Will be a LogisticsPipes:Request

for k, v in pairs(pipe.getAvailableItems()) do
  print(v) -- Will also be a LogisticsPipes:request!
end

Any subsequent call to a an LP method will return the same object. This was introduced in a098feb, which refactored some type conversion code into an interface:

public interface ILPCCTypeHolder {
  Object[] ccType = new Object[1];

  default void setCCType(Object type) {
    ccType[0] = type;
  }
  // etc...
}

This is invalid, as interfaces do not have instance fields. Instead, the ccType field is public static, and so shared across all values. Thus once one value has been converted, getCCType will return the same one for all of them!


I'm afraid I'm reporting this on behalf of another user, so haven't got version numbers/logs. Happy to reproduce and provide them if that'd be helpful.

commented

Fantastic, thank you very much for the speedy fix!

commented

Thank you for the detailed report as well as CC: Tweaked :)

commented

You are completely right, I missed the fact that interfaces can only define statics and thus this didn't work. Will push a fix in a second.