diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..1576722 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,42 @@ +name: CD + +on: + push: + tags: + - '*' + +jobs: + release: + runs-on: ubuntu-latest + + if: "!contains(github.event.head_commit.message, '[cd skip]')" + + steps: + - uses: actions/checkout@v4 + + - uses: denoland/setup-deno@v2 + with: + deno-version: v2.x + + - name: Format check + run: deno fmt --check + + - name: Lint check + run: deno lint + + - name: Type Check + run: deno task check:types + + - name: Test + run: deno task test + + - name: Build + run: deno task build:npm ${{ github.ref_name }} + + - name: Publish to jsr + run: npx jsr publish + + #- name: Publish to npm + # env: + # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + # run: cd npm && npm publish --access public diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e4d203f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: CI + +on: + push: + branches: ['main'] + paths: + - 'src/**/*.ts' + - 'tests/**/*.ts' + pull_request: + branches: ['main'] + paths: + - 'src/**/*.ts' + - 'tests/**/*.ts' + workflow_dispatch: + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + + if: "!contains(github.event.head_commit.message, '[ci skip]')" + + steps: + - uses: actions/checkout@v4 + + - uses: denoland/setup-deno@v2 + with: + deno-version: v2.x + + - name: Format check + run: deno fmt --check + + - name: Lint check + run: deno lint + + - name: Type Check + run: deno task check:types + + - name: Test + run: deno task test diff --git a/.github/workflows/deno.yml b/.github/workflows/deno.yml deleted file mode 100644 index 895437a..0000000 --- a/.github/workflows/deno.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Deno CI - -on: - push: - branches: ["master"] - paths: - - "src/**/*.ts" - - "tests/**/*.ts" - pull_request: - branches: ["master"] - paths: - - "src/**/*.ts" - - "tests/**/*.ts" - workflow_dispatch: - -permissions: - contents: read - -jobs: - test: - runs-on: ubuntu-latest - - if: "!contains(github.event.head_commit.message, '[ci skip]')" - - steps: - - uses: actions/checkout@v3 - - - uses: denoland/setup-deno@v1 - with: - deno-version: v1.x - - - name: Format check - run: deno fmt --check - - - name: Lint - run: deno lint - - - name: Test - run: deno test -A diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index e9ca7de..57c6408 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -2,10 +2,10 @@ name: docs on: push: - branches: ["master"] + branches: ['main'] paths: - - "docs/**" - - "README.md" + - 'docs/**' + - 'README.md' workflow_dispatch: @@ -15,7 +15,7 @@ permissions: id-token: write concurrency: - group: "pages" + group: 'pages' cancel-in-progress: false jobs: @@ -23,10 +23,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Pages - uses: actions/configure-pages@v3 + uses: actions/configure-pages@v5 - name: Copy Files run: cp README.md showcase.gif docs @@ -38,15 +38,8 @@ jobs: destination: ./_site - name: Upload artifact - uses: actions/upload-pages-artifact@v1 + uses: actions/upload-pages-artifact@v3 - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build - steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v2 + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 5e1bd0b..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Release CD - -on: - push: - tags: - - '*' - -jobs: - release: - runs-on: ubuntu-latest - - if: "!contains(github.event.head_commit.message, '[cd skip]')" - - steps: - - uses: actions/checkout@v3 - - - uses: denoland/setup-deno@v1 - with: - deno-version: v1.x - - - name: Format check - run: deno fmt --check - - - name: Lint - run: deno lint - - - name: Test - run: deno test -A - - - uses: actions/setup-node@v3 - with: - node-version: '18.x' - registry-url: 'https://registry.npmjs.org' - - - name: Build - run: deno run -A ./scripts/build_npm.ts ${{ github.ref_name }} - - - name: Publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - run: cd npm && npm publish --access public diff --git a/.gitignore b/.gitignore index 663f39e..e045dc2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,10 @@ .vscode/ demos/private/ +demos/public/ +demos/public/error/ +demos/public/portal2_sp_wr/ +demos/public/*_repaired.dem +examples/experimental/ dist/ npm/ diff --git a/LICENSE b/LICENSE index cde1334..6c49be1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018-2023, NeKz +Copyright (c) 2018-2024, NeKz Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index d1f7661..c7b33cd 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ -[![Deno CI](https://github.com/NeKzor/sdp/actions/workflows/deno.yml/badge.svg)](https://github.com/NeKzor/sdp/actions/workflows/deno.yml) -[![Release CD](https://github.com/NeKzor/sdp/actions/workflows/release.yml/badge.svg)](https://github.com/NeKzor/sdp/actions/workflows/release.yml) +[![CI](https://github.com/NeKzor/sdp/actions/workflows/ci.yml/badge.svg)](https://github.com/NeKzor/sdp/actions/workflows/ci.yml) +[![CD](https://github.com/NeKzor/sdp/actions/workflows/cd.yml/badge.svg)](https://github.com/NeKzor/sdp/actions/workflows/cd.yml) +[![jsr](https://jsr.io/badges/@nekz/sdp)](https://jsr.io/@nekz/sdp) [![npm](https://img.shields.io/npm/v/@nekz/sdp?color=blue)](https://www.npmjs.com/package/@nekz/sdp) # sdp @@ -13,6 +14,7 @@ Simple Source Engine demo parser. Try it out on [StackBlitz]! - Support for multiple engines - Portal 2 - Half-Life 2 + - Custom engine, see [Strata Source example](./examples/custom/strata.ts) - Optional decoding of message data - [User command info] - [NET/SVC messages] @@ -22,12 +24,15 @@ Simple Source Engine demo parser. Try it out on [StackBlitz]! - Speedrun timing - Rules for Portal, Portal 2 and mods - [SAR] timing - -[User command info]: https://nekz.me/dem/classes/usercmdinfo.html -[NET/SVC messages]: https://nekz.me/dem/classes/netsvc.html -[Send tables]: https://nekz.me/dem/classes/sendtable.html -[String tables]: https://nekz.me/dem/classes/stringtable.html -[Game events]: https://nekz.me/dem/classes/gameevent.html +- Utils + - Steam ID parsing + - SAR data + +[User command info]: https://dem.nekz.me/dem/classes/usercmdinfo.html +[NET/SVC messages]: https://dem.nekz.me/dem/classes/netsvc.html +[Send tables]: https://dem.nekz.me/dem/classes/sendtable.html +[String tables]: https://dem.nekz.me/dem/classes/stringtable.html +[Game events]: https://dem.nekz.me/dem/classes/gameevent.html [SAR]: https://sar.portal2.sr ## Examples @@ -37,7 +42,7 @@ Simple Source Engine demo parser. Try it out on [StackBlitz]! Using Deno + TypeScript: ```ts -import { SourceDemoParser } from 'npm:@nekz/sdp'; +import { SourceDemoParser } from 'jsr:@nekz/sdp'; const demo = SourceDemoParser.default() .setOptions({ messages: false }) @@ -87,20 +92,18 @@ console.log('registered jumps:', registeredJumps.length); */ ``` -### Jump Stats - The [examples directory](./examples/) contains more examples for Node and Deno. ### View Origin [![showcase.gif](showcase.gif)](https://nekz.me/parser) -Used in [nekz.me/parser](https://nekz.me/parser). Updated example can be found in [examples/parser.html](./examples/parser.html). +Used in [nekz.me/parser](https://nekz.me/parser). +Updated example can be found in [examples/web/parser.html](./examples/web/parser.html). -## Credits +## Dependencies -[inolen/bit-buffer] for `BitStream` and `BitView`. I ported it to TypeScript because Deno cannot bundle npm specifiers -and any other bundler is not good enough. Also this port significantly improves typings which means less errors etc. +Vendored [inolen/bit-buffer] for TypeScript port + improvements. [inolen/bit-buffer]: https://github.com/inolen/bit-buffer diff --git a/deno.json b/deno.json deleted file mode 100644 index fcce998..0000000 --- a/deno.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "tasks": { - "test": "deno test -A", - "build:npm": "deno run -A scripts/build_npm.ts", - "build:dist": "deno run -A scripts/build_dist.ts", - "build:esbuild": "deno run -A scripts/build_esbuild.ts", - "fixup": "deno run --allow-read=demos --allow-write=demos examples/fixup.ts demos/public/portal2_cm.dem", - "fixup:broken": "deno run --allow-read=demos --allow-write=demos examples/fixup.ts demos/public/portal2_requires_fixup.dem", - "jump-stats": "deno run --allow-read=demos examples/jump_stats.ts demos/public/portal2.dem" - }, - "fmt": { - "useTabs": false, - "lineWidth": 120, - "indentWidth": 4, - "singleQuote": true, - "proseWrap": "preserve", - "exclude": ["npm/"] - }, - "compilerOptions": { - "noUncheckedIndexedAccess": true - }, - "test": { - "include": [ - "tests/" - ] - }, - "lint": { - "include": ["src/"], - "exclude": ["npm/"] - } -} diff --git a/deno.jsonc b/deno.jsonc new file mode 100644 index 0000000..9acbf2c --- /dev/null +++ b/deno.jsonc @@ -0,0 +1,75 @@ +{ + "name": "@nekz/sdp", + "license": "MIT", + "version": "1.0.0-alpha.1", + "tasks": { + // Run fmt, lint and type checks + "check": "deno fmt --check && deno lint && deno task check:types", + // Run type check only + "check:types": "deno check --no-lock src/**/*.ts tests/**/*.ts examples/**/*.ts scripts/**/*.ts", + // Run tests + "test": "deno test -A", + // Build package for npm + "build:npm": "deno run -A scripts/build_npm.ts", + // Build package dist + "build:dist": "deno run -A scripts/build_dist.ts", + // Build package with esbuild + "build:esbuild": "deno run -A scripts/build_esbuild.ts", + // Run fixup example + "fixup": "deno run -RW=demos examples/info/fixup.ts demos/public/portal2_cm.dem", + // Run fixup broken example + "fixup:broken": "deno run -RW=demos examples/info/fixup.ts demos/public/portal2_requires_fixup.dem", + // Run jump stats example + "info:jumps": "deno run -R=demos examples/info/jump_stats.ts demos/public/portal2.dem", + // Run SAR data example + "info:sar": "deno run -R=demos examples/info/sar_data.ts demos/public/portal2_cm_latest.dem", + // Run Steam ID example + "info:steam": "deno run -R=demos examples/info/steam_id.ts demos/public/portal2_coop.dem", + // Run user messages example + "info:um": "deno run -R=demos examples/info/user_messages.ts demos/public/portal2_cm.dem", + // Run strata example + "strata": "deno run -R=demos examples/custom/strata.ts demos/public/portal_revolution_start.dem" + }, + "fmt": { + "useTabs": false, + "lineWidth": 120, + "indentWidth": 4, + "singleQuote": true, + "proseWrap": "preserve", + "exclude": [ + "npm/", + ".github/" + ] + }, + "compilerOptions": { + "noUncheckedIndexedAccess": true + }, + "exclude": [ + "demos/", + "examples/experimental/", + "examples/node/", + "npm/" + ], + "test": { + "include": [ + "tests/" + ] + }, + "lint": { + "include": [ + "src/" + ] + }, + "exports": { + ".": "./src/mod.ts", + "./utils": "./src/utils/mod.ts" + }, + "publish": { + "include": [ + "src/**/*.ts", + "deno.json", + "LICENSE", + "README.md" + ] + } +} diff --git a/deno.lock b/deno.lock index b356062..4ca0f7f 100644 --- a/deno.lock +++ b/deno.lock @@ -1,5 +1,350 @@ { - "version": "2", + "version": "4", + "specifiers": { + "jsr:@david/code-block-writer@^13.0.2": "13.0.3", + "jsr:@deno/cache-dir@0.13.2": "0.13.2", + "jsr:@deno/cache-dir@~0.10.3": "0.10.3", + "jsr:@deno/dnt@0.41.3": "0.41.3", + "jsr:@deno/emit@0.46.0": "0.46.0", + "jsr:@deno/graph@~0.73.1": "0.73.1", + "jsr:@luca/esbuild-deno-loader@0.11.0": "0.11.0", + "jsr:@std/assert@*": "1.0.7", + "jsr:@std/assert@0.223": "0.223.0", + "jsr:@std/assert@0.226": "0.226.0", + "jsr:@std/assert@^1.0.7": "1.0.7", + "jsr:@std/bytes@0.223": "0.223.0", + "jsr:@std/bytes@^1.0.2": "1.0.2", + "jsr:@std/encoding@^1.0.5": "1.0.5", + "jsr:@std/fmt@0.223": "0.223.0", + "jsr:@std/fmt@1": "1.0.3", + "jsr:@std/fs@0.223": "0.223.0", + "jsr:@std/fs@1": "1.0.5", + "jsr:@std/fs@1.0.5": "1.0.5", + "jsr:@std/fs@~0.229.3": "0.229.3", + "jsr:@std/internal@^1.0.5": "1.0.5", + "jsr:@std/io@0.223": "0.223.0", + "jsr:@std/path@0.223": "0.223.0", + "jsr:@std/path@1": "1.0.7", + "jsr:@std/path@1.0.0-rc.1": "1.0.0-rc.1", + "jsr:@std/path@^1.0.6": "1.0.7", + "jsr:@std/path@^1.0.7": "1.0.7", + "jsr:@std/path@~0.225.2": "0.225.2", + "jsr:@std/testing@*": "1.0.4", + "jsr:@ts-morph/bootstrap@0.24": "0.24.0", + "jsr:@ts-morph/common@0.24": "0.24.0", + "npm:@nekz/sdp@*": "0.3.0", + "npm:@types/node@*": "18.11.18", + "npm:esbuild@0.24.0": "0.24.0", + "npm:long@*": "5.2.3", + "npm:protobufjs@*": "7.4.0" + }, + "jsr": { + "@david/code-block-writer@13.0.3": { + "integrity": "f98c77d320f5957899a61bfb7a9bead7c6d83ad1515daee92dbacc861e13bb7f" + }, + "@deno/cache-dir@0.10.3": { + "integrity": "eb022f84ecc49c91d9d98131c6e6b118ff63a29e343624d058646b9d50404776", + "dependencies": [ + "jsr:@deno/graph", + "jsr:@std/fmt@0.223", + "jsr:@std/fs@0.223", + "jsr:@std/io", + "jsr:@std/path@0.223" + ] + }, + "@deno/cache-dir@0.13.2": { + "integrity": "c22419dfe27ab85f345bee487aaaadba498b005cce3644e9d2528db035c5454d", + "dependencies": [ + "jsr:@deno/graph", + "jsr:@std/fmt@0.223", + "jsr:@std/fs@0.223", + "jsr:@std/io", + "jsr:@std/path@0.223" + ] + }, + "@deno/dnt@0.41.3": { + "integrity": "b2ef2c8a5111eef86cb5bfcae103d6a2938e8e649e2461634a7befb7fc59d6d2", + "dependencies": [ + "jsr:@david/code-block-writer", + "jsr:@deno/cache-dir@~0.10.3", + "jsr:@std/fmt@1", + "jsr:@std/fs@1", + "jsr:@std/path@1", + "jsr:@ts-morph/bootstrap" + ] + }, + "@deno/emit@0.46.0": { + "integrity": "e276be2c77bac1b93caf775762e2a49a54cb00da2d48ca2b01ed8d7cba9d082c", + "dependencies": [ + "jsr:@deno/cache-dir@0.13.2", + "jsr:@std/path@0.223" + ] + }, + "@deno/graph@0.73.1": { + "integrity": "cd69639d2709d479037d5ce191a422eabe8d71bb68b0098344f6b07411c84d41" + }, + "@luca/esbuild-deno-loader@0.11.0": { + "integrity": "c05a989aa7c4ee6992a27be5f15cfc5be12834cab7ff84cabb47313737c51a2c", + "dependencies": [ + "jsr:@std/bytes@^1.0.2", + "jsr:@std/encoding", + "jsr:@std/path@^1.0.6" + ] + }, + "@std/assert@0.223.0": { + "integrity": "eb8d6d879d76e1cc431205bd346ed4d88dc051c6366365b1af47034b0670be24" + }, + "@std/assert@0.226.0": { + "integrity": "0dfb5f7c7723c18cec118e080fec76ce15b4c31154b15ad2bd74822603ef75b3" + }, + "@std/assert@1.0.7": { + "integrity": "64ce9fac879e0b9f3042a89b3c3f8ccfc9c984391af19e2087513a79d73e28c3", + "dependencies": [ + "jsr:@std/internal" + ] + }, + "@std/bytes@0.223.0": { + "integrity": "84b75052cd8680942c397c2631318772b295019098f40aac5c36cead4cba51a8" + }, + "@std/bytes@1.0.2": { + "integrity": "fbdee322bbd8c599a6af186a1603b3355e59a5fb1baa139f8f4c3c9a1b3e3d57" + }, + "@std/encoding@1.0.5": { + "integrity": "ecf363d4fc25bd85bd915ff6733a7e79b67e0e7806334af15f4645c569fefc04" + }, + "@std/fmt@0.223.0": { + "integrity": "6deb37794127dfc7d7bded2586b9fc6f5d50e62a8134846608baf71ffc1a5208" + }, + "@std/fmt@1.0.3": { + "integrity": "97765c16aa32245ff4e2204ecf7d8562496a3cb8592340a80e7e554e0bb9149f" + }, + "@std/fs@0.223.0": { + "integrity": "3b4b0550b2c524cbaaa5a9170c90e96cbb7354e837ad1bdaf15fc9df1ae9c31c" + }, + "@std/fs@0.229.3": { + "integrity": "783bca21f24da92e04c3893c9e79653227ab016c48e96b3078377ebd5222e6eb", + "dependencies": [ + "jsr:@std/path@1.0.0-rc.1" + ] + }, + "@std/fs@1.0.5": { + "integrity": "41806ad6823d0b5f275f9849a2640d87e4ef67c51ee1b8fb02426f55e02fd44e", + "dependencies": [ + "jsr:@std/path@^1.0.7" + ] + }, + "@std/internal@1.0.5": { + "integrity": "54a546004f769c1ac9e025abd15a76b6671ddc9687e2313b67376125650dc7ba" + }, + "@std/io@0.223.0": { + "integrity": "2d8c3c2ab3a515619b90da2c6ff5ea7b75a94383259ef4d02116b228393f84f1", + "dependencies": [ + "jsr:@std/assert@0.223", + "jsr:@std/bytes@0.223" + ] + }, + "@std/path@0.223.0": { + "integrity": "593963402d7e6597f5a6e620931661053572c982fc014000459edc1f93cc3989", + "dependencies": [ + "jsr:@std/assert@0.223" + ] + }, + "@std/path@0.225.2": { + "integrity": "0f2db41d36b50ef048dcb0399aac720a5348638dd3cb5bf80685bf2a745aa506", + "dependencies": [ + "jsr:@std/assert@0.226" + ] + }, + "@std/path@1.0.0-rc.1": { + "integrity": "b8c00ae2f19106a6bb7cbf1ab9be52aa70de1605daeb2dbdc4f87a7cbaf10ff6" + }, + "@std/path@1.0.7": { + "integrity": "76a689e07f0e15dcc6002ec39d0866797e7156629212b28f27179b8a5c3b33a1" + }, + "@std/testing@1.0.4": { + "integrity": "ca1368d720b183f572d40c469bb9faf09643ddd77b54f8b44d36ae6b94940576", + "dependencies": [ + "jsr:@std/assert@^1.0.7", + "jsr:@std/internal" + ] + }, + "@ts-morph/bootstrap@0.24.0": { + "integrity": "a826a2ef7fa8a7c3f1042df2c034d20744d94da2ee32bf29275bcd4dffd3c060", + "dependencies": [ + "jsr:@ts-morph/common" + ] + }, + "@ts-morph/common@0.24.0": { + "integrity": "12b625b8e562446ba658cdbe9ad77774b4bd96b992ae8bd34c60dbf24d06c1f3", + "dependencies": [ + "jsr:@std/fs@~0.229.3", + "jsr:@std/path@~0.225.2" + ] + } + }, + "npm": { + "@esbuild/aix-ppc64@0.24.0": { + "integrity": "sha512-WtKdFM7ls47zkKHFVzMz8opM7LkcsIp9amDUBIAWirg70RM71WRSjdILPsY5Uv1D42ZpUfaPILDlfactHgsRkw==" + }, + "@esbuild/android-arm64@0.24.0": { + "integrity": "sha512-Vsm497xFM7tTIPYK9bNTYJyF/lsP590Qc1WxJdlB6ljCbdZKU9SY8i7+Iin4kyhV/KV5J2rOKsBQbB77Ab7L/w==" + }, + "@esbuild/android-arm@0.24.0": { + "integrity": "sha512-arAtTPo76fJ/ICkXWetLCc9EwEHKaeya4vMrReVlEIUCAUncH7M4bhMQ+M9Vf+FFOZJdTNMXNBrWwW+OXWpSew==" + }, + "@esbuild/android-x64@0.24.0": { + "integrity": "sha512-t8GrvnFkiIY7pa7mMgJd7p8p8qqYIz1NYiAoKc75Zyv73L3DZW++oYMSHPRarcotTKuSs6m3hTOa5CKHaS02TQ==" + }, + "@esbuild/darwin-arm64@0.24.0": { + "integrity": "sha512-CKyDpRbK1hXwv79soeTJNHb5EiG6ct3efd/FTPdzOWdbZZfGhpbcqIpiD0+vwmpu0wTIL97ZRPZu8vUt46nBSw==" + }, + "@esbuild/darwin-x64@0.24.0": { + "integrity": "sha512-rgtz6flkVkh58od4PwTRqxbKH9cOjaXCMZgWD905JOzjFKW+7EiUObfd/Kav+A6Gyud6WZk9w+xu6QLytdi2OA==" + }, + "@esbuild/freebsd-arm64@0.24.0": { + "integrity": "sha512-6Mtdq5nHggwfDNLAHkPlyLBpE5L6hwsuXZX8XNmHno9JuL2+bg2BX5tRkwjyfn6sKbxZTq68suOjgWqCicvPXA==" + }, + "@esbuild/freebsd-x64@0.24.0": { + "integrity": "sha512-D3H+xh3/zphoX8ck4S2RxKR6gHlHDXXzOf6f/9dbFt/NRBDIE33+cVa49Kil4WUjxMGW0ZIYBYtaGCa2+OsQwQ==" + }, + "@esbuild/linux-arm64@0.24.0": { + "integrity": "sha512-TDijPXTOeE3eaMkRYpcy3LarIg13dS9wWHRdwYRnzlwlA370rNdZqbcp0WTyyV/k2zSxfko52+C7jU5F9Tfj1g==" + }, + "@esbuild/linux-arm@0.24.0": { + "integrity": "sha512-gJKIi2IjRo5G6Glxb8d3DzYXlxdEj2NlkixPsqePSZMhLudqPhtZ4BUrpIuTjJYXxvF9njql+vRjB2oaC9XpBw==" + }, + "@esbuild/linux-ia32@0.24.0": { + "integrity": "sha512-K40ip1LAcA0byL05TbCQ4yJ4swvnbzHscRmUilrmP9Am7//0UjPreh4lpYzvThT2Quw66MhjG//20mrufm40mA==" + }, + "@esbuild/linux-loong64@0.24.0": { + "integrity": "sha512-0mswrYP/9ai+CU0BzBfPMZ8RVm3RGAN/lmOMgW4aFUSOQBjA31UP8Mr6DDhWSuMwj7jaWOT0p0WoZ6jeHhrD7g==" + }, + "@esbuild/linux-mips64el@0.24.0": { + "integrity": "sha512-hIKvXm0/3w/5+RDtCJeXqMZGkI2s4oMUGj3/jM0QzhgIASWrGO5/RlzAzm5nNh/awHE0A19h/CvHQe6FaBNrRA==" + }, + "@esbuild/linux-ppc64@0.24.0": { + "integrity": "sha512-HcZh5BNq0aC52UoocJxaKORfFODWXZxtBaaZNuN3PUX3MoDsChsZqopzi5UupRhPHSEHotoiptqikjN/B77mYQ==" + }, + "@esbuild/linux-riscv64@0.24.0": { + "integrity": "sha512-bEh7dMn/h3QxeR2KTy1DUszQjUrIHPZKyO6aN1X4BCnhfYhuQqedHaa5MxSQA/06j3GpiIlFGSsy1c7Gf9padw==" + }, + "@esbuild/linux-s390x@0.24.0": { + "integrity": "sha512-ZcQ6+qRkw1UcZGPyrCiHHkmBaj9SiCD8Oqd556HldP+QlpUIe2Wgn3ehQGVoPOvZvtHm8HPx+bH20c9pvbkX3g==" + }, + "@esbuild/linux-x64@0.24.0": { + "integrity": "sha512-vbutsFqQ+foy3wSSbmjBXXIJ6PL3scghJoM8zCL142cGaZKAdCZHyf+Bpu/MmX9zT9Q0zFBVKb36Ma5Fzfa8xA==" + }, + "@esbuild/netbsd-x64@0.24.0": { + "integrity": "sha512-hjQ0R/ulkO8fCYFsG0FZoH+pWgTTDreqpqY7UnQntnaKv95uP5iW3+dChxnx7C3trQQU40S+OgWhUVwCjVFLvg==" + }, + "@esbuild/openbsd-arm64@0.24.0": { + "integrity": "sha512-MD9uzzkPQbYehwcN583yx3Tu5M8EIoTD+tUgKF982WYL9Pf5rKy9ltgD0eUgs8pvKnmizxjXZyLt0z6DC3rRXg==" + }, + "@esbuild/openbsd-x64@0.24.0": { + "integrity": "sha512-4ir0aY1NGUhIC1hdoCzr1+5b43mw99uNwVzhIq1OY3QcEwPDO3B7WNXBzaKY5Nsf1+N11i1eOfFcq+D/gOS15Q==" + }, + "@esbuild/sunos-x64@0.24.0": { + "integrity": "sha512-jVzdzsbM5xrotH+W5f1s+JtUy1UWgjU0Cf4wMvffTB8m6wP5/kx0KiaLHlbJO+dMgtxKV8RQ/JvtlFcdZ1zCPA==" + }, + "@esbuild/win32-arm64@0.24.0": { + "integrity": "sha512-iKc8GAslzRpBytO2/aN3d2yb2z8XTVfNV0PjGlCxKo5SgWmNXx82I/Q3aG1tFfS+A2igVCY97TJ8tnYwpUWLCA==" + }, + "@esbuild/win32-ia32@0.24.0": { + "integrity": "sha512-vQW36KZolfIudCcTnaTpmLQ24Ha1RjygBo39/aLkM2kmjkWmZGEJ5Gn9l5/7tzXA42QGIoWbICfg6KLLkIw6yw==" + }, + "@esbuild/win32-x64@0.24.0": { + "integrity": "sha512-7IAFPrjSQIJrGsK6flwg7NFmwBoSTyF3rl7If0hNUFQU4ilTsEPL6GuMuU9BfIWVVGuRnuIidkSMC+c0Otu8IA==" + }, + "@nekz/sdp@0.3.0": { + "integrity": "sha512-4vffmc60cA1o6SHMM65c5JXgsaFV99yDMJldufetl/bBb2BjZk1kHj4VqbfKlCrsL66YLhS5oXrJUvMgPgutAg==" + }, + "@protobufjs/aspromise@1.1.2": { + "integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==" + }, + "@protobufjs/base64@1.1.2": { + "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==" + }, + "@protobufjs/codegen@2.0.4": { + "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==" + }, + "@protobufjs/eventemitter@1.1.0": { + "integrity": "sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==" + }, + "@protobufjs/fetch@1.1.0": { + "integrity": "sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==", + "dependencies": [ + "@protobufjs/aspromise", + "@protobufjs/inquire" + ] + }, + "@protobufjs/float@1.0.2": { + "integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==" + }, + "@protobufjs/inquire@1.1.0": { + "integrity": "sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==" + }, + "@protobufjs/path@1.1.2": { + "integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==" + }, + "@protobufjs/pool@1.1.0": { + "integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==" + }, + "@protobufjs/utf8@1.1.0": { + "integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==" + }, + "@types/node@18.11.18": { + "integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==" + }, + "esbuild@0.24.0": { + "integrity": "sha512-FuLPevChGDshgSicjisSooU0cemp/sGXR841D5LHMB7mTVOmsEHcAxaH3irL53+8YDIeVNQEySh4DaYU/iuPqQ==", + "dependencies": [ + "@esbuild/aix-ppc64", + "@esbuild/android-arm", + "@esbuild/android-arm64", + "@esbuild/android-x64", + "@esbuild/darwin-arm64", + "@esbuild/darwin-x64", + "@esbuild/freebsd-arm64", + "@esbuild/freebsd-x64", + "@esbuild/linux-arm", + "@esbuild/linux-arm64", + "@esbuild/linux-ia32", + "@esbuild/linux-loong64", + "@esbuild/linux-mips64el", + "@esbuild/linux-ppc64", + "@esbuild/linux-riscv64", + "@esbuild/linux-s390x", + "@esbuild/linux-x64", + "@esbuild/netbsd-x64", + "@esbuild/openbsd-arm64", + "@esbuild/openbsd-x64", + "@esbuild/sunos-x64", + "@esbuild/win32-arm64", + "@esbuild/win32-ia32", + "@esbuild/win32-x64" + ] + }, + "long@5.2.3": { + "integrity": "sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==" + }, + "protobufjs@7.4.0": { + "integrity": "sha512-mRUWCc3KUU4w1jU8sGxICXH/gNS94DvI1gxqDvBzhj1JpcsimQkYiOJfwsPUykUI5ZaspFbSgmBLER8IrQ3tqw==", + "dependencies": [ + "@protobufjs/aspromise", + "@protobufjs/base64", + "@protobufjs/codegen", + "@protobufjs/eventemitter", + "@protobufjs/fetch", + "@protobufjs/float", + "@protobufjs/inquire", + "@protobufjs/path", + "@protobufjs/pool", + "@protobufjs/utf8", + "@types/node", + "long" + ] + } + }, "remote": { "https://deno.land/std@0.140.0/_util/assert.ts": "e94f2eb37cebd7f199952e242c77654e43333c1ac4c5c700e929ea3aa5489f74", "https://deno.land/std@0.140.0/_util/os.ts": "3b4c6e27febd119d36a416d7a97bd3b0251b77c88942c8f16ee5953ea13e2e49", @@ -193,21 +538,5 @@ "https://deno.land/x/wasmbuild@0.13.0/loader.ts": "d98d195a715f823151cbc8baa3f32127337628379a02d9eb2a3c5902dbccfc02", "https://deno.land/x/wasmbuild@0.14.1/cache.ts": "89eea5f3ce6035a1164b3e655c95f21300498920575ade23161421f5b01967f4", "https://deno.land/x/wasmbuild@0.14.1/loader.ts": "d98d195a715f823151cbc8baa3f32127337628379a02d9eb2a3c5902dbccfc02" - }, - "npm": { - "specifiers": { - "@nekz/sdp": "@nekz/sdp@0.3.0", - "@types/node": "@types/node@18.11.18" - }, - "packages": { - "@nekz/sdp@0.3.0": { - "integrity": "sha512-4vffmc60cA1o6SHMM65c5JXgsaFV99yDMJldufetl/bBb2BjZk1kHj4VqbfKlCrsL66YLhS5oXrJUvMgPgutAg==", - "dependencies": {} - }, - "@types/node@18.11.18": { - "integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==", - "dependencies": {} - } - } } } diff --git a/examples/custom/p2ce/base_usermessages.ts b/examples/custom/p2ce/base_usermessages.ts new file mode 100644 index 0000000..45aa918 --- /dev/null +++ b/examples/custom/p2ce/base_usermessages.ts @@ -0,0 +1,5096 @@ +import pb from 'npm:protobufjs/minimal.js'; +import Long from 'npm:long'; +import { CMsgQAngle, CMsgRGBA, CMsgVector, CMsgVector2D } from './netmessages.ts'; + +export const protobufPackage = ''; + +export enum EUserMessages { + UM_VGUIMenu = 1, + UM_Geiger = 2, + UM_Train = 3, + UM_HudText = 4, + UM_SayText = 5, + UM_SayText2 = 6, + UM_TextMsg = 7, + UM_HudMsg = 8, + UM_ResetHud = 9, + UM_Shake = 12, + UM_Fade = 13, + UM_Rumble = 14, + UM_CloseCaption = 15, + UM_CloseCaptionDirect = 16, + UM_SendAudio = 17, + UM_RawAudio = 18, + UM_VoiceMask = 19, + UM_RequestState = 20, + UM_Damage = 21, + UM_RadioText = 22, + UM_HintText = 23, + UM_KeyHintText = 24, + UM_UpdateTeamMoney = 28, + UM_StopSpectatorMode = 29, + UM_DesiredTimescale = 31, + UM_CurrentTimescale = 32, + UM_AchievementEvent = 33, + UM_PlayerStatsUpdate = 36, + UM_CallVoteFailed = 45, + UM_VoteStart = 46, + UM_VotePass = 47, + UM_VoteFailed = 48, + UM_VoteSetup = 49, + UM_SendLastKillerDamageToClient = 51, + UM_ItemPickup = 53, + UM_ShowMenu = 54, + UM_BarTime = 55, + UM_AmmoDenied = 56, + UM_MarkAchievement = 57, + UM_GlowPropTurnOff = 60, + UM_SendPlayerItemDrops = 61, + UM_SendPlayerItemFound = 63, + UM_XpUpdate = 65, + UM_ScoreLeaderboardData = 67, + UM_PlayerDecalDigitalSignature = 68, + UM_WeaponSound = 69, + UM_UpdateScreenHealthBar = 70, + UM_EntityOutlineHighlight = 71, + UM_SSUI = 72, + UM_SurvivalStats = 73, + UM_DisconnectToLobby2 = 74, + UM_Tilt = 250, + UM_Battery = 251, + UM_CreditsMsg = 253, + UM_LogoTimeMsg = 254, + UM_UpdateJalopyRadar = 255, + UM_MessageText = 256, + UM_StatsSkipState = 258, + UM_PanoramaEvent = 512, + UNRECOGNIZED = -1, +} + +export function eUserMessagesFromJSON(object: any): EUserMessages { + switch (object) { + case 1: + case 'UM_VGUIMenu': + return EUserMessages.UM_VGUIMenu; + case 2: + case 'UM_Geiger': + return EUserMessages.UM_Geiger; + case 3: + case 'UM_Train': + return EUserMessages.UM_Train; + case 4: + case 'UM_HudText': + return EUserMessages.UM_HudText; + case 5: + case 'UM_SayText': + return EUserMessages.UM_SayText; + case 6: + case 'UM_SayText2': + return EUserMessages.UM_SayText2; + case 7: + case 'UM_TextMsg': + return EUserMessages.UM_TextMsg; + case 8: + case 'UM_HudMsg': + return EUserMessages.UM_HudMsg; + case 9: + case 'UM_ResetHud': + return EUserMessages.UM_ResetHud; + case 12: + case 'UM_Shake': + return EUserMessages.UM_Shake; + case 13: + case 'UM_Fade': + return EUserMessages.UM_Fade; + case 14: + case 'UM_Rumble': + return EUserMessages.UM_Rumble; + case 15: + case 'UM_CloseCaption': + return EUserMessages.UM_CloseCaption; + case 16: + case 'UM_CloseCaptionDirect': + return EUserMessages.UM_CloseCaptionDirect; + case 17: + case 'UM_SendAudio': + return EUserMessages.UM_SendAudio; + case 18: + case 'UM_RawAudio': + return EUserMessages.UM_RawAudio; + case 19: + case 'UM_VoiceMask': + return EUserMessages.UM_VoiceMask; + case 20: + case 'UM_RequestState': + return EUserMessages.UM_RequestState; + case 21: + case 'UM_Damage': + return EUserMessages.UM_Damage; + case 22: + case 'UM_RadioText': + return EUserMessages.UM_RadioText; + case 23: + case 'UM_HintText': + return EUserMessages.UM_HintText; + case 24: + case 'UM_KeyHintText': + return EUserMessages.UM_KeyHintText; + case 28: + case 'UM_UpdateTeamMoney': + return EUserMessages.UM_UpdateTeamMoney; + case 29: + case 'UM_StopSpectatorMode': + return EUserMessages.UM_StopSpectatorMode; + case 31: + case 'UM_DesiredTimescale': + return EUserMessages.UM_DesiredTimescale; + case 32: + case 'UM_CurrentTimescale': + return EUserMessages.UM_CurrentTimescale; + case 33: + case 'UM_AchievementEvent': + return EUserMessages.UM_AchievementEvent; + case 36: + case 'UM_PlayerStatsUpdate': + return EUserMessages.UM_PlayerStatsUpdate; + case 45: + case 'UM_CallVoteFailed': + return EUserMessages.UM_CallVoteFailed; + case 46: + case 'UM_VoteStart': + return EUserMessages.UM_VoteStart; + case 47: + case 'UM_VotePass': + return EUserMessages.UM_VotePass; + case 48: + case 'UM_VoteFailed': + return EUserMessages.UM_VoteFailed; + case 49: + case 'UM_VoteSetup': + return EUserMessages.UM_VoteSetup; + case 51: + case 'UM_SendLastKillerDamageToClient': + return EUserMessages.UM_SendLastKillerDamageToClient; + case 53: + case 'UM_ItemPickup': + return EUserMessages.UM_ItemPickup; + case 54: + case 'UM_ShowMenu': + return EUserMessages.UM_ShowMenu; + case 55: + case 'UM_BarTime': + return EUserMessages.UM_BarTime; + case 56: + case 'UM_AmmoDenied': + return EUserMessages.UM_AmmoDenied; + case 57: + case 'UM_MarkAchievement': + return EUserMessages.UM_MarkAchievement; + case 60: + case 'UM_GlowPropTurnOff': + return EUserMessages.UM_GlowPropTurnOff; + case 61: + case 'UM_SendPlayerItemDrops': + return EUserMessages.UM_SendPlayerItemDrops; + case 63: + case 'UM_SendPlayerItemFound': + return EUserMessages.UM_SendPlayerItemFound; + case 65: + case 'UM_XpUpdate': + return EUserMessages.UM_XpUpdate; + case 67: + case 'UM_ScoreLeaderboardData': + return EUserMessages.UM_ScoreLeaderboardData; + case 68: + case 'UM_PlayerDecalDigitalSignature': + return EUserMessages.UM_PlayerDecalDigitalSignature; + case 69: + case 'UM_WeaponSound': + return EUserMessages.UM_WeaponSound; + case 70: + case 'UM_UpdateScreenHealthBar': + return EUserMessages.UM_UpdateScreenHealthBar; + case 71: + case 'UM_EntityOutlineHighlight': + return EUserMessages.UM_EntityOutlineHighlight; + case 72: + case 'UM_SSUI': + return EUserMessages.UM_SSUI; + case 73: + case 'UM_SurvivalStats': + return EUserMessages.UM_SurvivalStats; + case 74: + case 'UM_DisconnectToLobby2': + return EUserMessages.UM_DisconnectToLobby2; + case 250: + case 'UM_Tilt': + return EUserMessages.UM_Tilt; + case 251: + case 'UM_Battery': + return EUserMessages.UM_Battery; + case 253: + case 'UM_CreditsMsg': + return EUserMessages.UM_CreditsMsg; + case 254: + case 'UM_LogoTimeMsg': + return EUserMessages.UM_LogoTimeMsg; + case 255: + case 'UM_UpdateJalopyRadar': + return EUserMessages.UM_UpdateJalopyRadar; + case 256: + case 'UM_MessageText': + return EUserMessages.UM_MessageText; + case 258: + case 'UM_StatsSkipState': + return EUserMessages.UM_StatsSkipState; + case 512: + case 'UM_PanoramaEvent': + return EUserMessages.UM_PanoramaEvent; + case -1: + case 'UNRECOGNIZED': + default: + return EUserMessages.UNRECOGNIZED; + } +} + +export function eUserMessagesToJSON(object: EUserMessages): string { + switch (object) { + case EUserMessages.UM_VGUIMenu: + return 'UM_VGUIMenu'; + case EUserMessages.UM_Geiger: + return 'UM_Geiger'; + case EUserMessages.UM_Train: + return 'UM_Train'; + case EUserMessages.UM_HudText: + return 'UM_HudText'; + case EUserMessages.UM_SayText: + return 'UM_SayText'; + case EUserMessages.UM_SayText2: + return 'UM_SayText2'; + case EUserMessages.UM_TextMsg: + return 'UM_TextMsg'; + case EUserMessages.UM_HudMsg: + return 'UM_HudMsg'; + case EUserMessages.UM_ResetHud: + return 'UM_ResetHud'; + case EUserMessages.UM_Shake: + return 'UM_Shake'; + case EUserMessages.UM_Fade: + return 'UM_Fade'; + case EUserMessages.UM_Rumble: + return 'UM_Rumble'; + case EUserMessages.UM_CloseCaption: + return 'UM_CloseCaption'; + case EUserMessages.UM_CloseCaptionDirect: + return 'UM_CloseCaptionDirect'; + case EUserMessages.UM_SendAudio: + return 'UM_SendAudio'; + case EUserMessages.UM_RawAudio: + return 'UM_RawAudio'; + case EUserMessages.UM_VoiceMask: + return 'UM_VoiceMask'; + case EUserMessages.UM_RequestState: + return 'UM_RequestState'; + case EUserMessages.UM_Damage: + return 'UM_Damage'; + case EUserMessages.UM_RadioText: + return 'UM_RadioText'; + case EUserMessages.UM_HintText: + return 'UM_HintText'; + case EUserMessages.UM_KeyHintText: + return 'UM_KeyHintText'; + case EUserMessages.UM_UpdateTeamMoney: + return 'UM_UpdateTeamMoney'; + case EUserMessages.UM_StopSpectatorMode: + return 'UM_StopSpectatorMode'; + case EUserMessages.UM_DesiredTimescale: + return 'UM_DesiredTimescale'; + case EUserMessages.UM_CurrentTimescale: + return 'UM_CurrentTimescale'; + case EUserMessages.UM_AchievementEvent: + return 'UM_AchievementEvent'; + case EUserMessages.UM_PlayerStatsUpdate: + return 'UM_PlayerStatsUpdate'; + case EUserMessages.UM_CallVoteFailed: + return 'UM_CallVoteFailed'; + case EUserMessages.UM_VoteStart: + return 'UM_VoteStart'; + case EUserMessages.UM_VotePass: + return 'UM_VotePass'; + case EUserMessages.UM_VoteFailed: + return 'UM_VoteFailed'; + case EUserMessages.UM_VoteSetup: + return 'UM_VoteSetup'; + case EUserMessages.UM_SendLastKillerDamageToClient: + return 'UM_SendLastKillerDamageToClient'; + case EUserMessages.UM_ItemPickup: + return 'UM_ItemPickup'; + case EUserMessages.UM_ShowMenu: + return 'UM_ShowMenu'; + case EUserMessages.UM_BarTime: + return 'UM_BarTime'; + case EUserMessages.UM_AmmoDenied: + return 'UM_AmmoDenied'; + case EUserMessages.UM_MarkAchievement: + return 'UM_MarkAchievement'; + case EUserMessages.UM_GlowPropTurnOff: + return 'UM_GlowPropTurnOff'; + case EUserMessages.UM_SendPlayerItemDrops: + return 'UM_SendPlayerItemDrops'; + case EUserMessages.UM_SendPlayerItemFound: + return 'UM_SendPlayerItemFound'; + case EUserMessages.UM_XpUpdate: + return 'UM_XpUpdate'; + case EUserMessages.UM_ScoreLeaderboardData: + return 'UM_ScoreLeaderboardData'; + case EUserMessages.UM_PlayerDecalDigitalSignature: + return 'UM_PlayerDecalDigitalSignature'; + case EUserMessages.UM_WeaponSound: + return 'UM_WeaponSound'; + case EUserMessages.UM_UpdateScreenHealthBar: + return 'UM_UpdateScreenHealthBar'; + case EUserMessages.UM_EntityOutlineHighlight: + return 'UM_EntityOutlineHighlight'; + case EUserMessages.UM_SSUI: + return 'UM_SSUI'; + case EUserMessages.UM_SurvivalStats: + return 'UM_SurvivalStats'; + case EUserMessages.UM_DisconnectToLobby2: + return 'UM_DisconnectToLobby2'; + case EUserMessages.UM_Tilt: + return 'UM_Tilt'; + case EUserMessages.UM_Battery: + return 'UM_Battery'; + case EUserMessages.UM_CreditsMsg: + return 'UM_CreditsMsg'; + case EUserMessages.UM_LogoTimeMsg: + return 'UM_LogoTimeMsg'; + case EUserMessages.UM_UpdateJalopyRadar: + return 'UM_UpdateJalopyRadar'; + case EUserMessages.UM_MessageText: + return 'UM_MessageText'; + case EUserMessages.UM_StatsSkipState: + return 'UM_StatsSkipState'; + case EUserMessages.UM_PanoramaEvent: + return 'UM_PanoramaEvent'; + case EUserMessages.UNRECOGNIZED: + default: + return 'UNRECOGNIZED'; + } +} + +export interface CUsrMsgVGUIMenu { + name: string; + show: boolean; + subkeys: CUsrMsgVGUIMenu_Subkey[]; +} + +export interface CUsrMsgVGUIMenu_Subkey { + name: string; + str: string; +} + +export interface CUsrMsgGeiger { + range: number; +} + +export interface CUsrMsgTrain { + train: number; +} + +export interface CUsrMsgHudText { + text: string; +} + +export interface CUsrMsgSayText { + entIdx: number; + text: string; + chat: boolean; + textallchat: boolean; +} + +export interface CUsrMsgSayText2 { + entIdx: number; + chat: boolean; + msgName: string; + params: string[]; + textallchat: boolean; +} + +export interface CUsrMsgTextMsg { + msgDst: number; + params: string[]; +} + +export interface CUsrMsgHudMsg { + channel: number; + pos: CMsgVector2D | undefined; + clr1: CMsgRGBA | undefined; + clr2: CMsgRGBA | undefined; + effect: number; + fadeInTime: number; + fadeOutTime: number; + holdTime: number; + fxTime: number; + text: string; +} + +export interface CUsrMsgShake { + command: number; + localAmplitude: number; + frequency: number; + duration: number; +} + +export interface CUsrMsgFade { + duration: number; + holdTime: number; + flags: number; + clr: CMsgRGBA | undefined; +} + +export interface CUsrMsgRumble { + index: number; + data: number; + flags: number; +} + +export interface CUsrMsgCloseCaption { + hash: number; + duration: number; + fromPlayer: boolean; +} + +export interface CUsrMsgCloseCaptionDirect { + hash: number; + duration: number; + fromPlayer: boolean; +} + +export interface CUsrMsgSendAudio { + radioSound: string; +} + +export interface CUsrMsgRawAudio { + pitch: number; + entidx: number; + duration: number; + voiceFilename: string; +} + +export interface CUsrMsgVoiceMask { + playerMasks: CUsrMsgVoiceMask_PlayerMask[]; + playerModEnable: boolean; +} + +export interface CUsrMsgVoiceMask_PlayerMask { + gameRulesMask: number; + banMasks: number; +} + +export interface CUsrMsgDamage { + amount: number; + inflictorWorldPos: CMsgVector | undefined; + victimEntindex: number; + amountMin: number; + amountMax: number; +} + +export interface CUsrMsgRadioText { + msgDst: number; + client: number; + msgName: string; + params: string[]; +} + +export interface CUsrMsgHintText { + text: string; +} + +export interface CUsrMsgKeyHintText { + hints: string[]; +} + +export interface CUsrMsgWeaponSound { + entidx: number; + originX: number; + originY: number; + originZ: number; + sound: string; + timestamp: number; +} + +export interface CUsrMsgUpdateScreenHealthBar { + entidx: number; + healthratioOld: number; + healthratioNew: number; + style: number; +} + +export interface CUsrMsgEntityOutlineHighlight { + entidx: number; +} + +export interface CUsrMsgDesiredTimescale { + desiredTimescale: number; + durationRealtimeSec: number; + interpolatorType: number; + startBlendTime: number; +} + +export interface CUsrMsgCurrentTimescale { + curTimescale: number; +} + +export interface CUsrMsgAchievementEvent { + achievement: number; + count: number; + userId: number; +} + +export interface CUsrMsgPlayerStatsUpdate { + version: number; + stats: CUsrMsgPlayerStatsUpdate_Stat[]; + userId: number; + crc: number; +} + +export interface CUsrMsgPlayerStatsUpdate_Stat { + idx: number; + delta: number; +} + +export interface CUsrMsgCallVoteFailed { + reason: number; + time: number; +} + +export interface CUsrMsgVoteStart { + team: number; + entIdx: number; + voteType: number; + dispStr: string; + detailsStr: string; + otherTeamStr: string; + isYesNoVote: boolean; +} + +export interface CUsrMsgVotePass { + team: number; + voteType: number; + dispStr: string; + detailsStr: string; +} + +export interface CUsrMsgVoteFailed { + team: number; + reason: number; +} + +export interface CUsrMsgVoteSetup { + potentialIssues: string[]; +} + +export interface CUsrMsgSendLastKillerDamageToClient { + numHitsGiven: number; + damageGiven: number; + numHitsTaken: number; + damageTaken: number; +} + +export interface CUsrMsgItemPickup { + item: string; +} + +export interface CUsrMsgShowMenu { + bitsValidSlots: number; + displayTime: number; + menuString: string; +} + +export interface CUsrMsgBarTime { + time: string; +} + +export interface CUsrMsgAmmoDenied { + ammoIdx: number; +} + +export interface CUsrMsgMarkAchievement { + achievement: string; +} + +export interface CUsrMsgGlowPropTurnOff { + entidx: number; +} + +export interface CUsrMsgTilt { + command: number; + easeInOut: boolean; + angle: CMsgQAngle | undefined; + duration: number; + time: number; +} + +export interface CUsrMsgBattery { + value: number; +} + +export interface CUsrMsgCreditsMsg { + type: number; +} + +export interface CUsrMsgLogoTimeMsg { + length: number; +} + +export interface CUsrMsgUpdateJalopyRadar { + dummy: number; +} + +export interface CUsrMsgMessageText { + color: CMsgRGBA | undefined; + text: string; +} + +export interface CUsrMsgStatsSkipState { + numSkips: number; + numPlayers: number; +} + +export interface CUsrMsgPanoramaEvent { + event: string; + payload: string; +} + +export interface CUsrMsgResetHud { + reset: boolean; +} + +export interface CUsrMsgRequestState { + dummy: number; +} + +export interface CUsrMsgStopSpectatorMode { + dummy: number; +} + +function createBaseCUsrMsgVGUIMenu(): CUsrMsgVGUIMenu { + return { name: '', show: false, subkeys: [] }; +} + +export const CUsrMsgVGUIMenu = { + encode(message: CUsrMsgVGUIMenu, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.name !== '') { + writer.uint32(10).string(message.name); + } + if (message.show === true) { + writer.uint32(16).bool(message.show); + } + for (const v of message.subkeys) { + CUsrMsgVGUIMenu_Subkey.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgVGUIMenu { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgVGUIMenu(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.name = reader.string(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.show = reader.bool(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.subkeys.push(CUsrMsgVGUIMenu_Subkey.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgVGUIMenu { + return { + name: isSet(object.name) ? globalThis.String(object.name) : '', + show: isSet(object.show) ? globalThis.Boolean(object.show) : false, + subkeys: globalThis.Array.isArray(object?.subkeys) + ? object.subkeys.map((e: any) => CUsrMsgVGUIMenu_Subkey.fromJSON(e)) + : [], + }; + }, + + toJSON(message: CUsrMsgVGUIMenu): unknown { + const obj: any = {}; + if (message.name !== '') { + obj.name = message.name; + } + if (message.show === true) { + obj.show = message.show; + } + if (message.subkeys?.length) { + obj.subkeys = message.subkeys.map((e) => CUsrMsgVGUIMenu_Subkey.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgVGUIMenu { + return CUsrMsgVGUIMenu.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgVGUIMenu { + const message = createBaseCUsrMsgVGUIMenu(); + message.name = object.name ?? ''; + message.show = object.show ?? false; + message.subkeys = object.subkeys?.map((e) => CUsrMsgVGUIMenu_Subkey.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseCUsrMsgVGUIMenu_Subkey(): CUsrMsgVGUIMenu_Subkey { + return { name: '', str: '' }; +} + +export const CUsrMsgVGUIMenu_Subkey = { + encode(message: CUsrMsgVGUIMenu_Subkey, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.name !== '') { + writer.uint32(10).string(message.name); + } + if (message.str !== '') { + writer.uint32(18).string(message.str); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgVGUIMenu_Subkey { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgVGUIMenu_Subkey(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.name = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.str = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgVGUIMenu_Subkey { + return { + name: isSet(object.name) ? globalThis.String(object.name) : '', + str: isSet(object.str) ? globalThis.String(object.str) : '', + }; + }, + + toJSON(message: CUsrMsgVGUIMenu_Subkey): unknown { + const obj: any = {}; + if (message.name !== '') { + obj.name = message.name; + } + if (message.str !== '') { + obj.str = message.str; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgVGUIMenu_Subkey { + return CUsrMsgVGUIMenu_Subkey.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgVGUIMenu_Subkey { + const message = createBaseCUsrMsgVGUIMenu_Subkey(); + message.name = object.name ?? ''; + message.str = object.str ?? ''; + return message; + }, +}; + +function createBaseCUsrMsgGeiger(): CUsrMsgGeiger { + return { range: 0 }; +} + +export const CUsrMsgGeiger = { + encode(message: CUsrMsgGeiger, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.range !== 0) { + writer.uint32(8).int32(message.range); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgGeiger { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgGeiger(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.range = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgGeiger { + return { range: isSet(object.range) ? globalThis.Number(object.range) : 0 }; + }, + + toJSON(message: CUsrMsgGeiger): unknown { + const obj: any = {}; + if (message.range !== 0) { + obj.range = Math.round(message.range); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgGeiger { + return CUsrMsgGeiger.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgGeiger { + const message = createBaseCUsrMsgGeiger(); + message.range = object.range ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgTrain(): CUsrMsgTrain { + return { train: 0 }; +} + +export const CUsrMsgTrain = { + encode(message: CUsrMsgTrain, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.train !== 0) { + writer.uint32(8).int32(message.train); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgTrain { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgTrain(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.train = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgTrain { + return { train: isSet(object.train) ? globalThis.Number(object.train) : 0 }; + }, + + toJSON(message: CUsrMsgTrain): unknown { + const obj: any = {}; + if (message.train !== 0) { + obj.train = Math.round(message.train); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgTrain { + return CUsrMsgTrain.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgTrain { + const message = createBaseCUsrMsgTrain(); + message.train = object.train ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgHudText(): CUsrMsgHudText { + return { text: '' }; +} + +export const CUsrMsgHudText = { + encode(message: CUsrMsgHudText, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.text !== '') { + writer.uint32(10).string(message.text); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgHudText { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgHudText(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.text = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgHudText { + return { text: isSet(object.text) ? globalThis.String(object.text) : '' }; + }, + + toJSON(message: CUsrMsgHudText): unknown { + const obj: any = {}; + if (message.text !== '') { + obj.text = message.text; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgHudText { + return CUsrMsgHudText.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgHudText { + const message = createBaseCUsrMsgHudText(); + message.text = object.text ?? ''; + return message; + }, +}; + +function createBaseCUsrMsgSayText(): CUsrMsgSayText { + return { entIdx: 0, text: '', chat: false, textallchat: false }; +} + +export const CUsrMsgSayText = { + encode(message: CUsrMsgSayText, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.entIdx !== 0) { + writer.uint32(8).int32(message.entIdx); + } + if (message.text !== '') { + writer.uint32(18).string(message.text); + } + if (message.chat === true) { + writer.uint32(24).bool(message.chat); + } + if (message.textallchat === true) { + writer.uint32(32).bool(message.textallchat); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgSayText { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgSayText(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.entIdx = reader.int32(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.text = reader.string(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.chat = reader.bool(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.textallchat = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgSayText { + return { + entIdx: isSet(object.entIdx) ? globalThis.Number(object.entIdx) : 0, + text: isSet(object.text) ? globalThis.String(object.text) : '', + chat: isSet(object.chat) ? globalThis.Boolean(object.chat) : false, + textallchat: isSet(object.textallchat) ? globalThis.Boolean(object.textallchat) : false, + }; + }, + + toJSON(message: CUsrMsgSayText): unknown { + const obj: any = {}; + if (message.entIdx !== 0) { + obj.entIdx = Math.round(message.entIdx); + } + if (message.text !== '') { + obj.text = message.text; + } + if (message.chat === true) { + obj.chat = message.chat; + } + if (message.textallchat === true) { + obj.textallchat = message.textallchat; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgSayText { + return CUsrMsgSayText.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgSayText { + const message = createBaseCUsrMsgSayText(); + message.entIdx = object.entIdx ?? 0; + message.text = object.text ?? ''; + message.chat = object.chat ?? false; + message.textallchat = object.textallchat ?? false; + return message; + }, +}; + +function createBaseCUsrMsgSayText2(): CUsrMsgSayText2 { + return { entIdx: 0, chat: false, msgName: '', params: [], textallchat: false }; +} + +export const CUsrMsgSayText2 = { + encode(message: CUsrMsgSayText2, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.entIdx !== 0) { + writer.uint32(8).int32(message.entIdx); + } + if (message.chat === true) { + writer.uint32(16).bool(message.chat); + } + if (message.msgName !== '') { + writer.uint32(26).string(message.msgName); + } + for (const v of message.params) { + writer.uint32(34).string(v!); + } + if (message.textallchat === true) { + writer.uint32(40).bool(message.textallchat); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgSayText2 { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgSayText2(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.entIdx = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.chat = reader.bool(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.msgName = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.params.push(reader.string()); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.textallchat = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgSayText2 { + return { + entIdx: isSet(object.entIdx) ? globalThis.Number(object.entIdx) : 0, + chat: isSet(object.chat) ? globalThis.Boolean(object.chat) : false, + msgName: isSet(object.msgName) ? globalThis.String(object.msgName) : '', + params: globalThis.Array.isArray(object?.params) ? object.params.map((e: any) => globalThis.String(e)) : [], + textallchat: isSet(object.textallchat) ? globalThis.Boolean(object.textallchat) : false, + }; + }, + + toJSON(message: CUsrMsgSayText2): unknown { + const obj: any = {}; + if (message.entIdx !== 0) { + obj.entIdx = Math.round(message.entIdx); + } + if (message.chat === true) { + obj.chat = message.chat; + } + if (message.msgName !== '') { + obj.msgName = message.msgName; + } + if (message.params?.length) { + obj.params = message.params; + } + if (message.textallchat === true) { + obj.textallchat = message.textallchat; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgSayText2 { + return CUsrMsgSayText2.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgSayText2 { + const message = createBaseCUsrMsgSayText2(); + message.entIdx = object.entIdx ?? 0; + message.chat = object.chat ?? false; + message.msgName = object.msgName ?? ''; + message.params = object.params?.map((e) => e) || []; + message.textallchat = object.textallchat ?? false; + return message; + }, +}; + +function createBaseCUsrMsgTextMsg(): CUsrMsgTextMsg { + return { msgDst: 0, params: [] }; +} + +export const CUsrMsgTextMsg = { + encode(message: CUsrMsgTextMsg, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.msgDst !== 0) { + writer.uint32(8).int32(message.msgDst); + } + for (const v of message.params) { + writer.uint32(26).string(v!); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgTextMsg { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgTextMsg(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.msgDst = reader.int32(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.params.push(reader.string()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgTextMsg { + return { + msgDst: isSet(object.msgDst) ? globalThis.Number(object.msgDst) : 0, + params: globalThis.Array.isArray(object?.params) ? object.params.map((e: any) => globalThis.String(e)) : [], + }; + }, + + toJSON(message: CUsrMsgTextMsg): unknown { + const obj: any = {}; + if (message.msgDst !== 0) { + obj.msgDst = Math.round(message.msgDst); + } + if (message.params?.length) { + obj.params = message.params; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgTextMsg { + return CUsrMsgTextMsg.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgTextMsg { + const message = createBaseCUsrMsgTextMsg(); + message.msgDst = object.msgDst ?? 0; + message.params = object.params?.map((e) => e) || []; + return message; + }, +}; + +function createBaseCUsrMsgHudMsg(): CUsrMsgHudMsg { + return { + channel: 0, + pos: undefined, + clr1: undefined, + clr2: undefined, + effect: 0, + fadeInTime: 0, + fadeOutTime: 0, + holdTime: 0, + fxTime: 0, + text: '', + }; +} + +export const CUsrMsgHudMsg = { + encode(message: CUsrMsgHudMsg, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.channel !== 0) { + writer.uint32(8).int32(message.channel); + } + if (message.pos !== undefined) { + CMsgVector2D.encode(message.pos, writer.uint32(18).fork()).ldelim(); + } + if (message.clr1 !== undefined) { + CMsgRGBA.encode(message.clr1, writer.uint32(26).fork()).ldelim(); + } + if (message.clr2 !== undefined) { + CMsgRGBA.encode(message.clr2, writer.uint32(34).fork()).ldelim(); + } + if (message.effect !== 0) { + writer.uint32(40).int32(message.effect); + } + if (message.fadeInTime !== 0) { + writer.uint32(53).float(message.fadeInTime); + } + if (message.fadeOutTime !== 0) { + writer.uint32(61).float(message.fadeOutTime); + } + if (message.holdTime !== 0) { + writer.uint32(77).float(message.holdTime); + } + if (message.fxTime !== 0) { + writer.uint32(85).float(message.fxTime); + } + if (message.text !== '') { + writer.uint32(90).string(message.text); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgHudMsg { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgHudMsg(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.channel = reader.int32(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.pos = CMsgVector2D.decode(reader, reader.uint32()); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.clr1 = CMsgRGBA.decode(reader, reader.uint32()); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.clr2 = CMsgRGBA.decode(reader, reader.uint32()); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.effect = reader.int32(); + continue; + case 6: + if (tag !== 53) { + break; + } + + message.fadeInTime = reader.float(); + continue; + case 7: + if (tag !== 61) { + break; + } + + message.fadeOutTime = reader.float(); + continue; + case 9: + if (tag !== 77) { + break; + } + + message.holdTime = reader.float(); + continue; + case 10: + if (tag !== 85) { + break; + } + + message.fxTime = reader.float(); + continue; + case 11: + if (tag !== 90) { + break; + } + + message.text = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgHudMsg { + return { + channel: isSet(object.channel) ? globalThis.Number(object.channel) : 0, + pos: isSet(object.pos) ? CMsgVector2D.fromJSON(object.pos) : undefined, + clr1: isSet(object.clr1) ? CMsgRGBA.fromJSON(object.clr1) : undefined, + clr2: isSet(object.clr2) ? CMsgRGBA.fromJSON(object.clr2) : undefined, + effect: isSet(object.effect) ? globalThis.Number(object.effect) : 0, + fadeInTime: isSet(object.fadeInTime) ? globalThis.Number(object.fadeInTime) : 0, + fadeOutTime: isSet(object.fadeOutTime) ? globalThis.Number(object.fadeOutTime) : 0, + holdTime: isSet(object.holdTime) ? globalThis.Number(object.holdTime) : 0, + fxTime: isSet(object.fxTime) ? globalThis.Number(object.fxTime) : 0, + text: isSet(object.text) ? globalThis.String(object.text) : '', + }; + }, + + toJSON(message: CUsrMsgHudMsg): unknown { + const obj: any = {}; + if (message.channel !== 0) { + obj.channel = Math.round(message.channel); + } + if (message.pos !== undefined) { + obj.pos = CMsgVector2D.toJSON(message.pos); + } + if (message.clr1 !== undefined) { + obj.clr1 = CMsgRGBA.toJSON(message.clr1); + } + if (message.clr2 !== undefined) { + obj.clr2 = CMsgRGBA.toJSON(message.clr2); + } + if (message.effect !== 0) { + obj.effect = Math.round(message.effect); + } + if (message.fadeInTime !== 0) { + obj.fadeInTime = message.fadeInTime; + } + if (message.fadeOutTime !== 0) { + obj.fadeOutTime = message.fadeOutTime; + } + if (message.holdTime !== 0) { + obj.holdTime = message.holdTime; + } + if (message.fxTime !== 0) { + obj.fxTime = message.fxTime; + } + if (message.text !== '') { + obj.text = message.text; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgHudMsg { + return CUsrMsgHudMsg.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgHudMsg { + const message = createBaseCUsrMsgHudMsg(); + message.channel = object.channel ?? 0; + message.pos = (object.pos !== undefined && object.pos !== null) + ? CMsgVector2D.fromPartial(object.pos) + : undefined; + message.clr1 = (object.clr1 !== undefined && object.clr1 !== null) + ? CMsgRGBA.fromPartial(object.clr1) + : undefined; + message.clr2 = (object.clr2 !== undefined && object.clr2 !== null) + ? CMsgRGBA.fromPartial(object.clr2) + : undefined; + message.effect = object.effect ?? 0; + message.fadeInTime = object.fadeInTime ?? 0; + message.fadeOutTime = object.fadeOutTime ?? 0; + message.holdTime = object.holdTime ?? 0; + message.fxTime = object.fxTime ?? 0; + message.text = object.text ?? ''; + return message; + }, +}; + +function createBaseCUsrMsgShake(): CUsrMsgShake { + return { command: 0, localAmplitude: 0, frequency: 0, duration: 0 }; +} + +export const CUsrMsgShake = { + encode(message: CUsrMsgShake, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.command !== 0) { + writer.uint32(8).int32(message.command); + } + if (message.localAmplitude !== 0) { + writer.uint32(21).float(message.localAmplitude); + } + if (message.frequency !== 0) { + writer.uint32(29).float(message.frequency); + } + if (message.duration !== 0) { + writer.uint32(37).float(message.duration); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgShake { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgShake(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.command = reader.int32(); + continue; + case 2: + if (tag !== 21) { + break; + } + + message.localAmplitude = reader.float(); + continue; + case 3: + if (tag !== 29) { + break; + } + + message.frequency = reader.float(); + continue; + case 4: + if (tag !== 37) { + break; + } + + message.duration = reader.float(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgShake { + return { + command: isSet(object.command) ? globalThis.Number(object.command) : 0, + localAmplitude: isSet(object.localAmplitude) ? globalThis.Number(object.localAmplitude) : 0, + frequency: isSet(object.frequency) ? globalThis.Number(object.frequency) : 0, + duration: isSet(object.duration) ? globalThis.Number(object.duration) : 0, + }; + }, + + toJSON(message: CUsrMsgShake): unknown { + const obj: any = {}; + if (message.command !== 0) { + obj.command = Math.round(message.command); + } + if (message.localAmplitude !== 0) { + obj.localAmplitude = message.localAmplitude; + } + if (message.frequency !== 0) { + obj.frequency = message.frequency; + } + if (message.duration !== 0) { + obj.duration = message.duration; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgShake { + return CUsrMsgShake.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgShake { + const message = createBaseCUsrMsgShake(); + message.command = object.command ?? 0; + message.localAmplitude = object.localAmplitude ?? 0; + message.frequency = object.frequency ?? 0; + message.duration = object.duration ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgFade(): CUsrMsgFade { + return { duration: 0, holdTime: 0, flags: 0, clr: undefined }; +} + +export const CUsrMsgFade = { + encode(message: CUsrMsgFade, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.duration !== 0) { + writer.uint32(8).int32(message.duration); + } + if (message.holdTime !== 0) { + writer.uint32(16).int32(message.holdTime); + } + if (message.flags !== 0) { + writer.uint32(24).int32(message.flags); + } + if (message.clr !== undefined) { + CMsgRGBA.encode(message.clr, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgFade { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgFade(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.duration = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.holdTime = reader.int32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.flags = reader.int32(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.clr = CMsgRGBA.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgFade { + return { + duration: isSet(object.duration) ? globalThis.Number(object.duration) : 0, + holdTime: isSet(object.holdTime) ? globalThis.Number(object.holdTime) : 0, + flags: isSet(object.flags) ? globalThis.Number(object.flags) : 0, + clr: isSet(object.clr) ? CMsgRGBA.fromJSON(object.clr) : undefined, + }; + }, + + toJSON(message: CUsrMsgFade): unknown { + const obj: any = {}; + if (message.duration !== 0) { + obj.duration = Math.round(message.duration); + } + if (message.holdTime !== 0) { + obj.holdTime = Math.round(message.holdTime); + } + if (message.flags !== 0) { + obj.flags = Math.round(message.flags); + } + if (message.clr !== undefined) { + obj.clr = CMsgRGBA.toJSON(message.clr); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgFade { + return CUsrMsgFade.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgFade { + const message = createBaseCUsrMsgFade(); + message.duration = object.duration ?? 0; + message.holdTime = object.holdTime ?? 0; + message.flags = object.flags ?? 0; + message.clr = (object.clr !== undefined && object.clr !== null) ? CMsgRGBA.fromPartial(object.clr) : undefined; + return message; + }, +}; + +function createBaseCUsrMsgRumble(): CUsrMsgRumble { + return { index: 0, data: 0, flags: 0 }; +} + +export const CUsrMsgRumble = { + encode(message: CUsrMsgRumble, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.index !== 0) { + writer.uint32(8).int32(message.index); + } + if (message.data !== 0) { + writer.uint32(16).int32(message.data); + } + if (message.flags !== 0) { + writer.uint32(24).int32(message.flags); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgRumble { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgRumble(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.index = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.data = reader.int32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.flags = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgRumble { + return { + index: isSet(object.index) ? globalThis.Number(object.index) : 0, + data: isSet(object.data) ? globalThis.Number(object.data) : 0, + flags: isSet(object.flags) ? globalThis.Number(object.flags) : 0, + }; + }, + + toJSON(message: CUsrMsgRumble): unknown { + const obj: any = {}; + if (message.index !== 0) { + obj.index = Math.round(message.index); + } + if (message.data !== 0) { + obj.data = Math.round(message.data); + } + if (message.flags !== 0) { + obj.flags = Math.round(message.flags); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgRumble { + return CUsrMsgRumble.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgRumble { + const message = createBaseCUsrMsgRumble(); + message.index = object.index ?? 0; + message.data = object.data ?? 0; + message.flags = object.flags ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgCloseCaption(): CUsrMsgCloseCaption { + return { hash: 0, duration: 0, fromPlayer: false }; +} + +export const CUsrMsgCloseCaption = { + encode(message: CUsrMsgCloseCaption, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.hash !== 0) { + writer.uint32(8).uint32(message.hash); + } + if (message.duration !== 0) { + writer.uint32(16).int32(message.duration); + } + if (message.fromPlayer === true) { + writer.uint32(24).bool(message.fromPlayer); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgCloseCaption { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgCloseCaption(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.hash = reader.uint32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.duration = reader.int32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.fromPlayer = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgCloseCaption { + return { + hash: isSet(object.hash) ? globalThis.Number(object.hash) : 0, + duration: isSet(object.duration) ? globalThis.Number(object.duration) : 0, + fromPlayer: isSet(object.fromPlayer) ? globalThis.Boolean(object.fromPlayer) : false, + }; + }, + + toJSON(message: CUsrMsgCloseCaption): unknown { + const obj: any = {}; + if (message.hash !== 0) { + obj.hash = Math.round(message.hash); + } + if (message.duration !== 0) { + obj.duration = Math.round(message.duration); + } + if (message.fromPlayer === true) { + obj.fromPlayer = message.fromPlayer; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgCloseCaption { + return CUsrMsgCloseCaption.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgCloseCaption { + const message = createBaseCUsrMsgCloseCaption(); + message.hash = object.hash ?? 0; + message.duration = object.duration ?? 0; + message.fromPlayer = object.fromPlayer ?? false; + return message; + }, +}; + +function createBaseCUsrMsgCloseCaptionDirect(): CUsrMsgCloseCaptionDirect { + return { hash: 0, duration: 0, fromPlayer: false }; +} + +export const CUsrMsgCloseCaptionDirect = { + encode(message: CUsrMsgCloseCaptionDirect, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.hash !== 0) { + writer.uint32(8).uint32(message.hash); + } + if (message.duration !== 0) { + writer.uint32(16).int32(message.duration); + } + if (message.fromPlayer === true) { + writer.uint32(24).bool(message.fromPlayer); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgCloseCaptionDirect { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgCloseCaptionDirect(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.hash = reader.uint32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.duration = reader.int32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.fromPlayer = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgCloseCaptionDirect { + return { + hash: isSet(object.hash) ? globalThis.Number(object.hash) : 0, + duration: isSet(object.duration) ? globalThis.Number(object.duration) : 0, + fromPlayer: isSet(object.fromPlayer) ? globalThis.Boolean(object.fromPlayer) : false, + }; + }, + + toJSON(message: CUsrMsgCloseCaptionDirect): unknown { + const obj: any = {}; + if (message.hash !== 0) { + obj.hash = Math.round(message.hash); + } + if (message.duration !== 0) { + obj.duration = Math.round(message.duration); + } + if (message.fromPlayer === true) { + obj.fromPlayer = message.fromPlayer; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgCloseCaptionDirect { + return CUsrMsgCloseCaptionDirect.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgCloseCaptionDirect { + const message = createBaseCUsrMsgCloseCaptionDirect(); + message.hash = object.hash ?? 0; + message.duration = object.duration ?? 0; + message.fromPlayer = object.fromPlayer ?? false; + return message; + }, +}; + +function createBaseCUsrMsgSendAudio(): CUsrMsgSendAudio { + return { radioSound: '' }; +} + +export const CUsrMsgSendAudio = { + encode(message: CUsrMsgSendAudio, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.radioSound !== '') { + writer.uint32(10).string(message.radioSound); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgSendAudio { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgSendAudio(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.radioSound = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgSendAudio { + return { radioSound: isSet(object.radioSound) ? globalThis.String(object.radioSound) : '' }; + }, + + toJSON(message: CUsrMsgSendAudio): unknown { + const obj: any = {}; + if (message.radioSound !== '') { + obj.radioSound = message.radioSound; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgSendAudio { + return CUsrMsgSendAudio.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgSendAudio { + const message = createBaseCUsrMsgSendAudio(); + message.radioSound = object.radioSound ?? ''; + return message; + }, +}; + +function createBaseCUsrMsgRawAudio(): CUsrMsgRawAudio { + return { pitch: 0, entidx: 0, duration: 0, voiceFilename: '' }; +} + +export const CUsrMsgRawAudio = { + encode(message: CUsrMsgRawAudio, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.pitch !== 0) { + writer.uint32(8).int32(message.pitch); + } + if (message.entidx !== 0) { + writer.uint32(16).int32(message.entidx); + } + if (message.duration !== 0) { + writer.uint32(29).float(message.duration); + } + if (message.voiceFilename !== '') { + writer.uint32(34).string(message.voiceFilename); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgRawAudio { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgRawAudio(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.pitch = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.entidx = reader.int32(); + continue; + case 3: + if (tag !== 29) { + break; + } + + message.duration = reader.float(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.voiceFilename = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgRawAudio { + return { + pitch: isSet(object.pitch) ? globalThis.Number(object.pitch) : 0, + entidx: isSet(object.entidx) ? globalThis.Number(object.entidx) : 0, + duration: isSet(object.duration) ? globalThis.Number(object.duration) : 0, + voiceFilename: isSet(object.voiceFilename) ? globalThis.String(object.voiceFilename) : '', + }; + }, + + toJSON(message: CUsrMsgRawAudio): unknown { + const obj: any = {}; + if (message.pitch !== 0) { + obj.pitch = Math.round(message.pitch); + } + if (message.entidx !== 0) { + obj.entidx = Math.round(message.entidx); + } + if (message.duration !== 0) { + obj.duration = message.duration; + } + if (message.voiceFilename !== '') { + obj.voiceFilename = message.voiceFilename; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgRawAudio { + return CUsrMsgRawAudio.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgRawAudio { + const message = createBaseCUsrMsgRawAudio(); + message.pitch = object.pitch ?? 0; + message.entidx = object.entidx ?? 0; + message.duration = object.duration ?? 0; + message.voiceFilename = object.voiceFilename ?? ''; + return message; + }, +}; + +function createBaseCUsrMsgVoiceMask(): CUsrMsgVoiceMask { + return { playerMasks: [], playerModEnable: false }; +} + +export const CUsrMsgVoiceMask = { + encode(message: CUsrMsgVoiceMask, writer: pb.Writer = pb.Writer.create()): pb.Writer { + for (const v of message.playerMasks) { + CUsrMsgVoiceMask_PlayerMask.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.playerModEnable === true) { + writer.uint32(16).bool(message.playerModEnable); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgVoiceMask { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgVoiceMask(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.playerMasks.push(CUsrMsgVoiceMask_PlayerMask.decode(reader, reader.uint32())); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.playerModEnable = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgVoiceMask { + return { + playerMasks: globalThis.Array.isArray(object?.playerMasks) + ? object.playerMasks.map((e: any) => CUsrMsgVoiceMask_PlayerMask.fromJSON(e)) + : [], + playerModEnable: isSet(object.playerModEnable) ? globalThis.Boolean(object.playerModEnable) : false, + }; + }, + + toJSON(message: CUsrMsgVoiceMask): unknown { + const obj: any = {}; + if (message.playerMasks?.length) { + obj.playerMasks = message.playerMasks.map((e) => CUsrMsgVoiceMask_PlayerMask.toJSON(e)); + } + if (message.playerModEnable === true) { + obj.playerModEnable = message.playerModEnable; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgVoiceMask { + return CUsrMsgVoiceMask.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgVoiceMask { + const message = createBaseCUsrMsgVoiceMask(); + message.playerMasks = object.playerMasks?.map((e) => CUsrMsgVoiceMask_PlayerMask.fromPartial(e)) || []; + message.playerModEnable = object.playerModEnable ?? false; + return message; + }, +}; + +function createBaseCUsrMsgVoiceMask_PlayerMask(): CUsrMsgVoiceMask_PlayerMask { + return { gameRulesMask: 0, banMasks: 0 }; +} + +export const CUsrMsgVoiceMask_PlayerMask = { + encode(message: CUsrMsgVoiceMask_PlayerMask, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.gameRulesMask !== 0) { + writer.uint32(8).uint64(message.gameRulesMask); + } + if (message.banMasks !== 0) { + writer.uint32(16).uint64(message.banMasks); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgVoiceMask_PlayerMask { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgVoiceMask_PlayerMask(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.gameRulesMask = longToNumber(reader.uint64() as Long); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.banMasks = longToNumber(reader.uint64() as Long); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgVoiceMask_PlayerMask { + return { + gameRulesMask: isSet(object.gameRulesMask) ? globalThis.Number(object.gameRulesMask) : 0, + banMasks: isSet(object.banMasks) ? globalThis.Number(object.banMasks) : 0, + }; + }, + + toJSON(message: CUsrMsgVoiceMask_PlayerMask): unknown { + const obj: any = {}; + if (message.gameRulesMask !== 0) { + obj.gameRulesMask = Math.round(message.gameRulesMask); + } + if (message.banMasks !== 0) { + obj.banMasks = Math.round(message.banMasks); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgVoiceMask_PlayerMask { + return CUsrMsgVoiceMask_PlayerMask.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgVoiceMask_PlayerMask { + const message = createBaseCUsrMsgVoiceMask_PlayerMask(); + message.gameRulesMask = object.gameRulesMask ?? 0; + message.banMasks = object.banMasks ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgDamage(): CUsrMsgDamage { + return { amount: 0, inflictorWorldPos: undefined, victimEntindex: 0, amountMin: 0, amountMax: 0 }; +} + +export const CUsrMsgDamage = { + encode(message: CUsrMsgDamage, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.amount !== 0) { + writer.uint32(8).int32(message.amount); + } + if (message.inflictorWorldPos !== undefined) { + CMsgVector.encode(message.inflictorWorldPos, writer.uint32(18).fork()).ldelim(); + } + if (message.victimEntindex !== 0) { + writer.uint32(24).int32(message.victimEntindex); + } + if (message.amountMin !== 0) { + writer.uint32(32).int32(message.amountMin); + } + if (message.amountMax !== 0) { + writer.uint32(40).int32(message.amountMax); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgDamage { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgDamage(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.amount = reader.int32(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.inflictorWorldPos = CMsgVector.decode(reader, reader.uint32()); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.victimEntindex = reader.int32(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.amountMin = reader.int32(); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.amountMax = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgDamage { + return { + amount: isSet(object.amount) ? globalThis.Number(object.amount) : 0, + inflictorWorldPos: isSet(object.inflictorWorldPos) + ? CMsgVector.fromJSON(object.inflictorWorldPos) + : undefined, + victimEntindex: isSet(object.victimEntindex) ? globalThis.Number(object.victimEntindex) : 0, + amountMin: isSet(object.amountMin) ? globalThis.Number(object.amountMin) : 0, + amountMax: isSet(object.amountMax) ? globalThis.Number(object.amountMax) : 0, + }; + }, + + toJSON(message: CUsrMsgDamage): unknown { + const obj: any = {}; + if (message.amount !== 0) { + obj.amount = Math.round(message.amount); + } + if (message.inflictorWorldPos !== undefined) { + obj.inflictorWorldPos = CMsgVector.toJSON(message.inflictorWorldPos); + } + if (message.victimEntindex !== 0) { + obj.victimEntindex = Math.round(message.victimEntindex); + } + if (message.amountMin !== 0) { + obj.amountMin = Math.round(message.amountMin); + } + if (message.amountMax !== 0) { + obj.amountMax = Math.round(message.amountMax); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgDamage { + return CUsrMsgDamage.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgDamage { + const message = createBaseCUsrMsgDamage(); + message.amount = object.amount ?? 0; + message.inflictorWorldPos = (object.inflictorWorldPos !== undefined && object.inflictorWorldPos !== null) + ? CMsgVector.fromPartial(object.inflictorWorldPos) + : undefined; + message.victimEntindex = object.victimEntindex ?? 0; + message.amountMin = object.amountMin ?? 0; + message.amountMax = object.amountMax ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgRadioText(): CUsrMsgRadioText { + return { msgDst: 0, client: 0, msgName: '', params: [] }; +} + +export const CUsrMsgRadioText = { + encode(message: CUsrMsgRadioText, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.msgDst !== 0) { + writer.uint32(8).int32(message.msgDst); + } + if (message.client !== 0) { + writer.uint32(16).int32(message.client); + } + if (message.msgName !== '') { + writer.uint32(26).string(message.msgName); + } + for (const v of message.params) { + writer.uint32(34).string(v!); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgRadioText { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgRadioText(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.msgDst = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.client = reader.int32(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.msgName = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.params.push(reader.string()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgRadioText { + return { + msgDst: isSet(object.msgDst) ? globalThis.Number(object.msgDst) : 0, + client: isSet(object.client) ? globalThis.Number(object.client) : 0, + msgName: isSet(object.msgName) ? globalThis.String(object.msgName) : '', + params: globalThis.Array.isArray(object?.params) ? object.params.map((e: any) => globalThis.String(e)) : [], + }; + }, + + toJSON(message: CUsrMsgRadioText): unknown { + const obj: any = {}; + if (message.msgDst !== 0) { + obj.msgDst = Math.round(message.msgDst); + } + if (message.client !== 0) { + obj.client = Math.round(message.client); + } + if (message.msgName !== '') { + obj.msgName = message.msgName; + } + if (message.params?.length) { + obj.params = message.params; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgRadioText { + return CUsrMsgRadioText.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgRadioText { + const message = createBaseCUsrMsgRadioText(); + message.msgDst = object.msgDst ?? 0; + message.client = object.client ?? 0; + message.msgName = object.msgName ?? ''; + message.params = object.params?.map((e) => e) || []; + return message; + }, +}; + +function createBaseCUsrMsgHintText(): CUsrMsgHintText { + return { text: '' }; +} + +export const CUsrMsgHintText = { + encode(message: CUsrMsgHintText, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.text !== '') { + writer.uint32(10).string(message.text); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgHintText { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgHintText(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.text = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgHintText { + return { text: isSet(object.text) ? globalThis.String(object.text) : '' }; + }, + + toJSON(message: CUsrMsgHintText): unknown { + const obj: any = {}; + if (message.text !== '') { + obj.text = message.text; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgHintText { + return CUsrMsgHintText.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgHintText { + const message = createBaseCUsrMsgHintText(); + message.text = object.text ?? ''; + return message; + }, +}; + +function createBaseCUsrMsgKeyHintText(): CUsrMsgKeyHintText { + return { hints: [] }; +} + +export const CUsrMsgKeyHintText = { + encode(message: CUsrMsgKeyHintText, writer: pb.Writer = pb.Writer.create()): pb.Writer { + for (const v of message.hints) { + writer.uint32(10).string(v!); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgKeyHintText { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgKeyHintText(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.hints.push(reader.string()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgKeyHintText { + return { + hints: globalThis.Array.isArray(object?.hints) ? object.hints.map((e: any) => globalThis.String(e)) : [], + }; + }, + + toJSON(message: CUsrMsgKeyHintText): unknown { + const obj: any = {}; + if (message.hints?.length) { + obj.hints = message.hints; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgKeyHintText { + return CUsrMsgKeyHintText.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgKeyHintText { + const message = createBaseCUsrMsgKeyHintText(); + message.hints = object.hints?.map((e) => e) || []; + return message; + }, +}; + +function createBaseCUsrMsgWeaponSound(): CUsrMsgWeaponSound { + return { entidx: 0, originX: 0, originY: 0, originZ: 0, sound: '', timestamp: 0 }; +} + +export const CUsrMsgWeaponSound = { + encode(message: CUsrMsgWeaponSound, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.entidx !== 0) { + writer.uint32(8).int32(message.entidx); + } + if (message.originX !== 0) { + writer.uint32(21).float(message.originX); + } + if (message.originY !== 0) { + writer.uint32(29).float(message.originY); + } + if (message.originZ !== 0) { + writer.uint32(37).float(message.originZ); + } + if (message.sound !== '') { + writer.uint32(42).string(message.sound); + } + if (message.timestamp !== 0) { + writer.uint32(53).float(message.timestamp); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgWeaponSound { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgWeaponSound(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.entidx = reader.int32(); + continue; + case 2: + if (tag !== 21) { + break; + } + + message.originX = reader.float(); + continue; + case 3: + if (tag !== 29) { + break; + } + + message.originY = reader.float(); + continue; + case 4: + if (tag !== 37) { + break; + } + + message.originZ = reader.float(); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.sound = reader.string(); + continue; + case 6: + if (tag !== 53) { + break; + } + + message.timestamp = reader.float(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgWeaponSound { + return { + entidx: isSet(object.entidx) ? globalThis.Number(object.entidx) : 0, + originX: isSet(object.originX) ? globalThis.Number(object.originX) : 0, + originY: isSet(object.originY) ? globalThis.Number(object.originY) : 0, + originZ: isSet(object.originZ) ? globalThis.Number(object.originZ) : 0, + sound: isSet(object.sound) ? globalThis.String(object.sound) : '', + timestamp: isSet(object.timestamp) ? globalThis.Number(object.timestamp) : 0, + }; + }, + + toJSON(message: CUsrMsgWeaponSound): unknown { + const obj: any = {}; + if (message.entidx !== 0) { + obj.entidx = Math.round(message.entidx); + } + if (message.originX !== 0) { + obj.originX = message.originX; + } + if (message.originY !== 0) { + obj.originY = message.originY; + } + if (message.originZ !== 0) { + obj.originZ = message.originZ; + } + if (message.sound !== '') { + obj.sound = message.sound; + } + if (message.timestamp !== 0) { + obj.timestamp = message.timestamp; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgWeaponSound { + return CUsrMsgWeaponSound.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgWeaponSound { + const message = createBaseCUsrMsgWeaponSound(); + message.entidx = object.entidx ?? 0; + message.originX = object.originX ?? 0; + message.originY = object.originY ?? 0; + message.originZ = object.originZ ?? 0; + message.sound = object.sound ?? ''; + message.timestamp = object.timestamp ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgUpdateScreenHealthBar(): CUsrMsgUpdateScreenHealthBar { + return { entidx: 0, healthratioOld: 0, healthratioNew: 0, style: 0 }; +} + +export const CUsrMsgUpdateScreenHealthBar = { + encode(message: CUsrMsgUpdateScreenHealthBar, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.entidx !== 0) { + writer.uint32(8).int32(message.entidx); + } + if (message.healthratioOld !== 0) { + writer.uint32(21).float(message.healthratioOld); + } + if (message.healthratioNew !== 0) { + writer.uint32(29).float(message.healthratioNew); + } + if (message.style !== 0) { + writer.uint32(32).int32(message.style); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgUpdateScreenHealthBar { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgUpdateScreenHealthBar(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.entidx = reader.int32(); + continue; + case 2: + if (tag !== 21) { + break; + } + + message.healthratioOld = reader.float(); + continue; + case 3: + if (tag !== 29) { + break; + } + + message.healthratioNew = reader.float(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.style = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgUpdateScreenHealthBar { + return { + entidx: isSet(object.entidx) ? globalThis.Number(object.entidx) : 0, + healthratioOld: isSet(object.healthratioOld) ? globalThis.Number(object.healthratioOld) : 0, + healthratioNew: isSet(object.healthratioNew) ? globalThis.Number(object.healthratioNew) : 0, + style: isSet(object.style) ? globalThis.Number(object.style) : 0, + }; + }, + + toJSON(message: CUsrMsgUpdateScreenHealthBar): unknown { + const obj: any = {}; + if (message.entidx !== 0) { + obj.entidx = Math.round(message.entidx); + } + if (message.healthratioOld !== 0) { + obj.healthratioOld = message.healthratioOld; + } + if (message.healthratioNew !== 0) { + obj.healthratioNew = message.healthratioNew; + } + if (message.style !== 0) { + obj.style = Math.round(message.style); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgUpdateScreenHealthBar { + return CUsrMsgUpdateScreenHealthBar.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): CUsrMsgUpdateScreenHealthBar { + const message = createBaseCUsrMsgUpdateScreenHealthBar(); + message.entidx = object.entidx ?? 0; + message.healthratioOld = object.healthratioOld ?? 0; + message.healthratioNew = object.healthratioNew ?? 0; + message.style = object.style ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgEntityOutlineHighlight(): CUsrMsgEntityOutlineHighlight { + return { entidx: 0 }; +} + +export const CUsrMsgEntityOutlineHighlight = { + encode(message: CUsrMsgEntityOutlineHighlight, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.entidx !== 0) { + writer.uint32(8).int32(message.entidx); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgEntityOutlineHighlight { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgEntityOutlineHighlight(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.entidx = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgEntityOutlineHighlight { + return { entidx: isSet(object.entidx) ? globalThis.Number(object.entidx) : 0 }; + }, + + toJSON(message: CUsrMsgEntityOutlineHighlight): unknown { + const obj: any = {}; + if (message.entidx !== 0) { + obj.entidx = Math.round(message.entidx); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgEntityOutlineHighlight { + return CUsrMsgEntityOutlineHighlight.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): CUsrMsgEntityOutlineHighlight { + const message = createBaseCUsrMsgEntityOutlineHighlight(); + message.entidx = object.entidx ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgDesiredTimescale(): CUsrMsgDesiredTimescale { + return { desiredTimescale: 0, durationRealtimeSec: 0, interpolatorType: 0, startBlendTime: 0 }; +} + +export const CUsrMsgDesiredTimescale = { + encode(message: CUsrMsgDesiredTimescale, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.desiredTimescale !== 0) { + writer.uint32(13).float(message.desiredTimescale); + } + if (message.durationRealtimeSec !== 0) { + writer.uint32(21).float(message.durationRealtimeSec); + } + if (message.interpolatorType !== 0) { + writer.uint32(24).int32(message.interpolatorType); + } + if (message.startBlendTime !== 0) { + writer.uint32(37).float(message.startBlendTime); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgDesiredTimescale { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgDesiredTimescale(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 13) { + break; + } + + message.desiredTimescale = reader.float(); + continue; + case 2: + if (tag !== 21) { + break; + } + + message.durationRealtimeSec = reader.float(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.interpolatorType = reader.int32(); + continue; + case 4: + if (tag !== 37) { + break; + } + + message.startBlendTime = reader.float(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgDesiredTimescale { + return { + desiredTimescale: isSet(object.desiredTimescale) ? globalThis.Number(object.desiredTimescale) : 0, + durationRealtimeSec: isSet(object.durationRealtimeSec) ? globalThis.Number(object.durationRealtimeSec) : 0, + interpolatorType: isSet(object.interpolatorType) ? globalThis.Number(object.interpolatorType) : 0, + startBlendTime: isSet(object.startBlendTime) ? globalThis.Number(object.startBlendTime) : 0, + }; + }, + + toJSON(message: CUsrMsgDesiredTimescale): unknown { + const obj: any = {}; + if (message.desiredTimescale !== 0) { + obj.desiredTimescale = message.desiredTimescale; + } + if (message.durationRealtimeSec !== 0) { + obj.durationRealtimeSec = message.durationRealtimeSec; + } + if (message.interpolatorType !== 0) { + obj.interpolatorType = Math.round(message.interpolatorType); + } + if (message.startBlendTime !== 0) { + obj.startBlendTime = message.startBlendTime; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgDesiredTimescale { + return CUsrMsgDesiredTimescale.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgDesiredTimescale { + const message = createBaseCUsrMsgDesiredTimescale(); + message.desiredTimescale = object.desiredTimescale ?? 0; + message.durationRealtimeSec = object.durationRealtimeSec ?? 0; + message.interpolatorType = object.interpolatorType ?? 0; + message.startBlendTime = object.startBlendTime ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgCurrentTimescale(): CUsrMsgCurrentTimescale { + return { curTimescale: 0 }; +} + +export const CUsrMsgCurrentTimescale = { + encode(message: CUsrMsgCurrentTimescale, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.curTimescale !== 0) { + writer.uint32(13).float(message.curTimescale); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgCurrentTimescale { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgCurrentTimescale(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 13) { + break; + } + + message.curTimescale = reader.float(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgCurrentTimescale { + return { curTimescale: isSet(object.curTimescale) ? globalThis.Number(object.curTimescale) : 0 }; + }, + + toJSON(message: CUsrMsgCurrentTimescale): unknown { + const obj: any = {}; + if (message.curTimescale !== 0) { + obj.curTimescale = message.curTimescale; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgCurrentTimescale { + return CUsrMsgCurrentTimescale.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgCurrentTimescale { + const message = createBaseCUsrMsgCurrentTimescale(); + message.curTimescale = object.curTimescale ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgAchievementEvent(): CUsrMsgAchievementEvent { + return { achievement: 0, count: 0, userId: 0 }; +} + +export const CUsrMsgAchievementEvent = { + encode(message: CUsrMsgAchievementEvent, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.achievement !== 0) { + writer.uint32(8).int32(message.achievement); + } + if (message.count !== 0) { + writer.uint32(16).int32(message.count); + } + if (message.userId !== 0) { + writer.uint32(24).int32(message.userId); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgAchievementEvent { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgAchievementEvent(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.achievement = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.count = reader.int32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.userId = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgAchievementEvent { + return { + achievement: isSet(object.achievement) ? globalThis.Number(object.achievement) : 0, + count: isSet(object.count) ? globalThis.Number(object.count) : 0, + userId: isSet(object.userId) ? globalThis.Number(object.userId) : 0, + }; + }, + + toJSON(message: CUsrMsgAchievementEvent): unknown { + const obj: any = {}; + if (message.achievement !== 0) { + obj.achievement = Math.round(message.achievement); + } + if (message.count !== 0) { + obj.count = Math.round(message.count); + } + if (message.userId !== 0) { + obj.userId = Math.round(message.userId); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgAchievementEvent { + return CUsrMsgAchievementEvent.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgAchievementEvent { + const message = createBaseCUsrMsgAchievementEvent(); + message.achievement = object.achievement ?? 0; + message.count = object.count ?? 0; + message.userId = object.userId ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgPlayerStatsUpdate(): CUsrMsgPlayerStatsUpdate { + return { version: 0, stats: [], userId: 0, crc: 0 }; +} + +export const CUsrMsgPlayerStatsUpdate = { + encode(message: CUsrMsgPlayerStatsUpdate, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.version !== 0) { + writer.uint32(8).int32(message.version); + } + for (const v of message.stats) { + CUsrMsgPlayerStatsUpdate_Stat.encode(v!, writer.uint32(34).fork()).ldelim(); + } + if (message.userId !== 0) { + writer.uint32(40).int32(message.userId); + } + if (message.crc !== 0) { + writer.uint32(48).int32(message.crc); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgPlayerStatsUpdate { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgPlayerStatsUpdate(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.version = reader.int32(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.stats.push(CUsrMsgPlayerStatsUpdate_Stat.decode(reader, reader.uint32())); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.userId = reader.int32(); + continue; + case 6: + if (tag !== 48) { + break; + } + + message.crc = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgPlayerStatsUpdate { + return { + version: isSet(object.version) ? globalThis.Number(object.version) : 0, + stats: globalThis.Array.isArray(object?.stats) + ? object.stats.map((e: any) => CUsrMsgPlayerStatsUpdate_Stat.fromJSON(e)) + : [], + userId: isSet(object.userId) ? globalThis.Number(object.userId) : 0, + crc: isSet(object.crc) ? globalThis.Number(object.crc) : 0, + }; + }, + + toJSON(message: CUsrMsgPlayerStatsUpdate): unknown { + const obj: any = {}; + if (message.version !== 0) { + obj.version = Math.round(message.version); + } + if (message.stats?.length) { + obj.stats = message.stats.map((e) => CUsrMsgPlayerStatsUpdate_Stat.toJSON(e)); + } + if (message.userId !== 0) { + obj.userId = Math.round(message.userId); + } + if (message.crc !== 0) { + obj.crc = Math.round(message.crc); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgPlayerStatsUpdate { + return CUsrMsgPlayerStatsUpdate.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgPlayerStatsUpdate { + const message = createBaseCUsrMsgPlayerStatsUpdate(); + message.version = object.version ?? 0; + message.stats = object.stats?.map((e) => CUsrMsgPlayerStatsUpdate_Stat.fromPartial(e)) || []; + message.userId = object.userId ?? 0; + message.crc = object.crc ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgPlayerStatsUpdate_Stat(): CUsrMsgPlayerStatsUpdate_Stat { + return { idx: 0, delta: 0 }; +} + +export const CUsrMsgPlayerStatsUpdate_Stat = { + encode(message: CUsrMsgPlayerStatsUpdate_Stat, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.idx !== 0) { + writer.uint32(8).int32(message.idx); + } + if (message.delta !== 0) { + writer.uint32(16).int32(message.delta); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgPlayerStatsUpdate_Stat { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgPlayerStatsUpdate_Stat(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.idx = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.delta = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgPlayerStatsUpdate_Stat { + return { + idx: isSet(object.idx) ? globalThis.Number(object.idx) : 0, + delta: isSet(object.delta) ? globalThis.Number(object.delta) : 0, + }; + }, + + toJSON(message: CUsrMsgPlayerStatsUpdate_Stat): unknown { + const obj: any = {}; + if (message.idx !== 0) { + obj.idx = Math.round(message.idx); + } + if (message.delta !== 0) { + obj.delta = Math.round(message.delta); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgPlayerStatsUpdate_Stat { + return CUsrMsgPlayerStatsUpdate_Stat.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): CUsrMsgPlayerStatsUpdate_Stat { + const message = createBaseCUsrMsgPlayerStatsUpdate_Stat(); + message.idx = object.idx ?? 0; + message.delta = object.delta ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgCallVoteFailed(): CUsrMsgCallVoteFailed { + return { reason: 0, time: 0 }; +} + +export const CUsrMsgCallVoteFailed = { + encode(message: CUsrMsgCallVoteFailed, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.reason !== 0) { + writer.uint32(8).int32(message.reason); + } + if (message.time !== 0) { + writer.uint32(16).int32(message.time); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgCallVoteFailed { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgCallVoteFailed(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.reason = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.time = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgCallVoteFailed { + return { + reason: isSet(object.reason) ? globalThis.Number(object.reason) : 0, + time: isSet(object.time) ? globalThis.Number(object.time) : 0, + }; + }, + + toJSON(message: CUsrMsgCallVoteFailed): unknown { + const obj: any = {}; + if (message.reason !== 0) { + obj.reason = Math.round(message.reason); + } + if (message.time !== 0) { + obj.time = Math.round(message.time); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgCallVoteFailed { + return CUsrMsgCallVoteFailed.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgCallVoteFailed { + const message = createBaseCUsrMsgCallVoteFailed(); + message.reason = object.reason ?? 0; + message.time = object.time ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgVoteStart(): CUsrMsgVoteStart { + return { team: 0, entIdx: 0, voteType: 0, dispStr: '', detailsStr: '', otherTeamStr: '', isYesNoVote: false }; +} + +export const CUsrMsgVoteStart = { + encode(message: CUsrMsgVoteStart, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.team !== 0) { + writer.uint32(8).int32(message.team); + } + if (message.entIdx !== 0) { + writer.uint32(16).int32(message.entIdx); + } + if (message.voteType !== 0) { + writer.uint32(24).int32(message.voteType); + } + if (message.dispStr !== '') { + writer.uint32(34).string(message.dispStr); + } + if (message.detailsStr !== '') { + writer.uint32(42).string(message.detailsStr); + } + if (message.otherTeamStr !== '') { + writer.uint32(50).string(message.otherTeamStr); + } + if (message.isYesNoVote === true) { + writer.uint32(56).bool(message.isYesNoVote); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgVoteStart { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgVoteStart(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.team = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.entIdx = reader.int32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.voteType = reader.int32(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.dispStr = reader.string(); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.detailsStr = reader.string(); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.otherTeamStr = reader.string(); + continue; + case 7: + if (tag !== 56) { + break; + } + + message.isYesNoVote = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgVoteStart { + return { + team: isSet(object.team) ? globalThis.Number(object.team) : 0, + entIdx: isSet(object.entIdx) ? globalThis.Number(object.entIdx) : 0, + voteType: isSet(object.voteType) ? globalThis.Number(object.voteType) : 0, + dispStr: isSet(object.dispStr) ? globalThis.String(object.dispStr) : '', + detailsStr: isSet(object.detailsStr) ? globalThis.String(object.detailsStr) : '', + otherTeamStr: isSet(object.otherTeamStr) ? globalThis.String(object.otherTeamStr) : '', + isYesNoVote: isSet(object.isYesNoVote) ? globalThis.Boolean(object.isYesNoVote) : false, + }; + }, + + toJSON(message: CUsrMsgVoteStart): unknown { + const obj: any = {}; + if (message.team !== 0) { + obj.team = Math.round(message.team); + } + if (message.entIdx !== 0) { + obj.entIdx = Math.round(message.entIdx); + } + if (message.voteType !== 0) { + obj.voteType = Math.round(message.voteType); + } + if (message.dispStr !== '') { + obj.dispStr = message.dispStr; + } + if (message.detailsStr !== '') { + obj.detailsStr = message.detailsStr; + } + if (message.otherTeamStr !== '') { + obj.otherTeamStr = message.otherTeamStr; + } + if (message.isYesNoVote === true) { + obj.isYesNoVote = message.isYesNoVote; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgVoteStart { + return CUsrMsgVoteStart.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgVoteStart { + const message = createBaseCUsrMsgVoteStart(); + message.team = object.team ?? 0; + message.entIdx = object.entIdx ?? 0; + message.voteType = object.voteType ?? 0; + message.dispStr = object.dispStr ?? ''; + message.detailsStr = object.detailsStr ?? ''; + message.otherTeamStr = object.otherTeamStr ?? ''; + message.isYesNoVote = object.isYesNoVote ?? false; + return message; + }, +}; + +function createBaseCUsrMsgVotePass(): CUsrMsgVotePass { + return { team: 0, voteType: 0, dispStr: '', detailsStr: '' }; +} + +export const CUsrMsgVotePass = { + encode(message: CUsrMsgVotePass, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.team !== 0) { + writer.uint32(8).int32(message.team); + } + if (message.voteType !== 0) { + writer.uint32(16).int32(message.voteType); + } + if (message.dispStr !== '') { + writer.uint32(26).string(message.dispStr); + } + if (message.detailsStr !== '') { + writer.uint32(34).string(message.detailsStr); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgVotePass { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgVotePass(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.team = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.voteType = reader.int32(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.dispStr = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.detailsStr = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgVotePass { + return { + team: isSet(object.team) ? globalThis.Number(object.team) : 0, + voteType: isSet(object.voteType) ? globalThis.Number(object.voteType) : 0, + dispStr: isSet(object.dispStr) ? globalThis.String(object.dispStr) : '', + detailsStr: isSet(object.detailsStr) ? globalThis.String(object.detailsStr) : '', + }; + }, + + toJSON(message: CUsrMsgVotePass): unknown { + const obj: any = {}; + if (message.team !== 0) { + obj.team = Math.round(message.team); + } + if (message.voteType !== 0) { + obj.voteType = Math.round(message.voteType); + } + if (message.dispStr !== '') { + obj.dispStr = message.dispStr; + } + if (message.detailsStr !== '') { + obj.detailsStr = message.detailsStr; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgVotePass { + return CUsrMsgVotePass.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgVotePass { + const message = createBaseCUsrMsgVotePass(); + message.team = object.team ?? 0; + message.voteType = object.voteType ?? 0; + message.dispStr = object.dispStr ?? ''; + message.detailsStr = object.detailsStr ?? ''; + return message; + }, +}; + +function createBaseCUsrMsgVoteFailed(): CUsrMsgVoteFailed { + return { team: 0, reason: 0 }; +} + +export const CUsrMsgVoteFailed = { + encode(message: CUsrMsgVoteFailed, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.team !== 0) { + writer.uint32(8).int32(message.team); + } + if (message.reason !== 0) { + writer.uint32(16).int32(message.reason); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgVoteFailed { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgVoteFailed(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.team = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.reason = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgVoteFailed { + return { + team: isSet(object.team) ? globalThis.Number(object.team) : 0, + reason: isSet(object.reason) ? globalThis.Number(object.reason) : 0, + }; + }, + + toJSON(message: CUsrMsgVoteFailed): unknown { + const obj: any = {}; + if (message.team !== 0) { + obj.team = Math.round(message.team); + } + if (message.reason !== 0) { + obj.reason = Math.round(message.reason); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgVoteFailed { + return CUsrMsgVoteFailed.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgVoteFailed { + const message = createBaseCUsrMsgVoteFailed(); + message.team = object.team ?? 0; + message.reason = object.reason ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgVoteSetup(): CUsrMsgVoteSetup { + return { potentialIssues: [] }; +} + +export const CUsrMsgVoteSetup = { + encode(message: CUsrMsgVoteSetup, writer: pb.Writer = pb.Writer.create()): pb.Writer { + for (const v of message.potentialIssues) { + writer.uint32(10).string(v!); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgVoteSetup { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgVoteSetup(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.potentialIssues.push(reader.string()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgVoteSetup { + return { + potentialIssues: globalThis.Array.isArray(object?.potentialIssues) + ? object.potentialIssues.map((e: any) => globalThis.String(e)) + : [], + }; + }, + + toJSON(message: CUsrMsgVoteSetup): unknown { + const obj: any = {}; + if (message.potentialIssues?.length) { + obj.potentialIssues = message.potentialIssues; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgVoteSetup { + return CUsrMsgVoteSetup.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgVoteSetup { + const message = createBaseCUsrMsgVoteSetup(); + message.potentialIssues = object.potentialIssues?.map((e) => e) || []; + return message; + }, +}; + +function createBaseCUsrMsgSendLastKillerDamageToClient(): CUsrMsgSendLastKillerDamageToClient { + return { numHitsGiven: 0, damageGiven: 0, numHitsTaken: 0, damageTaken: 0 }; +} + +export const CUsrMsgSendLastKillerDamageToClient = { + encode(message: CUsrMsgSendLastKillerDamageToClient, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.numHitsGiven !== 0) { + writer.uint32(8).int32(message.numHitsGiven); + } + if (message.damageGiven !== 0) { + writer.uint32(16).int32(message.damageGiven); + } + if (message.numHitsTaken !== 0) { + writer.uint32(24).int32(message.numHitsTaken); + } + if (message.damageTaken !== 0) { + writer.uint32(32).int32(message.damageTaken); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgSendLastKillerDamageToClient { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgSendLastKillerDamageToClient(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.numHitsGiven = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.damageGiven = reader.int32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.numHitsTaken = reader.int32(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.damageTaken = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgSendLastKillerDamageToClient { + return { + numHitsGiven: isSet(object.numHitsGiven) ? globalThis.Number(object.numHitsGiven) : 0, + damageGiven: isSet(object.damageGiven) ? globalThis.Number(object.damageGiven) : 0, + numHitsTaken: isSet(object.numHitsTaken) ? globalThis.Number(object.numHitsTaken) : 0, + damageTaken: isSet(object.damageTaken) ? globalThis.Number(object.damageTaken) : 0, + }; + }, + + toJSON(message: CUsrMsgSendLastKillerDamageToClient): unknown { + const obj: any = {}; + if (message.numHitsGiven !== 0) { + obj.numHitsGiven = Math.round(message.numHitsGiven); + } + if (message.damageGiven !== 0) { + obj.damageGiven = Math.round(message.damageGiven); + } + if (message.numHitsTaken !== 0) { + obj.numHitsTaken = Math.round(message.numHitsTaken); + } + if (message.damageTaken !== 0) { + obj.damageTaken = Math.round(message.damageTaken); + } + return obj; + }, + + create, I>>( + base?: I, + ): CUsrMsgSendLastKillerDamageToClient { + return CUsrMsgSendLastKillerDamageToClient.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): CUsrMsgSendLastKillerDamageToClient { + const message = createBaseCUsrMsgSendLastKillerDamageToClient(); + message.numHitsGiven = object.numHitsGiven ?? 0; + message.damageGiven = object.damageGiven ?? 0; + message.numHitsTaken = object.numHitsTaken ?? 0; + message.damageTaken = object.damageTaken ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgItemPickup(): CUsrMsgItemPickup { + return { item: '' }; +} + +export const CUsrMsgItemPickup = { + encode(message: CUsrMsgItemPickup, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.item !== '') { + writer.uint32(10).string(message.item); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgItemPickup { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgItemPickup(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.item = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgItemPickup { + return { item: isSet(object.item) ? globalThis.String(object.item) : '' }; + }, + + toJSON(message: CUsrMsgItemPickup): unknown { + const obj: any = {}; + if (message.item !== '') { + obj.item = message.item; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgItemPickup { + return CUsrMsgItemPickup.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgItemPickup { + const message = createBaseCUsrMsgItemPickup(); + message.item = object.item ?? ''; + return message; + }, +}; + +function createBaseCUsrMsgShowMenu(): CUsrMsgShowMenu { + return { bitsValidSlots: 0, displayTime: 0, menuString: '' }; +} + +export const CUsrMsgShowMenu = { + encode(message: CUsrMsgShowMenu, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.bitsValidSlots !== 0) { + writer.uint32(8).int32(message.bitsValidSlots); + } + if (message.displayTime !== 0) { + writer.uint32(16).int32(message.displayTime); + } + if (message.menuString !== '') { + writer.uint32(26).string(message.menuString); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgShowMenu { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgShowMenu(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.bitsValidSlots = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.displayTime = reader.int32(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.menuString = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgShowMenu { + return { + bitsValidSlots: isSet(object.bitsValidSlots) ? globalThis.Number(object.bitsValidSlots) : 0, + displayTime: isSet(object.displayTime) ? globalThis.Number(object.displayTime) : 0, + menuString: isSet(object.menuString) ? globalThis.String(object.menuString) : '', + }; + }, + + toJSON(message: CUsrMsgShowMenu): unknown { + const obj: any = {}; + if (message.bitsValidSlots !== 0) { + obj.bitsValidSlots = Math.round(message.bitsValidSlots); + } + if (message.displayTime !== 0) { + obj.displayTime = Math.round(message.displayTime); + } + if (message.menuString !== '') { + obj.menuString = message.menuString; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgShowMenu { + return CUsrMsgShowMenu.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgShowMenu { + const message = createBaseCUsrMsgShowMenu(); + message.bitsValidSlots = object.bitsValidSlots ?? 0; + message.displayTime = object.displayTime ?? 0; + message.menuString = object.menuString ?? ''; + return message; + }, +}; + +function createBaseCUsrMsgBarTime(): CUsrMsgBarTime { + return { time: '' }; +} + +export const CUsrMsgBarTime = { + encode(message: CUsrMsgBarTime, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.time !== '') { + writer.uint32(10).string(message.time); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgBarTime { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgBarTime(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.time = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgBarTime { + return { time: isSet(object.time) ? globalThis.String(object.time) : '' }; + }, + + toJSON(message: CUsrMsgBarTime): unknown { + const obj: any = {}; + if (message.time !== '') { + obj.time = message.time; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgBarTime { + return CUsrMsgBarTime.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgBarTime { + const message = createBaseCUsrMsgBarTime(); + message.time = object.time ?? ''; + return message; + }, +}; + +function createBaseCUsrMsgAmmoDenied(): CUsrMsgAmmoDenied { + return { ammoIdx: 0 }; +} + +export const CUsrMsgAmmoDenied = { + encode(message: CUsrMsgAmmoDenied, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.ammoIdx !== 0) { + writer.uint32(8).int32(message.ammoIdx); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgAmmoDenied { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgAmmoDenied(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.ammoIdx = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgAmmoDenied { + return { ammoIdx: isSet(object.ammoIdx) ? globalThis.Number(object.ammoIdx) : 0 }; + }, + + toJSON(message: CUsrMsgAmmoDenied): unknown { + const obj: any = {}; + if (message.ammoIdx !== 0) { + obj.ammoIdx = Math.round(message.ammoIdx); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgAmmoDenied { + return CUsrMsgAmmoDenied.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgAmmoDenied { + const message = createBaseCUsrMsgAmmoDenied(); + message.ammoIdx = object.ammoIdx ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgMarkAchievement(): CUsrMsgMarkAchievement { + return { achievement: '' }; +} + +export const CUsrMsgMarkAchievement = { + encode(message: CUsrMsgMarkAchievement, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.achievement !== '') { + writer.uint32(10).string(message.achievement); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgMarkAchievement { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgMarkAchievement(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.achievement = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgMarkAchievement { + return { achievement: isSet(object.achievement) ? globalThis.String(object.achievement) : '' }; + }, + + toJSON(message: CUsrMsgMarkAchievement): unknown { + const obj: any = {}; + if (message.achievement !== '') { + obj.achievement = message.achievement; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgMarkAchievement { + return CUsrMsgMarkAchievement.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgMarkAchievement { + const message = createBaseCUsrMsgMarkAchievement(); + message.achievement = object.achievement ?? ''; + return message; + }, +}; + +function createBaseCUsrMsgGlowPropTurnOff(): CUsrMsgGlowPropTurnOff { + return { entidx: 0 }; +} + +export const CUsrMsgGlowPropTurnOff = { + encode(message: CUsrMsgGlowPropTurnOff, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.entidx !== 0) { + writer.uint32(8).int32(message.entidx); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgGlowPropTurnOff { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgGlowPropTurnOff(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.entidx = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgGlowPropTurnOff { + return { entidx: isSet(object.entidx) ? globalThis.Number(object.entidx) : 0 }; + }, + + toJSON(message: CUsrMsgGlowPropTurnOff): unknown { + const obj: any = {}; + if (message.entidx !== 0) { + obj.entidx = Math.round(message.entidx); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgGlowPropTurnOff { + return CUsrMsgGlowPropTurnOff.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgGlowPropTurnOff { + const message = createBaseCUsrMsgGlowPropTurnOff(); + message.entidx = object.entidx ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgTilt(): CUsrMsgTilt { + return { command: 0, easeInOut: false, angle: undefined, duration: 0, time: 0 }; +} + +export const CUsrMsgTilt = { + encode(message: CUsrMsgTilt, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.command !== 0) { + writer.uint32(8).int32(message.command); + } + if (message.easeInOut === true) { + writer.uint32(16).bool(message.easeInOut); + } + if (message.angle !== undefined) { + CMsgQAngle.encode(message.angle, writer.uint32(26).fork()).ldelim(); + } + if (message.duration !== 0) { + writer.uint32(37).float(message.duration); + } + if (message.time !== 0) { + writer.uint32(45).float(message.time); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgTilt { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgTilt(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.command = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.easeInOut = reader.bool(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.angle = CMsgQAngle.decode(reader, reader.uint32()); + continue; + case 4: + if (tag !== 37) { + break; + } + + message.duration = reader.float(); + continue; + case 5: + if (tag !== 45) { + break; + } + + message.time = reader.float(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgTilt { + return { + command: isSet(object.command) ? globalThis.Number(object.command) : 0, + easeInOut: isSet(object.easeInOut) ? globalThis.Boolean(object.easeInOut) : false, + angle: isSet(object.angle) ? CMsgQAngle.fromJSON(object.angle) : undefined, + duration: isSet(object.duration) ? globalThis.Number(object.duration) : 0, + time: isSet(object.time) ? globalThis.Number(object.time) : 0, + }; + }, + + toJSON(message: CUsrMsgTilt): unknown { + const obj: any = {}; + if (message.command !== 0) { + obj.command = Math.round(message.command); + } + if (message.easeInOut === true) { + obj.easeInOut = message.easeInOut; + } + if (message.angle !== undefined) { + obj.angle = CMsgQAngle.toJSON(message.angle); + } + if (message.duration !== 0) { + obj.duration = message.duration; + } + if (message.time !== 0) { + obj.time = message.time; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgTilt { + return CUsrMsgTilt.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgTilt { + const message = createBaseCUsrMsgTilt(); + message.command = object.command ?? 0; + message.easeInOut = object.easeInOut ?? false; + message.angle = (object.angle !== undefined && object.angle !== null) + ? CMsgQAngle.fromPartial(object.angle) + : undefined; + message.duration = object.duration ?? 0; + message.time = object.time ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgBattery(): CUsrMsgBattery { + return { value: 0 }; +} + +export const CUsrMsgBattery = { + encode(message: CUsrMsgBattery, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.value !== 0) { + writer.uint32(8).int32(message.value); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgBattery { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgBattery(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.value = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgBattery { + return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 }; + }, + + toJSON(message: CUsrMsgBattery): unknown { + const obj: any = {}; + if (message.value !== 0) { + obj.value = Math.round(message.value); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgBattery { + return CUsrMsgBattery.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgBattery { + const message = createBaseCUsrMsgBattery(); + message.value = object.value ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgCreditsMsg(): CUsrMsgCreditsMsg { + return { type: 0 }; +} + +export const CUsrMsgCreditsMsg = { + encode(message: CUsrMsgCreditsMsg, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgCreditsMsg { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgCreditsMsg(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.type = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgCreditsMsg { + return { type: isSet(object.type) ? globalThis.Number(object.type) : 0 }; + }, + + toJSON(message: CUsrMsgCreditsMsg): unknown { + const obj: any = {}; + if (message.type !== 0) { + obj.type = Math.round(message.type); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgCreditsMsg { + return CUsrMsgCreditsMsg.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgCreditsMsg { + const message = createBaseCUsrMsgCreditsMsg(); + message.type = object.type ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgLogoTimeMsg(): CUsrMsgLogoTimeMsg { + return { length: 0 }; +} + +export const CUsrMsgLogoTimeMsg = { + encode(message: CUsrMsgLogoTimeMsg, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.length !== 0) { + writer.uint32(13).float(message.length); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgLogoTimeMsg { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgLogoTimeMsg(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 13) { + break; + } + + message.length = reader.float(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgLogoTimeMsg { + return { length: isSet(object.length) ? globalThis.Number(object.length) : 0 }; + }, + + toJSON(message: CUsrMsgLogoTimeMsg): unknown { + const obj: any = {}; + if (message.length !== 0) { + obj.length = message.length; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgLogoTimeMsg { + return CUsrMsgLogoTimeMsg.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgLogoTimeMsg { + const message = createBaseCUsrMsgLogoTimeMsg(); + message.length = object.length ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgUpdateJalopyRadar(): CUsrMsgUpdateJalopyRadar { + return { dummy: 0 }; +} + +export const CUsrMsgUpdateJalopyRadar = { + encode(message: CUsrMsgUpdateJalopyRadar, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.dummy !== 0) { + writer.uint32(8).int32(message.dummy); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgUpdateJalopyRadar { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgUpdateJalopyRadar(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.dummy = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgUpdateJalopyRadar { + return { dummy: isSet(object.dummy) ? globalThis.Number(object.dummy) : 0 }; + }, + + toJSON(message: CUsrMsgUpdateJalopyRadar): unknown { + const obj: any = {}; + if (message.dummy !== 0) { + obj.dummy = Math.round(message.dummy); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgUpdateJalopyRadar { + return CUsrMsgUpdateJalopyRadar.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgUpdateJalopyRadar { + const message = createBaseCUsrMsgUpdateJalopyRadar(); + message.dummy = object.dummy ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgMessageText(): CUsrMsgMessageText { + return { color: undefined, text: '' }; +} + +export const CUsrMsgMessageText = { + encode(message: CUsrMsgMessageText, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.color !== undefined) { + CMsgRGBA.encode(message.color, writer.uint32(10).fork()).ldelim(); + } + if (message.text !== '') { + writer.uint32(18).string(message.text); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgMessageText { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgMessageText(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.color = CMsgRGBA.decode(reader, reader.uint32()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.text = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgMessageText { + return { + color: isSet(object.color) ? CMsgRGBA.fromJSON(object.color) : undefined, + text: isSet(object.text) ? globalThis.String(object.text) : '', + }; + }, + + toJSON(message: CUsrMsgMessageText): unknown { + const obj: any = {}; + if (message.color !== undefined) { + obj.color = CMsgRGBA.toJSON(message.color); + } + if (message.text !== '') { + obj.text = message.text; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgMessageText { + return CUsrMsgMessageText.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgMessageText { + const message = createBaseCUsrMsgMessageText(); + message.color = (object.color !== undefined && object.color !== null) + ? CMsgRGBA.fromPartial(object.color) + : undefined; + message.text = object.text ?? ''; + return message; + }, +}; + +function createBaseCUsrMsgStatsSkipState(): CUsrMsgStatsSkipState { + return { numSkips: 0, numPlayers: 0 }; +} + +export const CUsrMsgStatsSkipState = { + encode(message: CUsrMsgStatsSkipState, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.numSkips !== 0) { + writer.uint32(8).int32(message.numSkips); + } + if (message.numPlayers !== 0) { + writer.uint32(16).int32(message.numPlayers); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgStatsSkipState { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgStatsSkipState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.numSkips = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.numPlayers = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgStatsSkipState { + return { + numSkips: isSet(object.numSkips) ? globalThis.Number(object.numSkips) : 0, + numPlayers: isSet(object.numPlayers) ? globalThis.Number(object.numPlayers) : 0, + }; + }, + + toJSON(message: CUsrMsgStatsSkipState): unknown { + const obj: any = {}; + if (message.numSkips !== 0) { + obj.numSkips = Math.round(message.numSkips); + } + if (message.numPlayers !== 0) { + obj.numPlayers = Math.round(message.numPlayers); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgStatsSkipState { + return CUsrMsgStatsSkipState.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgStatsSkipState { + const message = createBaseCUsrMsgStatsSkipState(); + message.numSkips = object.numSkips ?? 0; + message.numPlayers = object.numPlayers ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgPanoramaEvent(): CUsrMsgPanoramaEvent { + return { event: '', payload: '' }; +} + +export const CUsrMsgPanoramaEvent = { + encode(message: CUsrMsgPanoramaEvent, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.event !== '') { + writer.uint32(10).string(message.event); + } + if (message.payload !== '') { + writer.uint32(18).string(message.payload); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgPanoramaEvent { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgPanoramaEvent(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.event = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.payload = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgPanoramaEvent { + return { + event: isSet(object.event) ? globalThis.String(object.event) : '', + payload: isSet(object.payload) ? globalThis.String(object.payload) : '', + }; + }, + + toJSON(message: CUsrMsgPanoramaEvent): unknown { + const obj: any = {}; + if (message.event !== '') { + obj.event = message.event; + } + if (message.payload !== '') { + obj.payload = message.payload; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgPanoramaEvent { + return CUsrMsgPanoramaEvent.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgPanoramaEvent { + const message = createBaseCUsrMsgPanoramaEvent(); + message.event = object.event ?? ''; + message.payload = object.payload ?? ''; + return message; + }, +}; + +function createBaseCUsrMsgResetHud(): CUsrMsgResetHud { + return { reset: false }; +} + +export const CUsrMsgResetHud = { + encode(message: CUsrMsgResetHud, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.reset === true) { + writer.uint32(8).bool(message.reset); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgResetHud { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgResetHud(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.reset = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgResetHud { + return { reset: isSet(object.reset) ? globalThis.Boolean(object.reset) : false }; + }, + + toJSON(message: CUsrMsgResetHud): unknown { + const obj: any = {}; + if (message.reset === true) { + obj.reset = message.reset; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgResetHud { + return CUsrMsgResetHud.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgResetHud { + const message = createBaseCUsrMsgResetHud(); + message.reset = object.reset ?? false; + return message; + }, +}; + +function createBaseCUsrMsgRequestState(): CUsrMsgRequestState { + return { dummy: 0 }; +} + +export const CUsrMsgRequestState = { + encode(message: CUsrMsgRequestState, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.dummy !== 0) { + writer.uint32(8).int32(message.dummy); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgRequestState { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgRequestState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.dummy = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgRequestState { + return { dummy: isSet(object.dummy) ? globalThis.Number(object.dummy) : 0 }; + }, + + toJSON(message: CUsrMsgRequestState): unknown { + const obj: any = {}; + if (message.dummy !== 0) { + obj.dummy = Math.round(message.dummy); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgRequestState { + return CUsrMsgRequestState.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgRequestState { + const message = createBaseCUsrMsgRequestState(); + message.dummy = object.dummy ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgStopSpectatorMode(): CUsrMsgStopSpectatorMode { + return { dummy: 0 }; +} + +export const CUsrMsgStopSpectatorMode = { + encode(message: CUsrMsgStopSpectatorMode, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.dummy !== 0) { + writer.uint32(8).int32(message.dummy); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgStopSpectatorMode { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgStopSpectatorMode(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.dummy = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgStopSpectatorMode { + return { dummy: isSet(object.dummy) ? globalThis.Number(object.dummy) : 0 }; + }, + + toJSON(message: CUsrMsgStopSpectatorMode): unknown { + const obj: any = {}; + if (message.dummy !== 0) { + obj.dummy = Math.round(message.dummy); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgStopSpectatorMode { + return CUsrMsgStopSpectatorMode.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgStopSpectatorMode { + const message = createBaseCUsrMsgStopSpectatorMode(); + message.dummy = object.dummy ?? 0; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function longToNumber(long: Long): number { + if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + } + return long.toNumber(); +} + +if (pb.util.Long !== Long) { + pb.util.Long = Long as any; + pb.configure(); +} + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/examples/custom/p2ce/google/protobuf/descriptor.ts b/examples/custom/p2ce/google/protobuf/descriptor.ts new file mode 100644 index 0000000..4efb253 --- /dev/null +++ b/examples/custom/p2ce/google/protobuf/descriptor.ts @@ -0,0 +1,3893 @@ +import pb from 'npm:protobufjs/minimal.js'; +import Long from 'npm:long'; + +export const protobufPackage = 'google.protobuf'; + +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +export interface FileDescriptorProto { + name: string; + package: string; + dependency: string[]; + publicDependency: number[]; + weakDependency: number[]; + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + sourceCodeInfo: SourceCodeInfo | undefined; + syntax: string; +} + +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + start: number; + end: number; + options: ExtensionRangeOptions | undefined; +} + +export interface DescriptorProto_ReservedRange { + start: number; + end: number; +} + +export interface ExtensionRangeOptions { + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + type: FieldDescriptorProto_Type; + typeName: string; + extendee: string; + defaultValue: string; + oneofIndex: number; + jsonName: string; + options: FieldOptions | undefined; + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + TYPE_GROUP = 10, + TYPE_MESSAGE = 11, + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + TYPE_SINT32 = 17, + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON(object: any): FieldDescriptorProto_Type { + switch (object) { + case 1: + case 'TYPE_DOUBLE': + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case 'TYPE_FLOAT': + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case 'TYPE_INT64': + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case 'TYPE_UINT64': + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case 'TYPE_INT32': + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case 'TYPE_FIXED64': + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case 'TYPE_FIXED32': + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case 'TYPE_BOOL': + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case 'TYPE_STRING': + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case 'TYPE_GROUP': + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case 'TYPE_MESSAGE': + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case 'TYPE_BYTES': + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case 'TYPE_UINT32': + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case 'TYPE_ENUM': + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case 'TYPE_SFIXED32': + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case 'TYPE_SFIXED64': + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case 'TYPE_SINT32': + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case 'TYPE_SINT64': + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case 'UNRECOGNIZED': + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON(object: FieldDescriptorProto_Type): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return 'TYPE_DOUBLE'; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return 'TYPE_FLOAT'; + case FieldDescriptorProto_Type.TYPE_INT64: + return 'TYPE_INT64'; + case FieldDescriptorProto_Type.TYPE_UINT64: + return 'TYPE_UINT64'; + case FieldDescriptorProto_Type.TYPE_INT32: + return 'TYPE_INT32'; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return 'TYPE_FIXED64'; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return 'TYPE_FIXED32'; + case FieldDescriptorProto_Type.TYPE_BOOL: + return 'TYPE_BOOL'; + case FieldDescriptorProto_Type.TYPE_STRING: + return 'TYPE_STRING'; + case FieldDescriptorProto_Type.TYPE_GROUP: + return 'TYPE_GROUP'; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return 'TYPE_MESSAGE'; + case FieldDescriptorProto_Type.TYPE_BYTES: + return 'TYPE_BYTES'; + case FieldDescriptorProto_Type.TYPE_UINT32: + return 'TYPE_UINT32'; + case FieldDescriptorProto_Type.TYPE_ENUM: + return 'TYPE_ENUM'; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return 'TYPE_SFIXED32'; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return 'TYPE_SFIXED64'; + case FieldDescriptorProto_Type.TYPE_SINT32: + return 'TYPE_SINT32'; + case FieldDescriptorProto_Type.TYPE_SINT64: + return 'TYPE_SINT64'; + case FieldDescriptorProto_Type.UNRECOGNIZED: + default: + return 'UNRECOGNIZED'; + } +} + +export enum FieldDescriptorProto_Label { + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON(object: any): FieldDescriptorProto_Label { + switch (object) { + case 1: + case 'LABEL_OPTIONAL': + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case 'LABEL_REQUIRED': + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case 'LABEL_REPEATED': + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case 'UNRECOGNIZED': + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON(object: FieldDescriptorProto_Label): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return 'LABEL_OPTIONAL'; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return 'LABEL_REQUIRED'; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return 'LABEL_REPEATED'; + case FieldDescriptorProto_Label.UNRECOGNIZED: + default: + return 'UNRECOGNIZED'; + } +} + +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + reservedName: string[]; +} + +export interface EnumDescriptorProto_EnumReservedRange { + start: number; + end: number; +} + +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +export interface MethodDescriptorProto { + name: string; + inputType: string; + outputType: string; + options: MethodOptions | undefined; + clientStreaming: boolean; + serverStreaming: boolean; +} + +export interface FileOptions { + javaPackage: string; + javaOuterClassname: string; + javaMultipleFiles: boolean; + /** @deprecated */ + javaGenerateEqualsAndHash: boolean; + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + goPackage: string; + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + deprecated: boolean; + ccEnableArenas: boolean; + objcClassPrefix: string; + csharpNamespace: string; + swiftPrefix: string; + phpClassPrefix: string; + phpNamespace: string; + phpMetadataNamespace: string; + rubyPackage: string; + uninterpretedOption: UninterpretedOption[]; +} + +export enum FileOptions_OptimizeMode { + SPEED = 1, + CODE_SIZE = 2, + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON(object: any): FileOptions_OptimizeMode { + switch (object) { + case 1: + case 'SPEED': + return FileOptions_OptimizeMode.SPEED; + case 2: + case 'CODE_SIZE': + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case 'LITE_RUNTIME': + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case 'UNRECOGNIZED': + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON(object: FileOptions_OptimizeMode): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return 'SPEED'; + case FileOptions_OptimizeMode.CODE_SIZE: + return 'CODE_SIZE'; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return 'LITE_RUNTIME'; + case FileOptions_OptimizeMode.UNRECOGNIZED: + default: + return 'UNRECOGNIZED'; + } +} + +export interface MessageOptions { + messageSetWireFormat: boolean; + noStandardDescriptorAccessor: boolean; + deprecated: boolean; + mapEntry: boolean; + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + ctype: FieldOptions_CType; + packed: boolean; + jstype: FieldOptions_JSType; + lazy: boolean; + deprecated: boolean; + weak: boolean; + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case 'STRING': + return FieldOptions_CType.STRING; + case 1: + case 'CORD': + return FieldOptions_CType.CORD; + case 2: + case 'STRING_PIECE': + return FieldOptions_CType.STRING_PIECE; + case -1: + case 'UNRECOGNIZED': + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return 'STRING'; + case FieldOptions_CType.CORD: + return 'CORD'; + case FieldOptions_CType.STRING_PIECE: + return 'STRING_PIECE'; + case FieldOptions_CType.UNRECOGNIZED: + default: + return 'UNRECOGNIZED'; + } +} + +export enum FieldOptions_JSType { + JS_NORMAL = 0, + JS_STRING = 1, + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case 'JS_NORMAL': + return FieldOptions_JSType.JS_NORMAL; + case 1: + case 'JS_STRING': + return FieldOptions_JSType.JS_STRING; + case 2: + case 'JS_NUMBER': + return FieldOptions_JSType.JS_NUMBER; + case -1: + case 'UNRECOGNIZED': + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return 'JS_NORMAL'; + case FieldOptions_JSType.JS_STRING: + return 'JS_STRING'; + case FieldOptions_JSType.JS_NUMBER: + return 'JS_NUMBER'; + case FieldOptions_JSType.UNRECOGNIZED: + default: + return 'UNRECOGNIZED'; + } +} + +export interface OneofOptions { + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + allowAlias: boolean; + deprecated: boolean; + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + deprecated: boolean; + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + deprecated: boolean; + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + uninterpretedOption: UninterpretedOption[]; +} + +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + NO_SIDE_EFFECTS = 1, + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON(object: any): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case 'IDEMPOTENCY_UNKNOWN': + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case 'NO_SIDE_EFFECTS': + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case 'IDEMPOTENT': + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case 'UNRECOGNIZED': + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON(object: MethodOptions_IdempotencyLevel): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return 'IDEMPOTENCY_UNKNOWN'; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return 'NO_SIDE_EFFECTS'; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return 'IDEMPOTENT'; + case MethodOptions_IdempotencyLevel.UNRECOGNIZED: + default: + return 'UNRECOGNIZED'; + } +} + +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +export interface SourceCodeInfo { + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + path: number[]; + span: number[]; + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +export interface GeneratedCodeInfo { + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + path: number[]; + sourceFile: string; + begin: number; + end: number; +} + +function createBaseFileDescriptorSet(): FileDescriptorSet { + return { file: [] }; +} + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: pb.Writer = pb.Writer.create()): pb.Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFileDescriptorSet(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.file.push(FileDescriptorProto.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + return { + file: globalThis.Array.isArray(object?.file) + ? object.file.map((e: any) => FileDescriptorProto.fromJSON(e)) + : [], + }; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file?.length) { + obj.file = message.file.map((e) => FileDescriptorProto.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): FileDescriptorSet { + return FileDescriptorSet.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): FileDescriptorSet { + const message = createBaseFileDescriptorSet(); + message.file = object.file?.map((e) => FileDescriptorProto.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseFileDescriptorProto(): FileDescriptorProto { + return { + name: '', + package: '', + dependency: [], + publicDependency: [], + weakDependency: [], + messageType: [], + enumType: [], + service: [], + extension: [], + options: undefined, + sourceCodeInfo: undefined, + syntax: '', + }; +} + +export const FileDescriptorProto = { + encode(message: FileDescriptorProto, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.name !== '') { + writer.uint32(10).string(message.name); + } + if (message.package !== '') { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode(message.sourceCodeInfo, writer.uint32(74).fork()).ldelim(); + } + if (message.syntax !== '') { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFileDescriptorProto(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.name = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.package = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.dependency.push(reader.string()); + continue; + case 10: + if (tag === 80) { + message.publicDependency.push(reader.int32()); + + continue; + } + + if (tag === 82) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + + continue; + } + + break; + case 11: + if (tag === 88) { + message.weakDependency.push(reader.int32()); + + continue; + } + + if (tag === 90) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + + continue; + } + + break; + case 4: + if (tag !== 34) { + break; + } + + message.messageType.push(DescriptorProto.decode(reader, reader.uint32())); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.enumType.push(EnumDescriptorProto.decode(reader, reader.uint32())); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.service.push(ServiceDescriptorProto.decode(reader, reader.uint32())); + continue; + case 7: + if (tag !== 58) { + break; + } + + message.extension.push(FieldDescriptorProto.decode(reader, reader.uint32())); + continue; + case 8: + if (tag !== 66) { + break; + } + + message.options = FileOptions.decode(reader, reader.uint32()); + continue; + case 9: + if (tag !== 74) { + break; + } + + message.sourceCodeInfo = SourceCodeInfo.decode(reader, reader.uint32()); + continue; + case 12: + if (tag !== 98) { + break; + } + + message.syntax = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + return { + name: isSet(object.name) ? globalThis.String(object.name) : '', + package: isSet(object.package) ? globalThis.String(object.package) : '', + dependency: globalThis.Array.isArray(object?.dependency) + ? object.dependency.map((e: any) => globalThis.String(e)) + : [], + publicDependency: globalThis.Array.isArray(object?.publicDependency) + ? object.publicDependency.map((e: any) => globalThis.Number(e)) + : [], + weakDependency: globalThis.Array.isArray(object?.weakDependency) + ? object.weakDependency.map((e: any) => globalThis.Number(e)) + : [], + messageType: globalThis.Array.isArray(object?.messageType) + ? object.messageType.map((e: any) => DescriptorProto.fromJSON(e)) + : [], + enumType: globalThis.Array.isArray(object?.enumType) + ? object.enumType.map((e: any) => EnumDescriptorProto.fromJSON(e)) + : [], + service: globalThis.Array.isArray(object?.service) + ? object.service.map((e: any) => ServiceDescriptorProto.fromJSON(e)) + : [], + extension: globalThis.Array.isArray(object?.extension) + ? object.extension.map((e: any) => FieldDescriptorProto.fromJSON(e)) + : [], + options: isSet(object.options) ? FileOptions.fromJSON(object.options) : undefined, + sourceCodeInfo: isSet(object.sourceCodeInfo) ? SourceCodeInfo.fromJSON(object.sourceCodeInfo) : undefined, + syntax: isSet(object.syntax) ? globalThis.String(object.syntax) : '', + }; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + if (message.name !== '') { + obj.name = message.name; + } + if (message.package !== '') { + obj.package = message.package; + } + if (message.dependency?.length) { + obj.dependency = message.dependency; + } + if (message.publicDependency?.length) { + obj.publicDependency = message.publicDependency.map((e) => Math.round(e)); + } + if (message.weakDependency?.length) { + obj.weakDependency = message.weakDependency.map((e) => Math.round(e)); + } + if (message.messageType?.length) { + obj.messageType = message.messageType.map((e) => DescriptorProto.toJSON(e)); + } + if (message.enumType?.length) { + obj.enumType = message.enumType.map((e) => EnumDescriptorProto.toJSON(e)); + } + if (message.service?.length) { + obj.service = message.service.map((e) => ServiceDescriptorProto.toJSON(e)); + } + if (message.extension?.length) { + obj.extension = message.extension.map((e) => FieldDescriptorProto.toJSON(e)); + } + if (message.options !== undefined) { + obj.options = FileOptions.toJSON(message.options); + } + if (message.sourceCodeInfo !== undefined) { + obj.sourceCodeInfo = SourceCodeInfo.toJSON(message.sourceCodeInfo); + } + if (message.syntax !== '') { + obj.syntax = message.syntax; + } + return obj; + }, + + create, I>>(base?: I): FileDescriptorProto { + return FileDescriptorProto.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): FileDescriptorProto { + const message = createBaseFileDescriptorProto(); + message.name = object.name ?? ''; + message.package = object.package ?? ''; + message.dependency = object.dependency?.map((e) => e) || []; + message.publicDependency = object.publicDependency?.map((e) => e) || []; + message.weakDependency = object.weakDependency?.map((e) => e) || []; + message.messageType = object.messageType?.map((e) => DescriptorProto.fromPartial(e)) || []; + message.enumType = object.enumType?.map((e) => EnumDescriptorProto.fromPartial(e)) || []; + message.service = object.service?.map((e) => ServiceDescriptorProto.fromPartial(e)) || []; + message.extension = object.extension?.map((e) => FieldDescriptorProto.fromPartial(e)) || []; + message.options = (object.options !== undefined && object.options !== null) + ? FileOptions.fromPartial(object.options) + : undefined; + message.sourceCodeInfo = (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) + ? SourceCodeInfo.fromPartial(object.sourceCodeInfo) + : undefined; + message.syntax = object.syntax ?? ''; + return message; + }, +}; + +function createBaseDescriptorProto(): DescriptorProto { + return { + name: '', + field: [], + extension: [], + nestedType: [], + enumType: [], + extensionRange: [], + oneofDecl: [], + options: undefined, + reservedRange: [], + reservedName: [], + }; +} + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.name !== '') { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode(v!, writer.uint32(74).fork()).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDescriptorProto(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.name = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.field.push(FieldDescriptorProto.decode(reader, reader.uint32())); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.extension.push(FieldDescriptorProto.decode(reader, reader.uint32())); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.nestedType.push(DescriptorProto.decode(reader, reader.uint32())); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.enumType.push(EnumDescriptorProto.decode(reader, reader.uint32())); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.extensionRange.push(DescriptorProto_ExtensionRange.decode(reader, reader.uint32())); + continue; + case 8: + if (tag !== 66) { + break; + } + + message.oneofDecl.push(OneofDescriptorProto.decode(reader, reader.uint32())); + continue; + case 7: + if (tag !== 58) { + break; + } + + message.options = MessageOptions.decode(reader, reader.uint32()); + continue; + case 9: + if (tag !== 74) { + break; + } + + message.reservedRange.push(DescriptorProto_ReservedRange.decode(reader, reader.uint32())); + continue; + case 10: + if (tag !== 82) { + break; + } + + message.reservedName.push(reader.string()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + return { + name: isSet(object.name) ? globalThis.String(object.name) : '', + field: globalThis.Array.isArray(object?.field) + ? object.field.map((e: any) => FieldDescriptorProto.fromJSON(e)) + : [], + extension: globalThis.Array.isArray(object?.extension) + ? object.extension.map((e: any) => FieldDescriptorProto.fromJSON(e)) + : [], + nestedType: globalThis.Array.isArray(object?.nestedType) + ? object.nestedType.map((e: any) => DescriptorProto.fromJSON(e)) + : [], + enumType: globalThis.Array.isArray(object?.enumType) + ? object.enumType.map((e: any) => EnumDescriptorProto.fromJSON(e)) + : [], + extensionRange: globalThis.Array.isArray(object?.extensionRange) + ? object.extensionRange.map((e: any) => DescriptorProto_ExtensionRange.fromJSON(e)) + : [], + oneofDecl: globalThis.Array.isArray(object?.oneofDecl) + ? object.oneofDecl.map((e: any) => OneofDescriptorProto.fromJSON(e)) + : [], + options: isSet(object.options) ? MessageOptions.fromJSON(object.options) : undefined, + reservedRange: globalThis.Array.isArray(object?.reservedRange) + ? object.reservedRange.map((e: any) => DescriptorProto_ReservedRange.fromJSON(e)) + : [], + reservedName: globalThis.Array.isArray(object?.reservedName) + ? object.reservedName.map((e: any) => globalThis.String(e)) + : [], + }; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + if (message.name !== '') { + obj.name = message.name; + } + if (message.field?.length) { + obj.field = message.field.map((e) => FieldDescriptorProto.toJSON(e)); + } + if (message.extension?.length) { + obj.extension = message.extension.map((e) => FieldDescriptorProto.toJSON(e)); + } + if (message.nestedType?.length) { + obj.nestedType = message.nestedType.map((e) => DescriptorProto.toJSON(e)); + } + if (message.enumType?.length) { + obj.enumType = message.enumType.map((e) => EnumDescriptorProto.toJSON(e)); + } + if (message.extensionRange?.length) { + obj.extensionRange = message.extensionRange.map((e) => DescriptorProto_ExtensionRange.toJSON(e)); + } + if (message.oneofDecl?.length) { + obj.oneofDecl = message.oneofDecl.map((e) => OneofDescriptorProto.toJSON(e)); + } + if (message.options !== undefined) { + obj.options = MessageOptions.toJSON(message.options); + } + if (message.reservedRange?.length) { + obj.reservedRange = message.reservedRange.map((e) => DescriptorProto_ReservedRange.toJSON(e)); + } + if (message.reservedName?.length) { + obj.reservedName = message.reservedName; + } + return obj; + }, + + create, I>>(base?: I): DescriptorProto { + return DescriptorProto.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): DescriptorProto { + const message = createBaseDescriptorProto(); + message.name = object.name ?? ''; + message.field = object.field?.map((e) => FieldDescriptorProto.fromPartial(e)) || []; + message.extension = object.extension?.map((e) => FieldDescriptorProto.fromPartial(e)) || []; + message.nestedType = object.nestedType?.map((e) => DescriptorProto.fromPartial(e)) || []; + message.enumType = object.enumType?.map((e) => EnumDescriptorProto.fromPartial(e)) || []; + message.extensionRange = object.extensionRange?.map((e) => DescriptorProto_ExtensionRange.fromPartial(e)) || []; + message.oneofDecl = object.oneofDecl?.map((e) => OneofDescriptorProto.fromPartial(e)) || []; + message.options = (object.options !== undefined && object.options !== null) + ? MessageOptions.fromPartial(object.options) + : undefined; + message.reservedRange = object.reservedRange?.map((e) => DescriptorProto_ReservedRange.fromPartial(e)) || []; + message.reservedName = object.reservedName?.map((e) => e) || []; + return message; + }, +}; + +function createBaseDescriptorProto_ExtensionRange(): DescriptorProto_ExtensionRange { + return { start: 0, end: 0, options: undefined }; +} + +export const DescriptorProto_ExtensionRange = { + encode(message: DescriptorProto_ExtensionRange, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): DescriptorProto_ExtensionRange { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDescriptorProto_ExtensionRange(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.start = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.end = reader.int32(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.options = ExtensionRangeOptions.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + return { + start: isSet(object.start) ? globalThis.Number(object.start) : 0, + end: isSet(object.end) ? globalThis.Number(object.end) : 0, + options: isSet(object.options) ? ExtensionRangeOptions.fromJSON(object.options) : undefined, + }; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + if (message.start !== 0) { + obj.start = Math.round(message.start); + } + if (message.end !== 0) { + obj.end = Math.round(message.end); + } + if (message.options !== undefined) { + obj.options = ExtensionRangeOptions.toJSON(message.options); + } + return obj; + }, + + create, I>>(base?: I): DescriptorProto_ExtensionRange { + return DescriptorProto_ExtensionRange.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): DescriptorProto_ExtensionRange { + const message = createBaseDescriptorProto_ExtensionRange(); + message.start = object.start ?? 0; + message.end = object.end ?? 0; + message.options = (object.options !== undefined && object.options !== null) + ? ExtensionRangeOptions.fromPartial(object.options) + : undefined; + return message; + }, +}; + +function createBaseDescriptorProto_ReservedRange(): DescriptorProto_ReservedRange { + return { start: 0, end: 0 }; +} + +export const DescriptorProto_ReservedRange = { + encode(message: DescriptorProto_ReservedRange, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): DescriptorProto_ReservedRange { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDescriptorProto_ReservedRange(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.start = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.end = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + return { + start: isSet(object.start) ? globalThis.Number(object.start) : 0, + end: isSet(object.end) ? globalThis.Number(object.end) : 0, + }; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + if (message.start !== 0) { + obj.start = Math.round(message.start); + } + if (message.end !== 0) { + obj.end = Math.round(message.end); + } + return obj; + }, + + create, I>>(base?: I): DescriptorProto_ReservedRange { + return DescriptorProto_ReservedRange.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): DescriptorProto_ReservedRange { + const message = createBaseDescriptorProto_ReservedRange(); + message.start = object.start ?? 0; + message.end = object.end ?? 0; + return message; + }, +}; + +function createBaseExtensionRangeOptions(): ExtensionRangeOptions { + return { uninterpretedOption: [] }; +} + +export const ExtensionRangeOptions = { + encode(message: ExtensionRangeOptions, writer: pb.Writer = pb.Writer.create()): pb.Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExtensionRangeOptions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + if (tag !== 7994) { + break; + } + + message.uninterpretedOption.push(UninterpretedOption.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + return { + uninterpretedOption: globalThis.Array.isArray(object?.uninterpretedOption) + ? object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)) + : [], + }; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption?.length) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => UninterpretedOption.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): ExtensionRangeOptions { + return ExtensionRangeOptions.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): ExtensionRangeOptions { + const message = createBaseExtensionRangeOptions(); + message.uninterpretedOption = object.uninterpretedOption?.map((e) => UninterpretedOption.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseFieldDescriptorProto(): FieldDescriptorProto { + return { + name: '', + number: 0, + label: 1, + type: 1, + typeName: '', + extendee: '', + defaultValue: '', + oneofIndex: 0, + jsonName: '', + options: undefined, + proto3Optional: false, + }; +} + +export const FieldDescriptorProto = { + encode(message: FieldDescriptorProto, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.name !== '') { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== '') { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== '') { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== '') { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== '') { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFieldDescriptorProto(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.name = reader.string(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.number = reader.int32(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.label = reader.int32() as any; + continue; + case 5: + if (tag !== 40) { + break; + } + + message.type = reader.int32() as any; + continue; + case 6: + if (tag !== 50) { + break; + } + + message.typeName = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.extendee = reader.string(); + continue; + case 7: + if (tag !== 58) { + break; + } + + message.defaultValue = reader.string(); + continue; + case 9: + if (tag !== 72) { + break; + } + + message.oneofIndex = reader.int32(); + continue; + case 10: + if (tag !== 82) { + break; + } + + message.jsonName = reader.string(); + continue; + case 8: + if (tag !== 66) { + break; + } + + message.options = FieldOptions.decode(reader, reader.uint32()); + continue; + case 17: + if (tag !== 136) { + break; + } + + message.proto3Optional = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + return { + name: isSet(object.name) ? globalThis.String(object.name) : '', + number: isSet(object.number) ? globalThis.Number(object.number) : 0, + label: isSet(object.label) ? fieldDescriptorProto_LabelFromJSON(object.label) : 1, + type: isSet(object.type) ? fieldDescriptorProto_TypeFromJSON(object.type) : 1, + typeName: isSet(object.typeName) ? globalThis.String(object.typeName) : '', + extendee: isSet(object.extendee) ? globalThis.String(object.extendee) : '', + defaultValue: isSet(object.defaultValue) ? globalThis.String(object.defaultValue) : '', + oneofIndex: isSet(object.oneofIndex) ? globalThis.Number(object.oneofIndex) : 0, + jsonName: isSet(object.jsonName) ? globalThis.String(object.jsonName) : '', + options: isSet(object.options) ? FieldOptions.fromJSON(object.options) : undefined, + proto3Optional: isSet(object.proto3Optional) ? globalThis.Boolean(object.proto3Optional) : false, + }; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + if (message.name !== '') { + obj.name = message.name; + } + if (message.number !== 0) { + obj.number = Math.round(message.number); + } + if (message.label !== 1) { + obj.label = fieldDescriptorProto_LabelToJSON(message.label); + } + if (message.type !== 1) { + obj.type = fieldDescriptorProto_TypeToJSON(message.type); + } + if (message.typeName !== '') { + obj.typeName = message.typeName; + } + if (message.extendee !== '') { + obj.extendee = message.extendee; + } + if (message.defaultValue !== '') { + obj.defaultValue = message.defaultValue; + } + if (message.oneofIndex !== 0) { + obj.oneofIndex = Math.round(message.oneofIndex); + } + if (message.jsonName !== '') { + obj.jsonName = message.jsonName; + } + if (message.options !== undefined) { + obj.options = FieldOptions.toJSON(message.options); + } + if (message.proto3Optional === true) { + obj.proto3Optional = message.proto3Optional; + } + return obj; + }, + + create, I>>(base?: I): FieldDescriptorProto { + return FieldDescriptorProto.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): FieldDescriptorProto { + const message = createBaseFieldDescriptorProto(); + message.name = object.name ?? ''; + message.number = object.number ?? 0; + message.label = object.label ?? 1; + message.type = object.type ?? 1; + message.typeName = object.typeName ?? ''; + message.extendee = object.extendee ?? ''; + message.defaultValue = object.defaultValue ?? ''; + message.oneofIndex = object.oneofIndex ?? 0; + message.jsonName = object.jsonName ?? ''; + message.options = (object.options !== undefined && object.options !== null) + ? FieldOptions.fromPartial(object.options) + : undefined; + message.proto3Optional = object.proto3Optional ?? false; + return message; + }, +}; + +function createBaseOneofDescriptorProto(): OneofDescriptorProto { + return { name: '', options: undefined }; +} + +export const OneofDescriptorProto = { + encode(message: OneofDescriptorProto, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.name !== '') { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOneofDescriptorProto(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.name = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.options = OneofOptions.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + return { + name: isSet(object.name) ? globalThis.String(object.name) : '', + options: isSet(object.options) ? OneofOptions.fromJSON(object.options) : undefined, + }; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + if (message.name !== '') { + obj.name = message.name; + } + if (message.options !== undefined) { + obj.options = OneofOptions.toJSON(message.options); + } + return obj; + }, + + create, I>>(base?: I): OneofDescriptorProto { + return OneofDescriptorProto.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): OneofDescriptorProto { + const message = createBaseOneofDescriptorProto(); + message.name = object.name ?? ''; + message.options = (object.options !== undefined && object.options !== null) + ? OneofOptions.fromPartial(object.options) + : undefined; + return message; + }, +}; + +function createBaseEnumDescriptorProto(): EnumDescriptorProto { + return { name: '', value: [], options: undefined, reservedRange: [], reservedName: [] }; +} + +export const EnumDescriptorProto = { + encode(message: EnumDescriptorProto, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.name !== '') { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEnumDescriptorProto(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.name = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.value.push(EnumValueDescriptorProto.decode(reader, reader.uint32())); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.options = EnumOptions.decode(reader, reader.uint32()); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.reservedRange.push(EnumDescriptorProto_EnumReservedRange.decode(reader, reader.uint32())); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.reservedName.push(reader.string()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + return { + name: isSet(object.name) ? globalThis.String(object.name) : '', + value: globalThis.Array.isArray(object?.value) + ? object.value.map((e: any) => EnumValueDescriptorProto.fromJSON(e)) + : [], + options: isSet(object.options) ? EnumOptions.fromJSON(object.options) : undefined, + reservedRange: globalThis.Array.isArray(object?.reservedRange) + ? object.reservedRange.map((e: any) => EnumDescriptorProto_EnumReservedRange.fromJSON(e)) + : [], + reservedName: globalThis.Array.isArray(object?.reservedName) + ? object.reservedName.map((e: any) => globalThis.String(e)) + : [], + }; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + if (message.name !== '') { + obj.name = message.name; + } + if (message.value?.length) { + obj.value = message.value.map((e) => EnumValueDescriptorProto.toJSON(e)); + } + if (message.options !== undefined) { + obj.options = EnumOptions.toJSON(message.options); + } + if (message.reservedRange?.length) { + obj.reservedRange = message.reservedRange.map((e) => EnumDescriptorProto_EnumReservedRange.toJSON(e)); + } + if (message.reservedName?.length) { + obj.reservedName = message.reservedName; + } + return obj; + }, + + create, I>>(base?: I): EnumDescriptorProto { + return EnumDescriptorProto.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): EnumDescriptorProto { + const message = createBaseEnumDescriptorProto(); + message.name = object.name ?? ''; + message.value = object.value?.map((e) => EnumValueDescriptorProto.fromPartial(e)) || []; + message.options = (object.options !== undefined && object.options !== null) + ? EnumOptions.fromPartial(object.options) + : undefined; + message.reservedRange = + object.reservedRange?.map((e) => EnumDescriptorProto_EnumReservedRange.fromPartial(e)) || + []; + message.reservedName = object.reservedName?.map((e) => e) || []; + return message; + }, +}; + +function createBaseEnumDescriptorProto_EnumReservedRange(): EnumDescriptorProto_EnumReservedRange { + return { start: 0, end: 0 }; +} + +export const EnumDescriptorProto_EnumReservedRange = { + encode(message: EnumDescriptorProto_EnumReservedRange, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEnumDescriptorProto_EnumReservedRange(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.start = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.end = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + return { + start: isSet(object.start) ? globalThis.Number(object.start) : 0, + end: isSet(object.end) ? globalThis.Number(object.end) : 0, + }; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + if (message.start !== 0) { + obj.start = Math.round(message.start); + } + if (message.end !== 0) { + obj.end = Math.round(message.end); + } + return obj; + }, + + create, I>>( + base?: I, + ): EnumDescriptorProto_EnumReservedRange { + return EnumDescriptorProto_EnumReservedRange.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): EnumDescriptorProto_EnumReservedRange { + const message = createBaseEnumDescriptorProto_EnumReservedRange(); + message.start = object.start ?? 0; + message.end = object.end ?? 0; + return message; + }, +}; + +function createBaseEnumValueDescriptorProto(): EnumValueDescriptorProto { + return { name: '', number: 0, options: undefined }; +} + +export const EnumValueDescriptorProto = { + encode(message: EnumValueDescriptorProto, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.name !== '') { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): EnumValueDescriptorProto { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEnumValueDescriptorProto(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.name = reader.string(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.number = reader.int32(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.options = EnumValueOptions.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + return { + name: isSet(object.name) ? globalThis.String(object.name) : '', + number: isSet(object.number) ? globalThis.Number(object.number) : 0, + options: isSet(object.options) ? EnumValueOptions.fromJSON(object.options) : undefined, + }; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + if (message.name !== '') { + obj.name = message.name; + } + if (message.number !== 0) { + obj.number = Math.round(message.number); + } + if (message.options !== undefined) { + obj.options = EnumValueOptions.toJSON(message.options); + } + return obj; + }, + + create, I>>(base?: I): EnumValueDescriptorProto { + return EnumValueDescriptorProto.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): EnumValueDescriptorProto { + const message = createBaseEnumValueDescriptorProto(); + message.name = object.name ?? ''; + message.number = object.number ?? 0; + message.options = (object.options !== undefined && object.options !== null) + ? EnumValueOptions.fromPartial(object.options) + : undefined; + return message; + }, +}; + +function createBaseServiceDescriptorProto(): ServiceDescriptorProto { + return { name: '', method: [], options: undefined }; +} + +export const ServiceDescriptorProto = { + encode(message: ServiceDescriptorProto, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.name !== '') { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseServiceDescriptorProto(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.name = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.method.push(MethodDescriptorProto.decode(reader, reader.uint32())); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.options = ServiceOptions.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + return { + name: isSet(object.name) ? globalThis.String(object.name) : '', + method: globalThis.Array.isArray(object?.method) + ? object.method.map((e: any) => MethodDescriptorProto.fromJSON(e)) + : [], + options: isSet(object.options) ? ServiceOptions.fromJSON(object.options) : undefined, + }; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + if (message.name !== '') { + obj.name = message.name; + } + if (message.method?.length) { + obj.method = message.method.map((e) => MethodDescriptorProto.toJSON(e)); + } + if (message.options !== undefined) { + obj.options = ServiceOptions.toJSON(message.options); + } + return obj; + }, + + create, I>>(base?: I): ServiceDescriptorProto { + return ServiceDescriptorProto.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): ServiceDescriptorProto { + const message = createBaseServiceDescriptorProto(); + message.name = object.name ?? ''; + message.method = object.method?.map((e) => MethodDescriptorProto.fromPartial(e)) || []; + message.options = (object.options !== undefined && object.options !== null) + ? ServiceOptions.fromPartial(object.options) + : undefined; + return message; + }, +}; + +function createBaseMethodDescriptorProto(): MethodDescriptorProto { + return { + name: '', + inputType: '', + outputType: '', + options: undefined, + clientStreaming: false, + serverStreaming: false, + }; +} + +export const MethodDescriptorProto = { + encode(message: MethodDescriptorProto, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.name !== '') { + writer.uint32(10).string(message.name); + } + if (message.inputType !== '') { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== '') { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMethodDescriptorProto(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.name = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.inputType = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.outputType = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.options = MethodOptions.decode(reader, reader.uint32()); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.clientStreaming = reader.bool(); + continue; + case 6: + if (tag !== 48) { + break; + } + + message.serverStreaming = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + return { + name: isSet(object.name) ? globalThis.String(object.name) : '', + inputType: isSet(object.inputType) ? globalThis.String(object.inputType) : '', + outputType: isSet(object.outputType) ? globalThis.String(object.outputType) : '', + options: isSet(object.options) ? MethodOptions.fromJSON(object.options) : undefined, + clientStreaming: isSet(object.clientStreaming) ? globalThis.Boolean(object.clientStreaming) : false, + serverStreaming: isSet(object.serverStreaming) ? globalThis.Boolean(object.serverStreaming) : false, + }; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + if (message.name !== '') { + obj.name = message.name; + } + if (message.inputType !== '') { + obj.inputType = message.inputType; + } + if (message.outputType !== '') { + obj.outputType = message.outputType; + } + if (message.options !== undefined) { + obj.options = MethodOptions.toJSON(message.options); + } + if (message.clientStreaming === true) { + obj.clientStreaming = message.clientStreaming; + } + if (message.serverStreaming === true) { + obj.serverStreaming = message.serverStreaming; + } + return obj; + }, + + create, I>>(base?: I): MethodDescriptorProto { + return MethodDescriptorProto.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): MethodDescriptorProto { + const message = createBaseMethodDescriptorProto(); + message.name = object.name ?? ''; + message.inputType = object.inputType ?? ''; + message.outputType = object.outputType ?? ''; + message.options = (object.options !== undefined && object.options !== null) + ? MethodOptions.fromPartial(object.options) + : undefined; + message.clientStreaming = object.clientStreaming ?? false; + message.serverStreaming = object.serverStreaming ?? false; + return message; + }, +}; + +function createBaseFileOptions(): FileOptions { + return { + javaPackage: '', + javaOuterClassname: '', + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: '', + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: '', + csharpNamespace: '', + swiftPrefix: '', + phpClassPrefix: '', + phpNamespace: '', + phpMetadataNamespace: '', + rubyPackage: '', + uninterpretedOption: [], + }; +} + +export const FileOptions = { + encode(message: FileOptions, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.javaPackage !== '') { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== '') { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== '') { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== '') { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== '') { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== '') { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== '') { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== '') { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== '') { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== '') { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFileOptions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.javaPackage = reader.string(); + continue; + case 8: + if (tag !== 66) { + break; + } + + message.javaOuterClassname = reader.string(); + continue; + case 10: + if (tag !== 80) { + break; + } + + message.javaMultipleFiles = reader.bool(); + continue; + case 20: + if (tag !== 160) { + break; + } + + message.javaGenerateEqualsAndHash = reader.bool(); + continue; + case 27: + if (tag !== 216) { + break; + } + + message.javaStringCheckUtf8 = reader.bool(); + continue; + case 9: + if (tag !== 72) { + break; + } + + message.optimizeFor = reader.int32() as any; + continue; + case 11: + if (tag !== 90) { + break; + } + + message.goPackage = reader.string(); + continue; + case 16: + if (tag !== 128) { + break; + } + + message.ccGenericServices = reader.bool(); + continue; + case 17: + if (tag !== 136) { + break; + } + + message.javaGenericServices = reader.bool(); + continue; + case 18: + if (tag !== 144) { + break; + } + + message.pyGenericServices = reader.bool(); + continue; + case 42: + if (tag !== 336) { + break; + } + + message.phpGenericServices = reader.bool(); + continue; + case 23: + if (tag !== 184) { + break; + } + + message.deprecated = reader.bool(); + continue; + case 31: + if (tag !== 248) { + break; + } + + message.ccEnableArenas = reader.bool(); + continue; + case 36: + if (tag !== 290) { + break; + } + + message.objcClassPrefix = reader.string(); + continue; + case 37: + if (tag !== 298) { + break; + } + + message.csharpNamespace = reader.string(); + continue; + case 39: + if (tag !== 314) { + break; + } + + message.swiftPrefix = reader.string(); + continue; + case 40: + if (tag !== 322) { + break; + } + + message.phpClassPrefix = reader.string(); + continue; + case 41: + if (tag !== 330) { + break; + } + + message.phpNamespace = reader.string(); + continue; + case 44: + if (tag !== 354) { + break; + } + + message.phpMetadataNamespace = reader.string(); + continue; + case 45: + if (tag !== 362) { + break; + } + + message.rubyPackage = reader.string(); + continue; + case 999: + if (tag !== 7994) { + break; + } + + message.uninterpretedOption.push(UninterpretedOption.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): FileOptions { + return { + javaPackage: isSet(object.javaPackage) ? globalThis.String(object.javaPackage) : '', + javaOuterClassname: isSet(object.javaOuterClassname) ? globalThis.String(object.javaOuterClassname) : '', + javaMultipleFiles: isSet(object.javaMultipleFiles) ? globalThis.Boolean(object.javaMultipleFiles) : false, + javaGenerateEqualsAndHash: isSet(object.javaGenerateEqualsAndHash) + ? globalThis.Boolean(object.javaGenerateEqualsAndHash) + : false, + javaStringCheckUtf8: isSet(object.javaStringCheckUtf8) + ? globalThis.Boolean(object.javaStringCheckUtf8) + : false, + optimizeFor: isSet(object.optimizeFor) ? fileOptions_OptimizeModeFromJSON(object.optimizeFor) : 1, + goPackage: isSet(object.goPackage) ? globalThis.String(object.goPackage) : '', + ccGenericServices: isSet(object.ccGenericServices) ? globalThis.Boolean(object.ccGenericServices) : false, + javaGenericServices: isSet(object.javaGenericServices) + ? globalThis.Boolean(object.javaGenericServices) + : false, + pyGenericServices: isSet(object.pyGenericServices) ? globalThis.Boolean(object.pyGenericServices) : false, + phpGenericServices: isSet(object.phpGenericServices) + ? globalThis.Boolean(object.phpGenericServices) + : false, + deprecated: isSet(object.deprecated) ? globalThis.Boolean(object.deprecated) : false, + ccEnableArenas: isSet(object.ccEnableArenas) ? globalThis.Boolean(object.ccEnableArenas) : false, + objcClassPrefix: isSet(object.objcClassPrefix) ? globalThis.String(object.objcClassPrefix) : '', + csharpNamespace: isSet(object.csharpNamespace) ? globalThis.String(object.csharpNamespace) : '', + swiftPrefix: isSet(object.swiftPrefix) ? globalThis.String(object.swiftPrefix) : '', + phpClassPrefix: isSet(object.phpClassPrefix) ? globalThis.String(object.phpClassPrefix) : '', + phpNamespace: isSet(object.phpNamespace) ? globalThis.String(object.phpNamespace) : '', + phpMetadataNamespace: isSet(object.phpMetadataNamespace) + ? globalThis.String(object.phpMetadataNamespace) + : '', + rubyPackage: isSet(object.rubyPackage) ? globalThis.String(object.rubyPackage) : '', + uninterpretedOption: globalThis.Array.isArray(object?.uninterpretedOption) + ? object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)) + : [], + }; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + if (message.javaPackage !== '') { + obj.javaPackage = message.javaPackage; + } + if (message.javaOuterClassname !== '') { + obj.javaOuterClassname = message.javaOuterClassname; + } + if (message.javaMultipleFiles === true) { + obj.javaMultipleFiles = message.javaMultipleFiles; + } + if (message.javaGenerateEqualsAndHash === true) { + obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash; + } + if (message.javaStringCheckUtf8 === true) { + obj.javaStringCheckUtf8 = message.javaStringCheckUtf8; + } + if (message.optimizeFor !== 1) { + obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor); + } + if (message.goPackage !== '') { + obj.goPackage = message.goPackage; + } + if (message.ccGenericServices === true) { + obj.ccGenericServices = message.ccGenericServices; + } + if (message.javaGenericServices === true) { + obj.javaGenericServices = message.javaGenericServices; + } + if (message.pyGenericServices === true) { + obj.pyGenericServices = message.pyGenericServices; + } + if (message.phpGenericServices === true) { + obj.phpGenericServices = message.phpGenericServices; + } + if (message.deprecated === true) { + obj.deprecated = message.deprecated; + } + if (message.ccEnableArenas === true) { + obj.ccEnableArenas = message.ccEnableArenas; + } + if (message.objcClassPrefix !== '') { + obj.objcClassPrefix = message.objcClassPrefix; + } + if (message.csharpNamespace !== '') { + obj.csharpNamespace = message.csharpNamespace; + } + if (message.swiftPrefix !== '') { + obj.swiftPrefix = message.swiftPrefix; + } + if (message.phpClassPrefix !== '') { + obj.phpClassPrefix = message.phpClassPrefix; + } + if (message.phpNamespace !== '') { + obj.phpNamespace = message.phpNamespace; + } + if (message.phpMetadataNamespace !== '') { + obj.phpMetadataNamespace = message.phpMetadataNamespace; + } + if (message.rubyPackage !== '') { + obj.rubyPackage = message.rubyPackage; + } + if (message.uninterpretedOption?.length) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => UninterpretedOption.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): FileOptions { + return FileOptions.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): FileOptions { + const message = createBaseFileOptions(); + message.javaPackage = object.javaPackage ?? ''; + message.javaOuterClassname = object.javaOuterClassname ?? ''; + message.javaMultipleFiles = object.javaMultipleFiles ?? false; + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash ?? false; + message.javaStringCheckUtf8 = object.javaStringCheckUtf8 ?? false; + message.optimizeFor = object.optimizeFor ?? 1; + message.goPackage = object.goPackage ?? ''; + message.ccGenericServices = object.ccGenericServices ?? false; + message.javaGenericServices = object.javaGenericServices ?? false; + message.pyGenericServices = object.pyGenericServices ?? false; + message.phpGenericServices = object.phpGenericServices ?? false; + message.deprecated = object.deprecated ?? false; + message.ccEnableArenas = object.ccEnableArenas ?? false; + message.objcClassPrefix = object.objcClassPrefix ?? ''; + message.csharpNamespace = object.csharpNamespace ?? ''; + message.swiftPrefix = object.swiftPrefix ?? ''; + message.phpClassPrefix = object.phpClassPrefix ?? ''; + message.phpNamespace = object.phpNamespace ?? ''; + message.phpMetadataNamespace = object.phpMetadataNamespace ?? ''; + message.rubyPackage = object.rubyPackage ?? ''; + message.uninterpretedOption = object.uninterpretedOption?.map((e) => UninterpretedOption.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseMessageOptions(): MessageOptions { + return { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, + uninterpretedOption: [], + }; +} + +export const MessageOptions = { + encode(message: MessageOptions, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMessageOptions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.messageSetWireFormat = reader.bool(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.noStandardDescriptorAccessor = reader.bool(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.deprecated = reader.bool(); + continue; + case 7: + if (tag !== 56) { + break; + } + + message.mapEntry = reader.bool(); + continue; + case 999: + if (tag !== 7994) { + break; + } + + message.uninterpretedOption.push(UninterpretedOption.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): MessageOptions { + return { + messageSetWireFormat: isSet(object.messageSetWireFormat) + ? globalThis.Boolean(object.messageSetWireFormat) + : false, + noStandardDescriptorAccessor: isSet(object.noStandardDescriptorAccessor) + ? globalThis.Boolean(object.noStandardDescriptorAccessor) + : false, + deprecated: isSet(object.deprecated) ? globalThis.Boolean(object.deprecated) : false, + mapEntry: isSet(object.mapEntry) ? globalThis.Boolean(object.mapEntry) : false, + uninterpretedOption: globalThis.Array.isArray(object?.uninterpretedOption) + ? object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)) + : [], + }; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + if (message.messageSetWireFormat === true) { + obj.messageSetWireFormat = message.messageSetWireFormat; + } + if (message.noStandardDescriptorAccessor === true) { + obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor; + } + if (message.deprecated === true) { + obj.deprecated = message.deprecated; + } + if (message.mapEntry === true) { + obj.mapEntry = message.mapEntry; + } + if (message.uninterpretedOption?.length) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => UninterpretedOption.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): MessageOptions { + return MessageOptions.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): MessageOptions { + const message = createBaseMessageOptions(); + message.messageSetWireFormat = object.messageSetWireFormat ?? false; + message.noStandardDescriptorAccessor = object.noStandardDescriptorAccessor ?? false; + message.deprecated = object.deprecated ?? false; + message.mapEntry = object.mapEntry ?? false; + message.uninterpretedOption = object.uninterpretedOption?.map((e) => UninterpretedOption.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseFieldOptions(): FieldOptions { + return { ctype: 0, packed: false, jstype: 0, lazy: false, deprecated: false, weak: false, uninterpretedOption: [] }; +} + +export const FieldOptions = { + encode(message: FieldOptions, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFieldOptions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.ctype = reader.int32() as any; + continue; + case 2: + if (tag !== 16) { + break; + } + + message.packed = reader.bool(); + continue; + case 6: + if (tag !== 48) { + break; + } + + message.jstype = reader.int32() as any; + continue; + case 5: + if (tag !== 40) { + break; + } + + message.lazy = reader.bool(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.deprecated = reader.bool(); + continue; + case 10: + if (tag !== 80) { + break; + } + + message.weak = reader.bool(); + continue; + case 999: + if (tag !== 7994) { + break; + } + + message.uninterpretedOption.push(UninterpretedOption.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): FieldOptions { + return { + ctype: isSet(object.ctype) ? fieldOptions_CTypeFromJSON(object.ctype) : 0, + packed: isSet(object.packed) ? globalThis.Boolean(object.packed) : false, + jstype: isSet(object.jstype) ? fieldOptions_JSTypeFromJSON(object.jstype) : 0, + lazy: isSet(object.lazy) ? globalThis.Boolean(object.lazy) : false, + deprecated: isSet(object.deprecated) ? globalThis.Boolean(object.deprecated) : false, + weak: isSet(object.weak) ? globalThis.Boolean(object.weak) : false, + uninterpretedOption: globalThis.Array.isArray(object?.uninterpretedOption) + ? object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)) + : [], + }; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + if (message.ctype !== 0) { + obj.ctype = fieldOptions_CTypeToJSON(message.ctype); + } + if (message.packed === true) { + obj.packed = message.packed; + } + if (message.jstype !== 0) { + obj.jstype = fieldOptions_JSTypeToJSON(message.jstype); + } + if (message.lazy === true) { + obj.lazy = message.lazy; + } + if (message.deprecated === true) { + obj.deprecated = message.deprecated; + } + if (message.weak === true) { + obj.weak = message.weak; + } + if (message.uninterpretedOption?.length) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => UninterpretedOption.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): FieldOptions { + return FieldOptions.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): FieldOptions { + const message = createBaseFieldOptions(); + message.ctype = object.ctype ?? 0; + message.packed = object.packed ?? false; + message.jstype = object.jstype ?? 0; + message.lazy = object.lazy ?? false; + message.deprecated = object.deprecated ?? false; + message.weak = object.weak ?? false; + message.uninterpretedOption = object.uninterpretedOption?.map((e) => UninterpretedOption.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseOneofOptions(): OneofOptions { + return { uninterpretedOption: [] }; +} + +export const OneofOptions = { + encode(message: OneofOptions, writer: pb.Writer = pb.Writer.create()): pb.Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOneofOptions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + if (tag !== 7994) { + break; + } + + message.uninterpretedOption.push(UninterpretedOption.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): OneofOptions { + return { + uninterpretedOption: globalThis.Array.isArray(object?.uninterpretedOption) + ? object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)) + : [], + }; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption?.length) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => UninterpretedOption.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): OneofOptions { + return OneofOptions.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): OneofOptions { + const message = createBaseOneofOptions(); + message.uninterpretedOption = object.uninterpretedOption?.map((e) => UninterpretedOption.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseEnumOptions(): EnumOptions { + return { allowAlias: false, deprecated: false, uninterpretedOption: [] }; +} + +export const EnumOptions = { + encode(message: EnumOptions, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEnumOptions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + if (tag !== 16) { + break; + } + + message.allowAlias = reader.bool(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.deprecated = reader.bool(); + continue; + case 999: + if (tag !== 7994) { + break; + } + + message.uninterpretedOption.push(UninterpretedOption.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): EnumOptions { + return { + allowAlias: isSet(object.allowAlias) ? globalThis.Boolean(object.allowAlias) : false, + deprecated: isSet(object.deprecated) ? globalThis.Boolean(object.deprecated) : false, + uninterpretedOption: globalThis.Array.isArray(object?.uninterpretedOption) + ? object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)) + : [], + }; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + if (message.allowAlias === true) { + obj.allowAlias = message.allowAlias; + } + if (message.deprecated === true) { + obj.deprecated = message.deprecated; + } + if (message.uninterpretedOption?.length) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => UninterpretedOption.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): EnumOptions { + return EnumOptions.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): EnumOptions { + const message = createBaseEnumOptions(); + message.allowAlias = object.allowAlias ?? false; + message.deprecated = object.deprecated ?? false; + message.uninterpretedOption = object.uninterpretedOption?.map((e) => UninterpretedOption.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseEnumValueOptions(): EnumValueOptions { + return { deprecated: false, uninterpretedOption: [] }; +} + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEnumValueOptions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.deprecated = reader.bool(); + continue; + case 999: + if (tag !== 7994) { + break; + } + + message.uninterpretedOption.push(UninterpretedOption.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + return { + deprecated: isSet(object.deprecated) ? globalThis.Boolean(object.deprecated) : false, + uninterpretedOption: globalThis.Array.isArray(object?.uninterpretedOption) + ? object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)) + : [], + }; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + if (message.deprecated === true) { + obj.deprecated = message.deprecated; + } + if (message.uninterpretedOption?.length) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => UninterpretedOption.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): EnumValueOptions { + return EnumValueOptions.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): EnumValueOptions { + const message = createBaseEnumValueOptions(); + message.deprecated = object.deprecated ?? false; + message.uninterpretedOption = object.uninterpretedOption?.map((e) => UninterpretedOption.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseServiceOptions(): ServiceOptions { + return { deprecated: false, uninterpretedOption: [] }; +} + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseServiceOptions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + if (tag !== 264) { + break; + } + + message.deprecated = reader.bool(); + continue; + case 999: + if (tag !== 7994) { + break; + } + + message.uninterpretedOption.push(UninterpretedOption.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + return { + deprecated: isSet(object.deprecated) ? globalThis.Boolean(object.deprecated) : false, + uninterpretedOption: globalThis.Array.isArray(object?.uninterpretedOption) + ? object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)) + : [], + }; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + if (message.deprecated === true) { + obj.deprecated = message.deprecated; + } + if (message.uninterpretedOption?.length) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => UninterpretedOption.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): ServiceOptions { + return ServiceOptions.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): ServiceOptions { + const message = createBaseServiceOptions(); + message.deprecated = object.deprecated ?? false; + message.uninterpretedOption = object.uninterpretedOption?.map((e) => UninterpretedOption.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseMethodOptions(): MethodOptions { + return { deprecated: false, idempotencyLevel: 0, uninterpretedOption: [] }; +} + +export const MethodOptions = { + encode(message: MethodOptions, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMethodOptions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + if (tag !== 264) { + break; + } + + message.deprecated = reader.bool(); + continue; + case 34: + if (tag !== 272) { + break; + } + + message.idempotencyLevel = reader.int32() as any; + continue; + case 999: + if (tag !== 7994) { + break; + } + + message.uninterpretedOption.push(UninterpretedOption.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): MethodOptions { + return { + deprecated: isSet(object.deprecated) ? globalThis.Boolean(object.deprecated) : false, + idempotencyLevel: isSet(object.idempotencyLevel) + ? methodOptions_IdempotencyLevelFromJSON(object.idempotencyLevel) + : 0, + uninterpretedOption: globalThis.Array.isArray(object?.uninterpretedOption) + ? object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)) + : [], + }; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + if (message.deprecated === true) { + obj.deprecated = message.deprecated; + } + if (message.idempotencyLevel !== 0) { + obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON(message.idempotencyLevel); + } + if (message.uninterpretedOption?.length) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => UninterpretedOption.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): MethodOptions { + return MethodOptions.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): MethodOptions { + const message = createBaseMethodOptions(); + message.deprecated = object.deprecated ?? false; + message.idempotencyLevel = object.idempotencyLevel ?? 0; + message.uninterpretedOption = object.uninterpretedOption?.map((e) => UninterpretedOption.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseUninterpretedOption(): UninterpretedOption { + return { + name: [], + identifierValue: '', + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + stringValue: new Uint8Array(0), + aggregateValue: '', + }; +} + +export const UninterpretedOption = { + encode(message: UninterpretedOption, writer: pb.Writer = pb.Writer.create()): pb.Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.identifierValue !== '') { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== '') { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUninterpretedOption(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + if (tag !== 18) { + break; + } + + message.name.push(UninterpretedOption_NamePart.decode(reader, reader.uint32())); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.identifierValue = reader.string(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.positiveIntValue = longToNumber(reader.uint64() as Long); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.negativeIntValue = longToNumber(reader.int64() as Long); + continue; + case 6: + if (tag !== 49) { + break; + } + + message.doubleValue = reader.double(); + continue; + case 7: + if (tag !== 58) { + break; + } + + message.stringValue = reader.bytes(); + continue; + case 8: + if (tag !== 66) { + break; + } + + message.aggregateValue = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + return { + name: globalThis.Array.isArray(object?.name) + ? object.name.map((e: any) => UninterpretedOption_NamePart.fromJSON(e)) + : [], + identifierValue: isSet(object.identifierValue) ? globalThis.String(object.identifierValue) : '', + positiveIntValue: isSet(object.positiveIntValue) ? globalThis.Number(object.positiveIntValue) : 0, + negativeIntValue: isSet(object.negativeIntValue) ? globalThis.Number(object.negativeIntValue) : 0, + doubleValue: isSet(object.doubleValue) ? globalThis.Number(object.doubleValue) : 0, + stringValue: isSet(object.stringValue) ? bytesFromBase64(object.stringValue) : new Uint8Array(0), + aggregateValue: isSet(object.aggregateValue) ? globalThis.String(object.aggregateValue) : '', + }; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name?.length) { + obj.name = message.name.map((e) => UninterpretedOption_NamePart.toJSON(e)); + } + if (message.identifierValue !== '') { + obj.identifierValue = message.identifierValue; + } + if (message.positiveIntValue !== 0) { + obj.positiveIntValue = Math.round(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + obj.negativeIntValue = Math.round(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + obj.doubleValue = message.doubleValue; + } + if (message.stringValue.length !== 0) { + obj.stringValue = base64FromBytes(message.stringValue); + } + if (message.aggregateValue !== '') { + obj.aggregateValue = message.aggregateValue; + } + return obj; + }, + + create, I>>(base?: I): UninterpretedOption { + return UninterpretedOption.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): UninterpretedOption { + const message = createBaseUninterpretedOption(); + message.name = object.name?.map((e) => UninterpretedOption_NamePart.fromPartial(e)) || []; + message.identifierValue = object.identifierValue ?? ''; + message.positiveIntValue = object.positiveIntValue ?? 0; + message.negativeIntValue = object.negativeIntValue ?? 0; + message.doubleValue = object.doubleValue ?? 0; + message.stringValue = object.stringValue ?? new Uint8Array(0); + message.aggregateValue = object.aggregateValue ?? ''; + return message; + }, +}; + +function createBaseUninterpretedOption_NamePart(): UninterpretedOption_NamePart { + return { namePart: '', isExtension: false }; +} + +export const UninterpretedOption_NamePart = { + encode(message: UninterpretedOption_NamePart, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.namePart !== '') { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): UninterpretedOption_NamePart { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUninterpretedOption_NamePart(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.namePart = reader.string(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.isExtension = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + return { + namePart: isSet(object.namePart) ? globalThis.String(object.namePart) : '', + isExtension: isSet(object.isExtension) ? globalThis.Boolean(object.isExtension) : false, + }; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + if (message.namePart !== '') { + obj.namePart = message.namePart; + } + if (message.isExtension === true) { + obj.isExtension = message.isExtension; + } + return obj; + }, + + create, I>>(base?: I): UninterpretedOption_NamePart { + return UninterpretedOption_NamePart.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): UninterpretedOption_NamePart { + const message = createBaseUninterpretedOption_NamePart(); + message.namePart = object.namePart ?? ''; + message.isExtension = object.isExtension ?? false; + return message; + }, +}; + +function createBaseSourceCodeInfo(): SourceCodeInfo { + return { location: [] }; +} + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: pb.Writer = pb.Writer.create()): pb.Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSourceCodeInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.location.push(SourceCodeInfo_Location.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + return { + location: globalThis.Array.isArray(object?.location) + ? object.location.map((e: any) => SourceCodeInfo_Location.fromJSON(e)) + : [], + }; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location?.length) { + obj.location = message.location.map((e) => SourceCodeInfo_Location.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): SourceCodeInfo { + return SourceCodeInfo.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): SourceCodeInfo { + const message = createBaseSourceCodeInfo(); + message.location = object.location?.map((e) => SourceCodeInfo_Location.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseSourceCodeInfo_Location(): SourceCodeInfo_Location { + return { path: [], span: [], leadingComments: '', trailingComments: '', leadingDetachedComments: [] }; +} + +export const SourceCodeInfo_Location = { + encode(message: SourceCodeInfo_Location, writer: pb.Writer = pb.Writer.create()): pb.Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== '') { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== '') { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSourceCodeInfo_Location(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag === 8) { + message.path.push(reader.int32()); + + continue; + } + + if (tag === 10) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + + continue; + } + + break; + case 2: + if (tag === 16) { + message.span.push(reader.int32()); + + continue; + } + + if (tag === 18) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + + continue; + } + + break; + case 3: + if (tag !== 26) { + break; + } + + message.leadingComments = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.trailingComments = reader.string(); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.leadingDetachedComments.push(reader.string()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + return { + path: globalThis.Array.isArray(object?.path) ? object.path.map((e: any) => globalThis.Number(e)) : [], + span: globalThis.Array.isArray(object?.span) ? object.span.map((e: any) => globalThis.Number(e)) : [], + leadingComments: isSet(object.leadingComments) ? globalThis.String(object.leadingComments) : '', + trailingComments: isSet(object.trailingComments) ? globalThis.String(object.trailingComments) : '', + leadingDetachedComments: globalThis.Array.isArray(object?.leadingDetachedComments) + ? object.leadingDetachedComments.map((e: any) => globalThis.String(e)) + : [], + }; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path?.length) { + obj.path = message.path.map((e) => Math.round(e)); + } + if (message.span?.length) { + obj.span = message.span.map((e) => Math.round(e)); + } + if (message.leadingComments !== '') { + obj.leadingComments = message.leadingComments; + } + if (message.trailingComments !== '') { + obj.trailingComments = message.trailingComments; + } + if (message.leadingDetachedComments?.length) { + obj.leadingDetachedComments = message.leadingDetachedComments; + } + return obj; + }, + + create, I>>(base?: I): SourceCodeInfo_Location { + return SourceCodeInfo_Location.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): SourceCodeInfo_Location { + const message = createBaseSourceCodeInfo_Location(); + message.path = object.path?.map((e) => e) || []; + message.span = object.span?.map((e) => e) || []; + message.leadingComments = object.leadingComments ?? ''; + message.trailingComments = object.trailingComments ?? ''; + message.leadingDetachedComments = object.leadingDetachedComments?.map((e) => e) || []; + return message; + }, +}; + +function createBaseGeneratedCodeInfo(): GeneratedCodeInfo { + return { annotation: [] }; +} + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: pb.Writer = pb.Writer.create()): pb.Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGeneratedCodeInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.annotation.push(GeneratedCodeInfo_Annotation.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + return { + annotation: globalThis.Array.isArray(object?.annotation) + ? object.annotation.map((e: any) => GeneratedCodeInfo_Annotation.fromJSON(e)) + : [], + }; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation?.length) { + obj.annotation = message.annotation.map((e) => GeneratedCodeInfo_Annotation.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): GeneratedCodeInfo { + return GeneratedCodeInfo.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): GeneratedCodeInfo { + const message = createBaseGeneratedCodeInfo(); + message.annotation = object.annotation?.map((e) => GeneratedCodeInfo_Annotation.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseGeneratedCodeInfo_Annotation(): GeneratedCodeInfo_Annotation { + return { path: [], sourceFile: '', begin: 0, end: 0 }; +} + +export const GeneratedCodeInfo_Annotation = { + encode(message: GeneratedCodeInfo_Annotation, writer: pb.Writer = pb.Writer.create()): pb.Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== '') { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): GeneratedCodeInfo_Annotation { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGeneratedCodeInfo_Annotation(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag === 8) { + message.path.push(reader.int32()); + + continue; + } + + if (tag === 10) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + + continue; + } + + break; + case 2: + if (tag !== 18) { + break; + } + + message.sourceFile = reader.string(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.begin = reader.int32(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.end = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + return { + path: globalThis.Array.isArray(object?.path) ? object.path.map((e: any) => globalThis.Number(e)) : [], + sourceFile: isSet(object.sourceFile) ? globalThis.String(object.sourceFile) : '', + begin: isSet(object.begin) ? globalThis.Number(object.begin) : 0, + end: isSet(object.end) ? globalThis.Number(object.end) : 0, + }; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path?.length) { + obj.path = message.path.map((e) => Math.round(e)); + } + if (message.sourceFile !== '') { + obj.sourceFile = message.sourceFile; + } + if (message.begin !== 0) { + obj.begin = Math.round(message.begin); + } + if (message.end !== 0) { + obj.end = Math.round(message.end); + } + return obj; + }, + + create, I>>(base?: I): GeneratedCodeInfo_Annotation { + return GeneratedCodeInfo_Annotation.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): GeneratedCodeInfo_Annotation { + const message = createBaseGeneratedCodeInfo_Annotation(); + message.path = object.path?.map((e) => e) || []; + message.sourceFile = object.sourceFile ?? ''; + message.begin = object.begin ?? 0; + message.end = object.end ?? 0; + return message; + }, +}; + +function bytesFromBase64(b64: string): Uint8Array { + const bin = globalThis.atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + arr.forEach((byte) => { + bin.push(globalThis.String.fromCharCode(byte)); + }); + return globalThis.btoa(bin.join('')); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function longToNumber(long: Long): number { + if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + } + return long.toNumber(); +} + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/examples/custom/p2ce/netmessages.ts b/examples/custom/p2ce/netmessages.ts new file mode 100644 index 0000000..e3670f8 --- /dev/null +++ b/examples/custom/p2ce/netmessages.ts @@ -0,0 +1,7437 @@ +import pb from 'npm:protobufjs/minimal.js'; +import Long from 'npm:long'; +import { + ENetworkDisconnectionReason, + eNetworkDisconnectionReasonFromJSON, + eNetworkDisconnectionReasonToJSON, +} from './network_connection.ts'; + +export const protobufPackage = ''; + +export enum NETMessages { + net_NOP = 0, + net_Disconnect = 1, + net_File = 2, + net_SplitScreenUser = 3, + net_Tick = 4, + net_StringCmd = 5, + net_SetConVar = 6, + net_SignonState = 7, + net_PlayerAvatarData = 100, + UNRECOGNIZED = -1, +} + +export function nETMessagesFromJSON(object: any): NETMessages { + switch (object) { + case 0: + case 'net_NOP': + return NETMessages.net_NOP; + case 1: + case 'net_Disconnect': + return NETMessages.net_Disconnect; + case 2: + case 'net_File': + return NETMessages.net_File; + case 3: + case 'net_SplitScreenUser': + return NETMessages.net_SplitScreenUser; + case 4: + case 'net_Tick': + return NETMessages.net_Tick; + case 5: + case 'net_StringCmd': + return NETMessages.net_StringCmd; + case 6: + case 'net_SetConVar': + return NETMessages.net_SetConVar; + case 7: + case 'net_SignonState': + return NETMessages.net_SignonState; + case 100: + case 'net_PlayerAvatarData': + return NETMessages.net_PlayerAvatarData; + case -1: + case 'UNRECOGNIZED': + default: + return NETMessages.UNRECOGNIZED; + } +} + +export function nETMessagesToJSON(object: NETMessages): string | undefined { + switch (object) { + case NETMessages.net_NOP: + return 'net_NOP'; + case NETMessages.net_Disconnect: + return 'net_Disconnect'; + case NETMessages.net_File: + return 'net_File'; + case NETMessages.net_SplitScreenUser: + return 'net_SplitScreenUser'; + case NETMessages.net_Tick: + return 'net_Tick'; + case NETMessages.net_StringCmd: + return 'net_StringCmd'; + case NETMessages.net_SetConVar: + return 'net_SetConVar'; + case NETMessages.net_SignonState: + return 'net_SignonState'; + case NETMessages.net_PlayerAvatarData: + return 'net_PlayerAvatarData'; + case NETMessages.UNRECOGNIZED: + default: + return undefined; + } +} + +export enum CLCMessages { + clc_ClientInfo = 8, + clc_Move = 9, + clc_VoiceData = 10, + clc_BaselineAck = 11, + clc_ListenEvents = 12, + clc_RespondCvarValue = 13, + clc_FileCRCCheck = 14, + clc_LoadingProgress = 15, + clc_SplitPlayerConnect = 16, + clc_ClientMessage = 17, + clc_CmdKeyValues = 18, + clc_HltvReplay = 20, + clc_HltvFixupOperatorTick = 21, + clc_HltvFixupOperatorReceiver = 22, + UNRECOGNIZED = -1, +} + +export function cLCMessagesFromJSON(object: any): CLCMessages { + switch (object) { + case 8: + case 'clc_ClientInfo': + return CLCMessages.clc_ClientInfo; + case 9: + case 'clc_Move': + return CLCMessages.clc_Move; + case 10: + case 'clc_VoiceData': + return CLCMessages.clc_VoiceData; + case 11: + case 'clc_BaselineAck': + return CLCMessages.clc_BaselineAck; + case 12: + case 'clc_ListenEvents': + return CLCMessages.clc_ListenEvents; + case 13: + case 'clc_RespondCvarValue': + return CLCMessages.clc_RespondCvarValue; + case 14: + case 'clc_FileCRCCheck': + return CLCMessages.clc_FileCRCCheck; + case 15: + case 'clc_LoadingProgress': + return CLCMessages.clc_LoadingProgress; + case 16: + case 'clc_SplitPlayerConnect': + return CLCMessages.clc_SplitPlayerConnect; + case 17: + case 'clc_ClientMessage': + return CLCMessages.clc_ClientMessage; + case 18: + case 'clc_CmdKeyValues': + return CLCMessages.clc_CmdKeyValues; + case 20: + case 'clc_HltvReplay': + return CLCMessages.clc_HltvReplay; + case 21: + case 'clc_HltvFixupOperatorTick': + return CLCMessages.clc_HltvFixupOperatorTick; + case 22: + case 'clc_HltvFixupOperatorReceiver': + return CLCMessages.clc_HltvFixupOperatorReceiver; + case -1: + case 'UNRECOGNIZED': + default: + return CLCMessages.UNRECOGNIZED; + } +} + +export function cLCMessagesToJSON(object: CLCMessages): string | undefined { + switch (object) { + case CLCMessages.clc_ClientInfo: + return 'clc_ClientInfo'; + case CLCMessages.clc_Move: + return 'clc_Move'; + case CLCMessages.clc_VoiceData: + return 'clc_VoiceData'; + case CLCMessages.clc_BaselineAck: + return 'clc_BaselineAck'; + case CLCMessages.clc_ListenEvents: + return 'clc_ListenEvents'; + case CLCMessages.clc_RespondCvarValue: + return 'clc_RespondCvarValue'; + case CLCMessages.clc_FileCRCCheck: + return 'clc_FileCRCCheck'; + case CLCMessages.clc_LoadingProgress: + return 'clc_LoadingProgress'; + case CLCMessages.clc_SplitPlayerConnect: + return 'clc_SplitPlayerConnect'; + case CLCMessages.clc_ClientMessage: + return 'clc_ClientMessage'; + case CLCMessages.clc_CmdKeyValues: + return 'clc_CmdKeyValues'; + case CLCMessages.clc_HltvReplay: + return 'clc_HltvReplay'; + case CLCMessages.clc_HltvFixupOperatorTick: + return 'clc_HltvFixupOperatorTick'; + case CLCMessages.clc_HltvFixupOperatorReceiver: + return 'clc_HltvFixupOperatorReceiver'; + case CLCMessages.UNRECOGNIZED: + default: + return undefined; + } +} + +export enum VoiceDataFormatT { + VOICEDATA_FORMAT_STEAM = 0, + VOICEDATA_FORMAT_ENGINE = 1, + UNRECOGNIZED = -1, +} + +export function voiceDataFormatTFromJSON(object: any): VoiceDataFormatT { + switch (object) { + case 0: + case 'VOICEDATA_FORMAT_STEAM': + return VoiceDataFormatT.VOICEDATA_FORMAT_STEAM; + case 1: + case 'VOICEDATA_FORMAT_ENGINE': + return VoiceDataFormatT.VOICEDATA_FORMAT_ENGINE; + case -1: + case 'UNRECOGNIZED': + default: + return VoiceDataFormatT.UNRECOGNIZED; + } +} + +export function voiceDataFormatTToJSON(object: VoiceDataFormatT): string { + switch (object) { + case VoiceDataFormatT.VOICEDATA_FORMAT_STEAM: + return 'VOICEDATA_FORMAT_STEAM'; + case VoiceDataFormatT.VOICEDATA_FORMAT_ENGINE: + return 'VOICEDATA_FORMAT_ENGINE'; + case VoiceDataFormatT.UNRECOGNIZED: + default: + return 'UNRECOGNIZED'; + } +} + +export enum ESplitScreenMessageType { + MSG_SPLITSCREEN_ADDUSER = 0, + MSG_SPLITSCREEN_REMOVEUSER = 1, + MSG_SPLITSCREEN_TYPE_BITS = 1, + UNRECOGNIZED = -1, +} + +export function eSplitScreenMessageTypeFromJSON(object: any): ESplitScreenMessageType { + switch (object) { + case 0: + case 'MSG_SPLITSCREEN_ADDUSER': + return ESplitScreenMessageType.MSG_SPLITSCREEN_ADDUSER; + case 1: + case 'MSG_SPLITSCREEN_REMOVEUSER': + return ESplitScreenMessageType.MSG_SPLITSCREEN_REMOVEUSER; + case 1: + case 'MSG_SPLITSCREEN_TYPE_BITS': + return ESplitScreenMessageType.MSG_SPLITSCREEN_TYPE_BITS; + case -1: + case 'UNRECOGNIZED': + default: + return ESplitScreenMessageType.UNRECOGNIZED; + } +} + +export function eSplitScreenMessageTypeToJSON(object: ESplitScreenMessageType): string { + switch (object) { + case ESplitScreenMessageType.MSG_SPLITSCREEN_ADDUSER: + return 'MSG_SPLITSCREEN_ADDUSER'; + case ESplitScreenMessageType.MSG_SPLITSCREEN_REMOVEUSER: + return 'MSG_SPLITSCREEN_REMOVEUSER'; + case ESplitScreenMessageType.MSG_SPLITSCREEN_TYPE_BITS: + return 'MSG_SPLITSCREEN_TYPE_BITS'; + case ESplitScreenMessageType.UNRECOGNIZED: + default: + return 'UNRECOGNIZED'; + } +} + +export enum SVCMessages { + svc_ServerInfo = 8, + svc_SendTable = 9, + svc_ClassInfo = 10, + svc_SetPause = 11, + svc_CreateStringTable = 12, + svc_UpdateStringTable = 13, + svc_VoiceInit = 14, + svc_VoiceData = 15, + svc_Print = 16, + svc_Sounds = 17, + svc_SetView = 18, + svc_FixAngle = 19, + svc_CrosshairAngle = 20, + svc_BSPDecal = 21, + svc_SplitScreen = 22, + svc_UserMessage = 23, + svc_EntityMessage = 24, + svc_GameEvent = 25, + svc_PacketEntities = 26, + svc_TempEntities = 27, + svc_Prefetch = 28, + svc_GameEventList = 30, + svc_GetCvarValue = 31, + svc_PaintmapData = 33, + svc_CmdKeyValues = 34, + svc_EncryptedData = 35, + svc_HltvReplay = 36, + svc_Broadcast_Command = 38, + svc_HltvFixupOperatorStatus = 39, + UNRECOGNIZED = -1, +} + +export function sVCMessagesFromJSON(object: any): SVCMessages { + switch (object) { + case 8: + case 'svc_ServerInfo': + return SVCMessages.svc_ServerInfo; + case 9: + case 'svc_SendTable': + return SVCMessages.svc_SendTable; + case 10: + case 'svc_ClassInfo': + return SVCMessages.svc_ClassInfo; + case 11: + case 'svc_SetPause': + return SVCMessages.svc_SetPause; + case 12: + case 'svc_CreateStringTable': + return SVCMessages.svc_CreateStringTable; + case 13: + case 'svc_UpdateStringTable': + return SVCMessages.svc_UpdateStringTable; + case 14: + case 'svc_VoiceInit': + return SVCMessages.svc_VoiceInit; + case 15: + case 'svc_VoiceData': + return SVCMessages.svc_VoiceData; + case 16: + case 'svc_Print': + return SVCMessages.svc_Print; + case 17: + case 'svc_Sounds': + return SVCMessages.svc_Sounds; + case 18: + case 'svc_SetView': + return SVCMessages.svc_SetView; + case 19: + case 'svc_FixAngle': + return SVCMessages.svc_FixAngle; + case 20: + case 'svc_CrosshairAngle': + return SVCMessages.svc_CrosshairAngle; + case 21: + case 'svc_BSPDecal': + return SVCMessages.svc_BSPDecal; + case 22: + case 'svc_SplitScreen': + return SVCMessages.svc_SplitScreen; + case 23: + case 'svc_UserMessage': + return SVCMessages.svc_UserMessage; + case 24: + case 'svc_EntityMessage': + return SVCMessages.svc_EntityMessage; + case 25: + case 'svc_GameEvent': + return SVCMessages.svc_GameEvent; + case 26: + case 'svc_PacketEntities': + return SVCMessages.svc_PacketEntities; + case 27: + case 'svc_TempEntities': + return SVCMessages.svc_TempEntities; + case 28: + case 'svc_Prefetch': + return SVCMessages.svc_Prefetch; + case 30: + case 'svc_GameEventList': + return SVCMessages.svc_GameEventList; + case 31: + case 'svc_GetCvarValue': + return SVCMessages.svc_GetCvarValue; + case 33: + case 'svc_PaintmapData': + return SVCMessages.svc_PaintmapData; + case 34: + case 'svc_CmdKeyValues': + return SVCMessages.svc_CmdKeyValues; + case 35: + case 'svc_EncryptedData': + return SVCMessages.svc_EncryptedData; + case 36: + case 'svc_HltvReplay': + return SVCMessages.svc_HltvReplay; + case 38: + case 'svc_Broadcast_Command': + return SVCMessages.svc_Broadcast_Command; + case 39: + case 'svc_HltvFixupOperatorStatus': + return SVCMessages.svc_HltvFixupOperatorStatus; + case -1: + case 'UNRECOGNIZED': + default: + return SVCMessages.UNRECOGNIZED; + } +} + +export function sVCMessagesToJSON(object: SVCMessages): string | undefined { + switch (object) { + case SVCMessages.svc_ServerInfo: + return 'svc_ServerInfo'; + case SVCMessages.svc_SendTable: + return 'svc_SendTable'; + case SVCMessages.svc_ClassInfo: + return 'svc_ClassInfo'; + case SVCMessages.svc_SetPause: + return 'svc_SetPause'; + case SVCMessages.svc_CreateStringTable: + return 'svc_CreateStringTable'; + case SVCMessages.svc_UpdateStringTable: + return 'svc_UpdateStringTable'; + case SVCMessages.svc_VoiceInit: + return 'svc_VoiceInit'; + case SVCMessages.svc_VoiceData: + return 'svc_VoiceData'; + case SVCMessages.svc_Print: + return 'svc_Print'; + case SVCMessages.svc_Sounds: + return 'svc_Sounds'; + case SVCMessages.svc_SetView: + return 'svc_SetView'; + case SVCMessages.svc_FixAngle: + return 'svc_FixAngle'; + case SVCMessages.svc_CrosshairAngle: + return 'svc_CrosshairAngle'; + case SVCMessages.svc_BSPDecal: + return 'svc_BSPDecal'; + case SVCMessages.svc_SplitScreen: + return 'svc_SplitScreen'; + case SVCMessages.svc_UserMessage: + return 'svc_UserMessage'; + case SVCMessages.svc_EntityMessage: + return 'svc_EntityMessage'; + case SVCMessages.svc_GameEvent: + return 'svc_GameEvent'; + case SVCMessages.svc_PacketEntities: + return 'svc_PacketEntities'; + case SVCMessages.svc_TempEntities: + return 'svc_TempEntities'; + case SVCMessages.svc_Prefetch: + return 'svc_Prefetch'; + case SVCMessages.svc_GameEventList: + return 'svc_GameEventList'; + case SVCMessages.svc_GetCvarValue: + return 'svc_GetCvarValue'; + case SVCMessages.svc_PaintmapData: + return 'svc_PaintmapData'; + case SVCMessages.svc_CmdKeyValues: + return 'svc_CmdKeyValues'; + case SVCMessages.svc_EncryptedData: + return 'svc_EncryptedData'; + case SVCMessages.svc_HltvReplay: + return 'svc_HltvReplay'; + case SVCMessages.svc_Broadcast_Command: + return 'svc_Broadcast_Command'; + case SVCMessages.svc_HltvFixupOperatorStatus: + return 'svc_HltvFixupOperatorStatus'; + case SVCMessages.UNRECOGNIZED: + default: + return undefined; + } +} + +export enum ReplayEventTypeT { + REPLAY_EVENT_CANCEL = 0, + REPLAY_EVENT_DEATH = 1, + REPLAY_EVENT_GENERIC = 2, + REPLAY_EVENT_STUCK_NEED_FULL_UPDATE = 3, + REPLAY_EVENT_VICTORY = 4, + UNRECOGNIZED = -1, +} + +export function replayEventTypeTFromJSON(object: any): ReplayEventTypeT { + switch (object) { + case 0: + case 'REPLAY_EVENT_CANCEL': + return ReplayEventTypeT.REPLAY_EVENT_CANCEL; + case 1: + case 'REPLAY_EVENT_DEATH': + return ReplayEventTypeT.REPLAY_EVENT_DEATH; + case 2: + case 'REPLAY_EVENT_GENERIC': + return ReplayEventTypeT.REPLAY_EVENT_GENERIC; + case 3: + case 'REPLAY_EVENT_STUCK_NEED_FULL_UPDATE': + return ReplayEventTypeT.REPLAY_EVENT_STUCK_NEED_FULL_UPDATE; + case 4: + case 'REPLAY_EVENT_VICTORY': + return ReplayEventTypeT.REPLAY_EVENT_VICTORY; + case -1: + case 'UNRECOGNIZED': + default: + return ReplayEventTypeT.UNRECOGNIZED; + } +} + +export function replayEventTypeTToJSON(object: ReplayEventTypeT): string { + switch (object) { + case ReplayEventTypeT.REPLAY_EVENT_CANCEL: + return 'REPLAY_EVENT_CANCEL'; + case ReplayEventTypeT.REPLAY_EVENT_DEATH: + return 'REPLAY_EVENT_DEATH'; + case ReplayEventTypeT.REPLAY_EVENT_GENERIC: + return 'REPLAY_EVENT_GENERIC'; + case ReplayEventTypeT.REPLAY_EVENT_STUCK_NEED_FULL_UPDATE: + return 'REPLAY_EVENT_STUCK_NEED_FULL_UPDATE'; + case ReplayEventTypeT.REPLAY_EVENT_VICTORY: + return 'REPLAY_EVENT_VICTORY'; + case ReplayEventTypeT.UNRECOGNIZED: + default: + return 'UNRECOGNIZED'; + } +} + +export interface CMsgVector { + x: number; + y: number; + z: number; +} + +export interface CMsgVector2D { + x: number; + y: number; +} + +export interface CMsgQAngle { + x: number; + y: number; + z: number; +} + +export interface CMsgRGBA { + r: number; + g: number; + b: number; + a: number; +} + +export interface CNETMsgTick { + tick: number; + hostComputationtime: number; + hostComputationtimeStdDeviation: number; + hostFramestarttimeStdDeviation: number; + hltvReplayFlags: number; +} + +export interface CNETMsgStringCmd { + command: string; +} + +export interface CNETMsgSignonState { + signonState: number; + spawnCount: number; + numServerPlayers: number; + playersNetworkids: string[]; + mapName: string; +} + +export interface CMsgCVars { + cvars: CMsgCVars_CVar[]; +} + +export interface CMsgCVars_CVar { + name: string; + value: string; + dictionaryName: number; +} + +export interface CNETMsgSetConVar { + convars: CMsgCVars | undefined; +} + +export interface CNETMsgNOP { +} + +export interface CNETMsgDisconnect { + reason: ENetworkDisconnectionReason; +} + +export interface CNETMsgFile { + transferId: number; + fileName: string; + isReplayDemoFile: boolean; + deny: boolean; +} + +export interface CNETMsgSplitScreenUser { + slot: number; +} + +export interface CNETMsgPlayerAvatarData { + accountid: number; + rgb: Uint8Array; +} + +export interface CCLCMsgClientInfo { + sendTableCrc: number; + serverCount: number; + isHltv: boolean; + isReplay: boolean; + friendsId: number; + friendsName: string; + customFiles: number[]; +} + +export interface CCLCMsgMove { + numBackupCommands: number; + numNewCommands: number; + data: Uint8Array; +} + +export interface CCLCMsgVoiceData { + data: Uint8Array; + xuid: number; + format: VoiceDataFormatT; + sequenceBytes: number; + sectionNumber: number; + uncompressedSampleOffset: number; +} + +export interface CCLCMsgBaselineAck { + baselineTick: number; + baselineNr: number; +} + +export interface CCLCMsgListenEvents { + eventMask: number[]; +} + +export interface CCLCMsgRespondCvarValue { + cookie: number; + statusCode: number; + name: string; + value: string; +} + +export interface CCLCMsgFileCRCCheck { + codePath: number; + path: string; + codeFilename: number; + filename: string; + fileFraction: number; + md5: Uint8Array; + crc: number; + fileHashType: number; + fileLen: number; + packFileId: number; + packFileNumber: number; +} + +export interface CCLCMsgLoadingProgress { + progress: number; +} + +export interface CCLCMsgSplitPlayerConnect { + convars: CMsgCVars | undefined; +} + +export interface CCLCMsgCmdKeyValues { + keyvalues: Uint8Array; +} + +export interface CSVCMsgServerInfo { + protocol: number; + serverCount: number; + isDedicated: boolean; + isOfficialValveServer: boolean; + isHltv: boolean; + isReplay: boolean; + isRedirectingToProxyRelay: boolean; + cOs: number; + mapCrc: number; + clientCrc: number; + stringTableCrc: number; + maxClients: number; + maxClasses: number; + playerSlot: number; + tickInterval: number; + gameDir: string; + mapName: string; + mapGroupName: string; + skyName: string; + hostName: string; + publicIp: number; + ugcMapId: number; +} + +export interface CSVCMsgClassInfo { + createOnClient: boolean; + classes: CSVCMsgClassInfo_classT[]; +} + +export interface CSVCMsgClassInfo_classT { + classId: number; + dataTableName: string; + className: string; +} + +export interface CSVCMsgSendTable { + isEnd: boolean; + netTableName: string; + needsDecoder: boolean; + props: CSVCMsgSendTable_sendpropT[]; +} + +export interface CSVCMsgSendTable_sendpropT { + type: number; + varName: string; + flags: number; + priority: number; + dtName: string; + numElements: number; + lowValue: number; + highValue: number; + numBits: number; +} + +export interface CSVCMsgPrint { + text: string; +} + +export interface CSVCMsgSetPause { + paused: boolean; +} + +export interface CSVCMsgSetView { + entityIndex: number; +} + +export interface CSVCMsgCreateStringTable { + name: string; + maxEntries: number; + numEntries: number; + userDataFixedSize: boolean; + userDataSize: number; + userDataSizeBits: number; + flags: number; + stringData: Uint8Array; +} + +export interface CSVCMsgUpdateStringTable { + tableId: number; + numChangedEntries: number; + stringData: Uint8Array; +} + +export interface CSVCMsgVoiceInit { + quality: number; + codec: string; + version: number; +} + +export interface CSVCMsgVoiceData { + client: number; + proximity: boolean; + xuid: number; + audibleMask: number; + voiceData: Uint8Array; + caster: boolean; + format: VoiceDataFormatT; + sequenceBytes: number; + sectionNumber: number; + uncompressedSampleOffset: number; +} + +export interface CSVCMsgFixAngle { + relative: boolean; + angle: CMsgQAngle | undefined; +} + +export interface CSVCMsgCrosshairAngle { + angle: CMsgQAngle | undefined; +} + +export interface CSVCMsgPrefetch { + soundIndex: number; +} + +export interface CSVCMsgBSPDecal { + pos: CMsgVector | undefined; + decalTextureIndex: number; + entityIndex: number; + modelIndex: number; + lowPriority: boolean; +} + +export interface CSVCMsgSplitScreen { + type: ESplitScreenMessageType; + slot: number; + playerIndex: number; +} + +export interface CSVCMsgGetCvarValue { + cookie: number; + cvarName: string; +} + +export interface CSVCMsgUserMessage { + msgType: number; + msgData: Uint8Array; + passthrough: number; +} + +export interface CSVCMsgPaintmapData { + paintmap: Uint8Array; +} + +export interface CSVCMsgGameEvent { + eventName: string; + eventid: number; + keys: CSVCMsgGameEvent_keyT[]; + passthrough: number; +} + +export interface CSVCMsgGameEvent_keyT { + type: number; + valString: string; + valFloat: number; + valLong: number; + valShort: number; + valByte: number; + valBool: boolean; + valUint64: number; + valWstring: Uint8Array; +} + +export interface CSVCMsgGameEventList { + descriptors: CSVCMsgGameEventList_descriptorT[]; +} + +export interface CSVCMsgGameEventList_keyT { + type: number; + name: string; +} + +export interface CSVCMsgGameEventList_descriptorT { + eventid: number; + name: string; + keys: CSVCMsgGameEventList_keyT[]; +} + +export interface CSVCMsgTempEntities { + reliable: boolean; + numEntries: number; + entityData: Uint8Array; +} + +export interface CSVCMsgPacketEntities { + maxEntries: number; + updatedEntries: number; + isDelta: boolean; + updateBaseline: boolean; + baseline: number; + deltaFrom: number; + entityData: Uint8Array; +} + +export interface CSVCMsgSounds { + reliableSound: boolean; + sounds: CSVCMsgSounds_sounddataT[]; +} + +export interface CSVCMsgSounds_sounddataT { + originX: number; + originY: number; + originZ: number; + volume: number; + delayValue: number; + sequenceNumber: number; + entityIndex: number; + channel: number; + pitch: number; + flags: number; + soundNum: number; + soundNumHandle: number; + speakerEntity: number; + randomSeed: number; + soundLevel: number; + isSentence: boolean; + isAmbient: boolean; +} + +export interface CSVCMsgEntityMsg { + entIndex: number; + classId: number; + entData: Uint8Array; +} + +export interface CSVCMsgCmdKeyValues { + keyvalues: Uint8Array; +} + +export interface CSVCMsgEncryptedData { + encrypted: Uint8Array; + keyType: number; +} + +export interface CSVCMsgHltvReplay { + delay: number; + primaryTarget: number; + replayStopAt: number; + replayStartAt: number; + replaySlowdownBegin: number; + replaySlowdownEnd: number; + replaySlowdownRate: number; + reason: number; +} + +export interface CCLCMsgHltvReplay { + request: number; + slowdownLength: number; + slowdownRate: number; + primaryTargetEntIndex: number; + eventTime: number; +} + +export interface CSVCMsgBroadcastCommand { + cmd: string; +} + +export interface CCLCMsgHltvFixupOperatorTick { + tick: number; + propsData: Uint8Array; + origin: CMsgVector | undefined; + eyeAngles: CMsgQAngle | undefined; + observerMode: number; + cameramanScoreboard: boolean; + observerTarget: number; + viewOffset: CMsgVector | undefined; +} + +export interface CSVCMsgHltvFixupOperatorStatus { + mode: number; + overrideOperatorName: string; +} + +function createBaseCMsgVector(): CMsgVector { + return { x: 0, y: 0, z: 0 }; +} + +export const CMsgVector = { + encode(message: CMsgVector, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.x !== 0) { + writer.uint32(13).float(message.x); + } + if (message.y !== 0) { + writer.uint32(21).float(message.y); + } + if (message.z !== 0) { + writer.uint32(29).float(message.z); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CMsgVector { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCMsgVector(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 13) { + break; + } + + message.x = reader.float(); + continue; + case 2: + if (tag !== 21) { + break; + } + + message.y = reader.float(); + continue; + case 3: + if (tag !== 29) { + break; + } + + message.z = reader.float(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CMsgVector { + return { + x: isSet(object.x) ? globalThis.Number(object.x) : 0, + y: isSet(object.y) ? globalThis.Number(object.y) : 0, + z: isSet(object.z) ? globalThis.Number(object.z) : 0, + }; + }, + + toJSON(message: CMsgVector): unknown { + const obj: any = {}; + if (message.x !== 0) { + obj.x = message.x; + } + if (message.y !== 0) { + obj.y = message.y; + } + if (message.z !== 0) { + obj.z = message.z; + } + return obj; + }, + + create, I>>(base?: I): CMsgVector { + return CMsgVector.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CMsgVector { + const message = createBaseCMsgVector(); + message.x = object.x ?? 0; + message.y = object.y ?? 0; + message.z = object.z ?? 0; + return message; + }, +}; + +function createBaseCMsgVector2D(): CMsgVector2D { + return { x: 0, y: 0 }; +} + +export const CMsgVector2D = { + encode(message: CMsgVector2D, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.x !== 0) { + writer.uint32(13).float(message.x); + } + if (message.y !== 0) { + writer.uint32(21).float(message.y); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CMsgVector2D { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCMsgVector2D(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 13) { + break; + } + + message.x = reader.float(); + continue; + case 2: + if (tag !== 21) { + break; + } + + message.y = reader.float(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CMsgVector2D { + return { + x: isSet(object.x) ? globalThis.Number(object.x) : 0, + y: isSet(object.y) ? globalThis.Number(object.y) : 0, + }; + }, + + toJSON(message: CMsgVector2D): unknown { + const obj: any = {}; + if (message.x !== 0) { + obj.x = message.x; + } + if (message.y !== 0) { + obj.y = message.y; + } + return obj; + }, + + create, I>>(base?: I): CMsgVector2D { + return CMsgVector2D.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CMsgVector2D { + const message = createBaseCMsgVector2D(); + message.x = object.x ?? 0; + message.y = object.y ?? 0; + return message; + }, +}; + +function createBaseCMsgQAngle(): CMsgQAngle { + return { x: 0, y: 0, z: 0 }; +} + +export const CMsgQAngle = { + encode(message: CMsgQAngle, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.x !== 0) { + writer.uint32(13).float(message.x); + } + if (message.y !== 0) { + writer.uint32(21).float(message.y); + } + if (message.z !== 0) { + writer.uint32(29).float(message.z); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CMsgQAngle { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCMsgQAngle(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 13) { + break; + } + + message.x = reader.float(); + continue; + case 2: + if (tag !== 21) { + break; + } + + message.y = reader.float(); + continue; + case 3: + if (tag !== 29) { + break; + } + + message.z = reader.float(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CMsgQAngle { + return { + x: isSet(object.x) ? globalThis.Number(object.x) : 0, + y: isSet(object.y) ? globalThis.Number(object.y) : 0, + z: isSet(object.z) ? globalThis.Number(object.z) : 0, + }; + }, + + toJSON(message: CMsgQAngle): unknown { + const obj: any = {}; + if (message.x !== 0) { + obj.x = message.x; + } + if (message.y !== 0) { + obj.y = message.y; + } + if (message.z !== 0) { + obj.z = message.z; + } + return obj; + }, + + create, I>>(base?: I): CMsgQAngle { + return CMsgQAngle.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CMsgQAngle { + const message = createBaseCMsgQAngle(); + message.x = object.x ?? 0; + message.y = object.y ?? 0; + message.z = object.z ?? 0; + return message; + }, +}; + +function createBaseCMsgRGBA(): CMsgRGBA { + return { r: 0, g: 0, b: 0, a: 0 }; +} + +export const CMsgRGBA = { + encode(message: CMsgRGBA, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.r !== 0) { + writer.uint32(8).int32(message.r); + } + if (message.g !== 0) { + writer.uint32(16).int32(message.g); + } + if (message.b !== 0) { + writer.uint32(24).int32(message.b); + } + if (message.a !== 0) { + writer.uint32(32).int32(message.a); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CMsgRGBA { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCMsgRGBA(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.r = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.g = reader.int32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.b = reader.int32(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.a = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CMsgRGBA { + return { + r: isSet(object.r) ? globalThis.Number(object.r) : 0, + g: isSet(object.g) ? globalThis.Number(object.g) : 0, + b: isSet(object.b) ? globalThis.Number(object.b) : 0, + a: isSet(object.a) ? globalThis.Number(object.a) : 0, + }; + }, + + toJSON(message: CMsgRGBA): unknown { + const obj: any = {}; + if (message.r !== 0) { + obj.r = Math.round(message.r); + } + if (message.g !== 0) { + obj.g = Math.round(message.g); + } + if (message.b !== 0) { + obj.b = Math.round(message.b); + } + if (message.a !== 0) { + obj.a = Math.round(message.a); + } + return obj; + }, + + create, I>>(base?: I): CMsgRGBA { + return CMsgRGBA.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CMsgRGBA { + const message = createBaseCMsgRGBA(); + message.r = object.r ?? 0; + message.g = object.g ?? 0; + message.b = object.b ?? 0; + message.a = object.a ?? 0; + return message; + }, +}; + +function createBaseCNETMsgTick(): CNETMsgTick { + return { + tick: 0, + hostComputationtime: 0, + hostComputationtimeStdDeviation: 0, + hostFramestarttimeStdDeviation: 0, + hltvReplayFlags: 0, + }; +} + +export const CNETMsgTick = { + encode(message: CNETMsgTick, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.tick !== 0) { + writer.uint32(8).uint32(message.tick); + } + if (message.hostComputationtime !== 0) { + writer.uint32(32).uint32(message.hostComputationtime); + } + if (message.hostComputationtimeStdDeviation !== 0) { + writer.uint32(40).uint32(message.hostComputationtimeStdDeviation); + } + if (message.hostFramestarttimeStdDeviation !== 0) { + writer.uint32(48).uint32(message.hostFramestarttimeStdDeviation); + } + if (message.hltvReplayFlags !== 0) { + writer.uint32(56).uint32(message.hltvReplayFlags); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CNETMsgTick { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCNETMsgTick(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.tick = reader.uint32(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.hostComputationtime = reader.uint32(); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.hostComputationtimeStdDeviation = reader.uint32(); + continue; + case 6: + if (tag !== 48) { + break; + } + + message.hostFramestarttimeStdDeviation = reader.uint32(); + continue; + case 7: + if (tag !== 56) { + break; + } + + message.hltvReplayFlags = reader.uint32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CNETMsgTick { + return { + tick: isSet(object.tick) ? globalThis.Number(object.tick) : 0, + hostComputationtime: isSet(object.hostComputationtime) ? globalThis.Number(object.hostComputationtime) : 0, + hostComputationtimeStdDeviation: isSet(object.hostComputationtimeStdDeviation) + ? globalThis.Number(object.hostComputationtimeStdDeviation) + : 0, + hostFramestarttimeStdDeviation: isSet(object.hostFramestarttimeStdDeviation) + ? globalThis.Number(object.hostFramestarttimeStdDeviation) + : 0, + hltvReplayFlags: isSet(object.hltvReplayFlags) ? globalThis.Number(object.hltvReplayFlags) : 0, + }; + }, + + toJSON(message: CNETMsgTick): unknown { + const obj: any = {}; + if (message.tick !== 0) { + obj.tick = Math.round(message.tick); + } + if (message.hostComputationtime !== 0) { + obj.hostComputationtime = Math.round(message.hostComputationtime); + } + if (message.hostComputationtimeStdDeviation !== 0) { + obj.hostComputationtimeStdDeviation = Math.round(message.hostComputationtimeStdDeviation); + } + if (message.hostFramestarttimeStdDeviation !== 0) { + obj.hostFramestarttimeStdDeviation = Math.round(message.hostFramestarttimeStdDeviation); + } + if (message.hltvReplayFlags !== 0) { + obj.hltvReplayFlags = Math.round(message.hltvReplayFlags); + } + return obj; + }, + + create, I>>(base?: I): CNETMsgTick { + return CNETMsgTick.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CNETMsgTick { + const message = createBaseCNETMsgTick(); + message.tick = object.tick ?? 0; + message.hostComputationtime = object.hostComputationtime ?? 0; + message.hostComputationtimeStdDeviation = object.hostComputationtimeStdDeviation ?? 0; + message.hostFramestarttimeStdDeviation = object.hostFramestarttimeStdDeviation ?? 0; + message.hltvReplayFlags = object.hltvReplayFlags ?? 0; + return message; + }, +}; + +function createBaseCNETMsgStringCmd(): CNETMsgStringCmd { + return { command: '' }; +} + +export const CNETMsgStringCmd = { + encode(message: CNETMsgStringCmd, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.command !== '') { + writer.uint32(10).string(message.command); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CNETMsgStringCmd { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCNETMsgStringCmd(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.command = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CNETMsgStringCmd { + return { command: isSet(object.command) ? globalThis.String(object.command) : '' }; + }, + + toJSON(message: CNETMsgStringCmd): unknown { + const obj: any = {}; + if (message.command !== '') { + obj.command = message.command; + } + return obj; + }, + + create, I>>(base?: I): CNETMsgStringCmd { + return CNETMsgStringCmd.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CNETMsgStringCmd { + const message = createBaseCNETMsgStringCmd(); + message.command = object.command ?? ''; + return message; + }, +}; + +function createBaseCNETMsgSignonState(): CNETMsgSignonState { + return { signonState: 0, spawnCount: 0, numServerPlayers: 0, playersNetworkids: [], mapName: '' }; +} + +export const CNETMsgSignonState = { + encode(message: CNETMsgSignonState, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.signonState !== 0) { + writer.uint32(8).uint32(message.signonState); + } + if (message.spawnCount !== 0) { + writer.uint32(16).uint32(message.spawnCount); + } + if (message.numServerPlayers !== 0) { + writer.uint32(24).uint32(message.numServerPlayers); + } + for (const v of message.playersNetworkids) { + writer.uint32(34).string(v!); + } + if (message.mapName !== '') { + writer.uint32(42).string(message.mapName); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CNETMsgSignonState { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCNETMsgSignonState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.signonState = reader.uint32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.spawnCount = reader.uint32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.numServerPlayers = reader.uint32(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.playersNetworkids.push(reader.string()); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.mapName = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CNETMsgSignonState { + return { + signonState: isSet(object.signonState) ? globalThis.Number(object.signonState) : 0, + spawnCount: isSet(object.spawnCount) ? globalThis.Number(object.spawnCount) : 0, + numServerPlayers: isSet(object.numServerPlayers) ? globalThis.Number(object.numServerPlayers) : 0, + playersNetworkids: globalThis.Array.isArray(object?.playersNetworkids) + ? object.playersNetworkids.map((e: any) => globalThis.String(e)) + : [], + mapName: isSet(object.mapName) ? globalThis.String(object.mapName) : '', + }; + }, + + toJSON(message: CNETMsgSignonState): unknown { + const obj: any = {}; + if (message.signonState !== 0) { + obj.signonState = Math.round(message.signonState); + } + if (message.spawnCount !== 0) { + obj.spawnCount = Math.round(message.spawnCount); + } + if (message.numServerPlayers !== 0) { + obj.numServerPlayers = Math.round(message.numServerPlayers); + } + if (message.playersNetworkids?.length) { + obj.playersNetworkids = message.playersNetworkids; + } + if (message.mapName !== '') { + obj.mapName = message.mapName; + } + return obj; + }, + + create, I>>(base?: I): CNETMsgSignonState { + return CNETMsgSignonState.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CNETMsgSignonState { + const message = createBaseCNETMsgSignonState(); + message.signonState = object.signonState ?? 0; + message.spawnCount = object.spawnCount ?? 0; + message.numServerPlayers = object.numServerPlayers ?? 0; + message.playersNetworkids = object.playersNetworkids?.map((e) => e) || []; + message.mapName = object.mapName ?? ''; + return message; + }, +}; + +function createBaseCMsgCVars(): CMsgCVars { + return { cvars: [] }; +} + +export const CMsgCVars = { + encode(message: CMsgCVars, writer: pb.Writer = pb.Writer.create()): pb.Writer { + for (const v of message.cvars) { + CMsgCVars_CVar.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CMsgCVars { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCMsgCVars(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.cvars.push(CMsgCVars_CVar.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CMsgCVars { + return { + cvars: globalThis.Array.isArray(object?.cvars) + ? object.cvars.map((e: any) => CMsgCVars_CVar.fromJSON(e)) + : [], + }; + }, + + toJSON(message: CMsgCVars): unknown { + const obj: any = {}; + if (message.cvars?.length) { + obj.cvars = message.cvars.map((e) => CMsgCVars_CVar.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): CMsgCVars { + return CMsgCVars.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CMsgCVars { + const message = createBaseCMsgCVars(); + message.cvars = object.cvars?.map((e) => CMsgCVars_CVar.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseCMsgCVars_CVar(): CMsgCVars_CVar { + return { name: '', value: '', dictionaryName: 0 }; +} + +export const CMsgCVars_CVar = { + encode(message: CMsgCVars_CVar, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.name !== '') { + writer.uint32(10).string(message.name); + } + if (message.value !== '') { + writer.uint32(18).string(message.value); + } + if (message.dictionaryName !== 0) { + writer.uint32(24).uint32(message.dictionaryName); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CMsgCVars_CVar { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCMsgCVars_CVar(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.name = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.value = reader.string(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.dictionaryName = reader.uint32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CMsgCVars_CVar { + return { + name: isSet(object.name) ? globalThis.String(object.name) : '', + value: isSet(object.value) ? globalThis.String(object.value) : '', + dictionaryName: isSet(object.dictionaryName) ? globalThis.Number(object.dictionaryName) : 0, + }; + }, + + toJSON(message: CMsgCVars_CVar): unknown { + const obj: any = {}; + if (message.name !== '') { + obj.name = message.name; + } + if (message.value !== '') { + obj.value = message.value; + } + if (message.dictionaryName !== 0) { + obj.dictionaryName = Math.round(message.dictionaryName); + } + return obj; + }, + + create, I>>(base?: I): CMsgCVars_CVar { + return CMsgCVars_CVar.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CMsgCVars_CVar { + const message = createBaseCMsgCVars_CVar(); + message.name = object.name ?? ''; + message.value = object.value ?? ''; + message.dictionaryName = object.dictionaryName ?? 0; + return message; + }, +}; + +function createBaseCNETMsgSetConVar(): CNETMsgSetConVar { + return { convars: undefined }; +} + +export const CNETMsgSetConVar = { + encode(message: CNETMsgSetConVar, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.convars !== undefined) { + CMsgCVars.encode(message.convars, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CNETMsgSetConVar { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCNETMsgSetConVar(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.convars = CMsgCVars.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CNETMsgSetConVar { + return { convars: isSet(object.convars) ? CMsgCVars.fromJSON(object.convars) : undefined }; + }, + + toJSON(message: CNETMsgSetConVar): unknown { + const obj: any = {}; + if (message.convars !== undefined) { + obj.convars = CMsgCVars.toJSON(message.convars); + } + return obj; + }, + + create, I>>(base?: I): CNETMsgSetConVar { + return CNETMsgSetConVar.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CNETMsgSetConVar { + const message = createBaseCNETMsgSetConVar(); + message.convars = (object.convars !== undefined && object.convars !== null) + ? CMsgCVars.fromPartial(object.convars) + : undefined; + return message; + }, +}; + +function createBaseCNETMsgNOP(): CNETMsgNOP { + return {}; +} + +export const CNETMsgNOP = { + encode(_: CNETMsgNOP, writer: pb.Writer = pb.Writer.create()): pb.Writer { + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CNETMsgNOP { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCNETMsgNOP(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): CNETMsgNOP { + return {}; + }, + + toJSON(_: CNETMsgNOP): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>(base?: I): CNETMsgNOP { + return CNETMsgNOP.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(_: I): CNETMsgNOP { + const message = createBaseCNETMsgNOP(); + return message; + }, +}; + +function createBaseCNETMsgDisconnect(): CNETMsgDisconnect { + return { reason: 0 }; +} + +export const CNETMsgDisconnect = { + encode(message: CNETMsgDisconnect, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.reason !== 0) { + writer.uint32(8).int32(message.reason); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CNETMsgDisconnect { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCNETMsgDisconnect(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.reason = reader.int32() as any; + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CNETMsgDisconnect { + return { reason: isSet(object.reason) ? eNetworkDisconnectionReasonFromJSON(object.reason) : 0 }; + }, + + toJSON(message: CNETMsgDisconnect): unknown { + const obj: any = {}; + if (message.reason !== 0) { + obj.reason = eNetworkDisconnectionReasonToJSON(message.reason); + } + return obj; + }, + + create, I>>(base?: I): CNETMsgDisconnect { + return CNETMsgDisconnect.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CNETMsgDisconnect { + const message = createBaseCNETMsgDisconnect(); + message.reason = object.reason ?? 0; + return message; + }, +}; + +function createBaseCNETMsgFile(): CNETMsgFile { + return { transferId: 0, fileName: '', isReplayDemoFile: false, deny: false }; +} + +export const CNETMsgFile = { + encode(message: CNETMsgFile, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.transferId !== 0) { + writer.uint32(8).int32(message.transferId); + } + if (message.fileName !== '') { + writer.uint32(18).string(message.fileName); + } + if (message.isReplayDemoFile === true) { + writer.uint32(24).bool(message.isReplayDemoFile); + } + if (message.deny === true) { + writer.uint32(32).bool(message.deny); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CNETMsgFile { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCNETMsgFile(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.transferId = reader.int32(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.fileName = reader.string(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.isReplayDemoFile = reader.bool(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.deny = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CNETMsgFile { + return { + transferId: isSet(object.transferId) ? globalThis.Number(object.transferId) : 0, + fileName: isSet(object.fileName) ? globalThis.String(object.fileName) : '', + isReplayDemoFile: isSet(object.isReplayDemoFile) ? globalThis.Boolean(object.isReplayDemoFile) : false, + deny: isSet(object.deny) ? globalThis.Boolean(object.deny) : false, + }; + }, + + toJSON(message: CNETMsgFile): unknown { + const obj: any = {}; + if (message.transferId !== 0) { + obj.transferId = Math.round(message.transferId); + } + if (message.fileName !== '') { + obj.fileName = message.fileName; + } + if (message.isReplayDemoFile === true) { + obj.isReplayDemoFile = message.isReplayDemoFile; + } + if (message.deny === true) { + obj.deny = message.deny; + } + return obj; + }, + + create, I>>(base?: I): CNETMsgFile { + return CNETMsgFile.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CNETMsgFile { + const message = createBaseCNETMsgFile(); + message.transferId = object.transferId ?? 0; + message.fileName = object.fileName ?? ''; + message.isReplayDemoFile = object.isReplayDemoFile ?? false; + message.deny = object.deny ?? false; + return message; + }, +}; + +function createBaseCNETMsgSplitScreenUser(): CNETMsgSplitScreenUser { + return { slot: 0 }; +} + +export const CNETMsgSplitScreenUser = { + encode(message: CNETMsgSplitScreenUser, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.slot !== 0) { + writer.uint32(8).int32(message.slot); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CNETMsgSplitScreenUser { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCNETMsgSplitScreenUser(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.slot = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CNETMsgSplitScreenUser { + return { slot: isSet(object.slot) ? globalThis.Number(object.slot) : 0 }; + }, + + toJSON(message: CNETMsgSplitScreenUser): unknown { + const obj: any = {}; + if (message.slot !== 0) { + obj.slot = Math.round(message.slot); + } + return obj; + }, + + create, I>>(base?: I): CNETMsgSplitScreenUser { + return CNETMsgSplitScreenUser.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CNETMsgSplitScreenUser { + const message = createBaseCNETMsgSplitScreenUser(); + message.slot = object.slot ?? 0; + return message; + }, +}; + +function createBaseCNETMsgPlayerAvatarData(): CNETMsgPlayerAvatarData { + return { accountid: 0, rgb: new Uint8Array(0) }; +} + +export const CNETMsgPlayerAvatarData = { + encode(message: CNETMsgPlayerAvatarData, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.accountid !== 0) { + writer.uint32(8).uint32(message.accountid); + } + if (message.rgb.length !== 0) { + writer.uint32(18).bytes(message.rgb); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CNETMsgPlayerAvatarData { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCNETMsgPlayerAvatarData(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.accountid = reader.uint32(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.rgb = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CNETMsgPlayerAvatarData { + return { + accountid: isSet(object.accountid) ? globalThis.Number(object.accountid) : 0, + rgb: isSet(object.rgb) ? bytesFromBase64(object.rgb) : new Uint8Array(0), + }; + }, + + toJSON(message: CNETMsgPlayerAvatarData): unknown { + const obj: any = {}; + if (message.accountid !== 0) { + obj.accountid = Math.round(message.accountid); + } + if (message.rgb.length !== 0) { + obj.rgb = base64FromBytes(message.rgb); + } + return obj; + }, + + create, I>>(base?: I): CNETMsgPlayerAvatarData { + return CNETMsgPlayerAvatarData.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CNETMsgPlayerAvatarData { + const message = createBaseCNETMsgPlayerAvatarData(); + message.accountid = object.accountid ?? 0; + message.rgb = object.rgb ?? new Uint8Array(0); + return message; + }, +}; + +function createBaseCCLCMsgClientInfo(): CCLCMsgClientInfo { + return { + sendTableCrc: 0, + serverCount: 0, + isHltv: false, + isReplay: false, + friendsId: 0, + friendsName: '', + customFiles: [], + }; +} + +export const CCLCMsgClientInfo = { + encode(message: CCLCMsgClientInfo, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.sendTableCrc !== 0) { + writer.uint32(13).fixed32(message.sendTableCrc); + } + if (message.serverCount !== 0) { + writer.uint32(16).uint32(message.serverCount); + } + if (message.isHltv === true) { + writer.uint32(24).bool(message.isHltv); + } + if (message.isReplay === true) { + writer.uint32(32).bool(message.isReplay); + } + if (message.friendsId !== 0) { + writer.uint32(40).uint32(message.friendsId); + } + if (message.friendsName !== '') { + writer.uint32(50).string(message.friendsName); + } + writer.uint32(58).fork(); + for (const v of message.customFiles) { + writer.fixed32(v); + } + writer.ldelim(); + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CCLCMsgClientInfo { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCCLCMsgClientInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 13) { + break; + } + + message.sendTableCrc = reader.fixed32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.serverCount = reader.uint32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.isHltv = reader.bool(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.isReplay = reader.bool(); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.friendsId = reader.uint32(); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.friendsName = reader.string(); + continue; + case 7: + if (tag === 61) { + message.customFiles.push(reader.fixed32()); + + continue; + } + + if (tag === 58) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.customFiles.push(reader.fixed32()); + } + + continue; + } + + break; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CCLCMsgClientInfo { + return { + sendTableCrc: isSet(object.sendTableCrc) ? globalThis.Number(object.sendTableCrc) : 0, + serverCount: isSet(object.serverCount) ? globalThis.Number(object.serverCount) : 0, + isHltv: isSet(object.isHltv) ? globalThis.Boolean(object.isHltv) : false, + isReplay: isSet(object.isReplay) ? globalThis.Boolean(object.isReplay) : false, + friendsId: isSet(object.friendsId) ? globalThis.Number(object.friendsId) : 0, + friendsName: isSet(object.friendsName) ? globalThis.String(object.friendsName) : '', + customFiles: globalThis.Array.isArray(object?.customFiles) + ? object.customFiles.map((e: any) => globalThis.Number(e)) + : [], + }; + }, + + toJSON(message: CCLCMsgClientInfo): unknown { + const obj: any = {}; + if (message.sendTableCrc !== 0) { + obj.sendTableCrc = Math.round(message.sendTableCrc); + } + if (message.serverCount !== 0) { + obj.serverCount = Math.round(message.serverCount); + } + if (message.isHltv === true) { + obj.isHltv = message.isHltv; + } + if (message.isReplay === true) { + obj.isReplay = message.isReplay; + } + if (message.friendsId !== 0) { + obj.friendsId = Math.round(message.friendsId); + } + if (message.friendsName !== '') { + obj.friendsName = message.friendsName; + } + if (message.customFiles?.length) { + obj.customFiles = message.customFiles.map((e) => Math.round(e)); + } + return obj; + }, + + create, I>>(base?: I): CCLCMsgClientInfo { + return CCLCMsgClientInfo.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CCLCMsgClientInfo { + const message = createBaseCCLCMsgClientInfo(); + message.sendTableCrc = object.sendTableCrc ?? 0; + message.serverCount = object.serverCount ?? 0; + message.isHltv = object.isHltv ?? false; + message.isReplay = object.isReplay ?? false; + message.friendsId = object.friendsId ?? 0; + message.friendsName = object.friendsName ?? ''; + message.customFiles = object.customFiles?.map((e) => e) || []; + return message; + }, +}; + +function createBaseCCLCMsgMove(): CCLCMsgMove { + return { numBackupCommands: 0, numNewCommands: 0, data: new Uint8Array(0) }; +} + +export const CCLCMsgMove = { + encode(message: CCLCMsgMove, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.numBackupCommands !== 0) { + writer.uint32(8).uint32(message.numBackupCommands); + } + if (message.numNewCommands !== 0) { + writer.uint32(16).uint32(message.numNewCommands); + } + if (message.data.length !== 0) { + writer.uint32(26).bytes(message.data); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CCLCMsgMove { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCCLCMsgMove(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.numBackupCommands = reader.uint32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.numNewCommands = reader.uint32(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.data = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CCLCMsgMove { + return { + numBackupCommands: isSet(object.numBackupCommands) ? globalThis.Number(object.numBackupCommands) : 0, + numNewCommands: isSet(object.numNewCommands) ? globalThis.Number(object.numNewCommands) : 0, + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(0), + }; + }, + + toJSON(message: CCLCMsgMove): unknown { + const obj: any = {}; + if (message.numBackupCommands !== 0) { + obj.numBackupCommands = Math.round(message.numBackupCommands); + } + if (message.numNewCommands !== 0) { + obj.numNewCommands = Math.round(message.numNewCommands); + } + if (message.data.length !== 0) { + obj.data = base64FromBytes(message.data); + } + return obj; + }, + + create, I>>(base?: I): CCLCMsgMove { + return CCLCMsgMove.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CCLCMsgMove { + const message = createBaseCCLCMsgMove(); + message.numBackupCommands = object.numBackupCommands ?? 0; + message.numNewCommands = object.numNewCommands ?? 0; + message.data = object.data ?? new Uint8Array(0); + return message; + }, +}; + +function createBaseCCLCMsgVoiceData(): CCLCMsgVoiceData { + return { + data: new Uint8Array(0), + xuid: 0, + format: 0, + sequenceBytes: 0, + sectionNumber: 0, + uncompressedSampleOffset: 0, + }; +} + +export const CCLCMsgVoiceData = { + encode(message: CCLCMsgVoiceData, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } + if (message.xuid !== 0) { + writer.uint32(17).fixed64(message.xuid); + } + if (message.format !== 0) { + writer.uint32(24).int32(message.format); + } + if (message.sequenceBytes !== 0) { + writer.uint32(32).int32(message.sequenceBytes); + } + if (message.sectionNumber !== 0) { + writer.uint32(40).uint32(message.sectionNumber); + } + if (message.uncompressedSampleOffset !== 0) { + writer.uint32(48).uint32(message.uncompressedSampleOffset); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CCLCMsgVoiceData { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCCLCMsgVoiceData(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.data = reader.bytes(); + continue; + case 2: + if (tag !== 17) { + break; + } + + message.xuid = longToNumber(reader.fixed64() as Long); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.format = reader.int32() as any; + continue; + case 4: + if (tag !== 32) { + break; + } + + message.sequenceBytes = reader.int32(); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.sectionNumber = reader.uint32(); + continue; + case 6: + if (tag !== 48) { + break; + } + + message.uncompressedSampleOffset = reader.uint32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CCLCMsgVoiceData { + return { + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(0), + xuid: isSet(object.xuid) ? globalThis.Number(object.xuid) : 0, + format: isSet(object.format) ? voiceDataFormatTFromJSON(object.format) : 0, + sequenceBytes: isSet(object.sequenceBytes) ? globalThis.Number(object.sequenceBytes) : 0, + sectionNumber: isSet(object.sectionNumber) ? globalThis.Number(object.sectionNumber) : 0, + uncompressedSampleOffset: isSet(object.uncompressedSampleOffset) + ? globalThis.Number(object.uncompressedSampleOffset) + : 0, + }; + }, + + toJSON(message: CCLCMsgVoiceData): unknown { + const obj: any = {}; + if (message.data.length !== 0) { + obj.data = base64FromBytes(message.data); + } + if (message.xuid !== 0) { + obj.xuid = Math.round(message.xuid); + } + if (message.format !== 0) { + obj.format = voiceDataFormatTToJSON(message.format); + } + if (message.sequenceBytes !== 0) { + obj.sequenceBytes = Math.round(message.sequenceBytes); + } + if (message.sectionNumber !== 0) { + obj.sectionNumber = Math.round(message.sectionNumber); + } + if (message.uncompressedSampleOffset !== 0) { + obj.uncompressedSampleOffset = Math.round(message.uncompressedSampleOffset); + } + return obj; + }, + + create, I>>(base?: I): CCLCMsgVoiceData { + return CCLCMsgVoiceData.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CCLCMsgVoiceData { + const message = createBaseCCLCMsgVoiceData(); + message.data = object.data ?? new Uint8Array(0); + message.xuid = object.xuid ?? 0; + message.format = object.format ?? 0; + message.sequenceBytes = object.sequenceBytes ?? 0; + message.sectionNumber = object.sectionNumber ?? 0; + message.uncompressedSampleOffset = object.uncompressedSampleOffset ?? 0; + return message; + }, +}; + +function createBaseCCLCMsgBaselineAck(): CCLCMsgBaselineAck { + return { baselineTick: 0, baselineNr: 0 }; +} + +export const CCLCMsgBaselineAck = { + encode(message: CCLCMsgBaselineAck, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.baselineTick !== 0) { + writer.uint32(8).int32(message.baselineTick); + } + if (message.baselineNr !== 0) { + writer.uint32(16).int32(message.baselineNr); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CCLCMsgBaselineAck { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCCLCMsgBaselineAck(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.baselineTick = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.baselineNr = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CCLCMsgBaselineAck { + return { + baselineTick: isSet(object.baselineTick) ? globalThis.Number(object.baselineTick) : 0, + baselineNr: isSet(object.baselineNr) ? globalThis.Number(object.baselineNr) : 0, + }; + }, + + toJSON(message: CCLCMsgBaselineAck): unknown { + const obj: any = {}; + if (message.baselineTick !== 0) { + obj.baselineTick = Math.round(message.baselineTick); + } + if (message.baselineNr !== 0) { + obj.baselineNr = Math.round(message.baselineNr); + } + return obj; + }, + + create, I>>(base?: I): CCLCMsgBaselineAck { + return CCLCMsgBaselineAck.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CCLCMsgBaselineAck { + const message = createBaseCCLCMsgBaselineAck(); + message.baselineTick = object.baselineTick ?? 0; + message.baselineNr = object.baselineNr ?? 0; + return message; + }, +}; + +function createBaseCCLCMsgListenEvents(): CCLCMsgListenEvents { + return { eventMask: [] }; +} + +export const CCLCMsgListenEvents = { + encode(message: CCLCMsgListenEvents, writer: pb.Writer = pb.Writer.create()): pb.Writer { + writer.uint32(10).fork(); + for (const v of message.eventMask) { + writer.fixed64(v); + } + writer.ldelim(); + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CCLCMsgListenEvents { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCCLCMsgListenEvents(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag === 9) { + message.eventMask.push(longToNumber(reader.fixed64() as Long)); + + continue; + } + + if (tag === 10) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.eventMask.push(longToNumber(reader.fixed64() as Long)); + } + + continue; + } + + break; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CCLCMsgListenEvents { + return { + eventMask: globalThis.Array.isArray(object?.eventMask) + ? object.eventMask.map((e: any) => globalThis.Number(e)) + : [], + }; + }, + + toJSON(message: CCLCMsgListenEvents): unknown { + const obj: any = {}; + if (message.eventMask?.length) { + obj.eventMask = message.eventMask.map((e) => Math.round(e)); + } + return obj; + }, + + create, I>>(base?: I): CCLCMsgListenEvents { + return CCLCMsgListenEvents.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CCLCMsgListenEvents { + const message = createBaseCCLCMsgListenEvents(); + message.eventMask = object.eventMask?.map((e) => e) || []; + return message; + }, +}; + +function createBaseCCLCMsgRespondCvarValue(): CCLCMsgRespondCvarValue { + return { cookie: 0, statusCode: 0, name: '', value: '' }; +} + +export const CCLCMsgRespondCvarValue = { + encode(message: CCLCMsgRespondCvarValue, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.cookie !== 0) { + writer.uint32(8).int32(message.cookie); + } + if (message.statusCode !== 0) { + writer.uint32(16).int32(message.statusCode); + } + if (message.name !== '') { + writer.uint32(26).string(message.name); + } + if (message.value !== '') { + writer.uint32(34).string(message.value); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CCLCMsgRespondCvarValue { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCCLCMsgRespondCvarValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.cookie = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.statusCode = reader.int32(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.name = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.value = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CCLCMsgRespondCvarValue { + return { + cookie: isSet(object.cookie) ? globalThis.Number(object.cookie) : 0, + statusCode: isSet(object.statusCode) ? globalThis.Number(object.statusCode) : 0, + name: isSet(object.name) ? globalThis.String(object.name) : '', + value: isSet(object.value) ? globalThis.String(object.value) : '', + }; + }, + + toJSON(message: CCLCMsgRespondCvarValue): unknown { + const obj: any = {}; + if (message.cookie !== 0) { + obj.cookie = Math.round(message.cookie); + } + if (message.statusCode !== 0) { + obj.statusCode = Math.round(message.statusCode); + } + if (message.name !== '') { + obj.name = message.name; + } + if (message.value !== '') { + obj.value = message.value; + } + return obj; + }, + + create, I>>(base?: I): CCLCMsgRespondCvarValue { + return CCLCMsgRespondCvarValue.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CCLCMsgRespondCvarValue { + const message = createBaseCCLCMsgRespondCvarValue(); + message.cookie = object.cookie ?? 0; + message.statusCode = object.statusCode ?? 0; + message.name = object.name ?? ''; + message.value = object.value ?? ''; + return message; + }, +}; + +function createBaseCCLCMsgFileCRCCheck(): CCLCMsgFileCRCCheck { + return { + codePath: 0, + path: '', + codeFilename: 0, + filename: '', + fileFraction: 0, + md5: new Uint8Array(0), + crc: 0, + fileHashType: 0, + fileLen: 0, + packFileId: 0, + packFileNumber: 0, + }; +} + +export const CCLCMsgFileCRCCheck = { + encode(message: CCLCMsgFileCRCCheck, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.codePath !== 0) { + writer.uint32(8).int32(message.codePath); + } + if (message.path !== '') { + writer.uint32(18).string(message.path); + } + if (message.codeFilename !== 0) { + writer.uint32(24).int32(message.codeFilename); + } + if (message.filename !== '') { + writer.uint32(34).string(message.filename); + } + if (message.fileFraction !== 0) { + writer.uint32(40).int32(message.fileFraction); + } + if (message.md5.length !== 0) { + writer.uint32(50).bytes(message.md5); + } + if (message.crc !== 0) { + writer.uint32(56).uint32(message.crc); + } + if (message.fileHashType !== 0) { + writer.uint32(64).int32(message.fileHashType); + } + if (message.fileLen !== 0) { + writer.uint32(72).int32(message.fileLen); + } + if (message.packFileId !== 0) { + writer.uint32(80).int32(message.packFileId); + } + if (message.packFileNumber !== 0) { + writer.uint32(88).int32(message.packFileNumber); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CCLCMsgFileCRCCheck { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCCLCMsgFileCRCCheck(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.codePath = reader.int32(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.path = reader.string(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.codeFilename = reader.int32(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.filename = reader.string(); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.fileFraction = reader.int32(); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.md5 = reader.bytes(); + continue; + case 7: + if (tag !== 56) { + break; + } + + message.crc = reader.uint32(); + continue; + case 8: + if (tag !== 64) { + break; + } + + message.fileHashType = reader.int32(); + continue; + case 9: + if (tag !== 72) { + break; + } + + message.fileLen = reader.int32(); + continue; + case 10: + if (tag !== 80) { + break; + } + + message.packFileId = reader.int32(); + continue; + case 11: + if (tag !== 88) { + break; + } + + message.packFileNumber = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CCLCMsgFileCRCCheck { + return { + codePath: isSet(object.codePath) ? globalThis.Number(object.codePath) : 0, + path: isSet(object.path) ? globalThis.String(object.path) : '', + codeFilename: isSet(object.codeFilename) ? globalThis.Number(object.codeFilename) : 0, + filename: isSet(object.filename) ? globalThis.String(object.filename) : '', + fileFraction: isSet(object.fileFraction) ? globalThis.Number(object.fileFraction) : 0, + md5: isSet(object.md5) ? bytesFromBase64(object.md5) : new Uint8Array(0), + crc: isSet(object.crc) ? globalThis.Number(object.crc) : 0, + fileHashType: isSet(object.fileHashType) ? globalThis.Number(object.fileHashType) : 0, + fileLen: isSet(object.fileLen) ? globalThis.Number(object.fileLen) : 0, + packFileId: isSet(object.packFileId) ? globalThis.Number(object.packFileId) : 0, + packFileNumber: isSet(object.packFileNumber) ? globalThis.Number(object.packFileNumber) : 0, + }; + }, + + toJSON(message: CCLCMsgFileCRCCheck): unknown { + const obj: any = {}; + if (message.codePath !== 0) { + obj.codePath = Math.round(message.codePath); + } + if (message.path !== '') { + obj.path = message.path; + } + if (message.codeFilename !== 0) { + obj.codeFilename = Math.round(message.codeFilename); + } + if (message.filename !== '') { + obj.filename = message.filename; + } + if (message.fileFraction !== 0) { + obj.fileFraction = Math.round(message.fileFraction); + } + if (message.md5.length !== 0) { + obj.md5 = base64FromBytes(message.md5); + } + if (message.crc !== 0) { + obj.crc = Math.round(message.crc); + } + if (message.fileHashType !== 0) { + obj.fileHashType = Math.round(message.fileHashType); + } + if (message.fileLen !== 0) { + obj.fileLen = Math.round(message.fileLen); + } + if (message.packFileId !== 0) { + obj.packFileId = Math.round(message.packFileId); + } + if (message.packFileNumber !== 0) { + obj.packFileNumber = Math.round(message.packFileNumber); + } + return obj; + }, + + create, I>>(base?: I): CCLCMsgFileCRCCheck { + return CCLCMsgFileCRCCheck.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CCLCMsgFileCRCCheck { + const message = createBaseCCLCMsgFileCRCCheck(); + message.codePath = object.codePath ?? 0; + message.path = object.path ?? ''; + message.codeFilename = object.codeFilename ?? 0; + message.filename = object.filename ?? ''; + message.fileFraction = object.fileFraction ?? 0; + message.md5 = object.md5 ?? new Uint8Array(0); + message.crc = object.crc ?? 0; + message.fileHashType = object.fileHashType ?? 0; + message.fileLen = object.fileLen ?? 0; + message.packFileId = object.packFileId ?? 0; + message.packFileNumber = object.packFileNumber ?? 0; + return message; + }, +}; + +function createBaseCCLCMsgLoadingProgress(): CCLCMsgLoadingProgress { + return { progress: 0 }; +} + +export const CCLCMsgLoadingProgress = { + encode(message: CCLCMsgLoadingProgress, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.progress !== 0) { + writer.uint32(8).int32(message.progress); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CCLCMsgLoadingProgress { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCCLCMsgLoadingProgress(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.progress = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CCLCMsgLoadingProgress { + return { progress: isSet(object.progress) ? globalThis.Number(object.progress) : 0 }; + }, + + toJSON(message: CCLCMsgLoadingProgress): unknown { + const obj: any = {}; + if (message.progress !== 0) { + obj.progress = Math.round(message.progress); + } + return obj; + }, + + create, I>>(base?: I): CCLCMsgLoadingProgress { + return CCLCMsgLoadingProgress.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CCLCMsgLoadingProgress { + const message = createBaseCCLCMsgLoadingProgress(); + message.progress = object.progress ?? 0; + return message; + }, +}; + +function createBaseCCLCMsgSplitPlayerConnect(): CCLCMsgSplitPlayerConnect { + return { convars: undefined }; +} + +export const CCLCMsgSplitPlayerConnect = { + encode(message: CCLCMsgSplitPlayerConnect, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.convars !== undefined) { + CMsgCVars.encode(message.convars, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CCLCMsgSplitPlayerConnect { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCCLCMsgSplitPlayerConnect(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.convars = CMsgCVars.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CCLCMsgSplitPlayerConnect { + return { convars: isSet(object.convars) ? CMsgCVars.fromJSON(object.convars) : undefined }; + }, + + toJSON(message: CCLCMsgSplitPlayerConnect): unknown { + const obj: any = {}; + if (message.convars !== undefined) { + obj.convars = CMsgCVars.toJSON(message.convars); + } + return obj; + }, + + create, I>>(base?: I): CCLCMsgSplitPlayerConnect { + return CCLCMsgSplitPlayerConnect.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CCLCMsgSplitPlayerConnect { + const message = createBaseCCLCMsgSplitPlayerConnect(); + message.convars = (object.convars !== undefined && object.convars !== null) + ? CMsgCVars.fromPartial(object.convars) + : undefined; + return message; + }, +}; + +function createBaseCCLCMsgCmdKeyValues(): CCLCMsgCmdKeyValues { + return { keyvalues: new Uint8Array(0) }; +} + +export const CCLCMsgCmdKeyValues = { + encode(message: CCLCMsgCmdKeyValues, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.keyvalues.length !== 0) { + writer.uint32(10).bytes(message.keyvalues); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CCLCMsgCmdKeyValues { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCCLCMsgCmdKeyValues(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.keyvalues = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CCLCMsgCmdKeyValues { + return { keyvalues: isSet(object.keyvalues) ? bytesFromBase64(object.keyvalues) : new Uint8Array(0) }; + }, + + toJSON(message: CCLCMsgCmdKeyValues): unknown { + const obj: any = {}; + if (message.keyvalues.length !== 0) { + obj.keyvalues = base64FromBytes(message.keyvalues); + } + return obj; + }, + + create, I>>(base?: I): CCLCMsgCmdKeyValues { + return CCLCMsgCmdKeyValues.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CCLCMsgCmdKeyValues { + const message = createBaseCCLCMsgCmdKeyValues(); + message.keyvalues = object.keyvalues ?? new Uint8Array(0); + return message; + }, +}; + +function createBaseCSVCMsgServerInfo(): CSVCMsgServerInfo { + return { + protocol: 0, + serverCount: 0, + isDedicated: false, + isOfficialValveServer: false, + isHltv: false, + isReplay: false, + isRedirectingToProxyRelay: false, + cOs: 0, + mapCrc: 0, + clientCrc: 0, + stringTableCrc: 0, + maxClients: 0, + maxClasses: 0, + playerSlot: 0, + tickInterval: 0, + gameDir: '', + mapName: '', + mapGroupName: '', + skyName: '', + hostName: '', + publicIp: 0, + ugcMapId: 0, + }; +} + +export const CSVCMsgServerInfo = { + encode(message: CSVCMsgServerInfo, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.protocol !== 0) { + writer.uint32(8).int32(message.protocol); + } + if (message.serverCount !== 0) { + writer.uint32(16).int32(message.serverCount); + } + if (message.isDedicated === true) { + writer.uint32(24).bool(message.isDedicated); + } + if (message.isOfficialValveServer === true) { + writer.uint32(32).bool(message.isOfficialValveServer); + } + if (message.isHltv === true) { + writer.uint32(40).bool(message.isHltv); + } + if (message.isReplay === true) { + writer.uint32(48).bool(message.isReplay); + } + if (message.isRedirectingToProxyRelay === true) { + writer.uint32(168).bool(message.isRedirectingToProxyRelay); + } + if (message.cOs !== 0) { + writer.uint32(56).int32(message.cOs); + } + if (message.mapCrc !== 0) { + writer.uint32(69).fixed32(message.mapCrc); + } + if (message.clientCrc !== 0) { + writer.uint32(77).fixed32(message.clientCrc); + } + if (message.stringTableCrc !== 0) { + writer.uint32(85).fixed32(message.stringTableCrc); + } + if (message.maxClients !== 0) { + writer.uint32(88).int32(message.maxClients); + } + if (message.maxClasses !== 0) { + writer.uint32(96).int32(message.maxClasses); + } + if (message.playerSlot !== 0) { + writer.uint32(104).int32(message.playerSlot); + } + if (message.tickInterval !== 0) { + writer.uint32(117).float(message.tickInterval); + } + if (message.gameDir !== '') { + writer.uint32(122).string(message.gameDir); + } + if (message.mapName !== '') { + writer.uint32(130).string(message.mapName); + } + if (message.mapGroupName !== '') { + writer.uint32(138).string(message.mapGroupName); + } + if (message.skyName !== '') { + writer.uint32(146).string(message.skyName); + } + if (message.hostName !== '') { + writer.uint32(154).string(message.hostName); + } + if (message.publicIp !== 0) { + writer.uint32(160).uint32(message.publicIp); + } + if (message.ugcMapId !== 0) { + writer.uint32(176).uint64(message.ugcMapId); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgServerInfo { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgServerInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.protocol = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.serverCount = reader.int32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.isDedicated = reader.bool(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.isOfficialValveServer = reader.bool(); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.isHltv = reader.bool(); + continue; + case 6: + if (tag !== 48) { + break; + } + + message.isReplay = reader.bool(); + continue; + case 21: + if (tag !== 168) { + break; + } + + message.isRedirectingToProxyRelay = reader.bool(); + continue; + case 7: + if (tag !== 56) { + break; + } + + message.cOs = reader.int32(); + continue; + case 8: + if (tag !== 69) { + break; + } + + message.mapCrc = reader.fixed32(); + continue; + case 9: + if (tag !== 77) { + break; + } + + message.clientCrc = reader.fixed32(); + continue; + case 10: + if (tag !== 85) { + break; + } + + message.stringTableCrc = reader.fixed32(); + continue; + case 11: + if (tag !== 88) { + break; + } + + message.maxClients = reader.int32(); + continue; + case 12: + if (tag !== 96) { + break; + } + + message.maxClasses = reader.int32(); + continue; + case 13: + if (tag !== 104) { + break; + } + + message.playerSlot = reader.int32(); + continue; + case 14: + if (tag !== 117) { + break; + } + + message.tickInterval = reader.float(); + continue; + case 15: + if (tag !== 122) { + break; + } + + message.gameDir = reader.string(); + continue; + case 16: + if (tag !== 130) { + break; + } + + message.mapName = reader.string(); + continue; + case 17: + if (tag !== 138) { + break; + } + + message.mapGroupName = reader.string(); + continue; + case 18: + if (tag !== 146) { + break; + } + + message.skyName = reader.string(); + continue; + case 19: + if (tag !== 154) { + break; + } + + message.hostName = reader.string(); + continue; + case 20: + if (tag !== 160) { + break; + } + + message.publicIp = reader.uint32(); + continue; + case 22: + if (tag !== 176) { + break; + } + + message.ugcMapId = longToNumber(reader.uint64() as Long); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgServerInfo { + return { + protocol: isSet(object.protocol) ? globalThis.Number(object.protocol) : 0, + serverCount: isSet(object.serverCount) ? globalThis.Number(object.serverCount) : 0, + isDedicated: isSet(object.isDedicated) ? globalThis.Boolean(object.isDedicated) : false, + isOfficialValveServer: isSet(object.isOfficialValveServer) + ? globalThis.Boolean(object.isOfficialValveServer) + : false, + isHltv: isSet(object.isHltv) ? globalThis.Boolean(object.isHltv) : false, + isReplay: isSet(object.isReplay) ? globalThis.Boolean(object.isReplay) : false, + isRedirectingToProxyRelay: isSet(object.isRedirectingToProxyRelay) + ? globalThis.Boolean(object.isRedirectingToProxyRelay) + : false, + cOs: isSet(object.cOs) ? globalThis.Number(object.cOs) : 0, + mapCrc: isSet(object.mapCrc) ? globalThis.Number(object.mapCrc) : 0, + clientCrc: isSet(object.clientCrc) ? globalThis.Number(object.clientCrc) : 0, + stringTableCrc: isSet(object.stringTableCrc) ? globalThis.Number(object.stringTableCrc) : 0, + maxClients: isSet(object.maxClients) ? globalThis.Number(object.maxClients) : 0, + maxClasses: isSet(object.maxClasses) ? globalThis.Number(object.maxClasses) : 0, + playerSlot: isSet(object.playerSlot) ? globalThis.Number(object.playerSlot) : 0, + tickInterval: isSet(object.tickInterval) ? globalThis.Number(object.tickInterval) : 0, + gameDir: isSet(object.gameDir) ? globalThis.String(object.gameDir) : '', + mapName: isSet(object.mapName) ? globalThis.String(object.mapName) : '', + mapGroupName: isSet(object.mapGroupName) ? globalThis.String(object.mapGroupName) : '', + skyName: isSet(object.skyName) ? globalThis.String(object.skyName) : '', + hostName: isSet(object.hostName) ? globalThis.String(object.hostName) : '', + publicIp: isSet(object.publicIp) ? globalThis.Number(object.publicIp) : 0, + ugcMapId: isSet(object.ugcMapId) ? globalThis.Number(object.ugcMapId) : 0, + }; + }, + + toJSON(message: CSVCMsgServerInfo): unknown { + const obj: any = {}; + if (message.protocol !== 0) { + obj.protocol = Math.round(message.protocol); + } + if (message.serverCount !== 0) { + obj.serverCount = Math.round(message.serverCount); + } + if (message.isDedicated === true) { + obj.isDedicated = message.isDedicated; + } + if (message.isOfficialValveServer === true) { + obj.isOfficialValveServer = message.isOfficialValveServer; + } + if (message.isHltv === true) { + obj.isHltv = message.isHltv; + } + if (message.isReplay === true) { + obj.isReplay = message.isReplay; + } + if (message.isRedirectingToProxyRelay === true) { + obj.isRedirectingToProxyRelay = message.isRedirectingToProxyRelay; + } + if (message.cOs !== 0) { + obj.cOs = Math.round(message.cOs); + } + if (message.mapCrc !== 0) { + obj.mapCrc = Math.round(message.mapCrc); + } + if (message.clientCrc !== 0) { + obj.clientCrc = Math.round(message.clientCrc); + } + if (message.stringTableCrc !== 0) { + obj.stringTableCrc = Math.round(message.stringTableCrc); + } + if (message.maxClients !== 0) { + obj.maxClients = Math.round(message.maxClients); + } + if (message.maxClasses !== 0) { + obj.maxClasses = Math.round(message.maxClasses); + } + if (message.playerSlot !== 0) { + obj.playerSlot = Math.round(message.playerSlot); + } + if (message.tickInterval !== 0) { + obj.tickInterval = message.tickInterval; + } + if (message.gameDir !== '') { + obj.gameDir = message.gameDir; + } + if (message.mapName !== '') { + obj.mapName = message.mapName; + } + if (message.mapGroupName !== '') { + obj.mapGroupName = message.mapGroupName; + } + if (message.skyName !== '') { + obj.skyName = message.skyName; + } + if (message.hostName !== '') { + obj.hostName = message.hostName; + } + if (message.publicIp !== 0) { + obj.publicIp = Math.round(message.publicIp); + } + if (message.ugcMapId !== 0) { + obj.ugcMapId = Math.round(message.ugcMapId); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgServerInfo { + return CSVCMsgServerInfo.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgServerInfo { + const message = createBaseCSVCMsgServerInfo(); + message.protocol = object.protocol ?? 0; + message.serverCount = object.serverCount ?? 0; + message.isDedicated = object.isDedicated ?? false; + message.isOfficialValveServer = object.isOfficialValveServer ?? false; + message.isHltv = object.isHltv ?? false; + message.isReplay = object.isReplay ?? false; + message.isRedirectingToProxyRelay = object.isRedirectingToProxyRelay ?? false; + message.cOs = object.cOs ?? 0; + message.mapCrc = object.mapCrc ?? 0; + message.clientCrc = object.clientCrc ?? 0; + message.stringTableCrc = object.stringTableCrc ?? 0; + message.maxClients = object.maxClients ?? 0; + message.maxClasses = object.maxClasses ?? 0; + message.playerSlot = object.playerSlot ?? 0; + message.tickInterval = object.tickInterval ?? 0; + message.gameDir = object.gameDir ?? ''; + message.mapName = object.mapName ?? ''; + message.mapGroupName = object.mapGroupName ?? ''; + message.skyName = object.skyName ?? ''; + message.hostName = object.hostName ?? ''; + message.publicIp = object.publicIp ?? 0; + message.ugcMapId = object.ugcMapId ?? 0; + return message; + }, +}; + +function createBaseCSVCMsgClassInfo(): CSVCMsgClassInfo { + return { createOnClient: false, classes: [] }; +} + +export const CSVCMsgClassInfo = { + encode(message: CSVCMsgClassInfo, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.createOnClient === true) { + writer.uint32(8).bool(message.createOnClient); + } + for (const v of message.classes) { + CSVCMsgClassInfo_classT.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgClassInfo { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgClassInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.createOnClient = reader.bool(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.classes.push(CSVCMsgClassInfo_classT.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgClassInfo { + return { + createOnClient: isSet(object.createOnClient) ? globalThis.Boolean(object.createOnClient) : false, + classes: globalThis.Array.isArray(object?.classes) + ? object.classes.map((e: any) => CSVCMsgClassInfo_classT.fromJSON(e)) + : [], + }; + }, + + toJSON(message: CSVCMsgClassInfo): unknown { + const obj: any = {}; + if (message.createOnClient === true) { + obj.createOnClient = message.createOnClient; + } + if (message.classes?.length) { + obj.classes = message.classes.map((e) => CSVCMsgClassInfo_classT.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgClassInfo { + return CSVCMsgClassInfo.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgClassInfo { + const message = createBaseCSVCMsgClassInfo(); + message.createOnClient = object.createOnClient ?? false; + message.classes = object.classes?.map((e) => CSVCMsgClassInfo_classT.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseCSVCMsgClassInfo_classT(): CSVCMsgClassInfo_classT { + return { classId: 0, dataTableName: '', className: '' }; +} + +export const CSVCMsgClassInfo_classT = { + encode(message: CSVCMsgClassInfo_classT, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.classId !== 0) { + writer.uint32(8).int32(message.classId); + } + if (message.dataTableName !== '') { + writer.uint32(18).string(message.dataTableName); + } + if (message.className !== '') { + writer.uint32(26).string(message.className); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgClassInfo_classT { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgClassInfo_classT(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.classId = reader.int32(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.dataTableName = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.className = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgClassInfo_classT { + return { + classId: isSet(object.classId) ? globalThis.Number(object.classId) : 0, + dataTableName: isSet(object.dataTableName) ? globalThis.String(object.dataTableName) : '', + className: isSet(object.className) ? globalThis.String(object.className) : '', + }; + }, + + toJSON(message: CSVCMsgClassInfo_classT): unknown { + const obj: any = {}; + if (message.classId !== 0) { + obj.classId = Math.round(message.classId); + } + if (message.dataTableName !== '') { + obj.dataTableName = message.dataTableName; + } + if (message.className !== '') { + obj.className = message.className; + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgClassInfo_classT { + return CSVCMsgClassInfo_classT.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgClassInfo_classT { + const message = createBaseCSVCMsgClassInfo_classT(); + message.classId = object.classId ?? 0; + message.dataTableName = object.dataTableName ?? ''; + message.className = object.className ?? ''; + return message; + }, +}; + +function createBaseCSVCMsgSendTable(): CSVCMsgSendTable { + return { isEnd: false, netTableName: '', needsDecoder: false, props: [] }; +} + +export const CSVCMsgSendTable = { + encode(message: CSVCMsgSendTable, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.isEnd === true) { + writer.uint32(8).bool(message.isEnd); + } + if (message.netTableName !== '') { + writer.uint32(18).string(message.netTableName); + } + if (message.needsDecoder === true) { + writer.uint32(24).bool(message.needsDecoder); + } + for (const v of message.props) { + CSVCMsgSendTable_sendpropT.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgSendTable { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgSendTable(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.isEnd = reader.bool(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.netTableName = reader.string(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.needsDecoder = reader.bool(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.props.push(CSVCMsgSendTable_sendpropT.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgSendTable { + return { + isEnd: isSet(object.isEnd) ? globalThis.Boolean(object.isEnd) : false, + netTableName: isSet(object.netTableName) ? globalThis.String(object.netTableName) : '', + needsDecoder: isSet(object.needsDecoder) ? globalThis.Boolean(object.needsDecoder) : false, + props: globalThis.Array.isArray(object?.props) + ? object.props.map((e: any) => CSVCMsgSendTable_sendpropT.fromJSON(e)) + : [], + }; + }, + + toJSON(message: CSVCMsgSendTable): unknown { + const obj: any = {}; + if (message.isEnd === true) { + obj.isEnd = message.isEnd; + } + if (message.netTableName !== '') { + obj.netTableName = message.netTableName; + } + if (message.needsDecoder === true) { + obj.needsDecoder = message.needsDecoder; + } + if (message.props?.length) { + obj.props = message.props.map((e) => CSVCMsgSendTable_sendpropT.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgSendTable { + return CSVCMsgSendTable.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgSendTable { + const message = createBaseCSVCMsgSendTable(); + message.isEnd = object.isEnd ?? false; + message.netTableName = object.netTableName ?? ''; + message.needsDecoder = object.needsDecoder ?? false; + message.props = object.props?.map((e) => CSVCMsgSendTable_sendpropT.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseCSVCMsgSendTable_sendpropT(): CSVCMsgSendTable_sendpropT { + return { + type: 0, + varName: '', + flags: 0, + priority: 0, + dtName: '', + numElements: 0, + lowValue: 0, + highValue: 0, + numBits: 0, + }; +} + +export const CSVCMsgSendTable_sendpropT = { + encode(message: CSVCMsgSendTable_sendpropT, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + if (message.varName !== '') { + writer.uint32(18).string(message.varName); + } + if (message.flags !== 0) { + writer.uint32(24).int32(message.flags); + } + if (message.priority !== 0) { + writer.uint32(32).int32(message.priority); + } + if (message.dtName !== '') { + writer.uint32(42).string(message.dtName); + } + if (message.numElements !== 0) { + writer.uint32(48).int32(message.numElements); + } + if (message.lowValue !== 0) { + writer.uint32(61).float(message.lowValue); + } + if (message.highValue !== 0) { + writer.uint32(69).float(message.highValue); + } + if (message.numBits !== 0) { + writer.uint32(72).int32(message.numBits); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgSendTable_sendpropT { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgSendTable_sendpropT(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.type = reader.int32(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.varName = reader.string(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.flags = reader.int32(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.priority = reader.int32(); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.dtName = reader.string(); + continue; + case 6: + if (tag !== 48) { + break; + } + + message.numElements = reader.int32(); + continue; + case 7: + if (tag !== 61) { + break; + } + + message.lowValue = reader.float(); + continue; + case 8: + if (tag !== 69) { + break; + } + + message.highValue = reader.float(); + continue; + case 9: + if (tag !== 72) { + break; + } + + message.numBits = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgSendTable_sendpropT { + return { + type: isSet(object.type) ? globalThis.Number(object.type) : 0, + varName: isSet(object.varName) ? globalThis.String(object.varName) : '', + flags: isSet(object.flags) ? globalThis.Number(object.flags) : 0, + priority: isSet(object.priority) ? globalThis.Number(object.priority) : 0, + dtName: isSet(object.dtName) ? globalThis.String(object.dtName) : '', + numElements: isSet(object.numElements) ? globalThis.Number(object.numElements) : 0, + lowValue: isSet(object.lowValue) ? globalThis.Number(object.lowValue) : 0, + highValue: isSet(object.highValue) ? globalThis.Number(object.highValue) : 0, + numBits: isSet(object.numBits) ? globalThis.Number(object.numBits) : 0, + }; + }, + + toJSON(message: CSVCMsgSendTable_sendpropT): unknown { + const obj: any = {}; + if (message.type !== 0) { + obj.type = Math.round(message.type); + } + if (message.varName !== '') { + obj.varName = message.varName; + } + if (message.flags !== 0) { + obj.flags = Math.round(message.flags); + } + if (message.priority !== 0) { + obj.priority = Math.round(message.priority); + } + if (message.dtName !== '') { + obj.dtName = message.dtName; + } + if (message.numElements !== 0) { + obj.numElements = Math.round(message.numElements); + } + if (message.lowValue !== 0) { + obj.lowValue = message.lowValue; + } + if (message.highValue !== 0) { + obj.highValue = message.highValue; + } + if (message.numBits !== 0) { + obj.numBits = Math.round(message.numBits); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgSendTable_sendpropT { + return CSVCMsgSendTable_sendpropT.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgSendTable_sendpropT { + const message = createBaseCSVCMsgSendTable_sendpropT(); + message.type = object.type ?? 0; + message.varName = object.varName ?? ''; + message.flags = object.flags ?? 0; + message.priority = object.priority ?? 0; + message.dtName = object.dtName ?? ''; + message.numElements = object.numElements ?? 0; + message.lowValue = object.lowValue ?? 0; + message.highValue = object.highValue ?? 0; + message.numBits = object.numBits ?? 0; + return message; + }, +}; + +function createBaseCSVCMsgPrint(): CSVCMsgPrint { + return { text: '' }; +} + +export const CSVCMsgPrint = { + encode(message: CSVCMsgPrint, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.text !== '') { + writer.uint32(10).string(message.text); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgPrint { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgPrint(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.text = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgPrint { + return { text: isSet(object.text) ? globalThis.String(object.text) : '' }; + }, + + toJSON(message: CSVCMsgPrint): unknown { + const obj: any = {}; + if (message.text !== '') { + obj.text = message.text; + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgPrint { + return CSVCMsgPrint.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgPrint { + const message = createBaseCSVCMsgPrint(); + message.text = object.text ?? ''; + return message; + }, +}; + +function createBaseCSVCMsgSetPause(): CSVCMsgSetPause { + return { paused: false }; +} + +export const CSVCMsgSetPause = { + encode(message: CSVCMsgSetPause, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.paused === true) { + writer.uint32(8).bool(message.paused); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgSetPause { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgSetPause(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.paused = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgSetPause { + return { paused: isSet(object.paused) ? globalThis.Boolean(object.paused) : false }; + }, + + toJSON(message: CSVCMsgSetPause): unknown { + const obj: any = {}; + if (message.paused === true) { + obj.paused = message.paused; + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgSetPause { + return CSVCMsgSetPause.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgSetPause { + const message = createBaseCSVCMsgSetPause(); + message.paused = object.paused ?? false; + return message; + }, +}; + +function createBaseCSVCMsgSetView(): CSVCMsgSetView { + return { entityIndex: 0 }; +} + +export const CSVCMsgSetView = { + encode(message: CSVCMsgSetView, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.entityIndex !== 0) { + writer.uint32(8).int32(message.entityIndex); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgSetView { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgSetView(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.entityIndex = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgSetView { + return { entityIndex: isSet(object.entityIndex) ? globalThis.Number(object.entityIndex) : 0 }; + }, + + toJSON(message: CSVCMsgSetView): unknown { + const obj: any = {}; + if (message.entityIndex !== 0) { + obj.entityIndex = Math.round(message.entityIndex); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgSetView { + return CSVCMsgSetView.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgSetView { + const message = createBaseCSVCMsgSetView(); + message.entityIndex = object.entityIndex ?? 0; + return message; + }, +}; + +function createBaseCSVCMsgCreateStringTable(): CSVCMsgCreateStringTable { + return { + name: '', + maxEntries: 0, + numEntries: 0, + userDataFixedSize: false, + userDataSize: 0, + userDataSizeBits: 0, + flags: 0, + stringData: new Uint8Array(0), + }; +} + +export const CSVCMsgCreateStringTable = { + encode(message: CSVCMsgCreateStringTable, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.name !== '') { + writer.uint32(10).string(message.name); + } + if (message.maxEntries !== 0) { + writer.uint32(16).int32(message.maxEntries); + } + if (message.numEntries !== 0) { + writer.uint32(24).int32(message.numEntries); + } + if (message.userDataFixedSize === true) { + writer.uint32(32).bool(message.userDataFixedSize); + } + if (message.userDataSize !== 0) { + writer.uint32(40).int32(message.userDataSize); + } + if (message.userDataSizeBits !== 0) { + writer.uint32(48).int32(message.userDataSizeBits); + } + if (message.flags !== 0) { + writer.uint32(56).int32(message.flags); + } + if (message.stringData.length !== 0) { + writer.uint32(66).bytes(message.stringData); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgCreateStringTable { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgCreateStringTable(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.name = reader.string(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.maxEntries = reader.int32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.numEntries = reader.int32(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.userDataFixedSize = reader.bool(); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.userDataSize = reader.int32(); + continue; + case 6: + if (tag !== 48) { + break; + } + + message.userDataSizeBits = reader.int32(); + continue; + case 7: + if (tag !== 56) { + break; + } + + message.flags = reader.int32(); + continue; + case 8: + if (tag !== 66) { + break; + } + + message.stringData = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgCreateStringTable { + return { + name: isSet(object.name) ? globalThis.String(object.name) : '', + maxEntries: isSet(object.maxEntries) ? globalThis.Number(object.maxEntries) : 0, + numEntries: isSet(object.numEntries) ? globalThis.Number(object.numEntries) : 0, + userDataFixedSize: isSet(object.userDataFixedSize) ? globalThis.Boolean(object.userDataFixedSize) : false, + userDataSize: isSet(object.userDataSize) ? globalThis.Number(object.userDataSize) : 0, + userDataSizeBits: isSet(object.userDataSizeBits) ? globalThis.Number(object.userDataSizeBits) : 0, + flags: isSet(object.flags) ? globalThis.Number(object.flags) : 0, + stringData: isSet(object.stringData) ? bytesFromBase64(object.stringData) : new Uint8Array(0), + }; + }, + + toJSON(message: CSVCMsgCreateStringTable): unknown { + const obj: any = {}; + if (message.name !== '') { + obj.name = message.name; + } + if (message.maxEntries !== 0) { + obj.maxEntries = Math.round(message.maxEntries); + } + if (message.numEntries !== 0) { + obj.numEntries = Math.round(message.numEntries); + } + if (message.userDataFixedSize === true) { + obj.userDataFixedSize = message.userDataFixedSize; + } + if (message.userDataSize !== 0) { + obj.userDataSize = Math.round(message.userDataSize); + } + if (message.userDataSizeBits !== 0) { + obj.userDataSizeBits = Math.round(message.userDataSizeBits); + } + if (message.flags !== 0) { + obj.flags = Math.round(message.flags); + } + if (message.stringData.length !== 0) { + obj.stringData = base64FromBytes(message.stringData); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgCreateStringTable { + return CSVCMsgCreateStringTable.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgCreateStringTable { + const message = createBaseCSVCMsgCreateStringTable(); + message.name = object.name ?? ''; + message.maxEntries = object.maxEntries ?? 0; + message.numEntries = object.numEntries ?? 0; + message.userDataFixedSize = object.userDataFixedSize ?? false; + message.userDataSize = object.userDataSize ?? 0; + message.userDataSizeBits = object.userDataSizeBits ?? 0; + message.flags = object.flags ?? 0; + message.stringData = object.stringData ?? new Uint8Array(0); + return message; + }, +}; + +function createBaseCSVCMsgUpdateStringTable(): CSVCMsgUpdateStringTable { + return { tableId: 0, numChangedEntries: 0, stringData: new Uint8Array(0) }; +} + +export const CSVCMsgUpdateStringTable = { + encode(message: CSVCMsgUpdateStringTable, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.tableId !== 0) { + writer.uint32(8).int32(message.tableId); + } + if (message.numChangedEntries !== 0) { + writer.uint32(16).int32(message.numChangedEntries); + } + if (message.stringData.length !== 0) { + writer.uint32(26).bytes(message.stringData); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgUpdateStringTable { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgUpdateStringTable(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.tableId = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.numChangedEntries = reader.int32(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.stringData = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgUpdateStringTable { + return { + tableId: isSet(object.tableId) ? globalThis.Number(object.tableId) : 0, + numChangedEntries: isSet(object.numChangedEntries) ? globalThis.Number(object.numChangedEntries) : 0, + stringData: isSet(object.stringData) ? bytesFromBase64(object.stringData) : new Uint8Array(0), + }; + }, + + toJSON(message: CSVCMsgUpdateStringTable): unknown { + const obj: any = {}; + if (message.tableId !== 0) { + obj.tableId = Math.round(message.tableId); + } + if (message.numChangedEntries !== 0) { + obj.numChangedEntries = Math.round(message.numChangedEntries); + } + if (message.stringData.length !== 0) { + obj.stringData = base64FromBytes(message.stringData); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgUpdateStringTable { + return CSVCMsgUpdateStringTable.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgUpdateStringTable { + const message = createBaseCSVCMsgUpdateStringTable(); + message.tableId = object.tableId ?? 0; + message.numChangedEntries = object.numChangedEntries ?? 0; + message.stringData = object.stringData ?? new Uint8Array(0); + return message; + }, +}; + +function createBaseCSVCMsgVoiceInit(): CSVCMsgVoiceInit { + return { quality: 0, codec: '', version: 0 }; +} + +export const CSVCMsgVoiceInit = { + encode(message: CSVCMsgVoiceInit, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.quality !== 0) { + writer.uint32(8).int32(message.quality); + } + if (message.codec !== '') { + writer.uint32(18).string(message.codec); + } + if (message.version !== 0) { + writer.uint32(24).int32(message.version); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgVoiceInit { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgVoiceInit(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.quality = reader.int32(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.codec = reader.string(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.version = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgVoiceInit { + return { + quality: isSet(object.quality) ? globalThis.Number(object.quality) : 0, + codec: isSet(object.codec) ? globalThis.String(object.codec) : '', + version: isSet(object.version) ? globalThis.Number(object.version) : 0, + }; + }, + + toJSON(message: CSVCMsgVoiceInit): unknown { + const obj: any = {}; + if (message.quality !== 0) { + obj.quality = Math.round(message.quality); + } + if (message.codec !== '') { + obj.codec = message.codec; + } + if (message.version !== 0) { + obj.version = Math.round(message.version); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgVoiceInit { + return CSVCMsgVoiceInit.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgVoiceInit { + const message = createBaseCSVCMsgVoiceInit(); + message.quality = object.quality ?? 0; + message.codec = object.codec ?? ''; + message.version = object.version ?? 0; + return message; + }, +}; + +function createBaseCSVCMsgVoiceData(): CSVCMsgVoiceData { + return { + client: 0, + proximity: false, + xuid: 0, + audibleMask: 0, + voiceData: new Uint8Array(0), + caster: false, + format: 0, + sequenceBytes: 0, + sectionNumber: 0, + uncompressedSampleOffset: 0, + }; +} + +export const CSVCMsgVoiceData = { + encode(message: CSVCMsgVoiceData, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.client !== 0) { + writer.uint32(8).int32(message.client); + } + if (message.proximity === true) { + writer.uint32(16).bool(message.proximity); + } + if (message.xuid !== 0) { + writer.uint32(25).fixed64(message.xuid); + } + if (message.audibleMask !== 0) { + writer.uint32(32).int32(message.audibleMask); + } + if (message.voiceData.length !== 0) { + writer.uint32(42).bytes(message.voiceData); + } + if (message.caster === true) { + writer.uint32(48).bool(message.caster); + } + if (message.format !== 0) { + writer.uint32(56).int32(message.format); + } + if (message.sequenceBytes !== 0) { + writer.uint32(64).int32(message.sequenceBytes); + } + if (message.sectionNumber !== 0) { + writer.uint32(72).uint32(message.sectionNumber); + } + if (message.uncompressedSampleOffset !== 0) { + writer.uint32(80).uint32(message.uncompressedSampleOffset); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgVoiceData { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgVoiceData(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.client = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.proximity = reader.bool(); + continue; + case 3: + if (tag !== 25) { + break; + } + + message.xuid = longToNumber(reader.fixed64() as Long); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.audibleMask = reader.int32(); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.voiceData = reader.bytes(); + continue; + case 6: + if (tag !== 48) { + break; + } + + message.caster = reader.bool(); + continue; + case 7: + if (tag !== 56) { + break; + } + + message.format = reader.int32() as any; + continue; + case 8: + if (tag !== 64) { + break; + } + + message.sequenceBytes = reader.int32(); + continue; + case 9: + if (tag !== 72) { + break; + } + + message.sectionNumber = reader.uint32(); + continue; + case 10: + if (tag !== 80) { + break; + } + + message.uncompressedSampleOffset = reader.uint32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgVoiceData { + return { + client: isSet(object.client) ? globalThis.Number(object.client) : 0, + proximity: isSet(object.proximity) ? globalThis.Boolean(object.proximity) : false, + xuid: isSet(object.xuid) ? globalThis.Number(object.xuid) : 0, + audibleMask: isSet(object.audibleMask) ? globalThis.Number(object.audibleMask) : 0, + voiceData: isSet(object.voiceData) ? bytesFromBase64(object.voiceData) : new Uint8Array(0), + caster: isSet(object.caster) ? globalThis.Boolean(object.caster) : false, + format: isSet(object.format) ? voiceDataFormatTFromJSON(object.format) : 0, + sequenceBytes: isSet(object.sequenceBytes) ? globalThis.Number(object.sequenceBytes) : 0, + sectionNumber: isSet(object.sectionNumber) ? globalThis.Number(object.sectionNumber) : 0, + uncompressedSampleOffset: isSet(object.uncompressedSampleOffset) + ? globalThis.Number(object.uncompressedSampleOffset) + : 0, + }; + }, + + toJSON(message: CSVCMsgVoiceData): unknown { + const obj: any = {}; + if (message.client !== 0) { + obj.client = Math.round(message.client); + } + if (message.proximity === true) { + obj.proximity = message.proximity; + } + if (message.xuid !== 0) { + obj.xuid = Math.round(message.xuid); + } + if (message.audibleMask !== 0) { + obj.audibleMask = Math.round(message.audibleMask); + } + if (message.voiceData.length !== 0) { + obj.voiceData = base64FromBytes(message.voiceData); + } + if (message.caster === true) { + obj.caster = message.caster; + } + if (message.format !== 0) { + obj.format = voiceDataFormatTToJSON(message.format); + } + if (message.sequenceBytes !== 0) { + obj.sequenceBytes = Math.round(message.sequenceBytes); + } + if (message.sectionNumber !== 0) { + obj.sectionNumber = Math.round(message.sectionNumber); + } + if (message.uncompressedSampleOffset !== 0) { + obj.uncompressedSampleOffset = Math.round(message.uncompressedSampleOffset); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgVoiceData { + return CSVCMsgVoiceData.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgVoiceData { + const message = createBaseCSVCMsgVoiceData(); + message.client = object.client ?? 0; + message.proximity = object.proximity ?? false; + message.xuid = object.xuid ?? 0; + message.audibleMask = object.audibleMask ?? 0; + message.voiceData = object.voiceData ?? new Uint8Array(0); + message.caster = object.caster ?? false; + message.format = object.format ?? 0; + message.sequenceBytes = object.sequenceBytes ?? 0; + message.sectionNumber = object.sectionNumber ?? 0; + message.uncompressedSampleOffset = object.uncompressedSampleOffset ?? 0; + return message; + }, +}; + +function createBaseCSVCMsgFixAngle(): CSVCMsgFixAngle { + return { relative: false, angle: undefined }; +} + +export const CSVCMsgFixAngle = { + encode(message: CSVCMsgFixAngle, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.relative === true) { + writer.uint32(8).bool(message.relative); + } + if (message.angle !== undefined) { + CMsgQAngle.encode(message.angle, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgFixAngle { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgFixAngle(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.relative = reader.bool(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.angle = CMsgQAngle.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgFixAngle { + return { + relative: isSet(object.relative) ? globalThis.Boolean(object.relative) : false, + angle: isSet(object.angle) ? CMsgQAngle.fromJSON(object.angle) : undefined, + }; + }, + + toJSON(message: CSVCMsgFixAngle): unknown { + const obj: any = {}; + if (message.relative === true) { + obj.relative = message.relative; + } + if (message.angle !== undefined) { + obj.angle = CMsgQAngle.toJSON(message.angle); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgFixAngle { + return CSVCMsgFixAngle.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgFixAngle { + const message = createBaseCSVCMsgFixAngle(); + message.relative = object.relative ?? false; + message.angle = (object.angle !== undefined && object.angle !== null) + ? CMsgQAngle.fromPartial(object.angle) + : undefined; + return message; + }, +}; + +function createBaseCSVCMsgCrosshairAngle(): CSVCMsgCrosshairAngle { + return { angle: undefined }; +} + +export const CSVCMsgCrosshairAngle = { + encode(message: CSVCMsgCrosshairAngle, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.angle !== undefined) { + CMsgQAngle.encode(message.angle, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgCrosshairAngle { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgCrosshairAngle(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.angle = CMsgQAngle.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgCrosshairAngle { + return { angle: isSet(object.angle) ? CMsgQAngle.fromJSON(object.angle) : undefined }; + }, + + toJSON(message: CSVCMsgCrosshairAngle): unknown { + const obj: any = {}; + if (message.angle !== undefined) { + obj.angle = CMsgQAngle.toJSON(message.angle); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgCrosshairAngle { + return CSVCMsgCrosshairAngle.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgCrosshairAngle { + const message = createBaseCSVCMsgCrosshairAngle(); + message.angle = (object.angle !== undefined && object.angle !== null) + ? CMsgQAngle.fromPartial(object.angle) + : undefined; + return message; + }, +}; + +function createBaseCSVCMsgPrefetch(): CSVCMsgPrefetch { + return { soundIndex: 0 }; +} + +export const CSVCMsgPrefetch = { + encode(message: CSVCMsgPrefetch, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.soundIndex !== 0) { + writer.uint32(8).int32(message.soundIndex); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgPrefetch { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgPrefetch(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.soundIndex = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgPrefetch { + return { soundIndex: isSet(object.soundIndex) ? globalThis.Number(object.soundIndex) : 0 }; + }, + + toJSON(message: CSVCMsgPrefetch): unknown { + const obj: any = {}; + if (message.soundIndex !== 0) { + obj.soundIndex = Math.round(message.soundIndex); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgPrefetch { + return CSVCMsgPrefetch.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgPrefetch { + const message = createBaseCSVCMsgPrefetch(); + message.soundIndex = object.soundIndex ?? 0; + return message; + }, +}; + +function createBaseCSVCMsgBSPDecal(): CSVCMsgBSPDecal { + return { pos: undefined, decalTextureIndex: 0, entityIndex: 0, modelIndex: 0, lowPriority: false }; +} + +export const CSVCMsgBSPDecal = { + encode(message: CSVCMsgBSPDecal, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.pos !== undefined) { + CMsgVector.encode(message.pos, writer.uint32(10).fork()).ldelim(); + } + if (message.decalTextureIndex !== 0) { + writer.uint32(16).int32(message.decalTextureIndex); + } + if (message.entityIndex !== 0) { + writer.uint32(24).int32(message.entityIndex); + } + if (message.modelIndex !== 0) { + writer.uint32(32).int32(message.modelIndex); + } + if (message.lowPriority === true) { + writer.uint32(40).bool(message.lowPriority); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgBSPDecal { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgBSPDecal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.pos = CMsgVector.decode(reader, reader.uint32()); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.decalTextureIndex = reader.int32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.entityIndex = reader.int32(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.modelIndex = reader.int32(); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.lowPriority = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgBSPDecal { + return { + pos: isSet(object.pos) ? CMsgVector.fromJSON(object.pos) : undefined, + decalTextureIndex: isSet(object.decalTextureIndex) ? globalThis.Number(object.decalTextureIndex) : 0, + entityIndex: isSet(object.entityIndex) ? globalThis.Number(object.entityIndex) : 0, + modelIndex: isSet(object.modelIndex) ? globalThis.Number(object.modelIndex) : 0, + lowPriority: isSet(object.lowPriority) ? globalThis.Boolean(object.lowPriority) : false, + }; + }, + + toJSON(message: CSVCMsgBSPDecal): unknown { + const obj: any = {}; + if (message.pos !== undefined) { + obj.pos = CMsgVector.toJSON(message.pos); + } + if (message.decalTextureIndex !== 0) { + obj.decalTextureIndex = Math.round(message.decalTextureIndex); + } + if (message.entityIndex !== 0) { + obj.entityIndex = Math.round(message.entityIndex); + } + if (message.modelIndex !== 0) { + obj.modelIndex = Math.round(message.modelIndex); + } + if (message.lowPriority === true) { + obj.lowPriority = message.lowPriority; + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgBSPDecal { + return CSVCMsgBSPDecal.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgBSPDecal { + const message = createBaseCSVCMsgBSPDecal(); + message.pos = (object.pos !== undefined && object.pos !== null) + ? CMsgVector.fromPartial(object.pos) + : undefined; + message.decalTextureIndex = object.decalTextureIndex ?? 0; + message.entityIndex = object.entityIndex ?? 0; + message.modelIndex = object.modelIndex ?? 0; + message.lowPriority = object.lowPriority ?? false; + return message; + }, +}; + +function createBaseCSVCMsgSplitScreen(): CSVCMsgSplitScreen { + return { type: 0, slot: 0, playerIndex: 0 }; +} + +export const CSVCMsgSplitScreen = { + encode(message: CSVCMsgSplitScreen, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + if (message.slot !== 0) { + writer.uint32(16).int32(message.slot); + } + if (message.playerIndex !== 0) { + writer.uint32(24).int32(message.playerIndex); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgSplitScreen { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgSplitScreen(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.type = reader.int32() as any; + continue; + case 2: + if (tag !== 16) { + break; + } + + message.slot = reader.int32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.playerIndex = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgSplitScreen { + return { + type: isSet(object.type) ? eSplitScreenMessageTypeFromJSON(object.type) : 0, + slot: isSet(object.slot) ? globalThis.Number(object.slot) : 0, + playerIndex: isSet(object.playerIndex) ? globalThis.Number(object.playerIndex) : 0, + }; + }, + + toJSON(message: CSVCMsgSplitScreen): unknown { + const obj: any = {}; + if (message.type !== 0) { + obj.type = eSplitScreenMessageTypeToJSON(message.type); + } + if (message.slot !== 0) { + obj.slot = Math.round(message.slot); + } + if (message.playerIndex !== 0) { + obj.playerIndex = Math.round(message.playerIndex); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgSplitScreen { + return CSVCMsgSplitScreen.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgSplitScreen { + const message = createBaseCSVCMsgSplitScreen(); + message.type = object.type ?? 0; + message.slot = object.slot ?? 0; + message.playerIndex = object.playerIndex ?? 0; + return message; + }, +}; + +function createBaseCSVCMsgGetCvarValue(): CSVCMsgGetCvarValue { + return { cookie: 0, cvarName: '' }; +} + +export const CSVCMsgGetCvarValue = { + encode(message: CSVCMsgGetCvarValue, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.cookie !== 0) { + writer.uint32(8).int32(message.cookie); + } + if (message.cvarName !== '') { + writer.uint32(18).string(message.cvarName); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgGetCvarValue { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgGetCvarValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.cookie = reader.int32(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.cvarName = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgGetCvarValue { + return { + cookie: isSet(object.cookie) ? globalThis.Number(object.cookie) : 0, + cvarName: isSet(object.cvarName) ? globalThis.String(object.cvarName) : '', + }; + }, + + toJSON(message: CSVCMsgGetCvarValue): unknown { + const obj: any = {}; + if (message.cookie !== 0) { + obj.cookie = Math.round(message.cookie); + } + if (message.cvarName !== '') { + obj.cvarName = message.cvarName; + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgGetCvarValue { + return CSVCMsgGetCvarValue.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgGetCvarValue { + const message = createBaseCSVCMsgGetCvarValue(); + message.cookie = object.cookie ?? 0; + message.cvarName = object.cvarName ?? ''; + return message; + }, +}; + +function createBaseCSVCMsgUserMessage(): CSVCMsgUserMessage { + return { msgType: 0, msgData: new Uint8Array(0), passthrough: 0 }; +} + +export const CSVCMsgUserMessage = { + encode(message: CSVCMsgUserMessage, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.msgType !== 0) { + writer.uint32(8).int32(message.msgType); + } + if (message.msgData.length !== 0) { + writer.uint32(18).bytes(message.msgData); + } + if (message.passthrough !== 0) { + writer.uint32(24).int32(message.passthrough); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgUserMessage { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgUserMessage(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.msgType = reader.int32(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.msgData = reader.bytes(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.passthrough = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgUserMessage { + return { + msgType: isSet(object.msgType) ? globalThis.Number(object.msgType) : 0, + msgData: isSet(object.msgData) ? bytesFromBase64(object.msgData) : new Uint8Array(0), + passthrough: isSet(object.passthrough) ? globalThis.Number(object.passthrough) : 0, + }; + }, + + toJSON(message: CSVCMsgUserMessage): unknown { + const obj: any = {}; + if (message.msgType !== 0) { + obj.msgType = Math.round(message.msgType); + } + if (message.msgData.length !== 0) { + obj.msgData = base64FromBytes(message.msgData); + } + if (message.passthrough !== 0) { + obj.passthrough = Math.round(message.passthrough); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgUserMessage { + return CSVCMsgUserMessage.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgUserMessage { + const message = createBaseCSVCMsgUserMessage(); + message.msgType = object.msgType ?? 0; + message.msgData = object.msgData ?? new Uint8Array(0); + message.passthrough = object.passthrough ?? 0; + return message; + }, +}; + +function createBaseCSVCMsgPaintmapData(): CSVCMsgPaintmapData { + return { paintmap: new Uint8Array(0) }; +} + +export const CSVCMsgPaintmapData = { + encode(message: CSVCMsgPaintmapData, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.paintmap.length !== 0) { + writer.uint32(10).bytes(message.paintmap); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgPaintmapData { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgPaintmapData(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.paintmap = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgPaintmapData { + return { paintmap: isSet(object.paintmap) ? bytesFromBase64(object.paintmap) : new Uint8Array(0) }; + }, + + toJSON(message: CSVCMsgPaintmapData): unknown { + const obj: any = {}; + if (message.paintmap.length !== 0) { + obj.paintmap = base64FromBytes(message.paintmap); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgPaintmapData { + return CSVCMsgPaintmapData.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgPaintmapData { + const message = createBaseCSVCMsgPaintmapData(); + message.paintmap = object.paintmap ?? new Uint8Array(0); + return message; + }, +}; + +function createBaseCSVCMsgGameEvent(): CSVCMsgGameEvent { + return { eventName: '', eventid: 0, keys: [], passthrough: 0 }; +} + +export const CSVCMsgGameEvent = { + encode(message: CSVCMsgGameEvent, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.eventName !== '') { + writer.uint32(10).string(message.eventName); + } + if (message.eventid !== 0) { + writer.uint32(16).int32(message.eventid); + } + for (const v of message.keys) { + CSVCMsgGameEvent_keyT.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.passthrough !== 0) { + writer.uint32(32).int32(message.passthrough); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgGameEvent { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgGameEvent(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.eventName = reader.string(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.eventid = reader.int32(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.keys.push(CSVCMsgGameEvent_keyT.decode(reader, reader.uint32())); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.passthrough = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgGameEvent { + return { + eventName: isSet(object.eventName) ? globalThis.String(object.eventName) : '', + eventid: isSet(object.eventid) ? globalThis.Number(object.eventid) : 0, + keys: globalThis.Array.isArray(object?.keys) + ? object.keys.map((e: any) => CSVCMsgGameEvent_keyT.fromJSON(e)) + : [], + passthrough: isSet(object.passthrough) ? globalThis.Number(object.passthrough) : 0, + }; + }, + + toJSON(message: CSVCMsgGameEvent): unknown { + const obj: any = {}; + if (message.eventName !== '') { + obj.eventName = message.eventName; + } + if (message.eventid !== 0) { + obj.eventid = Math.round(message.eventid); + } + if (message.keys?.length) { + obj.keys = message.keys.map((e) => CSVCMsgGameEvent_keyT.toJSON(e)); + } + if (message.passthrough !== 0) { + obj.passthrough = Math.round(message.passthrough); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgGameEvent { + return CSVCMsgGameEvent.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgGameEvent { + const message = createBaseCSVCMsgGameEvent(); + message.eventName = object.eventName ?? ''; + message.eventid = object.eventid ?? 0; + message.keys = object.keys?.map((e) => CSVCMsgGameEvent_keyT.fromPartial(e)) || []; + message.passthrough = object.passthrough ?? 0; + return message; + }, +}; + +function createBaseCSVCMsgGameEvent_keyT(): CSVCMsgGameEvent_keyT { + return { + type: 0, + valString: '', + valFloat: 0, + valLong: 0, + valShort: 0, + valByte: 0, + valBool: false, + valUint64: 0, + valWstring: new Uint8Array(0), + }; +} + +export const CSVCMsgGameEvent_keyT = { + encode(message: CSVCMsgGameEvent_keyT, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + if (message.valString !== '') { + writer.uint32(18).string(message.valString); + } + if (message.valFloat !== 0) { + writer.uint32(29).float(message.valFloat); + } + if (message.valLong !== 0) { + writer.uint32(32).int32(message.valLong); + } + if (message.valShort !== 0) { + writer.uint32(40).int32(message.valShort); + } + if (message.valByte !== 0) { + writer.uint32(48).int32(message.valByte); + } + if (message.valBool === true) { + writer.uint32(56).bool(message.valBool); + } + if (message.valUint64 !== 0) { + writer.uint32(64).uint64(message.valUint64); + } + if (message.valWstring.length !== 0) { + writer.uint32(74).bytes(message.valWstring); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgGameEvent_keyT { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgGameEvent_keyT(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.type = reader.int32(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.valString = reader.string(); + continue; + case 3: + if (tag !== 29) { + break; + } + + message.valFloat = reader.float(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.valLong = reader.int32(); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.valShort = reader.int32(); + continue; + case 6: + if (tag !== 48) { + break; + } + + message.valByte = reader.int32(); + continue; + case 7: + if (tag !== 56) { + break; + } + + message.valBool = reader.bool(); + continue; + case 8: + if (tag !== 64) { + break; + } + + message.valUint64 = longToNumber(reader.uint64() as Long); + continue; + case 9: + if (tag !== 74) { + break; + } + + message.valWstring = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgGameEvent_keyT { + return { + type: isSet(object.type) ? globalThis.Number(object.type) : 0, + valString: isSet(object.valString) ? globalThis.String(object.valString) : '', + valFloat: isSet(object.valFloat) ? globalThis.Number(object.valFloat) : 0, + valLong: isSet(object.valLong) ? globalThis.Number(object.valLong) : 0, + valShort: isSet(object.valShort) ? globalThis.Number(object.valShort) : 0, + valByte: isSet(object.valByte) ? globalThis.Number(object.valByte) : 0, + valBool: isSet(object.valBool) ? globalThis.Boolean(object.valBool) : false, + valUint64: isSet(object.valUint64) ? globalThis.Number(object.valUint64) : 0, + valWstring: isSet(object.valWstring) ? bytesFromBase64(object.valWstring) : new Uint8Array(0), + }; + }, + + toJSON(message: CSVCMsgGameEvent_keyT): unknown { + const obj: any = {}; + if (message.type !== 0) { + obj.type = Math.round(message.type); + } + if (message.valString !== '') { + obj.valString = message.valString; + } + if (message.valFloat !== 0) { + obj.valFloat = message.valFloat; + } + if (message.valLong !== 0) { + obj.valLong = Math.round(message.valLong); + } + if (message.valShort !== 0) { + obj.valShort = Math.round(message.valShort); + } + if (message.valByte !== 0) { + obj.valByte = Math.round(message.valByte); + } + if (message.valBool === true) { + obj.valBool = message.valBool; + } + if (message.valUint64 !== 0) { + obj.valUint64 = Math.round(message.valUint64); + } + if (message.valWstring.length !== 0) { + obj.valWstring = base64FromBytes(message.valWstring); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgGameEvent_keyT { + return CSVCMsgGameEvent_keyT.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgGameEvent_keyT { + const message = createBaseCSVCMsgGameEvent_keyT(); + message.type = object.type ?? 0; + message.valString = object.valString ?? ''; + message.valFloat = object.valFloat ?? 0; + message.valLong = object.valLong ?? 0; + message.valShort = object.valShort ?? 0; + message.valByte = object.valByte ?? 0; + message.valBool = object.valBool ?? false; + message.valUint64 = object.valUint64 ?? 0; + message.valWstring = object.valWstring ?? new Uint8Array(0); + return message; + }, +}; + +function createBaseCSVCMsgGameEventList(): CSVCMsgGameEventList { + return { descriptors: [] }; +} + +export const CSVCMsgGameEventList = { + encode(message: CSVCMsgGameEventList, writer: pb.Writer = pb.Writer.create()): pb.Writer { + for (const v of message.descriptors) { + CSVCMsgGameEventList_descriptorT.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgGameEventList { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgGameEventList(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.descriptors.push(CSVCMsgGameEventList_descriptorT.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgGameEventList { + return { + descriptors: globalThis.Array.isArray(object?.descriptors) + ? object.descriptors.map((e: any) => CSVCMsgGameEventList_descriptorT.fromJSON(e)) + : [], + }; + }, + + toJSON(message: CSVCMsgGameEventList): unknown { + const obj: any = {}; + if (message.descriptors?.length) { + obj.descriptors = message.descriptors.map((e) => CSVCMsgGameEventList_descriptorT.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgGameEventList { + return CSVCMsgGameEventList.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgGameEventList { + const message = createBaseCSVCMsgGameEventList(); + message.descriptors = object.descriptors?.map((e) => CSVCMsgGameEventList_descriptorT.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseCSVCMsgGameEventList_keyT(): CSVCMsgGameEventList_keyT { + return { type: 0, name: '' }; +} + +export const CSVCMsgGameEventList_keyT = { + encode(message: CSVCMsgGameEventList_keyT, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + if (message.name !== '') { + writer.uint32(18).string(message.name); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgGameEventList_keyT { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgGameEventList_keyT(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.type = reader.int32(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.name = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgGameEventList_keyT { + return { + type: isSet(object.type) ? globalThis.Number(object.type) : 0, + name: isSet(object.name) ? globalThis.String(object.name) : '', + }; + }, + + toJSON(message: CSVCMsgGameEventList_keyT): unknown { + const obj: any = {}; + if (message.type !== 0) { + obj.type = Math.round(message.type); + } + if (message.name !== '') { + obj.name = message.name; + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgGameEventList_keyT { + return CSVCMsgGameEventList_keyT.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgGameEventList_keyT { + const message = createBaseCSVCMsgGameEventList_keyT(); + message.type = object.type ?? 0; + message.name = object.name ?? ''; + return message; + }, +}; + +function createBaseCSVCMsgGameEventList_descriptorT(): CSVCMsgGameEventList_descriptorT { + return { eventid: 0, name: '', keys: [] }; +} + +export const CSVCMsgGameEventList_descriptorT = { + encode(message: CSVCMsgGameEventList_descriptorT, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.eventid !== 0) { + writer.uint32(8).int32(message.eventid); + } + if (message.name !== '') { + writer.uint32(18).string(message.name); + } + for (const v of message.keys) { + CSVCMsgGameEventList_keyT.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgGameEventList_descriptorT { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgGameEventList_descriptorT(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.eventid = reader.int32(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.name = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.keys.push(CSVCMsgGameEventList_keyT.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgGameEventList_descriptorT { + return { + eventid: isSet(object.eventid) ? globalThis.Number(object.eventid) : 0, + name: isSet(object.name) ? globalThis.String(object.name) : '', + keys: globalThis.Array.isArray(object?.keys) + ? object.keys.map((e: any) => CSVCMsgGameEventList_keyT.fromJSON(e)) + : [], + }; + }, + + toJSON(message: CSVCMsgGameEventList_descriptorT): unknown { + const obj: any = {}; + if (message.eventid !== 0) { + obj.eventid = Math.round(message.eventid); + } + if (message.name !== '') { + obj.name = message.name; + } + if (message.keys?.length) { + obj.keys = message.keys.map((e) => CSVCMsgGameEventList_keyT.toJSON(e)); + } + return obj; + }, + + create, I>>( + base?: I, + ): CSVCMsgGameEventList_descriptorT { + return CSVCMsgGameEventList_descriptorT.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): CSVCMsgGameEventList_descriptorT { + const message = createBaseCSVCMsgGameEventList_descriptorT(); + message.eventid = object.eventid ?? 0; + message.name = object.name ?? ''; + message.keys = object.keys?.map((e) => CSVCMsgGameEventList_keyT.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseCSVCMsgTempEntities(): CSVCMsgTempEntities { + return { reliable: false, numEntries: 0, entityData: new Uint8Array(0) }; +} + +export const CSVCMsgTempEntities = { + encode(message: CSVCMsgTempEntities, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.reliable === true) { + writer.uint32(8).bool(message.reliable); + } + if (message.numEntries !== 0) { + writer.uint32(16).int32(message.numEntries); + } + if (message.entityData.length !== 0) { + writer.uint32(26).bytes(message.entityData); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgTempEntities { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgTempEntities(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.reliable = reader.bool(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.numEntries = reader.int32(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.entityData = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgTempEntities { + return { + reliable: isSet(object.reliable) ? globalThis.Boolean(object.reliable) : false, + numEntries: isSet(object.numEntries) ? globalThis.Number(object.numEntries) : 0, + entityData: isSet(object.entityData) ? bytesFromBase64(object.entityData) : new Uint8Array(0), + }; + }, + + toJSON(message: CSVCMsgTempEntities): unknown { + const obj: any = {}; + if (message.reliable === true) { + obj.reliable = message.reliable; + } + if (message.numEntries !== 0) { + obj.numEntries = Math.round(message.numEntries); + } + if (message.entityData.length !== 0) { + obj.entityData = base64FromBytes(message.entityData); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgTempEntities { + return CSVCMsgTempEntities.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgTempEntities { + const message = createBaseCSVCMsgTempEntities(); + message.reliable = object.reliable ?? false; + message.numEntries = object.numEntries ?? 0; + message.entityData = object.entityData ?? new Uint8Array(0); + return message; + }, +}; + +function createBaseCSVCMsgPacketEntities(): CSVCMsgPacketEntities { + return { + maxEntries: 0, + updatedEntries: 0, + isDelta: false, + updateBaseline: false, + baseline: 0, + deltaFrom: 0, + entityData: new Uint8Array(0), + }; +} + +export const CSVCMsgPacketEntities = { + encode(message: CSVCMsgPacketEntities, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.maxEntries !== 0) { + writer.uint32(8).int32(message.maxEntries); + } + if (message.updatedEntries !== 0) { + writer.uint32(16).int32(message.updatedEntries); + } + if (message.isDelta === true) { + writer.uint32(24).bool(message.isDelta); + } + if (message.updateBaseline === true) { + writer.uint32(32).bool(message.updateBaseline); + } + if (message.baseline !== 0) { + writer.uint32(40).int32(message.baseline); + } + if (message.deltaFrom !== 0) { + writer.uint32(48).int32(message.deltaFrom); + } + if (message.entityData.length !== 0) { + writer.uint32(58).bytes(message.entityData); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgPacketEntities { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgPacketEntities(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.maxEntries = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.updatedEntries = reader.int32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.isDelta = reader.bool(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.updateBaseline = reader.bool(); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.baseline = reader.int32(); + continue; + case 6: + if (tag !== 48) { + break; + } + + message.deltaFrom = reader.int32(); + continue; + case 7: + if (tag !== 58) { + break; + } + + message.entityData = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgPacketEntities { + return { + maxEntries: isSet(object.maxEntries) ? globalThis.Number(object.maxEntries) : 0, + updatedEntries: isSet(object.updatedEntries) ? globalThis.Number(object.updatedEntries) : 0, + isDelta: isSet(object.isDelta) ? globalThis.Boolean(object.isDelta) : false, + updateBaseline: isSet(object.updateBaseline) ? globalThis.Boolean(object.updateBaseline) : false, + baseline: isSet(object.baseline) ? globalThis.Number(object.baseline) : 0, + deltaFrom: isSet(object.deltaFrom) ? globalThis.Number(object.deltaFrom) : 0, + entityData: isSet(object.entityData) ? bytesFromBase64(object.entityData) : new Uint8Array(0), + }; + }, + + toJSON(message: CSVCMsgPacketEntities): unknown { + const obj: any = {}; + if (message.maxEntries !== 0) { + obj.maxEntries = Math.round(message.maxEntries); + } + if (message.updatedEntries !== 0) { + obj.updatedEntries = Math.round(message.updatedEntries); + } + if (message.isDelta === true) { + obj.isDelta = message.isDelta; + } + if (message.updateBaseline === true) { + obj.updateBaseline = message.updateBaseline; + } + if (message.baseline !== 0) { + obj.baseline = Math.round(message.baseline); + } + if (message.deltaFrom !== 0) { + obj.deltaFrom = Math.round(message.deltaFrom); + } + if (message.entityData.length !== 0) { + obj.entityData = base64FromBytes(message.entityData); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgPacketEntities { + return CSVCMsgPacketEntities.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgPacketEntities { + const message = createBaseCSVCMsgPacketEntities(); + message.maxEntries = object.maxEntries ?? 0; + message.updatedEntries = object.updatedEntries ?? 0; + message.isDelta = object.isDelta ?? false; + message.updateBaseline = object.updateBaseline ?? false; + message.baseline = object.baseline ?? 0; + message.deltaFrom = object.deltaFrom ?? 0; + message.entityData = object.entityData ?? new Uint8Array(0); + return message; + }, +}; + +function createBaseCSVCMsgSounds(): CSVCMsgSounds { + return { reliableSound: false, sounds: [] }; +} + +export const CSVCMsgSounds = { + encode(message: CSVCMsgSounds, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.reliableSound === true) { + writer.uint32(8).bool(message.reliableSound); + } + for (const v of message.sounds) { + CSVCMsgSounds_sounddataT.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgSounds { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgSounds(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.reliableSound = reader.bool(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.sounds.push(CSVCMsgSounds_sounddataT.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgSounds { + return { + reliableSound: isSet(object.reliableSound) ? globalThis.Boolean(object.reliableSound) : false, + sounds: globalThis.Array.isArray(object?.sounds) + ? object.sounds.map((e: any) => CSVCMsgSounds_sounddataT.fromJSON(e)) + : [], + }; + }, + + toJSON(message: CSVCMsgSounds): unknown { + const obj: any = {}; + if (message.reliableSound === true) { + obj.reliableSound = message.reliableSound; + } + if (message.sounds?.length) { + obj.sounds = message.sounds.map((e) => CSVCMsgSounds_sounddataT.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgSounds { + return CSVCMsgSounds.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgSounds { + const message = createBaseCSVCMsgSounds(); + message.reliableSound = object.reliableSound ?? false; + message.sounds = object.sounds?.map((e) => CSVCMsgSounds_sounddataT.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseCSVCMsgSounds_sounddataT(): CSVCMsgSounds_sounddataT { + return { + originX: 0, + originY: 0, + originZ: 0, + volume: 0, + delayValue: 0, + sequenceNumber: 0, + entityIndex: 0, + channel: 0, + pitch: 0, + flags: 0, + soundNum: 0, + soundNumHandle: 0, + speakerEntity: 0, + randomSeed: 0, + soundLevel: 0, + isSentence: false, + isAmbient: false, + }; +} + +export const CSVCMsgSounds_sounddataT = { + encode(message: CSVCMsgSounds_sounddataT, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.originX !== 0) { + writer.uint32(8).sint32(message.originX); + } + if (message.originY !== 0) { + writer.uint32(16).sint32(message.originY); + } + if (message.originZ !== 0) { + writer.uint32(24).sint32(message.originZ); + } + if (message.volume !== 0) { + writer.uint32(32).uint32(message.volume); + } + if (message.delayValue !== 0) { + writer.uint32(45).float(message.delayValue); + } + if (message.sequenceNumber !== 0) { + writer.uint32(48).int32(message.sequenceNumber); + } + if (message.entityIndex !== 0) { + writer.uint32(56).int32(message.entityIndex); + } + if (message.channel !== 0) { + writer.uint32(64).int32(message.channel); + } + if (message.pitch !== 0) { + writer.uint32(72).int32(message.pitch); + } + if (message.flags !== 0) { + writer.uint32(80).int32(message.flags); + } + if (message.soundNum !== 0) { + writer.uint32(88).uint32(message.soundNum); + } + if (message.soundNumHandle !== 0) { + writer.uint32(101).fixed32(message.soundNumHandle); + } + if (message.speakerEntity !== 0) { + writer.uint32(104).int32(message.speakerEntity); + } + if (message.randomSeed !== 0) { + writer.uint32(112).int32(message.randomSeed); + } + if (message.soundLevel !== 0) { + writer.uint32(120).int32(message.soundLevel); + } + if (message.isSentence === true) { + writer.uint32(128).bool(message.isSentence); + } + if (message.isAmbient === true) { + writer.uint32(136).bool(message.isAmbient); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgSounds_sounddataT { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgSounds_sounddataT(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.originX = reader.sint32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.originY = reader.sint32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.originZ = reader.sint32(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.volume = reader.uint32(); + continue; + case 5: + if (tag !== 45) { + break; + } + + message.delayValue = reader.float(); + continue; + case 6: + if (tag !== 48) { + break; + } + + message.sequenceNumber = reader.int32(); + continue; + case 7: + if (tag !== 56) { + break; + } + + message.entityIndex = reader.int32(); + continue; + case 8: + if (tag !== 64) { + break; + } + + message.channel = reader.int32(); + continue; + case 9: + if (tag !== 72) { + break; + } + + message.pitch = reader.int32(); + continue; + case 10: + if (tag !== 80) { + break; + } + + message.flags = reader.int32(); + continue; + case 11: + if (tag !== 88) { + break; + } + + message.soundNum = reader.uint32(); + continue; + case 12: + if (tag !== 101) { + break; + } + + message.soundNumHandle = reader.fixed32(); + continue; + case 13: + if (tag !== 104) { + break; + } + + message.speakerEntity = reader.int32(); + continue; + case 14: + if (tag !== 112) { + break; + } + + message.randomSeed = reader.int32(); + continue; + case 15: + if (tag !== 120) { + break; + } + + message.soundLevel = reader.int32(); + continue; + case 16: + if (tag !== 128) { + break; + } + + message.isSentence = reader.bool(); + continue; + case 17: + if (tag !== 136) { + break; + } + + message.isAmbient = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgSounds_sounddataT { + return { + originX: isSet(object.originX) ? globalThis.Number(object.originX) : 0, + originY: isSet(object.originY) ? globalThis.Number(object.originY) : 0, + originZ: isSet(object.originZ) ? globalThis.Number(object.originZ) : 0, + volume: isSet(object.volume) ? globalThis.Number(object.volume) : 0, + delayValue: isSet(object.delayValue) ? globalThis.Number(object.delayValue) : 0, + sequenceNumber: isSet(object.sequenceNumber) ? globalThis.Number(object.sequenceNumber) : 0, + entityIndex: isSet(object.entityIndex) ? globalThis.Number(object.entityIndex) : 0, + channel: isSet(object.channel) ? globalThis.Number(object.channel) : 0, + pitch: isSet(object.pitch) ? globalThis.Number(object.pitch) : 0, + flags: isSet(object.flags) ? globalThis.Number(object.flags) : 0, + soundNum: isSet(object.soundNum) ? globalThis.Number(object.soundNum) : 0, + soundNumHandle: isSet(object.soundNumHandle) ? globalThis.Number(object.soundNumHandle) : 0, + speakerEntity: isSet(object.speakerEntity) ? globalThis.Number(object.speakerEntity) : 0, + randomSeed: isSet(object.randomSeed) ? globalThis.Number(object.randomSeed) : 0, + soundLevel: isSet(object.soundLevel) ? globalThis.Number(object.soundLevel) : 0, + isSentence: isSet(object.isSentence) ? globalThis.Boolean(object.isSentence) : false, + isAmbient: isSet(object.isAmbient) ? globalThis.Boolean(object.isAmbient) : false, + }; + }, + + toJSON(message: CSVCMsgSounds_sounddataT): unknown { + const obj: any = {}; + if (message.originX !== 0) { + obj.originX = Math.round(message.originX); + } + if (message.originY !== 0) { + obj.originY = Math.round(message.originY); + } + if (message.originZ !== 0) { + obj.originZ = Math.round(message.originZ); + } + if (message.volume !== 0) { + obj.volume = Math.round(message.volume); + } + if (message.delayValue !== 0) { + obj.delayValue = message.delayValue; + } + if (message.sequenceNumber !== 0) { + obj.sequenceNumber = Math.round(message.sequenceNumber); + } + if (message.entityIndex !== 0) { + obj.entityIndex = Math.round(message.entityIndex); + } + if (message.channel !== 0) { + obj.channel = Math.round(message.channel); + } + if (message.pitch !== 0) { + obj.pitch = Math.round(message.pitch); + } + if (message.flags !== 0) { + obj.flags = Math.round(message.flags); + } + if (message.soundNum !== 0) { + obj.soundNum = Math.round(message.soundNum); + } + if (message.soundNumHandle !== 0) { + obj.soundNumHandle = Math.round(message.soundNumHandle); + } + if (message.speakerEntity !== 0) { + obj.speakerEntity = Math.round(message.speakerEntity); + } + if (message.randomSeed !== 0) { + obj.randomSeed = Math.round(message.randomSeed); + } + if (message.soundLevel !== 0) { + obj.soundLevel = Math.round(message.soundLevel); + } + if (message.isSentence === true) { + obj.isSentence = message.isSentence; + } + if (message.isAmbient === true) { + obj.isAmbient = message.isAmbient; + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgSounds_sounddataT { + return CSVCMsgSounds_sounddataT.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgSounds_sounddataT { + const message = createBaseCSVCMsgSounds_sounddataT(); + message.originX = object.originX ?? 0; + message.originY = object.originY ?? 0; + message.originZ = object.originZ ?? 0; + message.volume = object.volume ?? 0; + message.delayValue = object.delayValue ?? 0; + message.sequenceNumber = object.sequenceNumber ?? 0; + message.entityIndex = object.entityIndex ?? 0; + message.channel = object.channel ?? 0; + message.pitch = object.pitch ?? 0; + message.flags = object.flags ?? 0; + message.soundNum = object.soundNum ?? 0; + message.soundNumHandle = object.soundNumHandle ?? 0; + message.speakerEntity = object.speakerEntity ?? 0; + message.randomSeed = object.randomSeed ?? 0; + message.soundLevel = object.soundLevel ?? 0; + message.isSentence = object.isSentence ?? false; + message.isAmbient = object.isAmbient ?? false; + return message; + }, +}; + +function createBaseCSVCMsgEntityMsg(): CSVCMsgEntityMsg { + return { entIndex: 0, classId: 0, entData: new Uint8Array(0) }; +} + +export const CSVCMsgEntityMsg = { + encode(message: CSVCMsgEntityMsg, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.entIndex !== 0) { + writer.uint32(8).int32(message.entIndex); + } + if (message.classId !== 0) { + writer.uint32(16).int32(message.classId); + } + if (message.entData.length !== 0) { + writer.uint32(26).bytes(message.entData); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgEntityMsg { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgEntityMsg(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.entIndex = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.classId = reader.int32(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.entData = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgEntityMsg { + return { + entIndex: isSet(object.entIndex) ? globalThis.Number(object.entIndex) : 0, + classId: isSet(object.classId) ? globalThis.Number(object.classId) : 0, + entData: isSet(object.entData) ? bytesFromBase64(object.entData) : new Uint8Array(0), + }; + }, + + toJSON(message: CSVCMsgEntityMsg): unknown { + const obj: any = {}; + if (message.entIndex !== 0) { + obj.entIndex = Math.round(message.entIndex); + } + if (message.classId !== 0) { + obj.classId = Math.round(message.classId); + } + if (message.entData.length !== 0) { + obj.entData = base64FromBytes(message.entData); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgEntityMsg { + return CSVCMsgEntityMsg.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgEntityMsg { + const message = createBaseCSVCMsgEntityMsg(); + message.entIndex = object.entIndex ?? 0; + message.classId = object.classId ?? 0; + message.entData = object.entData ?? new Uint8Array(0); + return message; + }, +}; + +function createBaseCSVCMsgCmdKeyValues(): CSVCMsgCmdKeyValues { + return { keyvalues: new Uint8Array(0) }; +} + +export const CSVCMsgCmdKeyValues = { + encode(message: CSVCMsgCmdKeyValues, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.keyvalues.length !== 0) { + writer.uint32(10).bytes(message.keyvalues); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgCmdKeyValues { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgCmdKeyValues(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.keyvalues = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgCmdKeyValues { + return { keyvalues: isSet(object.keyvalues) ? bytesFromBase64(object.keyvalues) : new Uint8Array(0) }; + }, + + toJSON(message: CSVCMsgCmdKeyValues): unknown { + const obj: any = {}; + if (message.keyvalues.length !== 0) { + obj.keyvalues = base64FromBytes(message.keyvalues); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgCmdKeyValues { + return CSVCMsgCmdKeyValues.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgCmdKeyValues { + const message = createBaseCSVCMsgCmdKeyValues(); + message.keyvalues = object.keyvalues ?? new Uint8Array(0); + return message; + }, +}; + +function createBaseCSVCMsgEncryptedData(): CSVCMsgEncryptedData { + return { encrypted: new Uint8Array(0), keyType: 0 }; +} + +export const CSVCMsgEncryptedData = { + encode(message: CSVCMsgEncryptedData, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.encrypted.length !== 0) { + writer.uint32(10).bytes(message.encrypted); + } + if (message.keyType !== 0) { + writer.uint32(16).int32(message.keyType); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgEncryptedData { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgEncryptedData(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.encrypted = reader.bytes(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.keyType = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgEncryptedData { + return { + encrypted: isSet(object.encrypted) ? bytesFromBase64(object.encrypted) : new Uint8Array(0), + keyType: isSet(object.keyType) ? globalThis.Number(object.keyType) : 0, + }; + }, + + toJSON(message: CSVCMsgEncryptedData): unknown { + const obj: any = {}; + if (message.encrypted.length !== 0) { + obj.encrypted = base64FromBytes(message.encrypted); + } + if (message.keyType !== 0) { + obj.keyType = Math.round(message.keyType); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgEncryptedData { + return CSVCMsgEncryptedData.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgEncryptedData { + const message = createBaseCSVCMsgEncryptedData(); + message.encrypted = object.encrypted ?? new Uint8Array(0); + message.keyType = object.keyType ?? 0; + return message; + }, +}; + +function createBaseCSVCMsgHltvReplay(): CSVCMsgHltvReplay { + return { + delay: 0, + primaryTarget: 0, + replayStopAt: 0, + replayStartAt: 0, + replaySlowdownBegin: 0, + replaySlowdownEnd: 0, + replaySlowdownRate: 0, + reason: 0, + }; +} + +export const CSVCMsgHltvReplay = { + encode(message: CSVCMsgHltvReplay, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.delay !== 0) { + writer.uint32(8).int32(message.delay); + } + if (message.primaryTarget !== 0) { + writer.uint32(16).int32(message.primaryTarget); + } + if (message.replayStopAt !== 0) { + writer.uint32(24).int32(message.replayStopAt); + } + if (message.replayStartAt !== 0) { + writer.uint32(32).int32(message.replayStartAt); + } + if (message.replaySlowdownBegin !== 0) { + writer.uint32(40).int32(message.replaySlowdownBegin); + } + if (message.replaySlowdownEnd !== 0) { + writer.uint32(48).int32(message.replaySlowdownEnd); + } + if (message.replaySlowdownRate !== 0) { + writer.uint32(61).float(message.replaySlowdownRate); + } + if (message.reason !== 0) { + writer.uint32(64).int32(message.reason); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgHltvReplay { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgHltvReplay(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.delay = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.primaryTarget = reader.int32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.replayStopAt = reader.int32(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.replayStartAt = reader.int32(); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.replaySlowdownBegin = reader.int32(); + continue; + case 6: + if (tag !== 48) { + break; + } + + message.replaySlowdownEnd = reader.int32(); + continue; + case 7: + if (tag !== 61) { + break; + } + + message.replaySlowdownRate = reader.float(); + continue; + case 8: + if (tag !== 64) { + break; + } + + message.reason = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgHltvReplay { + return { + delay: isSet(object.delay) ? globalThis.Number(object.delay) : 0, + primaryTarget: isSet(object.primaryTarget) ? globalThis.Number(object.primaryTarget) : 0, + replayStopAt: isSet(object.replayStopAt) ? globalThis.Number(object.replayStopAt) : 0, + replayStartAt: isSet(object.replayStartAt) ? globalThis.Number(object.replayStartAt) : 0, + replaySlowdownBegin: isSet(object.replaySlowdownBegin) ? globalThis.Number(object.replaySlowdownBegin) : 0, + replaySlowdownEnd: isSet(object.replaySlowdownEnd) ? globalThis.Number(object.replaySlowdownEnd) : 0, + replaySlowdownRate: isSet(object.replaySlowdownRate) ? globalThis.Number(object.replaySlowdownRate) : 0, + reason: isSet(object.reason) ? globalThis.Number(object.reason) : 0, + }; + }, + + toJSON(message: CSVCMsgHltvReplay): unknown { + const obj: any = {}; + if (message.delay !== 0) { + obj.delay = Math.round(message.delay); + } + if (message.primaryTarget !== 0) { + obj.primaryTarget = Math.round(message.primaryTarget); + } + if (message.replayStopAt !== 0) { + obj.replayStopAt = Math.round(message.replayStopAt); + } + if (message.replayStartAt !== 0) { + obj.replayStartAt = Math.round(message.replayStartAt); + } + if (message.replaySlowdownBegin !== 0) { + obj.replaySlowdownBegin = Math.round(message.replaySlowdownBegin); + } + if (message.replaySlowdownEnd !== 0) { + obj.replaySlowdownEnd = Math.round(message.replaySlowdownEnd); + } + if (message.replaySlowdownRate !== 0) { + obj.replaySlowdownRate = message.replaySlowdownRate; + } + if (message.reason !== 0) { + obj.reason = Math.round(message.reason); + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgHltvReplay { + return CSVCMsgHltvReplay.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgHltvReplay { + const message = createBaseCSVCMsgHltvReplay(); + message.delay = object.delay ?? 0; + message.primaryTarget = object.primaryTarget ?? 0; + message.replayStopAt = object.replayStopAt ?? 0; + message.replayStartAt = object.replayStartAt ?? 0; + message.replaySlowdownBegin = object.replaySlowdownBegin ?? 0; + message.replaySlowdownEnd = object.replaySlowdownEnd ?? 0; + message.replaySlowdownRate = object.replaySlowdownRate ?? 0; + message.reason = object.reason ?? 0; + return message; + }, +}; + +function createBaseCCLCMsgHltvReplay(): CCLCMsgHltvReplay { + return { request: 0, slowdownLength: 0, slowdownRate: 0, primaryTargetEntIndex: 0, eventTime: 0 }; +} + +export const CCLCMsgHltvReplay = { + encode(message: CCLCMsgHltvReplay, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.request !== 0) { + writer.uint32(8).int32(message.request); + } + if (message.slowdownLength !== 0) { + writer.uint32(21).float(message.slowdownLength); + } + if (message.slowdownRate !== 0) { + writer.uint32(29).float(message.slowdownRate); + } + if (message.primaryTargetEntIndex !== 0) { + writer.uint32(32).int32(message.primaryTargetEntIndex); + } + if (message.eventTime !== 0) { + writer.uint32(45).float(message.eventTime); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CCLCMsgHltvReplay { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCCLCMsgHltvReplay(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.request = reader.int32(); + continue; + case 2: + if (tag !== 21) { + break; + } + + message.slowdownLength = reader.float(); + continue; + case 3: + if (tag !== 29) { + break; + } + + message.slowdownRate = reader.float(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.primaryTargetEntIndex = reader.int32(); + continue; + case 5: + if (tag !== 45) { + break; + } + + message.eventTime = reader.float(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CCLCMsgHltvReplay { + return { + request: isSet(object.request) ? globalThis.Number(object.request) : 0, + slowdownLength: isSet(object.slowdownLength) ? globalThis.Number(object.slowdownLength) : 0, + slowdownRate: isSet(object.slowdownRate) ? globalThis.Number(object.slowdownRate) : 0, + primaryTargetEntIndex: isSet(object.primaryTargetEntIndex) + ? globalThis.Number(object.primaryTargetEntIndex) + : 0, + eventTime: isSet(object.eventTime) ? globalThis.Number(object.eventTime) : 0, + }; + }, + + toJSON(message: CCLCMsgHltvReplay): unknown { + const obj: any = {}; + if (message.request !== 0) { + obj.request = Math.round(message.request); + } + if (message.slowdownLength !== 0) { + obj.slowdownLength = message.slowdownLength; + } + if (message.slowdownRate !== 0) { + obj.slowdownRate = message.slowdownRate; + } + if (message.primaryTargetEntIndex !== 0) { + obj.primaryTargetEntIndex = Math.round(message.primaryTargetEntIndex); + } + if (message.eventTime !== 0) { + obj.eventTime = message.eventTime; + } + return obj; + }, + + create, I>>(base?: I): CCLCMsgHltvReplay { + return CCLCMsgHltvReplay.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CCLCMsgHltvReplay { + const message = createBaseCCLCMsgHltvReplay(); + message.request = object.request ?? 0; + message.slowdownLength = object.slowdownLength ?? 0; + message.slowdownRate = object.slowdownRate ?? 0; + message.primaryTargetEntIndex = object.primaryTargetEntIndex ?? 0; + message.eventTime = object.eventTime ?? 0; + return message; + }, +}; + +function createBaseCSVCMsgBroadcastCommand(): CSVCMsgBroadcastCommand { + return { cmd: '' }; +} + +export const CSVCMsgBroadcastCommand = { + encode(message: CSVCMsgBroadcastCommand, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.cmd !== '') { + writer.uint32(10).string(message.cmd); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgBroadcastCommand { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgBroadcastCommand(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.cmd = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgBroadcastCommand { + return { cmd: isSet(object.cmd) ? globalThis.String(object.cmd) : '' }; + }, + + toJSON(message: CSVCMsgBroadcastCommand): unknown { + const obj: any = {}; + if (message.cmd !== '') { + obj.cmd = message.cmd; + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgBroadcastCommand { + return CSVCMsgBroadcastCommand.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CSVCMsgBroadcastCommand { + const message = createBaseCSVCMsgBroadcastCommand(); + message.cmd = object.cmd ?? ''; + return message; + }, +}; + +function createBaseCCLCMsgHltvFixupOperatorTick(): CCLCMsgHltvFixupOperatorTick { + return { + tick: 0, + propsData: new Uint8Array(0), + origin: undefined, + eyeAngles: undefined, + observerMode: 0, + cameramanScoreboard: false, + observerTarget: 0, + viewOffset: undefined, + }; +} + +export const CCLCMsgHltvFixupOperatorTick = { + encode(message: CCLCMsgHltvFixupOperatorTick, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.tick !== 0) { + writer.uint32(8).int32(message.tick); + } + if (message.propsData.length !== 0) { + writer.uint32(18).bytes(message.propsData); + } + if (message.origin !== undefined) { + CMsgVector.encode(message.origin, writer.uint32(26).fork()).ldelim(); + } + if (message.eyeAngles !== undefined) { + CMsgQAngle.encode(message.eyeAngles, writer.uint32(34).fork()).ldelim(); + } + if (message.observerMode !== 0) { + writer.uint32(40).int32(message.observerMode); + } + if (message.cameramanScoreboard === true) { + writer.uint32(48).bool(message.cameramanScoreboard); + } + if (message.observerTarget !== 0) { + writer.uint32(56).int32(message.observerTarget); + } + if (message.viewOffset !== undefined) { + CMsgVector.encode(message.viewOffset, writer.uint32(66).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CCLCMsgHltvFixupOperatorTick { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCCLCMsgHltvFixupOperatorTick(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.tick = reader.int32(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.propsData = reader.bytes(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.origin = CMsgVector.decode(reader, reader.uint32()); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.eyeAngles = CMsgQAngle.decode(reader, reader.uint32()); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.observerMode = reader.int32(); + continue; + case 6: + if (tag !== 48) { + break; + } + + message.cameramanScoreboard = reader.bool(); + continue; + case 7: + if (tag !== 56) { + break; + } + + message.observerTarget = reader.int32(); + continue; + case 8: + if (tag !== 66) { + break; + } + + message.viewOffset = CMsgVector.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CCLCMsgHltvFixupOperatorTick { + return { + tick: isSet(object.tick) ? globalThis.Number(object.tick) : 0, + propsData: isSet(object.propsData) ? bytesFromBase64(object.propsData) : new Uint8Array(0), + origin: isSet(object.origin) ? CMsgVector.fromJSON(object.origin) : undefined, + eyeAngles: isSet(object.eyeAngles) ? CMsgQAngle.fromJSON(object.eyeAngles) : undefined, + observerMode: isSet(object.observerMode) ? globalThis.Number(object.observerMode) : 0, + cameramanScoreboard: isSet(object.cameramanScoreboard) + ? globalThis.Boolean(object.cameramanScoreboard) + : false, + observerTarget: isSet(object.observerTarget) ? globalThis.Number(object.observerTarget) : 0, + viewOffset: isSet(object.viewOffset) ? CMsgVector.fromJSON(object.viewOffset) : undefined, + }; + }, + + toJSON(message: CCLCMsgHltvFixupOperatorTick): unknown { + const obj: any = {}; + if (message.tick !== 0) { + obj.tick = Math.round(message.tick); + } + if (message.propsData.length !== 0) { + obj.propsData = base64FromBytes(message.propsData); + } + if (message.origin !== undefined) { + obj.origin = CMsgVector.toJSON(message.origin); + } + if (message.eyeAngles !== undefined) { + obj.eyeAngles = CMsgQAngle.toJSON(message.eyeAngles); + } + if (message.observerMode !== 0) { + obj.observerMode = Math.round(message.observerMode); + } + if (message.cameramanScoreboard === true) { + obj.cameramanScoreboard = message.cameramanScoreboard; + } + if (message.observerTarget !== 0) { + obj.observerTarget = Math.round(message.observerTarget); + } + if (message.viewOffset !== undefined) { + obj.viewOffset = CMsgVector.toJSON(message.viewOffset); + } + return obj; + }, + + create, I>>(base?: I): CCLCMsgHltvFixupOperatorTick { + return CCLCMsgHltvFixupOperatorTick.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): CCLCMsgHltvFixupOperatorTick { + const message = createBaseCCLCMsgHltvFixupOperatorTick(); + message.tick = object.tick ?? 0; + message.propsData = object.propsData ?? new Uint8Array(0); + message.origin = (object.origin !== undefined && object.origin !== null) + ? CMsgVector.fromPartial(object.origin) + : undefined; + message.eyeAngles = (object.eyeAngles !== undefined && object.eyeAngles !== null) + ? CMsgQAngle.fromPartial(object.eyeAngles) + : undefined; + message.observerMode = object.observerMode ?? 0; + message.cameramanScoreboard = object.cameramanScoreboard ?? false; + message.observerTarget = object.observerTarget ?? 0; + message.viewOffset = (object.viewOffset !== undefined && object.viewOffset !== null) + ? CMsgVector.fromPartial(object.viewOffset) + : undefined; + return message; + }, +}; + +function createBaseCSVCMsgHltvFixupOperatorStatus(): CSVCMsgHltvFixupOperatorStatus { + return { mode: 0, overrideOperatorName: '' }; +} + +export const CSVCMsgHltvFixupOperatorStatus = { + encode(message: CSVCMsgHltvFixupOperatorStatus, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.mode !== 0) { + writer.uint32(8).uint32(message.mode); + } + if (message.overrideOperatorName !== '') { + writer.uint32(18).string(message.overrideOperatorName); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CSVCMsgHltvFixupOperatorStatus { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCSVCMsgHltvFixupOperatorStatus(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.mode = reader.uint32(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.overrideOperatorName = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CSVCMsgHltvFixupOperatorStatus { + return { + mode: isSet(object.mode) ? globalThis.Number(object.mode) : 0, + overrideOperatorName: isSet(object.overrideOperatorName) + ? globalThis.String(object.overrideOperatorName) + : '', + }; + }, + + toJSON(message: CSVCMsgHltvFixupOperatorStatus): unknown { + const obj: any = {}; + if (message.mode !== 0) { + obj.mode = Math.round(message.mode); + } + if (message.overrideOperatorName !== '') { + obj.overrideOperatorName = message.overrideOperatorName; + } + return obj; + }, + + create, I>>(base?: I): CSVCMsgHltvFixupOperatorStatus { + return CSVCMsgHltvFixupOperatorStatus.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): CSVCMsgHltvFixupOperatorStatus { + const message = createBaseCSVCMsgHltvFixupOperatorStatus(); + message.mode = object.mode ?? 0; + message.overrideOperatorName = object.overrideOperatorName ?? ''; + return message; + }, +}; + +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + arr.forEach((byte) => { + bin.push(globalThis.String.fromCharCode(byte)); + }); + return globalThis.btoa(bin.join('')); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function longToNumber(long: Long): number { + if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + } + return long.toNumber(); +} + +if (pb.util.Long !== Long) { + pb.util.Long = Long as any; + pb.configure(); +} + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/examples/custom/p2ce/network_connection.ts b/examples/custom/p2ce/network_connection.ts new file mode 100644 index 0000000..c8c5335 --- /dev/null +++ b/examples/custom/p2ce/network_connection.ts @@ -0,0 +1,472 @@ +export const protobufPackage = ''; + +export enum ENetworkDisconnectionReason { + NETWORK_DISCONNECT_INVALID = 0, + NETWORK_DISCONNECT_SHUTDOWN = 1, + NETWORK_DISCONNECT_DISCONNECT_BY_USER = 2, + NETWORK_DISCONNECT_DISCONNECT_BY_SERVER = 3, + NETWORK_DISCONNECT_LOST = 4, + NETWORK_DISCONNECT_OVERFLOW = 5, + NETWORK_DISCONNECT_STEAM_BANNED = 6, + NETWORK_DISCONNECT_STEAM_INUSE = 7, + NETWORK_DISCONNECT_STEAM_TICKET = 8, + NETWORK_DISCONNECT_STEAM_LOGON = 9, + NETWORK_DISCONNECT_STEAM_AUTHCANCELLED = 10, + NETWORK_DISCONNECT_STEAM_AUTHALREADYUSED = 11, + NETWORK_DISCONNECT_STEAM_AUTHINVALID = 12, + NETWORK_DISCONNECT_STEAM_VACBANSTATE = 13, + NETWORK_DISCONNECT_STEAM_LOGGED_IN_ELSEWHERE = 14, + NETWORK_DISCONNECT_STEAM_VAC_CHECK_TIMEDOUT = 15, + NETWORK_DISCONNECT_STEAM_DROPPED = 16, + NETWORK_DISCONNECT_STEAM_OWNERSHIP = 17, + NETWORK_DISCONNECT_SERVERINFO_OVERFLOW = 18, + NETWORK_DISCONNECT_TICKMSG_OVERFLOW = 19, + NETWORK_DISCONNECT_STRINGTABLEMSG_OVERFLOW = 20, + NETWORK_DISCONNECT_DELTAENTMSG_OVERFLOW = 21, + NETWORK_DISCONNECT_TEMPENTMSG_OVERFLOW = 22, + NETWORK_DISCONNECT_SOUNDSMSG_OVERFLOW = 23, + NETWORK_DISCONNECT_SNAPSHOTOVERFLOW = 24, + NETWORK_DISCONNECT_SNAPSHOTERROR = 25, + NETWORK_DISCONNECT_RELIABLEOVERFLOW = 26, + NETWORK_DISCONNECT_BADDELTATICK = 27, + NETWORK_DISCONNECT_NOMORESPLITS = 28, + NETWORK_DISCONNECT_TIMEDOUT = 29, + NETWORK_DISCONNECT_DISCONNECTED = 30, + NETWORK_DISCONNECT_LEAVINGSPLIT = 31, + NETWORK_DISCONNECT_DIFFERENTCLASSTABLES = 32, + NETWORK_DISCONNECT_BADRELAYPASSWORD = 33, + NETWORK_DISCONNECT_BADSPECTATORPASSWORD = 34, + NETWORK_DISCONNECT_HLTVRESTRICTED = 35, + NETWORK_DISCONNECT_NOSPECTATORS = 36, + NETWORK_DISCONNECT_HLTVUNAVAILABLE = 37, + NETWORK_DISCONNECT_HLTVSTOP = 38, + NETWORK_DISCONNECT_KICKED = 39, + NETWORK_DISCONNECT_BANADDED = 40, + NETWORK_DISCONNECT_KICKBANADDED = 41, + NETWORK_DISCONNECT_HLTVDIRECT = 42, + NETWORK_DISCONNECT_PURESERVER_CLIENTEXTRA = 43, + NETWORK_DISCONNECT_PURESERVER_MISMATCH = 44, + NETWORK_DISCONNECT_USERCMD = 45, + NETWORK_DISCONNECT_REJECTED_BY_GAME = 46, + NETWORK_DISCONNECT_MESSAGE_PARSE_ERROR = 47, + NETWORK_DISCONNECT_INVALID_MESSAGE_ERROR = 48, + NETWORK_DISCONNECT_BAD_SERVER_PASSWORD = 49, + NETWORK_DISCONNECT_DIRECT_CONNECT_RESERVATION = 50, + NETWORK_DISCONNECT_CONNECTION_FAILURE = 51, + NETWORK_DISCONNECT_NO_PEER_GROUP_HANDLERS = 52, + NETWORK_DISCONNECT_RECONNECTION = 53, + NETWORK_DISCONNECT_CONNECTION_CLOSING = 54, + NETWORK_DISCONNECT_NO_GOTV_RELAYS_AVAILABLE = 55, + NETWORK_DISCONNECT_SESSION_MIGRATED = 56, + NETWORK_DISCONNECT_VERYLARGETRANSFEROVERFLOW = 57, + NETWORK_DISCONNECT_SENDNETOVERFLOW = 58, + NETWORK_DISCONNECT_PLAYER_REMOVED_FROM_HOST_SESSION = 59, + NETWORK_DISCONNECT_SERVER_DOS = 61, + NETWORK_DISCONNECT_SNS_LOCAL_MANYRELAYS = 62, + NETWORK_DISCONNECT_SNS_LOCAL_HOSTEDSERVERPRIMARYRELAY = 63, + NETWORK_DISCONNECT_SNS_LOCAL_NETWORKCONFIG = 64, + NETWORK_DISCONNECT_SNS_LOCAL_OTHER = 65, + NETWORK_DISCONNECT_SNS_REMOTE_TIMEOUTCONNECTING = 66, + NETWORK_DISCONNECT_SNS_REMOTE_TIMEOUT = 67, + NETWORK_DISCONNECT_SNS_REMOTE_BADCRYPT = 68, + NETWORK_DISCONNECT_SNS_REMOTE_BADCERT = 69, + NETWORK_DISCONNECT_SNS_CLOSEDBYPEER_TIMEOUT = 70, + NETWORK_DISCONNECT_SNS_CLOSEDBYPEER_OTHER = 71, + NETWORK_DISCONNECT_SNS_CONNECTION_TIMEOUT = 72, + NETWORK_DISCONNECT_SNS_CONNECTION_LOST = 73, + NETWORK_DISCONNECT_SNS_INTERNALERROR = 74, + NETWORK_DISCONNECT_SNS_UNUSUAL = 75, + UNRECOGNIZED = -1, +} + +export function eNetworkDisconnectionReasonFromJSON(object: any): ENetworkDisconnectionReason { + switch (object) { + case 0: + case 'NETWORK_DISCONNECT_INVALID': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_INVALID; + case 1: + case 'NETWORK_DISCONNECT_SHUTDOWN': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SHUTDOWN; + case 2: + case 'NETWORK_DISCONNECT_DISCONNECT_BY_USER': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_DISCONNECT_BY_USER; + case 3: + case 'NETWORK_DISCONNECT_DISCONNECT_BY_SERVER': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_DISCONNECT_BY_SERVER; + case 4: + case 'NETWORK_DISCONNECT_LOST': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_LOST; + case 5: + case 'NETWORK_DISCONNECT_OVERFLOW': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_OVERFLOW; + case 6: + case 'NETWORK_DISCONNECT_STEAM_BANNED': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_BANNED; + case 7: + case 'NETWORK_DISCONNECT_STEAM_INUSE': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_INUSE; + case 8: + case 'NETWORK_DISCONNECT_STEAM_TICKET': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_TICKET; + case 9: + case 'NETWORK_DISCONNECT_STEAM_LOGON': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_LOGON; + case 10: + case 'NETWORK_DISCONNECT_STEAM_AUTHCANCELLED': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_AUTHCANCELLED; + case 11: + case 'NETWORK_DISCONNECT_STEAM_AUTHALREADYUSED': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_AUTHALREADYUSED; + case 12: + case 'NETWORK_DISCONNECT_STEAM_AUTHINVALID': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_AUTHINVALID; + case 13: + case 'NETWORK_DISCONNECT_STEAM_VACBANSTATE': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_VACBANSTATE; + case 14: + case 'NETWORK_DISCONNECT_STEAM_LOGGED_IN_ELSEWHERE': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_LOGGED_IN_ELSEWHERE; + case 15: + case 'NETWORK_DISCONNECT_STEAM_VAC_CHECK_TIMEDOUT': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_VAC_CHECK_TIMEDOUT; + case 16: + case 'NETWORK_DISCONNECT_STEAM_DROPPED': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_DROPPED; + case 17: + case 'NETWORK_DISCONNECT_STEAM_OWNERSHIP': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_OWNERSHIP; + case 18: + case 'NETWORK_DISCONNECT_SERVERINFO_OVERFLOW': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SERVERINFO_OVERFLOW; + case 19: + case 'NETWORK_DISCONNECT_TICKMSG_OVERFLOW': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_TICKMSG_OVERFLOW; + case 20: + case 'NETWORK_DISCONNECT_STRINGTABLEMSG_OVERFLOW': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_STRINGTABLEMSG_OVERFLOW; + case 21: + case 'NETWORK_DISCONNECT_DELTAENTMSG_OVERFLOW': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_DELTAENTMSG_OVERFLOW; + case 22: + case 'NETWORK_DISCONNECT_TEMPENTMSG_OVERFLOW': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_TEMPENTMSG_OVERFLOW; + case 23: + case 'NETWORK_DISCONNECT_SOUNDSMSG_OVERFLOW': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SOUNDSMSG_OVERFLOW; + case 24: + case 'NETWORK_DISCONNECT_SNAPSHOTOVERFLOW': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNAPSHOTOVERFLOW; + case 25: + case 'NETWORK_DISCONNECT_SNAPSHOTERROR': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNAPSHOTERROR; + case 26: + case 'NETWORK_DISCONNECT_RELIABLEOVERFLOW': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_RELIABLEOVERFLOW; + case 27: + case 'NETWORK_DISCONNECT_BADDELTATICK': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_BADDELTATICK; + case 28: + case 'NETWORK_DISCONNECT_NOMORESPLITS': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_NOMORESPLITS; + case 29: + case 'NETWORK_DISCONNECT_TIMEDOUT': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_TIMEDOUT; + case 30: + case 'NETWORK_DISCONNECT_DISCONNECTED': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_DISCONNECTED; + case 31: + case 'NETWORK_DISCONNECT_LEAVINGSPLIT': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_LEAVINGSPLIT; + case 32: + case 'NETWORK_DISCONNECT_DIFFERENTCLASSTABLES': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_DIFFERENTCLASSTABLES; + case 33: + case 'NETWORK_DISCONNECT_BADRELAYPASSWORD': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_BADRELAYPASSWORD; + case 34: + case 'NETWORK_DISCONNECT_BADSPECTATORPASSWORD': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_BADSPECTATORPASSWORD; + case 35: + case 'NETWORK_DISCONNECT_HLTVRESTRICTED': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_HLTVRESTRICTED; + case 36: + case 'NETWORK_DISCONNECT_NOSPECTATORS': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_NOSPECTATORS; + case 37: + case 'NETWORK_DISCONNECT_HLTVUNAVAILABLE': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_HLTVUNAVAILABLE; + case 38: + case 'NETWORK_DISCONNECT_HLTVSTOP': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_HLTVSTOP; + case 39: + case 'NETWORK_DISCONNECT_KICKED': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_KICKED; + case 40: + case 'NETWORK_DISCONNECT_BANADDED': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_BANADDED; + case 41: + case 'NETWORK_DISCONNECT_KICKBANADDED': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_KICKBANADDED; + case 42: + case 'NETWORK_DISCONNECT_HLTVDIRECT': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_HLTVDIRECT; + case 43: + case 'NETWORK_DISCONNECT_PURESERVER_CLIENTEXTRA': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_PURESERVER_CLIENTEXTRA; + case 44: + case 'NETWORK_DISCONNECT_PURESERVER_MISMATCH': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_PURESERVER_MISMATCH; + case 45: + case 'NETWORK_DISCONNECT_USERCMD': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_USERCMD; + case 46: + case 'NETWORK_DISCONNECT_REJECTED_BY_GAME': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_REJECTED_BY_GAME; + case 47: + case 'NETWORK_DISCONNECT_MESSAGE_PARSE_ERROR': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_MESSAGE_PARSE_ERROR; + case 48: + case 'NETWORK_DISCONNECT_INVALID_MESSAGE_ERROR': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_INVALID_MESSAGE_ERROR; + case 49: + case 'NETWORK_DISCONNECT_BAD_SERVER_PASSWORD': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_BAD_SERVER_PASSWORD; + case 50: + case 'NETWORK_DISCONNECT_DIRECT_CONNECT_RESERVATION': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_DIRECT_CONNECT_RESERVATION; + case 51: + case 'NETWORK_DISCONNECT_CONNECTION_FAILURE': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_CONNECTION_FAILURE; + case 52: + case 'NETWORK_DISCONNECT_NO_PEER_GROUP_HANDLERS': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_NO_PEER_GROUP_HANDLERS; + case 53: + case 'NETWORK_DISCONNECT_RECONNECTION': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_RECONNECTION; + case 54: + case 'NETWORK_DISCONNECT_CONNECTION_CLOSING': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_CONNECTION_CLOSING; + case 55: + case 'NETWORK_DISCONNECT_NO_GOTV_RELAYS_AVAILABLE': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_NO_GOTV_RELAYS_AVAILABLE; + case 56: + case 'NETWORK_DISCONNECT_SESSION_MIGRATED': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SESSION_MIGRATED; + case 57: + case 'NETWORK_DISCONNECT_VERYLARGETRANSFEROVERFLOW': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_VERYLARGETRANSFEROVERFLOW; + case 58: + case 'NETWORK_DISCONNECT_SENDNETOVERFLOW': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SENDNETOVERFLOW; + case 59: + case 'NETWORK_DISCONNECT_PLAYER_REMOVED_FROM_HOST_SESSION': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_PLAYER_REMOVED_FROM_HOST_SESSION; + case 61: + case 'NETWORK_DISCONNECT_SERVER_DOS': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SERVER_DOS; + case 62: + case 'NETWORK_DISCONNECT_SNS_LOCAL_MANYRELAYS': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_LOCAL_MANYRELAYS; + case 63: + case 'NETWORK_DISCONNECT_SNS_LOCAL_HOSTEDSERVERPRIMARYRELAY': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_LOCAL_HOSTEDSERVERPRIMARYRELAY; + case 64: + case 'NETWORK_DISCONNECT_SNS_LOCAL_NETWORKCONFIG': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_LOCAL_NETWORKCONFIG; + case 65: + case 'NETWORK_DISCONNECT_SNS_LOCAL_OTHER': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_LOCAL_OTHER; + case 66: + case 'NETWORK_DISCONNECT_SNS_REMOTE_TIMEOUTCONNECTING': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_REMOTE_TIMEOUTCONNECTING; + case 67: + case 'NETWORK_DISCONNECT_SNS_REMOTE_TIMEOUT': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_REMOTE_TIMEOUT; + case 68: + case 'NETWORK_DISCONNECT_SNS_REMOTE_BADCRYPT': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_REMOTE_BADCRYPT; + case 69: + case 'NETWORK_DISCONNECT_SNS_REMOTE_BADCERT': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_REMOTE_BADCERT; + case 70: + case 'NETWORK_DISCONNECT_SNS_CLOSEDBYPEER_TIMEOUT': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_CLOSEDBYPEER_TIMEOUT; + case 71: + case 'NETWORK_DISCONNECT_SNS_CLOSEDBYPEER_OTHER': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_CLOSEDBYPEER_OTHER; + case 72: + case 'NETWORK_DISCONNECT_SNS_CONNECTION_TIMEOUT': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_CONNECTION_TIMEOUT; + case 73: + case 'NETWORK_DISCONNECT_SNS_CONNECTION_LOST': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_CONNECTION_LOST; + case 74: + case 'NETWORK_DISCONNECT_SNS_INTERNALERROR': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_INTERNALERROR; + case 75: + case 'NETWORK_DISCONNECT_SNS_UNUSUAL': + return ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_UNUSUAL; + case -1: + case 'UNRECOGNIZED': + default: + return ENetworkDisconnectionReason.UNRECOGNIZED; + } +} + +export function eNetworkDisconnectionReasonToJSON(object: ENetworkDisconnectionReason): string { + switch (object) { + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_INVALID: + return 'NETWORK_DISCONNECT_INVALID'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SHUTDOWN: + return 'NETWORK_DISCONNECT_SHUTDOWN'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_DISCONNECT_BY_USER: + return 'NETWORK_DISCONNECT_DISCONNECT_BY_USER'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_DISCONNECT_BY_SERVER: + return 'NETWORK_DISCONNECT_DISCONNECT_BY_SERVER'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_LOST: + return 'NETWORK_DISCONNECT_LOST'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_OVERFLOW: + return 'NETWORK_DISCONNECT_OVERFLOW'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_BANNED: + return 'NETWORK_DISCONNECT_STEAM_BANNED'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_INUSE: + return 'NETWORK_DISCONNECT_STEAM_INUSE'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_TICKET: + return 'NETWORK_DISCONNECT_STEAM_TICKET'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_LOGON: + return 'NETWORK_DISCONNECT_STEAM_LOGON'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_AUTHCANCELLED: + return 'NETWORK_DISCONNECT_STEAM_AUTHCANCELLED'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_AUTHALREADYUSED: + return 'NETWORK_DISCONNECT_STEAM_AUTHALREADYUSED'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_AUTHINVALID: + return 'NETWORK_DISCONNECT_STEAM_AUTHINVALID'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_VACBANSTATE: + return 'NETWORK_DISCONNECT_STEAM_VACBANSTATE'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_LOGGED_IN_ELSEWHERE: + return 'NETWORK_DISCONNECT_STEAM_LOGGED_IN_ELSEWHERE'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_VAC_CHECK_TIMEDOUT: + return 'NETWORK_DISCONNECT_STEAM_VAC_CHECK_TIMEDOUT'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_DROPPED: + return 'NETWORK_DISCONNECT_STEAM_DROPPED'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_STEAM_OWNERSHIP: + return 'NETWORK_DISCONNECT_STEAM_OWNERSHIP'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SERVERINFO_OVERFLOW: + return 'NETWORK_DISCONNECT_SERVERINFO_OVERFLOW'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_TICKMSG_OVERFLOW: + return 'NETWORK_DISCONNECT_TICKMSG_OVERFLOW'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_STRINGTABLEMSG_OVERFLOW: + return 'NETWORK_DISCONNECT_STRINGTABLEMSG_OVERFLOW'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_DELTAENTMSG_OVERFLOW: + return 'NETWORK_DISCONNECT_DELTAENTMSG_OVERFLOW'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_TEMPENTMSG_OVERFLOW: + return 'NETWORK_DISCONNECT_TEMPENTMSG_OVERFLOW'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SOUNDSMSG_OVERFLOW: + return 'NETWORK_DISCONNECT_SOUNDSMSG_OVERFLOW'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNAPSHOTOVERFLOW: + return 'NETWORK_DISCONNECT_SNAPSHOTOVERFLOW'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNAPSHOTERROR: + return 'NETWORK_DISCONNECT_SNAPSHOTERROR'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_RELIABLEOVERFLOW: + return 'NETWORK_DISCONNECT_RELIABLEOVERFLOW'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_BADDELTATICK: + return 'NETWORK_DISCONNECT_BADDELTATICK'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_NOMORESPLITS: + return 'NETWORK_DISCONNECT_NOMORESPLITS'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_TIMEDOUT: + return 'NETWORK_DISCONNECT_TIMEDOUT'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_DISCONNECTED: + return 'NETWORK_DISCONNECT_DISCONNECTED'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_LEAVINGSPLIT: + return 'NETWORK_DISCONNECT_LEAVINGSPLIT'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_DIFFERENTCLASSTABLES: + return 'NETWORK_DISCONNECT_DIFFERENTCLASSTABLES'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_BADRELAYPASSWORD: + return 'NETWORK_DISCONNECT_BADRELAYPASSWORD'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_BADSPECTATORPASSWORD: + return 'NETWORK_DISCONNECT_BADSPECTATORPASSWORD'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_HLTVRESTRICTED: + return 'NETWORK_DISCONNECT_HLTVRESTRICTED'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_NOSPECTATORS: + return 'NETWORK_DISCONNECT_NOSPECTATORS'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_HLTVUNAVAILABLE: + return 'NETWORK_DISCONNECT_HLTVUNAVAILABLE'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_HLTVSTOP: + return 'NETWORK_DISCONNECT_HLTVSTOP'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_KICKED: + return 'NETWORK_DISCONNECT_KICKED'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_BANADDED: + return 'NETWORK_DISCONNECT_BANADDED'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_KICKBANADDED: + return 'NETWORK_DISCONNECT_KICKBANADDED'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_HLTVDIRECT: + return 'NETWORK_DISCONNECT_HLTVDIRECT'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_PURESERVER_CLIENTEXTRA: + return 'NETWORK_DISCONNECT_PURESERVER_CLIENTEXTRA'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_PURESERVER_MISMATCH: + return 'NETWORK_DISCONNECT_PURESERVER_MISMATCH'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_USERCMD: + return 'NETWORK_DISCONNECT_USERCMD'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_REJECTED_BY_GAME: + return 'NETWORK_DISCONNECT_REJECTED_BY_GAME'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_MESSAGE_PARSE_ERROR: + return 'NETWORK_DISCONNECT_MESSAGE_PARSE_ERROR'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_INVALID_MESSAGE_ERROR: + return 'NETWORK_DISCONNECT_INVALID_MESSAGE_ERROR'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_BAD_SERVER_PASSWORD: + return 'NETWORK_DISCONNECT_BAD_SERVER_PASSWORD'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_DIRECT_CONNECT_RESERVATION: + return 'NETWORK_DISCONNECT_DIRECT_CONNECT_RESERVATION'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_CONNECTION_FAILURE: + return 'NETWORK_DISCONNECT_CONNECTION_FAILURE'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_NO_PEER_GROUP_HANDLERS: + return 'NETWORK_DISCONNECT_NO_PEER_GROUP_HANDLERS'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_RECONNECTION: + return 'NETWORK_DISCONNECT_RECONNECTION'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_CONNECTION_CLOSING: + return 'NETWORK_DISCONNECT_CONNECTION_CLOSING'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_NO_GOTV_RELAYS_AVAILABLE: + return 'NETWORK_DISCONNECT_NO_GOTV_RELAYS_AVAILABLE'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SESSION_MIGRATED: + return 'NETWORK_DISCONNECT_SESSION_MIGRATED'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_VERYLARGETRANSFEROVERFLOW: + return 'NETWORK_DISCONNECT_VERYLARGETRANSFEROVERFLOW'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SENDNETOVERFLOW: + return 'NETWORK_DISCONNECT_SENDNETOVERFLOW'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_PLAYER_REMOVED_FROM_HOST_SESSION: + return 'NETWORK_DISCONNECT_PLAYER_REMOVED_FROM_HOST_SESSION'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SERVER_DOS: + return 'NETWORK_DISCONNECT_SERVER_DOS'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_LOCAL_MANYRELAYS: + return 'NETWORK_DISCONNECT_SNS_LOCAL_MANYRELAYS'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_LOCAL_HOSTEDSERVERPRIMARYRELAY: + return 'NETWORK_DISCONNECT_SNS_LOCAL_HOSTEDSERVERPRIMARYRELAY'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_LOCAL_NETWORKCONFIG: + return 'NETWORK_DISCONNECT_SNS_LOCAL_NETWORKCONFIG'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_LOCAL_OTHER: + return 'NETWORK_DISCONNECT_SNS_LOCAL_OTHER'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_REMOTE_TIMEOUTCONNECTING: + return 'NETWORK_DISCONNECT_SNS_REMOTE_TIMEOUTCONNECTING'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_REMOTE_TIMEOUT: + return 'NETWORK_DISCONNECT_SNS_REMOTE_TIMEOUT'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_REMOTE_BADCRYPT: + return 'NETWORK_DISCONNECT_SNS_REMOTE_BADCRYPT'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_REMOTE_BADCERT: + return 'NETWORK_DISCONNECT_SNS_REMOTE_BADCERT'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_CLOSEDBYPEER_TIMEOUT: + return 'NETWORK_DISCONNECT_SNS_CLOSEDBYPEER_TIMEOUT'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_CLOSEDBYPEER_OTHER: + return 'NETWORK_DISCONNECT_SNS_CLOSEDBYPEER_OTHER'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_CONNECTION_TIMEOUT: + return 'NETWORK_DISCONNECT_SNS_CONNECTION_TIMEOUT'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_CONNECTION_LOST: + return 'NETWORK_DISCONNECT_SNS_CONNECTION_LOST'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_INTERNALERROR: + return 'NETWORK_DISCONNECT_SNS_INTERNALERROR'; + case ENetworkDisconnectionReason.NETWORK_DISCONNECT_SNS_UNUSUAL: + return 'NETWORK_DISCONNECT_SNS_UNUSUAL'; + case ENetworkDisconnectionReason.UNRECOGNIZED: + default: + return 'UNRECOGNIZED'; + } +} diff --git a/examples/custom/p2ce/p2ce_usermessages.ts b/examples/custom/p2ce/p2ce_usermessages.ts new file mode 100644 index 0000000..ef8ddbc --- /dev/null +++ b/examples/custom/p2ce/p2ce_usermessages.ts @@ -0,0 +1,2569 @@ +import pb from 'npm:protobufjs/minimal.js'; +import Long from 'npm:long'; +import { CMsgQAngle, CMsgVector } from './netmessages.ts'; + +export const protobufPackage = ''; + +export enum EP2CEUserMessages { + UM_CreditsPortalMsg = 200, + UM_ControlHelperAnimate = 203, + UM_HudPingIndicator = 206, + UM_OpenRadialMenu = 207, + UM_AddLocator = 208, + UM_MPMapCompleted = 209, + UM_MPMapIncomplete = 210, + UM_MPMapCompletedData = 211, + UM_MPTauntEarned = 212, + UM_MPTauntUnlocked = 213, + UM_MPTauntLocked = 214, + UM_MPAllTauntsLocked = 215, + UM_PortalFX_Surface = 216, + UM_PaintWorld = 217, + UM_PaintEntity = 218, + UM_ChangePaintColor = 219, + UM_PaintBombExplode = 220, + UM_RemoveAllPaint = 221, + UM_PaintAllSurfaces = 222, + UM_RemovePaint = 223, + UM_ApplyHitBoxDamageEffect = 225, + UM_SetMixLayerTriggerFactor = 226, + UM_TransitionFade = 227, + UM_ScoreboardTempUpdate = 228, + UM_ChallengeModeCheatSession = 229, + UM_ChallengeModeCloseAllUI = 230, + UM_MPVSGameStart = 231, + UM_MPVSGameOver = 232, + UM_MPVSRoundEnd = 233, + UM_PlaytestUpdate = 234, + UNRECOGNIZED = -1, +} + +export function eP2CEUserMessagesFromJSON(object: any): EP2CEUserMessages { + switch (object) { + case 200: + case 'UM_CreditsPortalMsg': + return EP2CEUserMessages.UM_CreditsPortalMsg; + case 203: + case 'UM_ControlHelperAnimate': + return EP2CEUserMessages.UM_ControlHelperAnimate; + case 206: + case 'UM_HudPingIndicator': + return EP2CEUserMessages.UM_HudPingIndicator; + case 207: + case 'UM_OpenRadialMenu': + return EP2CEUserMessages.UM_OpenRadialMenu; + case 208: + case 'UM_AddLocator': + return EP2CEUserMessages.UM_AddLocator; + case 209: + case 'UM_MPMapCompleted': + return EP2CEUserMessages.UM_MPMapCompleted; + case 210: + case 'UM_MPMapIncomplete': + return EP2CEUserMessages.UM_MPMapIncomplete; + case 211: + case 'UM_MPMapCompletedData': + return EP2CEUserMessages.UM_MPMapCompletedData; + case 212: + case 'UM_MPTauntEarned': + return EP2CEUserMessages.UM_MPTauntEarned; + case 213: + case 'UM_MPTauntUnlocked': + return EP2CEUserMessages.UM_MPTauntUnlocked; + case 214: + case 'UM_MPTauntLocked': + return EP2CEUserMessages.UM_MPTauntLocked; + case 215: + case 'UM_MPAllTauntsLocked': + return EP2CEUserMessages.UM_MPAllTauntsLocked; + case 216: + case 'UM_PortalFX_Surface': + return EP2CEUserMessages.UM_PortalFX_Surface; + case 217: + case 'UM_PaintWorld': + return EP2CEUserMessages.UM_PaintWorld; + case 218: + case 'UM_PaintEntity': + return EP2CEUserMessages.UM_PaintEntity; + case 219: + case 'UM_ChangePaintColor': + return EP2CEUserMessages.UM_ChangePaintColor; + case 220: + case 'UM_PaintBombExplode': + return EP2CEUserMessages.UM_PaintBombExplode; + case 221: + case 'UM_RemoveAllPaint': + return EP2CEUserMessages.UM_RemoveAllPaint; + case 222: + case 'UM_PaintAllSurfaces': + return EP2CEUserMessages.UM_PaintAllSurfaces; + case 223: + case 'UM_RemovePaint': + return EP2CEUserMessages.UM_RemovePaint; + case 225: + case 'UM_ApplyHitBoxDamageEffect': + return EP2CEUserMessages.UM_ApplyHitBoxDamageEffect; + case 226: + case 'UM_SetMixLayerTriggerFactor': + return EP2CEUserMessages.UM_SetMixLayerTriggerFactor; + case 227: + case 'UM_TransitionFade': + return EP2CEUserMessages.UM_TransitionFade; + case 228: + case 'UM_ScoreboardTempUpdate': + return EP2CEUserMessages.UM_ScoreboardTempUpdate; + case 229: + case 'UM_ChallengeModeCheatSession': + return EP2CEUserMessages.UM_ChallengeModeCheatSession; + case 230: + case 'UM_ChallengeModeCloseAllUI': + return EP2CEUserMessages.UM_ChallengeModeCloseAllUI; + case 231: + case 'UM_MPVSGameStart': + return EP2CEUserMessages.UM_MPVSGameStart; + case 232: + case 'UM_MPVSGameOver': + return EP2CEUserMessages.UM_MPVSGameOver; + case 233: + case 'UM_MPVSRoundEnd': + return EP2CEUserMessages.UM_MPVSRoundEnd; + case 234: + case 'UM_PlaytestUpdate': + return EP2CEUserMessages.UM_PlaytestUpdate; + case -1: + case 'UNRECOGNIZED': + default: + return EP2CEUserMessages.UNRECOGNIZED; + } +} + +export function eP2CEUserMessagesToJSON(object: EP2CEUserMessages): string { + switch (object) { + case EP2CEUserMessages.UM_CreditsPortalMsg: + return 'UM_CreditsPortalMsg'; + case EP2CEUserMessages.UM_ControlHelperAnimate: + return 'UM_ControlHelperAnimate'; + case EP2CEUserMessages.UM_HudPingIndicator: + return 'UM_HudPingIndicator'; + case EP2CEUserMessages.UM_OpenRadialMenu: + return 'UM_OpenRadialMenu'; + case EP2CEUserMessages.UM_AddLocator: + return 'UM_AddLocator'; + case EP2CEUserMessages.UM_MPMapCompleted: + return 'UM_MPMapCompleted'; + case EP2CEUserMessages.UM_MPMapIncomplete: + return 'UM_MPMapIncomplete'; + case EP2CEUserMessages.UM_MPMapCompletedData: + return 'UM_MPMapCompletedData'; + case EP2CEUserMessages.UM_MPTauntEarned: + return 'UM_MPTauntEarned'; + case EP2CEUserMessages.UM_MPTauntUnlocked: + return 'UM_MPTauntUnlocked'; + case EP2CEUserMessages.UM_MPTauntLocked: + return 'UM_MPTauntLocked'; + case EP2CEUserMessages.UM_MPAllTauntsLocked: + return 'UM_MPAllTauntsLocked'; + case EP2CEUserMessages.UM_PortalFX_Surface: + return 'UM_PortalFX_Surface'; + case EP2CEUserMessages.UM_PaintWorld: + return 'UM_PaintWorld'; + case EP2CEUserMessages.UM_PaintEntity: + return 'UM_PaintEntity'; + case EP2CEUserMessages.UM_ChangePaintColor: + return 'UM_ChangePaintColor'; + case EP2CEUserMessages.UM_PaintBombExplode: + return 'UM_PaintBombExplode'; + case EP2CEUserMessages.UM_RemoveAllPaint: + return 'UM_RemoveAllPaint'; + case EP2CEUserMessages.UM_PaintAllSurfaces: + return 'UM_PaintAllSurfaces'; + case EP2CEUserMessages.UM_RemovePaint: + return 'UM_RemovePaint'; + case EP2CEUserMessages.UM_ApplyHitBoxDamageEffect: + return 'UM_ApplyHitBoxDamageEffect'; + case EP2CEUserMessages.UM_SetMixLayerTriggerFactor: + return 'UM_SetMixLayerTriggerFactor'; + case EP2CEUserMessages.UM_TransitionFade: + return 'UM_TransitionFade'; + case EP2CEUserMessages.UM_ScoreboardTempUpdate: + return 'UM_ScoreboardTempUpdate'; + case EP2CEUserMessages.UM_ChallengeModeCheatSession: + return 'UM_ChallengeModeCheatSession'; + case EP2CEUserMessages.UM_ChallengeModeCloseAllUI: + return 'UM_ChallengeModeCloseAllUI'; + case EP2CEUserMessages.UM_MPVSGameStart: + return 'UM_MPVSGameStart'; + case EP2CEUserMessages.UM_MPVSGameOver: + return 'UM_MPVSGameOver'; + case EP2CEUserMessages.UM_MPVSRoundEnd: + return 'UM_MPVSRoundEnd'; + case EP2CEUserMessages.UM_PlaytestUpdate: + return 'UM_PlaytestUpdate'; + case EP2CEUserMessages.UNRECOGNIZED: + default: + return 'UNRECOGNIZED'; + } +} + +export interface CUsrMsgCreditsPortalMsg { + type: number; +} + +export interface CUsrMsgControlHelperAnimate { + clear: number; + frontIcon: number; +} + +export interface CUsrMsgHudPingIndicator { + location: CMsgVector | undefined; +} + +export interface CUsrMsgOpenRadialMenu { + data: number; +} + +export interface CUsrMsgAddLocator { + entityIndex: number; + targetHandle: number; + time: number; + position: CMsgVector | undefined; + normal: CMsgVector | undefined; + command: string; +} + +export interface CUsrMsgMPMapCompleted { + branch: number; + level: number; +} + +export interface CUsrMsgMPMapIncomplete { + branch: number; + level: number; +} + +export interface CUsrMsgMPMapCompletedData { + data: Uint8Array; +} + +export interface CUsrMsgMPTauntEarned { + taunt: string; + silent: boolean; +} + +export interface CUsrMsgMPTauntUnlocked { + taunt: string; +} + +export interface CUsrMsgMPTauntLocked { + taunt: string; +} + +export interface CUsrMsgMPAllTauntsLocked { + data: number; +} + +export interface CUsrMsgPortalFXSurface { + entityIndex: number; + playerIndex: number; + team: number; + portal: number; + effect: number; + origin: CMsgVector | undefined; + angles: CMsgQAngle | undefined; +} + +export interface CUsrMsgPaintWorld { + brush: number; + power: number; + radius: number; + alpha: number; + locationCount: number; + center: CMsgVector | undefined; + offset: CMsgVector[]; +} + +export interface CUsrMsgPaintEntity { + entity: number; + power: number; + center: CMsgVector | undefined; +} + +export interface CUsrMsgChangePaintColor { + weapon: number; + power: number; +} + +export interface CUsrMsgRemoveAllPaint { + data: number; +} + +export interface CUsrMsgPaintAllSurfaces { + power: number; +} + +export interface CUsrMsgRemovePaint { + entity: number; +} + +export interface CUsrMsgApplyHitBoxDamageEffect { + entity: number; + damageEffect: number; + particleEffect: number; +} + +export interface CUsrMsgSetMixLayerTriggerFactor { + layer: string; + group: string; + factor: number; +} + +export interface CUsrMsgTransitionFade { + time: number; +} + +export interface CUsrMsgScoreboardTempUpdate { + portals: number; + time: number; +} + +export interface CUsrMsgChallengeModeCheatSession { + data: number; +} + +export interface CUsrMsgChallengeModeCloseAllUI { + data: number; +} + +export interface CUsrMsgMPVSGameStart { + countdown: boolean; +} + +export interface CUsrMsgMPVSGameOver { + winner: number; +} + +export interface CUsrMsgMPVSRoundEnd { + winner: number; +} + +export interface CUsrMsgPlaytestUpdate { + type: CUsrMsgPlaytestUpdate_Type; +} + +export enum CUsrMsgPlaytestUpdate_Type { + START = 1, + END = 2, + UNRECOGNIZED = -1, +} + +export function cUsrMsgPlaytestUpdate_TypeFromJSON(object: any): CUsrMsgPlaytestUpdate_Type { + switch (object) { + case 1: + case 'START': + return CUsrMsgPlaytestUpdate_Type.START; + case 2: + case 'END': + return CUsrMsgPlaytestUpdate_Type.END; + case -1: + case 'UNRECOGNIZED': + default: + return CUsrMsgPlaytestUpdate_Type.UNRECOGNIZED; + } +} + +export function cUsrMsgPlaytestUpdate_TypeToJSON(object: CUsrMsgPlaytestUpdate_Type): string { + switch (object) { + case CUsrMsgPlaytestUpdate_Type.START: + return 'START'; + case CUsrMsgPlaytestUpdate_Type.END: + return 'END'; + case CUsrMsgPlaytestUpdate_Type.UNRECOGNIZED: + default: + return 'UNRECOGNIZED'; + } +} + +function createBaseCUsrMsgCreditsPortalMsg(): CUsrMsgCreditsPortalMsg { + return { type: 0 }; +} + +export const CUsrMsgCreditsPortalMsg = { + encode(message: CUsrMsgCreditsPortalMsg, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgCreditsPortalMsg { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgCreditsPortalMsg(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.type = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgCreditsPortalMsg { + return { type: isSet(object.type) ? globalThis.Number(object.type) : 0 }; + }, + + toJSON(message: CUsrMsgCreditsPortalMsg): unknown { + const obj: any = {}; + if (message.type !== 0) { + obj.type = Math.round(message.type); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgCreditsPortalMsg { + return CUsrMsgCreditsPortalMsg.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgCreditsPortalMsg { + const message = createBaseCUsrMsgCreditsPortalMsg(); + message.type = object.type ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgControlHelperAnimate(): CUsrMsgControlHelperAnimate { + return { clear: 0, frontIcon: 0 }; +} + +export const CUsrMsgControlHelperAnimate = { + encode(message: CUsrMsgControlHelperAnimate, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.clear !== 0) { + writer.uint32(8).int32(message.clear); + } + if (message.frontIcon !== 0) { + writer.uint32(16).int32(message.frontIcon); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgControlHelperAnimate { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgControlHelperAnimate(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.clear = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.frontIcon = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgControlHelperAnimate { + return { + clear: isSet(object.clear) ? globalThis.Number(object.clear) : 0, + frontIcon: isSet(object.frontIcon) ? globalThis.Number(object.frontIcon) : 0, + }; + }, + + toJSON(message: CUsrMsgControlHelperAnimate): unknown { + const obj: any = {}; + if (message.clear !== 0) { + obj.clear = Math.round(message.clear); + } + if (message.frontIcon !== 0) { + obj.frontIcon = Math.round(message.frontIcon); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgControlHelperAnimate { + return CUsrMsgControlHelperAnimate.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgControlHelperAnimate { + const message = createBaseCUsrMsgControlHelperAnimate(); + message.clear = object.clear ?? 0; + message.frontIcon = object.frontIcon ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgHudPingIndicator(): CUsrMsgHudPingIndicator { + return { location: undefined }; +} + +export const CUsrMsgHudPingIndicator = { + encode(message: CUsrMsgHudPingIndicator, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.location !== undefined) { + CMsgVector.encode(message.location, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgHudPingIndicator { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgHudPingIndicator(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.location = CMsgVector.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgHudPingIndicator { + return { location: isSet(object.location) ? CMsgVector.fromJSON(object.location) : undefined }; + }, + + toJSON(message: CUsrMsgHudPingIndicator): unknown { + const obj: any = {}; + if (message.location !== undefined) { + obj.location = CMsgVector.toJSON(message.location); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgHudPingIndicator { + return CUsrMsgHudPingIndicator.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgHudPingIndicator { + const message = createBaseCUsrMsgHudPingIndicator(); + message.location = (object.location !== undefined && object.location !== null) + ? CMsgVector.fromPartial(object.location) + : undefined; + return message; + }, +}; + +function createBaseCUsrMsgOpenRadialMenu(): CUsrMsgOpenRadialMenu { + return { data: 0 }; +} + +export const CUsrMsgOpenRadialMenu = { + encode(message: CUsrMsgOpenRadialMenu, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.data !== 0) { + writer.uint32(8).int32(message.data); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgOpenRadialMenu { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgOpenRadialMenu(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.data = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgOpenRadialMenu { + return { data: isSet(object.data) ? globalThis.Number(object.data) : 0 }; + }, + + toJSON(message: CUsrMsgOpenRadialMenu): unknown { + const obj: any = {}; + if (message.data !== 0) { + obj.data = Math.round(message.data); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgOpenRadialMenu { + return CUsrMsgOpenRadialMenu.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgOpenRadialMenu { + const message = createBaseCUsrMsgOpenRadialMenu(); + message.data = object.data ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgAddLocator(): CUsrMsgAddLocator { + return { entityIndex: 0, targetHandle: 0, time: 0, position: undefined, normal: undefined, command: '' }; +} + +export const CUsrMsgAddLocator = { + encode(message: CUsrMsgAddLocator, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.entityIndex !== 0) { + writer.uint32(8).int32(message.entityIndex); + } + if (message.targetHandle !== 0) { + writer.uint32(16).int64(message.targetHandle); + } + if (message.time !== 0) { + writer.uint32(29).float(message.time); + } + if (message.position !== undefined) { + CMsgVector.encode(message.position, writer.uint32(34).fork()).ldelim(); + } + if (message.normal !== undefined) { + CMsgVector.encode(message.normal, writer.uint32(42).fork()).ldelim(); + } + if (message.command !== '') { + writer.uint32(50).string(message.command); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgAddLocator { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgAddLocator(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.entityIndex = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.targetHandle = longToNumber(reader.int64() as Long); + continue; + case 3: + if (tag !== 29) { + break; + } + + message.time = reader.float(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.position = CMsgVector.decode(reader, reader.uint32()); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.normal = CMsgVector.decode(reader, reader.uint32()); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.command = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgAddLocator { + return { + entityIndex: isSet(object.entityIndex) ? globalThis.Number(object.entityIndex) : 0, + targetHandle: isSet(object.targetHandle) ? globalThis.Number(object.targetHandle) : 0, + time: isSet(object.time) ? globalThis.Number(object.time) : 0, + position: isSet(object.position) ? CMsgVector.fromJSON(object.position) : undefined, + normal: isSet(object.normal) ? CMsgVector.fromJSON(object.normal) : undefined, + command: isSet(object.command) ? globalThis.String(object.command) : '', + }; + }, + + toJSON(message: CUsrMsgAddLocator): unknown { + const obj: any = {}; + if (message.entityIndex !== 0) { + obj.entityIndex = Math.round(message.entityIndex); + } + if (message.targetHandle !== 0) { + obj.targetHandle = Math.round(message.targetHandle); + } + if (message.time !== 0) { + obj.time = message.time; + } + if (message.position !== undefined) { + obj.position = CMsgVector.toJSON(message.position); + } + if (message.normal !== undefined) { + obj.normal = CMsgVector.toJSON(message.normal); + } + if (message.command !== '') { + obj.command = message.command; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgAddLocator { + return CUsrMsgAddLocator.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgAddLocator { + const message = createBaseCUsrMsgAddLocator(); + message.entityIndex = object.entityIndex ?? 0; + message.targetHandle = object.targetHandle ?? 0; + message.time = object.time ?? 0; + message.position = (object.position !== undefined && object.position !== null) + ? CMsgVector.fromPartial(object.position) + : undefined; + message.normal = (object.normal !== undefined && object.normal !== null) + ? CMsgVector.fromPartial(object.normal) + : undefined; + message.command = object.command ?? ''; + return message; + }, +}; + +function createBaseCUsrMsgMPMapCompleted(): CUsrMsgMPMapCompleted { + return { branch: 0, level: 0 }; +} + +export const CUsrMsgMPMapCompleted = { + encode(message: CUsrMsgMPMapCompleted, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.branch !== 0) { + writer.uint32(8).int32(message.branch); + } + if (message.level !== 0) { + writer.uint32(16).int32(message.level); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgMPMapCompleted { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgMPMapCompleted(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.branch = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.level = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgMPMapCompleted { + return { + branch: isSet(object.branch) ? globalThis.Number(object.branch) : 0, + level: isSet(object.level) ? globalThis.Number(object.level) : 0, + }; + }, + + toJSON(message: CUsrMsgMPMapCompleted): unknown { + const obj: any = {}; + if (message.branch !== 0) { + obj.branch = Math.round(message.branch); + } + if (message.level !== 0) { + obj.level = Math.round(message.level); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgMPMapCompleted { + return CUsrMsgMPMapCompleted.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgMPMapCompleted { + const message = createBaseCUsrMsgMPMapCompleted(); + message.branch = object.branch ?? 0; + message.level = object.level ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgMPMapIncomplete(): CUsrMsgMPMapIncomplete { + return { branch: 0, level: 0 }; +} + +export const CUsrMsgMPMapIncomplete = { + encode(message: CUsrMsgMPMapIncomplete, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.branch !== 0) { + writer.uint32(8).int32(message.branch); + } + if (message.level !== 0) { + writer.uint32(16).int32(message.level); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgMPMapIncomplete { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgMPMapIncomplete(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.branch = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.level = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgMPMapIncomplete { + return { + branch: isSet(object.branch) ? globalThis.Number(object.branch) : 0, + level: isSet(object.level) ? globalThis.Number(object.level) : 0, + }; + }, + + toJSON(message: CUsrMsgMPMapIncomplete): unknown { + const obj: any = {}; + if (message.branch !== 0) { + obj.branch = Math.round(message.branch); + } + if (message.level !== 0) { + obj.level = Math.round(message.level); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgMPMapIncomplete { + return CUsrMsgMPMapIncomplete.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgMPMapIncomplete { + const message = createBaseCUsrMsgMPMapIncomplete(); + message.branch = object.branch ?? 0; + message.level = object.level ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgMPMapCompletedData(): CUsrMsgMPMapCompletedData { + return { data: new Uint8Array(0) }; +} + +export const CUsrMsgMPMapCompletedData = { + encode(message: CUsrMsgMPMapCompletedData, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgMPMapCompletedData { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgMPMapCompletedData(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.data = reader.bytes(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgMPMapCompletedData { + return { data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(0) }; + }, + + toJSON(message: CUsrMsgMPMapCompletedData): unknown { + const obj: any = {}; + if (message.data.length !== 0) { + obj.data = base64FromBytes(message.data); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgMPMapCompletedData { + return CUsrMsgMPMapCompletedData.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgMPMapCompletedData { + const message = createBaseCUsrMsgMPMapCompletedData(); + message.data = object.data ?? new Uint8Array(0); + return message; + }, +}; + +function createBaseCUsrMsgMPTauntEarned(): CUsrMsgMPTauntEarned { + return { taunt: '', silent: false }; +} + +export const CUsrMsgMPTauntEarned = { + encode(message: CUsrMsgMPTauntEarned, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.taunt !== '') { + writer.uint32(10).string(message.taunt); + } + if (message.silent === true) { + writer.uint32(16).bool(message.silent); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgMPTauntEarned { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgMPTauntEarned(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.taunt = reader.string(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.silent = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgMPTauntEarned { + return { + taunt: isSet(object.taunt) ? globalThis.String(object.taunt) : '', + silent: isSet(object.silent) ? globalThis.Boolean(object.silent) : false, + }; + }, + + toJSON(message: CUsrMsgMPTauntEarned): unknown { + const obj: any = {}; + if (message.taunt !== '') { + obj.taunt = message.taunt; + } + if (message.silent === true) { + obj.silent = message.silent; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgMPTauntEarned { + return CUsrMsgMPTauntEarned.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgMPTauntEarned { + const message = createBaseCUsrMsgMPTauntEarned(); + message.taunt = object.taunt ?? ''; + message.silent = object.silent ?? false; + return message; + }, +}; + +function createBaseCUsrMsgMPTauntUnlocked(): CUsrMsgMPTauntUnlocked { + return { taunt: '' }; +} + +export const CUsrMsgMPTauntUnlocked = { + encode(message: CUsrMsgMPTauntUnlocked, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.taunt !== '') { + writer.uint32(10).string(message.taunt); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgMPTauntUnlocked { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgMPTauntUnlocked(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.taunt = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgMPTauntUnlocked { + return { taunt: isSet(object.taunt) ? globalThis.String(object.taunt) : '' }; + }, + + toJSON(message: CUsrMsgMPTauntUnlocked): unknown { + const obj: any = {}; + if (message.taunt !== '') { + obj.taunt = message.taunt; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgMPTauntUnlocked { + return CUsrMsgMPTauntUnlocked.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgMPTauntUnlocked { + const message = createBaseCUsrMsgMPTauntUnlocked(); + message.taunt = object.taunt ?? ''; + return message; + }, +}; + +function createBaseCUsrMsgMPTauntLocked(): CUsrMsgMPTauntLocked { + return { taunt: '' }; +} + +export const CUsrMsgMPTauntLocked = { + encode(message: CUsrMsgMPTauntLocked, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.taunt !== '') { + writer.uint32(10).string(message.taunt); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgMPTauntLocked { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgMPTauntLocked(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.taunt = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgMPTauntLocked { + return { taunt: isSet(object.taunt) ? globalThis.String(object.taunt) : '' }; + }, + + toJSON(message: CUsrMsgMPTauntLocked): unknown { + const obj: any = {}; + if (message.taunt !== '') { + obj.taunt = message.taunt; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgMPTauntLocked { + return CUsrMsgMPTauntLocked.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgMPTauntLocked { + const message = createBaseCUsrMsgMPTauntLocked(); + message.taunt = object.taunt ?? ''; + return message; + }, +}; + +function createBaseCUsrMsgMPAllTauntsLocked(): CUsrMsgMPAllTauntsLocked { + return { data: 0 }; +} + +export const CUsrMsgMPAllTauntsLocked = { + encode(message: CUsrMsgMPAllTauntsLocked, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.data !== 0) { + writer.uint32(8).int32(message.data); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgMPAllTauntsLocked { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgMPAllTauntsLocked(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.data = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgMPAllTauntsLocked { + return { data: isSet(object.data) ? globalThis.Number(object.data) : 0 }; + }, + + toJSON(message: CUsrMsgMPAllTauntsLocked): unknown { + const obj: any = {}; + if (message.data !== 0) { + obj.data = Math.round(message.data); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgMPAllTauntsLocked { + return CUsrMsgMPAllTauntsLocked.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgMPAllTauntsLocked { + const message = createBaseCUsrMsgMPAllTauntsLocked(); + message.data = object.data ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgPortalFXSurface(): CUsrMsgPortalFXSurface { + return { entityIndex: 0, playerIndex: 0, team: 0, portal: 0, effect: 0, origin: undefined, angles: undefined }; +} + +export const CUsrMsgPortalFXSurface = { + encode(message: CUsrMsgPortalFXSurface, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.entityIndex !== 0) { + writer.uint32(8).int32(message.entityIndex); + } + if (message.playerIndex !== 0) { + writer.uint32(16).int32(message.playerIndex); + } + if (message.team !== 0) { + writer.uint32(24).int32(message.team); + } + if (message.portal !== 0) { + writer.uint32(32).int32(message.portal); + } + if (message.effect !== 0) { + writer.uint32(40).int32(message.effect); + } + if (message.origin !== undefined) { + CMsgVector.encode(message.origin, writer.uint32(50).fork()).ldelim(); + } + if (message.angles !== undefined) { + CMsgQAngle.encode(message.angles, writer.uint32(58).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgPortalFXSurface { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgPortalFXSurface(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.entityIndex = reader.int32(); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.playerIndex = reader.int32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.team = reader.int32(); + continue; + case 4: + if (tag !== 32) { + break; + } + + message.portal = reader.int32(); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.effect = reader.int32(); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.origin = CMsgVector.decode(reader, reader.uint32()); + continue; + case 7: + if (tag !== 58) { + break; + } + + message.angles = CMsgQAngle.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgPortalFXSurface { + return { + entityIndex: isSet(object.entityIndex) ? globalThis.Number(object.entityIndex) : 0, + playerIndex: isSet(object.playerIndex) ? globalThis.Number(object.playerIndex) : 0, + team: isSet(object.team) ? globalThis.Number(object.team) : 0, + portal: isSet(object.portal) ? globalThis.Number(object.portal) : 0, + effect: isSet(object.effect) ? globalThis.Number(object.effect) : 0, + origin: isSet(object.origin) ? CMsgVector.fromJSON(object.origin) : undefined, + angles: isSet(object.angles) ? CMsgQAngle.fromJSON(object.angles) : undefined, + }; + }, + + toJSON(message: CUsrMsgPortalFXSurface): unknown { + const obj: any = {}; + if (message.entityIndex !== 0) { + obj.entityIndex = Math.round(message.entityIndex); + } + if (message.playerIndex !== 0) { + obj.playerIndex = Math.round(message.playerIndex); + } + if (message.team !== 0) { + obj.team = Math.round(message.team); + } + if (message.portal !== 0) { + obj.portal = Math.round(message.portal); + } + if (message.effect !== 0) { + obj.effect = Math.round(message.effect); + } + if (message.origin !== undefined) { + obj.origin = CMsgVector.toJSON(message.origin); + } + if (message.angles !== undefined) { + obj.angles = CMsgQAngle.toJSON(message.angles); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgPortalFXSurface { + return CUsrMsgPortalFXSurface.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgPortalFXSurface { + const message = createBaseCUsrMsgPortalFXSurface(); + message.entityIndex = object.entityIndex ?? 0; + message.playerIndex = object.playerIndex ?? 0; + message.team = object.team ?? 0; + message.portal = object.portal ?? 0; + message.effect = object.effect ?? 0; + message.origin = (object.origin !== undefined && object.origin !== null) + ? CMsgVector.fromPartial(object.origin) + : undefined; + message.angles = (object.angles !== undefined && object.angles !== null) + ? CMsgQAngle.fromPartial(object.angles) + : undefined; + return message; + }, +}; + +function createBaseCUsrMsgPaintWorld(): CUsrMsgPaintWorld { + return { brush: 0, power: 0, radius: 0, alpha: 0, locationCount: 0, center: undefined, offset: [] }; +} + +export const CUsrMsgPaintWorld = { + encode(message: CUsrMsgPaintWorld, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.brush !== 0) { + writer.uint32(8).int64(message.brush); + } + if (message.power !== 0) { + writer.uint32(16).int32(message.power); + } + if (message.radius !== 0) { + writer.uint32(29).float(message.radius); + } + if (message.alpha !== 0) { + writer.uint32(37).float(message.alpha); + } + if (message.locationCount !== 0) { + writer.uint32(40).int32(message.locationCount); + } + if (message.center !== undefined) { + CMsgVector.encode(message.center, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.offset) { + CMsgVector.encode(v!, writer.uint32(58).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgPaintWorld { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgPaintWorld(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.brush = longToNumber(reader.int64() as Long); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.power = reader.int32(); + continue; + case 3: + if (tag !== 29) { + break; + } + + message.radius = reader.float(); + continue; + case 4: + if (tag !== 37) { + break; + } + + message.alpha = reader.float(); + continue; + case 5: + if (tag !== 40) { + break; + } + + message.locationCount = reader.int32(); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.center = CMsgVector.decode(reader, reader.uint32()); + continue; + case 7: + if (tag !== 58) { + break; + } + + message.offset.push(CMsgVector.decode(reader, reader.uint32())); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgPaintWorld { + return { + brush: isSet(object.brush) ? globalThis.Number(object.brush) : 0, + power: isSet(object.power) ? globalThis.Number(object.power) : 0, + radius: isSet(object.radius) ? globalThis.Number(object.radius) : 0, + alpha: isSet(object.alpha) ? globalThis.Number(object.alpha) : 0, + locationCount: isSet(object.locationCount) ? globalThis.Number(object.locationCount) : 0, + center: isSet(object.center) ? CMsgVector.fromJSON(object.center) : undefined, + offset: globalThis.Array.isArray(object?.offset) + ? object.offset.map((e: any) => CMsgVector.fromJSON(e)) + : [], + }; + }, + + toJSON(message: CUsrMsgPaintWorld): unknown { + const obj: any = {}; + if (message.brush !== 0) { + obj.brush = Math.round(message.brush); + } + if (message.power !== 0) { + obj.power = Math.round(message.power); + } + if (message.radius !== 0) { + obj.radius = message.radius; + } + if (message.alpha !== 0) { + obj.alpha = message.alpha; + } + if (message.locationCount !== 0) { + obj.locationCount = Math.round(message.locationCount); + } + if (message.center !== undefined) { + obj.center = CMsgVector.toJSON(message.center); + } + if (message.offset?.length) { + obj.offset = message.offset.map((e) => CMsgVector.toJSON(e)); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgPaintWorld { + return CUsrMsgPaintWorld.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgPaintWorld { + const message = createBaseCUsrMsgPaintWorld(); + message.brush = object.brush ?? 0; + message.power = object.power ?? 0; + message.radius = object.radius ?? 0; + message.alpha = object.alpha ?? 0; + message.locationCount = object.locationCount ?? 0; + message.center = (object.center !== undefined && object.center !== null) + ? CMsgVector.fromPartial(object.center) + : undefined; + message.offset = object.offset?.map((e) => CMsgVector.fromPartial(e)) || []; + return message; + }, +}; + +function createBaseCUsrMsgPaintEntity(): CUsrMsgPaintEntity { + return { entity: 0, power: 0, center: undefined }; +} + +export const CUsrMsgPaintEntity = { + encode(message: CUsrMsgPaintEntity, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.entity !== 0) { + writer.uint32(8).int64(message.entity); + } + if (message.power !== 0) { + writer.uint32(16).int32(message.power); + } + if (message.center !== undefined) { + CMsgVector.encode(message.center, writer.uint32(50).fork()).ldelim(); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgPaintEntity { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgPaintEntity(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.entity = longToNumber(reader.int64() as Long); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.power = reader.int32(); + continue; + case 6: + if (tag !== 50) { + break; + } + + message.center = CMsgVector.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgPaintEntity { + return { + entity: isSet(object.entity) ? globalThis.Number(object.entity) : 0, + power: isSet(object.power) ? globalThis.Number(object.power) : 0, + center: isSet(object.center) ? CMsgVector.fromJSON(object.center) : undefined, + }; + }, + + toJSON(message: CUsrMsgPaintEntity): unknown { + const obj: any = {}; + if (message.entity !== 0) { + obj.entity = Math.round(message.entity); + } + if (message.power !== 0) { + obj.power = Math.round(message.power); + } + if (message.center !== undefined) { + obj.center = CMsgVector.toJSON(message.center); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgPaintEntity { + return CUsrMsgPaintEntity.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgPaintEntity { + const message = createBaseCUsrMsgPaintEntity(); + message.entity = object.entity ?? 0; + message.power = object.power ?? 0; + message.center = (object.center !== undefined && object.center !== null) + ? CMsgVector.fromPartial(object.center) + : undefined; + return message; + }, +}; + +function createBaseCUsrMsgChangePaintColor(): CUsrMsgChangePaintColor { + return { weapon: 0, power: 0 }; +} + +export const CUsrMsgChangePaintColor = { + encode(message: CUsrMsgChangePaintColor, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.weapon !== 0) { + writer.uint32(8).int64(message.weapon); + } + if (message.power !== 0) { + writer.uint32(16).int32(message.power); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgChangePaintColor { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgChangePaintColor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.weapon = longToNumber(reader.int64() as Long); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.power = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgChangePaintColor { + return { + weapon: isSet(object.weapon) ? globalThis.Number(object.weapon) : 0, + power: isSet(object.power) ? globalThis.Number(object.power) : 0, + }; + }, + + toJSON(message: CUsrMsgChangePaintColor): unknown { + const obj: any = {}; + if (message.weapon !== 0) { + obj.weapon = Math.round(message.weapon); + } + if (message.power !== 0) { + obj.power = Math.round(message.power); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgChangePaintColor { + return CUsrMsgChangePaintColor.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgChangePaintColor { + const message = createBaseCUsrMsgChangePaintColor(); + message.weapon = object.weapon ?? 0; + message.power = object.power ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgRemoveAllPaint(): CUsrMsgRemoveAllPaint { + return { data: 0 }; +} + +export const CUsrMsgRemoveAllPaint = { + encode(message: CUsrMsgRemoveAllPaint, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.data !== 0) { + writer.uint32(8).int32(message.data); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgRemoveAllPaint { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgRemoveAllPaint(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.data = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgRemoveAllPaint { + return { data: isSet(object.data) ? globalThis.Number(object.data) : 0 }; + }, + + toJSON(message: CUsrMsgRemoveAllPaint): unknown { + const obj: any = {}; + if (message.data !== 0) { + obj.data = Math.round(message.data); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgRemoveAllPaint { + return CUsrMsgRemoveAllPaint.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgRemoveAllPaint { + const message = createBaseCUsrMsgRemoveAllPaint(); + message.data = object.data ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgPaintAllSurfaces(): CUsrMsgPaintAllSurfaces { + return { power: 0 }; +} + +export const CUsrMsgPaintAllSurfaces = { + encode(message: CUsrMsgPaintAllSurfaces, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.power !== 0) { + writer.uint32(8).int32(message.power); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgPaintAllSurfaces { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgPaintAllSurfaces(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.power = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgPaintAllSurfaces { + return { power: isSet(object.power) ? globalThis.Number(object.power) : 0 }; + }, + + toJSON(message: CUsrMsgPaintAllSurfaces): unknown { + const obj: any = {}; + if (message.power !== 0) { + obj.power = Math.round(message.power); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgPaintAllSurfaces { + return CUsrMsgPaintAllSurfaces.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgPaintAllSurfaces { + const message = createBaseCUsrMsgPaintAllSurfaces(); + message.power = object.power ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgRemovePaint(): CUsrMsgRemovePaint { + return { entity: 0 }; +} + +export const CUsrMsgRemovePaint = { + encode(message: CUsrMsgRemovePaint, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.entity !== 0) { + writer.uint32(8).int64(message.entity); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgRemovePaint { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgRemovePaint(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.entity = longToNumber(reader.int64() as Long); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgRemovePaint { + return { entity: isSet(object.entity) ? globalThis.Number(object.entity) : 0 }; + }, + + toJSON(message: CUsrMsgRemovePaint): unknown { + const obj: any = {}; + if (message.entity !== 0) { + obj.entity = Math.round(message.entity); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgRemovePaint { + return CUsrMsgRemovePaint.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgRemovePaint { + const message = createBaseCUsrMsgRemovePaint(); + message.entity = object.entity ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgApplyHitBoxDamageEffect(): CUsrMsgApplyHitBoxDamageEffect { + return { entity: 0, damageEffect: 0, particleEffect: 0 }; +} + +export const CUsrMsgApplyHitBoxDamageEffect = { + encode(message: CUsrMsgApplyHitBoxDamageEffect, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.entity !== 0) { + writer.uint32(8).int64(message.entity); + } + if (message.damageEffect !== 0) { + writer.uint32(16).int32(message.damageEffect); + } + if (message.particleEffect !== 0) { + writer.uint32(24).int32(message.particleEffect); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgApplyHitBoxDamageEffect { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgApplyHitBoxDamageEffect(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.entity = longToNumber(reader.int64() as Long); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.damageEffect = reader.int32(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.particleEffect = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgApplyHitBoxDamageEffect { + return { + entity: isSet(object.entity) ? globalThis.Number(object.entity) : 0, + damageEffect: isSet(object.damageEffect) ? globalThis.Number(object.damageEffect) : 0, + particleEffect: isSet(object.particleEffect) ? globalThis.Number(object.particleEffect) : 0, + }; + }, + + toJSON(message: CUsrMsgApplyHitBoxDamageEffect): unknown { + const obj: any = {}; + if (message.entity !== 0) { + obj.entity = Math.round(message.entity); + } + if (message.damageEffect !== 0) { + obj.damageEffect = Math.round(message.damageEffect); + } + if (message.particleEffect !== 0) { + obj.particleEffect = Math.round(message.particleEffect); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgApplyHitBoxDamageEffect { + return CUsrMsgApplyHitBoxDamageEffect.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): CUsrMsgApplyHitBoxDamageEffect { + const message = createBaseCUsrMsgApplyHitBoxDamageEffect(); + message.entity = object.entity ?? 0; + message.damageEffect = object.damageEffect ?? 0; + message.particleEffect = object.particleEffect ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgSetMixLayerTriggerFactor(): CUsrMsgSetMixLayerTriggerFactor { + return { layer: '', group: '', factor: 0 }; +} + +export const CUsrMsgSetMixLayerTriggerFactor = { + encode(message: CUsrMsgSetMixLayerTriggerFactor, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.layer !== '') { + writer.uint32(10).string(message.layer); + } + if (message.group !== '') { + writer.uint32(18).string(message.group); + } + if (message.factor !== 0) { + writer.uint32(29).float(message.factor); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgSetMixLayerTriggerFactor { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgSetMixLayerTriggerFactor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.layer = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.group = reader.string(); + continue; + case 3: + if (tag !== 29) { + break; + } + + message.factor = reader.float(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgSetMixLayerTriggerFactor { + return { + layer: isSet(object.layer) ? globalThis.String(object.layer) : '', + group: isSet(object.group) ? globalThis.String(object.group) : '', + factor: isSet(object.factor) ? globalThis.Number(object.factor) : 0, + }; + }, + + toJSON(message: CUsrMsgSetMixLayerTriggerFactor): unknown { + const obj: any = {}; + if (message.layer !== '') { + obj.layer = message.layer; + } + if (message.group !== '') { + obj.group = message.group; + } + if (message.factor !== 0) { + obj.factor = message.factor; + } + return obj; + }, + + create, I>>( + base?: I, + ): CUsrMsgSetMixLayerTriggerFactor { + return CUsrMsgSetMixLayerTriggerFactor.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): CUsrMsgSetMixLayerTriggerFactor { + const message = createBaseCUsrMsgSetMixLayerTriggerFactor(); + message.layer = object.layer ?? ''; + message.group = object.group ?? ''; + message.factor = object.factor ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgTransitionFade(): CUsrMsgTransitionFade { + return { time: 0 }; +} + +export const CUsrMsgTransitionFade = { + encode(message: CUsrMsgTransitionFade, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.time !== 0) { + writer.uint32(13).float(message.time); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgTransitionFade { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgTransitionFade(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 13) { + break; + } + + message.time = reader.float(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgTransitionFade { + return { time: isSet(object.time) ? globalThis.Number(object.time) : 0 }; + }, + + toJSON(message: CUsrMsgTransitionFade): unknown { + const obj: any = {}; + if (message.time !== 0) { + obj.time = message.time; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgTransitionFade { + return CUsrMsgTransitionFade.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgTransitionFade { + const message = createBaseCUsrMsgTransitionFade(); + message.time = object.time ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgScoreboardTempUpdate(): CUsrMsgScoreboardTempUpdate { + return { portals: 0, time: 0 }; +} + +export const CUsrMsgScoreboardTempUpdate = { + encode(message: CUsrMsgScoreboardTempUpdate, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.portals !== 0) { + writer.uint32(8).int64(message.portals); + } + if (message.time !== 0) { + writer.uint32(16).int64(message.time); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgScoreboardTempUpdate { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgScoreboardTempUpdate(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.portals = longToNumber(reader.int64() as Long); + continue; + case 2: + if (tag !== 16) { + break; + } + + message.time = longToNumber(reader.int64() as Long); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgScoreboardTempUpdate { + return { + portals: isSet(object.portals) ? globalThis.Number(object.portals) : 0, + time: isSet(object.time) ? globalThis.Number(object.time) : 0, + }; + }, + + toJSON(message: CUsrMsgScoreboardTempUpdate): unknown { + const obj: any = {}; + if (message.portals !== 0) { + obj.portals = Math.round(message.portals); + } + if (message.time !== 0) { + obj.time = Math.round(message.time); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgScoreboardTempUpdate { + return CUsrMsgScoreboardTempUpdate.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgScoreboardTempUpdate { + const message = createBaseCUsrMsgScoreboardTempUpdate(); + message.portals = object.portals ?? 0; + message.time = object.time ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgChallengeModeCheatSession(): CUsrMsgChallengeModeCheatSession { + return { data: 0 }; +} + +export const CUsrMsgChallengeModeCheatSession = { + encode(message: CUsrMsgChallengeModeCheatSession, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.data !== 0) { + writer.uint32(8).int32(message.data); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgChallengeModeCheatSession { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgChallengeModeCheatSession(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.data = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgChallengeModeCheatSession { + return { data: isSet(object.data) ? globalThis.Number(object.data) : 0 }; + }, + + toJSON(message: CUsrMsgChallengeModeCheatSession): unknown { + const obj: any = {}; + if (message.data !== 0) { + obj.data = Math.round(message.data); + } + return obj; + }, + + create, I>>( + base?: I, + ): CUsrMsgChallengeModeCheatSession { + return CUsrMsgChallengeModeCheatSession.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): CUsrMsgChallengeModeCheatSession { + const message = createBaseCUsrMsgChallengeModeCheatSession(); + message.data = object.data ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgChallengeModeCloseAllUI(): CUsrMsgChallengeModeCloseAllUI { + return { data: 0 }; +} + +export const CUsrMsgChallengeModeCloseAllUI = { + encode(message: CUsrMsgChallengeModeCloseAllUI, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.data !== 0) { + writer.uint32(8).int32(message.data); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgChallengeModeCloseAllUI { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgChallengeModeCloseAllUI(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.data = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgChallengeModeCloseAllUI { + return { data: isSet(object.data) ? globalThis.Number(object.data) : 0 }; + }, + + toJSON(message: CUsrMsgChallengeModeCloseAllUI): unknown { + const obj: any = {}; + if (message.data !== 0) { + obj.data = Math.round(message.data); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgChallengeModeCloseAllUI { + return CUsrMsgChallengeModeCloseAllUI.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): CUsrMsgChallengeModeCloseAllUI { + const message = createBaseCUsrMsgChallengeModeCloseAllUI(); + message.data = object.data ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgMPVSGameStart(): CUsrMsgMPVSGameStart { + return { countdown: false }; +} + +export const CUsrMsgMPVSGameStart = { + encode(message: CUsrMsgMPVSGameStart, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.countdown === true) { + writer.uint32(8).bool(message.countdown); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgMPVSGameStart { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgMPVSGameStart(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.countdown = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgMPVSGameStart { + return { countdown: isSet(object.countdown) ? globalThis.Boolean(object.countdown) : false }; + }, + + toJSON(message: CUsrMsgMPVSGameStart): unknown { + const obj: any = {}; + if (message.countdown === true) { + obj.countdown = message.countdown; + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgMPVSGameStart { + return CUsrMsgMPVSGameStart.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgMPVSGameStart { + const message = createBaseCUsrMsgMPVSGameStart(); + message.countdown = object.countdown ?? false; + return message; + }, +}; + +function createBaseCUsrMsgMPVSGameOver(): CUsrMsgMPVSGameOver { + return { winner: 0 }; +} + +export const CUsrMsgMPVSGameOver = { + encode(message: CUsrMsgMPVSGameOver, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.winner !== 0) { + writer.uint32(8).int32(message.winner); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgMPVSGameOver { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgMPVSGameOver(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.winner = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgMPVSGameOver { + return { winner: isSet(object.winner) ? globalThis.Number(object.winner) : 0 }; + }, + + toJSON(message: CUsrMsgMPVSGameOver): unknown { + const obj: any = {}; + if (message.winner !== 0) { + obj.winner = Math.round(message.winner); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgMPVSGameOver { + return CUsrMsgMPVSGameOver.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgMPVSGameOver { + const message = createBaseCUsrMsgMPVSGameOver(); + message.winner = object.winner ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgMPVSRoundEnd(): CUsrMsgMPVSRoundEnd { + return { winner: 0 }; +} + +export const CUsrMsgMPVSRoundEnd = { + encode(message: CUsrMsgMPVSRoundEnd, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.winner !== 0) { + writer.uint32(8).int32(message.winner); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgMPVSRoundEnd { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgMPVSRoundEnd(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.winner = reader.int32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgMPVSRoundEnd { + return { winner: isSet(object.winner) ? globalThis.Number(object.winner) : 0 }; + }, + + toJSON(message: CUsrMsgMPVSRoundEnd): unknown { + const obj: any = {}; + if (message.winner !== 0) { + obj.winner = Math.round(message.winner); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgMPVSRoundEnd { + return CUsrMsgMPVSRoundEnd.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgMPVSRoundEnd { + const message = createBaseCUsrMsgMPVSRoundEnd(); + message.winner = object.winner ?? 0; + return message; + }, +}; + +function createBaseCUsrMsgPlaytestUpdate(): CUsrMsgPlaytestUpdate { + return { type: 1 }; +} + +export const CUsrMsgPlaytestUpdate = { + encode(message: CUsrMsgPlaytestUpdate, writer: pb.Writer = pb.Writer.create()): pb.Writer { + if (message.type !== 1) { + writer.uint32(8).int32(message.type); + } + return writer; + }, + + decode(input: pb.Reader | Uint8Array, length?: number): CUsrMsgPlaytestUpdate { + const reader = input instanceof pb.Reader ? input : pb.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCUsrMsgPlaytestUpdate(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.type = reader.int32() as any; + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): CUsrMsgPlaytestUpdate { + return { type: isSet(object.type) ? cUsrMsgPlaytestUpdate_TypeFromJSON(object.type) : 1 }; + }, + + toJSON(message: CUsrMsgPlaytestUpdate): unknown { + const obj: any = {}; + if (message.type !== 1) { + obj.type = cUsrMsgPlaytestUpdate_TypeToJSON(message.type); + } + return obj; + }, + + create, I>>(base?: I): CUsrMsgPlaytestUpdate { + return CUsrMsgPlaytestUpdate.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): CUsrMsgPlaytestUpdate { + const message = createBaseCUsrMsgPlaytestUpdate(); + message.type = object.type ?? 1; + return message; + }, +}; + +function bytesFromBase64(b64: string): Uint8Array { + const bin = globalThis.atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + arr.forEach((byte) => { + bin.push(globalThis.String.fromCharCode(byte)); + }); + return globalThis.btoa(bin.join('')); +} + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function longToNumber(long: Long): number { + if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + } + return long.toNumber(); +} + +if (pb.util.Long !== Long) { + pb.util.Long = Long as any; + pb.configure(); +} + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/examples/custom/strata.ts b/examples/custom/strata.ts new file mode 100644 index 0000000..089b088 --- /dev/null +++ b/examples/custom/strata.ts @@ -0,0 +1,250 @@ +import { Messages, SourceDemo, SourceDemoBuffer, SourceDemoParser } from '../../src/mod.ts'; +import { DataTable, Packet } from '../../src/messages.ts'; +import { ServerClassInfo } from '../../src/types/DataTables.ts'; +import * as nm from './p2ce/netmessages.ts'; +import * as um from './p2ce/base_usermessages.ts'; +import * as p2ceUm from './p2ce/p2ce_usermessages.ts'; +//import { nETMessagesToJSON, sVCMessagesToJSON } from './p2ce/netmessages.ts'; + +export const p2ceNetMessages = { + [nm.NETMessages.net_Tick]: nm.CNETMsgTick, + [nm.NETMessages.net_StringCmd]: nm.CNETMsgStringCmd, + [nm.NETMessages.net_SignonState]: nm.CNETMsgSignonState, + [nm.NETMessages.net_SetConVar]: nm.CNETMsgSetConVar, + [nm.NETMessages.net_NOP]: nm.CNETMsgNOP, + [nm.NETMessages.net_Disconnect]: nm.CNETMsgDisconnect, + [nm.NETMessages.net_File]: nm.CNETMsgFile, + [nm.NETMessages.net_SplitScreenUser]: nm.CNETMsgSplitScreenUser, + [nm.NETMessages.net_PlayerAvatarData]: nm.CNETMsgPlayerAvatarData, + [nm.SVCMessages.svc_ServerInfo]: nm.CSVCMsgServerInfo, + [nm.SVCMessages.svc_ClassInfo]: nm.CSVCMsgClassInfo, + [nm.SVCMessages.svc_SendTable]: nm.CSVCMsgSendTable, + [nm.SVCMessages.svc_Print]: nm.CSVCMsgPrint, + [nm.SVCMessages.svc_SetPause]: nm.CSVCMsgSetPause, + [nm.SVCMessages.svc_SetView]: nm.CSVCMsgSetView, + [nm.SVCMessages.svc_CreateStringTable]: nm.CSVCMsgCreateStringTable, + [nm.SVCMessages.svc_UpdateStringTable]: nm.CSVCMsgUpdateStringTable, + [nm.SVCMessages.svc_VoiceInit]: nm.CSVCMsgVoiceInit, + [nm.SVCMessages.svc_VoiceData]: nm.CSVCMsgVoiceData, + [nm.SVCMessages.svc_FixAngle]: nm.CSVCMsgFixAngle, + [nm.SVCMessages.svc_CrosshairAngle]: nm.CSVCMsgCrosshairAngle, + [nm.SVCMessages.svc_Prefetch]: nm.CSVCMsgPrefetch, + [nm.SVCMessages.svc_BSPDecal]: nm.CSVCMsgBSPDecal, + [nm.SVCMessages.svc_SplitScreen]: nm.CSVCMsgSplitScreen, + [nm.SVCMessages.svc_GetCvarValue]: nm.CSVCMsgGetCvarValue, + [nm.SVCMessages.svc_UserMessage]: nm.CSVCMsgUserMessage, + [nm.SVCMessages.svc_PaintmapData]: nm.CSVCMsgPaintmapData, + [nm.SVCMessages.svc_GameEvent]: nm.CSVCMsgGameEvent, + [nm.SVCMessages.svc_GameEventList]: nm.CSVCMsgGameEventList, + [nm.SVCMessages.svc_TempEntities]: nm.CSVCMsgTempEntities, + [nm.SVCMessages.svc_PacketEntities]: nm.CSVCMsgPacketEntities, + [nm.SVCMessages.svc_Sounds]: nm.CSVCMsgSounds, + [nm.SVCMessages.svc_EntityMessage]: nm.CSVCMsgEntityMsg, + [nm.SVCMessages.svc_CmdKeyValues]: nm.CSVCMsgCmdKeyValues, + [nm.SVCMessages.svc_EncryptedData]: nm.CSVCMsgEncryptedData, + [nm.SVCMessages.svc_HltvReplay]: nm.CSVCMsgHltvReplay, + [nm.SVCMessages.svc_Broadcast_Command]: nm.CSVCMsgBroadcastCommand, + [nm.SVCMessages.svc_HltvFixupOperatorStatus]: nm.CSVCMsgHltvFixupOperatorStatus, +}; + +export const p2ceUserMessages = { + [um.EUserMessages.UM_VGUIMenu]: um.CUsrMsgVGUIMenu, + [um.EUserMessages.UM_Geiger]: um.CUsrMsgGeiger, + [um.EUserMessages.UM_Train]: um.CUsrMsgTrain, + [um.EUserMessages.UM_HudText]: um.CUsrMsgHudText, + [um.EUserMessages.UM_SayText]: um.CUsrMsgSayText, + [um.EUserMessages.UM_SayText2]: um.CUsrMsgSayText2, + [um.EUserMessages.UM_TextMsg]: um.CUsrMsgTextMsg, + [um.EUserMessages.UM_HudMsg]: um.CUsrMsgHudMsg, + [um.EUserMessages.UM_Shake]: um.CUsrMsgShake, + [um.EUserMessages.UM_Fade]: um.CUsrMsgFade, + [um.EUserMessages.UM_Rumble]: um.CUsrMsgRumble, + [um.EUserMessages.UM_CloseCaption]: um.CUsrMsgCloseCaption, + [um.EUserMessages.UM_CloseCaptionDirect]: um.CUsrMsgCloseCaptionDirect, + [um.EUserMessages.UM_SendAudio]: um.CUsrMsgSendAudio, + [um.EUserMessages.UM_RawAudio]: um.CUsrMsgRawAudio, + [um.EUserMessages.UM_VoiceMask]: um.CUsrMsgVoiceMask, + [um.EUserMessages.UM_Damage]: um.CUsrMsgDamage, + [um.EUserMessages.UM_RadioText]: um.CUsrMsgRadioText, + [um.EUserMessages.UM_HintText]: um.CUsrMsgHintText, + [um.EUserMessages.UM_KeyHintText]: um.CUsrMsgKeyHintText, + [um.EUserMessages.UM_WeaponSound]: um.CUsrMsgWeaponSound, + [um.EUserMessages.UM_UpdateScreenHealthBar]: um.CUsrMsgUpdateScreenHealthBar, + [um.EUserMessages.UM_EntityOutlineHighlight]: um.CUsrMsgEntityOutlineHighlight, + [um.EUserMessages.UM_DesiredTimescale]: um.CUsrMsgDesiredTimescale, + [um.EUserMessages.UM_CurrentTimescale]: um.CUsrMsgCurrentTimescale, + [um.EUserMessages.UM_AchievementEvent]: um.CUsrMsgAchievementEvent, + [um.EUserMessages.UM_PlayerStatsUpdate]: um.CUsrMsgPlayerStatsUpdate, + [um.EUserMessages.UM_CallVoteFailed]: um.CUsrMsgCallVoteFailed, + [um.EUserMessages.UM_VoteStart]: um.CUsrMsgVoteStart, + [um.EUserMessages.UM_VotePass]: um.CUsrMsgVotePass, + [um.EUserMessages.UM_VoteFailed]: um.CUsrMsgVoteFailed, + [um.EUserMessages.UM_VoteSetup]: um.CUsrMsgVoteSetup, + [um.EUserMessages.UM_SendLastKillerDamageToClient]: um.CUsrMsgSendLastKillerDamageToClient, + [um.EUserMessages.UM_ItemPickup]: um.CUsrMsgItemPickup, + [um.EUserMessages.UM_ShowMenu]: um.CUsrMsgShowMenu, + [um.EUserMessages.UM_BarTime]: um.CUsrMsgBarTime, + [um.EUserMessages.UM_AmmoDenied]: um.CUsrMsgAmmoDenied, + [um.EUserMessages.UM_MarkAchievement]: um.CUsrMsgMarkAchievement, + [um.EUserMessages.UM_GlowPropTurnOff]: um.CUsrMsgGlowPropTurnOff, + [um.EUserMessages.UM_Tilt]: um.CUsrMsgTilt, + [um.EUserMessages.UM_Battery]: um.CUsrMsgBattery, + [um.EUserMessages.UM_CreditsMsg]: um.CUsrMsgCreditsMsg, + [um.EUserMessages.UM_LogoTimeMsg]: um.CUsrMsgLogoTimeMsg, + [um.EUserMessages.UM_UpdateJalopyRadar]: um.CUsrMsgUpdateJalopyRadar, + [um.EUserMessages.UM_MessageText]: um.CUsrMsgMessageText, + [um.EUserMessages.UM_StatsSkipState]: um.CUsrMsgStatsSkipState, + [um.EUserMessages.UM_PanoramaEvent]: um.CUsrMsgPanoramaEvent, + [um.EUserMessages.UM_ResetHud]: um.CUsrMsgResetHud, + [um.EUserMessages.UM_RequestState]: um.CUsrMsgRequestState, + [um.EUserMessages.UM_StopSpectatorMode]: um.CUsrMsgStopSpectatorMode, + [p2ceUm.EP2CEUserMessages.UM_CreditsPortalMsg]: p2ceUm.CUsrMsgCreditsPortalMsg, + [p2ceUm.EP2CEUserMessages.UM_ControlHelperAnimate]: p2ceUm.CUsrMsgControlHelperAnimate, + [p2ceUm.EP2CEUserMessages.UM_HudPingIndicator]: p2ceUm.CUsrMsgHudPingIndicator, + [p2ceUm.EP2CEUserMessages.UM_OpenRadialMenu]: p2ceUm.CUsrMsgOpenRadialMenu, + [p2ceUm.EP2CEUserMessages.UM_AddLocator]: p2ceUm.CUsrMsgAddLocator, + [p2ceUm.EP2CEUserMessages.UM_MPMapCompleted]: p2ceUm.CUsrMsgMPMapCompleted, + [p2ceUm.EP2CEUserMessages.UM_MPMapIncomplete]: p2ceUm.CUsrMsgMPMapIncomplete, + [p2ceUm.EP2CEUserMessages.UM_MPMapCompletedData]: p2ceUm.CUsrMsgMPMapCompletedData, + [p2ceUm.EP2CEUserMessages.UM_MPTauntEarned]: p2ceUm.CUsrMsgMPTauntEarned, + [p2ceUm.EP2CEUserMessages.UM_MPTauntUnlocked]: p2ceUm.CUsrMsgMPTauntUnlocked, + [p2ceUm.EP2CEUserMessages.UM_MPTauntLocked]: p2ceUm.CUsrMsgMPTauntLocked, + [p2ceUm.EP2CEUserMessages.UM_MPAllTauntsLocked]: p2ceUm.CUsrMsgMPAllTauntsLocked, + [p2ceUm.EP2CEUserMessages.UM_PortalFX_Surface]: p2ceUm.CUsrMsgPortalFXSurface, + [p2ceUm.EP2CEUserMessages.UM_PaintWorld]: p2ceUm.CUsrMsgPaintWorld, + [p2ceUm.EP2CEUserMessages.UM_PaintEntity]: p2ceUm.CUsrMsgPaintEntity, + [p2ceUm.EP2CEUserMessages.UM_ChangePaintColor]: p2ceUm.CUsrMsgChangePaintColor, + [p2ceUm.EP2CEUserMessages.UM_RemoveAllPaint]: p2ceUm.CUsrMsgRemoveAllPaint, + [p2ceUm.EP2CEUserMessages.UM_PaintAllSurfaces]: p2ceUm.CUsrMsgPaintAllSurfaces, + [p2ceUm.EP2CEUserMessages.UM_RemovePaint]: p2ceUm.CUsrMsgRemovePaint, + [p2ceUm.EP2CEUserMessages.UM_ApplyHitBoxDamageEffect]: p2ceUm.CUsrMsgApplyHitBoxDamageEffect, + [p2ceUm.EP2CEUserMessages.UM_SetMixLayerTriggerFactor]: p2ceUm.CUsrMsgSetMixLayerTriggerFactor, + [p2ceUm.EP2CEUserMessages.UM_TransitionFade]: p2ceUm.CUsrMsgTransitionFade, + [p2ceUm.EP2CEUserMessages.UM_ScoreboardTempUpdate]: p2ceUm.CUsrMsgScoreboardTempUpdate, + [p2ceUm.EP2CEUserMessages.UM_ChallengeModeCheatSession]: p2ceUm.CUsrMsgChallengeModeCheatSession, + [p2ceUm.EP2CEUserMessages.UM_ChallengeModeCloseAllUI]: p2ceUm.CUsrMsgChallengeModeCloseAllUI, + [p2ceUm.EP2CEUserMessages.UM_MPVSGameStart]: p2ceUm.CUsrMsgMPVSGameStart, + [p2ceUm.EP2CEUserMessages.UM_MPVSGameOver]: p2ceUm.CUsrMsgMPVSGameOver, + [p2ceUm.EP2CEUserMessages.UM_MPVSRoundEnd]: p2ceUm.CUsrMsgMPVSRoundEnd, + [p2ceUm.EP2CEUserMessages.UM_PlaytestUpdate]: p2ceUm.CUsrMsgPlaytestUpdate, +}; + +export class StrataSourceDemo extends SourceDemo { + override readPackets() { + for (const message of this.messages ?? []) { + if (message instanceof Packet) { + const packets: any[] = []; + const data = SourceDemoBuffer.from(message.data!); + + while (data.bitsLeft >= 16) { + const cmd = data.readVarInt32(); + const size = data.readVarInt32(); + + const message = (p2ceNetMessages as any)[cmd]; + const packet = message.decode(new Uint8Array(data.readArrayBuffer(size))); + packets.push(packet); + + //console.log(nETMessagesToJSON(cmd) ?? sVCMessagesToJSON(cmd)); + if (cmd === nm.SVCMessages.svc_UserMessage) { + const userMessage = (p2ceUserMessages as any)[packet.msgType]; + const umPacket = userMessage.decode(new Uint8Array(userMessage.msgData)); + console.log(umPacket); + } + } + + if (data.bitsLeft) { + message.restData = data.readBitStream(data.bitsLeft); + } + + message.packets = packets; + } + } + + return this; + } + override readDataTables() { + for (const message of this.messages ?? []) { + if (message instanceof DataTable) { + const dataTable: { + tables: any[]; + serverClasses: ServerClassInfo[]; + restData: SourceDemoBuffer | undefined; + } = { + tables: [], + serverClasses: [], + restData: undefined, + }; + + const data = SourceDemoBuffer.from(message.data!); + + while (data.bitsLeft) { + const type = data.readVarInt32(); + const size = data.readVarInt32(); + const descriptor = p2ceNetMessages[type as keyof typeof p2ceNetMessages]; + const msg = descriptor.decode(new Uint8Array(data.readArrayBuffer(size))) as nm.CSVCMsgSendTable; + dataTable.tables.push(msg); + if (msg.isEnd) { + break; + } + } + + let classes = data.readInt16() ?? 0; + while (classes--) { + const sc = new ServerClassInfo(); + sc.read(data); + //console.log(dataTable.tables.find((table) => table.netTableName === sc.dataTableName)); + dataTable.serverClasses.push(sc); + } + + if (data.bitsLeft) { + dataTable.restData = data.readBitStream(data.bitsLeft); + } + + message.dataTable = dataTable; + } + } + + return this; + } +} + +export class StrataSourceDemoParser extends SourceDemoParser { + static override default() { + return new this(); + } + override parse(buffer: ArrayBuffer) { + const buf = this.prepare(buffer); + const demo = StrataSourceDemo.default(); + + if (this.options.header) demo.readHeader(buf); + if (this.options.messages) demo.readMessages(buf); + + if (demo.messages?.length) { + if (this.options.stringTables) demo.readStringTables(); + if (this.options.dataTables) demo.readDataTables(); + if (this.options.packets) demo.readPackets(); + if (this.options.userCmds) demo.readUserCmds(); + } + + return demo; + } +} + +const file = Deno.args.at(0); +if (!file) { + console.error('demo path argument not specified!'); + Deno.exit(1); +} + +const demo = StrataSourceDemoParser.default() + .parse(Deno.readFileSync(file)); + +demo.readPackets(); +//demo.readDataTables(); +demo.readStringTables(); + +console.dir( + demo.findMessage((packet) => packet.getName() === 'StringTable') + ?.stringTables + ?.find((x) => x.name === 'instancebaseline'), +); diff --git a/examples/jump_stats.ts b/examples/info/jump_stats.ts similarity index 95% rename from examples/jump_stats.ts rename to examples/info/jump_stats.ts index 36f0004..3f80ed9 100644 --- a/examples/jump_stats.ts +++ b/examples/info/jump_stats.ts @@ -1,7 +1,6 @@ -import { DemoMessages, SourceDemoParser } from 'npm:@nekz/sdp'; +import { DemoMessages, SourceDemoParser } from '../../src/mod.ts'; const file = Deno.args.at(0); - if (!file) { console.error('demo path argument not specified!'); Deno.exit(1); diff --git a/examples/info/sar_data.ts b/examples/info/sar_data.ts new file mode 100644 index 0000000..6ec2493 --- /dev/null +++ b/examples/info/sar_data.ts @@ -0,0 +1,21 @@ +import { SourceDemoParser } from '../../src/mod.ts'; +import { readSarData, SarDataType } from '../../src/utils/mod.ts'; + +const file = Deno.args.at(0); +if (!file) { + console.error('[-] Demo path argument not specified.'); + Deno.exit(1); +} + +const demo = SourceDemoParser.default() + .parse(Deno.readFileSync(file)); + +const { messages } = readSarData(demo); + +const message = messages.find(({ type }) => type === SarDataType.SpeedrunTime); +if (!message) { + console.log('[-] No speedrun time found.'); + Deno.exit(1); +} + +console.log('[+] Found speedrun time', message.speedrunTime); diff --git a/examples/info/steam_id.ts b/examples/info/steam_id.ts new file mode 100644 index 0000000..0d0b1f8 --- /dev/null +++ b/examples/info/steam_id.ts @@ -0,0 +1,69 @@ +import { Messages, SourceDemo, SourceDemoParser } from '../../src/mod.ts'; +import { PlayerInfo, StringTableEntry } from '../../src/types/mod.ts'; +import { getPlayerSteamData, SteamIdResult } from '../../src/utils/steam.ts'; + +const file = Deno.args.at(0); +if (!file) { + console.error('[-] Demo path argument not specified.'); + Deno.exit(1); +} + +const buffer = Deno.readFileSync(file); +const parser = SourceDemoParser.default(); + +const buf = parser + .prepare(buffer); + +const demo = SourceDemo.default(); + +try { + demo.readHeader(buf).readMessages(buf); +} catch { +} + +demo.readStringTables(); + +const message = demo.findMessage(Messages.StringTable); +const isHost = demo.serverName!.startsWith('localhost'); + +const printResult = (entry: StringTableEntry) => { + const [steamData, result] = getPlayerSteamData(entry); + + switch (result) { + case SteamIdResult.Ok: { + console.log('[+] Found Steam profile', { + ...steamData, + steamUrl: steamData ? `https://steamcommunity.com/profiles/${steamData.steamId}` : null, + }); + break; + } + case SteamIdResult.NoPlayerInfoGuid: { + console.log('[-] Found missing player info guid'); + break; + } + case SteamIdResult.InvalidSteamId: { + console.log('[-] Invalid Steam ID:', steamData); + break; + } + } +}; + +for (const stringTable of message?.stringTables ?? []) { + const entries = stringTable.entries ?? []; + const playerInfos = entries.filter((entry) => entry.data instanceof PlayerInfo); + + if (!playerInfos.length) { + continue; + } + + const host = playerInfos.at(isHost ? 0 : 1); + const partner = playerInfos.at(isHost ? 1 : 0); + + host && printResult(host); + partner && printResult(partner); + + Deno.exit(0); +} + +console.log('[-] Unable to parse player info.'); +Deno.exit(1); diff --git a/examples/user_messages.ts b/examples/info/user_messages.ts similarity index 78% rename from examples/user_messages.ts rename to examples/info/user_messages.ts index a54d288..94fb49b 100644 --- a/examples/user_messages.ts +++ b/examples/info/user_messages.ts @@ -1,7 +1,7 @@ -import { NetMessages, SourceDemoParser } from '../src/mod.ts'; +import { SourceDemoParser } from '../../src/mod.ts'; +import { SvcUserMessage } from '../../src/types/mod.ts'; const file = Deno.args.at(0); - if (!file) { console.error('[-] Demo path argument not specified!'); Deno.exit(1); @@ -12,14 +12,14 @@ const demo = SourceDemoParser.default() .parse(Deno.readFileSync(file)); const userMessages = demo - .findPackets(NetMessages.SvcUserMessage); + .findPackets(SvcUserMessage); const unique = new Set(); for (const { userMessage, msgDataLength } of userMessages) { const name = userMessage!.getName(); if (unique.has(name)) { - continue; + //continue; } unique.add(name); diff --git a/examples/jump_stats.mjs b/examples/node/jump_stats.mjs similarity index 99% rename from examples/jump_stats.mjs rename to examples/node/jump_stats.mjs index f9d8e70..d3f6a97 100644 --- a/examples/jump_stats.mjs +++ b/examples/node/jump_stats.mjs @@ -2,7 +2,6 @@ import fs from 'node:fs'; import { DemoMessages, SourceDemoParser } from '@nekz/sdp'; const file = process.argv.at(2); - if (!file) { console.error('demo path argument not specified!'); process.exit(1); diff --git a/examples/package-lock.json b/examples/node/package-lock.json similarity index 100% rename from examples/package-lock.json rename to examples/node/package-lock.json diff --git a/examples/package.json b/examples/node/package.json similarity index 100% rename from examples/package.json rename to examples/node/package.json diff --git a/examples/parser.html b/examples/parser.html deleted file mode 100644 index 4f581bc..0000000 --- a/examples/parser.html +++ /dev/null @@ -1,1050 +0,0 @@ - - - - - - Demo Parser | nekz.me - - - - - - - - - - -
-
-
-
-
-
- folder_open - -
- -
-
-     -
- show_chart -
-
-
-
-

-
-
-
-
-

-
Header
- - -
-
-
-
-
-

-
Inputs
- -
-
-
-
-
Commands
-
-
-
-
- - -
-
-
-
- - -
-
-
-
-
-
-
-
- - - - - - - - - - - - - - - - - -
MapClientTicksTimeTotal TicksTotal Time
Drag & drop files here.
-
-
-
-
-
-
- add - -
- -
-
-     -
- clear_all -
-     -
- save -
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- add - -
- -
-
-     -
- clear_all -
-
-
-
-
-
-
-
-
-
-

sdp

-

- Simple Source Engine demo parser. -

-
-
Features
-
    -
  • •   Support for protocol 2, 3 and 4
  • -
  • •   Automatic tick adjustment with rules defined by speedrunning communities
  • -
  • •   Console command inspection with filter function
  • -
  • •   Demo listing and csv exporter
  • -
  • •   Camera position in 3D plot
  • -
  • •   Button inputs view
  • -
  • - •   SourceAutoRecord - timing -
  • -
-
-

- Special thanks to spidda for testing this first! -

-
-
-
-
- - - - - - - diff --git a/examples/steam_id.ts b/examples/steam_id.ts deleted file mode 100644 index 9b919d3..0000000 --- a/examples/steam_id.ts +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2024, NeKz - * - * SPDX-License-Identifier: MIT - * - * This example finds the Steam ID of the players. - */ - -import { Messages, SourceDemoParser, StringTables } from '../src/mod.ts'; - -export enum SteamIdUniverse { - Individual = 0, - Public = 1, - Beta = 2, - Internal = 3, - Dev = 4, - Rc = 5, -} - -export enum SteamIdType { - Invalid = 0, - Individual = 1, - Multiseat = 2, - GameServer = 3, - AnonGameServer = 4, - Pending = 5, - ContentServer = 6, - Clan = 7, - Chat = 8, - P2PSuperSeeder = 9, - AnonUser = 10, -} - -export enum SteamIdInstance { - All = 0, - Desktop = 1, - Console = 2, - Web = 4, -} - -export class SteamId { - universe = BigInt(SteamIdUniverse.Public); - type = BigInt(SteamIdType.Individual); - instance = BigInt(SteamIdInstance.Desktop); - account = 0n; - isValid = false; - - constructor(props?: { account: bigint; universe: bigint; isValid: boolean }) { - Object.assign(this, props); - } - - static from(steamId: string) { - const groups = steamId.match(/^STEAM\_([0-9]+)\:([0-9]+)\:([0-9]+)$/); - if (groups) { - const [x, y, z] = groups.slice(1).map((value) => BigInt(value)); - - return new this({ - account: (z! << 1n) | y!, - universe: x!, - isValid: true, - }); - } - - return new this(); - } - - toSteamId64() { - return this.isValid - ? (this.universe << 56n) | (this.type << 52n) | (this.instance << 32n) | this.account - : null; - } -} - -const file = Deno.args.at(0); -if (!file) { - console.error('[-] Demo path argument not specified.'); - Deno.exit(1); -} - -const buffer = Deno.readFileSync(file); -const parser = SourceDemoParser.default(); - -const demo = parser - .setOptions({ stringTables: true }) - .parse(buffer); - -const extractSteamData = (playerInfo?: StringTables.StringTableEntry): [string | null, string | null] => { - if (!playerInfo) { - return [null, null]; - } - - const guid = playerInfo.data?.guid; - if (guid === undefined) { - console.error(`Found undefined player info GUID`); - return [null, null]; - } - - const steamId = SteamId.from(guid).toSteamId64(); - if (steamId === null) { - console.error(`Found invalid SteamID: ${guid}`); - } - - const playerName = playerInfo.data?.name; - - return [ - playerName ? decodeURIComponent(escape(playerName)) : null, - steamId?.toString() ?? null, - ]; -}; - -const message = demo.findMessage(Messages.StringTable); -const isHost = demo.serverName!.startsWith('localhost'); - -for (const stringTable of message?.stringTables ?? []) { - const entries = stringTable.entries ?? []; - const playerInfos = entries.filter((entry) => entry.data instanceof StringTables.PlayerInfo); - - if (!playerInfos.length) { - continue; - } - - const host = playerInfos.at(isHost ? 0 : 1); - const partner = playerInfos.at(isHost ? 1 : 0); - - const [playerName, steamId] = extractSteamData(host); - const [partnerPlayerName, partnerSteamId] = extractSteamData(partner); - - console.log({ - playerName, - steamId, - steamUrl: steamId ? `https://steamcommunity.com/profiles/${steamId}` : null, - partnerPlayerName, - partnerSteamId, - partnerSteamUrl: partnerSteamId ? `https://steamcommunity.com/profiles/${partnerSteamId}` : null, - }); - - break; -} diff --git a/examples/fixup.ts b/examples/tools/fixup.ts similarity index 86% rename from examples/fixup.ts rename to examples/tools/fixup.ts index ff71d0d..1bf77f4 100644 --- a/examples/fixup.ts +++ b/examples/tools/fixup.ts @@ -1,14 +1,11 @@ -/* - * Copyright (c) 2023, NeKz - * - * SPDX-License-Identifier: MIT - * - * This fixes old Portal 2 demos to make them playable again. - * Research based on: https://github.com/p2sr/demofixup - */ - -import { basename, dirname, join } from 'https://deno.land/std@0.140.0/path/posix.ts'; -import { Messages, SourceDemoParser } from '../src/mod.ts'; +// Copyright (c) 2023-2024, NeKz +// SPDX-License-Identifier: MIT + +// This fixes old Portal 2 demos to make them playable again. +// Research based on: https://github.com/p2sr/demofixup + +import { basename, dirname, join } from 'jsr:@std/path'; +import { Messages, SourceDemoParser } from '../../src/mod.ts'; const file = Deno.args.at(0); if (!file) { diff --git a/examples/repair.ts b/examples/tools/repair.ts similarity index 92% rename from examples/repair.ts rename to examples/tools/repair.ts index a8d09b7..96f5102 100644 --- a/examples/repair.ts +++ b/examples/tools/repair.ts @@ -1,16 +1,13 @@ -/* - * Copyright (c) 2024, NeKz - * - * SPDX-License-Identifier: MIT - * - * This repairs demos which: - * - contain pauses causing the game to freeze - * - are still running after a coop challenge mode run has finished - * - end abruptly causing an incorrect demo header and corrupted last message - * - are unplayable because of a patch that removed the CPointSurvey entity class - */ - -import { basename, dirname, join } from 'https://deno.land/std@0.140.0/path/posix.ts'; +// Copyright (c) 2024, NeKz +// SPDX-License-Identifier: MIT + +// This repairs demos which: +// - contain pauses causing the game to freeze +// - are still running after a coop challenge mode run has finished +// - end abruptly causing an incorrect demo header and corrupted last message +// - are unplayable because of a patch that removed the CPointSurvey entity class + +import { basename, dirname, join } from 'jsr:@std/path'; import { DemoMessages, Messages, @@ -19,7 +16,7 @@ import { SourceDemo, SourceDemoBuffer, SourceDemoParser, -} from '../src/mod.ts'; +} from '../../src/mod.ts'; const file = Deno.args.at(0); const options = Deno.args.at(1)?.toLowerCase() ?? ''; diff --git a/examples/web/parser.html b/examples/web/parser.html new file mode 100644 index 0000000..942f2a5 --- /dev/null +++ b/examples/web/parser.html @@ -0,0 +1,1103 @@ + + + + + Demo Parser | nekz.me + + + + + + + + + + +
+
+
+
+
+
+ folder_open + +
+ +
+
+     +
+ show_chart +
+
+
+
+

+
+
+
+
+

+
Header
+ + +
+
+
+
+
+

+
Inputs
+ +
+
+
+
+
Commands
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + +
MapClientTicksTimeTotal TicksTotal Time
Drag & drop files here.
+
+
+
+
+
+
+ add + +
+ +
+
+     +
+ clear_all +
+     +
+ save +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ add + +
+ +
+
+     +
+ clear_all +
+
+
+
+
+
+
+
+
+
+

sdp

+

+ Simple Source Engine demo parser. +

+
+
Features
+
    +
  • •   Support for protocol 2, 3 and 4
  • +
  • + •   Automatic tick adjustment with rules defined by speedrunning + communities +
  • +
  • •   Console command inspection with filter function
  • +
  • •   Demo listing and csv exporter
  • +
  • •   Camera position in 3D plot
  • +
  • •   Button inputs view
  • +
  • + •   SourceAutoRecord + timing +
  • +
+
+

+ Special thanks to spidda for testing this first! +

+
+
+
+
+ + + + + + diff --git a/scripts/build_dist.ts b/scripts/build_dist.ts index cc8d0a4..a096238 100644 --- a/scripts/build_dist.ts +++ b/scripts/build_dist.ts @@ -1,10 +1,7 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT -import { bundle } from 'https://deno.land/x/emit@0.24.0/mod.ts'; +import { bundle } from 'jsr:@deno/emit@0.46.0'; // This is about 9 times slower than esbuild without minification lol. // However, both don't support npm specifiers but deno_emit will support them diff --git a/scripts/build_esbuild.ts b/scripts/build_esbuild.ts index 56c79fb..6195036 100644 --- a/scripts/build_esbuild.ts +++ b/scripts/build_esbuild.ts @@ -1,11 +1,8 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT -import * as esbuild from 'https://deno.land/x/esbuild@v0.17.19/mod.js'; -import { denoPlugins } from 'https://deno.land/x/esbuild_deno_loader@0.8.1/mod.ts'; +import * as esbuild from 'npm:esbuild@0.24.0'; +import { denoPlugins } from 'jsr:@luca/esbuild-deno-loader@0.11.0'; // Esbuild is fast! go > rust? I guess it's WASM... diff --git a/scripts/build_npm.ts b/scripts/build_npm.ts index 9db0928..453495f 100644 --- a/scripts/build_npm.ts +++ b/scripts/build_npm.ts @@ -1,11 +1,8 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT -import { build, emptyDir } from 'https://deno.land/x/dnt@0.37.0/mod.ts'; -import { copy } from 'https://deno.land/std@0.191.0/fs/copy.ts'; +import { build, emptyDir } from 'jsr:@deno/dnt@0.41.3'; +import { copy } from 'jsr:@std/fs@1.0.5'; const version = Deno.args[0]; if (!version) { diff --git a/src/buffer.ts b/src/buffer.ts index 8143c54..5507294 100644 --- a/src/buffer.ts +++ b/src/buffer.ts @@ -1,10 +1,7 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT -import { BitStream, BitView } from './lib/bit-buffer.ts'; +import { BitStream, type BitView } from './lib/bit-buffer.ts'; import { QAngle } from './types/QAngle.ts'; import { Vector } from './types/Vector.ts'; @@ -16,54 +13,58 @@ export class SourceDemoBuffer extends BitStream { ) { super(source, byteOffset, byteLength); } - static from(buffer: SourceDemoBuffer) { + static from(buffer: SourceDemoBuffer): SourceDemoBuffer { const copy = new SourceDemoBuffer(buffer.view); copy._index = buffer._index; copy._startIndex = buffer._startIndex; copy._length = buffer._length; return copy; } - static allocate(bytes: number) { + static allocate(bytes: number): SourceDemoBuffer { return new SourceDemoBuffer(new ArrayBuffer(bytes)); } - static allocateBits(bits: number) { + static allocateBits(bits: number): SourceDemoBuffer { if ((bits % 8) !== 0) { throw new Error('Number of bits to allocate is not aligned!'); } return new SourceDemoBuffer(new ArrayBuffer(bits / 8)); } - clone() { + clone(): SourceDemoBuffer { return new SourceDemoBuffer(this.view); } - reset() { + reset(): SourceDemoBuffer { this._index = this._startIndex; return this; } - readVector() { + // TODO: implementation + readVarInt32(): number { + throw new Error('Not implemented yet!'); + } + readVector(): Vector { return new Vector( this.readFloat32(), this.readFloat32(), this.readFloat32(), ); } - writeVector(vec: Vector) { + writeVector(vec: Vector): void { this.writeFloat32(vec.x!); this.writeFloat32(vec.y!); this.writeFloat32(vec.z!); } - readQAngle() { + readQAngle(): QAngle { return new QAngle( this.readFloat32(), this.readFloat32(), this.readFloat32(), ); } - writeQAngle(ang: QAngle) { + writeQAngle(ang: QAngle): void { this.writeFloat32(ang.pitch!); this.writeFloat32(ang.yaw!); this.writeFloat32(ang.roll!); } - readCoord() { + readCoord(): number { const COORD_INTEGER_BITS = 14; const COORD_FRACTIONAL_BITS = 5; const COORD_DENOMINATOR = 1 << COORD_FRACTIONAL_BITS; @@ -86,7 +87,7 @@ export class SourceDemoBuffer extends BitStream { return value; } - writeCoord(value: number) { + writeCoord(value: number): void { const COORD_INTEGER_BITS = 14; const COORD_FRACTIONAL_BITS = 5; const COORD_DENOMINATOR = 1 << COORD_FRACTIONAL_BITS; @@ -111,7 +112,7 @@ export class SourceDemoBuffer extends BitStream { } } } - readVectorCoord() { + readVectorCoord(): Vector { const [x, y, z] = [ this.readBoolean(), this.readBoolean(), @@ -123,7 +124,7 @@ export class SourceDemoBuffer extends BitStream { z ? this.readCoord() : 0, ); } - writeVectorCoord(vec: Vector) { + writeVectorCoord(vec: Vector): void { const COORD_FRACTIONAL_BITS = 5; const COORD_DENOMINATOR = 1 << COORD_FRACTIONAL_BITS; const COORD_RESOLUTION = 1.0 / COORD_DENOMINATOR; @@ -142,17 +143,17 @@ export class SourceDemoBuffer extends BitStream { y && this.writeCoord(vec.y); z && this.writeCoord(vec.z); } - readAngles() { + readAngles(): QAngle { const { x, y, z } = this.readVectorCoord(); return new QAngle(x, y, z); } - writeAngles(angle: QAngle) { + writeAngles(angle: QAngle): void { return this.writeVectorCoord(new Vector(angle.pitch, angle.yaw, angle.roll)); } - readField(bits: number, fallbackValue = 0) { + readField(bits: number, fallbackValue = 0): number { return this.readBoolean() ? this.readBits(bits) : fallbackValue; } - writeField(field: number, bits: number, fallbackValue = 0) { + writeField(field: number, bits: number, fallbackValue = 0): void { this.writeBoolean(field !== fallbackValue); if (field !== fallbackValue) { this.writeBits(field, bits); @@ -162,7 +163,7 @@ export class SourceDemoBuffer extends BitStream { bits: number, fallbackValue: number, callback: (bits: number) => void, - ) { + ): number | void { return this.readBoolean() ? callback(this.readBits(bits)) : fallbackValue; } writeFieldThen( @@ -170,14 +171,14 @@ export class SourceDemoBuffer extends BitStream { bits: number, fallbackValue: number, callback: (bits: number) => void, - ) { + ): void { this.writeBoolean(field !== fallbackValue); if (field !== fallbackValue) { this.writeBits(field, bits); callback(field); } } - readBitStream(bitLength: number) { + override readBitStream(bitLength: number): SourceDemoBuffer { const slice = new SourceDemoBuffer(this._view); slice._startIndex = this._index; slice._index = this._index; @@ -185,7 +186,7 @@ export class SourceDemoBuffer extends BitStream { this._index += bitLength; return slice; } - writeBitStream(stream: BitStream, length: number) { + override writeBitStream(stream: BitStream, length: number): void { if (!length) { length = stream.bitsLeft; } @@ -200,7 +201,7 @@ export class SourceDemoBuffer extends BitStream { length -= bitsToWrite; } } - writeArrayBuffer(buffer: ArrayBuffer, byteLength: number) { + override writeArrayBuffer(buffer: ArrayBuffer, byteLength: number): void { this.writeBitStream(new SourceDemoBuffer(buffer), byteLength * 8); } } diff --git a/src/demo.ts b/src/demo.ts index b2a9dec..1e02e7a 100644 --- a/src/demo.ts +++ b/src/demo.ts @@ -1,8 +1,5 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT import { DataTable, DemoMessages, Message, Packet, SyncTick } from './messages.ts'; import { SendTable, ServerClassInfo } from './types/DataTables.ts'; @@ -10,8 +7,8 @@ import { NetMessage, NetMessages } from './types/NetMessages.ts'; import { StringTable } from './types/StringTables.ts'; import { UserCmd } from './types/UserCmd.ts'; import { SourceDemoBuffer } from './buffer.ts'; -import { GameEventManager } from './types/GameEventManager.ts'; -import { SourceGame } from './speedrun/games/SourceGame.ts'; +import type { GameEventManager } from './types/GameEventManager.ts'; +import type { SourceGame } from './speedrun/games/SourceGame.ts'; import { SourceGames } from './speedrun/games/mod.ts'; export const Portal2EngineGameMods = [ @@ -39,25 +36,27 @@ export class SourceDemo { game?: SourceGame; gameEventManager?: GameEventManager; isPortal2Engine = false; - static default() { + static default(): SourceDemo { return new this(); } - isNewEngine() { + isNewEngine(): boolean { return this.demoProtocol === 4; } - findMessage(type: (new (type: number) => T) | ((msg: Message) => boolean)) { + findMessage(type: (new (type: number) => T) | ((msg: Message) => boolean)): T | undefined { const byType = type.prototype instanceof Message ? (msg: Message) => msg instanceof type : (msg: Message) => (type as unknown as (msg: Message) => boolean)(msg); return (this.messages ?? []).find(byType) as T | undefined; } - findMessages(type: (new (type: number) => T) | ((msg: Message) => boolean)) { + findMessages(type: (new (type: number) => T) | ((msg: Message) => boolean)): T[] { const byType = type.prototype instanceof Message ? (msg: Message) => msg instanceof type : (msg: Message) => (type as unknown as (msg: Message) => boolean)(msg); return (this.messages ?? []).filter(byType) as T[]; } - findPacket(type: (new (type: number) => T) | ((packet: NetMessage) => boolean)) { + findPacket( + type: (new (type: number) => T) | ((packet: NetMessage) => boolean), + ): T | undefined { const byType = type.prototype instanceof NetMessage ? (packet: NetMessage) => packet instanceof type : (packet: NetMessage) => (type as unknown as (msg: NetMessage) => boolean)(packet); @@ -71,7 +70,7 @@ export class SourceDemo { } } } - findPackets(type: (new (type: number) => T) | ((packet: NetMessage) => boolean)) { + findPackets(type: (new (type: number) => T) | ((packet: NetMessage) => boolean)): T[] { const isType = type.prototype instanceof NetMessage ? (packet: NetMessage) => packet instanceof type : (packet: NetMessage) => (type as unknown as (msg: NetMessage) => boolean)(packet); @@ -88,7 +87,7 @@ export class SourceDemo { } return packets; } - readHeader(buf: SourceDemoBuffer) { + readHeader(buf: SourceDemoBuffer): SourceDemo { this.demoFileStamp = buf.readASCIIString(8); if (this.demoFileStamp !== 'HL2DEMO') { throw new Error(`Invalid demo file stamp: ${this.demoFileStamp}`); @@ -107,7 +106,7 @@ export class SourceDemo { this.isPortal2Engine = Portal2EngineGameMods.includes(this.gameDirectory); return this; } - writeHeader(buf: SourceDemoBuffer) { + writeHeader(buf: SourceDemoBuffer): SourceDemo { buf.writeASCIIString(this.demoFileStamp!); buf.writeInt32(this.demoProtocol!); buf.writeInt32(this.networkProtocol!); @@ -121,7 +120,7 @@ export class SourceDemo { buf.writeInt32(this.signOnLength!); return this; } - readMessages(buf: SourceDemoBuffer) { + readMessages(buf: SourceDemoBuffer): SourceDemo { if (!this.messages) { this.messages = []; } @@ -147,7 +146,7 @@ export class SourceDemo { return this; } - writeMessages(buf: SourceDemoBuffer) { + writeMessages(buf: SourceDemoBuffer): void { (this.messages ?? []).forEach((message) => { buf.writeInt8(message.type); buf.writeInt32(message.tick!); @@ -159,7 +158,7 @@ export class SourceDemo { message.write(buf, this); }); } - readUserCmds() { + readUserCmds(): SourceDemo { for (const message of this.messages ?? []) { if (message instanceof DemoMessages.UserCmd) { const data = SourceDemoBuffer.from(message.data!); @@ -175,7 +174,7 @@ export class SourceDemo { return this; } - writeUserCmds() { + writeUserCmds(): SourceDemo { for (const message of this.messages ?? []) { if (message instanceof DemoMessages.UserCmd && message.userCmd) { const data = SourceDemoBuffer.allocateBits(message.data!.length); @@ -191,7 +190,7 @@ export class SourceDemo { return this; } - readStringTables() { + readStringTables(): SourceDemo { for (const message of this.messages ?? []) { if (message instanceof DemoMessages.StringTable) { const stringTables = []; @@ -215,7 +214,7 @@ export class SourceDemo { return this; } - writeStringTables() { + writeStringTables(): SourceDemo { for (const message of this.messages ?? []) { if (message instanceof DemoMessages.StringTable && message.stringTables) { const data = SourceDemoBuffer.allocateBits(message.data!.length); @@ -236,7 +235,7 @@ export class SourceDemo { return this; } - readDataTables() { + readDataTables(): SourceDemo { for (const message of this.messages ?? []) { if (message instanceof DataTable) { const dataTable: { @@ -274,7 +273,7 @@ export class SourceDemo { return this; } - writeDataTables() { + writeDataTables(): SourceDemo { for (const message of this.messages ?? []) { if (message instanceof DataTable && message.dataTable) { const data = SourceDemoBuffer.allocateBits(message.data!.length); @@ -300,7 +299,7 @@ export class SourceDemo { return this; } - readPackets(netMessages?: (typeof NetMessage | undefined)[]) { + readPackets(netMessages?: (typeof NetMessage | undefined)[]): SourceDemo { netMessages = netMessages ?? (this.isNewEngine() ? NetMessages.Portal2Engine : NetMessages.HalfLife2Engine); @@ -332,7 +331,7 @@ export class SourceDemo { return this; } - writePackets() { + writePackets(): SourceDemo { for (const message of this.messages ?? []) { if (message instanceof Packet && message.packets) { const data = SourceDemoBuffer.allocateBits(message.data!.length); @@ -352,13 +351,13 @@ export class SourceDemo { return this; } - detectGame(sourceGames = SourceGames) { + detectGame(sourceGames = SourceGames): SourceDemo { this.game = sourceGames.find( (game) => game.directory === this.gameDirectory, ); return this; } - getIntervalPerTick() { + getIntervalPerTick(): number { if (this.playbackTicks === undefined || this.playbackTime === undefined) { throw new Error('Cannot find tickrate without parsing the header.'); } @@ -370,7 +369,7 @@ export class SourceDemo { } return this.playbackTime / this.playbackTicks; } - getTickrate() { + getTickrate(): number { if (this.playbackTicks === undefined || this.playbackTime === undefined) { throw new Error('Cannot find tickrate without parsing the header.'); } @@ -382,7 +381,7 @@ export class SourceDemo { } return this.playbackTicks / this.playbackTime; } - adjustTicks() { + adjustTicks(): SourceDemo { if (!this.messages?.length) { throw new Error('Cannot adjust ticks without parsed messages.'); } @@ -404,7 +403,7 @@ export class SourceDemo { return this; } - adjustRange(endTick = 0, startTick = 0, tickrate: number | undefined = undefined) { + adjustRange(endTick = 0, startTick = 0, tickrate: number | undefined = undefined): SourceDemo { if (!this.messages?.length) { throw new Error('Cannot adjust range without parsed messages.'); } @@ -429,7 +428,7 @@ export class SourceDemo { return this; } - rebaseFrom(tick: number) { + rebaseFrom(tick: number): SourceDemo { if (!this.messages?.length) { throw new Error('Cannot adjust ticks without parsed messages.'); } @@ -454,7 +453,14 @@ export class SourceDemo { return this; } - getSyncedTicks(demo: SourceDemo, viewTolerance = 1, splitScreenIndex = 0) { + getSyncedTicks(demo: SourceDemo, viewTolerance = 1, splitScreenIndex = 0): { + source: number | undefined; + destination: number | undefined; + delta: number; + x: number | undefined; + y: number | undefined; + z: number | undefined; + }[] { if (!this.messages?.length || !demo.messages?.length) { throw new Error('Cannot adjust ticks without parsed messages.'); } diff --git a/src/lib/bit-buffer.ts b/src/lib/bit-buffer.ts index d9f6a3f..5114f22 100644 --- a/src/lib/bit-buffer.ts +++ b/src/lib/bit-buffer.ts @@ -2,7 +2,7 @@ * MIT License * * Copyright (c) 2020, bit-buffer developers - * Copyright (c) 2023, NeKz + * Copyright (c) 2023-2024, NeKz * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -62,25 +62,25 @@ export class BitView { // Used to massage fp values so we can operate on them // at the bit level. - _scratch = new DataView(new ArrayBuffer(8)); + _scratch: DataView = new DataView(new ArrayBuffer(8)); - get buffer() { + get buffer(): ArrayBufferLike { return this._view.buffer; } - get byteLength() { + get byteLength(): number { return this._view.length; } - _setBit(offset: number, on: boolean) { + _setBit(offset: number, on: boolean): void { if (on) { - this._view[offset >> 3] |= 1 << (offset & 7); + this._view[offset >> 3]! |= 1 << (offset & 7); } else { - this._view[offset >> 3] &= ~(1 << (offset & 7)); + this._view[offset >> 3]! &= ~(1 << (offset & 7)); } } - getBits(offset: number, bits: number, signed?: boolean) { + getBits(offset: number, bits: number, signed?: boolean): number { const available = this._view.length * 8 - offset; if (bits > available) { @@ -133,7 +133,7 @@ export class BitView { return value >>> 0; } - setBits(offset: number, value: number, bits: number) { + setBits(offset: number, value: number, bits: number): void { const available = this._view.length * 8 - offset; if (bits > available) { @@ -177,69 +177,69 @@ export class BitView { } } - getBoolean(offset: number) { + getBoolean(offset: number): boolean { return this.getBits(offset, 1, false) !== 0; } - getInt8(offset: number) { + getInt8(offset: number): number { return this.getBits(offset, 8, true); } - getUint8(offset: number) { + getUint8(offset: number): number { return this.getBits(offset, 8, false); } - getInt16(offset: number) { + getInt16(offset: number): number { return this.getBits(offset, 16, true); } - getUint16(offset: number) { + getUint16(offset: number): number { return this.getBits(offset, 16, false); } - getInt32(offset: number) { + getInt32(offset: number): number { return this.getBits(offset, 32, true); } - getUint32(offset: number) { + getUint32(offset: number): number { return this.getBits(offset, 32, false); } - getFloat32(offset: number) { + getFloat32(offset: number): number { this._scratch.setUint32(0, this.getUint32(offset)); return this._scratch.getFloat32(0); } - getFloat64(offset: number) { + getFloat64(offset: number): number { this._scratch.setUint32(0, this.getUint32(offset)); // DataView offset is in bytes. this._scratch.setUint32(4, this.getUint32(offset + 32)); return this._scratch.getFloat64(0); } - setBoolean(offset: number, value: boolean) { + setBoolean(offset: number, value: boolean): void { this.setBits(offset, value ? 1 : 0, 1); } - setInt8(offset: number, value: number) { + setInt8(offset: number, value: number): void { this.setBits(offset, value, 8); } - setUint8(offset: number, value: number) { + setUint8(offset: number, value: number): void { this.setBits(offset, value, 8); } - setInt16(offset: number, value: number) { + setInt16(offset: number, value: number): void { this.setBits(offset, value, 16); } - setUint16(offset: number, value: number) { + setUint16(offset: number, value: number): void { this.setBits(offset, value, 16); } - setInt32(offset: number, value: number) { + setInt32(offset: number, value: number): void { this.setBits(offset, value, 32); } - setUint32(offset: number, value: number) { + setUint32(offset: number, value: number): void { this.setBits(offset, value, 32); } - setFloat32(offset: number, value: number) { + setFloat32(offset: number, value: number): void { this._scratch.setFloat32(0, value); this.setBits(offset, this._scratch.getUint32(0), 32); } - setFloat64(offset: number, value: number) { + setFloat64(offset: number, value: number): void { this._scratch.setFloat64(0, value); this.setBits(offset, this._scratch.getUint32(0), 32); this.setBits(offset + 32, this._scratch.getUint32(4), 32); } - getArrayBuffer(offset: number, byteLength: number) { + getArrayBuffer(offset: number, byteLength: number): Uint8Array { const buffer = new Uint8Array(byteLength); for (let i = 0; i < byteLength; ++i) { buffer[i] = this.getUint8(offset + i * 8); @@ -312,42 +312,42 @@ export class BitStream { protected _startIndex: number; protected _length: number; - get offset() { + get offset(): number { return this._index; } - get index() { + get index(): number { return this._index - this._startIndex; } set index(val: number) { this._index = val + this._startIndex; } - get length() { + get length(): number { return this._length - this._startIndex; } set length(val: number) { this._length = val + this._startIndex; } - get bitsLeft() { + get bitsLeft(): number { return this._length - this._index; } // Ceil the returned value, over compensating for the amount of // bits written to the stream. - get byteIndex() { + get byteIndex(): number { return Math.ceil(this._index / 8); } set byteIndex(val: number) { this._index = val * 8; } - get buffer() { + get buffer(): ArrayBufferLike { return this._view.buffer; } - get view() { + get view(): BitView { return this._view; } - get bigEndian() { + get bigEndian(): boolean { return this._view.bigEndian; } set bigEndian(val: boolean) { @@ -357,7 +357,7 @@ export class BitStream { protected reader< T extends number | boolean, F extends (offset: number) => T = (offset: number) => T, - >(name: keyof BitView, size: number) { + >(name: keyof BitView, size: number): () => T { return () => { if (this._index + size > this._length) { throw new Error('Trying to read past the end of the stream'); @@ -376,7 +376,7 @@ export class BitStream { offset: number, value: T, ) => void, - >(name: keyof BitView, size: number) { + >(name: keyof BitView, size: number): (value: T) => void { return (value: T) => { (this._view as unknown as Record)[name]( this._index, @@ -386,7 +386,7 @@ export class BitStream { }; } - protected readString(bytes?: number, utf8?: boolean) { + protected readString(bytes?: number, utf8?: boolean): string { if (bytes === 0) { return ''; } @@ -431,54 +431,54 @@ export class BitStream { } } - readBits(bits: number, signed?: boolean) { + readBits(bits: number, signed?: boolean): number { const val = this._view.getBits(this._index, bits, signed); this._index += bits; return val; } - peakBits(offset: number, bits: number, signed?: boolean) { + peakBits(offset: number, bits: number, signed?: boolean): number { const val = this._view.getBits(offset, bits, signed); return val; } - writeBits(value: number, bits: number) { + writeBits(value: number, bits: number): void { this._view.setBits(this._index, value, bits); this._index += bits; } - readBoolean = this.reader('getBoolean', 1); - readInt8 = this.reader('getInt8', 8); - readUint8 = this.reader('getUint8', 8); - readInt16 = this.reader('getInt16', 16); - readUint16 = this.reader('getUint16', 16); - readInt32 = this.reader('getInt32', 32); - readUint32 = this.reader('getUint32', 32); - readFloat32 = this.reader('getFloat32', 32); - readFloat64 = this.reader('getFloat64', 64); - - writeBoolean = this.writer('setBoolean', 1); - writeInt8 = this.writer('setInt8', 8); - writeUint8 = this.writer('setUint8', 8); - writeInt16 = this.writer('setInt16', 16); - writeUint16 = this.writer('setUint16', 16); - writeInt32 = this.writer('setInt32', 32); - writeUint32 = this.writer('setUint32', 32); - writeFloat32 = this.writer('setFloat32', 32); - writeFloat64 = this.writer('setFloat64', 64); - - readASCIIString(bytes?: number) { + readBoolean: () => boolean = this.reader('getBoolean', 1); + readInt8: () => number = this.reader('getInt8', 8); + readUint8: () => number = this.reader('getUint8', 8); + readInt16: () => number = this.reader('getInt16', 16); + readUint16: () => number = this.reader('getUint16', 16); + readInt32: () => number = this.reader('getInt32', 32); + readUint32: () => number = this.reader('getUint32', 32); + readFloat32: () => number = this.reader('getFloat32', 32); + readFloat64: () => number = this.reader('getFloat64', 64); + + writeBoolean: (value: boolean) => void = this.writer('setBoolean', 1); + writeInt8: (value: number) => void = this.writer('setInt8', 8); + writeUint8: (value: number) => void = this.writer('setUint8', 8); + writeInt16: (value: number) => void = this.writer('setInt16', 16); + writeUint16: (value: number) => void = this.writer('setUint16', 16); + writeInt32: (value: number) => void = this.writer('setInt32', 32); + writeUint32: (value: number) => void = this.writer('setUint32', 32); + writeFloat32: (value: number) => void = this.writer('setFloat32', 32); + writeFloat64: (value: number) => void = this.writer('setFloat64', 64); + + readASCIIString(bytes?: number): string { return this.readString(bytes, false); } - readUTF8String(bytes?: number) { + readUTF8String(bytes?: number): string { return this.readString(bytes, true); } - writeASCIIString(string: string, bytes?: number) { + writeASCIIString(string: string, bytes?: number): void { const length = bytes || string.length + 1; // + 1 for NULL for (let i = 0; i < length; ++i) { this.writeUint8(i < string.length ? string.charCodeAt(i) : 0x00); } } - writeUTF8String(string: string, bytes: number) { + writeUTF8String(string: string, bytes: number): void { const byteArray = stringToByteArray(string); const length = bytes || byteArray.length + 1; // + 1 for NULL @@ -486,7 +486,7 @@ export class BitStream { this.writeUint8(i < byteArray.length ? byteArray[i]! : 0x00); } } - readBitStream(bitLength: number) { + readBitStream(bitLength: number): BitStream { const slice = new BitStream(this._view); slice._startIndex = this._index; slice._index = this._index; @@ -494,7 +494,7 @@ export class BitStream { this._index += bitLength; return slice; } - writeBitStream(stream: BitStream, length: number) { + writeBitStream(stream: BitStream, length: number): void { if (!length) { length = stream.bitsLeft; } @@ -506,12 +506,12 @@ export class BitStream { length -= bitsToWrite; } } - readArrayBuffer(byteLength: number) { + readArrayBuffer(byteLength: number): Uint8Array { const buffer = this._view.getArrayBuffer(this._index, byteLength); this._index += byteLength * 8; return buffer; } - writeArrayBuffer(buffer: ArrayBuffer, byteLength: number) { + writeArrayBuffer(buffer: ArrayBuffer, byteLength: number): void { this.writeBitStream(new BitStream(buffer), byteLength * 8); } } diff --git a/src/messages.ts b/src/messages.ts index aafc1b8..da365b5 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -1,16 +1,13 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT -import { SourceDemoBuffer } from './buffer.ts'; -import { SourceDemo } from './demo.ts'; +import type { SourceDemoBuffer } from './buffer.ts'; +import type { SourceDemo } from './demo.ts'; import { CmdInfo } from './types/CmdInfo.ts'; -import { SendTable, ServerClassInfo } from './types/DataTables.ts'; +import type { SendTable, ServerClassInfo } from './types/DataTables.ts'; import { NetMessage } from './types/NetMessages.ts'; -import { StringTable as StringTableType } from './types/StringTables.ts'; -import { UserCmd as UserCmdType } from './types/UserCmd.ts'; +import type { StringTable as StringTableType } from './types/StringTables.ts'; +import type { UserCmd as UserCmdType } from './types/UserCmd.ts'; export class Message { type: number; @@ -19,26 +16,26 @@ export class Message { constructor(type: number) { this.type = type; } - static default(type: number) { + static default(type: number): Message { return new this(type); } - getType() { + getType(): number | undefined { return this.type; } - getName() { + getName(): string { return this.constructor.name; } - getTick() { + getTick(): number | undefined { return this.tick; } - getSlot() { + getSlot(): number | undefined { return this.slot; } - setTick(tick: number) { + setTick(tick: number): this { this.tick = tick; return this; } - setSlot(slot: number) { + setSlot(slot: number): this { this.slot = slot; return this; } @@ -60,21 +57,23 @@ export class Packet extends Message { constructor(type: number) { super(type); } - findPacket(type: (new (type: number) => T) | ((packet: NetMessage) => boolean)) { + findPacket( + type: (new (type: number) => T) | ((packet: NetMessage) => boolean), + ): T | undefined { const byType = type instanceof NetMessage ? (packet: NetMessage) => packet instanceof type : (packet: NetMessage) => (type as unknown as (packet: NetMessage) => boolean)(packet); return (this.packets ?? []).find(byType) as T | undefined; } - findPackets(type: (new (type: number) => T) | ((packet: NetMessage) => boolean)) { + findPackets(type: (new (type: number) => T) | ((packet: NetMessage) => boolean)): T[] { const byType = type instanceof NetMessage ? (packet: NetMessage) => packet instanceof type : (packet: NetMessage) => (type as unknown as (packet: NetMessage) => boolean)(packet); return (this.packets ?? []).filter(byType) as T[]; } - read(buf: SourceDemoBuffer, demo: SourceDemo) { + override read(buf: SourceDemoBuffer, demo: SourceDemo): Packet { let mssc = demo.demoProtocol === 4 ? 2 : 1; this.cmdInfo = []; @@ -89,7 +88,7 @@ export class Packet extends Message { this.data = buf.readBitStream(buf.readInt32() * 8); return this; } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer): Packet { this.cmdInfo!.forEach((cmd) => cmd.write(buf)); buf.writeInt32(this.inSequence!); buf.writeInt32(this.outSequence!); @@ -97,7 +96,7 @@ export class Packet extends Message { buf.writeBitStream(this.data!, this.data!.length); return this; } - *[Symbol.iterator]() { + *[Symbol.iterator](): Generator { for (const packet of this.packets ?? []) { yield packet; } @@ -105,20 +104,20 @@ export class Packet extends Message { } export class SignOn extends Packet {} export class SyncTick extends Message { - read() { + override read(): SyncTick { return this; } - write() { + override write(): SyncTick { return this; } } export class ConsoleCmd extends Message { command?: string; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer): ConsoleCmd { this.command = buf.readASCIIString(buf.readInt32()); return this; } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer): ConsoleCmd { buf.writeInt32(this.command!.length + 1); buf.writeASCIIString(this.command!, this.command!.length + 1); return this; @@ -129,12 +128,12 @@ export class UserCmd extends Message { data?: SourceDemoBuffer; userCmd?: UserCmdType; restData?: SourceDemoBuffer; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer): UserCmd { this.cmd = buf.readInt32(); this.data = buf.readBitStream(buf.readInt32() * 8); return this; } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer): UserCmd { buf.writeInt32(this.cmd!); buf.writeInt32(this.data!.length / 8); buf.writeBitStream(this.data!, this.data!.length); @@ -148,11 +147,11 @@ export class DataTable extends Message { serverClasses: ServerClassInfo[]; restData?: SourceDemoBuffer; }; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer): DataTable { this.data = buf.readBitStream(buf.readInt32() * 8); return this; } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer): DataTable { buf.writeInt32(this.data!.length / 8); buf.writeBitStream(this.data!, this.data!.length); return this; @@ -160,11 +159,11 @@ export class DataTable extends Message { } export class Stop extends Message { restData?: SourceDemoBuffer; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer): Stop { this.restData = buf.readBitStream(buf.bitsLeft); return this; } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer): Stop { buf.writeBitStream(this.restData!, this.restData!.bitsLeft); return this; } @@ -172,12 +171,12 @@ export class Stop extends Message { export class CustomData extends Message { unk?: number; data?: SourceDemoBuffer; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer): CustomData { this.unk = buf.readInt32(); this.data = buf.readBitStream(buf.readInt32() * 8); return this; } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer): CustomData { buf.writeInt32(this.unk!); buf.writeInt32(this.data!.length / 8); buf.writeBitStream(this.data!, this.data!.length); @@ -188,11 +187,11 @@ export class StringTable extends Message { data?: SourceDemoBuffer; stringTables?: StringTableType[]; restData?: SourceDemoBuffer; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer): StringTable { this.data = buf.readBitStream(buf.readInt32() * 8); return this; } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer): StringTable { buf.writeInt32(this.data!.length / 8); buf.writeBitStream(this.data!, this.data!.length); return this; diff --git a/src/mod.ts b/src/mod.ts index 4cb26ca..b17c7e5 100644 --- a/src/mod.ts +++ b/src/mod.ts @@ -1,13 +1,6 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT -export * from './speedrun/games/mod.ts'; -export * from './speedrun/games/SourceGame.ts'; -export * from './speedrun/sar.ts'; -export * from './speedrun/timer.ts'; export * from './types/CmdInfo.ts'; export * as DataTables from './types/DataTables.ts'; export * from './types/GameEventManager.ts'; diff --git a/src/parser.ts b/src/parser.ts index 6d7f54a..a3d9e80 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -1,8 +1,5 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT import { SourceDemoBuffer } from './buffer.ts'; import { SourceDemo } from './demo.ts'; @@ -31,17 +28,17 @@ export class SourceDemoParser { constructor(options: ParsingOptions = DefaultParsingOptions) { this.options = options; } - static default() { + static default(): SourceDemoParser { return new this(DefaultParsingOptions); } - setOptions(options: Partial) { + setOptions(options: Partial): SourceDemoParser { this.options = { ...this.options, ...options, }; return this; } - prepare(buffer: ArrayBuffer) { + prepare(buffer: ArrayBuffer): SourceDemoBuffer { const extended = new Uint8Array( buffer.byteLength + 4 - (buffer.byteLength % 4), ); @@ -49,7 +46,7 @@ export class SourceDemoParser { return new SourceDemoBuffer(extended.buffer); } - parse(buffer: ArrayBuffer) { + parse(buffer: ArrayBuffer): SourceDemo { const buf = this.prepare(buffer); const demo = SourceDemo.default(); @@ -65,7 +62,7 @@ export class SourceDemoParser { return demo; } - save(demo: SourceDemo, bufferSize: number) { + save(demo: SourceDemo, bufferSize: number): Uint8Array { if (!this.options.header || !this.options.header) { throw new Error('Cannot save demo without parsed header and messages.'); } diff --git a/src/speedrun/games/ApertureTag.ts b/src/speedrun/games/ApertureTag.ts index a16ac26..02911ef 100644 --- a/src/speedrun/games/ApertureTag.ts +++ b/src/speedrun/games/ApertureTag.ts @@ -1,10 +1,7 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT -import { SourceGame } from './SourceGame.ts'; +import type { SourceGame } from './SourceGame.ts'; export default { directory: 'aperturetag', @@ -69,4 +66,4 @@ export default { }, }, ], -} satisfies SourceGame; +} satisfies SourceGame as SourceGame; diff --git a/src/speedrun/games/Portal.ts b/src/speedrun/games/Portal.ts index 4d0e487..bacf9e7 100644 --- a/src/speedrun/games/Portal.ts +++ b/src/speedrun/games/Portal.ts @@ -1,10 +1,7 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT -import { SourceGame } from './SourceGame.ts'; +import type { SourceGame } from './SourceGame.ts'; export default { directory: 'portal', @@ -38,4 +35,4 @@ export default { }, }, ], -} satisfies SourceGame; +} satisfies SourceGame as SourceGame; diff --git a/src/speedrun/games/Portal2.ts b/src/speedrun/games/Portal2.ts index 4362c2d..9eaa3b1 100644 --- a/src/speedrun/games/Portal2.ts +++ b/src/speedrun/games/Portal2.ts @@ -1,10 +1,7 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT -import { SourceGame } from './SourceGame.ts'; +import type { SourceGame } from './SourceGame.ts'; export default { directory: 'portal2', @@ -137,4 +134,4 @@ export default { }, }, ], -} satisfies SourceGame; +} satisfies SourceGame as SourceGame; diff --git a/src/speedrun/games/PortalStoriesMel.ts b/src/speedrun/games/PortalStoriesMel.ts index 9920265..85e266a 100644 --- a/src/speedrun/games/PortalStoriesMel.ts +++ b/src/speedrun/games/PortalStoriesMel.ts @@ -1,10 +1,7 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT -import { SourceGame } from './SourceGame.ts'; +import type { SourceGame } from './SourceGame.ts'; export default { directory: 'portal_stories', @@ -46,4 +43,4 @@ export default { }, }, ], -} satisfies SourceGame; +} satisfies SourceGame as SourceGame; diff --git a/src/speedrun/games/SourceGame.ts b/src/speedrun/games/SourceGame.ts index 9d18c21..6b54ea7 100644 --- a/src/speedrun/games/SourceGame.ts +++ b/src/speedrun/games/SourceGame.ts @@ -1,10 +1,7 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT -import { Vector } from '../../types/Vector.ts'; +import type { Vector } from '../../types/Vector.ts'; export interface SourceGameRule { map?: string | string[]; diff --git a/src/speedrun/games/mod.ts b/src/speedrun/games/mod.ts index 4e228dc..176383d 100644 --- a/src/speedrun/games/mod.ts +++ b/src/speedrun/games/mod.ts @@ -1,14 +1,11 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT import Portal from './Portal.ts'; import Portal2 from './Portal2.ts'; import PortalStoriesMel from './PortalStoriesMel.ts'; import ApertureTag from './ApertureTag.ts'; -import { SourceGame } from './SourceGame.ts'; +import type { SourceGame } from './SourceGame.ts'; export const Games = { Portal, diff --git a/src/speedrun/mod.ts b/src/speedrun/mod.ts new file mode 100644 index 0000000..a5b6615 --- /dev/null +++ b/src/speedrun/mod.ts @@ -0,0 +1,7 @@ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT + +export * from './games/mod.ts'; +export * from './games/SourceGame.ts'; +export * from './sar.ts'; +export * from './timer.ts'; diff --git a/src/speedrun/sar.ts b/src/speedrun/sar.ts index f6e1965..90c01e1 100644 --- a/src/speedrun/sar.ts +++ b/src/speedrun/sar.ts @@ -1,19 +1,20 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT import { ConsoleCmd, UserCmd } from '../messages.ts'; -import { SourceDemo } from '../demo.ts'; +import type { SourceDemo } from '../demo.ts'; export const ReplayHeader = 'sar-tas-replay v1.8\n'; export class SarTimer { - static default() { + static default(): SarTimer { return new SarTimer(); } - time(demo: SourceDemo) { + time(demo: SourceDemo): { + startTick: number | undefined; + endTick: number | undefined; + delta: number; + } | undefined { if (!demo.messages?.length) { throw new Error('Cannot adjust ticks without parsed messages.'); } @@ -47,10 +48,10 @@ export class SarReplay { constructor(size: number) { this.buffer = this.alloc(size).buffer; } - static default() { + static default(): SarReplay { return new SarReplay(0); } - convert(demos: SourceDemo[]) { + convert(demos: SourceDemo[]): ArrayBufferLike { this.writeString(ReplayHeader); this.writeInt32(demos.length); @@ -73,10 +74,10 @@ export class SarReplay { return this.buffer; } - alloc(size: number) { + alloc(size: number): DataView { return new DataView(new ArrayBuffer(size)); } - concat(buffers: ArrayBuffer[]) { + concat(buffers: ArrayBuffer[]): ArrayBufferLike { const array = new Uint8Array( buffers.reduce((sum, buffer) => (sum += buffer.byteLength), 0), ); @@ -89,28 +90,28 @@ export class SarReplay { return array.buffer; } - writeInt8(value: number) { + writeInt8(value: number): void { const data = this.alloc(1); const result = data.setInt8(value, 0); this.buffer = this.concat([this.buffer, data.buffer]); return result; } - writeInt16(value: number) { + writeInt16(value: number): void { const data = this.alloc(2); data.setInt16(value, 0, true); this.buffer = this.concat([this.buffer, data.buffer]); } - writeInt32(value: number) { + writeInt32(value: number): void { const data = this.alloc(4); data.setInt32(value, 0, true); this.buffer = this.concat([this.buffer, data.buffer]); } - writeFloat(value: number) { + writeFloat(value: number): void { const data = this.alloc(4); data.setFloat32(value, 0, true); this.buffer = this.concat([this.buffer, data.buffer]); } - writeString(value: string) { + writeString(value: string): void { const data = this.alloc(value.length); let offset = 0; for (const c of value) { diff --git a/src/speedrun/timer.ts b/src/speedrun/timer.ts index a314c88..9fcf824 100644 --- a/src/speedrun/timer.ts +++ b/src/speedrun/timer.ts @@ -1,12 +1,9 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT import { Vector } from '../types/Vector.ts'; import { ConsoleCmd, Packet } from '../messages.ts'; -import { SourceDemo } from '../demo.ts'; +import type { SourceDemo } from '../demo.ts'; export class TimingResult { delta: number; @@ -35,7 +32,7 @@ export class TimingResult { }: { playbackTicks: number; playbackTime: number; - }) { + }): TimingResult { this.ticks.after = playbackTicks; this.time.after = playbackTime; this.delta = Math.abs(this.ticks.before - this.ticks.after); @@ -48,10 +45,10 @@ export class SourceTimer { constructor(splitScreenIndex: number) { this.splitScreenIndex = splitScreenIndex; } - static default() { + static default(): SourceTimer { return new SourceTimer(0); } - time(demo: SourceDemo) { + time(demo: SourceDemo): TimingResult { if (demo.playbackTicks === undefined || demo.playbackTime === undefined) { throw new Error('Cannot time speedrun when demo header was not parsed.'); } @@ -80,7 +77,7 @@ export class SourceTimer { playbackTime: demo.playbackTime, }); } - checkRules(demo: SourceDemo, type: 'start' | 'end') { + checkRules(demo: SourceDemo, type: 'start' | 'end'): number | undefined { if (demo.mapName === undefined) { throw new Error('Cannot time speedrun when demo header was not parsed.'); } diff --git a/src/types/CmdInfo.ts b/src/types/CmdInfo.ts index 0fe922f..9878dc9 100644 --- a/src/types/CmdInfo.ts +++ b/src/types/CmdInfo.ts @@ -1,12 +1,9 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT -import { SourceDemoBuffer } from '../buffer.ts'; -import { QAngle } from './QAngle.ts'; -import { Vector } from './Vector.ts'; +import type { SourceDemoBuffer } from '../buffer.ts'; +import type { QAngle } from './QAngle.ts'; +import type { Vector } from './Vector.ts'; export class CmdInfo { flags?: number; @@ -16,7 +13,7 @@ export class CmdInfo { viewOrigin2?: Vector; viewAngles2?: QAngle; localViewAngles2?: QAngle; - read(buf: SourceDemoBuffer) { + read(buf: SourceDemoBuffer): CmdInfo { this.flags = buf.readInt32(); this.viewOrigin = buf.readVector(); this.viewAngles = buf.readQAngle(); @@ -27,7 +24,7 @@ export class CmdInfo { return this; } - write(buf: SourceDemoBuffer) { + write(buf: SourceDemoBuffer): CmdInfo { buf.writeInt32(this.flags!); buf.writeVector(this.viewOrigin!); buf.writeQAngle(this.viewAngles!); diff --git a/src/types/DataTables.ts b/src/types/DataTables.ts index d38994e..2834524 100644 --- a/src/types/DataTables.ts +++ b/src/types/DataTables.ts @@ -1,11 +1,8 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT -import { SourceDemoBuffer } from '../buffer.ts'; -import { SourceDemo } from '../demo.ts'; +import type { SourceDemoBuffer } from '../buffer.ts'; +import type { SourceDemo } from '../demo.ts'; export const SendPropType = { Int: 0, diff --git a/src/types/GameEventManager.ts b/src/types/GameEventManager.ts index b178862..428ea10 100644 --- a/src/types/GameEventManager.ts +++ b/src/types/GameEventManager.ts @@ -1,4 +1,4 @@ -import { SourceDemoBuffer } from '../buffer.ts'; +import type { SourceDemoBuffer } from '../buffer.ts'; export class GameEventDescriptor { eventId?: number; @@ -35,10 +35,10 @@ export class GameEvent { this.descriptor = descriptor; this.dataKeys = new Map(); } - get>(keyName: string) { + get>(keyName: string): T { return this.dataKeys.get(keyName) as T; } - set['1']>(keyName: string, defaultValue: T) { + set['1']>(keyName: string, defaultValue: T): T { this.dataKeys.set(keyName, defaultValue); return defaultValue; } @@ -49,7 +49,7 @@ export class GameEventManager { constructor(gameEvents: GameEventDescriptor[]) { this.gameEvents = gameEvents; } - deserializeEvent(buf: SourceDemoBuffer) { + deserializeEvent(buf: SourceDemoBuffer): GameEvent { const eventId = buf.readBits(9); const descriptor = this.gameEvents.find( @@ -90,7 +90,7 @@ export class GameEventManager { return event; } - serializeEvent(event: GameEvent, buf: SourceDemoBuffer) { + serializeEvent(event: GameEvent, buf: SourceDemoBuffer): GameEvent { buf.writeBits(event.descriptor.eventId!, 9); for (const [keyName, type] of event.descriptor.keys!.entries()) { diff --git a/src/types/NetMessages.ts b/src/types/NetMessages.ts index 873113d..e186538 100644 --- a/src/types/NetMessages.ts +++ b/src/types/NetMessages.ts @@ -1,25 +1,22 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT import { SoundInfo } from './SoundInfo.ts'; -import { GameEvent, GameEventDescriptor, GameEventManager } from './GameEventManager.ts'; +import { type GameEvent, GameEventDescriptor, GameEventManager } from './GameEventManager.ts'; import { SourceDemoBuffer } from '../buffer.ts'; -import { SourceDemo } from '../demo.ts'; -import { Vector } from './Vector.ts'; -import { UserMessage, UserMessages } from './UserMessages.ts'; +import type { SourceDemo } from '../demo.ts'; +import type { Vector } from './Vector.ts'; +import { type UserMessage, UserMessages } from './UserMessages.ts'; export class NetMessage { type: number; constructor(type: number) { this.type = type; } - getType() { + getType(): number { return this.type; } - getName() { + getName(): string { return this.constructor.name; } read(_buf: SourceDemoBuffer, _demo: SourceDemo) { @@ -31,15 +28,15 @@ export class NetMessage { } export class NetNop extends NetMessage { - read() {} - write() {} + override read() {} + override write() {} } export class NetDisconnect extends NetMessage { text?: string; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.text = buf.readASCIIString(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeASCIIString(this.text!); } } @@ -48,7 +45,7 @@ export class NetFile extends NetMessage { fileName?: string; fileRequested?: boolean; unk?: boolean; - read(buf: SourceDemoBuffer, demo: SourceDemo) { + override read(buf: SourceDemoBuffer, demo: SourceDemo) { this.transferId = buf.readInt32(); this.fileName = buf.readASCIIString(); this.fileRequested = buf.readBoolean(); @@ -56,7 +53,7 @@ export class NetFile extends NetMessage { this.unk = buf.readBoolean(); } } - write(buf: SourceDemoBuffer, demo: SourceDemo) { + override write(buf: SourceDemoBuffer, demo: SourceDemo) { buf.writeInt32(this.transferId!); buf.writeASCIIString(this.fileName!); buf.writeBoolean(this.fileRequested!); @@ -67,10 +64,10 @@ export class NetFile extends NetMessage { } export class NetSplitScreenUser extends NetMessage { unk?: boolean; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.unk = buf.readBoolean(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeBoolean(this.unk!); } } @@ -78,13 +75,13 @@ export class NetTick extends NetMessage { tick?: number; hostFrameTime?: number; hostFrameTimeStdDeviation?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { const NET_TICK_SCALEUP = 100_000; this.tick = buf.readInt32(); this.hostFrameTime = buf.readInt16() / NET_TICK_SCALEUP; this.hostFrameTimeStdDeviation = buf.readInt16() / NET_TICK_SCALEUP; } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { const NET_TICK_SCALEUP = 100_000; buf.writeInt32(this.tick!); @@ -99,16 +96,16 @@ export class NetTick extends NetMessage { } export class NetStringCmd extends NetMessage { command?: string; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.command = buf.readASCIIString(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeASCIIString(this.command!); } } export class NetSetConVar extends NetMessage { convars?: { name: string; value: string }[]; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.convars = []; let length = buf.readInt8(); while (length--) { @@ -118,7 +115,7 @@ export class NetSetConVar extends NetMessage { }); } } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeInt8(this.convars!.length); this.convars!.forEach(({ name, value }) => { buf.writeASCIIString(name); @@ -134,7 +131,7 @@ export class NetSignonState extends NetMessage { playersNetworkIds?: Uint8Array; mapNameLength?: number; mapName?: string; - read(buf: SourceDemoBuffer, demo: SourceDemo) { + override read(buf: SourceDemoBuffer, demo: SourceDemo) { this.signonState = buf.readInt8(); this.spawnCount = buf.readInt32(); if (demo.isNewEngine()) { @@ -149,7 +146,7 @@ export class NetSignonState extends NetMessage { } } } - write(buf: SourceDemoBuffer, demo: SourceDemo) { + override write(buf: SourceDemoBuffer, demo: SourceDemo) { buf.writeInt8(this.signonState!); buf.writeInt32(this.spawnCount!); if (demo.isNewEngine()) { @@ -182,7 +179,7 @@ export class SvcServerInfo extends NetMessage { mapName?: string; skyName?: string; hostName?: string; - read(buf: SourceDemoBuffer, demo: SourceDemo) { + override read(buf: SourceDemoBuffer, demo: SourceDemo) { this.protocol = buf.readInt16(); this.serverCount = buf.readInt32(); this.isHltv = buf.readBoolean(); @@ -204,7 +201,7 @@ export class SvcServerInfo extends NetMessage { this.skyName = buf.readASCIIString(); this.hostName = buf.readASCIIString(); } - write(buf: SourceDemoBuffer, demo: SourceDemo) { + override write(buf: SourceDemoBuffer, demo: SourceDemo) { buf.writeInt16(this.protocol!); buf.writeInt32(this.serverCount!); buf.writeBoolean(this.isHltv!); @@ -231,12 +228,12 @@ export class SvcSendTable extends NetMessage { needsDecoder?: boolean; propsLength?: number; props?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.needsDecoder = buf.readBoolean(); this.propsLength = buf.readInt16(); this.props = buf.readBits(this.propsLength); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeBoolean(this.needsDecoder!); buf.writeInt16(this.propsLength!); buf.writeBits(this.props!, this.propsLength!); @@ -250,7 +247,7 @@ export class SvcClassInfo extends NetMessage { className: string; dataTableName: string; }[]; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.length = buf.readInt16(); this.createOnClient = buf.readBoolean(); if (!this.createOnClient) { @@ -265,7 +262,7 @@ export class SvcClassInfo extends NetMessage { } } } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeInt16(this.length!); buf.writeBoolean(this.createOnClient!); if (!this.createOnClient) { @@ -281,10 +278,10 @@ export class SvcClassInfo extends NetMessage { } export class SvcSetPause extends NetMessage { paused?: boolean; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.paused = buf.readBoolean(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeBoolean(this.paused!); } } @@ -298,7 +295,7 @@ export class SvcCreateStringTable extends NetMessage { flags?: number; stringDataLength?: number; stringData?: SourceDemoBuffer; - read(buf: SourceDemoBuffer, demo: SourceDemo) { + override read(buf: SourceDemoBuffer, demo: SourceDemo) { this.name = buf.readASCIIString(); this.maxEntries = buf.readInt16(); this.numEntries = buf.readBits(Math.log2(this.maxEntries) + 1); @@ -309,7 +306,7 @@ export class SvcCreateStringTable extends NetMessage { this.flags = buf.readBits(demo.isNewEngine() ? 2 : 1); this.stringData = buf.readBitStream(this.stringDataLength); } - write(buf: SourceDemoBuffer, demo: SourceDemo) { + override write(buf: SourceDemoBuffer, demo: SourceDemo) { buf.writeASCIIString(this.name!); buf.writeInt16(this.maxEntries!); buf.writeBits(this.numEntries!, Math.log2(this.maxEntries!) + 1); @@ -326,13 +323,13 @@ export class SvcUpdateStringTable extends NetMessage { numChangedEntries?: number; stringDataLength?: number; stringData?: SourceDemoBuffer; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.tableId = buf.readBits(5); this.numChangedEntries = buf.readBoolean() ? buf.readInt16() : 1; this.stringDataLength = buf.readBits(20); this.stringData = buf.readBitStream(this.stringDataLength); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeBits(this.tableId!, 5); buf.writeBoolean(this.numChangedEntries !== 1); this.numChangedEntries !== 1 && buf.writeInt16(this.numChangedEntries!); @@ -344,12 +341,12 @@ export class SvcVoiceInit extends NetMessage { codec?: string; quality?: number; unk?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.codec = buf.readASCIIString(); this.quality = buf.readInt8(); if (this.quality === 255) this.unk = buf.readFloat32(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeASCIIString(this.codec!); buf.writeInt8(this.quality!); this.unk !== undefined && buf.writeFloat32(this.unk!); @@ -360,13 +357,13 @@ export class SvcVoiceData extends NetMessage { proximity?: number; voiceDataLength?: number; voiceData?: SourceDemoBuffer; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.client = buf.readInt8(); this.proximity = buf.readInt8(); this.voiceDataLength = buf.readInt16(); this.voiceData = buf.readBitStream(this.voiceDataLength); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeInt8(this.client!); buf.writeInt8(this.proximity!); buf.writeInt16(this.voiceDataLength!); @@ -375,10 +372,10 @@ export class SvcVoiceData extends NetMessage { } export class SvcPrint extends NetMessage { message?: string; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.message = buf.readASCIIString(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeASCIIString(this.message!); } } @@ -388,7 +385,7 @@ export class SvcSounds extends NetMessage { soundsDataLength?: number; soundsData?: SourceDemoBuffer; sounds?: SoundInfo[]; - read(buf: SourceDemoBuffer, demo: SourceDemo) { + override read(buf: SourceDemoBuffer, demo: SourceDemo) { this.reliableSound = buf.readBoolean(); this.soundsLength = this.reliableSound ? 1 : buf.readBits(8); @@ -405,7 +402,7 @@ export class SvcSounds extends NetMessage { } } } - write(buf: SourceDemoBuffer, demo: SourceDemo) { + override write(buf: SourceDemoBuffer, demo: SourceDemo) { buf.writeBoolean(this.reliableSound!); !this.reliableSound && buf.writeBits(this.soundsLength!, 8); @@ -421,31 +418,31 @@ export class SvcSounds extends NetMessage { } export class SvcSetView extends NetMessage { entityIndex?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.entityIndex = buf.readBits(11); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeBits(this.entityIndex!, 11); } } export class SvcFixAngle extends NetMessage { relative?: boolean; angle?: [number, number, number]; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.relative = buf.readBoolean(); this.angle = [buf.readInt16(), buf.readInt16(), buf.readInt16()]; } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeBoolean(this.relative!); this.angle!.forEach((ang) => buf.writeInt16(ang)); } } export class SvcCrosshairAngle extends NetMessage { angle?: [number, number, number]; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.angle = [buf.readInt16(), buf.readInt16(), buf.readInt16()]; } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { this.angle!.forEach((ang) => buf.writeInt16(ang)); } } @@ -455,7 +452,7 @@ export class SvcBspDecal extends NetMessage { entityIndex?: number; modelIndex?: number; lowPriority?: boolean; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.pos = buf.readVectorCoord(); this.decalTextureIndex = buf.readBits(9); if (buf.readBoolean()) { @@ -464,7 +461,7 @@ export class SvcBspDecal extends NetMessage { } this.lowPriority = buf.readBoolean(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeVectorCoord(this.pos!); buf.writeBits(this.decalTextureIndex!, 9); buf.writeBoolean(this.entityIndex !== undefined); @@ -479,12 +476,12 @@ export class SvcSplitScreen extends NetMessage { unk?: number; dataLength?: number; data?: SourceDemoBuffer; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.unk = buf.readBits(1); this.dataLength = buf.readBits(11); this.data = buf.readBitStream(this.dataLength); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeBits(this.unk!, 1); buf.writeBits(this.dataLength!, 11); buf.writeBitStream(this.data!, this.dataLength!); @@ -495,7 +492,7 @@ export class SvcUserMessage extends NetMessage { msgDataLength?: number; msgData?: SourceDemoBuffer; userMessage?: UserMessage; - read(buf: SourceDemoBuffer, demo: SourceDemo) { + override read(buf: SourceDemoBuffer, demo: SourceDemo) { this.msgType = buf.readInt8(); this.msgDataLength = buf.readBits(demo.isNewEngine() ? 12 : 11); this.msgData = buf.readBitStream(this.msgDataLength); @@ -508,7 +505,7 @@ export class SvcUserMessage extends NetMessage { } } } - write(buf: SourceDemoBuffer, demo: SourceDemo) { + override write(buf: SourceDemoBuffer, demo: SourceDemo) { buf.writeInt8(this.msgType!); if (this.userMessage) { @@ -526,13 +523,13 @@ export class SvcEntityMessage extends NetMessage { classId?: number; dataLength?: number; data?: SourceDemoBuffer; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.entityIndex = buf.readBits(11); this.classId = buf.readBits(9); this.dataLength = buf.readBits(11); this.data = buf.readBitStream(this.dataLength); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeBits(this.entityIndex!, 11); buf.writeBits(this.classId!, 9); buf.writeBits(this.dataLength!, 11); @@ -542,7 +539,7 @@ export class SvcEntityMessage extends NetMessage { export class SvcGameEvent extends NetMessage { event?: GameEvent; data?: SourceDemoBuffer; - read(buf: SourceDemoBuffer, demo: SourceDemo) { + override read(buf: SourceDemoBuffer, demo: SourceDemo) { this.data = buf.readBitStream(buf.readBits(11)); if (demo.gameEventManager) { @@ -550,7 +547,7 @@ export class SvcGameEvent extends NetMessage { this.event = demo.gameEventManager.deserializeEvent(data); } } - write(buf: SourceDemoBuffer, demo: SourceDemo) { + override write(buf: SourceDemoBuffer, demo: SourceDemo) { if (demo.gameEventManager) { const data = SourceDemoBuffer.from(this.data!); demo.gameEventManager.serializeEvent(this.event!, data); @@ -570,7 +567,7 @@ export class SvcPacketEntities extends NetMessage { updateBaseline?: boolean; dataLength?: number; data?: SourceDemoBuffer; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.maxEntries = buf.readBits(11); this.isDelta = buf.readBoolean(); this.deltaFrom = this.isDelta ? buf.readInt32() : 0; @@ -580,7 +577,7 @@ export class SvcPacketEntities extends NetMessage { this.updateBaseline = buf.readBoolean(); this.data = buf.readBitStream(this.dataLength); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeBits(this.maxEntries!, 11); buf.writeBoolean(this.isDelta!); this.isDelta && buf.writeInt32(this.deltaFrom!); @@ -595,12 +592,12 @@ export class SvcTempEntities extends NetMessage { numEntries?: number; dataLength?: number; data?: SourceDemoBuffer; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.numEntries = buf.readInt8(); this.dataLength = buf.readBits(17); this.data = buf.readBitStream(this.dataLength); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeInt8(this.numEntries!); buf.writeBits(this.data!.length, 17); buf.writeBitStream(this.data!, this.dataLength!); @@ -608,10 +605,10 @@ export class SvcTempEntities extends NetMessage { } export class SvcPrefetch extends NetMessage { soundIndex?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.soundIndex = buf.readBits(13); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeBits(this.soundIndex!, 13); } } @@ -619,12 +616,12 @@ export class SvcMenu extends NetMessage { menuType?: number; dataLength?: number; data?: SourceDemoBuffer; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.menuType = buf.readInt16(); this.dataLength = buf.readInt32(); this.data = buf.readBitStream(this.dataLength); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeInt16(this.menuType!); buf.writeInt32(this.dataLength!); buf.writeBitStream(this.data!, this.dataLength!); @@ -634,7 +631,7 @@ export class SvcGameEventList extends NetMessage { events?: number; dataLength?: number; data?: SourceDemoBuffer; - read(buf: SourceDemoBuffer, demo: SourceDemo) { + override read(buf: SourceDemoBuffer, demo: SourceDemo) { this.events = buf.readBits(9); this.dataLength = buf.readBits(20); this.data = buf.readBitStream(this.dataLength); @@ -649,7 +646,7 @@ export class SvcGameEventList extends NetMessage { demo.gameEventManager = new GameEventManager(gameEvents); } - write(buf: SourceDemoBuffer, demo: SourceDemo) { + override write(buf: SourceDemoBuffer, demo: SourceDemo) { buf.writeBits(this.events!, 9); const data = SourceDemoBuffer.allocate(this.dataLength!); @@ -663,22 +660,22 @@ export class SvcGameEventList extends NetMessage { export class SvcGetCvarValue extends NetMessage { cookie?: number; cvarName?: string; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.cookie = buf.readInt32(); this.cvarName = buf.readASCIIString(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeInt32(this.cookie!); buf.writeASCIIString(this.cvarName!); } } export class SvcCmdKeyValues extends NetMessage { buffer?: Uint8Array; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { const length = buf.readInt32(); this.buffer = buf.readArrayBuffer(length); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeInt32(this.buffer!.byteLength); buf.writeArrayBuffer(this.buffer!.buffer, this.buffer!.byteLength); } @@ -686,11 +683,11 @@ export class SvcCmdKeyValues extends NetMessage { export class SvcPaintMapData extends NetMessage { dataLength?: number; data?: SourceDemoBuffer; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.dataLength = buf.readInt32(); this.data = buf.readBitStream(this.dataLength); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeInt32(this.data!.length); buf.writeBitStream(this.data!, this.dataLength!); } diff --git a/src/types/QAngle.ts b/src/types/QAngle.ts index 2fadf16..69c4a48 100644 --- a/src/types/QAngle.ts +++ b/src/types/QAngle.ts @@ -1,8 +1,5 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT export class QAngle { pitch: number; @@ -13,7 +10,7 @@ export class QAngle { this.yaw = yaw; this.roll = roll; } - *[Symbol.iterator]() { + *[Symbol.iterator](): Generator { yield this.pitch; yield this.yaw; yield this.roll; diff --git a/src/types/SoundInfo.ts b/src/types/SoundInfo.ts index 1059b38..82e9279 100644 --- a/src/types/SoundInfo.ts +++ b/src/types/SoundInfo.ts @@ -1,10 +1,7 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT -import { SourceDemoBuffer } from '../buffer.ts'; +import type { SourceDemoBuffer } from '../buffer.ts'; export const SoundFlags = { NoFlags: 0, diff --git a/src/types/StringTables.ts b/src/types/StringTables.ts index 6267a5a..4b8b63c 100644 --- a/src/types/StringTables.ts +++ b/src/types/StringTables.ts @@ -1,11 +1,8 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT import { SourceDemoBuffer } from '../buffer.ts'; -import { SourceDemo } from '../demo.ts'; +import type { SourceDemo } from '../demo.ts'; export class StringTable { name?: string; diff --git a/src/types/UserCmd.ts b/src/types/UserCmd.ts index 16d4a82..7c3e3c0 100644 --- a/src/types/UserCmd.ts +++ b/src/types/UserCmd.ts @@ -1,10 +1,7 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT -import { SourceDemoBuffer } from '../buffer.ts'; +import type { SourceDemoBuffer } from '../buffer.ts'; export class UserCmd { commandNumber?: number; diff --git a/src/types/UserMessages.ts b/src/types/UserMessages.ts index d71679d..b9efd4d 100644 --- a/src/types/UserMessages.ts +++ b/src/types/UserMessages.ts @@ -1,23 +1,20 @@ -/* - * Copyright (c) 2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2023-2024, NeKz +// SPDX-License-Identifier: MIT -import { SourceDemoBuffer } from '../buffer.ts'; -import { SourceDemo } from '../demo.ts'; -import { QAngle } from './QAngle.ts'; -import { Vector } from './Vector.ts'; +import type { SourceDemoBuffer } from '../buffer.ts'; +import type { SourceDemo } from '../demo.ts'; +import type { QAngle } from './QAngle.ts'; +import type { Vector } from './Vector.ts'; export class UserMessage { type: number; constructor(type: number) { this.type = type; } - getType() { + getType(): number { return this.type; } - getName() { + getName(): string { return this.constructor.name; } read(_buf: SourceDemoBuffer, _demo: SourceDemo) { @@ -26,35 +23,35 @@ export class UserMessage { write(_buf: SourceDemoBuffer, _demo: SourceDemo) { throw new Error(`write() for ${this.constructor.name} not implemented!`); } - as() { + as(): T { return this as unknown as T; } } export class Geiger extends UserMessage { geigerRange?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.geigerRange = buf.readUint8(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint8(this.geigerRange!); } } export class Train extends UserMessage { pos?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.pos = buf.readUint8(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint8(this.pos!); } } export class HudText extends UserMessage { text?: string; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.text = buf.readASCIIString(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeASCIIString(this.text!); } } @@ -62,12 +59,12 @@ export class SayText extends UserMessage { client?: number; text?: string; wantsToChat?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.client = buf.readUint8(); this.text = buf.readASCIIString(); this.wantsToChat = buf.readUint8(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint8(this.client!); buf.writeASCIIString(this.text!); buf.writeUint8(this.wantsToChat!); @@ -79,7 +76,7 @@ export class SayText2 extends UserMessage { wantsToChat?: number; messageText?: string; messages?: [string, string, string, string]; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.client = buf.readUint8(); this.text = buf.readASCIIString(); this.wantsToChat = buf.readUint8(); @@ -91,7 +88,7 @@ export class SayText2 extends UserMessage { buf.readASCIIString(), ]; } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint8(this.client!); buf.writeASCIIString(this.text!); buf.writeUint8(this.wantsToChat!); @@ -111,7 +108,7 @@ export enum HudPrint { export class TextMsg extends UserMessage { msgDest?: HudPrint; output?: [string, string, string, string, string]; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.msgDest = buf.readUint8(); this.output = ['', '', '', '', '']; @@ -119,7 +116,7 @@ export class TextMsg extends UserMessage { this.output[i] = buf.readASCIIString(); } } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint8(this.msgDest!); for (const str of this.output!.values() ?? []) { @@ -148,7 +145,7 @@ export interface HudTextParms { export class HudMsg extends UserMessage { textParms?: HudTextParms; message?: string; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.textParms = { channel: buf.readUint8(), x: buf.readFloat32(), @@ -169,7 +166,7 @@ export class HudMsg extends UserMessage { }; this.message = buf.readASCIIString(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint8(this.textParms!.channel); buf.writeFloat32(this.textParms!.x); buf.writeFloat32(this.textParms!.y); @@ -191,30 +188,30 @@ export class HudMsg extends UserMessage { } export class ResetHUD extends UserMessage { reset?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.reset = buf.readUint8(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint8(this.reset!); } } export class GameTitle extends UserMessage { - read(_buf: SourceDemoBuffer) {} - write(_buf: SourceDemoBuffer) {} + override read(_buf: SourceDemoBuffer) {} + override write(_buf: SourceDemoBuffer) {} } export class ItemPickup extends UserMessage { name?: string; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.name = buf.readASCIIString(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeASCIIString(this.name!); } } // NOTE: Unused export class ShowMenu extends UserMessage { - read(_buf: SourceDemoBuffer) {} - write(_buf: SourceDemoBuffer) {} + override read(_buf: SourceDemoBuffer) {} + override write(_buf: SourceDemoBuffer) {} } export enum ShakeCommand { Start = 0, @@ -229,13 +226,13 @@ export class Shake extends UserMessage { amplitude?: number; frequency?: number; duration?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.command = buf.readUint8(); this.amplitude = buf.readFloat32(); this.frequency = buf.readFloat32(); this.duration = buf.readFloat32(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint8(this.command!); buf.writeFloat32(this.amplitude!); buf.writeFloat32(this.frequency!); @@ -248,14 +245,14 @@ export class Tilt extends UserMessage { angle?: QAngle; duration?: number; time?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.command = buf.readUint8(); this.easeInOut = buf.readUint8(); this.angle = buf.readQAngle(); this.duration = buf.readFloat32(); this.time = buf.readFloat32(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint8(this.command!); buf.writeUint8(this.easeInOut!); buf.writeQAngle(this.angle!); @@ -268,7 +265,7 @@ export class Fade extends UserMessage { holdTime?: number; fadeFlags?: number; fade?: { r: number; g: number; b: number; a: number }; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.duration = buf.readUint16(); this.holdTime = buf.readUint16(); this.fadeFlags = buf.readUint16(); @@ -279,7 +276,7 @@ export class Fade extends UserMessage { a: buf.readUint8(), }; } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint16(this.duration!); buf.writeUint16(this.holdTime!); buf.writeUint16(this.fadeFlags!); @@ -294,7 +291,7 @@ export class VGUIMenu extends UserMessage { show?: number; size?: number; keyValues?: { key: string; value: string }[]; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.name = buf.readASCIIString(); this.show = buf.readUint8(); this.size = buf.readUint8(); @@ -307,7 +304,7 @@ export class VGUIMenu extends UserMessage { }); } } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeASCIIString(this.name!); buf.writeUint8(this.show!); buf.writeUint8(this.size!); @@ -322,12 +319,12 @@ export class Rumble extends UserMessage { index?: number; data?: number; flags?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.index = buf.readUint8(); this.data = buf.readUint8(); this.flags = buf.readUint8(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint8(this.index!); buf.writeUint8(this.data!); buf.writeUint8(this.flags!); @@ -335,23 +332,23 @@ export class Rumble extends UserMessage { } export class Battery extends UserMessage { battery?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.battery = buf.readUint16(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint16(this.battery!); } } // NOTE: Unused export class Damage extends UserMessage { - read(_buf: SourceDemoBuffer) {} - write(_buf: SourceDemoBuffer) {} + override read(_buf: SourceDemoBuffer) {} + override write(_buf: SourceDemoBuffer) {} } export class VoiceMask extends UserMessage { audiblePlayers?: [number, number]; serverBannedPlayers?: [number, number]; serverModEnabled?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { const VOICE_MAX_PLAYERS_DW = 2; this.audiblePlayers = [0, 0]; @@ -364,7 +361,7 @@ export class VoiceMask extends UserMessage { this.serverModEnabled = buf.readUint8(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { const VOICE_MAX_PLAYERS_DW = 2; for (let index = 0; index < VOICE_MAX_PLAYERS_DW; ++index) { @@ -376,19 +373,19 @@ export class VoiceMask extends UserMessage { } } export class RequestState extends UserMessage { - read(_buf: SourceDemoBuffer) {} - write(_buf: SourceDemoBuffer) {} + override read(_buf: SourceDemoBuffer) {} + override write(_buf: SourceDemoBuffer) {} } export class CloseCaption extends UserMessage { hash?: number; duration?: number; fromPlayer?: boolean; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.hash = buf.readUint32(); this.duration = buf.readBits(15, false); this.fromPlayer = buf.readBoolean(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint32(this.hash!); buf.writeBits(this.duration!, 15); buf.writeBoolean(this.fromPlayer!); @@ -398,12 +395,12 @@ export class CloseCaptionDirect extends UserMessage { hash?: number; duration?: number; fromPlayer?: boolean; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.hash = buf.readUint32(); this.duration = buf.readBits(15, false); this.fromPlayer = buf.readBoolean(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint32(this.hash!); buf.writeBits(this.duration!, 15); buf.writeBoolean(this.fromPlayer!); @@ -411,37 +408,37 @@ export class CloseCaptionDirect extends UserMessage { } export class HintText extends UserMessage { hintString?: string; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.hintString = buf.readASCIIString(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeASCIIString(this.hintString!); } } export class KeyHintText extends UserMessage { messages?: 1; message?: string; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.messages = buf.readUint8() as 1; this.message = buf.readASCIIString(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint8(this.messages!); buf.writeASCIIString(this.message!); } } // NOTE: Unused export class SquadMemberDied extends UserMessage { - read(_buf: SourceDemoBuffer) {} - write(_buf: SourceDemoBuffer) {} + override read(_buf: SourceDemoBuffer) {} + override write(_buf: SourceDemoBuffer) {} } // NOTE: Unused export class AmmoDenied extends UserMessage { ammo?: number; - read(_buf: SourceDemoBuffer) { + override read(_buf: SourceDemoBuffer) { // this.ammo = buf.readUint16(); } - write(_buf: SourceDemoBuffer) { + override write(_buf: SourceDemoBuffer) { // buf.writeUint16(this.ammo); } } @@ -452,39 +449,39 @@ export enum CreditsType { } export class CreditsMsg extends UserMessage { creditsType?: CreditsType; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.creditsType = buf.readUint8(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint8(this.creditsType!); } } export class LogoTimeMsg extends UserMessage { time?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.time = buf.readFloat32(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeFloat32(this.time!); } } // NOTE: Unused export class AchievementEvent extends UserMessage { achievementId?: number; - read(_buf: SourceDemoBuffer) { + override read(_buf: SourceDemoBuffer) { // this.achievementId = buf.readUint16(); } - write(_buf: SourceDemoBuffer) { + override write(_buf: SourceDemoBuffer) { // buf.writeUint16(this.achievementId); } } export class UpdateJalopyRadar extends UserMessage { - read(_buf: SourceDemoBuffer) {} - write(_buf: SourceDemoBuffer) {} + override read(_buf: SourceDemoBuffer) {} + override write(_buf: SourceDemoBuffer) {} } export class CurrentTimescale extends UserMessage { - read(_buf: SourceDemoBuffer) {} - write(_buf: SourceDemoBuffer) {} + override read(_buf: SourceDemoBuffer) {} + override write(_buf: SourceDemoBuffer) {} } export enum GameTimescaleInterpolators { Linear = 0, @@ -497,13 +494,13 @@ export class DesiredTimescale extends UserMessage { durationRealTimeSeconds?: number; interpolationType?: GameTimescaleInterpolators; startBlendTime?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.desiredTimescale = buf.readFloat32(); this.durationRealTimeSeconds = buf.readFloat32(); this.interpolationType = buf.readUint8(); this.startBlendTime = buf.readFloat32(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeFloat32(this.desiredTimescale!); buf.writeFloat32(this.durationRealTimeSeconds!); buf.writeUint8(this.interpolationType!); @@ -518,51 +515,51 @@ export enum PortalCreditsType { } export class CreditsPortalMsg extends UserMessage { creditsType?: PortalCreditsType; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.creditsType = buf.readUint8(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint8(this.creditsType!); } } // NOTE: Unused export class InventoryFlash extends UserMessage { - read(_buf: SourceDemoBuffer) {} - write(_buf: SourceDemoBuffer) {} + override read(_buf: SourceDemoBuffer) {} + override write(_buf: SourceDemoBuffer) {} } // NOTE: Unused export class IndicatorFlash extends UserMessage { - read(_buf: SourceDemoBuffer) {} - write(_buf: SourceDemoBuffer) {} + override read(_buf: SourceDemoBuffer) {} + override write(_buf: SourceDemoBuffer) {} } // NOTE: Unused export class ControlHelperAnimate extends UserMessage { - read(_buf: SourceDemoBuffer) {} - write(_buf: SourceDemoBuffer) {} + override read(_buf: SourceDemoBuffer) {} + override write(_buf: SourceDemoBuffer) {} } // NOTE: Unused export class TakePhoto extends UserMessage { - read(_buf: SourceDemoBuffer) {} - write(_buf: SourceDemoBuffer) {} + override read(_buf: SourceDemoBuffer) {} + override write(_buf: SourceDemoBuffer) {} } // NOTE: Unused export class Flash extends UserMessage { - read(_buf: SourceDemoBuffer) {} - write(_buf: SourceDemoBuffer) {} + override read(_buf: SourceDemoBuffer) {} + override write(_buf: SourceDemoBuffer) {} } export class HudPingIndicator extends UserMessage { position?: Vector; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.position = buf.readVector(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeVector(this.position!); } } // NOTE: Unused export class OpenRadialMenu extends UserMessage { - read(_buf: SourceDemoBuffer) {} - write(_buf: SourceDemoBuffer) {} + override read(_buf: SourceDemoBuffer) {} + override write(_buf: SourceDemoBuffer) {} } // TODO export class AddLocator extends UserMessage { @@ -572,7 +569,7 @@ export class AddLocator extends UserMessage { position?: Vector; normal?: Vector; iconName?: string; - read(_buf: SourceDemoBuffer) { + override read(_buf: SourceDemoBuffer) { // this.playerIndex = buf.readUint16(); // this.entityHandle = buf.readUint32(); // this.displayTime = buf.readFloat32(); @@ -580,7 +577,7 @@ export class AddLocator extends UserMessage { // this.normal = buf.readVector(); // this.iconName = buf.readASCIIString(); } - write(_buf: SourceDemoBuffer) { + override write(_buf: SourceDemoBuffer) { // buf.writeUint16(this.playerIndex!); // buf.writeUint32(this.entityHandle!); // buf.writeFloat32(this.displayTime!); @@ -592,11 +589,11 @@ export class AddLocator extends UserMessage { export class MPMapCompleted extends UserMessage { branch?: number; level?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.branch = buf.readUint8(); this.level = buf.readUint8(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint8(this.branch!); buf.writeUint8(this.level!); } @@ -604,11 +601,11 @@ export class MPMapCompleted extends UserMessage { export class MPMapIncomplete extends UserMessage { branch?: number; level?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.branch = buf.readUint8(); this.level = buf.readUint8(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint8(this.branch!); buf.writeUint8(this.level!); } @@ -616,7 +613,7 @@ export class MPMapIncomplete extends UserMessage { // TODO export class MPMapCompletedData extends UserMessage { levelCompletions?: boolean[][][]; - read(_buf: SourceDemoBuffer) { + override read(_buf: SourceDemoBuffer) { // const MAX_PORTAL2_COOP_BRANCHES = 6; // const MAX_PORTAL2_COOP_LEVELS_PER_BRANCH = 16; // const numBits = 2 * MAX_PORTAL2_COOP_BRANCHES * MAX_PORTAL2_COOP_LEVELS_PER_BRANCH; @@ -648,7 +645,7 @@ export class MPMapCompletedData extends UserMessage { // } // } } - write(_buf: SourceDemoBuffer) { + override write(_buf: SourceDemoBuffer) { // const MAX_PORTAL2_COOP_BRANCHES = 6; // const MAX_PORTAL2_COOP_LEVELS_PER_BRANCH = 16; // const numBits = 2 * MAX_PORTAL2_COOP_BRANCHES * MAX_PORTAL2_COOP_LEVELS_PER_BRANCH; @@ -685,36 +682,36 @@ export class MPMapCompletedData extends UserMessage { export class MPTauntEarned extends UserMessage { taunt?: string; awardSilently?: boolean; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.taunt = buf.readASCIIString(); this.awardSilently = buf.readBoolean(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeASCIIString(this.taunt!); buf.writeBoolean(this.awardSilently!); } } export class MPTauntUnlocked extends UserMessage { taunt?: string; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.taunt = buf.readASCIIString(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeASCIIString(this.taunt!); } } export class MPTauntLocked extends UserMessage { taunt?: string; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.taunt = buf.readASCIIString(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeASCIIString(this.taunt!); } } export class MPAllTauntsLocked extends UserMessage { - read(_buf: SourceDemoBuffer) {} - write(_buf: SourceDemoBuffer) {} + override read(_buf: SourceDemoBuffer) {} + override write(_buf: SourceDemoBuffer) {} } export enum PortalFizzleType { Success = 0, @@ -738,7 +735,7 @@ export class PortalFX_Surface extends UserMessage { effect?: PortalFizzleType; vecOrigin?: Vector; angles?: QAngle; - read(_buf: SourceDemoBuffer) { + override read(_buf: SourceDemoBuffer) { // this.entIndex = buf.readInt16(); // this.playerEntIndex = buf.readInt16(); // this.team = buf.readInt8(); @@ -747,7 +744,7 @@ export class PortalFX_Surface extends UserMessage { // this.vecOrigin = buf.readVectorCoord(); // this.angles = buf.readAngles(); } - write(_buf: SourceDemoBuffer) { + override write(_buf: SourceDemoBuffer) { // buf.writeInt16(this.entIndex!); // buf.writeInt16(this.playerEntIndex!); // buf.writeInt8(this.team!); @@ -764,14 +761,14 @@ export class PaintWorld extends UserMessage { unk3?: number; unk4?: number; unk5?: number; - read(_buf: SourceDemoBuffer) { + override read(_buf: SourceDemoBuffer) { // this.unk1 = buf.readUint8(); // this.unk2 = buf.readUint32(); // this.unk3 = buf.readFloat32(); // this.unk4 = buf.readFloat32(); // this.unk5 = buf.readUint8(); } - write(_buf: SourceDemoBuffer) { + override write(_buf: SourceDemoBuffer) { // buf.writeUint8(this.unk1!); // buf.writeUint32(this.unk2!); // buf.writeFloat32(this.unk3!); @@ -786,14 +783,14 @@ export class PaintEntity extends UserMessage { unk3?: number; unk4?: number; unk5?: number; - read(_buf: SourceDemoBuffer) { + override read(_buf: SourceDemoBuffer) { // this.unk1 = buf.readUint32(); // this.unk2 = buf.readUint8(); // this.unk3 = buf.readFloat32(); // this.unk4 = buf.readFloat32(); // this.unk5 = buf.readFloat32(); } - write(_buf: SourceDemoBuffer) { + override write(_buf: SourceDemoBuffer) { // buf.writeUint32(this.unk1!); // buf.writeUint8(this.unk2!); // buf.writeFloat32(this.unk3!); @@ -805,40 +802,40 @@ export class PaintEntity extends UserMessage { export class ChangePaintColor extends UserMessage { unk1?: number; unk2?: number; - read(_buf: SourceDemoBuffer) { + override read(_buf: SourceDemoBuffer) { // this.unk1 = buf.readUint32(); // this.unk2 = buf.readUint8(); } - write(_buf: SourceDemoBuffer) { + override write(_buf: SourceDemoBuffer) { // buf.writeUint32(this.unk1!); // buf.writeUint8(this.unk2!); } } // NOTE: Unused export class PaintBombExplode extends UserMessage { - read(_buf: SourceDemoBuffer) {} - write(_buf: SourceDemoBuffer) {} + override read(_buf: SourceDemoBuffer) {} + override write(_buf: SourceDemoBuffer) {} } export class RemoveAllPaint extends UserMessage { - read(_buf: SourceDemoBuffer) {} - write(_buf: SourceDemoBuffer) {} + override read(_buf: SourceDemoBuffer) {} + override write(_buf: SourceDemoBuffer) {} } // NOTE: Unused export class PaintAllSurfaces extends UserMessage { - read(_buf: SourceDemoBuffer) {} - write(_buf: SourceDemoBuffer) {} + override read(_buf: SourceDemoBuffer) {} + override write(_buf: SourceDemoBuffer) {} } export class RemovePaint extends UserMessage { - read(_buf: SourceDemoBuffer) {} - write(_buf: SourceDemoBuffer) {} + override read(_buf: SourceDemoBuffer) {} + override write(_buf: SourceDemoBuffer) {} } // NOTE: Unused export class StartSurvey extends UserMessage { handle?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.handle = buf.readUint32(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint32(this.handle!); } } @@ -847,12 +844,12 @@ export class ApplyHitBoxDamageEffect extends UserMessage { entityHandle?: number; effectIndex?: number; hits?: number; - read(_buf: SourceDemoBuffer) { + override read(_buf: SourceDemoBuffer) { // this.entityHandle = buf.readUint32(); // this.effectIndex = buf.readUint8(); // this.hits = buf.readUint8(); } - write(_buf: SourceDemoBuffer) { + override write(_buf: SourceDemoBuffer) { // buf.writeUint32(this.entityHandle!); // buf.writeUint8(this.effectIndex!); // buf.writeUint8(this.hits!); @@ -862,12 +859,12 @@ export class SetMixLayerTriggerFactor extends UserMessage { layer?: string; group?: string; factor?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.layer = buf.readASCIIString(); this.group = buf.readASCIIString(); this.factor = buf.readFloat32(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeASCIIString(this.layer!); buf.writeASCIIString(this.group!); buf.writeFloat32(this.factor!); @@ -875,32 +872,32 @@ export class SetMixLayerTriggerFactor extends UserMessage { } export class TransitionFade extends UserMessage { fade?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.fade = buf.readFloat32(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeFloat32(this.fade!); } } export class ScoreboardTempUpdate extends UserMessage { portalScore?: number; timeScore?: number; - read(buf: SourceDemoBuffer) { + override read(buf: SourceDemoBuffer) { this.portalScore = buf.readUint32(); this.timeScore = buf.readUint32(); } - write(buf: SourceDemoBuffer) { + override write(buf: SourceDemoBuffer) { buf.writeUint32(this.portalScore!); buf.writeUint32(this.timeScore!); } } export class ChallengeModeCheatSession extends UserMessage { - read(_buf: SourceDemoBuffer) {} - write(_buf: SourceDemoBuffer) {} + override read(_buf: SourceDemoBuffer) {} + override write(_buf: SourceDemoBuffer) {} } export class ChallengeModeCloseAllUI extends UserMessage { - read(_buf: SourceDemoBuffer) {} - write(_buf: SourceDemoBuffer) {} + override read(_buf: SourceDemoBuffer) {} + override write(_buf: SourceDemoBuffer) {} } export const UserMessages = { diff --git a/src/types/Vector.ts b/src/types/Vector.ts index a1578ff..2bf3118 100644 --- a/src/types/Vector.ts +++ b/src/types/Vector.ts @@ -1,8 +1,5 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT export class Vector { x: number; @@ -13,13 +10,13 @@ export class Vector { this.y = y; this.z = z; } - length() { + length(): number { return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); } - length2D() { + length2D(): number { return Math.sqrt(this.x * this.x + this.y * this.y); } - *[Symbol.iterator]() { + *[Symbol.iterator](): Generator { yield this.x; yield this.y; yield this.z; diff --git a/src/types/mod.ts b/src/types/mod.ts new file mode 100644 index 0000000..e460fbb --- /dev/null +++ b/src/types/mod.ts @@ -0,0 +1,13 @@ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT + +export * from './CmdInfo.ts'; +export * from './DataTables.ts'; +export * from './GameEventManager.ts'; +export * from './NetMessages.ts'; +export * from './QAngle.ts'; +export * from './SoundInfo.ts'; +export * from './StringTables.ts'; +export * from './UserCmd.ts'; +export * from './UserMessages.ts'; +export * from './Vector.ts'; diff --git a/src/utils/mod.ts b/src/utils/mod.ts new file mode 100644 index 0000000..94f4e5f --- /dev/null +++ b/src/utils/mod.ts @@ -0,0 +1,5 @@ +// Copyright (c) 2024, NeKz +// SPDX-License-Identifier: MIT + +export * from './sar.ts'; +export * from './steam.ts'; diff --git a/src/utils/sar.ts b/src/utils/sar.ts new file mode 100644 index 0000000..78c741f --- /dev/null +++ b/src/utils/sar.ts @@ -0,0 +1,301 @@ +// Copyright (c) 2023-2024, NeKz +// SPDX-License-Identifier: MIT + +import type { SourceDemoBuffer } from '../buffer.ts'; +import type { SourceDemo } from '../demo.ts'; +import { DemoMessages } from '../messages.ts'; + +export class SarMessage { + timescale?: number; + slot?: number; + pauseTicks?: number; + initialCvar?: { + cvar: string; + val: string; + }; + checksum?: { + demoSum: number; + sarSum: number; + }; + checksumV2?: { + sarSum: number; + signature: ArrayBuffer; + }; + entityInput?: { + targetname: string; + classname: string; + inputname: string; + parameter: string; + }; + portalPlacement?: { + x: number; + y: number; + z: number; + orange: boolean; + }; + waitRun?: { + tick: number; + cmd: string; + }; + hwaitRun?: { + ticks: number; + cmd: string; + }; + speedrunTime?: { + nsplits: number; + splits?: { + name: string; + nsegs: number; + segs?: { + name: string; + ticks: number; + }[]; + }[]; + }; + timestamp?: { + year: number; + mon: number; + day: number; + hour: number; + min: number; + sec: number; + }; + fileChecksum?: { + path: string; + sum: number; + }; + + constructor(public type: SarDataType) { + } +} + +export enum SarDataType { + TimescaleCheat = 0x01, + InitialCvar = 0x02, + EntityInput = 0x03, + EntityInputSlot = 0x04, + PortalPlacement = 0x05, + ChallengeFlags = 0x06, + CrouchFly = 0x07, + Pause = 0x08, + WaitRun = 0x09, + SpeedrunTime = 0x0A, + Timestamp = 0x0B, + FileChecksum = 0x0C, + HwaitRun = 0x0D, + Checksum = 0xFF, + ChecksumV2 = 0xFE, + Invalid = -1, +} + +export enum ChecksumV2State { + None, + Invalid, + Valid, +} + +export interface SarResult { + demo: SourceDemo; + messages: SarMessage[]; +} + +// _parse_sar_data +export const readSarMessageData = (data: SourceDemoBuffer, len: number): SarMessage => { + if (len === 0) { + return new SarMessage(SarDataType.Invalid); + } + + const type = data.readUint8() as SarDataType; + + if (type === SarDataType.Checksum && len === 5) { + len = 9; + } + + const out = new SarMessage(SarDataType.Invalid); + out.type = type; + + switch (type) { + case SarDataType.TimescaleCheat: + if (len !== 5) { + out.type = SarDataType.Invalid; + break; + } + out.timescale = data.readFloat32(); + break; + case SarDataType.InitialCvar: + out.initialCvar = { + cvar: data.readASCIIString(), + val: data.readASCIIString(), + }; + break; + // deno-lint-ignore no-fallthrough + case SarDataType.EntityInputSlot: + out.slot = data.readUint8(); + case SarDataType.EntityInput: + out.entityInput = { + targetname: data.readASCIIString(), + classname: data.readASCIIString(), + inputname: data.readASCIIString(), + parameter: data.readASCIIString(), + }; + break; + case SarDataType.Checksum: + if (len !== 9) { + out.type = SarDataType.Invalid; + break; + } + out.checksum = { + demoSum: data.readUint32(), + sarSum: data.readUint32(), + }; + break; + case SarDataType.ChecksumV2: + if (len !== 69) { + out.type = SarDataType.Invalid; + break; + } + out.checksumV2 = { + sarSum: data.readUint32(), + signature: data.readArrayBuffer(64), + }; + break; + case SarDataType.PortalPlacement: + if (len !== 15) { + out.type = SarDataType.Invalid; + break; + } + out.slot = data.readUint8(); + out.portalPlacement = { + orange: Boolean(data.readUint8()), + x: data.readFloat32(), + y: data.readFloat32(), + z: data.readFloat32(), + }; + break; + case SarDataType.ChallengeFlags: + case SarDataType.CrouchFly: + if (len !== 2) { + out.type = SarDataType.Invalid; + break; + } + out.slot = data.readUint8(); + break; + case SarDataType.Pause: + if (len !== 5) { + out.type = SarDataType.Invalid; + break; + } + out.pauseTicks = data.readUint32(); + break; + case SarDataType.WaitRun: + if (len < 6) { + out.type = SarDataType.Invalid; + break; + } + out.waitRun = { + tick: data.readUint32(), + cmd: data.readASCIIString(), + }; + break; + case SarDataType.HwaitRun: + if (len < 6) { + out.type = SarDataType.Invalid; + break; + } + out.hwaitRun = { + ticks: data.readUint32(), + cmd: data.readASCIIString(), + }; + break; + case SarDataType.SpeedrunTime: + if (len < 5) { + out.type = SarDataType.Invalid; + break; + } + out.speedrunTime = { + nsplits: data.readUint32(), + splits: [], + }; + for (let i = 0; i < out.speedrunTime.nsplits; ++i) { + type Inner = T extends (infer U)[] ? U : T; + type SplitsType = Exclude< + Inner['splits']>, + undefined + >; + + const split: SplitsType = { + name: data.readASCIIString(), + nsegs: data.readUint32(), + segs: [], + }; + + for (let j = 0; j < split.nsegs; ++j) { + split.segs!.push({ + name: data.readASCIIString(), + ticks: data.readUint32(), + }); + } + + out.speedrunTime.splits!.push(split); + } + + if (data.bitsLeft) { + out.type = SarDataType.Invalid; + break; + } + + break; + case SarDataType.Timestamp: + if (len !== 8) { + out.type = SarDataType.Invalid; + break; + } + out.timestamp = { + year: data.readUint8() | (data.readUint8() << 8), + mon: data.readUint8() + 1, + day: data.readUint8(), + hour: data.readUint8(), + min: data.readUint8(), + sec: data.readUint8(), + }; + break; + case SarDataType.FileChecksum: + if (len < 6) { + out.type = SarDataType.Invalid; + break; + } + out.fileChecksum = { + sum: data.readUint32(), + path: data.readASCIIString(), + }; + break; + default: + out.type = SarDataType.Invalid; + break; + } + + return out; +}; + +export const readSarData = (demo: SourceDemo): SarResult => { + const messages: SarMessage[] = []; + + for (const message of demo.findMessages(DemoMessages.CustomData)) { + const data = message.data!; + + // _parse_msg + if (message.unk !== 0 || data.length === 64) { + continue; + } + + data.readArrayBuffer(8); + const len = (data.length / 8) - 8; + + messages.push(readSarMessageData(data, len)); + } + + return { + demo, + messages, + } as SarResult; +}; diff --git a/src/utils/steam.ts b/src/utils/steam.ts new file mode 100644 index 0000000..9e7951a --- /dev/null +++ b/src/utils/steam.ts @@ -0,0 +1,100 @@ +// Copyright (c) 2024, NeKz +// SPDX-License-Identifier: MIT + +import type { StringTableEntry } from '../types/StringTables.ts'; + +export enum SteamIdUniverse { + Individual = 0, + Public = 1, + Beta = 2, + Internal = 3, + Dev = 4, + Rc = 5, +} + +export enum SteamIdType { + Invalid = 0, + Individual = 1, + Multiseat = 2, + GameServer = 3, + AnonGameServer = 4, + Pending = 5, + ContentServer = 6, + Clan = 7, + Chat = 8, + P2PSuperSeeder = 9, + AnonUser = 10, +} + +export enum SteamIdInstance { + All = 0, + Desktop = 1, + Console = 2, + Web = 4, +} + +export class SteamId { + universe: bigint = BigInt(SteamIdUniverse.Public); + type: bigint = BigInt(SteamIdType.Individual); + instance: bigint = BigInt(SteamIdInstance.Desktop); + account = 0n; + isValid = false; + + constructor(props?: { account: bigint; universe: bigint; isValid: boolean }) { + Object.assign(this, props); + } + + static from(steamId: string): SteamId { + const groups = steamId.match(/^STEAM\_([0-9]+)\:([0-9]+)\:([0-9]+)$/); + if (groups) { + const [x, y, z] = groups.slice(1).map((value) => BigInt(value)); + + return new this({ + account: (z! << 1n) | y!, + universe: x!, + isValid: true, + }); + } + + return new this(); + } + + toSteamId64(): bigint | null { + return this.isValid + ? (this.universe << 56n) | (this.type << 52n) | (this.instance << 32n) | this.account + : null; + } +} + +export enum SteamIdResult { + Ok, + NoPlayerInfoGuid, + InvalidSteamId, +} + +export type PlayerSteamDataResult = + | [null, SteamIdResult.NoPlayerInfoGuid] + | [guid: string, SteamIdResult.InvalidSteamId] + | [{ playerName: string | null; steamId: string | null }, SteamIdResult.Ok]; + +export const getPlayerSteamData = (playerInfo: StringTableEntry): PlayerSteamDataResult => { + const guid = playerInfo.data?.guid; + if (guid === undefined) { + return [null, SteamIdResult.NoPlayerInfoGuid]; + } + + const steamId = SteamId.from(guid).toSteamId64(); + if (steamId === null) { + return [guid, SteamIdResult.InvalidSteamId]; + } + + const playerName = playerInfo.data?.name; + + return [ + { + playerName: playerName ? decodeURIComponent(escape(playerName)) : null, + steamId: steamId?.toString() ?? null, + }, + SteamIdResult.Ok, + ]; +}; diff --git a/tests/buffer_test.ts b/tests/buffer_test.ts index 406000f..7480415 100644 --- a/tests/buffer_test.ts +++ b/tests/buffer_test.ts @@ -1,11 +1,8 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT -import { assertEquals } from 'https://deno.land/std@0.191.0/testing/asserts.ts'; -import { describe, it } from 'https://deno.land/std@0.191.0/testing/bdd.ts'; +import { assertEquals } from 'jsr:@std/assert'; +import { describe, it } from 'jsr:@std/testing/bdd'; import { SourceDemoBuffer } from '../src/buffer.ts'; describe('SourceDemoBuffer', () => { diff --git a/tests/parser_test.ts b/tests/parser_test.ts index db5d823..3555ccb 100644 --- a/tests/parser_test.ts +++ b/tests/parser_test.ts @@ -1,14 +1,12 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT -import { assert, assertEquals } from 'https://deno.land/std@0.191.0/testing/asserts.ts'; -import { describe, it } from 'https://deno.land/std@0.191.0/testing/bdd.ts'; -import { DemoMessages, NetMessages, SourceDemoParser, SourceTimer } from '../src/mod.ts'; +import { assert, assertEquals } from 'jsr:@std/assert'; +import { describe, it } from 'jsr:@std/testing/bdd'; +import { DemoMessages, NetMessages, SourceDemoParser } from '../src/mod.ts'; import { DataTable, Packet, StringTable, UserCmd } from '../src/messages.ts'; import { ScoreboardTempUpdate } from '../src/types/UserMessages.ts'; +import { SourceTimer } from '../src/speedrun/mod.ts'; describe('SourceDemoParser', () => { describe('#Portal', () => { @@ -23,7 +21,7 @@ describe('SourceDemoParser', () => { assertEquals(demo.demoProtocol, 3); assertEquals(demo.networkProtocol, 15); assertEquals(demo.serverName, 'localhost:0'); - assertEquals(demo.clientName, 'Can\'t Even'); + assertEquals(demo.clientName, "Can't Even"); assertEquals(demo.mapName, 'testchmb_a_00'); assertEquals(demo.gameDirectory, 'portal'); assertEquals(demo.playbackTime, 3.944999933242798); diff --git a/tests/save_test.ts b/tests/save_test.ts index a46b70c..cefb57c 100644 --- a/tests/save_test.ts +++ b/tests/save_test.ts @@ -1,11 +1,8 @@ -/* - * Copyright (c) 2018-2023, NeKz - * - * SPDX-License-Identifier: MIT - */ - -import { assertEquals } from 'https://deno.land/std@0.191.0/testing/asserts.ts'; -import { describe, it } from 'https://deno.land/std@0.191.0/testing/bdd.ts'; +// Copyright (c) 2018-2024, NeKz +// SPDX-License-Identifier: MIT + +import { assertEquals } from 'jsr:@std/assert'; +import { describe, it } from 'jsr:@std/testing/bdd'; import { SourceDemoParser } from '../src/mod.ts'; describe('SourceDemoParser', () => { diff --git a/tests/timer_test.ts b/tests/timer_test.ts new file mode 100644 index 0000000..fe15542 --- /dev/null +++ b/tests/timer_test.ts @@ -0,0 +1,52 @@ +// Copyright (c) 2023-2024, NeKz +// SPDX-License-Identifier: MIT + +import { assert, assertEquals } from 'jsr:@std/assert'; +import { describe, it } from 'jsr:@std/testing/bdd'; +import { SourceDemoParser } from '../src/mod.ts'; +import { SarTimer } from '../src/speedrun/mod.ts'; + +describe('SarTimer', () => { + describe('#Portal 2', () => { + it('time demo correctly', () => { + const buffer = Deno.readFileSync('./demos/public/portal2_sar_timer.dem'); + const parser = SourceDemoParser.default(); + const timer = SarTimer.default(); + + const demo = parser.parse(buffer); + const timing = timer.time(demo); + + assert(timing, 'Timing is not undefined'); + + assertEquals(timing.startTick, 497, 'Equal start tick'); + assertEquals(timing.endTick, 723, 'Equal end tick'); + assertEquals(timing.delta, 226, 'Equal delta'); + }); + + it('time demo correctly with multiple starts and stops', () => { + const buffer = Deno.readFileSync('./demos/public/portal2_sar_timer2.dem'); + const parser = SourceDemoParser.default(); + const timer = SarTimer.default(); + + const demo = parser.parse(buffer); + const timing = timer.time(demo); + + assert(timing, 'Timing is not undefined'); + + assertEquals(timing.startTick, 335, 'Equal start tick'); + assertEquals(timing.endTick, 533, 'Equal end tick'); + assertEquals(timing.delta, 198, 'Equal delta'); + }); + + it('time demo correctly without timer commands', () => { + const buffer = Deno.readFileSync('./demos/public/portal2.dem'); + const parser = SourceDemoParser.default(); + const timer = SarTimer.default(); + + const demo = parser.parse(buffer); + const timing = timer.time(demo); + + assertEquals(timing, undefined, 'Timing is undefined'); + }); + }); +});