diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..93837ff --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,52 @@ +name: .NET Build and Publish to Gitea + +on: + push: + branches: '*' + pull_request: + +jobs: + build: + runs-on: dotnet + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: true + - name: Restore dependencies + run: dotnet restore + + - name: Download Dalamud + run: | + mkdir -p $HOME/.xlcore/dalamud/Hooks/dev/ + curl -L https://goatcorp.github.io/dalamud-distrib/stg/latest.zip -o latest.zip + unzip -o latest.zip -d $HOME/.xlcore/dalamud/Hooks/dev/ + + - name: Build project + run: dotnet build --no-restore --configuration Release --nologo + + - name: Publish Windows executable + run: dotnet publish -c Release -r win-x64 --self-contained true -o ./publish + + - name: Archive published files + run: zip -r SnowcloakClient.zip ./publish/* + + - name: Create Gitea release + env: + GITEA_TOKEN: ${{ secrets.BUILD_SNOWCLOAK_CLIENT }} + run: | + API_URL="https://git.snowcloak-sync.com/api/v1/repos/Eauldane/SnowcloakClient/releases" + TAG="v$(date +%Y%m%d%H%M)" + # Create release + RELEASE_ID=$(curl -s -X POST \ + -H "Content-Type: application/json" \ + -H "Authorization: token $GITEA_TOKEN" \ + -d "{\"tag_name\":\"$TAG\",\"name\":\"Automated Build $TAG\",\"body\":\"Automated build artifact\"}" \ + $API_URL | jq -r '.id') + echo "Release ID: $RELEASE_ID" + # Upload asset + curl -s -X POST \ + -H "Authorization: token $GITEA_TOKEN" \ + -F "name=SnowcloakClient.zip" \ + -F "attachment=@SnowcloakClient.zip" \ + "$API_URL/$RELEASE_ID/assets" diff --git a/MareSynchronos/Utils/PngHdr.cs b/MareSynchronos/Utils/PngHdr.cs index 5723f5a..16631b8 100644 --- a/MareSynchronos/Utils/PngHdr.cs +++ b/MareSynchronos/Utils/PngHdr.cs @@ -20,7 +20,7 @@ public class PngHdr stream.ReadExactly(buffer[..8]); - uint ihdrLength = BitConverter.ToUInt32(buffer); + uint ihdrLength = ReadBigEndianUInt32(buffer[..4]); // The next four bytes will be the length of the IHDR section (it should be 13 bytes but we only need 8) if (ihdrLength < 8) @@ -32,8 +32,8 @@ public class PngHdr stream.ReadExactly(buffer[..8]); - uint width = BitConverter.ToUInt32(buffer); - uint height = BitConverter.ToUInt32(buffer[4..]); + uint width = ReadBigEndianUInt32(buffer[..4]); + uint height = ReadBigEndianUInt32(buffer[4..8]); // Validate the width/height are non-negative and... that's all we care about! if (width > int.MaxValue || height > int.MaxValue) @@ -46,4 +46,12 @@ public class PngHdr return InvalidSize; } } -} + // Minimal helper for big-endian conversion + private static uint ReadBigEndianUInt32(ReadOnlySpan bytes) + { + return ((uint)bytes[0] << 24) | + ((uint)bytes[1] << 16) | + ((uint)bytes[2] << 8) | + bytes[3]; + } +} \ No newline at end of file