Skip to content

Commit

Permalink
Fix possible int overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
zeng-github01 committed Mar 19, 2024
1 parent 29870e6 commit 29d1e69
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/main/java/com/zengyj/exposer/handler/FluidHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public FluidHandler(INetwork network){
public IFluidTankProperties[] getTankProperties() {
List<FluidTankProperties> properties = new ArrayList<>();
for (FluidStack fluidStack : storageCacheData) {
properties.add(new FluidTankProperties(fluidStack,getCapacity()));
properties.add(new FluidTankProperties(fluidStack,Integer.MAX_VALUE));
}

return properties.toArray(new IFluidTankProperties[properties.size()]);
Expand Down Expand Up @@ -97,20 +97,20 @@ private void invalidate(){
this.storageCacheData = this.network.getFluidStorageCache().getList().getStacks().toArray(new FluidStack[0]);
}

private int getCapacity(){
int capacity = 0;
if (network == null) return 0;

for (IStorage<FluidStack> storage : this.network.getFluidStorageCache().getStorages()) {
if(storage instanceof IStorageDisk){
capacity += ((IStorageDisk<FluidStack>) storage).getCapacity();
}

if (storage instanceof IStorageExternal){
capacity += ((IStorageExternal<FluidStack>) storage).getCapacity();
}
}

return capacity;
}
// private int getCapacity(){
// int capacity = 0;
// if (network == null) return 0;
//
// for (IStorage<FluidStack> storage : this.network.getFluidStorageCache().getStorages()) {
// if(storage instanceof IStorageDisk){
// capacity += ((IStorageDisk<FluidStack>) storage).getCapacity();
// }
//
// if (storage instanceof IStorageExternal){
// capacity += ((IStorageExternal<FluidStack>) storage).getCapacity();
// }
// }
//
// return capacity;
// }
}

0 comments on commit 29d1e69

Please sign in to comment.