1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-10-26 09:13:28 +03:00

Fixed boolean setters for Structs (#8041)

This commit is contained in:
Zelaux 2023-01-07 21:44:08 +05:00 committed by GitHub
parent a3a071e520
commit 2c103c157a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -97,14 +97,14 @@ public class StructProcess extends BaseProcessor{
}
//[setter] + [constructor building]
if(varType == TypeName.BOOLEAN){
if(isBool){
cons.append(" | (").append(varName).append(" ? ").append("1L << ").append(offset).append("L : 0)");
//bools: single bit, needs special case to clear things
setter.beginControlFlow("if(value)");
setter.addStatement("return ($T)(($L & ~(1L << $LL)))", structType, structParam, offset);
setter.nextControlFlow("else");
setter.addStatement("return ($T)(($L & ~(1L << $LL)) | (1L << $LL))", structType, structParam, offset, offset);
setter.nextControlFlow("else");
setter.addStatement("return ($T)(($L & ~(1L << $LL)))", structType, structParam, offset);
setter.endControlFlow();
}else if(varType == TypeName.FLOAT){
cons.append(" | (").append("(").append(structType).append(")").append("Float.floatToIntBits(").append(varName).append(") << ").append(offset).append("L)");