func main() { base.SetDatadir("../data") g := game.MakeGame() engine, err := cgf.NewHostEngine(g, 17, "", 20007, nil, nil) if err != nil { fmt.Printf("Unable to create engine: %v\n", err) return } err = cgf.Host(20007, "thunderball") if err != nil { fmt.Printf("Unable to host: %v\n", err) return } fmt.Printf("%v\n", engine) select {} }
func debugHookup(version string) *cgf.Engine { var err error for false && len(sys.GetActiveDevices()[gin.DeviceTypeController]) < 2 { time.Sleep(time.Millisecond * 100) sys.Think() } var engine *cgf.Engine if version != "host" { engine, err = cgf.NewClientEngine(17, "thunderingvictory.dyndns.org", 20007, base.EmailCrashReport, base.Log()) if err != nil { base.Log().Printf("Unable to connect: %v", err) base.Error().Fatalf("%v", err.Error()) } } else { sys.Think() g := game.MakeGame() if version == "host" { engine, err = cgf.NewHostEngine(g, 17, "", 20007, base.EmailCrashReport, base.Log()) if err != nil { panic(err) } err = cgf.Host(20007, "thunderball") if err != nil { panic(err) } } else { engine, err = cgf.NewLocalEngine(g, 17, base.EmailCrashReport, base.Log()) } if err != nil { base.Error().Fatalf("%v", err.Error()) } } engine.Pause() engine.GetState().(*game.Game).SetSystem(sys) engine.Unpause() base.Log().Printf("Engine Id: %v", engine.Id()) base.Log().Printf("All Ids: %v", engine.Ids()) return engine }
func debugHookup(version string) (*cgf.Engine, *game.LocalData) { // if version != "standard" && version != "moba" && version != "host" && version != "client" { // base.Log().Fatalf("Unable to handle Version() == '%s'", Version()) // } for false && len(sys.GetActiveDevices()[gin.DeviceTypeController]) < 2 { time.Sleep(time.Millisecond * 100) sys.Think() } var engine *cgf.Engine var room game.Room generated := generator.GenerateRoom(1024, 1024, 100, 64, 64522029961391019) data, err := json.Marshal(generated) if err != nil { base.Error().Fatalf("%v", err) } err = json.Unmarshal(data, &room) // err = base.LoadJson(filepath.Join(base.GetDataDir(), "rooms/basic.json"), &room) if err != nil { base.Error().Fatalf("%v", err) } var players []game.Gid var localData *game.LocalData var g *game.Game if version != "host" { res, err := cgf.SearchLANForHosts(20007, 20002, 500) if err != nil || len(res) == 0 { base.Log().Printf("Unable to connect: %v", err) base.Error().Fatalf("%v", err.Error()) } engine, err = cgf.NewClientEngine(17, res[0].Ip, 20007, base.EmailCrashReport, base.Log()) if err != nil { base.Log().Printf("Unable to connect: %v", err) base.Error().Fatalf("%v", err.Error()) } localData = game.NewLocalDataArchitect(engine, sys) g = engine.GetState().(*game.Game) for _, ent := range g.Ents { if _, ok := ent.(*game.PlayerEnt); ok { players = append(players, ent.Id()) } } } else { sys.Think() g = game.MakeGame() if version == "host" { engine, err = cgf.NewHostEngine(g, 17, "", 20007, base.EmailCrashReport, base.Log()) if err != nil { panic(err) } err = cgf.Host(20007, "thunderball") if err != nil { panic(err) } } else { engine, err = cgf.NewLocalEngine(g, 17, base.EmailCrashReport, base.Log()) } if err != nil { base.Error().Fatalf("%v", err.Error()) } } localData = game.NewLocalDataMoba(engine, gin.DeviceIndexAny, sys) // localData = game.NewLocalDataInvaders(engine, sys) // Hook the players up regardless of in we're architect or not, since we can // switch between the two in debug mode. // d := sys.GetActiveDevices() // n := 0 // for _, index := range d[gin.DeviceTypeController] { // localData.SetLocalPlayer(g.Ents[players[n]], index) // n++ // if n > len(players) { // break // } // } // if len(d[gin.DeviceTypeController]) == 0 { // localData.SetLocalPlayer(g.Ents[players[0]], 0) // } base.Log().Printf("Engine Id: %v", engine.Id()) base.Log().Printf("All Ids: %v", engine.Ids()) return engine, localData }