Compare commits
5 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
d154b31bbf | 2 years ago |
|
|
66d79dc366 | 2 years ago |
|
|
4c343695c7 | 2 years ago |
|
|
5946d075d0 | 2 years ago |
|
|
909c0f02ff | 2 years ago |
@ -0,0 +1,398 @@
|
|||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.rsuser
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Mono auto generated files
|
||||||
|
mono_crash.*
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
[Ww][Ii][Nn]32/
|
||||||
|
[Aa][Rr][Mm]/
|
||||||
|
[Aa][Rr][Mm]64/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
[Ll]ogs/
|
||||||
|
|
||||||
|
# Visual Studio 2015/2017 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# Visual Studio 2017 auto generated files
|
||||||
|
Generated\ Files/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUnit
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
nunit-*.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
BenchmarkDotNet.Artifacts/
|
||||||
|
|
||||||
|
# .NET Core
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
|
||||||
|
# ASP.NET Scaffolding
|
||||||
|
ScaffoldingReadMe.txt
|
||||||
|
|
||||||
|
# StyleCop
|
||||||
|
StyleCopReport.xml
|
||||||
|
|
||||||
|
# Files built by Visual Studio
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_h.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.iobj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.ipdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*_wpftmp.csproj
|
||||||
|
*.log
|
||||||
|
*.tlog
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# Visual Studio Trace Files
|
||||||
|
*.e2e
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# Coverlet is a free, cross platform Code Coverage Tool
|
||||||
|
coverage*.json
|
||||||
|
coverage*.xml
|
||||||
|
coverage*.info
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# NuGet Symbol Packages
|
||||||
|
*.snupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/[Pp]ackages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/[Pp]ackages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/[Pp]ackages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
*.appx
|
||||||
|
*.appxbundle
|
||||||
|
*.appxupload
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!?*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Including strong name files can present a security risk
|
||||||
|
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||||
|
#*.snk
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
ServiceFabricBackup/
|
||||||
|
*.rptproj.bak
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
*.ndf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
*.rptproj.rsuser
|
||||||
|
*- [Bb]ackup.rdl
|
||||||
|
*- [Bb]ackup ([0-9]).rdl
|
||||||
|
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||||
|
*.vbp
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||||
|
*.dsw
|
||||||
|
*.dsp
|
||||||
|
|
||||||
|
# Visual Studio 6 technical files
|
||||||
|
*.ncb
|
||||||
|
*.aps
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# CodeRush personal settings
|
||||||
|
.cr/personal
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
*.tss
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
||||||
|
|
||||||
|
# OpenCover UI analysis results
|
||||||
|
OpenCover/
|
||||||
|
|
||||||
|
# Azure Stream Analytics local run output
|
||||||
|
ASALocalRun/
|
||||||
|
|
||||||
|
# MSBuild Binary and Structured Log
|
||||||
|
*.binlog
|
||||||
|
|
||||||
|
# NVidia Nsight GPU debugger configuration file
|
||||||
|
*.nvuser
|
||||||
|
|
||||||
|
# MFractors (Xamarin productivity tool) working folder
|
||||||
|
.mfractor/
|
||||||
|
|
||||||
|
# Local History for Visual Studio
|
||||||
|
.localhistory/
|
||||||
|
|
||||||
|
# Visual Studio History (VSHistory) files
|
||||||
|
.vshistory/
|
||||||
|
|
||||||
|
# BeatPulse healthcheck temp database
|
||||||
|
healthchecksdb
|
||||||
|
|
||||||
|
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||||
|
MigrationBackup/
|
||||||
|
|
||||||
|
# Ionide (cross platform F# VS Code tools) working folder
|
||||||
|
.ionide/
|
||||||
|
|
||||||
|
# Fody - auto-generated XML schema
|
||||||
|
FodyWeavers.xsd
|
||||||
|
|
||||||
|
# VS Code files for those working on multiple tools
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
*.code-workspace
|
||||||
|
|
||||||
|
# Local History for Visual Studio Code
|
||||||
|
.history/
|
||||||
|
|
||||||
|
# Windows Installer files from build outputs
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# JetBrains Rider
|
||||||
|
*.sln.iml
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
// Use IntelliSense to find out which attributes exist for C# debugging
|
||||||
|
// Use hover for the description of the existing attributes
|
||||||
|
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
|
||||||
|
"name": ".NET Core Launch (console)",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "build",
|
||||||
|
// If you have changed target frameworks, make sure to update the program path.
|
||||||
|
"program": "${workspaceFolder}/src/bin/Debug/net7.0/src.dll",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}/src",
|
||||||
|
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
|
||||||
|
"console": "internalConsole",
|
||||||
|
"stopAtEntry": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": ".NET Core Attach",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "attach"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "build",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"build",
|
||||||
|
"${workspaceFolder}/src/src.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "publish",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"publish",
|
||||||
|
"${workspaceFolder}/src/src.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "watch",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"watch",
|
||||||
|
"run",
|
||||||
|
"--project",
|
||||||
|
"${workspaceFolder}/src/src.csproj"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -0,0 +1,299 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using System.Text;
|
||||||
|
using BitSet;
|
||||||
|
using DemoParser;
|
||||||
|
using TF2Net;
|
||||||
|
using TF2Net.Data;
|
||||||
|
using TF2Net.NetMessages;
|
||||||
|
|
||||||
|
namespace DemoLib.Commands
|
||||||
|
{
|
||||||
|
public enum DemoCommandType : byte {
|
||||||
|
|
||||||
|
dem_invalid = 0,
|
||||||
|
|
||||||
|
// it's a startup message, process as fast as possible
|
||||||
|
dem_signon = 1,
|
||||||
|
// it's a normal network packet that we stored off
|
||||||
|
dem_packet,
|
||||||
|
// sync client clock to demo tick
|
||||||
|
dem_synctick,
|
||||||
|
// console command
|
||||||
|
dem_consolecmd,
|
||||||
|
// user input command
|
||||||
|
dem_usercmd,
|
||||||
|
// network data tables
|
||||||
|
dem_datatables,
|
||||||
|
// end of time.
|
||||||
|
dem_stop,
|
||||||
|
|
||||||
|
dem_stringtables,
|
||||||
|
|
||||||
|
// Last command -- not necessary in C#
|
||||||
|
//dem_lastcmd = dem_stringtables
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DemoCommand
|
||||||
|
{
|
||||||
|
public DemoCommandType Type { get; protected set; } = DemoCommandType.dem_invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
class TimestampedDemoCommand : DemoCommand
|
||||||
|
{
|
||||||
|
public int Tick { get; set; }
|
||||||
|
|
||||||
|
public TimestampedDemoCommand(Stream input)
|
||||||
|
{
|
||||||
|
using (BinaryReader reader = new BinaryReader(input, Encoding.Default, true))
|
||||||
|
{
|
||||||
|
Tick = reader.ReadInt32();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sealed class DemoConsoleCommand : TimestampedDemoCommand
|
||||||
|
{
|
||||||
|
public string Command { get; set; }
|
||||||
|
|
||||||
|
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
|
||||||
|
private string DebuggerDisplayAttributeValue
|
||||||
|
{
|
||||||
|
get { return Command.Replace('"', '\''); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public DemoConsoleCommand(Stream input) : base(input)
|
||||||
|
{
|
||||||
|
Type = DemoCommandType.dem_consolecmd;
|
||||||
|
|
||||||
|
using (BinaryReader reader = new BinaryReader(input, Encoding.ASCII, true))
|
||||||
|
Command = new string(reader.ReadChars(reader.ReadInt32())).TrimEnd('\0');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DemoDataTablesCommand : TimestampedDemoCommand {
|
||||||
|
const int PROPINFOBITS_NUMPROPS = 10;
|
||||||
|
const int PROPINFOBITS_TYPE = 5;
|
||||||
|
const int PROPINFOBITS_FLAGS = SPROP_NUMFLAGBITS_NETWORKED;
|
||||||
|
const int PROPINFOBITS_NUMELEMENTS = 10;
|
||||||
|
const int PROPINFOBITS_NUMBITS = 7;
|
||||||
|
|
||||||
|
const int SPROP_NUMFLAGBITS_NETWORKED = 16;
|
||||||
|
|
||||||
|
public IList<SendTable> SendTables { get; set; } = new List<SendTable>();
|
||||||
|
public IList<ServerClass> ServerClasses { get; set; } = new List<ServerClass>();
|
||||||
|
|
||||||
|
public DemoDataTablesCommand(Stream input) : base(input)
|
||||||
|
{
|
||||||
|
Type = DemoCommandType.dem_datatables;
|
||||||
|
|
||||||
|
BitStream stream;
|
||||||
|
using (BinaryReader reader = new BinaryReader(input, Encoding.ASCII, true))
|
||||||
|
{
|
||||||
|
int length = reader.ReadInt32();
|
||||||
|
stream = new BitStream(reader.ReadBytes(length));
|
||||||
|
}
|
||||||
|
|
||||||
|
while (stream.ReadBool())
|
||||||
|
SendTables.Add(ParseSendTable(stream));
|
||||||
|
|
||||||
|
// Link referenced datatables
|
||||||
|
foreach (SendTable table in SendTables)
|
||||||
|
{
|
||||||
|
foreach (SendPropDefinition dtProp in table.Properties)
|
||||||
|
{
|
||||||
|
if (dtProp.Type == SendPropType.Datatable)
|
||||||
|
{
|
||||||
|
dtProp.Table = SendTables.Single(t => t.NetTableName == dtProp.ExcludeName);
|
||||||
|
dtProp.ExcludeName = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
short serverClasses = stream.ReadShort();
|
||||||
|
Debug.Assert(serverClasses > 0);
|
||||||
|
|
||||||
|
ServerClasses = new List<ServerClass>(serverClasses);
|
||||||
|
|
||||||
|
for (int i = 0; i < serverClasses; i++)
|
||||||
|
{
|
||||||
|
short classID = stream.ReadShort();
|
||||||
|
if (classID >= serverClasses)
|
||||||
|
throw new Exception("Demo parsing failed: Invalid server class ID");
|
||||||
|
|
||||||
|
ServerClass sc = new ServerClass();
|
||||||
|
sc.Classname = stream.ReadCString();
|
||||||
|
sc.DatatableName = stream.ReadCString();
|
||||||
|
ServerClasses.Add(sc);
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.Assert((stream.Length - stream.Cursor) < 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
static SendTable ParseSendTable(BitStream stream)
|
||||||
|
{
|
||||||
|
SendTable table = new SendTable();
|
||||||
|
|
||||||
|
table.Unknown1 = stream.ReadBool();
|
||||||
|
|
||||||
|
table.NetTableName = stream.ReadCString();
|
||||||
|
|
||||||
|
int propertyCount = (int)stream.ReadULong(PROPINFOBITS_NUMPROPS);
|
||||||
|
|
||||||
|
SendPropDefinition arrayElementProp = null;
|
||||||
|
|
||||||
|
for (int i = 0; i < propertyCount; i++)
|
||||||
|
{
|
||||||
|
SendPropDefinition prop = new SendPropDefinition(table);
|
||||||
|
|
||||||
|
prop.Type = (SendPropType)stream.ReadULong(PROPINFOBITS_TYPE);
|
||||||
|
Debug.Assert(Enum.GetValues(typeof(SendPropType)).Cast<SendPropType>().Contains(prop.Type));
|
||||||
|
|
||||||
|
Debug.Assert(prop.Type == SendPropType.Datatable ? prop.Flags == 0 : true);
|
||||||
|
|
||||||
|
prop.Name = stream.ReadCString();
|
||||||
|
|
||||||
|
prop.Flags = (SendPropFlags)stream.ReadULong(PROPINFOBITS_FLAGS);
|
||||||
|
|
||||||
|
if (prop.Type == SendPropType.Datatable)
|
||||||
|
{
|
||||||
|
prop.ExcludeName = stream.ReadCString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((prop.Flags & SendPropFlags.Exclude) != 0)
|
||||||
|
prop.ExcludeName = stream.ReadCString();
|
||||||
|
else if (prop.Type == SendPropType.Array)
|
||||||
|
prop.ArrayElements = (int)stream.ReadULong(PROPINFOBITS_NUMELEMENTS);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prop.LowValue = stream.ReadSingle();
|
||||||
|
prop.HighValue = stream.ReadSingle();
|
||||||
|
|
||||||
|
prop.BitCount = stream.ReadULong(PROPINFOBITS_NUMBITS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prop.Flags.HasFlag(SendPropFlags.NoScale))
|
||||||
|
{
|
||||||
|
if (prop.Type == SendPropType.Float)
|
||||||
|
prop.BitCount = 32;
|
||||||
|
else if (prop.Type == SendPropType.Vector)
|
||||||
|
{
|
||||||
|
if (!prop.Flags.HasFlag(SendPropFlags.Normal))
|
||||||
|
prop.BitCount = 32 * 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arrayElementProp != null)
|
||||||
|
{
|
||||||
|
Debug.Assert(prop.Type == SendPropType.Array);
|
||||||
|
prop.ArrayProperty = arrayElementProp;
|
||||||
|
arrayElementProp = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prop.Flags.HasFlag(SendPropFlags.InsideArray))
|
||||||
|
{
|
||||||
|
Debug.Assert(arrayElementProp == null);
|
||||||
|
Debug.Assert(!prop.Flags.HasFlag(SendPropFlags.ChangesOften));
|
||||||
|
arrayElementProp = prop;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
table.Properties.Add(prop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sealed class DemoUserCommand : TimestampedDemoCommand
|
||||||
|
{
|
||||||
|
public int OutgoingSequence { get; set; }
|
||||||
|
|
||||||
|
public byte[] Data { get; set; }
|
||||||
|
|
||||||
|
public DemoUserCommand(Stream input) : base(input)
|
||||||
|
{
|
||||||
|
Type = DemoCommandType.dem_usercmd;
|
||||||
|
|
||||||
|
using (BinaryReader reader = new BinaryReader(input, Encoding.ASCII, true))
|
||||||
|
{
|
||||||
|
OutgoingSequence = reader.ReadInt32();
|
||||||
|
|
||||||
|
Data = reader.ReadBytes(reader.ReadInt32());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sealed class DemoSyncTickCommand : TimestampedDemoCommand
|
||||||
|
{
|
||||||
|
public DemoSyncTickCommand(Stream input) : base(input)
|
||||||
|
{
|
||||||
|
Type = DemoCommandType.dem_synctick;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sealed class DemoStringTablesCommand : TimestampedDemoCommand
|
||||||
|
{
|
||||||
|
public BitStream Data { get; set; }
|
||||||
|
|
||||||
|
public DemoStringTablesCommand(Stream input) : base(input)
|
||||||
|
{
|
||||||
|
Type = DemoCommandType.dem_stringtables;
|
||||||
|
|
||||||
|
using (BinaryReader reader = new BinaryReader(input, Encoding.ASCII, true))
|
||||||
|
{
|
||||||
|
int dataLength = reader.ReadInt32();
|
||||||
|
Data = new BitStream(reader.ReadBytes(dataLength));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sealed class DemoSignonCommand : DemoPacketCommand
|
||||||
|
{
|
||||||
|
public DemoSignonCommand(Stream input, ulong signonLength) : base(input)
|
||||||
|
{
|
||||||
|
Type = DemoCommandType.dem_signon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DemoPacketCommand : TimestampedDemoCommand
|
||||||
|
{
|
||||||
|
public DemoViewpoint Viewpoint { get; set; }
|
||||||
|
|
||||||
|
public int SequenceIn { get; set; }
|
||||||
|
public int SequenceOut { get; set; }
|
||||||
|
|
||||||
|
public IList<INetMessage> Messages { get; set; }
|
||||||
|
|
||||||
|
public DemoPacketCommand(Stream input) : base(input)
|
||||||
|
{
|
||||||
|
Type = DemoCommandType.dem_packet;
|
||||||
|
|
||||||
|
using (BinaryReader r = new BinaryReader(input, Encoding.ASCII, true))
|
||||||
|
{
|
||||||
|
Viewpoint = new DemoViewpoint();
|
||||||
|
|
||||||
|
Viewpoint.ViewpointFlags = (DemoViewpoint.Flags)r.ReadInt32();
|
||||||
|
|
||||||
|
Viewpoint.ViewOrigin1 = new Vector(r.ReadSingle(), r.ReadSingle(), r.ReadSingle());
|
||||||
|
Viewpoint.ViewAngles1 = new Vector(r.ReadSingle(), r.ReadSingle(), r.ReadSingle());
|
||||||
|
Viewpoint.LocalViewAngles1 = new Vector(r.ReadSingle(), r.ReadSingle(), r.ReadSingle());
|
||||||
|
|
||||||
|
Viewpoint.ViewOrigin2 = new Vector(r.ReadSingle(), r.ReadSingle(), r.ReadSingle());
|
||||||
|
Viewpoint.ViewAngles2 = new Vector(r.ReadSingle(), r.ReadSingle(), r.ReadSingle());
|
||||||
|
Viewpoint.LocalViewAngles2 = new Vector(r.ReadSingle(), r.ReadSingle(), r.ReadSingle());
|
||||||
|
|
||||||
|
SequenceIn = r.ReadInt32();
|
||||||
|
SequenceOut = r.ReadInt32();
|
||||||
|
|
||||||
|
BitStream data = new BitStream(r.ReadBytes((int)r.ReadUInt32()));
|
||||||
|
Messages = NetMessageCoder.Decode(data).ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
using BitSet;
|
||||||
|
using TF2Net.Data;
|
||||||
|
using TF2Net.NetMessages;
|
||||||
|
|
||||||
|
namespace TF2Net.Extensions
|
||||||
|
{
|
||||||
|
public static class BitStreamExtensions
|
||||||
|
{
|
||||||
|
public static Vector ReadVector(this BitStream stream)
|
||||||
|
{
|
||||||
|
bool flagX = stream.ReadBool();
|
||||||
|
bool flagY = stream.ReadBool();
|
||||||
|
bool flagZ = stream.ReadBool();
|
||||||
|
|
||||||
|
Vector vector = new Vector();
|
||||||
|
if (flagX)
|
||||||
|
vector.X = BitCoord.Read(stream);
|
||||||
|
if (flagY)
|
||||||
|
vector.Y = BitCoord.Read(stream);
|
||||||
|
if (flagZ)
|
||||||
|
vector.Z = BitCoord.Read(stream);
|
||||||
|
return vector;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue