Skip to content

Commit

Permalink
fix: defense site detection after atk/def swap
Browse files Browse the repository at this point in the history
  • Loading branch information
redraskal committed Aug 18, 2024
1 parent b54d339 commit 96bd464
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions dissect/site.go
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
package dissect

import (
"bytes"
"strings"

"github.com/rs/zerolog/log"
)

var currentSitePattern = []byte{0xFC, 0xC6, 0xA8, 0x60, 0x01}

func readSpawn(r *Reader) error {
location, err := r.String()
if err != nil {
return err
}
if err = r.Skip(37); err != nil {
if err = r.Skip(150); err != nil {
return err
}
flag, err := r.Int()
pattern, err := r.Bytes(5)
if err != nil {
return err
}
if !strings.Contains(location, "<br/>") {
return nil
}
log.Debug().
Int("flag", flag).
Str("site", location).
Msg("site")
if r.Header.Site == "" && (flag == 1 || flag == 164) {
Send()
if r.Header.Site == "" || bytes.Equal(pattern, currentSitePattern) {
formatted := strings.Replace(location, "<br/>", ", ", 1)
log.Debug().Str("site", formatted).Msg("defense site")
for i, p := range r.Header.Players {
Expand Down

0 comments on commit 96bd464

Please sign in to comment.