Fix bugs
This commit is contained in:
parent
dc854d411f
commit
ab94c12299
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
proto/tuneller.pb.go
|
proto/tuneller.pb.go
|
||||||
proto/*
|
proto/*
|
||||||
config.json
|
config.json
|
||||||
|
build/*
|
13
doBuilds.sh
Executable file
13
doBuilds.sh
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
export CGO_ENABLED=1
|
||||||
|
|
||||||
|
GOOS=linux GOARCH=amd64 go build -o build/tunnelerLinux64
|
||||||
|
GOOS=linux GOARCH=386 go build -o build/tunnelerLinux32
|
||||||
|
|
||||||
|
export CC=x86_64-w64-mingw32-gcc
|
||||||
|
export CXX=x86_64-w64-mingw32-g++
|
||||||
|
GOOS=windows GOARCH=amd64 go build -o build/tunneler64.exe
|
||||||
|
|
||||||
|
export CC=i686-w64-mingw32-gcc
|
||||||
|
export CXX=i686-w64-mingw32-g++
|
||||||
|
GOOS=windows GOARCH=386 go build -o build/tunneler32.exe
|
131
main.go
131
main.go
@ -13,48 +13,49 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ServerConfig struct {
|
type ServerConfig struct {
|
||||||
MapWidth uint32
|
MapWidth uint32 `json:"map_width"`
|
||||||
MapHeight uint32
|
MapHeight uint32 `json:"map_height"`
|
||||||
BlastRadius uint32
|
BlastRadius uint32 `json:"blast_radius"`
|
||||||
|
|
||||||
MaxEnergy uint32
|
MaxEnergy uint32 `json:"max_energy"`
|
||||||
MaxAmmunition uint32
|
MaxAmmunition uint32 `json:"max_ammunition"`
|
||||||
MaxShields uint32
|
MaxShields uint32 `json:"max_shields"`
|
||||||
|
|
||||||
NormalShotCost uint32
|
NormalShotCost uint32 `json:"normal_shot_cost"`
|
||||||
SuperShotCost uint32
|
SuperShotCost uint32 `json:"super_shot_cost"`
|
||||||
ReloadCost uint32
|
ReloadCost uint32 `json:"reload_cost"`
|
||||||
MovementCost uint32
|
MovementCost uint32 `json:"movement_cost"`
|
||||||
DiggingCost uint32
|
DiggingCost uint32 `json:"digging_cost"`
|
||||||
ShootDiggingCostBonus uint32
|
ShootDiggingCostBonus uint32 `json:"shoot_digging_cost_bonus"`
|
||||||
|
|
||||||
ShootCooldown uint32
|
ShootCooldown uint32 `json:"shoot_cooldown"`
|
||||||
RechargeCooldownOwn uint32
|
RechargeCooldownOwn uint32 `json:"recharge_cooldown_own"`
|
||||||
DiggingCooldown uint32
|
DiggingCooldown uint32 `json:"digging_cooldown"`
|
||||||
RechargeCooldownOpponent uint32
|
RechargeCooldownOpponent uint32 `json:"recharge_cooldown_opponent"`
|
||||||
RepairCooldown uint32
|
RepairCooldown uint32 `json:"repair_cooldown"`
|
||||||
MovementCooldown uint32
|
MovementCooldown uint32 `json:"movement_cooldown"`
|
||||||
MovementCooldownNoEnergy uint32
|
MovementCooldownNoEnergy uint32 `json:"movement_cooldown_no_energy"`
|
||||||
DiggingCooldownNoEnergy uint32
|
DiggingCooldownNoEnergy uint32 `json:"digging_cooldown_no_energy"`
|
||||||
ReloadCooldown uint32
|
ReloadCooldown uint32 `json:"reload_cooldown"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Debug bool `json:"debug"`
|
Debug bool `json:"debug"`
|
||||||
MapWindow bool `json:"map_window"`
|
MapWindow bool `json:"map_window"`
|
||||||
RenderGameObjects bool `json:"render_game_objects"`
|
RenderGameObjects bool `json:"render_game_objects"`
|
||||||
ProfilerOn bool `json:"profiler_on"`
|
ProfilerOn bool `json:"profiler_on"`
|
||||||
ProfilerInterval uint64 `json:"profiler_interval"`
|
ProfilerInterval uint64 `json:"profiler_interval"`
|
||||||
Server bool `json:"server"`
|
Server bool `json:"server"`
|
||||||
CameraW int32 `json:"camera_w"`
|
CameraW int32 `json:"camera_w"`
|
||||||
CameraH int32 `json:"camera_h"`
|
CameraH int32 `json:"camera_h"`
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
Client bool `json:"client"`
|
Client bool `json:"client"`
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
JoyStickDeadZone int16 `json:"joystick_dead_zone"`
|
JoyStickDeadZone int16 `json:"joystick_dead_zone"`
|
||||||
DoAllKeymapsPlayers bool `json:"do_all_keymaps_players"`
|
DoAllKeymapsPlayers bool `json:"do_all_keymaps_players"`
|
||||||
DoJoyStickPlayers bool `json:"do_joystick_players"`
|
DoJoyStickPlayers bool `json:"do_joystick_players"`
|
||||||
DoKeymapPlayer bool `json:"do_keymap_player"`
|
DoKeymapPlayer bool `json:"do_keymap_player"`
|
||||||
|
ServerConfig ServerConfig `json:"server_config"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadOrCreateConfig(filename string) (*Config, error) {
|
func loadOrCreateConfig(filename string) (*Config, error) {
|
||||||
@ -74,6 +75,32 @@ func loadOrCreateConfig(filename string) (*Config, error) {
|
|||||||
DoAllKeymapsPlayers: false,
|
DoAllKeymapsPlayers: false,
|
||||||
DoJoyStickPlayers: true,
|
DoJoyStickPlayers: true,
|
||||||
DoKeymapPlayer: true,
|
DoKeymapPlayer: true,
|
||||||
|
ServerConfig: ServerConfig{
|
||||||
|
MapWidth: 1000,
|
||||||
|
MapHeight: 1000,
|
||||||
|
BlastRadius: 5,
|
||||||
|
|
||||||
|
MaxEnergy: 3520,
|
||||||
|
MaxAmmunition: 6,
|
||||||
|
MaxShields: 100,
|
||||||
|
|
||||||
|
NormalShotCost: 7,
|
||||||
|
SuperShotCost: 80,
|
||||||
|
ReloadCost: 4,
|
||||||
|
MovementCost: 1,
|
||||||
|
DiggingCost: 3,
|
||||||
|
ShootDiggingCostBonus: 1,
|
||||||
|
|
||||||
|
ShootCooldown: 8,
|
||||||
|
RechargeCooldownOwn: 0,
|
||||||
|
DiggingCooldown: 4,
|
||||||
|
RechargeCooldownOpponent: 6,
|
||||||
|
RepairCooldown: 4,
|
||||||
|
MovementCooldown: 2,
|
||||||
|
MovementCooldownNoEnergy: 4,
|
||||||
|
DiggingCooldownNoEnergy: 8,
|
||||||
|
ReloadCooldown: 16,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the file exists
|
// Check if the file exists
|
||||||
@ -110,36 +137,11 @@ var config *Config
|
|||||||
|
|
||||||
var gameMap = &GameMap{}
|
var gameMap = &GameMap{}
|
||||||
|
|
||||||
var serverConfig = ServerConfig{
|
var serverConfig ServerConfig
|
||||||
MapWidth: 1000,
|
|
||||||
MapHeight: 1000,
|
|
||||||
BlastRadius: 5,
|
|
||||||
|
|
||||||
MaxEnergy: 3520,
|
|
||||||
MaxAmmunition: 6,
|
|
||||||
MaxShields: 100,
|
|
||||||
|
|
||||||
NormalShotCost: 7,
|
|
||||||
SuperShotCost: 80,
|
|
||||||
ReloadCost: 4,
|
|
||||||
MovementCost: 1,
|
|
||||||
DiggingCost: 3,
|
|
||||||
ShootDiggingCostBonus: 1,
|
|
||||||
|
|
||||||
ShootCooldown: 8,
|
|
||||||
RechargeCooldownOwn: 0,
|
|
||||||
DiggingCooldown: 4,
|
|
||||||
RechargeCooldownOpponent: 6,
|
|
||||||
RepairCooldown: 4,
|
|
||||||
MovementCooldown: 2,
|
|
||||||
MovementCooldownNoEnergy: 4,
|
|
||||||
DiggingCooldownNoEnergy: 8,
|
|
||||||
ReloadCooldown: 16,
|
|
||||||
}
|
|
||||||
|
|
||||||
var mapWindow *sdl.Window
|
var mapWindow *sdl.Window
|
||||||
var mapSurface *sdl.Surface
|
var mapSurface *sdl.Surface
|
||||||
var mapRendererRect = &sdl.Rect{X: 0, Y: 0, W: int32(serverConfig.MapWidth), H: int32(serverConfig.MapHeight)}
|
var mapRendererRect *sdl.Rect
|
||||||
|
|
||||||
var netPlayerMapper = map[*net.Conn]*Player{}
|
var netPlayerMapper = map[*net.Conn]*Player{}
|
||||||
|
|
||||||
@ -154,7 +156,9 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
serverConfig = configX.ServerConfig
|
||||||
config = configX
|
config = configX
|
||||||
|
mapRendererRect = &sdl.Rect{X: 0, Y: 0, W: int32(serverConfig.MapWidth), H: int32(serverConfig.MapHeight)}
|
||||||
players := make(map[uint32]*Player)
|
players := make(map[uint32]*Player)
|
||||||
initPlayerColors()
|
initPlayerColors()
|
||||||
bullets := make(map[uint32]*Bullet)
|
bullets := make(map[uint32]*Bullet)
|
||||||
@ -247,6 +251,7 @@ func main() {
|
|||||||
if config.MapWindow {
|
if config.MapWindow {
|
||||||
// Profile rendering (aggregate all renderings)
|
// Profile rendering (aggregate all renderings)
|
||||||
totalRenderTime += profileSection(func() {
|
totalRenderTime += profileSection(func() {
|
||||||
|
running = running && handleEvents(mapWindow, mapSurface)
|
||||||
gameMap.render(mapRendererRect, mapSurface)
|
gameMap.render(mapRendererRect, mapSurface)
|
||||||
for _, bullet := range bullets {
|
for _, bullet := range bullets {
|
||||||
(*bullet).render(mapRendererRect, mapSurface, bullets)
|
(*bullet).render(mapRendererRect, mapSurface, bullets)
|
||||||
|
@ -1321,9 +1321,6 @@ func handleRequest(conn net.Conn, players map[uint32]*Player, bullets map[uint32
|
|||||||
player.playerID,
|
player.playerID,
|
||||||
uint32(float64(player.gameObject.baseRect.W)*1.5))
|
uint32(float64(player.gameObject.baseRect.W)*1.5))
|
||||||
|
|
||||||
player.gameObject.baseRect = players[0].gameObject.baseRect
|
|
||||||
player.gameObject.baseRect.Y += 10
|
|
||||||
|
|
||||||
defer bases[newPlayerID].delete(bases)
|
defer bases[newPlayerID].delete(bases)
|
||||||
netPlayerMapper[&conn] = player
|
netPlayerMapper[&conn] = player
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user