Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
add: fleet rename
Browse files Browse the repository at this point in the history
  • Loading branch information
ggmolly committed Jul 14, 2024
1 parent b095bd2 commit bf1f91f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions answer/fleet_rename.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package answer

import (
"github.com/ggmolly/belfast/connection"
"github.com/ggmolly/belfast/protobuf"
"google.golang.org/protobuf/proto"
)

func FleetRename(buffer *[]byte, client *connection.Client) (int, int, error) {
var payload protobuf.CS_12104
if err := proto.Unmarshal(*buffer, &payload); err != nil {
return 0, 12104, err
}
response := protobuf.SC_12105{
Result: proto.Uint32(0),
}

// Check if the commander has this fleet, if the fleet exists, rename it
fleet, ok := client.Commander.FleetsMap[payload.GetId()]
if !ok {
response.Result = proto.Uint32(1)
} else {
if err := fleet.RenameFleet(payload.GetName()); err != nil {
response.Result = proto.Uint32(2)
}
}
return client.SendMessage(12105, &response)
}
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ func init() {

// Fleet
packets.RegisterPacketHandler(12102, []packets.PacketHandler{answer.FleetCommit})
packets.RegisterPacketHandler(12104, []packets.PacketHandler{answer.FleetRename})

packets.RegisterPacketHandler(13107, []packets.PacketHandler{func(b *[]byte, c *connection.Client) (int, int, error) {
response := protobuf.SC_13108{
Expand Down

0 comments on commit bf1f91f

Please sign in to comment.