Skip to content

Commit 7c16ba6

Browse files
Copilotsparkoo
andcommitted
Fix loaded ammo -1 issue by filtering weapons by owner
Co-authored-by: sparkoo <[email protected]>
1 parent 99922d1 commit 7c16ba6

File tree

3 files changed

+524
-520
lines changed

3 files changed

+524
-520
lines changed

parser/pkg/log/logger.go

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
1-
package log
2-
3-
import (
4-
"csgo-2d-demo-player/conf"
5-
"fmt"
6-
7-
"go.uber.org/zap"
8-
)
9-
10-
var logger *zap.Logger
11-
12-
func Init(mode conf.Mode) {
13-
switch mode {
14-
case conf.MODE_DEV:
15-
logger = zap.Must(zap.NewDevelopment())
16-
logger.Info("initialized development logger")
17-
case conf.MODE_PROD:
18-
logger = zap.Must(zap.NewProduction())
19-
logger.Info("initialized production logger")
20-
default:
21-
panic("unknown mode")
22-
}
23-
}
24-
25-
func Close() {
26-
errClose := logger.Sync()
27-
if errClose != nil {
28-
panic(errClose)
29-
}
30-
}
31-
32-
func L() *zap.Logger {
33-
if logger == nil {
34-
Init(conf.MODE_DEV)
35-
}
36-
return logger
37-
}
38-
39-
func Print(msg string, err error) {
40-
L().Info(msg, zap.Error(err))
41-
}
42-
43-
func Printf(msg string, args ...any) {
44-
L().Info(fmt.Sprintf(msg, args...))
45-
}
46-
47-
func Println(msg string, err error) {
48-
L().Info(msg, zap.Error(err))
49-
}
1+
package log
2+
3+
import (
4+
"csgo-2d-demo-player/conf"
5+
"fmt"
6+
7+
"go.uber.org/zap"
8+
)
9+
10+
var logger *zap.Logger
11+
12+
func Init(mode conf.Mode) {
13+
switch mode {
14+
case conf.MODE_DEV:
15+
logger = zap.Must(zap.NewDevelopment())
16+
logger.Info("initialized development logger")
17+
case conf.MODE_PROD:
18+
logger = zap.Must(zap.NewProduction())
19+
logger.Info("initialized production logger")
20+
default:
21+
panic("unknown mode")
22+
}
23+
}
24+
25+
func Close() {
26+
errClose := logger.Sync()
27+
if errClose != nil {
28+
panic(errClose)
29+
}
30+
}
31+
32+
func L() *zap.Logger {
33+
if logger == nil {
34+
Init(conf.MODE_DEV)
35+
}
36+
return logger
37+
}
38+
39+
func Print(msg string, err error) {
40+
L().Info(msg, zap.Error(err))
41+
}
42+
43+
func Printf(msg string, args ...any) {
44+
L().Info(fmt.Sprintf(msg, args...))
45+
}
46+
47+
func Println(msg string, err error) {
48+
L().Info(msg, zap.Error(err))
49+
}

parser/pkg/parser/map.go

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
1-
// Package metadata provides metadata and utility functions,
2-
// like translations from ingame coordinates to radar image pixels (see also /assets/maps directory).
3-
package parser
4-
5-
import (
6-
"github.com/golang/geo/r2"
7-
)
8-
9-
// MapCS represents a CS:GO map. It contains information required to translate
10-
// in-game world coordinates to coordinates relative to (0, 0) on the provided map-overviews (radar images).
11-
type MapCS struct {
12-
Name string
13-
PZero r2.Point
14-
Scale float64
15-
}
16-
17-
// Translate translates in-game world-relative coordinates to (0, 0) relative coordinates.
18-
func (m MapCS) Translate(x, y float64) (float64, float64) {
19-
return x - m.PZero.X, m.PZero.Y - y
20-
}
21-
22-
// TranslateScale translates and scales in-game world-relative coordinates to (0, 0) relative coordinates.
23-
// The outputs are pixel coordinates for the radar images found in the maps folder.
24-
func (m MapCS) TranslateScale(x, y float64) (float64, float64) {
25-
x, y = m.Translate(x, y)
26-
return x / m.Scale, y / m.Scale
27-
}
28-
29-
// MapNameToMap translates a map name to a Map.
30-
var MapNameToMap = make(map[string]MapCS)
31-
32-
// makeMap creates a map stuct initialized with the given parameters.
33-
func makeMap(name string, x, y, scale float64) MapCS {
34-
m := MapCS{Name: name, PZero: r2.Point{X: x, Y: y}, Scale: scale}
35-
36-
MapNameToMap[name] = m
37-
38-
return m
39-
}
40-
41-
// Pre-defined map translations.
42-
// see "steamapps/common/Counter-Strike Global Offensive/csgo/resource/overviews/*.txt"
43-
var (
44-
MapDeAncient = makeMap("de_ancient", -2953, 2164, 5)
45-
MapDeAnubis = makeMap("de_anubis", -2796, 3328, 5.22)
46-
MapDeCache = makeMap("de_cache", -2000, 3250, 5.5)
47-
MapDeCanals = makeMap("de_canals", -2496, 1792, 4)
48-
MapDeCbble = makeMap("de_cbble", -3840, 3072, 6)
49-
MapDeDust2 = makeMap("de_dust2", -2476, 3239, 4.4)
50-
MapDeInferno = makeMap("de_inferno", -2087, 3870, 4.9)
51-
MapDeMirage = makeMap("de_mirage", -3230, 1713, 5)
52-
MapDeNuke = makeMap("de_nuke", -3453, 2887, 7)
53-
MapDeOverpass = makeMap("de_overpass", -4831, 1781, 5.2)
54-
MapDeTrain = makeMap("de_train", -2477, 2392, 4.7)
55-
MapDeVertigo = makeMap("de_vertigo", -3168, 1762, 4)
56-
MapCsAgency = makeMap("cs_agency", -2947, 2492, 5)
57-
MapCsOffice = makeMap("cs_office", -1838, 1858, 4.1)
58-
)
1+
// Package metadata provides metadata and utility functions,
2+
// like translations from ingame coordinates to radar image pixels (see also /assets/maps directory).
3+
package parser
4+
5+
import (
6+
"github.com/golang/geo/r2"
7+
)
8+
9+
// MapCS represents a CS:GO map. It contains information required to translate
10+
// in-game world coordinates to coordinates relative to (0, 0) on the provided map-overviews (radar images).
11+
type MapCS struct {
12+
Name string
13+
PZero r2.Point
14+
Scale float64
15+
}
16+
17+
// Translate translates in-game world-relative coordinates to (0, 0) relative coordinates.
18+
func (m MapCS) Translate(x, y float64) (float64, float64) {
19+
return x - m.PZero.X, m.PZero.Y - y
20+
}
21+
22+
// TranslateScale translates and scales in-game world-relative coordinates to (0, 0) relative coordinates.
23+
// The outputs are pixel coordinates for the radar images found in the maps folder.
24+
func (m MapCS) TranslateScale(x, y float64) (float64, float64) {
25+
x, y = m.Translate(x, y)
26+
return x / m.Scale, y / m.Scale
27+
}
28+
29+
// MapNameToMap translates a map name to a Map.
30+
var MapNameToMap = make(map[string]MapCS)
31+
32+
// makeMap creates a map stuct initialized with the given parameters.
33+
func makeMap(name string, x, y, scale float64) MapCS {
34+
m := MapCS{Name: name, PZero: r2.Point{X: x, Y: y}, Scale: scale}
35+
36+
MapNameToMap[name] = m
37+
38+
return m
39+
}
40+
41+
// Pre-defined map translations.
42+
// see "steamapps/common/Counter-Strike Global Offensive/csgo/resource/overviews/*.txt"
43+
var (
44+
MapDeAncient = makeMap("de_ancient", -2953, 2164, 5)
45+
MapDeAnubis = makeMap("de_anubis", -2796, 3328, 5.22)
46+
MapDeCache = makeMap("de_cache", -2000, 3250, 5.5)
47+
MapDeCanals = makeMap("de_canals", -2496, 1792, 4)
48+
MapDeCbble = makeMap("de_cbble", -3840, 3072, 6)
49+
MapDeDust2 = makeMap("de_dust2", -2476, 3239, 4.4)
50+
MapDeInferno = makeMap("de_inferno", -2087, 3870, 4.9)
51+
MapDeMirage = makeMap("de_mirage", -3230, 1713, 5)
52+
MapDeNuke = makeMap("de_nuke", -3453, 2887, 7)
53+
MapDeOverpass = makeMap("de_overpass", -4831, 1781, 5.2)
54+
MapDeTrain = makeMap("de_train", -2477, 2392, 4.7)
55+
MapDeVertigo = makeMap("de_vertigo", -3168, 1762, 4)
56+
MapCsAgency = makeMap("cs_agency", -2947, 2492, 5)
57+
MapCsOffice = makeMap("cs_office", -1838, 1858, 4.1)
58+
)

0 commit comments

Comments
 (0)