blob: f19fd30e6142d3dc33908ffa4d0212398d558e58 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package main
import game "../game"
import "core:fmt"
import "core:os"
import "core:path/filepath"
main :: proc() {
if len(os.args) > 1 && os.args[1] == "--headless" {
os.exit(game.game_headless(os.args[1:]) ? 0 : 1)
}
script := len(os.args) > 1 && os.args[1] == "--script"
// Everything the game writes lives under cache/ relative to the working directory (weather snapshot,
// identity, messages, peers). The release exe embeds its assets, so it runs from the user's data folder
// (~/.local/share, ~/Library/Application Support, %APPDATA%) instead of next to the exe.
// A scripted run reads its files relative to where it was started.
if base, err := os.user_data_dir(context.allocator); err == nil && !script {
dir, _ := filepath.join({base, "Drift"}, context.allocator)
if os.make_directory_all(dir) == nil || os.exists(dir) {
if os.set_working_directory(dir) != nil do fmt.eprintln("[release] cannot use", dir, "- writing next to the exe")
}
}
game.game_init_window()
memory := game.game_init()
if memory == nil {
os.exit(1)
}
if script && (len(os.args) != 3 || !game.game_script(memory, os.args[2])) {
fmt.eprintln("[release] usage: drift --script <file>")
os.exit(1)
}
for game.game_update(memory) {
}
game.game_shutdown(memory)
game.game_shutdown_window()
}
|