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/*
|
||||
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 {
|
||||
MapWidth uint32
|
||||
MapHeight uint32
|
||||
BlastRadius uint32
|
||||
MapWidth uint32 `json:"map_width"`
|
||||
MapHeight uint32 `json:"map_height"`
|
||||
BlastRadius uint32 `json:"blast_radius"`
|
||||
|
||||
MaxEnergy uint32
|
||||
MaxAmmunition uint32
|
||||
MaxShields uint32
|
||||
MaxEnergy uint32 `json:"max_energy"`
|
||||
MaxAmmunition uint32 `json:"max_ammunition"`
|
||||
MaxShields uint32 `json:"max_shields"`
|
||||
|
||||
NormalShotCost uint32
|
||||
SuperShotCost uint32
|
||||
ReloadCost uint32
|
||||
MovementCost uint32
|
||||
DiggingCost uint32
|
||||
ShootDiggingCostBonus uint32
|
||||
NormalShotCost uint32 `json:"normal_shot_cost"`
|
||||
SuperShotCost uint32 `json:"super_shot_cost"`
|
||||
ReloadCost uint32 `json:"reload_cost"`
|
||||
MovementCost uint32 `json:"movement_cost"`
|
||||
DiggingCost uint32 `json:"digging_cost"`
|
||||
ShootDiggingCostBonus uint32 `json:"shoot_digging_cost_bonus"`
|
||||
|
||||
ShootCooldown uint32
|
||||
RechargeCooldownOwn uint32
|
||||
DiggingCooldown uint32
|
||||
RechargeCooldownOpponent uint32
|
||||
RepairCooldown uint32
|
||||
MovementCooldown uint32
|
||||
MovementCooldownNoEnergy uint32
|
||||
DiggingCooldownNoEnergy uint32
|
||||
ReloadCooldown uint32
|
||||
ShootCooldown uint32 `json:"shoot_cooldown"`
|
||||
RechargeCooldownOwn uint32 `json:"recharge_cooldown_own"`
|
||||
DiggingCooldown uint32 `json:"digging_cooldown"`
|
||||
RechargeCooldownOpponent uint32 `json:"recharge_cooldown_opponent"`
|
||||
RepairCooldown uint32 `json:"repair_cooldown"`
|
||||
MovementCooldown uint32 `json:"movement_cooldown"`
|
||||
MovementCooldownNoEnergy uint32 `json:"movement_cooldown_no_energy"`
|
||||
DiggingCooldownNoEnergy uint32 `json:"digging_cooldown_no_energy"`
|
||||
ReloadCooldown uint32 `json:"reload_cooldown"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Debug bool `json:"debug"`
|
||||
MapWindow bool `json:"map_window"`
|
||||
RenderGameObjects bool `json:"render_game_objects"`
|
||||
ProfilerOn bool `json:"profiler_on"`
|
||||
ProfilerInterval uint64 `json:"profiler_interval"`
|
||||
Server bool `json:"server"`
|
||||
CameraW int32 `json:"camera_w"`
|
||||
CameraH int32 `json:"camera_h"`
|
||||
Version string `json:"version"`
|
||||
Client bool `json:"client"`
|
||||
Address string `json:"address"`
|
||||
JoyStickDeadZone int16 `json:"joystick_dead_zone"`
|
||||
DoAllKeymapsPlayers bool `json:"do_all_keymaps_players"`
|
||||
DoJoyStickPlayers bool `json:"do_joystick_players"`
|
||||
DoKeymapPlayer bool `json:"do_keymap_player"`
|
||||
Debug bool `json:"debug"`
|
||||
MapWindow bool `json:"map_window"`
|
||||
RenderGameObjects bool `json:"render_game_objects"`
|
||||
ProfilerOn bool `json:"profiler_on"`
|
||||
ProfilerInterval uint64 `json:"profiler_interval"`
|
||||
Server bool `json:"server"`
|
||||
CameraW int32 `json:"camera_w"`
|
||||
CameraH int32 `json:"camera_h"`
|
||||
Version string `json:"version"`
|
||||
Client bool `json:"client"`
|
||||
Address string `json:"address"`
|
||||
JoyStickDeadZone int16 `json:"joystick_dead_zone"`
|
||||
DoAllKeymapsPlayers bool `json:"do_all_keymaps_players"`
|
||||
DoJoyStickPlayers bool `json:"do_joystick_players"`
|
||||
DoKeymapPlayer bool `json:"do_keymap_player"`
|
||||
ServerConfig ServerConfig `json:"server_config"`
|
||||
}
|
||||
|
||||
func loadOrCreateConfig(filename string) (*Config, error) {
|
||||
@ -74,6 +75,32 @@ func loadOrCreateConfig(filename string) (*Config, error) {
|
||||
DoAllKeymapsPlayers: false,
|
||||
DoJoyStickPlayers: 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
|
||||
@ -110,36 +137,11 @@ var config *Config
|
||||
|
||||
var gameMap = &GameMap{}
|
||||
|
||||
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 serverConfig ServerConfig
|
||||
|
||||
var mapWindow *sdl.Window
|
||||
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{}
|
||||
|
||||
@ -154,7 +156,9 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
serverConfig = configX.ServerConfig
|
||||
config = configX
|
||||
mapRendererRect = &sdl.Rect{X: 0, Y: 0, W: int32(serverConfig.MapWidth), H: int32(serverConfig.MapHeight)}
|
||||
players := make(map[uint32]*Player)
|
||||
initPlayerColors()
|
||||
bullets := make(map[uint32]*Bullet)
|
||||
@ -247,6 +251,7 @@ func main() {
|
||||
if config.MapWindow {
|
||||
// Profile rendering (aggregate all renderings)
|
||||
totalRenderTime += profileSection(func() {
|
||||
running = running && handleEvents(mapWindow, mapSurface)
|
||||
gameMap.render(mapRendererRect, mapSurface)
|
||||
for _, bullet := range bullets {
|
||||
(*bullet).render(mapRendererRect, mapSurface, bullets)
|
||||
|
@ -1321,9 +1321,6 @@ func handleRequest(conn net.Conn, players map[uint32]*Player, bullets map[uint32
|
||||
player.playerID,
|
||||
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)
|
||||
netPlayerMapper[&conn] = player
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user