Browse Source

Fixed reading past player fields and limited maximum number of illegible server messages.

Adam Klvač 1 year ago
parent
commit
a150de00ec
1 changed files with 9 additions and 2 deletions
  1. 9 2
      etdd/etdd.go

+ 9 - 2
etdd/etdd.go

@@ -98,6 +98,7 @@ type Demo struct {
 	levelTime        int
 	bloc             int // We need to maintain this in our thread.
 	initialized      bool
+	illegible        int
 }
 
 type message struct {
@@ -332,10 +333,16 @@ func (m *message) Parse(handler *Logger, demo *Demo) {
 			break
 
 		default:
+			demo.illegible++
 			handler.Error(errors.New(fmt.Sprintf("illegible server message %d", int(command))))
 
 		}
 
+		if demo.illegible == 10 {
+			demo.file = nil
+			break
+		}
+
 	}
 
 	m.parseBinaryMessage(handler, demo)
@@ -593,7 +600,7 @@ func (m *message) parseSnapshot(handler *Logger, demo *Demo) {
 
 		}
 
-		if oNum > nn {
+		if oNum > nn && nn < maxGEntities {
 			m.deltaEntity(demo, &newSnap, nn, &demo.baselines[nn], false)
 		}
 
@@ -737,7 +744,7 @@ func (m *message) readDeltaPlayerState(from *PlayerState, to *PlayerState) {
 
 	lc := m.readBits(8)
 
-	for i := 0; i < lc; i++ {
+	for i := 0; i < lc && i < len(playerStateFieldBits); i++ {
 
 		if m.readBits(1) == 1 {