From 3cb32b89624ce3e5dc70c084b6c20f7949512800 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Sun, 22 Mar 2020 17:19:26 +0000 Subject: [PATCH] Adjustments following kind discussion with LunarJetman on IRC --- .gitignore | 2 +- Makefile | 8 ++--- README.md | 33 +++++++++++------ cmd/{wh40k => ordoor}/main.go | 4 +-- config.toml.example | 2 +- internal/config/config.go | 2 +- internal/{wh40k/wh40k.go => ordoor/ordoor.go} | 14 ++++---- internal/ordoor/videos.go | 35 +++++++++++++++++++ internal/wh40k/videos.go | 35 ------------------- 9 files changed, 73 insertions(+), 62 deletions(-) rename cmd/{wh40k => ordoor}/main.go (66%) rename internal/{wh40k/wh40k.go => ordoor/ordoor.go} (59%) create mode 100644 internal/ordoor/videos.go delete mode 100644 internal/wh40k/videos.go diff --git a/.gitignore b/.gitignore index 51a7c11..8a61620 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,6 @@ /view-minimap /view-menu /view-set -/wh40k +/ordoor /investigation/Maps /investigation/Obj diff --git a/Makefile b/Makefile index 1a2853e..9658889 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ srcfiles = Makefile go.mod $(shell find . -iname *.go) GOBUILD ?= go build -tags ebitengl -all: loader palette-idx view-obj view-map view-menu view-minimap view-set wh40k +all: loader ordoor palette-idx view-obj view-map view-menu view-minimap view-set loader: $(srcfiles) $(GOBUILD) -o loader ./cmd/loader @@ -25,10 +25,10 @@ view-minimap: $(srcfiles) view-set: $(srcfiles) $(GOBUILD) -o view-set ./cmd/view-set -wh40k: $(srcfiles) - $(GOBUILD) -o wh40k ./cmd/wh40k +ordoor: $(srcfiles) + $(GOBUILD) -o ordoor ./cmd/ordoor clean: - rm -f loader view-obj view-map view-minimap view-set wh40k palette-idx + rm -f loader ordoor view-obj view-map view-minimap view-set palette-idx .PHONY: all clean diff --git a/README.md b/README.md index dfbf13c..62cf91e 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,27 @@ # Ordoor -Portmanteau of Order Door, a remake project for Warhammer 40,000: Chaos Gate, -the game from 1998. +Ordoor is an **unofficial** [game engine recreation](https://en.wikipedia.org/wiki/Game_engine_recreation) +of the classic game from 1998, [Warhammer 40,000: Chaos Gate](https://en.wikipedia.org/wiki/Warhammer_40,000:_Chaos_Gate) -**You must have a copy of the original game data to use this project** +**You must have a copy of the original game data to use this project**. GOG is +the current publisher of this game; [you can purchase it here](https://www.gog.com/game/warhammer_40000_chaos_gate). -No game yet, nothing even close. I'm in the very early stages of trying to -understand the various file formats. Until then, you can play WH40K: Chaos Gate -in a WinXP VM, disconnected from the internet. It doesn't need 3D rendering! +"Warhammer 40,000" is a trademark of Games Workshop, and the game data used by +Ordoor contains Games Workshop intellectual property. I am confident that this +project uses all those things in accordance with the +[Intellectual Property Policy](https://www.games-workshop.com/en-GB/Intellectual-Property-Policy) +and the license granted when purchasing a copy of the game in question. Do let +me know if you see or suspect any violation, and I'll address it immediately. -WH40K.exe is the existing game engine, and WH40K_TD.exe is the map editor. -Allows things to be saved as .MAP or as .SMF ("Super Macro File"). +Ordoor is a portmanteau of Order Door, which is, of course, the opposite of a +Chaos Gate. + +## Current status + +Some of the original file formats are either partially or fully decoded. Maps, +menus, and most visual data can be rendered pixel-perfect. Sound can be played +(with a preprocessing step). Some UI tookit work is done. No game mechanics are +implemented yet. ## Building from source @@ -66,12 +77,12 @@ Use the arrow keys to scroll around the map, the mouse wheel to zoom, and the Dependency management uses `go mod`, so ensure you have at least Go 1.11. -There is the **start** of the menu / campaign flow in a `wh40k` binary: +There is the **start** of the menu / campaign flow in a `ordoor` binary: ``` $ cp config.toml.example config.toml -$ make wh40k -$ ./wh40k +$ make ordoor +$ ./ordoor ``` This plays the introductory videos so far, and nothing else. diff --git a/cmd/wh40k/main.go b/cmd/ordoor/main.go similarity index 66% rename from cmd/wh40k/main.go rename to cmd/ordoor/main.go index eaf50a4..30bd176 100644 --- a/cmd/wh40k/main.go +++ b/cmd/ordoor/main.go @@ -4,7 +4,7 @@ import ( "log" "os" - "code.ur.gs/lupine/ordoor/internal/wh40k" + "code.ur.gs/lupine/ordoor/internal/ordoor" ) func main() { @@ -13,7 +13,7 @@ func main() { configFile = os.Args[1] } - if err := wh40k.Run(configFile); err != nil { + if err := ordoor.Run(configFile); err != nil { log.Fatalf(err.Error()) } diff --git a/config.toml.example b/config.toml.example index 5362838..0b14d0f 100644 --- a/config.toml.example +++ b/config.toml.example @@ -1,4 +1,4 @@ -[wh40k] +[ordoor] data_dir = "./orig" video_player = [ "mpv", diff --git a/internal/config/config.go b/internal/config/config.go index c1fc78c..1e33188 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -12,7 +12,7 @@ type WH40K struct { } type Config struct { - WH40K `toml:"wh40k"` + WH40K `toml:"ordoor"` } func Load(filename string) (*Config, error) { diff --git a/internal/wh40k/wh40k.go b/internal/ordoor/ordoor.go similarity index 59% rename from internal/wh40k/wh40k.go rename to internal/ordoor/ordoor.go index 2322af1..0031d30 100644 --- a/internal/wh40k/wh40k.go +++ b/internal/ordoor/ordoor.go @@ -1,8 +1,8 @@ -// package wh40k implements the full WH40K.EXE functionality, and is used from -// cmd/wh40k/main.go +// package ordoor implements the full WH40K.EXE functionality, and is used from +// cmd/ordoor/main.go // // Entrypoint is Run() -package wh40k +package ordoor import ( "fmt" @@ -10,7 +10,7 @@ import ( "code.ur.gs/lupine/ordoor/internal/config" ) -type WH40K struct { +type Ordoor struct { Config *config.Config } @@ -20,12 +20,12 @@ func Run(configFile string) error { return fmt.Errorf("Couldn't load config file: %v", err) } - wh40k := &WH40K{ + ordoor := &Ordoor{ Config: cfg, } - wh40k.PlaySkippableVideo("LOGOS") - wh40k.PlaySkippableVideo("movie1") + ordoor.PlaySkippableVideo("LOGOS") + ordoor.PlaySkippableVideo("movie1") // TODO: load main interface diff --git a/internal/ordoor/videos.go b/internal/ordoor/videos.go new file mode 100644 index 0000000..742a4fe --- /dev/null +++ b/internal/ordoor/videos.go @@ -0,0 +1,35 @@ +package ordoor + +import ( + "log" + "os/exec" +) + +func (o *Ordoor) PlayVideo(name string, skippable bool) { + filename := o.Config.DataFile("SMK/" + name + ".smk") + + if len(o.Config.VideoPlayer) == 0 { + log.Printf("Video player not configured, skipping video %v", filename) + return + } + + argc := o.Config.VideoPlayer[0] + argv := append(o.Config.VideoPlayer[1:]) + if skippable { + argv = append(argv, "--input-conf=skippable.mpv.conf") + } + + argv = append(argv, filename) + + if err := exec.Command(argc, argv...).Run(); err != nil { + log.Printf("Error playing video %v: %v", filename, err) + } +} + +func (o *Ordoor) PlayUnskippableVideo(name string) { + o.PlayVideo(name, false) +} + +func (o *Ordoor) PlaySkippableVideo(name string) { + o.PlayVideo(name, true) +} diff --git a/internal/wh40k/videos.go b/internal/wh40k/videos.go deleted file mode 100644 index c861bcd..0000000 --- a/internal/wh40k/videos.go +++ /dev/null @@ -1,35 +0,0 @@ -package wh40k - -import ( - "log" - "os/exec" -) - -func (w *WH40K) PlayVideo(name string, skippable bool) { - filename := w.Config.DataFile("SMK/" + name + ".smk") - - if len(w.Config.VideoPlayer) == 0 { - log.Printf("Video player not configured, skipping video %v", filename) - return - } - - argc := w.Config.VideoPlayer[0] - argv := append(w.Config.VideoPlayer[1:]) - if skippable { - argv = append(argv, "--input-conf=skippable.mpv.conf") - } - - argv = append(argv, filename) - - if err := exec.Command(argc, argv...).Run(); err != nil { - log.Printf("Error playing video %v: %v", filename, err) - } -} - -func (w *WH40K) PlayUnskippableVideo(name string) { - w.PlayVideo(name, false) -} - -func (w *WH40K) PlaySkippableVideo(name string) { - w.PlayVideo(name, true) -}