Webclient: Make it easier to change where default texture pack is downloaded from, and use ccall a little bit less

Also update buildbot scripts
This commit is contained in:
UnknownShadow200 2024-01-09 19:56:39 +11:00
parent bb5ca6a957
commit 85d0a980ec
7 changed files with 75 additions and 12 deletions

View file

@ -16,10 +16,10 @@ Common compilation errors
Add ```-lrt``` when compiling. Occurs when using glibc versions before 2.17.
#### fatal error: execinfo.h: No such file or directory
Install ```libexecinfo``` package. Occurs when using musl.
Define `CC_BACKTRACE_BUILTIN` when compiling. Usually occurs when using musl.
#### Undefined reference to 'backtrace'
Add ```-lexecinfo``` when compiling. Occurs when using musl.
Define `CC_BACKTRACE_BUILTIN` when compiling. Usually occurs when using musl.
Webclient patches
---------------------

View file

@ -20,6 +20,12 @@ For simplicitly,
The play.html page is the trickiest part, because how to implement this is website-specific. (depends on how the website is styled, what webserver is used, what programming language is used to generate the html, etc)
#### Changing where the game downloads the texture pack from
There should be this piece of code somewhere in the .JS file: `function _interop_AsyncDownloadTexturePack(rawPath) {`
A bit below that, there should be `var url = '/static/default.zip';` - change that to the desired URL.
#### Embedding the game in play.html
The following HTML code is required to be somewhere in the webpage:

View file

@ -112,7 +112,7 @@ WEB_CC="/home/buildbot/emsdk/emscripten/1.38.31/emcc"
build_web() {
echo "Building web.."
rm cc.js
$WEB_CC *.c -O1 -o cc.js --js-library interop_web.js -s WASM=0 -s LEGACY_VM_SUPPORT=1 -s ALLOW_MEMORY_GROWTH=1 -s ABORTING_MALLOC=0 -s ENVIRONMENT=web
$WEB_CC *.c -s WASM=0 -s NO_EXIT_RUNTIME=1 -s LEGACY_VM_SUPPORT=1 -s ALLOW_MEMORY_GROWTH=1 -s ABORTING_MALLOC=0 -s ENVIRONMENT=web --js-library interop_web.js -Os -g2 -s SINGLE_FILE
if [ $? -ne 0 ]; then echo "Failed to compile Webclient" >> "$ERRS_FILE"; fi
# fix mouse wheel scrolling page not being properly prevented
# "[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive."
@ -262,6 +262,49 @@ run_timed build_web
run_timed build_rpi32
run_timed build_rpi64
run_timed build_android
run_timed build_ios
~/upload_build.sh latest/ClassiCube.rpi cc-rpi
~/upload_build.sh latest/cc-rpi-64 cc-rpi64
~/upload_build.sh latest/ClassiCube.ipa cc.ipa
~/upload_build.sh latest/ClassiCube.apk cc.apk
~/upload_build.sh latest/ClassiCube.ipa cc.ipa
~/upload_build.sh latest/ClassiCube.apk cc.apk
~/upload_build.sh latest/ClassiCube.exe cc-w32-d3d.exe
~/upload_build.sh latest/ClassiCube.opengl.exe cc-w32-ogl.exe
~/upload_build.sh latest/cc-w32-d3d11.exe cc-w32-d3d11.exe
~/upload_build.sh latest/ClassiCube.64.exe cc-w64-d3d.exe
~/upload_build.sh latest/ClassiCube.64-opengl.exe cc-w64-ogl.exe
~/upload_build.sh latest/cc-w64-d3d11.exe cc-w64-d3d11.exe
~/upload_build.sh latest/ClassiCube.64.osx cc-osx64
~/upload_build.sh latest/cc-osx64-gl2 cc-osx64-gl2
~/upload_build.sh latest/ClassiCube.osx cc-osx32
~/upload_build.sh latest/cc-osx32-gl2 cc-osx32-gl2
~/upload_build.sh latest/ClassiCube cc-nix64
~/upload_build.sh latest/cc-nix64-gl2 cc-nix64-gl2
~/upload_build.sh latest/ClassiCube.32 cc-nix32
~/upload_build.sh latest/cc-nix32-gl2 cc-nix32-gl2
~/upload_build.sh latest/ClassiCube.js cc.js
rm builds.zip
zip builds.zip cc-w32-d3d.exe cc-w32-ogl.exe cc-w32-d3d11.exe cc-w64-d3d.exe cc-w64-ogl.exe cc-w64-d3d11.exe
~/upload_build.sh $LATEST/builds.zip builds.zip
# nightlies page on classicube.net
~/upload_build.sh $LATEST/ClassiCube.exe cc-w32-d3d.exe
~/upload_build.sh $LATEST/ClassiCube.64.exe cc-w64-d3d.exe
~/upload_build.sh $LATEST/ClassiCube.32 cc-nix32
~/upload_build.sh $LATEST/ClassiCube cc-nix64
~/upload_build.sh $LATEST/ClassiCube.osx cc-osx32
~/upload_build.sh $LATEST/ClassiCube.64.osx cc-osx64
cd ~
python3 notify.py
python3 notify.py 'client/cc_errors.txt'

View file

@ -16,6 +16,7 @@ def notify_webhook(body):
"avatar_url": "https://static.classicube.net/img/cc-cube-small.png",
"content" : body
}
r = requests.post(WEBHOOK_URL, json=webhook_data)
print("BuildNotify response: " + r.text)
except Exception as e:
@ -23,7 +24,7 @@ def notify_webhook(body):
cc_errors = None
try:
with open('client/cc_errors.txt', 'r') as file:
with open(sys.argv[1], 'r') as file:
cc_errors = file.read()
except FileNotFoundError:
# nothing to as no compile errors

View file

@ -0,0 +1,13 @@
# upload_build.sh [TARGET NAME] [SOURCE FILE]
# e.g. ~/upload_build.sh latest/ClassiCube.ipa cc.ipa
API_URL=
API_KEY=
if [ -s $2 ]; then
curl $API_URL \
--header "X-Build-Key:$API_KEY" \
--header "X-Build-Name:$1" \
--data-binary @$2
else
echo "Missing or empty file: $2"
fi

View file

@ -407,7 +407,7 @@ static char** _argv;
extern void interop_FS_Init(void);
extern void interop_DirectorySetWorking(const char* path);
extern void interop_AsyncDownloadTexturePack(const char* path, const char* url);
extern void interop_AsyncDownloadTexturePack(const char* path);
int main(int argc, char** argv) {
_argc = argc; _argv = argv;
@ -419,7 +419,7 @@ int main(int argc, char** argv) {
/* > web_main (game actually starts) */
interop_FS_Init();
interop_DirectorySetWorking("/classicube");
interop_AsyncDownloadTexturePack("texpacks/default.zip", "/static/default.zip");
interop_AsyncDownloadTexturePack("texpacks/default.zip");
}
extern void interop_LoadIndexedDB(void);

View file

@ -178,18 +178,18 @@ mergeInto(LibraryManager.library, {
xhr.send();
},
interop_AsyncDownloadTexturePack__deps: ['fetchTexturePackAsync'],
interop_AsyncDownloadTexturePack: function (rawPath, rawUrl) {
interop_AsyncDownloadTexturePack: function (rawPath) {
var path = UTF8ToString(rawPath);
var url = UTF8ToString(rawUrl);
var url = '/static/default.zip';
Module.setStatus('Downloading textures.. (1/2)');
_fetchTexturePackAsync(url,
function(buffer) {
CCFS.writeFile(path, new Uint8Array(buffer));
ccall('main_phase1', 'void');
Module['_main_phase1']();
},
function() {
ccall('main_phase1', 'void');
Module['_main_phase1']();
}
);
},
@ -200,7 +200,7 @@ mergeInto(LibraryManager.library, {
_IDBFS_loadFS(function(err) {
if (err) window.cc_idbErr = err;
Module.setStatus('');
ccall('main_phase2', 'void');
Module['_main_phase2']();
});
},