Skip to content

Commit

Permalink
Rename client-config.json based on CLIENTBIN
Browse files Browse the repository at this point in the history
Also make viewing client.html directly use client-config.json in the
same directory so it's possible to "live edit" both the files without
having to run make.
  • Loading branch information
zturtleman committed Jun 11, 2024
1 parent 7bfd5c9 commit c1ab47a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1093,8 +1093,6 @@ ifeq ($(PLATFORM),emscripten)
$(error "No files in '$(BASEGAME)' directory for emscripten to preload.")
endif
CLIENT_LDFLAGS+=--preload-file $(BASEGAME)
else
CLIENT_EXTRA_FILES+=code/web/client-config.json
endif

OPTIMIZEVM = -O3
Expand Down Expand Up @@ -1230,6 +1228,9 @@ ifeq ($(PLATFORM),emscripten)

ifneq ($(BUILD_CLIENT),0)
TARGETS += $(B)/$(CLIENTBIN).html
ifneq ($(EMSCRIPTEN_PRELOAD_FILE),1)
TARGETS += $(B)/$(CLIENTBIN)-config.json
endif

ifneq ($(USE_RENDERER_DLOPEN),0)
GENERATEDTARGETS += $(B)/$(CLIENTBIN).$(ARCH).wasm
Expand Down Expand Up @@ -3094,6 +3095,10 @@ $(B)/$(CLIENTBIN).html: $(WEBDIR)/client.html
$(echo_cmd) "SED $@"
$(Q)sed 's/__CLIENTBIN__/$(CLIENTBIN)/g;s/__BASEGAME__/$(BASEGAME)/g;s/__EMSCRIPTEN_PRELOAD_FILE__/$(EMSCRIPTEN_PRELOAD_FILE)/g' < $< > $@

$(B)/$(CLIENTBIN)-config.json: $(WEBDIR)/client-config.json
$(echo_cmd) "CP $@"
$(Q)cp $< $@


#############################################################################
# MISC
Expand Down
4 changes: 2 additions & 2 deletions code/web/client.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
// Path or URL containing fs_game directories.
let dataPath = './';
// Path or URL for config file that specifies the files to load for each fs_game.
let configFilename = './client-config.json';
let configFilename = `./${CLIENTBIN}-config.json`;

// If displaying the unmodified HTML file, fallback to defaults.
if (clientHtmlFallback) {
CLIENTBIN='ioquake3';
BASEGAME='baseq3';
EMSCRIPTEN_PRELOAD_FILE=0;
configFilename='./client-config.json';
}

if (window.location.protocol === 'file:') throw new Error(`Unfortunately browser security restrictions prevent loading wasm from a file: URL. This file must be loaded from a web server. The easiest way to do this is probably to use Python\'s built-in web server by running \`python3 -m http.server\` in the top level source directory and then navigate to http://localhost:8000/build/debug-emscripten-wasm32/${CLIENTBIN}.html`);
Expand Down Expand Up @@ -68,7 +69,6 @@

enginePath = buildPaths[buildIndex];
dataPath = buildPaths[buildIndex];
configFilename = dataPath + 'client-config.json';
}

const dataURL = new URL(dataPath, location.origin + location.pathname);
Expand Down

0 comments on commit c1ab47a

Please sign in to comment.