Skip to content

Commit c025497

Browse files
authored
Some fixes (#3)
* Stub commands 39 and 78 * Don't fail if no resign command
1 parent 7700832 commit c025497

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

parser/formatter.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,6 @@ func getLosingTeams(commandList *[]RawGameCommand, profileKeys *map[string]Profi
177177
}
178178
}
179179

180-
// If no one resigned, return error
181-
if len(resigningPlayers) == 0 {
182-
return nil, fmt.Errorf("no resign commands found")
183-
}
184-
185180
// Use a map to deduplicate team IDs
186181
teamIds := make(map[int]bool)
187182

@@ -195,10 +190,6 @@ func getLosingTeams(commandList *[]RawGameCommand, profileKeys *map[string]Profi
195190
}
196191
}
197192

198-
if len(teamIds) == 0 {
199-
return nil, fmt.Errorf("could not find team IDs for resigning players")
200-
}
201-
202193
return teamIds, nil
203194
}
204195

parser/gameCommands.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func BuildCommandFactory() *CommandFactory {
6161
factory.Register(35, AutoScoutEventCommand{})
6262
factory.Register(37, ChangeControlGroupContentsCommand{})
6363
factory.Register(38, RepairCommand{})
64+
factory.Register(39, UnknownCommand39{})
6465
factory.Register(41, TauntCommand{})
6566
factory.Register(44, CheatCommand{})
6667
factory.Register(45, CancelQueuedItemCommand{})
@@ -74,6 +75,7 @@ func BuildCommandFactory() *CommandFactory {
7475
factory.Register(71, SeekShelterCommand{})
7576
factory.Register(72, PrequeueTechCommand{})
7677
factory.Register(75, PrebuyGodPowerCommand{})
78+
factory.Register(78, UnknownCommand78{})
7779

7880
return factory
7981
}
@@ -728,6 +730,24 @@ func (cmd RepairCommand) Refine(baseCommand *BaseCommand, data *[]byte) RawGameC
728730
return RepairCommand{*baseCommand}
729731
}
730732

733+
// ========================================================================
734+
// 39 - Unknown
735+
// ========================================================================
736+
737+
type UnknownCommand39 struct {
738+
BaseCommand
739+
}
740+
741+
func (cmd UnknownCommand39) Refine(baseCommand *BaseCommand, data *[]byte) RawGameCommand {
742+
inputTypes := []func() int{unpackInt32, unpackInt32, unpackInt32}
743+
byteLength := 0
744+
for _, f := range inputTypes {
745+
byteLength += f()
746+
}
747+
enrichBaseCommand(baseCommand, byteLength)
748+
return UnknownCommand39{*baseCommand}
749+
}
750+
731751
// ========================================================================
732752
// 41 - taunt
733753
// ========================================================================
@@ -1049,3 +1069,21 @@ func (cmd PrebuyGodPowerCommand) Refine(baseCommand *BaseCommand, data *[]byte)
10491069
enrichBaseCommand(baseCommand, byteLength)
10501070
return PrebuyGodPowerCommand{*baseCommand}
10511071
}
1072+
1073+
// ========================================================================
1074+
// 78 - Unknown
1075+
// ========================================================================
1076+
1077+
type UnknownCommand78 struct {
1078+
BaseCommand
1079+
}
1080+
1081+
func (cmd UnknownCommand78) Refine(baseCommand *BaseCommand, data *[]byte) RawGameCommand {
1082+
inputTypes := []func() int{unpackInt32, unpackInt32, unpackInt32, unpackInt32, unpackInt32}
1083+
byteLength := 0
1084+
for _, f := range inputTypes {
1085+
byteLength += f()
1086+
}
1087+
enrichBaseCommand(baseCommand, byteLength)
1088+
return UnknownCommand78{*baseCommand}
1089+
}

0 commit comments

Comments
 (0)