Coder Social home page Coder Social logo

gopenttd's Issues

Setting UpdateTypeClientInfo to UpdateFrequencyAutomatically throws Panic when server info is queried.

This is very odd, but if you request that UpdateTypeClientInfo is set to UpdateFrequencyAutomatically ie:
sess.RequestUpdates(enum.UpdateTypeClientInfo, enum.UpdateFrequencyAutomatically)

and then query server info, by either viewing the server in OpenTTD Multiplayer List or clicking the Refresh server

gopenttd will Panic with:

"reflect.Set: value of type uint8 is not assignable to type enum.NetE...
Stack:
	2  0x00000000004a4ad1 in reflect.Value.assignTo
	    at /snap/go/current/src/reflect/value.go:2797
	3  0x00000000004a1a32 in reflect.Value.Set
	    at /snap/go/current/src/reflect/value.go:1905
	4  0x000000000075d51e in github.com/ropenttd/gopenttd/pkg/admin.ottdUnmarshalData
	    at /home/baa/go/pkg/mod/memleak.eu/sn0w/[email protected]/pkg/admin/proto_unmarshal.go:46
	5  0x000000000075d0b8 in github.com/ropenttd/gopenttd/pkg/admin.ottdUnmarshal
	    at /home/baa/go/pkg/mod/memleak.eu/sn0w/[email protected]/pkg/admin/proto_unmarshal.go:26
	6  0x000000000075c2c5 in github.com/ropenttd/gopenttd/pkg/admin.(*Session).onEvent
	    at /home/baa/go/pkg/mod/memleak.eu/sn0w/[email protected]/pkg/admin/proto_api.go:419
	7  0x000000000075b42b in github.com/ropenttd/gopenttd/pkg/admin.(*Session).listen
	    at /home/baa/go/pkg/mod/memleak.eu/sn0w/[email protected]/pkg/admin/proto_api.go:287
	8  0x000000000075a1c7 in github.com/ropenttd/gopenttd/pkg/admin.(*Session).Open路dwrap路10
	    at /home/baa/go/pkg/mod/memleak.eu/sn0w/[email protected]/pkg/admin/proto_api.go:108

I find that setting type NetError uint8 to type NetError int8 under pgk/enum/constants.go resolves the issue... but I'm not sure if that's correct or not: https://memleak.eu/sn0w/gopenttd/commit/63e5c696f0cd942a7b7388881e08f95225ce88ac

High CPU Usage and Handlers not being triggered.

Hi, thanks for making this it looks really good and I'd love to use it but I'm running into some trouble
When I open a session my CPU usage on a single core jumps to 100%,

Also I have some handlers but only the very first date event is triggered none of the others seem to be working, this is my code:

package main

import (
	"fmt"
	"os"
	"os/signal"
	"syscall"

	"github.com/ropenttd/gopenttd/pkg/admin"
	"github.com/ropenttd/gopenttd/pkg/util"
)

func main() {
	sess, err := admin.New("127.0.0.1", 3977, "admin123")
	if err != nil {
		panic(err)
	}
	err = sess.Open()
	if err != nil {
		panic(err)
	}

	sess.AddHandler(clientJoin)
	sess.AddHandler(getDate)
	sess.AddHandler(onMessage)

	// Wait here until CTRL-C or other term signal is received.
	fmt.Println("Bot is now running.  Press CTRL-C to exit.")
	sc := make(chan os.Signal, 1)
	signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
	<-sc

}

func getDate(sess *admin.Session, d *admin.Date) {
	fmt.Println(util.DateFormat(d.CurrentDate))
}

func clientJoin(sess *admin.Session, d *admin.ClientJoin) {
	fmt.Println("Meow")
}

func onMessage(sess *admin.Session, d *admin.Chat) {
	fmt.Println("Message sent")
}

It's meant to print Meow or Message Sent when someone sends a chat message or joins the server, it should also print the current date whenever it's triggered but the only output is a single Current Date:

Starting: /home/baa/go/bin/dlv-dap dap --check-go-version=false --listen=127.0.0.1:42275 --log-dest=3 from /home/baa/Documents/Dev/OpenTTD-Discord-Bot
DAP server listening at: 127.0.0.1:42275
Type 'dlv help' for list of commands.
Bot is now running.  Press CTRL-C to exit.
1991-01-05 00:00:00 +0000 UTC

OpenTTD 14 removed share owners

With OpenTTD/OpenTTD#10709 company shares have been removed, including from he admin packet with an increment of the protocol version number.

I'm not sure what is going to happen, since I have not set up go and as such can't run the code. However, I suspect it's either bailing out because the packet does not have enough information for the decoding to complete, or it's returning the company with id 0 as owner of all the shares. The latter might trip up users of this library, as it might think that company 0 owns a lot of other companies.

Share1 uint8 // Owner of Share 1.
Share2 uint8 // Owner of Share 2.
Share3 uint8 // Owner of Share 3.
Share4 uint8 // Owner of Share 4.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    馃枛 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 馃搳馃搱馃帀

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google 鉂わ笍 Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.