Skip to content

Commit

Permalink
Remove Shares from admin packet format
Browse files Browse the repository at this point in the history
For OpenTTD 14.0 support - maybe we should add support for detecting game version and decoding as such? This isn't backwards compatible.

Signed-off-by: duck. <[email protected]>
  • Loading branch information
duckfullstop committed Apr 5, 2024
1 parent ccf1a51 commit e38bff4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
9 changes: 5 additions & 4 deletions pkg/admin/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,11 @@ type CompanyUpdate struct { // Type 115
Colour uint8 // Main company colour.
Password bool // Company is password protected.
BankruptcyQuarters uint8 // Quarters of Bankruptcy.
Share1 uint8 // Owner of Share 1.
Share2 uint8 // Owner of Share 2.
Share3 uint8 // Owner of Share 3.
Share4 uint8 // Owner of Share 4.
// Removed in OpenTTD 14.0
// Share1 uint8 // Owner of Share 1.
// Share2 uint8 // Owner of Share 2.
// Share3 uint8 // Owner of Share 3.
// Share4 uint8 // Owner of Share 4.
}

// CompanyRemove fires when a company is removed from the game.
Expand Down
8 changes: 4 additions & 4 deletions pkg/admin/packets/packets_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,10 @@ type ServerCompanyUpdate struct { // Type 115
Colour uint8 // Main company colour.
Password bool // Company is password protected.
BankruptcyQuarters uint8 // Quarters of Bankruptcy.
Share1 uint8 // Owner of Share 1.
Share2 uint8 // Owner of Share 2.
Share3 uint8 // Owner of Share 3.
Share4 uint8 // Owner of Share 4.
// Share1 uint8 // Owner of Share 1.
// Share2 uint8 // Owner of Share 2.
// Share3 uint8 // Owner of Share 3.
// Share4 uint8 // Owner of Share 4.
}

func (p ServerCompanyUpdate) String() string {
Expand Down
10 changes: 6 additions & 4 deletions pkg/admin/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,12 @@ func (s *State) onCompanyUpdate(se *Session, r *CompanyUpdate) (err error) {
com.Colour = helpers.OpenttdColour(r.Colour)
com.Passworded = r.Password
com.Bankruptcy = r.BankruptcyQuarters
com.Share1 = r.Share1
com.Share2 = r.Share2
com.Share3 = r.Share3
com.Share4 = r.Share4

// Shares removed in OpenTTD 14.0
// com.Share1 = r.Share1
// com.Share2 = r.Share2
// com.Share3 = r.Share3
// com.Share4 = r.Share4

s.Companies[r.ID] = com

Expand Down
18 changes: 9 additions & 9 deletions pkg/admin/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ type Company struct {
// The number of quarters this company has been in a bankruptcy state (this may mean they're about to be dissolved!)
Bankruptcy uint8 `json:"bankruptcy"`

// Share data
// Share 1 is owned by...
Share1 uint8 `json:"share1"`
// Share 2 is owned by...
Share2 uint8 `json:"share2"`
// Share 3 is owned by...
Share3 uint8 `json:"share3"`
// Share 4 is owned by...
Share4 uint8 `json:"share4"`
// Share data - removed in OpenTTD 14
// // Share 1 is owned by...
// Share1 uint8 `json:"share1"`
// // Share 2 is owned by...
// Share2 uint8 `json:"share2"`
// // Share 3 is owned by...
// Share3 uint8 `json:"share3"`
// // Share 4 is owned by...
// Share4 uint8 `json:"share4"`

// Cargo delivered in the current quarter.
CargoThisQuarter uint16 `json:"cargo_current"`
Expand Down

0 comments on commit e38bff4

Please sign in to comment.