Skip to content

Commit

Permalink
back to demoinfocs v4
Browse files Browse the repository at this point in the history
  • Loading branch information
sparkoo committed Dec 7, 2024
1 parent dfdb621 commit 8eb7386
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 49 deletions.
2 changes: 1 addition & 1 deletion cmd/wasm/wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"syscall/js"
"time"

"github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs"
"github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs"
"google.golang.org/protobuf/proto"
)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/alexflint/go-arg v1.5.1
github.com/golang/geo v0.0.0-20230421003525-6adc56603217
github.com/gorilla/websocket v1.5.3
github.com/markus-wa/demoinfocs-golang/v5 v5.0.0-20240904222726-24b77fe5ebfa
github.com/markus-wa/demoinfocs-golang/v4 v4.3.0
github.com/sparkoo/go-steam v0.0.0-20231112203532-968479d66868
github.com/stretchr/testify v1.9.0
github.com/yohcop/openid-go v1.0.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/markus-wa/demoinfocs-golang/v5 v5.0.0-20240904222726-24b77fe5ebfa h1:+pL8fo9ZRYpvYRw9RTP1QY032T4USfqNWeuZAsHD+ao=
github.com/markus-wa/demoinfocs-golang/v5 v5.0.0-20240904222726-24b77fe5ebfa/go.mod h1:703o9w3vKbMGvoIA9L/dyJVbRXIBcm2wOkIbO2wVZ7o=
github.com/markus-wa/demoinfocs-golang/v4 v4.3.0 h1:R+lazMCOA7ycuAKDPoqWjjLHYuIyor/sVM7hD9UaB+M=
github.com/markus-wa/demoinfocs-golang/v4 v4.3.0/go.mod h1:HoKANU0AlFzSgtEJ4YD/pMQw3L0dNRgtn2GPVD+tF7I=
github.com/markus-wa/go-unassert v0.1.3 h1:4N2fPLUS3929Rmkv94jbWskjsLiyNT2yQpCulTFFWfM=
github.com/markus-wa/go-unassert v0.1.3/go.mod h1:/pqt7a0LRmdsRNYQ2nU3SGrXfw3bLXrvIkakY/6jpPY=
github.com/markus-wa/gobitread v0.2.4 h1:BDr3dZnsqntDD4D8E7DzhkQlASIkQdfxCXLhWcI2K5A=
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

"github.com/alexflint/go-arg"
"github.com/gorilla/websocket"
"github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs"
"github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs"
"go.uber.org/zap"
"google.golang.org/protobuf/proto"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/message/message.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package message

import "github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs"
import "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs"

func NewRound(startTick int) *Round {
return &Round{
Expand Down
4 changes: 2 additions & 2 deletions pkg/parser/bomb.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"csgo-2d-demo-player/pkg/message"

"github.com/golang/geo/r3"
dem "github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs"
"github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs/events"
dem "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs"
"github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/events"
)

type bombHandler struct {
Expand Down
6 changes: 3 additions & 3 deletions pkg/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"time"

"github.com/golang/geo/r3"
dem "github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs"
"github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs/common"
"github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs/events"
dem "github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs"
"github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/common"
"github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/events"
"go.uber.org/zap"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/parser/weapons.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package parser
import (
"csgo-2d-demo-player/pkg/log"

"github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs/common"
"github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/common"
)

// TODO: unused, remove later. keeping here for now to have model names
Expand Down
49 changes: 12 additions & 37 deletions web/src/Player/PlayerApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,18 @@ export function PlayerApp() {

const urlParams = new URLSearchParams(window.location.search);
const channel = new BroadcastChannel(urlParams.get("uuid"));
channel.addEventListener("message", e => {
console.log("received", e, isWasmLoaded)
window.testt(e.data, function (data) {
channel.onmessage = (event) => {
console.log("received", event, isWasmLoaded)
window.testt(event.data, function (data) {
if (data instanceof Uint8Array) {
const msg = proto.Message.deserializeBinary(data).toObject()
messageBus.emit(msg)
} else {
// text frame
// console.log(event.data);
console.log("[message] text data received from server, this is weird. We're using protobufs ?!?!?", data);
messageBus.emit(JSON.parse(data))
}

// console.log(`[message] Data received from server: ${event.data}`);
// let msg = JSON.parse(event.data)
// messageBus.emit(msg)
})
});
};
messageBus.listen([13], function (msg) {
alert(msg.message)
// window.testt(byteArray)
Expand All @@ -55,37 +49,10 @@ export function PlayerApp() {
go.run(result.instance);
console.log("should be loaded now")
setIsWasmLoaded(true)
// window.withDownload("https://corsproxy.io/?" + encodeURIComponent("https://github.com/sparkoo/csgo-2d-demo-viewer/raw/refs/heads/master/test_demos/1-c26b4e22-66ac-4904-87cc-3b2b65a67ddb-1-1.dem.gz"))
// fetch("https://corsproxy.io/?" + encodeURIComponent("https://github.com/sparkoo/csgo-2d-demo-viewer/raw/refs/heads/master/test_demos/1-c26b4e22-66ac-4904-87cc-3b2b65a67ddb-1-1.dem.gz"))
// .then((result) => {
// console.log(result)
// result.arrayBuffer().then(b => {
// const data = new Uint8Array(b)
// console.log(data)
// window.testt(data, function (data) {
// if(data instanceof Uint8Array) {
// const msg = proto.Message.deserializeBinary(data).toObject()
// messageBus.emit(msg)
// } else {
// // text frame
// // console.log(event.data);
// console.log("[message] text data received from server, this is weird. We're using protobufs ?!?!?", data);
// messageBus.emit(JSON.parse(data))
// }

// // console.log(`[message] Data received from server: ${event.data}`);
// // let msg = JSON.parse(event.data)
// // messageBus.emit(msg)
// })
// })
// })
// .catch(err => console.log(err))
});
}

}, [isWasmLoaded])


return (
<ErrorBoundary>
<div className="grid-container">
Expand All @@ -98,3 +65,11 @@ export function PlayerApp() {
</div>
</ErrorBoundary>);
}

async function parseDemo(event, messageBus) {
await parse(event, messageBus)
}

async function parse(event, messageBus) {

}

0 comments on commit 8eb7386

Please sign in to comment.