Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e1a20497e8 | |||
| ac1fea0720 | |||
| 8855266638 | |||
| 2f53275462 | |||
| 1408a56ddc | |||
| b04b2d70fc |
@@ -10,6 +10,11 @@
|
||||
#include "../../Minecraft.World/Blocks/Tile.h"
|
||||
#include "../../Minecraft.World/Level/WaterLevelChunk.h"
|
||||
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
// eh... I should've enabled wasm64
|
||||
#define InterlockedCompareExchangeRelease InterlockedCompareExchangeRelease64
|
||||
#endif
|
||||
|
||||
MultiPlayerChunkCache::MultiPlayerChunkCache(Level* level) {
|
||||
XZSIZE = level->dimension->getXZSize(); // 4J Added
|
||||
XZOFFSET = XZSIZE / 2; // 4J Added
|
||||
@@ -295,4 +300,4 @@ void MultiPlayerChunkCache::dataReceived(int x, int z) {
|
||||
if ((iz < 0) || (iz >= XZSIZE)) return;
|
||||
int idx = ix * XZSIZE + iz;
|
||||
hasData[idx] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,11 @@ int strcasecmp(const char* a, const char* b) {
|
||||
return ca - cb;
|
||||
}
|
||||
#define MINIAUDIO_IMPLEMENTATION
|
||||
#ifndef __EMSCRIPTEN__
|
||||
#include "miniaudio.h"
|
||||
#else
|
||||
#include "../../Emscripten/miniaudio.h"
|
||||
#endif // __EMSCRIPTEN__
|
||||
#undef STB_VORBIS_HEADER_ONLY
|
||||
#include "stb_vorbis.c"
|
||||
#endif
|
||||
@@ -2425,4 +2429,4 @@ ConsoleSoundEngine::ScheduledSound::ScheduledSound(int iSound, float x, float y,
|
||||
this->volume = volume;
|
||||
this->pitch = pitch;
|
||||
this->delay = delay;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,11 @@ class Mob;
|
||||
class Options;
|
||||
using namespace std;
|
||||
#include "../../Minecraft.World/Util/SoundTypes.h"
|
||||
#ifndef __EMSCRIPTEN__
|
||||
#include "./miniaudio.h"
|
||||
#else
|
||||
#include "../../Emscripten/miniaudio.h"
|
||||
#endif
|
||||
constexpr float SFX_3D_MIN_DISTANCE = 1.0f;
|
||||
constexpr float SFX_3D_MAX_DISTANCE = 16.0f;
|
||||
constexpr float SFX_3D_ROLLOFF = 0.5f;
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -99,6 +99,8 @@
|
||||
#elif defined(_M_ARM) || defined(_M_ARM64) || defined(_M_HYBRID_X86_ARM64) || \
|
||||
defined(_M_ARM64EC) || __arm__ || __aarch64__
|
||||
#define _XM_ARM_NEON_INTRINSICS_
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
#define _XM_NO_INTRINSICS_
|
||||
#elif !defined(_XM_NO_INTRINSICS_)
|
||||
#error DirectX Math does not support this target
|
||||
#endif
|
||||
@@ -935,10 +937,10 @@ struct XMFLOAT3X3 {
|
||||
return m[Row][Column];
|
||||
}
|
||||
|
||||
#if (__cplusplus >= 202002L)
|
||||
bool operator==(const XMFLOAT3X3&) const = delete;
|
||||
auto operator<=>(const XMFLOAT3X3&) const = delete;
|
||||
#endif
|
||||
#if (__cplusplus >= 202002L)
|
||||
bool operator==(const XMFLOAT3X3&) const = delete;
|
||||
auto operator<=>(const XMFLOAT3X3&) const = delete;
|
||||
#endif
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -987,10 +989,10 @@ struct XMFLOAT4X3 {
|
||||
return m[Row][Column];
|
||||
}
|
||||
|
||||
#if (__cplusplus >= 202002L)
|
||||
bool operator==(const XMFLOAT4X3&) const = delete;
|
||||
auto operator<=>(const XMFLOAT4X3&) const = delete;
|
||||
#endif
|
||||
#if (__cplusplus >= 202002L)
|
||||
bool operator==(const XMFLOAT4X3&) const = delete;
|
||||
auto operator<=>(const XMFLOAT4X3&) const = delete;
|
||||
#endif
|
||||
};
|
||||
|
||||
// 4x3 Row-major Matrix: 32 bit floating point components aligned on a 16 byte
|
||||
@@ -1044,10 +1046,10 @@ struct XMFLOAT3X4 {
|
||||
return m[Row][Column];
|
||||
}
|
||||
|
||||
#if (__cplusplus >= 202002L)
|
||||
bool operator==(const XMFLOAT3X4&) const = delete;
|
||||
auto operator<=>(const XMFLOAT3X4&) const = delete;
|
||||
#endif
|
||||
#if (__cplusplus >= 202002L)
|
||||
bool operator==(const XMFLOAT3X4&) const = delete;
|
||||
auto operator<=>(const XMFLOAT3X4&) const = delete;
|
||||
#endif
|
||||
};
|
||||
|
||||
// 3x4 Column-major Matrix: 32 bit floating point components aligned on a 16
|
||||
@@ -1106,10 +1108,10 @@ struct XMFLOAT4X4 {
|
||||
return m[Row][Column];
|
||||
}
|
||||
|
||||
#if (__cplusplus >= 202002L)
|
||||
bool operator==(const XMFLOAT4X4&) const = delete;
|
||||
auto operator<=>(const XMFLOAT4X4&) const = delete;
|
||||
#endif
|
||||
#if (__cplusplus >= 202002L)
|
||||
bool operator==(const XMFLOAT4X4&) const = delete;
|
||||
auto operator<=>(const XMFLOAT4X4&) const = delete;
|
||||
#endif
|
||||
};
|
||||
|
||||
// 4x4 Matrix: 32 bit floating point components aligned on a 16 byte boundary
|
||||
|
||||
@@ -23,7 +23,9 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include <locale>
|
||||
#ifndef __EMSCRIPTEN__
|
||||
#include <linux/mman.h>
|
||||
#endif // __EMSCRIPTEN__
|
||||
#include <sys/mman.h>
|
||||
#include <codecvt>
|
||||
|
||||
@@ -35,4 +37,4 @@
|
||||
#include "iggy_stubs.h"
|
||||
#endif
|
||||
|
||||
#endif // STUBS_H
|
||||
#endif // STUBS_H
|
||||
|
||||
@@ -46,7 +46,7 @@ platform_sources += run_command(
|
||||
).stdout().strip().split('\n')
|
||||
|
||||
# linux-specific files (everything in Platform/Linux)
|
||||
if host_machine.system() == 'linux'
|
||||
if host_machine.system() == 'linux' or host_machine.system() == 'emscripten'
|
||||
platform_sources += run_command(
|
||||
'sh', '-c',
|
||||
'find "'
|
||||
@@ -56,6 +56,15 @@ if host_machine.system() == 'linux'
|
||||
).stdout().strip().split('\n')
|
||||
endif
|
||||
|
||||
is_emscripten = host_machine.system() == 'emscripten'
|
||||
emcc_link_args = []
|
||||
|
||||
if is_emscripten
|
||||
emcc_link_args += ['--preload-file', meson.global_source_root() + '/build/Minecraft.Client/Common@Common']
|
||||
emcc_link_args += ['--shell-file', meson.global_source_root() + '/scripts/shell.html']
|
||||
emcc_link_args += ['-o 4JCraft.html']
|
||||
endif
|
||||
|
||||
client_dependencies = [
|
||||
render_dep,
|
||||
input_dep,
|
||||
@@ -67,7 +76,7 @@ client_dependencies = [
|
||||
glu_dep,
|
||||
thread_dep,
|
||||
thread_dep,
|
||||
dependency('zlib'),
|
||||
zlib_dep,
|
||||
miniaudio_dep
|
||||
]
|
||||
|
||||
@@ -101,6 +110,7 @@ client = executable('Minecraft.Client',
|
||||
'-DUNICODE', '-D_UNICODE',
|
||||
'-include', meson.current_source_dir() / 'Platform/stdafx.h',
|
||||
],
|
||||
link_args: emcc_link_args,
|
||||
c_args : global_cpp_defs + ['-DUNICODE', '-D_UNICODE'],
|
||||
install : true,
|
||||
install_dir : ''
|
||||
|
||||
Submodule
+1
Submodule Minecraft.World/Emscripten/md5 added at d8e299482a
@@ -1,14 +1,16 @@
|
||||
#include "../Platform/stdafx.h"
|
||||
#if defined(_WIN32)
|
||||
#include <xhash>
|
||||
#else
|
||||
#include <openssl/md5.h>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#if defined(_WIN32)
|
||||
#include <xhash>
|
||||
#elif defined (__EMSCRIPTEN__)
|
||||
// no.
|
||||
#else
|
||||
#include <openssl/md5.h>
|
||||
#include <openssl/evp.h>
|
||||
#endif // _WIN32
|
||||
#include "Hasher.h"
|
||||
#include <openssl/evp.h>
|
||||
|
||||
Hasher::Hasher(std::wstring& salt) { this->salt = salt; }
|
||||
|
||||
@@ -29,6 +31,9 @@ std::wstring Hasher::getHash(std::wstring& name) {
|
||||
//{
|
||||
// throw new RuntimeException(e);
|
||||
//}
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
std::wstring s = std::wstring(salt).append(name);
|
||||
return s;
|
||||
#else
|
||||
// adapted from a SSL example
|
||||
std::wstring combined = salt + name;
|
||||
|
||||
@@ -46,8 +46,12 @@ lib_world = static_library('Minecraft.World',
|
||||
],
|
||||
)
|
||||
|
||||
zlib_dep = dependency('zlib')
|
||||
crypto_dep = dependency('libcrypto') # for MD5 in Hasher.cpp on Linux
|
||||
is_emscripten = host_machine.system() == 'emscripten'
|
||||
if is_emscripten
|
||||
crypto_dep = declare_dependency()
|
||||
else
|
||||
crypto_dep = dependency('libcrypto') # for MD5 in Hasher.cpp on Linux
|
||||
endif
|
||||
|
||||
world_dep = declare_dependency(
|
||||
link_with : lib_world,
|
||||
|
||||
+43
-6
@@ -17,13 +17,26 @@ python = pymod.find_installation('python3', required: true)
|
||||
cc = meson.get_compiler('cpp')
|
||||
|
||||
# system deps
|
||||
gl_dep = dependency('gl')
|
||||
glu_dep = dependency('glu')
|
||||
sdl2_dep = dependency('sdl2') # Yes.. i know sdl3 is out, but there's not point upgrading right now except when
|
||||
if host_machine.system() == 'emscripten'
|
||||
# These are handled in Emscripten via -sUSE_<whatever>
|
||||
gl_dep = declare_dependency()
|
||||
glu_dep = declare_dependency()
|
||||
sdl2_dep = declare_dependency()
|
||||
thread_dep = declare_dependency()
|
||||
zlib_dep = declare_dependency()
|
||||
miniaudio_dep = declare_dependency()
|
||||
else
|
||||
gl_dep = dependency('gl')
|
||||
glu_dep = dependency('glu')
|
||||
sdl2_dep = dependency('sdl2') # Yes.. i know sdl3 is out, but there's not point upgrading right now except when
|
||||
# someone is gonna ask me "Hey juicey can you make it SDL3?" and i'd be like fuck you and still do it.
|
||||
thread_dep = dependency('threads')
|
||||
miniaudio_dep = dependency('miniaudio')
|
||||
thread_dep = dependency('threads')
|
||||
zlib_dep = dependency('zlib')
|
||||
miniaudio_dep = dependency('miniaudio')
|
||||
endif
|
||||
|
||||
stb = subproject('stb').get_variable('stb_inc')
|
||||
|
||||
# compile flags (chagne ts juicey)
|
||||
global_cpp_args = [
|
||||
'-fpermissive',
|
||||
@@ -31,6 +44,29 @@ global_cpp_args = [
|
||||
'-pipe', # use pipes instead of temp files between compiler stages
|
||||
]
|
||||
|
||||
if host_machine.system() == 'emscripten'
|
||||
add_project_arguments(
|
||||
'-pthread',
|
||||
'--use-port=zlib',
|
||||
'-sUSE_SDL=2',
|
||||
'--use-port=sdl2',
|
||||
language: 'cpp'
|
||||
)
|
||||
|
||||
add_project_link_arguments(
|
||||
'-sUSE_SDL=2',
|
||||
'-sUSE_WEBGL2=1',
|
||||
'-sLEGACY_GL_EMULATION=1',
|
||||
'-sALLOW_MEMORY_GROWTH=1',
|
||||
'-sPTHREAD_POOL_SIZE=4',
|
||||
'-sERROR_ON_UNDEFINED_SYMBOLS=0',
|
||||
'-sASSERTIONS=0',
|
||||
'--use-port=zlib',
|
||||
'--use-port=sdl2',
|
||||
language: 'cpp'
|
||||
)
|
||||
endif
|
||||
|
||||
# global ccp defs type shi
|
||||
global_cpp_defs = [
|
||||
'-DSPLIT_SAVES',
|
||||
@@ -41,7 +77,8 @@ global_cpp_defs = [
|
||||
'-DDEBUG',
|
||||
]
|
||||
|
||||
if host_machine.system() == 'linux'
|
||||
# DecalOverdose: yes i know it's bad to do this but I don't know a better way to do this.
|
||||
if host_machine.system() == 'linux' or host_machine.system() == 'emscripten'
|
||||
global_cpp_defs += [
|
||||
'-Dlinux',
|
||||
'-D__linux',
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
[binaries]
|
||||
c = 'emcc'
|
||||
cpp = 'em++'
|
||||
ar = 'emar'
|
||||
strip = 'emstrip'
|
||||
|
||||
[built-in options]
|
||||
c_args = []
|
||||
c_link_args = []
|
||||
|
||||
[host_machine]
|
||||
system = 'emscripten'
|
||||
cpu_family = 'wasm32'
|
||||
cpu = 'wasm32'
|
||||
endian = 'little'
|
||||
@@ -0,0 +1,115 @@
|
||||
<!doctype html>
|
||||
<html lang="en-us">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Emscripten-Generated Code</title>
|
||||
<style>{{{ SHELL_CSS }}}</style>
|
||||
</head>
|
||||
<body>
|
||||
<a href="http://emscripten.org">{{{ SHELL_LOGO }}}</a>
|
||||
|
||||
<div class="spinner" id='spinner'></div>
|
||||
<div class="emscripten" id="status">Downloading...</div>
|
||||
|
||||
<span id='controls'>
|
||||
<span><input type="checkbox" id="resize">Resize canvas</span>
|
||||
<span><input type="checkbox" id="pointerLock" checked>Lock/hide mouse pointer </span>
|
||||
<span><input type="button" value="Fullscreen" onclick="Module.requestFullscreen(document.getElementById('pointerLock').checked,
|
||||
document.getElementById('resize').checked)">
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<div class="emscripten">
|
||||
<progress value="0" max="100" id="progress" hidden=1></progress>
|
||||
</div>
|
||||
|
||||
<div class="emscripten_border">
|
||||
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
|
||||
</div>
|
||||
<textarea id="output" rows="8"></textarea>
|
||||
|
||||
<script type='text/javascript'>
|
||||
var statusElement = document.getElementById('status');
|
||||
var progressElement = document.getElementById('progress');
|
||||
var spinnerElement = document.getElementById('spinner');
|
||||
var canvasElement = document.getElementById('canvas');
|
||||
var outputElement = document.getElementById('output');
|
||||
if (outputElement) outputElement.value = ''; // clear browser cache
|
||||
|
||||
// As a default initial behavior, pop up an alert when webgl context is lost. To make your
|
||||
// application robust, you may want to override this behavior before shipping!
|
||||
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
|
||||
canvasElement.addEventListener('webglcontextlost', (e) => {
|
||||
alert('WebGL context lost. You will need to reload the page.');
|
||||
e.preventDefault();
|
||||
}, false);
|
||||
|
||||
var setStatus = (text) => {
|
||||
if (!setStatus.last) setStatus.last = { time: Date.now(), text: '' };
|
||||
if (text === setStatus.last.text) return;
|
||||
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
|
||||
var now = Date.now();
|
||||
// if this is a progress update, skip it if too soon
|
||||
if (m && now - setStatus.last.time < 30) return;
|
||||
setStatus.last.time = now;
|
||||
setStatus.last.text = text;
|
||||
if (m) {
|
||||
text = m[1];
|
||||
progressElement.value = parseInt(m[2])*100;
|
||||
progressElement.max = parseInt(m[4])*100;
|
||||
progressElement.hidden = false;
|
||||
spinnerElement.hidden = false;
|
||||
} else {
|
||||
progressElement.value = null;
|
||||
progressElement.max = null;
|
||||
progressElement.hidden = true;
|
||||
if (!text) spinnerElement.style.display = 'none';
|
||||
}
|
||||
statusElement.innerHTML = text;
|
||||
};
|
||||
|
||||
#if MODULARIZE && !EXPORT_ES6
|
||||
var moduleArgs = {
|
||||
#else
|
||||
var Module = {
|
||||
#endif
|
||||
print(...args) {
|
||||
console.log(...args);
|
||||
// These replacements are necessary if you render to raw HTML
|
||||
//text = text.replace(/&/g, "&");
|
||||
//text = text.replace(/</g, "<");
|
||||
//text = text.replace(/>/g, ">");
|
||||
//text = text.replace('\n', '<br>', 'g');
|
||||
if (outputElement) {
|
||||
var text = args.join(' ');
|
||||
outputElement.value += text + "\n";
|
||||
outputElement.scrollTop = outputElement.scrollHeight; // focus on bottom
|
||||
}
|
||||
},
|
||||
canvas: canvasElement,
|
||||
setStatus: setStatus,
|
||||
totalDependencies: 0,
|
||||
monitorRunDependencies(left) {
|
||||
this.totalDependencies = Math.max(this.totalDependencies, left);
|
||||
setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
|
||||
}
|
||||
};
|
||||
setStatus('Downloading...');
|
||||
window.onerror = (event) => {
|
||||
// TODO: do not warn on ok events like simulating an infinite loop or exitStatus
|
||||
setStatus('Exception thrown, see JavaScript console');
|
||||
spinnerElement.style.display = 'none';
|
||||
setStatus = (text) => {
|
||||
if (text) console.error('[post-exception status] ' + text);
|
||||
};
|
||||
};
|
||||
</script>
|
||||
{{{ SCRIPT }}}
|
||||
#if MODULARIZE && !EXPORT_ES6
|
||||
<script type='text/javascript'>
|
||||
{{{ EXPORT_NAME }}}(moduleArgs);
|
||||
</script>
|
||||
#endif
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user