mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-10 16:03:15 -04:00
more minor documentation/example fixes, and remove some unnecessary code
This commit is contained in:
parent
9f76f39cc7
commit
a05aea21ca
@ -23,36 +23,6 @@ Add ```-lexecinfo``` when compiling. Occurs when using musl.
|
|||||||
|
|
||||||
Webclient patches
|
Webclient patches
|
||||||
---------------------
|
---------------------
|
||||||
#### Starting game **Error 00000002 when setting current directory**
|
|
||||||
This is caused by IndexedDB not being initialised, which also means saved maps are lost when the tab is closed.
|
|
||||||
|
|
||||||
Due to how IndexedDB works, you must load and initialise it before the game starts. Change:
|
|
||||||
|
|
||||||
```
|
|
||||||
<script type='text/javascript'>
|
|
||||||
var Module = {
|
|
||||||
preRun: [],
|
|
||||||
...
|
|
||||||
```
|
|
||||||
to
|
|
||||||
```
|
|
||||||
<script type='text/javascript'>
|
|
||||||
// need to load IndexedDB before running the game
|
|
||||||
function preloadIndexedDB() {
|
|
||||||
addRunDependency('load-idb');
|
|
||||||
FS.mkdir('/classicube');
|
|
||||||
FS.mount(IDBFS, {}, '/classicube');
|
|
||||||
FS.syncfs(true, function(err) {
|
|
||||||
if (err) window.cc_idbErr = err;
|
|
||||||
removeRunDependency('load-idb');
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
var Module = {
|
|
||||||
preRun: [ preloadIndexedDB ],
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Mouse scrolling not properly prevented
|
#### Mouse scrolling not properly prevented
|
||||||
With recent chrome/firefox versions, page is still scrolled and console is spammed with\
|
With recent chrome/firefox versions, page is still scrolled and console is spammed with\
|
||||||
```"[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive."```
|
```"[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive."```
|
||||||
|
@ -110,10 +110,8 @@ WEB_CC="/home/buildbot/emsdk/emscripten/1.38.31/emcc"
|
|||||||
build_web() {
|
build_web() {
|
||||||
echo "Building web.."
|
echo "Building web.."
|
||||||
rm cc.js
|
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 --preload-file texpacks/default.zip -w
|
$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 -w
|
||||||
if [ $? -ne 0 ]; then echo "Failed to compile Webclient" >> "$ERRS_FILE"; fi
|
if [ $? -ne 0 ]; then echo "Failed to compile Webclient" >> "$ERRS_FILE"; fi
|
||||||
# so game loads textures from classicube.net/static/default.zip
|
|
||||||
sed -i 's#cc.data#/static/default.zip#g' cc.js
|
|
||||||
# fix mouse wheel scrolling page not being properly prevented
|
# fix mouse wheel scrolling page not being properly prevented
|
||||||
# "[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive."
|
# "[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive."
|
||||||
sed -i 's#eventHandler.useCapture);#{ useCapture: eventHandler.useCapture, passive: false });#g' cc.js
|
sed -i 's#eventHandler.useCapture);#{ useCapture: eventHandler.useCapture, passive: false });#g' cc.js
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <emscripten.h>
|
||||||
|
|
||||||
#define O_RDONLY 0x000
|
#define O_RDONLY 0x000
|
||||||
#define O_WRONLY 0x001
|
#define O_WRONLY 0x001
|
||||||
@ -34,8 +35,6 @@ const cc_result ReturnCode_FileNotFound = ENOENT;
|
|||||||
const cc_result ReturnCode_SocketInProgess = _EINPROGRESS;
|
const cc_result ReturnCode_SocketInProgess = _EINPROGRESS;
|
||||||
const cc_result ReturnCode_SocketWouldBlock = _EAGAIN;
|
const cc_result ReturnCode_SocketWouldBlock = _EAGAIN;
|
||||||
const cc_result ReturnCode_DirectoryExists = EEXIST;
|
const cc_result ReturnCode_DirectoryExists = EEXIST;
|
||||||
#include <emscripten.h>
|
|
||||||
#include "Chat.h"
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
@ -66,11 +65,9 @@ void Mem_Free(void* mem) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*------------------------------------------------------Logging/Time-------------------------------------------------------*
|
*------------------------------------------------------Logging/Time-------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
/* TODO: check this is actually accurate */
|
|
||||||
static cc_uint64 sw_freqMul = 1, sw_freqDiv = 1;
|
|
||||||
cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) {
|
cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) {
|
||||||
if (end < beg) return 0;
|
if (end < beg) return 0;
|
||||||
return ((end - beg) * sw_freqMul) / sw_freqDiv;
|
return end - beg;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void interop_Log(const char* msg, int len);
|
extern void interop_Log(const char* msg, int len);
|
||||||
@ -92,6 +89,7 @@ void DateTime_CurrentLocal(struct DateTime* t) {
|
|||||||
|
|
||||||
cc_uint64 Stopwatch_Measure(void) {
|
cc_uint64 Stopwatch_Measure(void) {
|
||||||
/* time is a milliseconds double */
|
/* time is a milliseconds double */
|
||||||
|
/* convert to microseconds */
|
||||||
return (cc_uint64)(emscripten_get_now() * 1000);
|
return (cc_uint64)(emscripten_get_now() * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,9 +347,6 @@ cc_result Socket_Poll(cc_socket s, int mode, cc_bool* success) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------Process/Module------------------------------------------------------*
|
*-----------------------------------------------------Process/Module------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
cc_result Process_StartGame(const cc_string* args, int numArgs) {
|
|
||||||
return ERR_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
void Process_Exit(cc_result code) {
|
void Process_Exit(cc_result code) {
|
||||||
/* 'Window' (i.e. the web canvas) isn't implicitly closed when process is exited */
|
/* 'Window' (i.e. the web canvas) isn't implicitly closed when process is exited */
|
||||||
if (code) Window_Close();
|
if (code) Window_Close();
|
||||||
@ -372,26 +367,6 @@ cc_result Process_StartOpen(const cc_string* args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*--------------------------------------------------------Updater----------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
const struct UpdaterInfo Updater_Info = { "", 0 };
|
|
||||||
|
|
||||||
cc_result Updater_GetBuildTime(cc_uint64* t) { return ERR_NOT_SUPPORTED; }
|
|
||||||
cc_bool Updater_Clean(void) { return true; }
|
|
||||||
cc_result Updater_Start(const char** action) { return ERR_NOT_SUPPORTED; }
|
|
||||||
cc_result Updater_MarkExecutable(void) { return 0; }
|
|
||||||
cc_result Updater_SetNewBuildTime(cc_uint64 t) { return ERR_NOT_SUPPORTED; }
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
|
||||||
*-------------------------------------------------------Dynamic lib-------------------------------------------------------*
|
|
||||||
*#########################################################################################################################*/
|
|
||||||
void* DynamicLib_Load2(const cc_string* path) { return NULL; }
|
|
||||||
void* DynamicLib_Get2(void* lib, const char* name) { return NULL; }
|
|
||||||
cc_bool DynamicLib_DescribeError(cc_string* dst) { return false; }
|
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*--------------------------------------------------------Platform---------------------------------------------------------*
|
*--------------------------------------------------------Platform---------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
@ -471,11 +446,10 @@ int main(int argc, char** argv) {
|
|||||||
_argc = argc; _argv = argv;
|
_argc = argc; _argv = argv;
|
||||||
|
|
||||||
/* Game loads resources asynchronously, then actually starts itself */
|
/* Game loads resources asynchronously, then actually starts itself */
|
||||||
/* main
|
/* main */
|
||||||
/* > texture pack download (async) */
|
/* > texture pack download (async) */
|
||||||
/* > load indexedDB (async) */
|
/* > load indexedDB (async) */
|
||||||
/* > web_main (game actually starts) */
|
/* > web_main (game actually starts) */
|
||||||
|
|
||||||
interop_FS_Init();
|
interop_FS_Init();
|
||||||
interop_DirectorySetWorking("/classicube");
|
interop_DirectorySetWorking("/classicube");
|
||||||
interop_AsyncDownloadTexturePack("texpacks/default.zip", "static/default.zip");
|
interop_AsyncDownloadTexturePack("texpacks/default.zip", "static/default.zip");
|
||||||
|
@ -180,7 +180,7 @@ static const char* OnBeforeUnload(int type, const void* ev, void *data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static EM_BOOL OnVisibilityChanged(int eventType, const EmscriptenVisibilityChangeEvent* ev, void* data) {
|
static EM_BOOL OnVisibilityChanged(int eventType, const EmscriptenVisibilityChangeEvent* ev, void* data) {
|
||||||
cc_bool inactive = ev->visibilityState == EMSCRIPTEN_VISIBILITY_HIDDEN;\
|
cc_bool inactive = ev->visibilityState == EMSCRIPTEN_VISIBILITY_HIDDEN;
|
||||||
if (WindowInfo.Inactive == inactive) return false;
|
if (WindowInfo.Inactive == inactive) return false;
|
||||||
|
|
||||||
WindowInfo.Inactive = inactive;
|
WindowInfo.Inactive = inactive;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user