Compare commits
151 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 397ab0a6e5 | |||
| f7e555ea6b | |||
| 76788f1708 | |||
| 2396e6bb96 | |||
| d7cc42d40e | |||
| b7ad828882 | |||
| 93215033e4 | |||
| c432e83d18 | |||
| c58c1bd9d2 | |||
| a399023cca | |||
| b0fac9fbc6 | |||
| ff7baaac3b | |||
| 05adecade7 | |||
| 69b749a844 | |||
| 5c248704ac | |||
| 027f87f653 | |||
| 6e0b3f163a | |||
| 0160419756 | |||
| 1628e08748 | |||
| 41437bb999 | |||
| 64a44b5385 | |||
| 2fc0095b86 | |||
| 85a4e09e17 | |||
| abeead819e | |||
| 347265c362 | |||
| 50f6bf8e68 | |||
| b7d200a5b1 | |||
| 69c418213e | |||
| 8c6effdabf | |||
| daf56bc296 | |||
| 8f04e231bd | |||
| d181ed62f6 | |||
| cf94e7d162 | |||
| e7dca2570a | |||
| d862d05616 | |||
| c4bbf6cf1f | |||
| 9e74005af7 | |||
| 5d28fc9fd5 | |||
| fbac609df2 | |||
| 224fd9dacc | |||
| 19f73c2754 | |||
| bc494aa979 | |||
| b20b8cb311 | |||
| 8552634614 | |||
| d87dd6ae72 | |||
| a71b1036c7 | |||
| d3a9de8b2a | |||
| 9c1c1695a7 | |||
| 7513c37f52 | |||
| 650c81db3d | |||
| 684b55c260 | |||
| 41d139ce32 | |||
| 514c75bf01 | |||
| 557dd7430b | |||
| 6fd9148e17 | |||
| a1b9329ad8 | |||
| 9b729ed19e | |||
| 0a5cf82d80 | |||
| e174fabcb6 | |||
| 62186f8afb | |||
| 4d9db3ed3b | |||
| 8b202ba5f1 | |||
| 80019158da | |||
| 84140ae6d4 | |||
| aa250ff560 | |||
| 08d8e341b9 | |||
| 9c502ce8fc | |||
| fbfccdeac6 | |||
| 5d86773134 | |||
| e051527607 | |||
| 45c85fcf79 | |||
| fe77d9c2a0 | |||
| b7792622a9 | |||
| cd4b39cf88 | |||
| 81c2eb82f0 | |||
| aa515c5f3d | |||
| 1b9d27f4a0 | |||
| 0ef3b2de31 | |||
| b3d6e7151b | |||
| 03618ed156 | |||
| 33fe5fec3a | |||
| 61a0d9690b | |||
| 09a6ba4a12 | |||
| e14825c302 | |||
| efe4c91538 | |||
| a3b8adeb5a | |||
| 58de5bb40b | |||
| 1ddf12beb9 | |||
| e5cdd2c370 | |||
| 9b830f1bfc | |||
| b032e2a3a0 | |||
| 60410f59bf | |||
| 9834a95f0e | |||
| 7b28bcbcb6 | |||
| 016b2d91b4 | |||
| 5f7e4ab703 | |||
| 95efdb54dd | |||
| 6e1964adb3 | |||
| 52b4ccaea2 | |||
| 8084ec7857 | |||
| 6b3b0134cf | |||
| d7eca58551 | |||
| 875039a6dd | |||
| 7cceb05d83 | |||
| b3223ff8e3 | |||
| 7af301c62b | |||
| 7e97721325 | |||
| 552ef2b92f | |||
| 265c5d03e6 | |||
| 223541b009 | |||
| 1e94adb190 | |||
| 48a170a6c4 | |||
| 5ba98a547e | |||
| dcf9e0bcdb | |||
| 00fec789b5 | |||
| 50147bd2a6 | |||
| 34c8421d2c | |||
| 2912e9ae2e | |||
| f1f1d116b3 | |||
| 56caa4f2dc | |||
| e4883d87fc | |||
| 6faa481013 | |||
| 4a365e19f2 | |||
| 0e6a6cc537 | |||
| 559b207ee2 | |||
| d9f2cb03c7 | |||
| 489ca2675d | |||
| c6285c903d | |||
| 2f1a6f265f | |||
| 32aaafeb7e | |||
| 8a1b3cc1c4 | |||
| 28931d5380 | |||
| 0bdef577f5 | |||
| 25e6f7159e | |||
| a3a21557f8 | |||
| b88a89ae01 | |||
| 2672ad5493 | |||
| 706db0c300 | |||
| e9fb5ea39a | |||
| 8b35193cf7 | |||
| 5d9bcac156 | |||
| 7787015025 | |||
| 3b47b80762 | |||
| d61d3cddab | |||
| 0c7800d28b | |||
| 5f64818302 | |||
| f28c722da4 | |||
| 54a1f90212 | |||
| d814a78453 | |||
| 9c0dfd60d5 | |||
| e452788fff |
@@ -1,36 +1,62 @@
|
||||
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04
|
||||
FROM ubuntu:24.04 as clang
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ARG LLVM_VERSION=20
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y \
|
||||
wget \
|
||||
lsb-release \
|
||||
software-properties-common \
|
||||
gnupg
|
||||
|
||||
RUN wget https://apt.llvm.org/llvm.sh \
|
||||
&& chmod +x llvm.sh \
|
||||
&& ./llvm.sh ${LLVM_VERSION} \
|
||||
&& rm llvm.sh
|
||||
|
||||
RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${LLVM_VERSION} 100 \
|
||||
--slave /usr/bin/clang++ clang++ /usr/bin/clang++-${LLVM_VERSION}
|
||||
|
||||
RUN update-alternatives --install /usr/bin/lld lld /usr/bin/lld-${LLVM_VERSION} 100
|
||||
|
||||
RUN apt-get install -y \
|
||||
libc++-${LLVM_VERSION}-dev \
|
||||
libc++abi-${LLVM_VERSION}-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV CC="clang" \
|
||||
CXX="clang++" \
|
||||
CC_LD="lld" \
|
||||
CXX_LD="lld"
|
||||
|
||||
FROM clang AS ivjcraft
|
||||
|
||||
ARG MESON_VERSION=1.10.2
|
||||
|
||||
# Dependencies
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y software-properties-common \
|
||||
&& add-apt-repository -y ppa:ubuntu-toolchain-r/test \
|
||||
&& add-apt-repository ppa:ubuntu-toolchain-r/test \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y \
|
||||
build-essential \
|
||||
gcc-14 g++-14 \
|
||||
python3 \
|
||||
ninja-build \
|
||||
libsdl2-dev \
|
||||
libgl-dev \
|
||||
libglm-dev \
|
||||
libglu1-mesa-dev \
|
||||
libpthread-stubs0-dev \
|
||||
# Set GCC 14 as the default compiler
|
||||
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100 \
|
||||
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100 \
|
||||
# Clean up lol
|
||||
libssl-dev \
|
||||
gcc-15 g++-15 \
|
||||
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-15 100 \
|
||||
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-15 100 \
|
||||
&& apt-get autoremove -y \
|
||||
&& apt-get clean -y \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Use the latest version of Meson -> $(curl -s "https://api.github.com/repos/mesonbuild/meson/releases/latest" | grep -Po '"tag_name": "\K[0-9.]+')
|
||||
RUN MESON_VERSION=1.10.2 \
|
||||
&& wget -qO meson.tar.gz https://github.com/mesonbuild/meson/releases/latest/download/meson-${MESON_VERSION}.tar.gz \
|
||||
RUN wget -qO meson.tar.gz https://github.com/mesonbuild/meson/releases/latest/download/meson-${MESON_VERSION}.tar.gz \
|
||||
&& mkdir /opt/meson \
|
||||
&& tar xf meson.tar.gz --strip-components=1 -C /opt/meson \
|
||||
&& mv /opt/meson/meson.py /opt/meson/meson \
|
||||
&& ln -s /opt/meson/meson /usr/bin/meson \
|
||||
&& rm -rf meson.tar.gz
|
||||
|
||||
ENV DEBIAN_FRONTEND=dialog
|
||||
|
||||
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 438 B |
|
Before Width: | Height: | Size: 477 B |
@@ -1,7 +1,5 @@
|
||||
# <img src=".github-assets/logo.jpg" alt="Logo" width="50" height="50" style="vertical-align: middle;"> 4JCraft
|
||||
|
||||
     
|
||||
   
|
||||
---
|
||||
|
||||
4JCraft is a modified version of the Minecraft Console Legacy Edition, aimed at porting old Minecraft to different platforms (such as Linux, Android, Emscripten, etc.) and refactoring the codebase to improve organization and use modern C++ features.
|
||||
|
||||
@@ -1,58 +1,55 @@
|
||||
# MARK: build configuration
|
||||
|
||||
project(
|
||||
'4jcraft',
|
||||
['cpp', 'c'],
|
||||
version: '0.1.0',
|
||||
meson_version: '>= 1.3',
|
||||
default_options: [
|
||||
'cpp_std=c++23',
|
||||
'warning_level=0',
|
||||
'buildtype=debugoptimized', # for now
|
||||
'unity=on', # merge source files per target
|
||||
'unity_size=8', # TODO: mess around with this
|
||||
'b_pch=true', # precompiled headers
|
||||
],
|
||||
'4jcraft',
|
||||
['cpp', 'c'],
|
||||
version: '0.1.0',
|
||||
meson_version: '>= 1.3',
|
||||
default_options: [
|
||||
'cpp_std=c++20',
|
||||
'warning_level=0',
|
||||
'unity=on', # merge source files per target
|
||||
'unity_size=8', # TODO: mess around with this
|
||||
'buildtype=debug',
|
||||
'b_pch=true', # precompiled headers
|
||||
'default_library=static', # static linkage to subprojects
|
||||
# 'b_lto=true', # link-time optimisation (ThinLTO under clang+lld)
|
||||
# 'b_ndebug=if-release', # drop assert() in --buildtype=release
|
||||
],
|
||||
)
|
||||
|
||||
pymod = import('python')
|
||||
python = pymod.find_installation('python3', required: true)
|
||||
|
||||
cc = meson.get_compiler('cpp')
|
||||
lib_dir = meson.current_source_dir() / 'thirdparty/lib' / host_machine.system() / host_machine.cpu()
|
||||
inc_dir = 'thirdparty/include' / host_machine.system()
|
||||
|
||||
global_cpp_args = []
|
||||
global_cpp_defs = [
|
||||
'-DSPLIT_SAVES',
|
||||
'-D_LARGE_WORLDS',
|
||||
'-D_EXTENDED_ACHIEVEMENTS',
|
||||
'-D_DEBUG_MENUS_ENABLED',
|
||||
'-D_DEBUG',
|
||||
'-D_FORTIFY_SOURCE=2',
|
||||
'-DDEBUG',
|
||||
'-DSPLIT_SAVES',
|
||||
'-D_LARGE_WORLDS',
|
||||
'-D_EXTENDED_ACHIEVEMENTS',
|
||||
'-DMULTITHREAD_ENABLE', # always-on threading flag (formerly in App_Defines.h)
|
||||
]
|
||||
|
||||
if host_machine.system() == 'linux' or host_machine.system() == 'android'
|
||||
global_cpp_defs += ['-Dlinux', '-D__linux', '-D__linux__']
|
||||
# Debug-only defines: keep for debug + debugoptimized so iteration is unchanged.
|
||||
# --buildtype=release strips them so shipping builds don't carry debug logging,
|
||||
# debug menu UI, or assert-driven sanity checks.
|
||||
if get_option('buildtype') in ['debug', 'debugoptimized']
|
||||
global_cpp_defs += [
|
||||
'-D_DEBUG',
|
||||
'-DDEBUG',
|
||||
'-D_DEBUG_MENUS_ENABLED',
|
||||
]
|
||||
endif
|
||||
|
||||
if host_machine.system() == 'android'
|
||||
global_cpp_defs += ['-D__android__']
|
||||
if get_option('buildtype') == 'debugoptimized'
|
||||
global_cpp_defs += ['-D_FORTIFY_SOURCE=2']
|
||||
endif
|
||||
|
||||
if get_option('renderer') == 'gles'
|
||||
global_cpp_defs += ['-DGLES']
|
||||
if host_machine.system() == 'android'
|
||||
gl_dep = cc.find_library('GLESv3', required: true )
|
||||
else
|
||||
gl_dep = dependency('glesv2', required: true)
|
||||
endif
|
||||
glu_dep = dependency('', required: false)
|
||||
else
|
||||
gl_dep = dependency('gl', required: true)
|
||||
glu_dep = dependency('glu', required: true)
|
||||
endif
|
||||
# MARK: meson options
|
||||
|
||||
if get_option('enable_vsync')
|
||||
global_cpp_defs += ['-DENABLE_VSYNC']
|
||||
global_cpp_defs += ['-DENABLE_VSYNC']
|
||||
endif
|
||||
|
||||
if get_option('classic_panorama')
|
||||
@@ -60,51 +57,52 @@ if get_option('classic_panorama')
|
||||
endif
|
||||
|
||||
if get_option('enable_frame_profiler')
|
||||
global_cpp_defs += ['-DENABLE_FRAME_PROFILER']
|
||||
global_cpp_defs += ['-DENABLE_FRAME_PROFILER']
|
||||
endif
|
||||
|
||||
if get_option('ui_backend') == 'shiggy'
|
||||
global_cpp_defs += ['-D_ENABLEIGGY']
|
||||
global_cpp_defs += ['-D_ENABLEIGGY']
|
||||
endif
|
||||
|
||||
if get_option('ui_backend') == 'java'
|
||||
global_cpp_defs += '-DENABLE_JAVA_GUIS'
|
||||
global_cpp_defs += '-DENABLE_JAVA_GUIS'
|
||||
endif
|
||||
|
||||
if get_option('occlusion_culling') == 'off'
|
||||
global_cpp_defs += ['-DOCCLUSION_MODE_NONE']
|
||||
elif get_option('occlusion_culling') == 'frustum'
|
||||
global_cpp_defs += ['-DOCCLUSION_MODE_FRUSTUM']
|
||||
elif get_option('occlusion_culling') == 'bfs'
|
||||
global_cpp_defs += ['-DOCCLUSION_MODE_BFS', '-DUSE_OCCLUSION_CULLING']
|
||||
elif get_option('occlusion_culling') == 'hardware'
|
||||
global_cpp_defs += ['-DOCCLUSION_MODE_HARDWARE', '-DUSE_OCCLUSION_CULLING']
|
||||
endif
|
||||
|
||||
add_project_arguments(global_cpp_defs, language: ['cpp', 'c'])
|
||||
|
||||
global_cpp_args = [
|
||||
'-Wshift-count-overflow',
|
||||
'-pipe',
|
||||
]
|
||||
add_project_arguments(global_cpp_args, language: 'cpp')
|
||||
|
||||
if host_machine.system() == 'android'
|
||||
sdl2_dep = declare_dependency(
|
||||
dependencies: cc.find_library('SDL2', dirs: lib_dir, required: true ),
|
||||
include_directories: inc_dir)
|
||||
else
|
||||
sdl2_dep = dependency('sdl2')
|
||||
endif
|
||||
thread_dep = dependency('threads')
|
||||
dl_dep = cc.find_library('dl', required: true)
|
||||
|
||||
if host_machine.system() == 'android'
|
||||
glm_dep = declare_dependency(include_directories: inc_dir)
|
||||
else
|
||||
glm_dep = dependency('glm')
|
||||
endif
|
||||
|
||||
stb = subproject('stb').get_variable('stb_inc')
|
||||
stb_dep = declare_dependency(include_directories: stb)
|
||||
|
||||
miniaudio_dep = dependency('miniaudio')
|
||||
|
||||
subdir('targets/util')
|
||||
subdir('targets/java')
|
||||
subdir('targets/nbt')
|
||||
subdir('targets/platform')
|
||||
|
||||
# MARK: platform configuration
|
||||
|
||||
if host_machine.system() in ['linux', 'windows']
|
||||
platform_fs_dep = platform_fs_std_dep
|
||||
platform_game_dep = platform_game_stub_dep
|
||||
platform_input_dep = platform_input_sdl2_dep
|
||||
platform_leaderboard_dep = platform_leaderboard_stub_dep
|
||||
platform_network_dep = platform_network_stub_dep
|
||||
platform_profile_dep = platform_profile_stub_dep
|
||||
platform_renderer_dep = platform_renderer_gl_dep
|
||||
platform_sound_dep = platform_sound_miniaudio_dep
|
||||
platform_storage_dep = platform_storage_stub_dep
|
||||
platform_thread_dep = platform_thread_dep # standardized backend (for now)
|
||||
|
||||
app_platform_sources = files('targets/app/desktop/main.cpp')
|
||||
endif
|
||||
|
||||
subdir('targets/resources')
|
||||
subdir('targets/minecraft')
|
||||
subdir('targets/app')
|
||||
|
||||
@@ -40,3 +40,10 @@ option(
|
||||
value: 'frustum',
|
||||
description: 'Occlusion culling mode. Off disables ALL CULLING (debug only!), Frustum disables offscreen rendering (default), BFS is experimental connectivity culling, hardware uses GPU queries.',
|
||||
)
|
||||
|
||||
option(
|
||||
'enable_mimalloc',
|
||||
type: 'feature',
|
||||
value: 'auto',
|
||||
description: 'Link mimalloc as the malloc implementation. Requires libmimalloc-dev.',
|
||||
)
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
[constants]
|
||||
ndk_home = 'set_path_to_you_ndk'
|
||||
ndk_api = 'set_api_ndk'
|
||||
|
||||
[properties]
|
||||
skip_sanity_check = true
|
||||
|
||||
[binaries]
|
||||
c = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android' + ndk_api + '-clang'
|
||||
cpp = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android' + ndk_api + '-clang++'
|
||||
ar = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar'
|
||||
strip = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip'
|
||||
sys_root = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/sysroot'
|
||||
as = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as'
|
||||
ranlib = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib'
|
||||
ld = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ld'
|
||||
pkg_config = 'false'
|
||||
|
||||
[host_machine]
|
||||
system = 'android'
|
||||
cpu_family = 'arm'
|
||||
cpu = 'aarch64'
|
||||
endian = 'little'
|
||||
@@ -0,0 +1,183 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
from pathlib import Path
|
||||
|
||||
DEFAULT_EXTENSIONS = {
|
||||
".c",
|
||||
".cc",
|
||||
".cpp",
|
||||
".cxx",
|
||||
".h",
|
||||
".hh",
|
||||
".hpp",
|
||||
".hxx",
|
||||
".inl",
|
||||
".ipp",
|
||||
}
|
||||
DEFAULT_JOBS = os.cpu_count() or 4
|
||||
DEFAULT_TIMEOUT = 10
|
||||
|
||||
# ansi escapes
|
||||
RESET = "\033[0m" if sys.stdout.isatty() else ""
|
||||
GREEN = "\033[32m" if sys.stdout.isatty() else ""
|
||||
YELLOW = "\033[33m" if sys.stdout.isatty() else ""
|
||||
RED = "\033[31m" if sys.stdout.isatty() else ""
|
||||
BOLD = "\033[1m" if sys.stdout.isatty() else ""
|
||||
|
||||
def format_file(path, clang_format, extra_args, timeout):
|
||||
cmd = [clang_format, "-i"]
|
||||
cmd += extra_args
|
||||
cmd.append(str(path))
|
||||
|
||||
try:
|
||||
result = subprocess.run(
|
||||
cmd,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=timeout,
|
||||
)
|
||||
if result.returncode != 0:
|
||||
msg = (result.stderr or result.stdout or "non-zero exit code").strip()
|
||||
return ("error", str(path), msg)
|
||||
return ("ok", str(path), None)
|
||||
|
||||
except subprocess.TimeoutExpired:
|
||||
return ("timeout", str(path), f"exceeded {timeout}s timeout")
|
||||
|
||||
except FileNotFoundError:
|
||||
return ("error", str(path), f"'{clang_format}' not found — is it installed?")
|
||||
|
||||
except Exception as exc:
|
||||
return ("error", str(path), str(exc))
|
||||
|
||||
def find_files(root, extensions, exclude_dirs):
|
||||
found = []
|
||||
for dirpath, dirnames, filenames in os.walk(root):
|
||||
dirnames[:] = [d for d in dirnames if d not in exclude_dirs]
|
||||
for fname in filenames:
|
||||
if Path(fname).suffix.lower() in extensions:
|
||||
found.append(Path(dirpath) / fname)
|
||||
return sorted(found)
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser(
|
||||
description="Recursively runs clang-format on C/C++ files.",
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
)
|
||||
p.add_argument("directory", nargs="?", default=".", type=Path)
|
||||
p.add_argument(
|
||||
"--clang-format",
|
||||
default="clang-format",
|
||||
metavar="BIN",
|
||||
help="Path to the clang-format executable. (default: clang-format)",
|
||||
)
|
||||
p.add_argument(
|
||||
"-j",
|
||||
"--jobs",
|
||||
type=int,
|
||||
default=DEFAULT_JOBS,
|
||||
metavar="N",
|
||||
help=f"Number of parallel workers. (default: {DEFAULT_JOBS})",
|
||||
)
|
||||
p.add_argument(
|
||||
"--timeout",
|
||||
type=int,
|
||||
default=DEFAULT_TIMEOUT,
|
||||
metavar="SECS",
|
||||
help=f"Per-file timeout in seconds. (default: {DEFAULT_TIMEOUT})",
|
||||
)
|
||||
p.add_argument(
|
||||
"--extensions",
|
||||
nargs="+",
|
||||
metavar="EXT",
|
||||
help="File extensions to process (including the dot)."
|
||||
f"(default: {' '.join(sorted(DEFAULT_EXTENSIONS))})",
|
||||
)
|
||||
p.add_argument(
|
||||
"--exclude",
|
||||
nargs="*",
|
||||
default=[],
|
||||
metavar="DIR",
|
||||
help="Directory names to skip during traversal (e.g. build third_party).",
|
||||
)
|
||||
p.add_argument(
|
||||
"--clang-format-args",
|
||||
nargs=argparse.REMAINDER,
|
||||
default=[],
|
||||
metavar="...",
|
||||
)
|
||||
args = p.parse_args()
|
||||
|
||||
root = args.directory.resolve()
|
||||
if not root.is_dir():
|
||||
print(f"{RED}Error:{RESET} '{root}' is not a directory.", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
extensions = (
|
||||
{e if e.startswith(".") else f".{e}" for e in args.extensions}
|
||||
if args.extensions
|
||||
else DEFAULT_EXTENSIONS
|
||||
)
|
||||
|
||||
exclude_dirs = set(args.exclude)
|
||||
|
||||
files = find_files(root, extensions, exclude_dirs)
|
||||
if not files:
|
||||
print(f"{YELLOW}No source files found.{RESET}")
|
||||
return 0
|
||||
|
||||
total = len(files)
|
||||
print(f"Found {BOLD}{total}{RESET} file(s).")
|
||||
|
||||
counters = {"ok": 0, "timeout": 0, "error": 0}
|
||||
completed = 0
|
||||
|
||||
with ThreadPoolExecutor(max_workers=args.jobs) as pool:
|
||||
futures = {
|
||||
pool.submit(
|
||||
format_file,
|
||||
f,
|
||||
args.clang_format,
|
||||
args.clang_format_args,
|
||||
args.timeout,
|
||||
): f
|
||||
for f in files
|
||||
}
|
||||
|
||||
for future in as_completed(futures):
|
||||
status, path_str, error = future.result()
|
||||
counters[status] += 1
|
||||
completed += 1
|
||||
rel = os.path.relpath(path_str, root)
|
||||
|
||||
if status == "ok":
|
||||
tag = f"{GREEN}[ OK ]{RESET}"
|
||||
elif status == "timeout":
|
||||
tag = f"{YELLOW}[ TIMEOUT ]{RESET}"
|
||||
else:
|
||||
tag = f"{RED}[ ERROR ]{RESET}"
|
||||
|
||||
progress = f"[{completed:>{len(str(total))}}/{total}]"
|
||||
line = f"{progress} {tag} {rel}"
|
||||
if error:
|
||||
line += f"\n {RED}{error}{RESET}"
|
||||
print(line)
|
||||
|
||||
print()
|
||||
print(f"{BOLD}Summary{RESET}")
|
||||
print(f"Total: {total}")
|
||||
print(f"{GREEN}OK: {counters['ok']}{RESET}")
|
||||
|
||||
if counters["timeout"]:
|
||||
print(f"{YELLOW}Timeout: {counters['timeout']}{RESET}")
|
||||
if counters["error"]:
|
||||
print(f"{RED}Error: {counters['error']}{RESET}")
|
||||
|
||||
return 1 if (counters["timeout"] or counters["error"]) else 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Enumerate C/C++ source files for a meson target.
|
||||
|
||||
Replaces the run_command('sh', '-c', 'find ...') hack in
|
||||
targets/{minecraft,app}/meson.build. Run this whenever source files are
|
||||
added or removed and commit the regenerated *_sources.txt files.
|
||||
|
||||
Usage:
|
||||
python3 scripts/list_sources.py
|
||||
|
||||
Each module's sources.txt is generated relative to its meson source dir.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
# Module configuration: (output_path, scan_root, [exclude_basenames]).
|
||||
# Paths in the output file are relative to the directory containing the
|
||||
# meson.build that reads it.
|
||||
MODULES = [
|
||||
{
|
||||
"name": "minecraft",
|
||||
"output": REPO_ROOT / "targets" / "minecraft" / "sources.txt",
|
||||
"scan_root": REPO_ROOT / "targets" / "minecraft",
|
||||
"rel_to": REPO_ROOT / "targets" / "minecraft",
|
||||
"exclude": {
|
||||
"DurangoStats.cpp", # Durango-specific
|
||||
# Incomplete / unused
|
||||
"SkyIslandDimension.cpp",
|
||||
"MemoryChunkStorage.cpp",
|
||||
"MemoryLevelStorage.cpp",
|
||||
"MemoryLevelStorageSource.cpp",
|
||||
"NbtSlotFile.cpp",
|
||||
"ZonedChunkStorage.cpp",
|
||||
"ZoneFile.cpp",
|
||||
"ZoneIo.cpp",
|
||||
"LevelConflictException.cpp",
|
||||
"SurvivalMode.cpp",
|
||||
"CreativeMode.cpp",
|
||||
"GameMode.cpp",
|
||||
"DemoMode.cpp",
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "app_common",
|
||||
"output": REPO_ROOT / "targets" / "app" / "common_sources.txt",
|
||||
"scan_root": REPO_ROOT / "targets" / "app" / "common",
|
||||
"rel_to": REPO_ROOT / "targets" / "app",
|
||||
"exclude": {
|
||||
"UIScene_InGameSaveManagementMenu.cpp",
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "app_linux",
|
||||
"output": REPO_ROOT / "targets" / "app" / "linux_sources.txt",
|
||||
"scan_root": REPO_ROOT / "targets" / "app" / "linux",
|
||||
"rel_to": REPO_ROOT / "targets" / "app",
|
||||
"exclude": set(),
|
||||
},
|
||||
]
|
||||
|
||||
EXTENSIONS = (".cpp", ".c")
|
||||
|
||||
|
||||
def collect(scan_root: Path, rel_to: Path, exclude: set[str]) -> list[str]:
|
||||
out: list[str] = []
|
||||
for dirpath, _dirnames, filenames in os.walk(scan_root):
|
||||
for name in filenames:
|
||||
if not name.endswith(EXTENSIONS):
|
||||
continue
|
||||
if name in exclude:
|
||||
continue
|
||||
full = Path(dirpath) / name
|
||||
out.append(str(full.relative_to(rel_to)))
|
||||
out.sort()
|
||||
return out
|
||||
|
||||
|
||||
def main() -> int:
|
||||
for mod in MODULES:
|
||||
sources = collect(mod["scan_root"], mod["rel_to"], mod["exclude"])
|
||||
body = "\n".join(sources) + "\n"
|
||||
out_path: Path = mod["output"]
|
||||
previous = out_path.read_text() if out_path.exists() else ""
|
||||
if previous == body:
|
||||
print(f"{mod['name']}: {len(sources)} files (unchanged)")
|
||||
else:
|
||||
out_path.write_text(body)
|
||||
print(f"{mod['name']}: {len(sources)} files (regenerated {out_path.relative_to(REPO_ROOT)})")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -3,7 +3,3 @@ c = 'clang'
|
||||
cpp = 'clang++'
|
||||
c_ld = 'lld'
|
||||
cpp_ld = 'lld'
|
||||
|
||||
[built-in options]
|
||||
cpp_args = ['-stdlib=libc++']
|
||||
cpp_link_args = ['-stdlib=libc++']
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
[wrap-file]
|
||||
directory = glew-2.2.0
|
||||
source_url = http://downloads.sourceforge.net/glew/glew-2.2.0.tgz
|
||||
source_filename = glew-2.2.0.tgz
|
||||
source_hash = d4fc82893cfb00109578d0a1a2337fb8ca335b3ceccf97b97e5cc7f08e4353e1
|
||||
patch_filename = glew_2.2.0-2_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/glew_2.2.0-2/get_patch
|
||||
patch_hash = df7bc80456da53f83e93e89ca5035d04cdff19a836c956887a684b2bee16eb9b
|
||||
wrapdb_version = 2.2.0-2
|
||||
|
||||
[provide]
|
||||
glew = glew_dep
|
||||
@@ -0,0 +1,13 @@
|
||||
[wrap-file]
|
||||
directory = glm-1.0.1
|
||||
source_url = https://github.com/g-truc/glm/archive/refs/tags/1.0.1.tar.gz
|
||||
source_filename = glm-1.0.1.tar.gz
|
||||
source_hash = 9f3174561fd26904b23f0db5e560971cbf9b3cbda0b280f04d5c379d03bf234c
|
||||
patch_filename = glm_1.0.1-1_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/glm_1.0.1-1/get_patch
|
||||
patch_hash = 25679275e26bc4c36bb617d1b4a52197039402af828d2a4bf67b3c0260a5df6a
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/glm_1.0.1-1/glm-1.0.1.tar.gz
|
||||
wrapdb_version = 1.0.1-1
|
||||
|
||||
[provide]
|
||||
glm = glm_dep
|
||||
@@ -1,6 +1,6 @@
|
||||
project('simdutf',
|
||||
'cpp',
|
||||
default_options: ['cpp_std=c++23'],
|
||||
default_options: ['cpp_std=c++20'],
|
||||
version: '8.2.0',
|
||||
meson_version: '>= 1.1',
|
||||
license: ['MIT'],
|
||||
@@ -55,7 +55,7 @@ simdutf_lib = static_library(
|
||||
)
|
||||
|
||||
simdutf_dep = declare_dependency(
|
||||
sources: simdutf_amalgamate,
|
||||
include_directories: include_directories('.'),
|
||||
link_with: simdutf_lib,
|
||||
)
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
project('stb', 'c')
|
||||
|
||||
stb_inc = include_directories('.')
|
||||
stb_dep = declare_dependency(
|
||||
include_directories: include_directories('.'),
|
||||
)
|
||||
|
||||
meson.override_dependency('stb', stb_dep)
|
||||
@@ -0,0 +1,15 @@
|
||||
[wrap-file]
|
||||
directory = SDL2-2.32.8
|
||||
source_url = https://github.com/libsdl-org/SDL/releases/download/release-2.32.8/SDL2-2.32.8.tar.gz
|
||||
source_filename = SDL2-2.32.8.tar.gz
|
||||
source_hash = 0ca83e9c9b31e18288c7ec811108e58bac1f1bb5ec6577ad386830eac51c787e
|
||||
patch_filename = sdl2_2.32.8-1_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/sdl2_2.32.8-1/get_patch
|
||||
patch_hash = 5df17ea39ca418826db20e96bd821fa52b5718dac64b6225119fb6588c2744f0
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/sdl2_2.32.8-1/SDL2-2.32.8.tar.gz
|
||||
wrapdb_version = 2.32.8-1
|
||||
|
||||
[provide]
|
||||
sdl2 = sdl2_dep
|
||||
sdl2main = sdl2main_dep
|
||||
sdl2_test = sdl2_test_dep
|
||||
@@ -1,7 +1,7 @@
|
||||
[wrap-git]
|
||||
url = https://github.com/simdutf/simdutf.git
|
||||
depth = 1
|
||||
revision = v8.2.0
|
||||
revision = fd476229424b40ae71a58dd5a205795c3d76b5f1
|
||||
patch_directory = simdutf
|
||||
|
||||
[provide]
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
[wrap-file]
|
||||
directory = zlib-1.3.2
|
||||
source_url = https://zlib.net/zlib-1.3.2.tar.xz
|
||||
source_fallback_url = https://wrapdb.mesonbuild.com/v2/zlib_1.3.2-1/get_source/zlib-1.3.2.tar.xz
|
||||
source_filename = zlib-1.3.2.tar.xz
|
||||
source_hash = d7a0654783a4da529d1bb793b7ad9c3318020af77667bcae35f95d0e42a792f3
|
||||
patch_filename = zlib_1.3.2-1_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/zlib_1.3.2-1/get_patch
|
||||
patch_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/zlib_1.3.2-1/zlib_1.3.2-1_patch.zip
|
||||
patch_hash = 5ae7a2e92f823df118cfb8c1b23d94e3117864392b3446581d669049b2fba6dd
|
||||
wrapdb_version = 1.3.2-1
|
||||
|
||||
[provide]
|
||||
dependency_names = zlib
|
||||
@@ -1,48 +0,0 @@
|
||||
# Network Code Implementation Notes
|
||||
|
||||
## Overview
|
||||
|
||||
The networking classes are organized as follows:
|
||||
|
||||
```
|
||||
Game \
|
||||
^ |
|
||||
| |
|
||||
+-----------------------------+-----------------------------+ |
|
||||
| | |
|
||||
v v |
|
||||
Game Network Manager <--------------------------------> Network Player Interface |- platform independent layers
|
||||
^ ^ |
|
||||
| | |
|
||||
v | |
|
||||
Platform Network Manager Interface | |
|
||||
^ | /
|
||||
| |
|
||||
v v \
|
||||
Platform Network Manager Implementation(1) <------> Network Player Implementation (3) |
|
||||
^ ^ |_ platform specific layers
|
||||
| | |
|
||||
v v |
|
||||
Platform specific network code(2) Platform specific player code (4) /
|
||||
```
|
||||
|
||||
### Notes
|
||||
|
||||
- In general the game should **only communicate with the `GameNetworkManager` and `NetworkPlayerInterface` APIs**, which provide a platform independent interface for networking functionality. The `GameNetworkManager` may in general have code which is aware of the game itself, but it *shouldn't have any platform-specific networking code*. It communicates with a platform specific implementation of a `PlatformNetworkManagerInterface` to achieve this.
|
||||
|
||||
- The platform specific layers shouldn't contain any general game code, as this is much better placed in the platform independent layers to avoid duplicating effort.
|
||||
|
||||
- Platform specific files for each platform for the numbered classes in the previous diagram are currently:
|
||||
|
||||
|
||||
## Platform-Specific Files
|
||||
|
||||
The platform-specific implementations for each numbered class in the diagram:
|
||||
|
||||
| Class | Xbox 360 | Sony | Other |
|
||||
|-------|---------------------------------|----------------------------|-----------------------|
|
||||
| (1) | PlatformNetworkManagerXbox | PlatformNetworkManagerSony | PlatformNetworkManagerStub |
|
||||
| (2) | Provided by QNET | SQRNetworkManager | Qnet stub* |
|
||||
| (3) | NetworkPlayerXbox | NetworkPlayerSony | NetworkPlayerXbox |
|
||||
| (4) | Provided by QNET | SQRNetworkPlayer | Qnet stub* |
|
||||
\*Temporarily provided by `extra64.h`
|
||||
@@ -1,27 +0,0 @@
|
||||
========================================================================
|
||||
Xbox 360 APPLICATION : Minecraft.Client Project Overview
|
||||
========================================================================
|
||||
|
||||
AppWizard has created this Minecraft.Client application for you.
|
||||
|
||||
This file contains a summary of what you will find in each of the files that
|
||||
make up your Minecraft.Client application.
|
||||
|
||||
Minecraft.Client.vcxproj
|
||||
This is the main project file for VC++ projects generated using an Application Wizard.
|
||||
It contains information about the version of Visual C++ that generated the file, and
|
||||
information about the platforms, configurations, and project features selected with the
|
||||
Application Wizard.
|
||||
|
||||
Minecraft.Client.cpp
|
||||
This is the main application source file.
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Other notes:
|
||||
|
||||
AppWizard uses "TODO:" comments to indicate parts of the source code you
|
||||
should add to or customize.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,438 @@
|
||||
#include "app/common/AppGameServices.h"
|
||||
|
||||
#include "app/common/DLC/DLCSkinFile.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "java/Class.h" // eINSTANCEOF
|
||||
#include "platform/game/game.h"
|
||||
|
||||
AppGameServices::AppGameServices(Game& game, IMenuService& menus)
|
||||
: game_(game), menus_(menus) {}
|
||||
|
||||
// -- Strings --
|
||||
|
||||
const char* AppGameServices::getString(int id) { return Game::GetString(id); }
|
||||
|
||||
// -- Debug settings --
|
||||
|
||||
bool AppGameServices::debugSettingsOn() { return game_.DebugSettingsOn(); }
|
||||
|
||||
bool AppGameServices::debugArtToolsOn() { return game_.DebugArtToolsOn(); }
|
||||
|
||||
unsigned int AppGameServices::debugGetMask(int iPad, bool overridePlayer) {
|
||||
return game_.GetGameSettingsDebugMask(iPad, overridePlayer);
|
||||
}
|
||||
|
||||
bool AppGameServices::debugMobsDontAttack() {
|
||||
return game_.GetMobsDontAttackEnabled();
|
||||
}
|
||||
|
||||
bool AppGameServices::debugMobsDontTick() {
|
||||
return game_.GetMobsDontTickEnabled();
|
||||
}
|
||||
|
||||
bool AppGameServices::debugFreezePlayers() { return game_.GetFreezePlayers(); }
|
||||
|
||||
// -- Game host options --
|
||||
|
||||
unsigned int AppGameServices::getGameHostOption(eGameHostOption option) {
|
||||
return game_.GetGameHostOption(option);
|
||||
}
|
||||
|
||||
void AppGameServices::setGameHostOption(eGameHostOption option,
|
||||
unsigned int value) {
|
||||
game_.SetGameHostOption(option, value);
|
||||
}
|
||||
|
||||
// -- Level generation --
|
||||
|
||||
LevelGenerationOptions* AppGameServices::getLevelGenerationOptions() {
|
||||
return game_.getLevelGenerationOptions();
|
||||
}
|
||||
|
||||
LevelRuleset* AppGameServices::getGameRuleDefinitions() {
|
||||
return game_.getGameRuleDefinitions();
|
||||
}
|
||||
|
||||
// -- Texture cache --
|
||||
|
||||
void AppGameServices::addMemoryTextureFile(const std::string& name,
|
||||
std::uint8_t* data,
|
||||
unsigned int size) {
|
||||
game_.AddMemoryTextureFile(name, data, size);
|
||||
}
|
||||
|
||||
void AppGameServices::removeMemoryTextureFile(const std::string& name) {
|
||||
game_.RemoveMemoryTextureFile(name);
|
||||
}
|
||||
|
||||
void AppGameServices::getMemFileDetails(const std::string& name,
|
||||
std::uint8_t** data,
|
||||
unsigned int* size) {
|
||||
game_.GetMemFileDetails(name, data, size);
|
||||
}
|
||||
|
||||
bool AppGameServices::isFileInMemoryTextures(const std::string& name) {
|
||||
return game_.IsFileInMemoryTextures(name);
|
||||
}
|
||||
|
||||
// -- Player settings --
|
||||
|
||||
unsigned char AppGameServices::getGameSettings(int iPad, int setting) {
|
||||
return game_.GetGameSettings(iPad, static_cast<eGameSetting>(setting));
|
||||
}
|
||||
|
||||
unsigned char AppGameServices::getGameSettings(int setting) {
|
||||
return game_.GetGameSettings(static_cast<eGameSetting>(setting));
|
||||
}
|
||||
|
||||
// -- App time --
|
||||
|
||||
float AppGameServices::getAppTime() { return game_.getAppTime(); }
|
||||
|
||||
// -- Game state --
|
||||
|
||||
bool AppGameServices::getGameStarted() { return game_.GetGameStarted(); }
|
||||
void AppGameServices::setGameStarted(bool val) { game_.SetGameStarted(val); }
|
||||
bool AppGameServices::getTutorialMode() { return game_.GetTutorialMode(); }
|
||||
void AppGameServices::setTutorialMode(bool val) { game_.SetTutorialMode(val); }
|
||||
bool AppGameServices::isAppPaused() { return game_.IsAppPaused(); }
|
||||
int AppGameServices::getLocalPlayerCount() {
|
||||
return game_.GetLocalPlayerCount();
|
||||
}
|
||||
bool AppGameServices::autosaveDue() { return game_.AutosaveDue(); }
|
||||
void AppGameServices::setAutosaveTimerTime() { game_.SetAutosaveTimerTime(); }
|
||||
int64_t AppGameServices::secondsToAutosave() {
|
||||
return game_.SecondsToAutosave();
|
||||
}
|
||||
|
||||
void AppGameServices::setDisconnectReason(
|
||||
DisconnectPacket::eDisconnectReason reason) {
|
||||
game_.SetDisconnectReason(reason);
|
||||
}
|
||||
|
||||
void AppGameServices::lockSaveNotification() { game_.lockSaveNotification(); }
|
||||
void AppGameServices::unlockSaveNotification() {
|
||||
game_.unlockSaveNotification();
|
||||
}
|
||||
bool AppGameServices::getResetNether() { return game_.GetResetNether(); }
|
||||
bool AppGameServices::getUseDPadForDebug() {
|
||||
return game_.GetUseDPadForDebug();
|
||||
}
|
||||
|
||||
bool AppGameServices::getWriteSavesToFolderEnabled() {
|
||||
return game_.GetWriteSavesToFolderEnabled();
|
||||
}
|
||||
|
||||
bool AppGameServices::isLocalMultiplayerAvailable() {
|
||||
return game_.IsLocalMultiplayerAvailable();
|
||||
}
|
||||
|
||||
bool AppGameServices::dlcInstallPending() { return game_.DLCInstallPending(); }
|
||||
|
||||
bool AppGameServices::dlcInstallProcessCompleted() {
|
||||
return game_.DLCInstallProcessCompleted();
|
||||
}
|
||||
|
||||
bool AppGameServices::canRecordStatsAndAchievements() {
|
||||
return game_.CanRecordStatsAndAchievements();
|
||||
}
|
||||
|
||||
bool AppGameServices::getTMSGlobalFileListRead() {
|
||||
return game_.GetTMSGlobalFileListRead();
|
||||
}
|
||||
|
||||
void AppGameServices::setRequiredTexturePackID(std::uint32_t id) {
|
||||
game_.SetRequiredTexturePackID(id);
|
||||
}
|
||||
|
||||
void AppGameServices::setSpecialTutorialCompletionFlag(int iPad, int index) {
|
||||
game_.SetSpecialTutorialCompletionFlag(iPad, index);
|
||||
}
|
||||
|
||||
void AppGameServices::setBanListCheck(int iPad, bool val) {
|
||||
game_.SetBanListCheck(iPad, val);
|
||||
}
|
||||
|
||||
bool AppGameServices::getBanListCheck(int iPad) {
|
||||
return game_.GetBanListCheck(iPad);
|
||||
}
|
||||
|
||||
unsigned int AppGameServices::getGameNewWorldSize() {
|
||||
return game_.GetGameNewWorldSize();
|
||||
}
|
||||
|
||||
unsigned int AppGameServices::getGameNewWorldSizeUseMoat() {
|
||||
return game_.GetGameNewWorldSizeUseMoat();
|
||||
}
|
||||
|
||||
unsigned int AppGameServices::getGameNewHellScale() {
|
||||
return game_.GetGameNewHellScale();
|
||||
}
|
||||
|
||||
// -- UI dispatch --
|
||||
|
||||
void AppGameServices::setAction(int iPad, eXuiAction action, void* param) {
|
||||
game_.SetAction(iPad, action, param);
|
||||
}
|
||||
|
||||
eXuiAction AppGameServices::getXuiAction(int iPad) {
|
||||
return game_.GetXuiAction(iPad);
|
||||
}
|
||||
|
||||
void AppGameServices::setGlobalXuiAction(eXuiAction action) {
|
||||
game_.SetGlobalXuiAction(action);
|
||||
}
|
||||
|
||||
void AppGameServices::handleButtonPresses() { game_.HandleButtonPresses(); }
|
||||
|
||||
void AppGameServices::setTMSAction(int iPad, eTMSAction action) {
|
||||
game_.SetTMSAction(iPad, action);
|
||||
}
|
||||
|
||||
// -- Skin / cape / animation --
|
||||
|
||||
std::string AppGameServices::getPlayerSkinName(int iPad) {
|
||||
return game_.GetPlayerSkinName(iPad);
|
||||
}
|
||||
|
||||
std::uint32_t AppGameServices::getPlayerSkinId(int iPad) {
|
||||
return game_.GetPlayerSkinId(iPad);
|
||||
}
|
||||
|
||||
std::string AppGameServices::getPlayerCapeName(int iPad) {
|
||||
return game_.GetPlayerCapeName(iPad);
|
||||
}
|
||||
|
||||
std::uint32_t AppGameServices::getPlayerCapeId(int iPad) {
|
||||
return game_.GetPlayerCapeId(iPad);
|
||||
}
|
||||
|
||||
std::uint32_t AppGameServices::getAdditionalModelPartsForPad(int iPad) {
|
||||
return game_.GetAdditionalModelParts(iPad);
|
||||
}
|
||||
|
||||
void AppGameServices::setAdditionalSkinBoxes(std::uint32_t dwSkinID,
|
||||
SKIN_BOX* boxA,
|
||||
unsigned int boxC) {
|
||||
game_.SetAdditionalSkinBoxes(dwSkinID, boxA, boxC);
|
||||
}
|
||||
|
||||
std::vector<SKIN_BOX*>* AppGameServices::getAdditionalSkinBoxes(
|
||||
std::uint32_t dwSkinID) {
|
||||
return game_.GetAdditionalSkinBoxes(dwSkinID);
|
||||
}
|
||||
|
||||
std::vector<ModelPart*>* AppGameServices::getAdditionalModelParts(
|
||||
std::uint32_t dwSkinID) {
|
||||
return game_.GetAdditionalModelParts(dwSkinID);
|
||||
}
|
||||
|
||||
std::vector<ModelPart*>* AppGameServices::setAdditionalSkinBoxesFromVec(
|
||||
std::uint32_t dwSkinID, std::vector<SKIN_BOX*>* pvSkinBoxA) {
|
||||
return game_.SetAdditionalSkinBoxes(dwSkinID, pvSkinBoxA);
|
||||
}
|
||||
|
||||
void AppGameServices::setAnimOverrideBitmask(std::uint32_t dwSkinID,
|
||||
unsigned int bitmask) {
|
||||
game_.SetAnimOverrideBitmask(dwSkinID, bitmask);
|
||||
}
|
||||
|
||||
unsigned int AppGameServices::getAnimOverrideBitmask(std::uint32_t dwSkinID) {
|
||||
return game_.GetAnimOverrideBitmask(dwSkinID);
|
||||
}
|
||||
|
||||
std::uint32_t AppGameServices::getSkinIdFromPath(const std::string& skin) {
|
||||
return Game::getSkinIdFromPath(skin);
|
||||
}
|
||||
|
||||
std::string AppGameServices::getSkinPathFromId(std::uint32_t skinId) {
|
||||
return Game::getSkinPathFromId(skinId);
|
||||
}
|
||||
|
||||
bool AppGameServices::defaultCapeExists() { return game_.DefaultCapeExists(); }
|
||||
|
||||
bool AppGameServices::isXuidNotch(PlayerUID xuid) {
|
||||
return game_.isXuidNotch(xuid);
|
||||
}
|
||||
|
||||
bool AppGameServices::isXuidDeadmau5(PlayerUID xuid) {
|
||||
return game_.isXuidDeadmau5(xuid);
|
||||
}
|
||||
|
||||
// -- Platform features --
|
||||
|
||||
void AppGameServices::fatalLoadError() { game_.FatalLoadError(); }
|
||||
|
||||
void AppGameServices::setRichPresenceContext(int iPad, int contextId) {
|
||||
PlatformGame.SetRichPresenceContext(iPad, contextId);
|
||||
}
|
||||
|
||||
void AppGameServices::captureSaveThumbnail() {
|
||||
PlatformGame.CaptureSaveThumbnail();
|
||||
}
|
||||
|
||||
void AppGameServices::getSaveThumbnail(std::uint8_t** data,
|
||||
unsigned int* size) {
|
||||
PlatformGame.GetSaveThumbnail(data, size);
|
||||
}
|
||||
|
||||
void AppGameServices::readBannedList(int iPad, eTMSAction action,
|
||||
bool bCallback) {
|
||||
PlatformGame.ReadBannedList(iPad, action, bCallback);
|
||||
}
|
||||
|
||||
void AppGameServices::updatePlayerInfo(std::uint8_t networkSmallId,
|
||||
int16_t playerColourIndex,
|
||||
unsigned int playerPrivileges) {
|
||||
game_.UpdatePlayerInfo(networkSmallId, playerColourIndex, playerPrivileges);
|
||||
}
|
||||
|
||||
unsigned int AppGameServices::getPlayerPrivileges(std::uint8_t networkSmallId) {
|
||||
return game_.GetPlayerPrivileges(networkSmallId);
|
||||
}
|
||||
|
||||
void AppGameServices::setGameSettingsDebugMask(int iPad, unsigned int uiVal) {
|
||||
game_.SetGameSettingsDebugMask(iPad, uiVal);
|
||||
}
|
||||
|
||||
// -- Schematics / terrain --
|
||||
|
||||
void AppGameServices::processSchematics(LevelChunk* chunk) {
|
||||
game_.processSchematics(chunk);
|
||||
}
|
||||
|
||||
void AppGameServices::processSchematicsLighting(LevelChunk* chunk) {
|
||||
game_.processSchematicsLighting(chunk);
|
||||
}
|
||||
|
||||
void AppGameServices::addTerrainFeaturePosition(_eTerrainFeatureType type,
|
||||
int x, int z) {
|
||||
game_.AddTerrainFeaturePosition(type, x, z);
|
||||
}
|
||||
|
||||
bool AppGameServices::getTerrainFeaturePosition(_eTerrainFeatureType type,
|
||||
int* pX, int* pZ) {
|
||||
return game_.GetTerrainFeaturePosition(type, pX, pZ);
|
||||
}
|
||||
|
||||
void AppGameServices::loadDefaultGameRules() { game_.loadDefaultGameRules(); }
|
||||
|
||||
// -- Archive / resources --
|
||||
|
||||
bool AppGameServices::hasArchiveFile(const std::string& filename) {
|
||||
return game_.hasArchiveFile(filename);
|
||||
}
|
||||
|
||||
std::vector<std::uint8_t> AppGameServices::getArchiveFile(
|
||||
const std::string& filename) {
|
||||
return game_.getArchiveFile(filename);
|
||||
}
|
||||
|
||||
// -- Strings / formatting / misc queries --
|
||||
|
||||
int AppGameServices::getHTMLColour(eMinecraftColour colour) {
|
||||
return game_.GetHTMLColour(colour);
|
||||
}
|
||||
|
||||
std::string AppGameServices::getEntityName(EntityTypeId type) {
|
||||
return game_.getEntityName(static_cast<eINSTANCEOF>(type));
|
||||
}
|
||||
|
||||
const char* AppGameServices::getGameRulesString(const std::string& key) {
|
||||
return game_.GetGameRulesString(key);
|
||||
}
|
||||
|
||||
unsigned int AppGameServices::createImageTextData(
|
||||
std::uint8_t* textMetadata, int64_t seed, bool hasSeed,
|
||||
unsigned int uiHostOptions, unsigned int uiTexturePackId) {
|
||||
return game_.CreateImageTextData(textMetadata, seed, hasSeed, uiHostOptions,
|
||||
uiTexturePackId);
|
||||
}
|
||||
|
||||
std::string AppGameServices::getFilePath(std::uint32_t packId,
|
||||
std::string filename,
|
||||
bool bAddDataFolder,
|
||||
std::string mountPoint) {
|
||||
return game_.getFilePath(packId, filename, bAddDataFolder, mountPoint);
|
||||
}
|
||||
|
||||
char* AppGameServices::getUniqueMapName() { return game_.GetUniqueMapName(); }
|
||||
|
||||
void AppGameServices::setUniqueMapName(char* name) {
|
||||
game_.SetUniqueMapName(name);
|
||||
}
|
||||
|
||||
unsigned int AppGameServices::getOpacityTimer(int iPad) {
|
||||
return game_.GetOpacityTimer(iPad);
|
||||
}
|
||||
|
||||
void AppGameServices::setOpacityTimer(int iPad) { game_.SetOpacityTimer(iPad); }
|
||||
|
||||
void AppGameServices::tickOpacityTimer(int iPad) {
|
||||
game_.TickOpacityTimer(iPad);
|
||||
}
|
||||
|
||||
bool AppGameServices::isInBannedLevelList(int iPad, PlayerUID xuid,
|
||||
char* levelName) {
|
||||
return game_.IsInBannedLevelList(iPad, xuid, levelName);
|
||||
}
|
||||
|
||||
MOJANG_DATA* AppGameServices::getMojangDataForXuid(PlayerUID xuid) {
|
||||
return game_.GetMojangDataForXuid(xuid);
|
||||
}
|
||||
|
||||
void AppGameServices::debugPrintf(const char* msg) {
|
||||
game_.DebugPrintf("%s", msg);
|
||||
}
|
||||
|
||||
// -- DLC --
|
||||
|
||||
ISkinAssetData* AppGameServices::getSkinAssetData(const std::string& name) {
|
||||
return game_.m_dlcManager.getSkinFile(name);
|
||||
}
|
||||
bool AppGameServices::dlcNeedsCorruptCheck() {
|
||||
return game_.m_dlcManager.NeedsCorruptCheck();
|
||||
}
|
||||
unsigned int AppGameServices::dlcCheckForCorrupt(bool showMessage) {
|
||||
return game_.m_dlcManager.checkForCorruptDLCAndAlert(showMessage);
|
||||
}
|
||||
bool AppGameServices::dlcReadDataFile(unsigned int& filesProcessed,
|
||||
const std::string& path, DLCPack* pack,
|
||||
bool fromArchive) {
|
||||
return game_.m_dlcManager.readDLCDataFile(filesProcessed, path, pack,
|
||||
fromArchive);
|
||||
}
|
||||
void AppGameServices::dlcRemovePack(DLCPack* pack) {
|
||||
game_.m_dlcManager.removePack(pack);
|
||||
}
|
||||
|
||||
// -- Game rules --
|
||||
|
||||
LevelGenerationOptions* AppGameServices::loadGameRules(std::uint8_t* data,
|
||||
unsigned int size) {
|
||||
return game_.m_gameRules.loadGameRules(data, size);
|
||||
}
|
||||
void AppGameServices::saveGameRules(std::uint8_t** data, unsigned int* size) {
|
||||
game_.m_gameRules.saveGameRules(data, size);
|
||||
}
|
||||
void AppGameServices::unloadCurrentGameRules() {
|
||||
game_.m_gameRules.unloadCurrentGameRules();
|
||||
}
|
||||
void AppGameServices::setLevelGenerationOptions(
|
||||
LevelGenerationOptions* levelGen) {
|
||||
game_.m_gameRules.setLevelGenerationOptions(levelGen);
|
||||
}
|
||||
|
||||
// -- Shared data --
|
||||
|
||||
std::vector<std::string>& AppGameServices::getSkinNames() {
|
||||
return game_.vSkinNames;
|
||||
}
|
||||
|
||||
std::vector<FEATURE_DATA*>& AppGameServices::getTerrainFeatures() {
|
||||
return *game_.m_terrainFeatureManager.features();
|
||||
}
|
||||
|
||||
// -- Menu service --
|
||||
|
||||
IMenuService& AppGameServices::menus() { return menus_; }
|
||||
@@ -0,0 +1,178 @@
|
||||
#pragma once
|
||||
|
||||
#include "minecraft/IGameServices.h"
|
||||
|
||||
class Game;
|
||||
class IMenuService;
|
||||
class ISkinAssetData;
|
||||
|
||||
class AppGameServices : public IGameServices {
|
||||
public:
|
||||
AppGameServices(Game& game, IMenuService& menus);
|
||||
|
||||
// -- Strings --
|
||||
const char* getString(int id) override;
|
||||
|
||||
// -- Debug settings --
|
||||
bool debugSettingsOn() override;
|
||||
bool debugArtToolsOn() override;
|
||||
unsigned int debugGetMask(int iPad, bool overridePlayer) override;
|
||||
bool debugMobsDontAttack() override;
|
||||
bool debugMobsDontTick() override;
|
||||
bool debugFreezePlayers() override;
|
||||
|
||||
// -- Game host options --
|
||||
unsigned int getGameHostOption(eGameHostOption option) override;
|
||||
void setGameHostOption(eGameHostOption option, unsigned int value) override;
|
||||
|
||||
// -- Level generation --
|
||||
LevelGenerationOptions* getLevelGenerationOptions() override;
|
||||
LevelRuleset* getGameRuleDefinitions() override;
|
||||
|
||||
// -- Texture cache --
|
||||
void addMemoryTextureFile(const std::string& name, std::uint8_t* data,
|
||||
unsigned int size) override;
|
||||
void removeMemoryTextureFile(const std::string& name) override;
|
||||
void getMemFileDetails(const std::string& name, std::uint8_t** data,
|
||||
unsigned int* size) override;
|
||||
bool isFileInMemoryTextures(const std::string& name) override;
|
||||
|
||||
// -- Player settings --
|
||||
unsigned char getGameSettings(int iPad, int setting) override;
|
||||
unsigned char getGameSettings(int setting) override;
|
||||
|
||||
// -- App time --
|
||||
float getAppTime() override;
|
||||
|
||||
// -- Game state --
|
||||
bool getGameStarted() override;
|
||||
void setGameStarted(bool val) override;
|
||||
bool getTutorialMode() override;
|
||||
void setTutorialMode(bool val) override;
|
||||
bool isAppPaused() override;
|
||||
int getLocalPlayerCount() override;
|
||||
bool autosaveDue() override;
|
||||
void setAutosaveTimerTime() override;
|
||||
int64_t secondsToAutosave() override;
|
||||
void setDisconnectReason(
|
||||
DisconnectPacket::eDisconnectReason reason) override;
|
||||
void lockSaveNotification() override;
|
||||
void unlockSaveNotification() override;
|
||||
bool getResetNether() override;
|
||||
bool getUseDPadForDebug() override;
|
||||
bool getWriteSavesToFolderEnabled() override;
|
||||
bool isLocalMultiplayerAvailable() override;
|
||||
bool dlcInstallPending() override;
|
||||
bool dlcInstallProcessCompleted() override;
|
||||
bool canRecordStatsAndAchievements() override;
|
||||
bool getTMSGlobalFileListRead() override;
|
||||
void setRequiredTexturePackID(std::uint32_t id) override;
|
||||
void setSpecialTutorialCompletionFlag(int iPad, int index) override;
|
||||
void setBanListCheck(int iPad, bool val) override;
|
||||
bool getBanListCheck(int iPad) override;
|
||||
unsigned int getGameNewWorldSize() override;
|
||||
unsigned int getGameNewWorldSizeUseMoat() override;
|
||||
unsigned int getGameNewHellScale() override;
|
||||
|
||||
// -- UI dispatch --
|
||||
void setAction(int iPad, eXuiAction action, void* param) override;
|
||||
eXuiAction getXuiAction(int iPad) override;
|
||||
void setGlobalXuiAction(eXuiAction action) override;
|
||||
void handleButtonPresses() override;
|
||||
void setTMSAction(int iPad, eTMSAction action) override;
|
||||
|
||||
// -- Skin / cape / animation --
|
||||
std::string getPlayerSkinName(int iPad) override;
|
||||
std::uint32_t getPlayerSkinId(int iPad) override;
|
||||
std::string getPlayerCapeName(int iPad) override;
|
||||
std::uint32_t getPlayerCapeId(int iPad) override;
|
||||
std::uint32_t getAdditionalModelPartsForPad(int iPad) override;
|
||||
void setAdditionalSkinBoxes(std::uint32_t dwSkinID, SKIN_BOX* boxA,
|
||||
unsigned int boxC) override;
|
||||
std::vector<SKIN_BOX*>* getAdditionalSkinBoxes(
|
||||
std::uint32_t dwSkinID) override;
|
||||
std::vector<ModelPart*>* getAdditionalModelParts(
|
||||
std::uint32_t dwSkinID) override;
|
||||
std::vector<ModelPart*>* setAdditionalSkinBoxesFromVec(
|
||||
std::uint32_t dwSkinID, std::vector<SKIN_BOX*>* pvSkinBoxA) override;
|
||||
void setAnimOverrideBitmask(std::uint32_t dwSkinID,
|
||||
unsigned int bitmask) override;
|
||||
unsigned int getAnimOverrideBitmask(std::uint32_t dwSkinID) override;
|
||||
std::uint32_t getSkinIdFromPath(const std::string& skin) override;
|
||||
std::string getSkinPathFromId(std::uint32_t skinId) override;
|
||||
bool defaultCapeExists() override;
|
||||
bool isXuidNotch(PlayerUID xuid) override;
|
||||
bool isXuidDeadmau5(PlayerUID xuid) override;
|
||||
|
||||
// -- Platform features --
|
||||
void fatalLoadError() override;
|
||||
void setRichPresenceContext(int iPad, int contextId) override;
|
||||
void captureSaveThumbnail() override;
|
||||
void getSaveThumbnail(std::uint8_t** data, unsigned int* size) override;
|
||||
void readBannedList(int iPad, eTMSAction action, bool bCallback) override;
|
||||
void updatePlayerInfo(std::uint8_t networkSmallId,
|
||||
int16_t playerColourIndex,
|
||||
unsigned int playerPrivileges) override;
|
||||
unsigned int getPlayerPrivileges(std::uint8_t networkSmallId) override;
|
||||
void setGameSettingsDebugMask(int iPad, unsigned int uiVal) override;
|
||||
|
||||
// -- Schematics / terrain --
|
||||
void processSchematics(LevelChunk* chunk) override;
|
||||
void processSchematicsLighting(LevelChunk* chunk) override;
|
||||
void addTerrainFeaturePosition(_eTerrainFeatureType type, int x,
|
||||
int z) override;
|
||||
bool getTerrainFeaturePosition(_eTerrainFeatureType type, int* pX,
|
||||
int* pZ) override;
|
||||
void loadDefaultGameRules() override;
|
||||
|
||||
// -- Archive / resources --
|
||||
bool hasArchiveFile(const std::string& filename) override;
|
||||
std::vector<std::uint8_t> getArchiveFile(
|
||||
const std::string& filename) override;
|
||||
|
||||
// -- Strings / formatting / misc queries --
|
||||
int getHTMLColour(eMinecraftColour colour) override;
|
||||
std::string getEntityName(EntityTypeId type) override;
|
||||
const char* getGameRulesString(const std::string& key) override;
|
||||
unsigned int createImageTextData(std::uint8_t* textMetadata, int64_t seed,
|
||||
bool hasSeed, unsigned int uiHostOptions,
|
||||
unsigned int uiTexturePackId) override;
|
||||
std::string getFilePath(std::uint32_t packId, std::string filename,
|
||||
bool bAddDataFolder,
|
||||
std::string mountPoint) override;
|
||||
char* getUniqueMapName() override;
|
||||
void setUniqueMapName(char* name) override;
|
||||
unsigned int getOpacityTimer(int iPad) override;
|
||||
void setOpacityTimer(int iPad) override;
|
||||
void tickOpacityTimer(int iPad) override;
|
||||
bool isInBannedLevelList(int iPad, PlayerUID xuid,
|
||||
char* levelName) override;
|
||||
MOJANG_DATA* getMojangDataForXuid(PlayerUID xuid) override;
|
||||
void debugPrintf(const char* msg) override;
|
||||
|
||||
// -- DLC --
|
||||
ISkinAssetData* getSkinAssetData(const std::string& name) override;
|
||||
bool dlcNeedsCorruptCheck() override;
|
||||
unsigned int dlcCheckForCorrupt(bool showMessage) override;
|
||||
bool dlcReadDataFile(unsigned int& filesProcessed, const std::string& path,
|
||||
DLCPack* pack, bool fromArchive) override;
|
||||
void dlcRemovePack(DLCPack* pack) override;
|
||||
|
||||
// -- Game rules --
|
||||
LevelGenerationOptions* loadGameRules(std::uint8_t* data,
|
||||
unsigned int size) override;
|
||||
void saveGameRules(std::uint8_t** data, unsigned int* size) override;
|
||||
void unloadCurrentGameRules() override;
|
||||
void setLevelGenerationOptions(LevelGenerationOptions* levelGen) override;
|
||||
|
||||
// -- Shared data --
|
||||
std::vector<std::string>& getSkinNames() override;
|
||||
std::vector<FEATURE_DATA*>& getTerrainFeatures() override;
|
||||
|
||||
// -- Menu service --
|
||||
IMenuService& menus() override;
|
||||
|
||||
private:
|
||||
Game& game_;
|
||||
IMenuService& menus_;
|
||||
};
|
||||
@@ -1,135 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// 4J Stu - For non-splitscreen menus, default to this screen
|
||||
#define DEFAULT_XUI_MENU_USER 0
|
||||
#define MULTITHREAD_ENABLE
|
||||
#define MAX_CAPENAME_SIZE 32
|
||||
#define MAX_BANNERNAME_SIZE 32
|
||||
#define MAX_TMSFILENAME_SIZE 40
|
||||
#define MAX_TYPE_SIZE 32
|
||||
#define MAX_EXTENSION_TYPES 3
|
||||
|
||||
#define MAX_LOCAL_PLAYERS 4
|
||||
|
||||
// 4J Stu - Required for sentient reporting of whether the volume level has been
|
||||
// changed or not
|
||||
#define DEFAULT_VOLUME_LEVEL 100
|
||||
|
||||
#define GAME_HOST_OPTION_BITMASK_DIFFICULTY 0x00000003 // 0 - 3
|
||||
#define GAME_HOST_OPTION_BITMASK_FRIENDSOFFRIENDS 0x00000004
|
||||
#define GAME_HOST_OPTION_BITMASK_GAMERTAGS 0x00000008
|
||||
#define GAME_HOST_OPTION_BITMASK_GAMETYPE 0x00000030
|
||||
#define GAME_HOST_OPTION_BITMASK_LEVELTYPE 0x00000040
|
||||
#define GAME_HOST_OPTION_BITMASK_STRUCTURES 0x00000080
|
||||
#define GAME_HOST_OPTION_BITMASK_BONUSCHEST 0x00000100
|
||||
#define GAME_HOST_OPTION_BITMASK_BEENINCREATIVE 0x00000200
|
||||
#define GAME_HOST_OPTION_BITMASK_PVP 0x00000400
|
||||
#define GAME_HOST_OPTION_BITMASK_TRUSTPLAYERS 0x00000800
|
||||
#define GAME_HOST_OPTION_BITMASK_TNT 0x00001000
|
||||
#define GAME_HOST_OPTION_BITMASK_FIRESPREADS 0x00002000
|
||||
#define GAME_HOST_OPTION_BITMASK_HOSTFLY 0x00004000
|
||||
#define GAME_HOST_OPTION_BITMASK_HOSTHUNGER 0x00008000
|
||||
#define GAME_HOST_OPTION_BITMASK_HOSTINVISIBLE 0x00010000
|
||||
#define GAME_HOST_OPTION_BITMASK_BEDROCKFOG 0x00020000
|
||||
#define GAME_HOST_OPTION_BITMASK_DISABLESAVE 0x00040000
|
||||
#define GAME_HOST_OPTION_BITMASK_NOTOWNER 0x00080000
|
||||
#define GAME_HOST_OPTION_BITMASK_WORLDSIZE \
|
||||
0x00700000 // 3 bits, 5 values (unset(0), classic(1), small(2), medium(3),
|
||||
// large(4))
|
||||
#define GAME_HOST_OPTION_BITMASK_MOBGRIEFING 0x00800000
|
||||
#define GAME_HOST_OPTION_BITMASK_KEEPINVENTORY 0x01000000
|
||||
#define GAME_HOST_OPTION_BITMASK_DOMOBSPAWNING 0x02000000
|
||||
#define GAME_HOST_OPTION_BITMASK_DOMOBLOOT 0x04000000
|
||||
#define GAME_HOST_OPTION_BITMASK_DOTILEDROPS 0x08000000
|
||||
#define GAME_HOST_OPTION_BITMASK_NATURALREGEN 0x10000000
|
||||
#define GAME_HOST_OPTION_BITMASK_DODAYLIGHTCYCLE 0x20000000
|
||||
#define GAME_HOST_OPTION_BITMASK_ALL 0xFFFFFFFF
|
||||
|
||||
#define GAME_HOST_OPTION_BITMASK_WORLDSIZE_BITSHIFT 20
|
||||
|
||||
enum EGameHostOptionWorldSize {
|
||||
e_worldSize_Unknown = 0,
|
||||
e_worldSize_Classic,
|
||||
e_worldSize_Small,
|
||||
e_worldSize_Medium,
|
||||
e_worldSize_Large
|
||||
};
|
||||
|
||||
#define PROFILE_VERSION_8 10
|
||||
#define PROFILE_VERSION_9 11
|
||||
|
||||
#define PROFILE_VERSION_10 12
|
||||
|
||||
// 4J-JEV: New Statistics and Achievements for 'NexGen' platforms.
|
||||
#define PROFILE_VERSION_11 13
|
||||
|
||||
// Java 1.6.4
|
||||
#define PROFILE_VERSION_12 14
|
||||
|
||||
#define PROFILE_VERSION_CURRENT PROFILE_VERSION_12
|
||||
|
||||
#define MAX_FAVORITE_SKINS \
|
||||
10 // these are stored in the profile data so keep it small
|
||||
|
||||
// defines for game settings - uiBitmaskValues
|
||||
|
||||
#define GAMESETTING_CLOUDS 0x00000001
|
||||
#define GAMESETTING_ONLINE 0x00000002
|
||||
#define GAMESETTING_INVITEONLY 0x00000004
|
||||
#define GAMESETTING_FRIENDSOFFRIENDS 0x00000008
|
||||
#define GAMESETTING_DISPLAYUPDATEMSG 0x00000030
|
||||
#define GAMESETTING_BEDROCKFOG 0x00000040
|
||||
#define GAMESETTING_DISPLAYHUD 0x00000080
|
||||
#define GAMESETTING_DISPLAYHAND 0x00000100
|
||||
#define GAMESETTING_CUSTOMSKINANIM 0x00000200
|
||||
#define GAMESETTING_DEATHMESSAGES 0x00000400
|
||||
#define GAMESETTING_UISIZE 0x00001800
|
||||
#define GAMESETTING_UISIZE_SPLITSCREEN 0x00006000
|
||||
#define GAMESETTING_ANIMATEDCHARACTER 0x00008000
|
||||
#define GAMESETTING_PS3EULAREAD 0x00010000
|
||||
#define GAMESETTING_PSVITANETWORKMODEADHOC 0x00020000
|
||||
|
||||
// defines for languages
|
||||
|
||||
#define MINECRAFT_LANGUAGE_DEFAULT 0x00
|
||||
#define MINECRAFT_LANGUAGE_ENGLISH 0x01
|
||||
#define MINECRAFT_LANGUAGE_JAPANESE 0x02
|
||||
#define MINECRAFT_LANGUAGE_GERMAN 0x03
|
||||
#define MINECRAFT_LANGUAGE_FRENCH 0x04
|
||||
#define MINECRAFT_LANGUAGE_SPANISH 0x05
|
||||
#define MINECRAFT_LANGUAGE_ITALIAN 0x06
|
||||
#define MINECRAFT_LANGUAGE_KOREAN 0x07
|
||||
#define MINECRAFT_LANGUAGE_TCHINESE 0x08
|
||||
#define MINECRAFT_LANGUAGE_PORTUGUESE 0x09
|
||||
#define MINECRAFT_LANGUAGE_BRAZILIAN 0x0A
|
||||
#define MINECRAFT_LANGUAGE_RUSSIAN 0x0B
|
||||
#define MINECRAFT_LANGUAGE_DUTCH 0x0C
|
||||
#define MINECRAFT_LANGUAGE_FINISH 0x0D
|
||||
#define MINECRAFT_LANGUAGE_SWEDISH 0x0E
|
||||
#define MINECRAFT_LANGUAGE_DANISH 0x0F
|
||||
#define MINECRAFT_LANGUAGE_NORWEGIAN 0x10
|
||||
#define MINECRAFT_LANGUAGE_POLISH 0x11
|
||||
#define MINECRAFT_LANGUAGE_TURKISH 0x12
|
||||
#define MINECRAFT_LANGUAGE_LATINAMERICANSPANISH 0x13
|
||||
#define MINECRAFT_LANGUAGE_GREEK 0x14
|
||||
|
||||
/* Match these
|
||||
|
||||
const int XC_LANGUAGE_ENGLISH =1; const int XC_LANGUAGE_JAPANESE
|
||||
=2; const int XC_LANGUAGE_GERMAN
|
||||
=3; const int XC_LANGUAGE_FRENCH
|
||||
=4; const int XC_LANGUAGE_SPANISH
|
||||
=5; const int XC_LANGUAGE_ITALIAN
|
||||
=6; const int XC_LANGUAGE_KOREAN
|
||||
=7; const int XC_LANGUAGE_TCHINESE
|
||||
=8; const int XC_LANGUAGE_PORTUGUESE =9; const int XC_LANGUAGE_BRAZILIAN
|
||||
=10; const int XC_LANGUAGE_RUSSIAN
|
||||
=11; const int XC_LANGUAGE_DUTCH
|
||||
=12; const int XC_LANGUAGE_FINISH
|
||||
=13; const int XC_LANGUAGE_SWEDISH
|
||||
=14; const int XC_LANGUAGE_DANISH
|
||||
=15; const int XC_LANGUAGE_NORWEGIAN =16; const int XC_LANGUAGE_POLISH
|
||||
=17; const int XC_LANGUAGE_TURKISH
|
||||
=18; const int XC_LANGUAGE_LATINAMERICANSPANISH =19;
|
||||
const int XC_LANGUAGE_GREEK =20;
|
||||
*/
|
||||
@@ -2,17 +2,18 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "platform/sdl2/Storage.h"
|
||||
#include "app/common/App_Defines.h"
|
||||
#include "app/common/App_enums.h"
|
||||
#include "app/common/src/Tutorial/TutorialEnum.h"
|
||||
#include "app/common/src/UI/All Platforms/UIEnums.h"
|
||||
#include "app/include/NetTypes.h"
|
||||
#include "app/include/SkinBox.h"
|
||||
#include "app/include/XboxStubs.h"
|
||||
#include "app/common/UI/All Platforms/UIEnums.h"
|
||||
#include "minecraft/GameEnums.h"
|
||||
#include "minecraft/GameTypes.h"
|
||||
#include "minecraft/client/model/SkinBox.h"
|
||||
#include "minecraft/world/tutorial/TutorialEnum.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
#include "platform/network/NetTypes.h"
|
||||
#include "platform/profile/ProfileConstants.h"
|
||||
#include "platform/storage/storage.h"
|
||||
|
||||
typedef struct {
|
||||
wchar_t* wchFilename;
|
||||
char* wchFilename;
|
||||
eFileExtensionType eEXT;
|
||||
eTMSFileType eTMSType;
|
||||
std::uint8_t* pbData;
|
||||
@@ -144,29 +145,18 @@ typedef struct {
|
||||
int uiStringID;
|
||||
} TIPSTRUCT;
|
||||
|
||||
typedef struct {
|
||||
eXUID eXuid;
|
||||
wchar_t wchCape[MAX_CAPENAME_SIZE];
|
||||
wchar_t wchSkin[MAX_CAPENAME_SIZE];
|
||||
} MOJANG_DATA;
|
||||
|
||||
typedef struct {
|
||||
eDLCContentType eDLCType;
|
||||
|
||||
uint64_t ullOfferID_Full;
|
||||
uint64_t ullOfferID_Trial;
|
||||
wchar_t wchBanner[MAX_BANNERNAME_SIZE];
|
||||
wchar_t wchDataFile[MAX_BANNERNAME_SIZE];
|
||||
char wchBanner[MAX_BANNERNAME_SIZE];
|
||||
char wchDataFile[MAX_BANNERNAME_SIZE];
|
||||
int iGender;
|
||||
int iConfig;
|
||||
unsigned int uiSortIndex;
|
||||
} DLC_INFO;
|
||||
|
||||
typedef struct {
|
||||
int x, z;
|
||||
_eTerrainFeatureType eTerrainFeature;
|
||||
} FEATURE_DATA;
|
||||
|
||||
// banned list
|
||||
typedef struct {
|
||||
std::uint8_t* pBannedList;
|
||||
@@ -181,12 +171,12 @@ typedef struct _DLCRequest {
|
||||
typedef struct _TMSPPRequest {
|
||||
eTMSContentState eState;
|
||||
eDLCContentType eType;
|
||||
C4JStorage::eGlobalStorage eStorageFacility;
|
||||
C4JStorage::eTMS_FILETYPEVAL eFileTypeVal;
|
||||
IPlatformStorage::eGlobalStorage eStorageFacility;
|
||||
IPlatformStorage::eTMS_FILETYPEVAL eFileTypeVal;
|
||||
// char szFilename[MAX_TMSFILENAME_SIZE];
|
||||
int (*CallbackFunc)(void*, int, int, C4JStorage::PTMSPP_FILEDATA,
|
||||
int (*CallbackFunc)(void*, int, int, IPlatformStorage::PTMSPP_FILEDATA,
|
||||
const char* szFilename);
|
||||
wchar_t wchFilename[MAX_TMSFILENAME_SIZE];
|
||||
char wchFilename[MAX_TMSFILENAME_SIZE];
|
||||
|
||||
void* lpCallbackParam;
|
||||
} TMSPPRequest;
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
#include "app/common/ArchiveManager.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/UI/All Platforms/ArchiveFile.h"
|
||||
#include "java/File.h"
|
||||
#include "minecraft/client/Minecraft.h"
|
||||
#include "minecraft/client/skins/TexturePack.h"
|
||||
#include "minecraft/client/skins/TexturePackRepository.h"
|
||||
#include "platform/PlatformTypes.h"
|
||||
#include "platform/fs/fs.h"
|
||||
|
||||
ArchiveManager::ArchiveManager()
|
||||
: m_mediaArchive(nullptr), m_dwRequiredTexturePackID(0) {}
|
||||
|
||||
void ArchiveManager::loadMediaArchive() {
|
||||
std::string mediapath = "";
|
||||
|
||||
mediapath = "Common\\Media\\MediaWindows64.arc";
|
||||
|
||||
if (!mediapath.empty()) {
|
||||
std::string exeDirW = PlatformFilesystem.getBasePath().string();
|
||||
std::string candidate = exeDirW + File::pathSeparator + mediapath;
|
||||
if (File(candidate).exists()) {
|
||||
m_mediaArchive = new ArchiveFile(File(candidate));
|
||||
} else {
|
||||
m_mediaArchive = new ArchiveFile(File(mediapath));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ArchiveManager::getArchiveFileSize(const std::string& filename) {
|
||||
TexturePack* tPack = nullptr;
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
if (pMinecraft && pMinecraft->skins)
|
||||
tPack = pMinecraft->skins->getSelected();
|
||||
if (tPack && tPack->hasData() && tPack->getArchiveFile() &&
|
||||
tPack->getArchiveFile()->hasFile(filename)) {
|
||||
return tPack->getArchiveFile()->getFileSize(filename);
|
||||
} else
|
||||
return m_mediaArchive->getFileSize(filename);
|
||||
}
|
||||
|
||||
bool ArchiveManager::hasArchiveFile(const std::string& filename) {
|
||||
TexturePack* tPack = nullptr;
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
if (pMinecraft && pMinecraft->skins)
|
||||
tPack = pMinecraft->skins->getSelected();
|
||||
if (tPack && tPack->hasData() && tPack->getArchiveFile() &&
|
||||
tPack->getArchiveFile()->hasFile(filename))
|
||||
return true;
|
||||
else
|
||||
return m_mediaArchive->hasFile(filename);
|
||||
}
|
||||
|
||||
std::vector<uint8_t> ArchiveManager::getArchiveFile(
|
||||
const std::string& filename) {
|
||||
TexturePack* tPack = nullptr;
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
if (pMinecraft && pMinecraft->skins)
|
||||
tPack = pMinecraft->skins->getSelected();
|
||||
if (tPack && tPack->hasData() && tPack->getArchiveFile() &&
|
||||
tPack->getArchiveFile()->hasFile(filename)) {
|
||||
return tPack->getArchiveFile()->getFile(filename);
|
||||
} else
|
||||
return m_mediaArchive->getFile(filename);
|
||||
}
|
||||
|
||||
void ArchiveManager::addMemoryTPDFile(int iConfig, std::uint8_t* pbData,
|
||||
unsigned int byteCount) {
|
||||
std::lock_guard<std::mutex> lock(csMemTPDLock);
|
||||
PMEMDATA pData = nullptr;
|
||||
auto it = m_MEM_TPD.find(iConfig);
|
||||
if (it == m_MEM_TPD.end()) {
|
||||
pData = new MEMDATA();
|
||||
pData->pbData = pbData;
|
||||
pData->byteCount = byteCount;
|
||||
pData->ucRefCount = 1;
|
||||
|
||||
m_MEM_TPD[iConfig] = pData;
|
||||
}
|
||||
}
|
||||
|
||||
void ArchiveManager::removeMemoryTPDFile(int iConfig) {
|
||||
std::lock_guard<std::mutex> lock(csMemTPDLock);
|
||||
PMEMDATA pData = nullptr;
|
||||
auto it = m_MEM_TPD.find(iConfig);
|
||||
if (it != m_MEM_TPD.end()) {
|
||||
pData = m_MEM_TPD[iConfig];
|
||||
delete pData;
|
||||
m_MEM_TPD.erase(iConfig);
|
||||
}
|
||||
}
|
||||
|
||||
int ArchiveManager::getTPConfigVal(char* pwchDataFile) { return -1; }
|
||||
|
||||
bool ArchiveManager::isFileInTPD(int iConfig) {
|
||||
bool val = false;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(csMemTPDLock);
|
||||
auto it = m_MEM_TPD.find(iConfig);
|
||||
if (it != m_MEM_TPD.end()) val = true;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
void ArchiveManager::getTPD(int iConfig, std::uint8_t** ppbData,
|
||||
unsigned int* pByteCount) {
|
||||
std::lock_guard<std::mutex> lock(csMemTPDLock);
|
||||
auto it = m_MEM_TPD.find(iConfig);
|
||||
if (it != m_MEM_TPD.end()) {
|
||||
PMEMDATA pData = (*it).second;
|
||||
*ppbData = pData->pbData;
|
||||
*pByteCount = pData->byteCount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "app/common/App_structs.h"
|
||||
|
||||
class ArchiveFile;
|
||||
|
||||
class ArchiveManager {
|
||||
public:
|
||||
ArchiveManager();
|
||||
|
||||
void loadMediaArchive();
|
||||
ArchiveFile* getMediaArchive() const { return m_mediaArchive; }
|
||||
|
||||
int getArchiveFileSize(const std::string& filename);
|
||||
bool hasArchiveFile(const std::string& filename);
|
||||
std::vector<uint8_t> getArchiveFile(const std::string& filename);
|
||||
|
||||
// Texture Pack Data files (icon, banner, comparison shot & text)
|
||||
void addMemoryTPDFile(int iConfig, std::uint8_t* pbData,
|
||||
unsigned int byteCount);
|
||||
void removeMemoryTPDFile(int iConfig);
|
||||
bool isFileInTPD(int iConfig);
|
||||
void getTPD(int iConfig, std::uint8_t** ppbData, unsigned int* pByteCount);
|
||||
int getTPDSize() { return m_MEM_TPD.size(); }
|
||||
int getTPConfigVal(char* pwchDataFile);
|
||||
|
||||
void setRequiredTexturePackID(std::uint32_t texturePackId) {
|
||||
m_dwRequiredTexturePackID = texturePackId;
|
||||
}
|
||||
std::uint32_t getRequiredTexturePackID() const {
|
||||
return m_dwRequiredTexturePackID;
|
||||
}
|
||||
|
||||
virtual void getFileFromTPD(eTPDFileType eType, std::uint8_t* pbData,
|
||||
unsigned int byteCount, std::uint8_t** ppbData,
|
||||
unsigned int* pByteCount) {
|
||||
*ppbData = nullptr;
|
||||
*pByteCount = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
ArchiveFile* m_mediaArchive;
|
||||
|
||||
private:
|
||||
std::unordered_map<int, PMEMDATA> m_MEM_TPD;
|
||||
std::mutex csMemTPDLock;
|
||||
std::uint32_t m_dwRequiredTexturePackID;
|
||||
};
|
||||
@@ -0,0 +1,62 @@
|
||||
#include "app/common/Audio/ConsoleSoundEngine.h"
|
||||
|
||||
bool ConsoleSoundEngine::GetIsPlayingStreamingCDMusic() {
|
||||
return m_bIsPlayingStreamingCDMusic;
|
||||
}
|
||||
bool ConsoleSoundEngine::GetIsPlayingStreamingGameMusic() {
|
||||
return m_bIsPlayingStreamingGameMusic;
|
||||
}
|
||||
void ConsoleSoundEngine::SetIsPlayingStreamingCDMusic(bool bVal) {
|
||||
m_bIsPlayingStreamingCDMusic = bVal;
|
||||
}
|
||||
void ConsoleSoundEngine::SetIsPlayingStreamingGameMusic(bool bVal) {
|
||||
m_bIsPlayingStreamingGameMusic = bVal;
|
||||
}
|
||||
bool ConsoleSoundEngine::GetIsPlayingEndMusic() { return m_bIsPlayingEndMusic; }
|
||||
bool ConsoleSoundEngine::GetIsPlayingNetherMusic() {
|
||||
return m_bIsPlayingNetherMusic;
|
||||
}
|
||||
void ConsoleSoundEngine::SetIsPlayingEndMusic(bool bVal) {
|
||||
m_bIsPlayingEndMusic = bVal;
|
||||
}
|
||||
void ConsoleSoundEngine::SetIsPlayingNetherMusic(bool bVal) {
|
||||
m_bIsPlayingNetherMusic = bVal;
|
||||
}
|
||||
|
||||
void ConsoleSoundEngine::tick() {
|
||||
if (scheduledSounds.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto it = scheduledSounds.begin(); it != scheduledSounds.end();) {
|
||||
ConsoleSoundEngine::ScheduledSound* next = *it;
|
||||
next->delay--;
|
||||
|
||||
if (next->delay <= 0) {
|
||||
play(next->iSound, next->x, next->y, next->z, next->volume,
|
||||
next->pitch);
|
||||
it = scheduledSounds.erase(it);
|
||||
delete next;
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConsoleSoundEngine::schedule(int iSound, float x, float y, float z,
|
||||
float volume, float pitch, int delayTicks) {
|
||||
scheduledSounds.push_back(new ConsoleSoundEngine::ScheduledSound(
|
||||
iSound, x, y, z, volume, pitch, delayTicks));
|
||||
}
|
||||
|
||||
ConsoleSoundEngine::ScheduledSound::ScheduledSound(int iSound, float x, float y,
|
||||
float z, float volume,
|
||||
float pitch, int delay) {
|
||||
this->iSound = iSound;
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
this->z = z;
|
||||
this->volume = volume;
|
||||
this->pitch = pitch;
|
||||
this->delay = delay;
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "minecraft/sounds/SoundTypes.h"
|
||||
#include "SoundTypes.h"
|
||||
|
||||
class File;
|
||||
|
||||
@@ -21,6 +21,11 @@ typedef struct {
|
||||
class Options;
|
||||
class Mob;
|
||||
|
||||
// Game-side sound engine interface. The concrete backend
|
||||
// (app/common/Audio/SoundEngine) inherits from this and forwards into
|
||||
// IPlatformSound. minecraft/ consumers see only the abstract base, so
|
||||
// they don't have to drag the concrete backend (and its miniaudio
|
||||
// pimpl) into their compilation units.
|
||||
class ConsoleSoundEngine {
|
||||
public:
|
||||
ConsoleSoundEngine()
|
||||
@@ -29,11 +34,13 @@ public:
|
||||
m_bIsPlayingEndMusic(false),
|
||||
m_bIsPlayingNetherMusic(false) {}
|
||||
|
||||
virtual ~ConsoleSoundEngine() = default;
|
||||
|
||||
virtual void tick(std::shared_ptr<Mob>* players, float a) = 0;
|
||||
virtual void destroy() = 0;
|
||||
virtual void play(int iSound, float x, float y, float z, float volume,
|
||||
float pitch) = 0;
|
||||
virtual void playStreaming(const std::wstring& name, float x, float y,
|
||||
virtual void playStreaming(const std::string& name, float x, float y,
|
||||
float z, float volume, float pitch,
|
||||
bool bMusicDelay = true) = 0;
|
||||
virtual void playUI(int iSound, float volume, float pitch) = 0;
|
||||
@@ -41,10 +48,10 @@ public:
|
||||
virtual void updateSystemMusicPlaying(bool isPlaying) = 0;
|
||||
virtual void updateSoundEffectVolume(float fVal) = 0;
|
||||
virtual void init(Options*) = 0;
|
||||
virtual void add(const std::wstring& name, File* file) = 0;
|
||||
virtual void addMusic(const std::wstring& name, File* file) = 0;
|
||||
virtual void addStreaming(const std::wstring& name, File* file) = 0;
|
||||
virtual char* ConvertSoundPathToName(const std::wstring& name,
|
||||
virtual void add(const std::string& name, File* file) = 0;
|
||||
virtual void addMusic(const std::string& name, File* file) = 0;
|
||||
virtual void addStreaming(const std::string& name, File* file) = 0;
|
||||
virtual char* ConvertSoundPathToName(const std::string& name,
|
||||
bool bConvertSpaces) = 0;
|
||||
virtual void playMusicTick() = 0;
|
||||
|
||||
@@ -57,8 +64,8 @@ public:
|
||||
virtual void SetIsPlayingEndMusic(bool bVal);
|
||||
virtual void SetIsPlayingNetherMusic(bool bVal);
|
||||
|
||||
static const wchar_t* wchSoundNames[eSoundType_MAX];
|
||||
static const wchar_t* wchUISoundNames[eSFX_MAX];
|
||||
static const char* wchSoundNames[eSoundType_MAX];
|
||||
static const char* wchUISoundNames[eSFX_MAX];
|
||||
|
||||
public:
|
||||
void tick();
|
||||
@@ -0,0 +1,882 @@
|
||||
#include "SoundEngine.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <initializer_list>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "app/common/Audio/ConsoleSoundEngine.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/Iggy/include/rrCore.h"
|
||||
#include "java/Random.h"
|
||||
#include "minecraft/client/Minecraft.h"
|
||||
#include "minecraft/client/multiplayer/MultiPlayerLocalPlayer.h"
|
||||
#include "minecraft/client/skins/TexturePackRepository.h"
|
||||
#include "minecraft/util/Mth.h"
|
||||
#include "minecraft/world/entity/Mob.h"
|
||||
#include "minecraft/world/level/storage/LevelData.h"
|
||||
#include "platform/PlatformTypes.h"
|
||||
#include "platform/fs/fs.h"
|
||||
#include "platform/thread/C4JThread.h"
|
||||
|
||||
#define STB_VORBIS_HEADER_ONLY
|
||||
#include "stb_vorbis.c"
|
||||
|
||||
// Fixes strcasecmp in miniaudio
|
||||
// https://stackoverflow.com/questions/31127260/strcasecmp-a-non-standard-function
|
||||
int strcasecmp(const char* a, const char* b) {
|
||||
int ca, cb;
|
||||
do {
|
||||
ca = *(unsigned char*)a;
|
||||
cb = *(unsigned char*)b;
|
||||
ca = tolower(toupper(ca));
|
||||
cb = tolower(toupper(cb));
|
||||
a++;
|
||||
b++;
|
||||
} while (ca == cb && ca != '\0');
|
||||
return ca - cb;
|
||||
}
|
||||
#define MINIAUDIO_IMPLEMENTATION
|
||||
#include "miniaudio.h"
|
||||
|
||||
#undef STB_VORBIS_HEADER_ONLY
|
||||
#include "stb_vorbis.c"
|
||||
|
||||
// stb_vorbis leaks single-letter macros (C, L, R, etc.) that collide with
|
||||
// identifiers in other translation units during unity builds.
|
||||
#undef C
|
||||
#undef L
|
||||
#undef R
|
||||
#undef TRUE
|
||||
#undef FALSE
|
||||
|
||||
// ASSETS
|
||||
const char* SoundEngine::m_szStreamFileA[eStream_Max] = {"calm1",
|
||||
"calm2",
|
||||
"calm3",
|
||||
"hal1",
|
||||
"hal2",
|
||||
"hal3",
|
||||
"hal4",
|
||||
"nuance1",
|
||||
"nuance2",
|
||||
"creative1",
|
||||
"creative2",
|
||||
"creative3",
|
||||
"creative4",
|
||||
"creative5",
|
||||
"creative6",
|
||||
"menu1",
|
||||
"menu2",
|
||||
"menu3",
|
||||
"menu4",
|
||||
"piano1",
|
||||
"piano2",
|
||||
"piano3",
|
||||
"nether1",
|
||||
"nether2",
|
||||
"nether3",
|
||||
"nether4",
|
||||
"the_end_dragon_alive",
|
||||
"the_end_end",
|
||||
"11",
|
||||
"13",
|
||||
"blocks",
|
||||
"cat",
|
||||
"chirp",
|
||||
"far",
|
||||
"mall",
|
||||
"mellohi",
|
||||
"stal",
|
||||
"strad",
|
||||
"ward",
|
||||
"where_are_we_now"};
|
||||
char SoundEngine::m_szSoundPath[] = {"app/common/Sound/"};
|
||||
char SoundEngine::m_szMusicPath[] = {"app/common/"};
|
||||
char SoundEngine::m_szRedistName[] = {"redist64"};
|
||||
|
||||
// END ASSETS
|
||||
|
||||
// Linux specific functions
|
||||
|
||||
// PIMPL'd state for the miniaudio backend. Defined here so SoundEngine.h
|
||||
// stays free of miniaudio.h.
|
||||
struct SoundEngineMiniAudio {
|
||||
ma_engine engine{};
|
||||
ma_engine_config engineConfig{};
|
||||
ma_sound musicStream{};
|
||||
};
|
||||
|
||||
struct MiniAudioSound {
|
||||
ma_sound sound;
|
||||
AUDIO_INFO info;
|
||||
bool active;
|
||||
};
|
||||
|
||||
SoundEngine::SoundEngine()
|
||||
: m_audio(std::make_unique<SoundEngineMiniAudio>()) {}
|
||||
SoundEngine::~SoundEngine() = default;
|
||||
std::vector<MiniAudioSound*> m_activeSounds;
|
||||
void SoundEngine::init(Options* pOptions) {
|
||||
app.DebugPrintf("---SoundEngine::init\n");
|
||||
random = new Random();
|
||||
*m_audio = SoundEngineMiniAudio{};
|
||||
m_musicStreamActive = false;
|
||||
m_StreamState = eMusicStreamState_Idle;
|
||||
m_iMusicDelay = 0;
|
||||
m_validListenerCount = 0;
|
||||
|
||||
m_bHeardTrackA = nullptr;
|
||||
|
||||
// Start the streaming music playing some music from the overworld
|
||||
SetStreamingSounds(eStream_Overworld_Calm1, eStream_Overworld_piano3,
|
||||
eStream_Nether1, eStream_Nether4, eStream_end_dragon,
|
||||
eStream_end_end, eStream_CD_1);
|
||||
|
||||
m_musicID = getMusicID(LevelData::DIMENSION_OVERWORLD);
|
||||
|
||||
m_StreamingAudioInfo.bIs3D = false;
|
||||
m_StreamingAudioInfo.x = 0;
|
||||
m_StreamingAudioInfo.y = 0;
|
||||
m_StreamingAudioInfo.z = 0;
|
||||
m_StreamingAudioInfo.volume = 1;
|
||||
m_StreamingAudioInfo.pitch = 1;
|
||||
|
||||
memset(CurrentSoundsPlaying, 0,
|
||||
sizeof(int) *
|
||||
(static_cast<int>(eSoundType_MAX) + static_cast<int>(eSFX_MAX)));
|
||||
memset(m_ListenerA, 0, sizeof(AUDIO_LISTENER) * XUSER_MAX_COUNT);
|
||||
m_audio->engineConfig = ma_engine_config_init();
|
||||
m_audio->engineConfig.listenerCount = MAX_LOCAL_PLAYERS;
|
||||
|
||||
if (ma_engine_init(&m_audio->engineConfig, &m_audio->engine) !=
|
||||
MA_SUCCESS) {
|
||||
app.DebugPrintf("Failed to initialize miniaudio engine\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ma_engine_set_volume(&m_audio->engine, 1.0f);
|
||||
|
||||
m_MasterMusicVolume = 1.0f;
|
||||
m_MasterEffectsVolume = 1.0f;
|
||||
|
||||
m_validListenerCount = 1;
|
||||
|
||||
m_bSystemMusicPlaying = false;
|
||||
}
|
||||
void SoundEngine::destroy() { ma_engine_uninit(&m_audio->engine); }
|
||||
|
||||
void SoundEngine::play(int iSound, float x, float y, float z, float volume,
|
||||
float pitch) {
|
||||
if (iSound == -1) return;
|
||||
char szId[256];
|
||||
strncpy(szId, wchSoundNames[iSound], 255);
|
||||
for (int i = 0; szId[i]; i++)
|
||||
if (szId[i] == '.') szId[i] = '/';
|
||||
|
||||
std::string base = PlatformFilesystem.getBasePath().string() + "/";
|
||||
const char* roots[] = {"Sound/Minecraft/", "app/common/Sound/Minecraft/",
|
||||
"app/common/res/TitleUpdate/res/Sound/Minecraft/"};
|
||||
char finalPath[512] = {0};
|
||||
bool found = false;
|
||||
|
||||
for (const char* root : roots) {
|
||||
std::string fullRoot = base + root;
|
||||
for (const char* ext : {".ogg", ".wav"}) {
|
||||
int count = 0;
|
||||
for (int i = 1; i <= 16; i++) {
|
||||
char tryP[512];
|
||||
snprintf(tryP, 512, "%s%s%d%s", fullRoot.c_str(), szId, i, ext);
|
||||
if (PlatformFilesystem.exists(tryP))
|
||||
count = i;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (count > 0) {
|
||||
snprintf(finalPath, 512, "%s%s%d%s", fullRoot.c_str(), szId,
|
||||
(rand() % count) + 1, ext);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
char tryP[512];
|
||||
snprintf(tryP, 512, "%s%s%s", fullRoot.c_str(), szId, ext);
|
||||
if (PlatformFilesystem.exists(tryP)) {
|
||||
strncpy(finalPath, tryP, 511);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) break;
|
||||
}
|
||||
|
||||
if (!found) return;
|
||||
MiniAudioSound* s = new MiniAudioSound();
|
||||
memset(&s->info, 0, sizeof(AUDIO_INFO));
|
||||
s->info.x = x;
|
||||
s->info.y = y;
|
||||
s->info.z = z;
|
||||
s->info.volume = volume;
|
||||
s->info.pitch = pitch;
|
||||
s->info.bIs3D = true;
|
||||
|
||||
if (ma_sound_init_from_file(&m_audio->engine, finalPath,
|
||||
MA_SOUND_FLAG_ASYNC, nullptr, nullptr,
|
||||
&s->sound) == MA_SUCCESS) {
|
||||
ma_sound_set_spatialization_enabled(&s->sound, MA_TRUE);
|
||||
ma_sound_set_min_distance(&s->sound, 2.0f);
|
||||
ma_sound_set_max_distance(&s->sound, 48.0f);
|
||||
ma_sound_set_volume(&s->sound, volume * m_MasterEffectsVolume);
|
||||
ma_sound_set_position(&s->sound, x, y, z);
|
||||
ma_sound_start(&s->sound);
|
||||
m_activeSounds.push_back(s);
|
||||
} else
|
||||
delete s;
|
||||
}
|
||||
|
||||
void SoundEngine::playUI(int iSound, float volume, float pitch) {
|
||||
char szIdentifier[256];
|
||||
if (iSound >= eSFX_MAX)
|
||||
strncpy(szIdentifier, wchSoundNames[iSound], 255);
|
||||
else
|
||||
strncpy(szIdentifier, wchUISoundNames[iSound], 255);
|
||||
for (int i = 0; szIdentifier[i]; i++)
|
||||
if (szIdentifier[i] == '.') szIdentifier[i] = '/';
|
||||
std::string base = PlatformFilesystem.getBasePath().string() + "/";
|
||||
const char* roots[] = {
|
||||
"Sound/Minecraft/UI/",
|
||||
"Sound/Minecraft/",
|
||||
"app/common/Sound/Minecraft/UI/",
|
||||
"app/common/Sound/Minecraft/",
|
||||
};
|
||||
char finalPath[512] = {0};
|
||||
bool found = false;
|
||||
|
||||
for (const char* root : roots) {
|
||||
for (const char* ext : {".ogg", ".wav", ".mp3"}) {
|
||||
char tryP[512];
|
||||
snprintf(tryP, 512, "%s%s%s%s", base.c_str(), root, szIdentifier,
|
||||
ext);
|
||||
if (PlatformFilesystem.exists(tryP)) {
|
||||
strncpy(finalPath, tryP, 511);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) break;
|
||||
}
|
||||
|
||||
if (!found) return;
|
||||
MiniAudioSound* s = new MiniAudioSound();
|
||||
memset(&s->info, 0, sizeof(AUDIO_INFO));
|
||||
s->info.volume = volume;
|
||||
s->info.pitch = pitch;
|
||||
s->info.bIs3D = false;
|
||||
|
||||
if (ma_sound_init_from_file(&m_audio->engine, finalPath,
|
||||
MA_SOUND_FLAG_ASYNC, nullptr, nullptr,
|
||||
&s->sound) == MA_SUCCESS) {
|
||||
ma_sound_set_spatialization_enabled(&s->sound, MA_FALSE);
|
||||
ma_sound_set_volume(&s->sound, volume * m_MasterEffectsVolume);
|
||||
ma_sound_set_pitch(&s->sound, pitch);
|
||||
ma_sound_start(&s->sound);
|
||||
m_activeSounds.push_back(s);
|
||||
} else
|
||||
delete s;
|
||||
}
|
||||
|
||||
int SoundEngine::getMusicID(int iDomain) {
|
||||
int iRandomVal = 0;
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
// Protection from errors
|
||||
if (pMinecraft == nullptr || pMinecraft->skins == nullptr) {
|
||||
// any track from the overworld
|
||||
return GetRandomishTrack(m_iStream_Overworld_Min,
|
||||
m_iStream_Overworld_Max);
|
||||
}
|
||||
|
||||
if (pMinecraft->skins->isUsingDefaultSkin()) {
|
||||
switch (iDomain) {
|
||||
case LevelData::DIMENSION_END:
|
||||
// the end isn't random - it has different music depending
|
||||
// whether the dragon is alive or not, but we've not
|
||||
// added the dead dragon music yet
|
||||
// haha they said wheter
|
||||
return m_iStream_End_Min;
|
||||
case LevelData::DIMENSION_NETHER:
|
||||
return GetRandomishTrack(m_iStream_Nether_Min,
|
||||
m_iStream_Nether_Max);
|
||||
// return m_iStream_Nether_Min +
|
||||
// random->nextInt(m_iStream_Nether_Max-m_iStream_Nether_Min);
|
||||
default: // overworld
|
||||
// return m_iStream_Overworld_Min +
|
||||
// random->nextInt(m_iStream_Overworld_Max-m_iStream_Overworld_Min);
|
||||
return GetRandomishTrack(m_iStream_Overworld_Min,
|
||||
m_iStream_Overworld_Max);
|
||||
}
|
||||
} else {
|
||||
// using a texture pack - may have multiple End music tracks
|
||||
switch (iDomain) {
|
||||
case LevelData::DIMENSION_END:
|
||||
return GetRandomishTrack(m_iStream_End_Min, m_iStream_End_Max);
|
||||
case LevelData::DIMENSION_NETHER:
|
||||
// return m_iStream_Nether_Min +
|
||||
// random->nextInt(m_iStream_Nether_Max-m_iStream_Nether_Min);
|
||||
return GetRandomishTrack(m_iStream_Nether_Min,
|
||||
m_iStream_Nether_Max);
|
||||
default: // overworld
|
||||
// return m_iStream_Overworld_Min +
|
||||
// random->nextInt(m_iStream_Overworld_Max-m_iStream_Overworld_Min);
|
||||
return GetRandomishTrack(m_iStream_Overworld_Min,
|
||||
m_iStream_Overworld_Max);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int SoundEngine::getMusicID(const std::string& name) {
|
||||
int iCD = 0;
|
||||
for (size_t i = 0; i < 12; i++) {
|
||||
std::string fileName = m_szStreamFileA[i + eStream_CD_1];
|
||||
|
||||
if (name == fileName) {
|
||||
iCD = static_cast<int>(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return iCD + m_iStream_CD_1;
|
||||
}
|
||||
|
||||
void SoundEngine::playStreaming(const std::string& name, float x, float y,
|
||||
float z, float volume, float pitch,
|
||||
bool bMusicDelay) {
|
||||
m_StreamingAudioInfo.x = x;
|
||||
m_StreamingAudioInfo.y = y;
|
||||
m_StreamingAudioInfo.z = z;
|
||||
m_StreamingAudioInfo.volume = volume;
|
||||
m_StreamingAudioInfo.pitch = pitch;
|
||||
|
||||
if (m_StreamState == eMusicStreamState_Playing) {
|
||||
m_StreamState = eMusicStreamState_Stop;
|
||||
} else if (m_StreamState == eMusicStreamState_Opening) {
|
||||
m_StreamState = eMusicStreamState_OpeningCancel;
|
||||
}
|
||||
app.DebugPrintf("playStreaming %S", name.c_str());
|
||||
if (name.empty()) {
|
||||
// music, or stop CD
|
||||
m_StreamingAudioInfo.bIs3D = false;
|
||||
|
||||
// we need a music id
|
||||
// random delay of up to 3 minutes for music
|
||||
m_iMusicDelay = random->nextInt(
|
||||
20 * 60 * 3); // random->nextInt(20 * 60 * 10) + 20 * 60 * 10;
|
||||
|
||||
#if defined(_DEBUG)
|
||||
m_iMusicDelay = 0;
|
||||
#endif
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
bool playerInEnd = false;
|
||||
bool playerInNether = false;
|
||||
|
||||
for (unsigned int i = 0; i < MAX_LOCAL_PLAYERS; i++) {
|
||||
if (pMinecraft->localplayers[i] != nullptr) {
|
||||
if (pMinecraft->localplayers[i]->dimension ==
|
||||
LevelData::DIMENSION_END) {
|
||||
playerInEnd = true;
|
||||
} else if (pMinecraft->localplayers[i]->dimension ==
|
||||
LevelData::DIMENSION_NETHER) {
|
||||
playerInNether = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (playerInEnd) {
|
||||
m_musicID = getMusicID(LevelData::DIMENSION_END);
|
||||
} else if (playerInNether) {
|
||||
m_musicID = getMusicID(LevelData::DIMENSION_NETHER);
|
||||
} else {
|
||||
m_musicID = getMusicID(LevelData::DIMENSION_OVERWORLD);
|
||||
}
|
||||
} else {
|
||||
// jukebox
|
||||
m_StreamingAudioInfo.bIs3D = true;
|
||||
m_musicID = getMusicID(name);
|
||||
m_iMusicDelay = 0;
|
||||
}
|
||||
}
|
||||
int SoundEngine::OpenStreamThreadProc(void* lpParameter) {
|
||||
SoundEngine* soundEngine = (SoundEngine*)lpParameter;
|
||||
|
||||
const char* ext = strrchr(soundEngine->m_szStreamName, '.');
|
||||
|
||||
if (soundEngine->m_musicStreamActive) {
|
||||
ma_sound_stop(&soundEngine->m_audio->musicStream);
|
||||
ma_sound_uninit(&soundEngine->m_audio->musicStream);
|
||||
soundEngine->m_musicStreamActive = false;
|
||||
}
|
||||
|
||||
ma_result result = ma_sound_init_from_file(
|
||||
&soundEngine->m_audio->engine, soundEngine->m_szStreamName,
|
||||
MA_SOUND_FLAG_STREAM, nullptr, nullptr,
|
||||
&soundEngine->m_audio->musicStream);
|
||||
|
||||
if (result != MA_SUCCESS) {
|
||||
app.DebugPrintf(
|
||||
"SoundEngine::OpenStreamThreadProc - Failed to open stream: "
|
||||
"%s\n",
|
||||
soundEngine->m_szStreamName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ma_sound_set_spatialization_enabled(&soundEngine->m_audio->musicStream,
|
||||
MA_FALSE);
|
||||
ma_sound_set_looping(&soundEngine->m_audio->musicStream, MA_FALSE);
|
||||
|
||||
soundEngine->m_musicStreamActive = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
void SoundEngine::playMusicTick() {
|
||||
static float fMusicVol = 0.0f;
|
||||
fMusicVol = getMasterMusicVolume();
|
||||
|
||||
switch (m_StreamState) {
|
||||
case eMusicStreamState_Idle:
|
||||
if (m_iMusicDelay > 0) {
|
||||
m_iMusicDelay--;
|
||||
return;
|
||||
}
|
||||
if (m_musicID != -1) {
|
||||
std::string base =
|
||||
PlatformFilesystem.getBasePath().string() + "/";
|
||||
bool isCD = (m_musicID >= m_iStream_CD_1);
|
||||
const char* folder = isCD ? "cds/" : "music/";
|
||||
const char* track = m_szStreamFileA[m_musicID];
|
||||
bool found = false;
|
||||
m_szStreamName[0] = '\0';
|
||||
|
||||
const char* roots[] = {"app/common/music/", "music/", "./"};
|
||||
|
||||
for (const char* r : roots) {
|
||||
for (const char* e : {".ogg", ".mp3", ".wav"}) {
|
||||
// try with folder prefix (music/ or cds/)
|
||||
snprintf(m_szStreamName, sizeof(m_szStreamName),
|
||||
"%s%s%s%s%s", base.c_str(), r, folder, track,
|
||||
e);
|
||||
if (PlatformFilesystem.exists(m_szStreamName)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
// try without folder prefix
|
||||
snprintf(m_szStreamName, sizeof(m_szStreamName),
|
||||
"%s%s%s%s", base.c_str(), r, track, e);
|
||||
if (PlatformFilesystem.exists(m_szStreamName)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) break;
|
||||
}
|
||||
|
||||
if (found) {
|
||||
SetIsPlayingStreamingGameMusic(!isCD);
|
||||
SetIsPlayingStreamingCDMusic(isCD);
|
||||
m_openStreamThread = new C4JThread(
|
||||
OpenStreamThreadProc, this, "OpenStreamThreadProc");
|
||||
m_openStreamThread->run();
|
||||
m_StreamState = eMusicStreamState_Opening;
|
||||
} else {
|
||||
app.DebugPrintf(
|
||||
"[SoundEngine] oh noes couldn't find music track '%s', "
|
||||
"retrying "
|
||||
"in 1min\n",
|
||||
track);
|
||||
m_iMusicDelay = 20 * 60;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case eMusicStreamState_Opening:
|
||||
if (!m_openStreamThread->isRunning()) {
|
||||
delete m_openStreamThread;
|
||||
m_openStreamThread = nullptr;
|
||||
|
||||
if (!m_musicStreamActive) {
|
||||
m_StreamState = eMusicStreamState_Idle;
|
||||
break;
|
||||
}
|
||||
|
||||
ma_sound_set_spatialization_enabled(
|
||||
&m_audio->musicStream,
|
||||
m_StreamingAudioInfo.bIs3D ? MA_TRUE : MA_FALSE);
|
||||
if (m_StreamingAudioInfo.bIs3D) {
|
||||
ma_sound_set_position(
|
||||
&m_audio->musicStream, m_StreamingAudioInfo.x,
|
||||
m_StreamingAudioInfo.y, m_StreamingAudioInfo.z);
|
||||
}
|
||||
|
||||
ma_sound_set_pitch(&m_audio->musicStream,
|
||||
m_StreamingAudioInfo.pitch);
|
||||
ma_sound_set_volume(
|
||||
&m_audio->musicStream,
|
||||
m_StreamingAudioInfo.volume * getMasterMusicVolume());
|
||||
ma_sound_start(&m_audio->musicStream);
|
||||
|
||||
m_StreamState = eMusicStreamState_Playing;
|
||||
}
|
||||
break;
|
||||
|
||||
case eMusicStreamState_OpeningCancel:
|
||||
if (!m_openStreamThread->isRunning()) {
|
||||
delete m_openStreamThread;
|
||||
m_openStreamThread = nullptr;
|
||||
m_StreamState = eMusicStreamState_Stop;
|
||||
}
|
||||
break;
|
||||
|
||||
case eMusicStreamState_Stop:
|
||||
if (m_musicStreamActive) {
|
||||
ma_sound_stop(&m_audio->musicStream);
|
||||
ma_sound_uninit(&m_audio->musicStream);
|
||||
m_musicStreamActive = false;
|
||||
}
|
||||
SetIsPlayingStreamingCDMusic(false);
|
||||
SetIsPlayingStreamingGameMusic(false);
|
||||
m_StreamState = eMusicStreamState_Idle;
|
||||
break;
|
||||
|
||||
case eMusicStreamState_Playing:
|
||||
if (GetIsPlayingStreamingGameMusic()) {
|
||||
bool playerInEnd = false, playerInNether = false;
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
for (unsigned int i = 0; i < MAX_LOCAL_PLAYERS; ++i) {
|
||||
if (pMinecraft->localplayers[i]) {
|
||||
if (pMinecraft->localplayers[i]->dimension ==
|
||||
LevelData::DIMENSION_END)
|
||||
playerInEnd = true;
|
||||
else if (pMinecraft->localplayers[i]->dimension ==
|
||||
LevelData::DIMENSION_NETHER)
|
||||
playerInNether = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle Dimension Switching
|
||||
bool needsStop = false;
|
||||
if (playerInEnd && !GetIsPlayingEndMusic()) {
|
||||
m_musicID = getMusicID(LevelData::DIMENSION_END);
|
||||
SetIsPlayingEndMusic(true);
|
||||
SetIsPlayingNetherMusic(false);
|
||||
needsStop = true;
|
||||
} else if (!playerInEnd && GetIsPlayingEndMusic()) {
|
||||
m_musicID =
|
||||
playerInNether
|
||||
? getMusicID(LevelData::DIMENSION_NETHER)
|
||||
: getMusicID(LevelData::DIMENSION_OVERWORLD);
|
||||
SetIsPlayingEndMusic(false);
|
||||
SetIsPlayingNetherMusic(playerInNether);
|
||||
needsStop = true;
|
||||
} else if (playerInNether && !GetIsPlayingNetherMusic()) {
|
||||
m_musicID = getMusicID(LevelData::DIMENSION_NETHER);
|
||||
SetIsPlayingNetherMusic(true);
|
||||
SetIsPlayingEndMusic(false);
|
||||
needsStop = true;
|
||||
} else if (!playerInNether && GetIsPlayingNetherMusic()) {
|
||||
m_musicID =
|
||||
playerInEnd
|
||||
? getMusicID(LevelData::DIMENSION_END)
|
||||
: getMusicID(LevelData::DIMENSION_OVERWORLD);
|
||||
SetIsPlayingNetherMusic(false);
|
||||
SetIsPlayingEndMusic(playerInEnd);
|
||||
needsStop = true;
|
||||
}
|
||||
|
||||
if (needsStop) m_StreamState = eMusicStreamState_Stop;
|
||||
|
||||
// volume change required?
|
||||
if (m_musicStreamActive)
|
||||
ma_sound_set_volume(
|
||||
&m_audio->musicStream,
|
||||
m_StreamingAudioInfo.volume * fMusicVol);
|
||||
|
||||
} else if (m_StreamingAudioInfo.bIs3D && m_validListenerCount > 1 &&
|
||||
m_musicStreamActive) {
|
||||
float fClosestDist = 1e6f;
|
||||
int iClosest = 0;
|
||||
for (size_t i = 0; i < MAX_LOCAL_PLAYERS; i++) {
|
||||
if (m_ListenerA[i].bValid) {
|
||||
float dist = sqrtf(powf(m_StreamingAudioInfo.x -
|
||||
m_ListenerA[i].vPosition.x,
|
||||
2) +
|
||||
powf(m_StreamingAudioInfo.y -
|
||||
m_ListenerA[i].vPosition.y,
|
||||
2) +
|
||||
powf(m_StreamingAudioInfo.z -
|
||||
m_ListenerA[i].vPosition.z,
|
||||
2));
|
||||
if (dist < fClosestDist) {
|
||||
fClosestDist = dist;
|
||||
iClosest = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
ma_sound_set_position(
|
||||
&m_audio->musicStream,
|
||||
m_StreamingAudioInfo.x - m_ListenerA[iClosest].vPosition.x,
|
||||
m_StreamingAudioInfo.y - m_ListenerA[iClosest].vPosition.y,
|
||||
m_StreamingAudioInfo.z - m_ListenerA[iClosest].vPosition.z);
|
||||
}
|
||||
break;
|
||||
|
||||
case eMusicStreamState_Completed:
|
||||
m_iMusicDelay = random->nextInt(20 * 60 * 3);
|
||||
{
|
||||
int dim = LevelData::DIMENSION_OVERWORLD;
|
||||
Minecraft* pMc = Minecraft::GetInstance();
|
||||
for (int i = 0; i < MAX_LOCAL_PLAYERS; i++) {
|
||||
if (pMc->localplayers[i]) {
|
||||
dim = pMc->localplayers[i]->dimension;
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_musicID = getMusicID(dim);
|
||||
SetIsPlayingEndMusic(dim == LevelData::DIMENSION_END);
|
||||
SetIsPlayingNetherMusic(dim == LevelData::DIMENSION_NETHER);
|
||||
}
|
||||
m_StreamState = eMusicStreamState_Idle;
|
||||
break;
|
||||
}
|
||||
|
||||
// check the status of the stream - this is for when a track completes
|
||||
// rather than is stopped by the user action
|
||||
|
||||
if (m_musicStreamActive && !ma_sound_is_playing(&m_audio->musicStream) &&
|
||||
ma_sound_at_end(&m_audio->musicStream)) {
|
||||
ma_sound_uninit(&m_audio->musicStream);
|
||||
m_musicStreamActive = false;
|
||||
SetIsPlayingStreamingCDMusic(false);
|
||||
SetIsPlayingStreamingGameMusic(false);
|
||||
m_StreamState = eMusicStreamState_Completed;
|
||||
}
|
||||
}
|
||||
|
||||
void SoundEngine::updateMiniAudio() {
|
||||
if (m_validListenerCount == 1) {
|
||||
for (size_t i = 0; i < MAX_LOCAL_PLAYERS; i++) {
|
||||
if (m_ListenerA[i].bValid) {
|
||||
ma_engine_listener_set_position(
|
||||
&m_audio->engine, 0, m_ListenerA[i].vPosition.x,
|
||||
m_ListenerA[i].vPosition.y, m_ListenerA[i].vPosition.z);
|
||||
|
||||
ma_engine_listener_set_direction(&m_audio->engine, 0,
|
||||
m_ListenerA[i].vOrientFront.x,
|
||||
m_ListenerA[i].vOrientFront.y,
|
||||
m_ListenerA[i].vOrientFront.z);
|
||||
|
||||
ma_engine_listener_set_world_up(&m_audio->engine, 0, 0.0f, 1.0f,
|
||||
0.0f);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ma_engine_listener_set_position(&m_audio->engine, 0, 0.0f, 0.0f, 0.0f);
|
||||
ma_engine_listener_set_direction(&m_audio->engine, 0, 0.0f, 0.0f, 1.0f);
|
||||
ma_engine_listener_set_world_up(&m_audio->engine, 0, 0.0f, 1.0f, 0.0f);
|
||||
}
|
||||
|
||||
for (auto it = m_activeSounds.begin(); it != m_activeSounds.end();) {
|
||||
MiniAudioSound* s = *it;
|
||||
|
||||
if (!ma_sound_is_playing(&s->sound)) {
|
||||
ma_sound_uninit(&s->sound);
|
||||
delete s;
|
||||
it = m_activeSounds.erase(it);
|
||||
continue;
|
||||
}
|
||||
|
||||
float finalVolume =
|
||||
s->info.volume * m_MasterEffectsVolume * SFX_VOLUME_MULTIPLIER;
|
||||
if (finalVolume > SFX_MAX_GAIN) finalVolume = SFX_MAX_GAIN;
|
||||
|
||||
ma_sound_set_volume(&s->sound, finalVolume);
|
||||
ma_sound_set_pitch(&s->sound, s->info.pitch);
|
||||
|
||||
if (s->info.bIs3D) {
|
||||
if (m_validListenerCount > 1) {
|
||||
float fClosest = 10000.0f;
|
||||
int iClosestListener = 0;
|
||||
float fClosestX = 0.0f, fClosestY = 0.0f, fClosestZ = 0.0f,
|
||||
fDist;
|
||||
for (size_t i = 0; i < MAX_LOCAL_PLAYERS; i++) {
|
||||
if (m_ListenerA[i].bValid) {
|
||||
float x, y, z;
|
||||
|
||||
x = fabs(m_ListenerA[i].vPosition.x - s->info.x);
|
||||
y = fabs(m_ListenerA[i].vPosition.y - s->info.y);
|
||||
z = fabs(m_ListenerA[i].vPosition.z - s->info.z);
|
||||
fDist = x + y + z;
|
||||
|
||||
if (fDist < fClosest) {
|
||||
fClosest = fDist;
|
||||
fClosestX = x;
|
||||
fClosestY = y;
|
||||
fClosestZ = z;
|
||||
iClosestListener = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float realDist =
|
||||
sqrtf((fClosestX * fClosestX) + (fClosestY * fClosestY) +
|
||||
(fClosestZ * fClosestZ));
|
||||
ma_sound_set_position(&s->sound, 0, 0, realDist);
|
||||
} else {
|
||||
ma_sound_set_position(&s->sound, s->info.x, s->info.y,
|
||||
s->info.z);
|
||||
}
|
||||
}
|
||||
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
void SoundEngine::tick(std::shared_ptr<Mob>* players, float a) {
|
||||
// update the listener positions
|
||||
int listenerCount = 0;
|
||||
if (players) {
|
||||
bool bListenerPostionSet = false;
|
||||
for (size_t i = 0; i < MAX_LOCAL_PLAYERS; i++) {
|
||||
if (players[i] != nullptr) {
|
||||
m_ListenerA[i].bValid = true;
|
||||
F32 x, y, z;
|
||||
x = players[i]->xo + (players[i]->x - players[i]->xo) * a;
|
||||
y = players[i]->yo + (players[i]->y - players[i]->yo) * a;
|
||||
z = players[i]->zo + (players[i]->z - players[i]->zo) * a;
|
||||
|
||||
float yRot = players[i]->yRotO +
|
||||
(players[i]->yRot - players[i]->yRotO) * a;
|
||||
float yCos = (float)cos(yRot * Mth::DEG_TO_RAD);
|
||||
float ySin = (float)sin(yRot * Mth::DEG_TO_RAD);
|
||||
|
||||
// store the listener positions for splitscreen
|
||||
m_ListenerA[i].vPosition.x = x;
|
||||
m_ListenerA[i].vPosition.y = y;
|
||||
m_ListenerA[i].vPosition.z = z;
|
||||
|
||||
m_ListenerA[i].vOrientFront.x = -ySin;
|
||||
m_ListenerA[i].vOrientFront.y = 0;
|
||||
m_ListenerA[i].vOrientFront.z = yCos;
|
||||
|
||||
listenerCount++;
|
||||
} else {
|
||||
m_ListenerA[i].bValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If there were no valid players set, make up a default listener
|
||||
if (listenerCount == 0) {
|
||||
m_ListenerA[0].vPosition.x = 0;
|
||||
m_ListenerA[0].vPosition.y = 0;
|
||||
m_ListenerA[0].vPosition.z = 0;
|
||||
m_ListenerA[0].vOrientFront.x = 0;
|
||||
m_ListenerA[0].vOrientFront.y = 0;
|
||||
m_ListenerA[0].vOrientFront.z = 1.0f;
|
||||
listenerCount++;
|
||||
}
|
||||
m_validListenerCount = listenerCount;
|
||||
updateMiniAudio();
|
||||
}
|
||||
|
||||
// Universal, these functions shouldn't need platform specific
|
||||
// implementations
|
||||
void SoundEngine::updateMusicVolume(float fVal) { m_MasterMusicVolume = fVal; }
|
||||
void SoundEngine::updateSystemMusicPlaying(bool isPlaying) {
|
||||
m_bSystemMusicPlaying = isPlaying;
|
||||
}
|
||||
void SoundEngine::updateSoundEffectVolume(float fVal) {
|
||||
m_MasterEffectsVolume = fVal;
|
||||
}
|
||||
void SoundEngine::SetStreamingSounds(int iOverworldMin, int iOverWorldMax,
|
||||
int iNetherMin, int iNetherMax,
|
||||
int iEndMin, int iEndMax, int iCD1) {
|
||||
m_iStream_Overworld_Min = iOverworldMin;
|
||||
m_iStream_Overworld_Max = iOverWorldMax;
|
||||
m_iStream_Nether_Min = iNetherMin;
|
||||
m_iStream_Nether_Max = iNetherMax;
|
||||
m_iStream_End_Min = iEndMin;
|
||||
m_iStream_End_Max = iEndMax;
|
||||
m_iStream_CD_1 = iCD1;
|
||||
|
||||
// array to monitor recently played tracks
|
||||
if (m_bHeardTrackA) {
|
||||
delete[] m_bHeardTrackA;
|
||||
}
|
||||
m_bHeardTrackA = new bool[iEndMax + 1];
|
||||
memset(m_bHeardTrackA, 0, sizeof(bool) * (iEndMax + 1));
|
||||
}
|
||||
int SoundEngine::GetRandomishTrack(int iStart, int iEnd) {
|
||||
// 4J-PB - make it more likely that we'll get a track we've not heard for a
|
||||
// while, although repeating tracks sometimes is fine
|
||||
|
||||
// if all tracks have been heard, clear the flags
|
||||
bool bAllTracksHeard = true;
|
||||
int iVal = iStart;
|
||||
for (size_t i = iStart; i <= iEnd; i++) {
|
||||
if (m_bHeardTrackA[i] == false) {
|
||||
bAllTracksHeard = false;
|
||||
app.DebugPrintf("Not heard all tracks yet\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bAllTracksHeard) {
|
||||
app.DebugPrintf("Heard all tracks - resetting the tracking array\n");
|
||||
|
||||
for (size_t i = iStart; i <= iEnd; i++) {
|
||||
m_bHeardTrackA[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
// trying to get a track we haven't heard, but not too hard
|
||||
for (size_t i = 0; i <= ((iEnd - iStart) / 2); i++) {
|
||||
// random->nextInt(1) will always return 0
|
||||
iVal = random->nextInt((iEnd - iStart) + 1) + iStart;
|
||||
if (m_bHeardTrackA[iVal] == false) {
|
||||
// not heard this
|
||||
app.DebugPrintf("(%d) Not heard track %d yet, so playing it now\n",
|
||||
i, iVal);
|
||||
m_bHeardTrackA[iVal] = true;
|
||||
break;
|
||||
} else {
|
||||
app.DebugPrintf(
|
||||
"(%d) Skipping track %d already heard it recently\n", i, iVal);
|
||||
}
|
||||
}
|
||||
|
||||
app.DebugPrintf("Select track %d\n", iVal);
|
||||
return iVal;
|
||||
}
|
||||
float SoundEngine::getMasterMusicVolume() {
|
||||
if (m_bSystemMusicPlaying) {
|
||||
return 0.0f;
|
||||
} else {
|
||||
return m_MasterMusicVolume;
|
||||
}
|
||||
}
|
||||
void SoundEngine::add(const std::string& name, File* file) {}
|
||||
|
||||
void SoundEngine::addMusic(const std::string& name, File* file) {}
|
||||
void SoundEngine::addStreaming(const std::string& name, File* file) {}
|
||||
|
||||
bool SoundEngine::isStreamingWavebankReady() { return true; }
|
||||
// This is unused by the linux version, it'll need to be changed
|
||||
char* SoundEngine::ConvertSoundPathToName(const std::string& name,
|
||||
bool bConvertSpaces) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -4,13 +4,19 @@ class Options;
|
||||
class C4JThread;
|
||||
class Random;
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "app/common/App_Defines.h"
|
||||
#include "app/common/src/Audio/Consoles_SoundEngine.h"
|
||||
#include "app/linux/Iggy/include/rrCore.h"
|
||||
#include "minecraft/sounds/SoundTypes.h"
|
||||
#include "miniaudio.h"
|
||||
#include "app/common/Audio/ConsoleSoundEngine.h"
|
||||
#include "app/common/Audio/SoundTypes.h"
|
||||
#include "app/common/Iggy/include/rrCore.h"
|
||||
#include "platform/PlatformTypes.h"
|
||||
|
||||
// Forward-declare the miniaudio backing state. The full struct lives in
|
||||
// SoundEngine.cpp where miniaudio.h is actually included. This keeps
|
||||
// miniaudio.h out of the 9 minecraft files that include SoundEngine.h
|
||||
// via the 4j include chain.
|
||||
struct SoundEngineMiniAudio;
|
||||
|
||||
constexpr float SFX_3D_MIN_DISTANCE = 1.0f;
|
||||
constexpr float SFX_3D_MAX_DISTANCE = 16.0f;
|
||||
@@ -90,22 +96,22 @@ typedef struct {
|
||||
char chName[64];
|
||||
#endif
|
||||
} AUDIO_INFO;
|
||||
struct MiniAudioSound {
|
||||
ma_sound sound;
|
||||
AUDIO_INFO info;
|
||||
bool active;
|
||||
};
|
||||
|
||||
// MiniAudioSound's definition lives in SoundEngine.cpp alongside the
|
||||
// miniaudio backend; consumers of this header don't need to see it.
|
||||
|
||||
class SoundEngine : public ConsoleSoundEngine {
|
||||
static const int MAX_SAME_SOUNDS_PLAYING = 8; // 4J added
|
||||
public:
|
||||
SoundEngine();
|
||||
~SoundEngine();
|
||||
virtual void destroy();
|
||||
#if defined(_DEBUG)
|
||||
void GetSoundName(char* szSoundName, int iSound);
|
||||
#endif
|
||||
virtual void play(int iSound, float x, float y, float z, float volume,
|
||||
float pitch);
|
||||
virtual void playStreaming(const std::wstring& name, float x, float y,
|
||||
virtual void playStreaming(const std::string& name, float x, float y,
|
||||
float z, float volume, float pitch,
|
||||
bool bMusicDelay = true);
|
||||
virtual void playUI(int iSound, float volume, float pitch);
|
||||
@@ -117,14 +123,14 @@ public:
|
||||
virtual void tick(std::shared_ptr<Mob>* players,
|
||||
float a); // 4J - updated to take array of local players
|
||||
// rather than single one
|
||||
virtual void add(const std::wstring& name, File* file);
|
||||
virtual void addMusic(const std::wstring& name, File* file);
|
||||
virtual void addStreaming(const std::wstring& name, File* file);
|
||||
virtual char* ConvertSoundPathToName(const std::wstring& name,
|
||||
virtual void add(const std::string& name, File* file);
|
||||
virtual void addMusic(const std::string& name, File* file);
|
||||
virtual void addStreaming(const std::string& name, File* file);
|
||||
virtual char* ConvertSoundPathToName(const std::string& name,
|
||||
bool bConvertSpaces = false);
|
||||
bool isStreamingWavebankReady(); // 4J Added
|
||||
int getMusicID(int iDomain);
|
||||
int getMusicID(const std::wstring& name);
|
||||
int getMusicID(const std::string& name);
|
||||
void SetStreamingSounds(int iOverworldMin, int iOverWorldMax,
|
||||
int iNetherMin, int iNetherMax, int iEndMin,
|
||||
int iEndMax, int iCD1);
|
||||
@@ -136,15 +142,15 @@ private:
|
||||
float getMasterMusicVolume();
|
||||
// platform specific functions
|
||||
int initAudioHardware(int iMinSpeakers) { return iMinSpeakers; }
|
||||
#if defined(__linux__)
|
||||
void updateMiniAudio();
|
||||
#endif
|
||||
|
||||
int GetRandomishTrack(int iStart, int iEnd);
|
||||
|
||||
ma_engine m_engine;
|
||||
ma_engine_config m_engineConfig;
|
||||
ma_sound m_musicStream;
|
||||
// Miniaudio engine + music stream PIMPL'd into SoundEngineMiniAudio,
|
||||
// defined in SoundEngine.cpp. Owned via unique_ptr; the destructor
|
||||
// is out-of-line so the unique_ptr instantiation can see the full
|
||||
// type.
|
||||
std::unique_ptr<SoundEngineMiniAudio> m_audio;
|
||||
bool m_musicStreamActive;
|
||||
|
||||
static char m_szSoundPath[];
|
||||
@@ -161,7 +167,7 @@ private:
|
||||
int m_StreamState;
|
||||
int m_MusicType;
|
||||
AUDIO_INFO m_StreamingAudioInfo;
|
||||
std::wstring m_CDMusic;
|
||||
std::string m_CDMusic;
|
||||
bool m_bSystemMusicPlaying;
|
||||
float m_MasterMusicVolume;
|
||||
float m_MasterEffectsVolume;
|
||||
@@ -0,0 +1,228 @@
|
||||
#include "app/common/Audio/ConsoleSoundEngine.h"
|
||||
#include "app/common/Audio/SoundTypes.h"
|
||||
|
||||
const char* ConsoleSoundEngine::wchSoundNames[eSoundType_MAX] = {
|
||||
"mob/chicken/chicken", // eSoundType_MOB_CHICKEN_AMBIENT
|
||||
"mob/chicken/chickenhurt", // eSoundType_MOB_CHICKEN_HURT
|
||||
"mob/chicken/chickenplop", // eSoundType_MOB_CHICKENPLOP
|
||||
"mob/cow/say", // eSoundType_MOB_COW_AMBIENT
|
||||
"mob/cow/hurt", // eSoundType_MOB_COW_HURT
|
||||
"mob/pig/pig", // eSoundType_MOB_PIG_AMBIENT
|
||||
"mob/pig/pigdeath", // eSoundType_MOB_PIG_DEATH
|
||||
"mob/sheep/sheep", // eSoundType_MOB_SHEEP_AMBIENT
|
||||
"mob/wolf/growl", // eSoundType_MOB_WOLF_GROWL
|
||||
"mob/wolf/whine", // eSoundType_MOB_WOLF_WHINE
|
||||
"mob/wolf/panting", // eSoundType_MOB_WOLF_PANTING
|
||||
"mob/wolf/bark", // eSoundType_MOB_WOLF_BARK
|
||||
"mob/wolf/hurt", // eSoundType_MOB_WOLF_HURT
|
||||
"mob/wolf/death", // eSoundType_MOB_WOLF_DEATH
|
||||
"mob/wolf/shake", // eSoundType_MOB_WOLF_SHAKE
|
||||
"mob/blaze/breathe", // eSoundType_MOB_BLAZE_BREATHE
|
||||
"mob/blaze/hit", // eSoundType_MOB_BLAZE_HURT
|
||||
"mob/blaze/death", // eSoundType_MOB_BLAZE_DEATH
|
||||
"mob/ghast/moan", // eSoundType_MOB_GHAST_MOAN
|
||||
"mob/ghast/scream", // eSoundType_MOB_GHAST_SCREAM
|
||||
"mob/ghast/death", // eSoundType_MOB_GHAST_DEATH
|
||||
"mob/ghast/fireball", // eSoundType_MOB_GHAST_FIREBALL
|
||||
"mob/ghast/charge", // eSoundType_MOB_GHAST_CHARGE
|
||||
"mob/endermen/idle", // eSoundType_MOB_ENDERMEN_IDLE
|
||||
"mob/endermen/hit", // eSoundType_MOB_ENDERMEN_HIT
|
||||
"mob/endermen/death", // eSoundType_MOB_ENDERMEN_DEATH
|
||||
"mob/endermen/portal", // eSoundType_MOB_ENDERMEN_PORTAL
|
||||
"mob/zombiepig/zpig", // eSoundType_MOB_ZOMBIEPIG_AMBIENT
|
||||
"mob/zombiepig/zpighurt", // eSoundType_MOB_ZOMBIEPIG_HURT
|
||||
"mob/zombiepig/zpigdeath", // eSoundType_MOB_ZOMBIEPIG_DEATH
|
||||
"mob/zombiepig/zpigangry", // eSoundType_MOB_ZOMBIEPIG_ZPIGANGRY
|
||||
"mob/silverfish/say", // eSoundType_MOB_SILVERFISH_AMBIENT,
|
||||
"mob/silverfish/hit", // eSoundType_MOB_SILVERFISH_HURT
|
||||
"mob/silverfish/kill", // eSoundType_MOB_SILVERFISH_DEATH,
|
||||
"mob/silverfish/step", // eSoundType_MOB_SILVERFISH_STEP,
|
||||
"mob/skeleton/skeleton", // eSoundType_MOB_SKELETON_AMBIENT,
|
||||
"mob/skeleton/skeletonhurt", // eSoundType_MOB_SKELETON_HURT,
|
||||
"mob/spider/spider", // eSoundType_MOB_SPIDER_AMBIENT,
|
||||
"mob/spider/spiderdeath", // eSoundType_MOB_SPIDER_DEATH,
|
||||
"mob/slime/slime", // eSoundType_MOB_SLIME,
|
||||
"mob/slime/slimeattack", // eSoundType_MOB_SLIME_ATTACK,
|
||||
"mob/creeper/creeper", // eSoundType_MOB_CREEPER_HURT,
|
||||
"mob/creeper/creeperdeath", // eSoundType_MOB_CREEPER_DEATH,
|
||||
"mob/zombie/zombie", // eSoundType_MOB_ZOMBIE_AMBIENT,
|
||||
"mob/zombie/zombiehurt", // eSoundType_MOB_ZOMBIE_HURT,
|
||||
"mob/zombie/zombiedeath", // eSoundType_MOB_ZOMBIE_DEATH,
|
||||
"mob/zombie/wood", // eSoundType_MOB_ZOMBIE_WOOD,
|
||||
"mob/zombie/woodbreak", // eSoundType_MOB_ZOMBIE_WOOD_BREAK,
|
||||
"mob/zombie/metal", // eSoundType_MOB_ZOMBIE_METAL,
|
||||
"mob/magmacube/big", // eSoundType_MOB_MAGMACUBE_BIG,
|
||||
"mob/magmacube/small", // eSoundType_MOB_MAGMACUBE_SMALL,
|
||||
"mob/cat/purr", // eSoundType_MOB_CAT_PURR
|
||||
"mob/cat/purreow", // eSoundType_MOB_CAT_PURREOW
|
||||
"mob/cat/meow", // eSoundType_MOB_CAT_MEOW
|
||||
// 4J-PB - correct the name of the event for hitting ocelots
|
||||
"mob/cat/hitt", // eSoundType_MOB_CAT_HITT
|
||||
// "mob.irongolem.throw", //
|
||||
// eSoundType_MOB_IRONGOLEM_THROW "mob.irongolem.hit",
|
||||
//// eSoundType_MOB_IRONGOLEM_HIT "mob.irongolem.death",
|
||||
//// eSoundType_MOB_IRONGOLEM_DEATH "mob.irongolem.walk",
|
||||
//// eSoundType_MOB_IRONGOLEM_WALK
|
||||
"random/bow", // eSoundType_RANDOM_BOW,
|
||||
"random/bowhit", // eSoundType_RANDOM_BOW_HIT,
|
||||
"random/explode", // eSoundType_RANDOM_EXPLODE,
|
||||
"random/fizz", // eSoundType_RANDOM_FIZZ,
|
||||
"random/pop", // eSoundType_RANDOM_POP,
|
||||
"random/fuse", // eSoundType_RANDOM_FUSE,
|
||||
"random/drink", // eSoundType_RANDOM_DRINK,
|
||||
"random/eat", // eSoundType_RANDOM_EAT,
|
||||
"random/burp", // eSoundType_RANDOM_BURP,
|
||||
"random/splash", // eSoundType_RANDOM_SPLASH,
|
||||
"random/click", // eSoundType_RANDOM_CLICK,
|
||||
"random/glass", // eSoundType_RANDOM_GLASS,
|
||||
"random/orb", // eSoundType_RANDOM_ORB,
|
||||
"random/break", // eSoundType_RANDOM_BREAK,
|
||||
"random/chestopen", // eSoundType_RANDOM_CHEST_OPEN,
|
||||
"random/chestclosed", // eSoundType_RANDOM_CHEST_CLOSE,
|
||||
"random/door_open", // eSoundType_RANDOM_DOOR_OPEN,
|
||||
"random/door_close", // eSoundType_RANDOM_DOOR_CLOSE,
|
||||
"ambient/weather/rain", // eSoundType_AMBIENT_WEATHER_RAIN,
|
||||
"ambient/weather/thunder", // eSoundType_AMBIENT_WEATHER_THUNDER,
|
||||
"ambient/cave/cave", // eSoundType_CAVE_CAVE, DON'T USE FOR XBOX 360!!!
|
||||
"portal/portal", // eSoundType_PORTAL_PORTAL,
|
||||
// 4J-PB - added a couple that were still using std::string
|
||||
"portal/trigger", // eSoundType_PORTAL_TRIGGER
|
||||
"portal/travel", // eSoundType_PORTAL_TRAVEL
|
||||
|
||||
"fire/ignite", // eSoundType_FIRE_IGNITE,
|
||||
"fire/fire", // eSoundType_FIRE_FIRE,
|
||||
"damage/hit", // eSoundType_DAMAGE_HURT,
|
||||
"damage/fallsmall", // eSoundType_DAMAGE_FALL_SMALL,
|
||||
"damage/fallbig", // eSoundType_DAMAGE_FALL_BIG,
|
||||
"note/harp", // eSoundType_NOTE_HARP,
|
||||
"note/bd", // eSoundType_NOTE_BD,
|
||||
"note/snare", // eSoundType_NOTE_SNARE,
|
||||
"note/hat", // eSoundType_NOTE_HAT,
|
||||
"note/bassattack", // eSoundType_NOTE_BASSATTACK,
|
||||
"tile/piston.in", // eSoundType_TILE_PISTON_IN,
|
||||
"tile/piston.out", // eSoundType_TILE_PISTON_OUT,
|
||||
"liquid/water", // eSoundType_LIQUID_WATER,
|
||||
"liquid/lavapop", // eSoundType_LIQUID_LAVA_POP,
|
||||
"liquid/lava", // eSoundType_LIQUID_LAVA,
|
||||
"step/stone", // eSoundType_STEP_STONE,
|
||||
"step/wood", // eSoundType_STEP_WOOD,
|
||||
"step/gravel", // eSoundType_STEP_GRAVEL,
|
||||
"step/grass", // eSoundType_STEP_GRASS,
|
||||
"step/metal", // eSoundType_STEP_METAL,
|
||||
"step/cloth", // eSoundType_STEP_CLOTH,
|
||||
"step/sand", // eSoundType_STEP_SAND,
|
||||
|
||||
// below this are the additional sounds from the second soundbank
|
||||
"mob/enderdragon/end", // eSoundType_MOB_ENDERDRAGON_END
|
||||
"mob/enderdragon/growl", // eSoundType_MOB_ENDERDRAGON_GROWL
|
||||
"mob/enderdragon/hit", // eSoundType_MOB_ENDERDRAGON_HIT
|
||||
"mob/enderdragon/wings", // eSoundType_MOB_ENDERDRAGON_MOVE
|
||||
"mob/irongolem/throw", // eSoundType_MOB_IRONGOLEM_THROW
|
||||
"mob/irongolem/hit", // eSoundType_MOB_IRONGOLEM_HIT
|
||||
"mob/irongolem/death", // eSoundType_MOB_IRONGOLEM_DEATH
|
||||
"mob/irongolem/walk", // eSoundType_MOB_IRONGOLEM_WALK
|
||||
|
||||
// TU14
|
||||
"damage/thorns", // eSoundType_DAMAGE_THORNS
|
||||
"random/anvil_break", // eSoundType_RANDOM_ANVIL_BREAK
|
||||
"random/anvil_land", // eSoundType_RANDOM_ANVIL_LAND
|
||||
"random/anvil_use", // eSoundType_RANDOM_ANVIL_USE
|
||||
"mob/villager/haggle", // eSoundType_MOB_VILLAGER_HAGGLE
|
||||
"mob/villager/idle", // eSoundType_MOB_VILLAGER_IDLE
|
||||
"mob/villager/hit", // eSoundType_MOB_VILLAGER_HIT
|
||||
"mob/villager/death", // eSoundType_MOB_VILLAGER_DEATH
|
||||
"mob/villager/yes", // eSoundType_MOB_VILLAGER_YES
|
||||
"mob/villager/no", // eSoundType_MOB_VILLAGER_NO
|
||||
"mob/zombie/infect", // eSoundType_MOB_ZOMBIE_INFECT
|
||||
"mob/zombie/unfect", // eSoundType_MOB_ZOMBIE_UNFECT
|
||||
"mob/zombie/remedy", // eSoundType_MOB_ZOMBIE_REMEDY
|
||||
"step/snow", // eSoundType_STEP_SNOW
|
||||
"step/ladder", // eSoundType_STEP_LADDER
|
||||
"dig/cloth", // eSoundType_DIG_CLOTH
|
||||
"dig/grass", // eSoundType_DIG_GRASS
|
||||
"dig/gravel", // eSoundType_DIG_GRAVEL
|
||||
"dig/sand", // eSoundType_DIG_SAND
|
||||
"dig/snow", // eSoundType_DIG_SNOW
|
||||
"dig/stone", // eSoundType_DIG_STONE
|
||||
"dig/wood", // eSoundType_DIG_WOOD
|
||||
|
||||
// 1.6.4
|
||||
"fireworks/launch", // eSoundType_FIREWORKS_LAUNCH,
|
||||
"fireworks/blast", // eSoundType_FIREWORKS_BLAST,
|
||||
"fireworks/blast_far", // eSoundType_FIREWORKS_BLAST_FAR,
|
||||
"fireworks/large_blast", // eSoundType_FIREWORKS_LARGE_BLAST,
|
||||
"fireworks/large_blast_far", // eSoundType_FIREWORKS_LARGE_BLAST_FAR,
|
||||
"fireworks/twinkle", // eSoundType_FIREWORKS_TWINKLE,
|
||||
"fireworks/twinkle_far", // eSoundType_FIREWORKS_TWINKLE_FAR,
|
||||
|
||||
"mob/bat/idle", // eSoundType_MOB_BAT_IDLE,
|
||||
"mob/bat/hurt", // eSoundType_MOB_BAT_HURT,
|
||||
"mob/bat/death", // eSoundType_MOB_BAT_DEATH,
|
||||
"mob/bat/takeoff", // eSoundType_MOB_BAT_TAKEOFF,
|
||||
|
||||
"mob/wither/spawn", // eSoundType_MOB_WITHER_SPAWN,
|
||||
"mob/wither/idle", // eSoundType_MOB_WITHER_IDLE,
|
||||
"mob/wither/hurt", // eSoundType_MOB_WITHER_HURT,
|
||||
"mob/wither/death", // eSoundType_MOB_WITHER_DEATH,
|
||||
"mob/wither/shoot", // eSoundType_MOB_WITHER_SHOOT,
|
||||
|
||||
"mob/cow/step", // eSoundType_MOB_COW_STEP,
|
||||
"mob/chicken/step", // eSoundType_MOB_CHICKEN_STEP,
|
||||
"mob/pig/step", // eSoundType_MOB_PIG_STEP,
|
||||
"mob/enderman/stare", // eSoundType_MOB_ENDERMAN_STARE,
|
||||
"mob/enderman/scream", // eSoundType_MOB_ENDERMAN_SCREAM,
|
||||
"mob/sheep/shear", // eSoundType_MOB_SHEEP_SHEAR,
|
||||
"mob/sheep/step", // eSoundType_MOB_SHEEP_STEP,
|
||||
"mob/skeleton.death", // eSoundType_MOB_SKELETON_DEATH,
|
||||
"mob/skeleton/step", // eSoundType_MOB_SKELETON_STEP,
|
||||
"mob/spider/step", // eSoundType_MOB_SPIDER_STEP,
|
||||
"mob/wolf/step", // eSoundType_MOB_WOLF_STEP,
|
||||
"mob/zombie/step", // eSoundType_MOB_ZOMBIE_STEP,
|
||||
|
||||
"liquid/swim", // eSoundType_LIQUID_SWIM,
|
||||
|
||||
"mob/horse/land", // eSoundType_MOB_HORSE_LAND,
|
||||
"mob/horse/armor", // eSoundType_MOB_HORSE_ARMOR,
|
||||
"mob/horse/leather", // eSoundType_MOB_HORSE_LEATHER,
|
||||
"mob/horse/zombie.death", // eSoundType_MOB_HORSE_ZOMBIE_DEATH,
|
||||
"mob/horse/skeleton.death", // eSoundType_MOB_HORSE_SKELETON_DEATH,
|
||||
"mob/horse/donkey.death", // eSoundType_MOB_HORSE_DONKEY_DEATH,
|
||||
"mob/horse/death", // eSoundType_MOB_HORSE_DEATH,
|
||||
"mob/horse/zombie.hit", // eSoundType_MOB_HORSE_ZOMBIE_HIT,
|
||||
"mob/horse/skeleton.hit", // eSoundType_MOB_HORSE_SKELETON_HIT,
|
||||
"mob/horse/donkey.hit", // eSoundType_MOB_HORSE_DONKEY_HIT,
|
||||
"mob/horse/hit", // eSoundType_MOB_HORSE_HIT,
|
||||
"mob/horse/zombie.idle", // eSoundType_MOB_HORSE_ZOMBIE_IDLE,
|
||||
"mob/horse/skeleton.idle", // eSoundType_MOB_HORSE_SKELETON_IDLE,
|
||||
"mob/horse/donkey.idle", // eSoundType_MOB_HORSE_DONKEY_IDLE,
|
||||
"mob/horse/idle", // eSoundType_MOB_HORSE_IDLE,
|
||||
"mob/horse/donkey.angry", // eSoundType_MOB_HORSE_DONKEY_ANGRY,
|
||||
"mob/horse/angry", // eSoundType_MOB_HORSE_ANGRY,
|
||||
"mob/horse/gallop", // eSoundType_MOB_HORSE_GALLOP,
|
||||
"mob/horse/breathe", // eSoundType_MOB_HORSE_BREATHE,
|
||||
"mob/horse/wood", // eSoundType_MOB_HORSE_WOOD,
|
||||
"mob/horse/soft", // eSoundType_MOB_HORSE_SOFT,
|
||||
"mob/horse/jump", // eSoundType_MOB_HORSE_JUMP,
|
||||
|
||||
"mob/witch/idle", // eSoundType_MOB_WITCH_IDLE, <---
|
||||
// missing
|
||||
"mob/witch/hurt", // eSoundType_MOB_WITCH_HURT, <---
|
||||
// missing
|
||||
"mob/witch/death", // eSoundType_MOB_WITCH_DEATH, <---
|
||||
// missing
|
||||
|
||||
"mob/slime/big", // eSoundType_MOB_SLIME_BIG,
|
||||
"mob/slime/small", // eSoundType_MOB_SLIME_SMALL,
|
||||
|
||||
"eating", // eSoundType_EATING <--- missing
|
||||
"random/levelup", // eSoundType_RANDOM_LEVELUP
|
||||
|
||||
// 4J-PB - Some sounds were updated, but we can't do that for the 360 or we
|
||||
// have to do a new sound bank instead, we'll add the sounds as new ones and
|
||||
// change the code to reference them
|
||||
"fire/new_ignite",
|
||||
};
|
||||
|
||||
const char* ConsoleSoundEngine::wchUISoundNames[eSFX_MAX] = {
|
||||
"back", "craft", "craftfail", "focus", "press", "scroll",
|
||||
};
|
||||
@@ -239,125 +239,125 @@ enum eMATERIALSOUND_TYPE {
|
||||
/*
|
||||
enum eSOUND_TYPE
|
||||
{
|
||||
L"mob.chicken",
|
||||
L"mob.chickenhurt",
|
||||
L"mob.chickenplop",
|
||||
"mob.chicken",
|
||||
"mob.chickenhurt",
|
||||
"mob.chickenplop",
|
||||
|
||||
L"mob.cow",
|
||||
L"mob.cowhurt",
|
||||
"mob.cow",
|
||||
"mob.cowhurt",
|
||||
|
||||
L"mob.pig",
|
||||
L"mob.pigdeath",
|
||||
"mob.pig",
|
||||
"mob.pigdeath",
|
||||
|
||||
L"mob.sheep",
|
||||
"mob.sheep",
|
||||
|
||||
L"mob.wolf.growl",
|
||||
L"mob.wolf.whine",
|
||||
L"mob.wolf.panting",
|
||||
L"mob.wolf.bark",
|
||||
L"mob.wolf.hurt",
|
||||
L"mob.wolf.death",
|
||||
L"mob.wolf.shake",
|
||||
"mob.wolf.growl",
|
||||
"mob.wolf.whine",
|
||||
"mob.wolf.panting",
|
||||
"mob.wolf.bark",
|
||||
"mob.wolf.hurt",
|
||||
"mob.wolf.death",
|
||||
"mob.wolf.shake",
|
||||
|
||||
L"mob.blaze.breathe",
|
||||
L"mob.blaze.hit",
|
||||
L"mob.blaze.death",
|
||||
"mob.blaze.breathe",
|
||||
"mob.blaze.hit",
|
||||
"mob.blaze.death",
|
||||
|
||||
L"mob.ghast.moan",
|
||||
L"mob.ghast.scream",
|
||||
L"mob.ghast.death",
|
||||
L"mob.ghast.fireball",
|
||||
L"mob.ghast.charge",
|
||||
"mob.ghast.moan",
|
||||
"mob.ghast.scream",
|
||||
"mob.ghast.death",
|
||||
"mob.ghast.fireball",
|
||||
"mob.ghast.charge",
|
||||
|
||||
L"mob.endermen.idle",
|
||||
L"mob.endermen.hit",
|
||||
L"mob.endermen.death",
|
||||
L"mob.endermen.portal",
|
||||
"mob.endermen.idle",
|
||||
"mob.endermen.hit",
|
||||
"mob.endermen.death",
|
||||
"mob.endermen.portal",
|
||||
|
||||
L"mob.zombiepig.zpig",
|
||||
L"mob.zombiepig.zpighurt",
|
||||
L"mob.zombiepig.zpigdeath",
|
||||
L"mob.zombiepig.zpigangry",
|
||||
"mob.zombiepig.zpig",
|
||||
"mob.zombiepig.zpighurt",
|
||||
"mob.zombiepig.zpigdeath",
|
||||
"mob.zombiepig.zpigangry",
|
||||
|
||||
L"mob.silverfish.say",
|
||||
L"mob.silverfish.hit",
|
||||
L"mob.silverfish.kill",
|
||||
L"mob.silverfish.step",
|
||||
"mob.silverfish.say",
|
||||
"mob.silverfish.hit",
|
||||
"mob.silverfish.kill",
|
||||
"mob.silverfish.step",
|
||||
|
||||
L"mob.skeleton",
|
||||
L"mob.skeleton.hurt",
|
||||
"mob.skeleton",
|
||||
"mob.skeleton.hurt",
|
||||
|
||||
L"mob.spider",
|
||||
L"mob.spiderdeath",
|
||||
"mob.spider",
|
||||
"mob.spiderdeath",
|
||||
|
||||
L"mob.slime",
|
||||
L"mob.slimeattack",
|
||||
"mob.slime",
|
||||
"mob.slimeattack",
|
||||
|
||||
L"mob.creeper",
|
||||
L"mob.creeperdeath",
|
||||
"mob.creeper",
|
||||
"mob.creeperdeath",
|
||||
|
||||
L"mob.zombie",
|
||||
L"mob.zombiehurt",
|
||||
L"mob.zombiedeath",
|
||||
L"mob.zombie.wood",
|
||||
L"mob.zombie.woodbreak",
|
||||
L"mob.zombie.metal",
|
||||
"mob.zombie",
|
||||
"mob.zombiehurt",
|
||||
"mob.zombiedeath",
|
||||
"mob.zombie.wood",
|
||||
"mob.zombie.woodbreak",
|
||||
"mob.zombie.metal",
|
||||
|
||||
L"mob.magmacube.big",
|
||||
L"mob.magmacube.small",
|
||||
"mob.magmacube.big",
|
||||
"mob.magmacube.small",
|
||||
|
||||
L"random.bow",
|
||||
L"random.bowhit",
|
||||
L"random.explode",
|
||||
L"random.fizz",
|
||||
L"random.pop",
|
||||
L"random.fuse",
|
||||
L"random.drink",
|
||||
L"random.eat",
|
||||
L"random.burp",
|
||||
L"random.splash",
|
||||
L"random.click",
|
||||
L"random.glass",
|
||||
L"random.orb",
|
||||
L"random.break",
|
||||
L"random.chestopen",
|
||||
L"random.chestclosed",
|
||||
L"random.door_open",
|
||||
L"random.door_close",
|
||||
"random.bow",
|
||||
"random.bowhit",
|
||||
"random.explode",
|
||||
"random.fizz",
|
||||
"random.pop",
|
||||
"random.fuse",
|
||||
"random.drink",
|
||||
"random.eat",
|
||||
"random.burp",
|
||||
"random.splash",
|
||||
"random.click",
|
||||
"random.glass",
|
||||
"random.orb",
|
||||
"random.break",
|
||||
"random.chestopen",
|
||||
"random.chestclosed",
|
||||
"random.door_open",
|
||||
"random.door_close",
|
||||
|
||||
L"ambient.weather.rain",
|
||||
L"ambient.weather.thunder",
|
||||
"ambient.weather.rain",
|
||||
"ambient.weather.thunder",
|
||||
|
||||
L"ambient.cave.cave",
|
||||
"ambient.cave.cave",
|
||||
|
||||
L"portal.portal",
|
||||
"portal.portal",
|
||||
|
||||
L"fire.ignite",
|
||||
L"fire.fire",
|
||||
"fire.ignite",
|
||||
"fire.fire",
|
||||
|
||||
L"damage.hurtflesh",
|
||||
L"damage.fallsmall",
|
||||
L"damage.fallbig",
|
||||
"damage.hurtflesh",
|
||||
"damage.fallsmall",
|
||||
"damage.fallbig",
|
||||
|
||||
L"note.harp",
|
||||
L"note.bd",
|
||||
L"note.snare",
|
||||
L"note.hat",
|
||||
L"note.bassattack",
|
||||
"note.harp",
|
||||
"note.bd",
|
||||
"note.snare",
|
||||
"note.hat",
|
||||
"note.bassattack",
|
||||
|
||||
L"tile.piston.in",
|
||||
L"tile.piston.out",
|
||||
"tile.piston.in",
|
||||
"tile.piston.out",
|
||||
|
||||
L"liquid.water",
|
||||
L"liquid.lavapop",
|
||||
L"liquid.lava",
|
||||
"liquid.water",
|
||||
"liquid.lavapop",
|
||||
"liquid.lava",
|
||||
|
||||
L"step.stone",
|
||||
L"step.wood",
|
||||
L"step.gravel",
|
||||
L"step.grass",
|
||||
L"step.metal",
|
||||
L"step.cloth",
|
||||
L"step.sand",
|
||||
"step.stone",
|
||||
"step.wood",
|
||||
"step.gravel",
|
||||
"step.grass",
|
||||
"step.metal",
|
||||
"step.cloth",
|
||||
"step.sand",
|
||||
|
||||
};*/
|
||||
@@ -0,0 +1,128 @@
|
||||
#include "app/common/BannedListManager.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "platform/XboxStubs.h"
|
||||
|
||||
BannedListManager::BannedListManager() {
|
||||
m_pBannedListFileBuffer = nullptr;
|
||||
m_dwBannedListFileSize = 0;
|
||||
std::memset(m_pszUniqueMapName, 0, 14);
|
||||
|
||||
for (int i = 0; i < XUSER_MAX_COUNT; i++) {
|
||||
m_bRead_BannedListA[i] = false;
|
||||
m_BanListCheck[i] = false;
|
||||
m_vBannedListA[i] = new std::vector<PBANNEDLISTDATA>;
|
||||
}
|
||||
}
|
||||
|
||||
void BannedListManager::invalidate(int iPad) {
|
||||
if (m_bRead_BannedListA[iPad] == true) {
|
||||
m_bRead_BannedListA[iPad] = false;
|
||||
setBanListCheck(iPad, false);
|
||||
m_vBannedListA[iPad]->clear();
|
||||
|
||||
if (BannedListA[iPad].pBannedList) {
|
||||
delete[] BannedListA[iPad].pBannedList;
|
||||
BannedListA[iPad].pBannedList = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BannedListManager::addLevel(int iPad, PlayerUID xuid, char* pszLevelName,
|
||||
bool bWriteToTMS) {
|
||||
// we will have retrieved the banned level list from TMS, so add this one to
|
||||
// it and write it back to TMS
|
||||
|
||||
BANNEDLISTDATA* pBannedListData = new BANNEDLISTDATA;
|
||||
memset(pBannedListData, 0, sizeof(BANNEDLISTDATA));
|
||||
|
||||
memcpy(&pBannedListData->xuid, &xuid, sizeof(PlayerUID));
|
||||
strcpy(pBannedListData->pszLevelName, pszLevelName);
|
||||
m_vBannedListA[iPad]->push_back(pBannedListData);
|
||||
|
||||
if (bWriteToTMS) {
|
||||
const std::size_t bannedListCount = m_vBannedListA[iPad]->size();
|
||||
const unsigned int dataBytes =
|
||||
static_cast<unsigned int>(sizeof(BANNEDLISTDATA) * bannedListCount);
|
||||
PBANNEDLISTDATA pBannedList = new BANNEDLISTDATA[bannedListCount];
|
||||
int iCount = 0;
|
||||
for (auto it = m_vBannedListA[iPad]->begin();
|
||||
it != m_vBannedListA[iPad]->end(); ++it) {
|
||||
PBANNEDLISTDATA pData = *it;
|
||||
memcpy(&pBannedList[iCount++], pData, sizeof(BANNEDLISTDATA));
|
||||
}
|
||||
|
||||
// 4J-PB - write to TMS++ now
|
||||
|
||||
// bool
|
||||
// bRes=PlatformStorage.WriteTMSFile(iPad,IPlatformStorage::eGlobalStorage_TitleUser,"BannedList",(std::uint8_t*)pBannedList,
|
||||
// dwDataBytes);
|
||||
|
||||
delete[] pBannedList;
|
||||
}
|
||||
// update telemetry too
|
||||
}
|
||||
|
||||
bool BannedListManager::isInList(int iPad, PlayerUID xuid, char* pszLevelName) {
|
||||
for (auto it = m_vBannedListA[iPad]->begin();
|
||||
it != m_vBannedListA[iPad]->end(); ++it) {
|
||||
PBANNEDLISTDATA pData = *it;
|
||||
if (IsEqualXUID(pData->xuid, xuid) &&
|
||||
(strcmp(pData->pszLevelName, pszLevelName) == 0)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void BannedListManager::removeLevel(int iPad, PlayerUID xuid,
|
||||
char* pszLevelName) {
|
||||
// bool bFound=false;
|
||||
// bool bRes;
|
||||
|
||||
// we will have retrieved the banned level list from TMS, so remove this one
|
||||
// from it and write it back to TMS
|
||||
for (auto it = m_vBannedListA[iPad]->begin();
|
||||
it != m_vBannedListA[iPad]->end();) {
|
||||
PBANNEDLISTDATA pBannedListData = *it;
|
||||
|
||||
if (pBannedListData != nullptr) {
|
||||
if (IsEqualXUID(pBannedListData->xuid, xuid) &&
|
||||
(strcmp(pBannedListData->pszLevelName, pszLevelName) == 0)) {
|
||||
// match found, so remove this entry
|
||||
it = m_vBannedListA[iPad]->erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
const std::size_t bannedListCount = m_vBannedListA[iPad]->size();
|
||||
const unsigned int dataBytes =
|
||||
static_cast<unsigned int>(sizeof(BANNEDLISTDATA) * bannedListCount);
|
||||
if (dataBytes == 0) {
|
||||
// wipe the file
|
||||
} else {
|
||||
PBANNEDLISTDATA pBannedList =
|
||||
(BANNEDLISTDATA*)(new std::uint8_t[dataBytes]);
|
||||
|
||||
for (std::size_t i = 0; i < bannedListCount; ++i) {
|
||||
PBANNEDLISTDATA pBannedListData = m_vBannedListA[iPad]->at(i);
|
||||
|
||||
memcpy(&pBannedList[i], pBannedListData, sizeof(BANNEDLISTDATA));
|
||||
}
|
||||
delete[] pBannedList;
|
||||
}
|
||||
|
||||
// update telemetry too
|
||||
}
|
||||
|
||||
void BannedListManager::setUniqueMapName(char* pszUniqueMapName) {
|
||||
memcpy(m_pszUniqueMapName, pszUniqueMapName, 14);
|
||||
}
|
||||
|
||||
char* BannedListManager::getUniqueMapName() { return m_pszUniqueMapName; }
|
||||
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
#include "app/common/App_structs.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
|
||||
class BannedListManager {
|
||||
public:
|
||||
BannedListManager();
|
||||
|
||||
void invalidate(int iPad);
|
||||
void addLevel(int iPad, PlayerUID xuid, char* pszLevelName,
|
||||
bool bWriteToTMS);
|
||||
bool isInList(int iPad, PlayerUID xuid, char* pszLevelName);
|
||||
void removeLevel(int iPad, PlayerUID xuid, char* pszLevelName);
|
||||
|
||||
void setUniqueMapName(char* pszUniqueMapName);
|
||||
char* getUniqueMapName();
|
||||
|
||||
void setBanListCheck(int iPad, bool bVal) { m_BanListCheck[iPad] = bVal; }
|
||||
bool getBanListCheck(int iPad) const { return m_BanListCheck[iPad]; }
|
||||
|
||||
bool getBanListRead(int iPad) const { return m_bRead_BannedListA[iPad]; }
|
||||
void setBanListRead(int iPad, bool bVal) {
|
||||
m_bRead_BannedListA[iPad] = bVal;
|
||||
}
|
||||
|
||||
void clearBanList(int iPad) {
|
||||
BannedListA[iPad].pBannedList = nullptr;
|
||||
BannedListA[iPad].byteCount = 0;
|
||||
}
|
||||
|
||||
BANNEDLIST BannedListA[XUSER_MAX_COUNT];
|
||||
|
||||
std::uint8_t* m_pBannedListFileBuffer;
|
||||
unsigned int m_dwBannedListFileSize;
|
||||
|
||||
private:
|
||||
VBANNEDLIST* m_vBannedListA[XUSER_MAX_COUNT];
|
||||
bool m_bRead_BannedListA[XUSER_MAX_COUNT];
|
||||
char m_pszUniqueMapName[14];
|
||||
bool m_BanListCheck[XUSER_MAX_COUNT];
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "ConsoleGameMode.h"
|
||||
|
||||
#include "app/common/src/Tutorial/Tutorial.h"
|
||||
#include "app/common/src/Tutorial/TutorialMode.h"
|
||||
#include "app/common/Tutorial/Tutorial.h"
|
||||
#include "app/common/Tutorial/TutorialMode.h"
|
||||
|
||||
class ClientConnection;
|
||||
class Minecraft;
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "app/common/src/Tutorial/TutorialMode.h"
|
||||
#include "app/common/Tutorial/TutorialMode.h"
|
||||
|
||||
class ClientConnection;
|
||||
class Minecraft;
|
||||
@@ -5,40 +5,17 @@
|
||||
#include <cstring>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "platform/sdl2/Render.h"
|
||||
#include "platform/sdl2/Storage.h"
|
||||
#include "DLCManager.h"
|
||||
#include "app/common/src/DLC/DLCFile.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "app/include/XboxStubs.h"
|
||||
#if defined(_WINDOWS64)
|
||||
#include "app/windows/XML/ATGXmlParser.h"
|
||||
#include "app/windows/XML/xmlFilesCallback.h"
|
||||
#endif
|
||||
#include "app/common/DLC/DLCFile.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
#include "platform/renderer/renderer.h"
|
||||
#include "platform/storage/storage.h"
|
||||
#include "util/StringHelpers.h"
|
||||
|
||||
namespace {
|
||||
constexpr std::size_t AUDIO_DLC_WCHAR_BIN_SIZE = 2;
|
||||
|
||||
#if WCHAR_MAX > 0xFFFF
|
||||
static std::wstring ReadAudioDlcWString(const void* data) {
|
||||
const std::uint16_t* chars = static_cast<const std::uint16_t*>(data);
|
||||
const std::uint16_t* end = chars;
|
||||
while (*end != 0) {
|
||||
++end;
|
||||
}
|
||||
|
||||
std::wstring out(static_cast<std::size_t>(end - chars), 0);
|
||||
for (std::size_t i = 0; i < out.size(); ++i) {
|
||||
out[i] = static_cast<wchar_t>(chars[i]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
#else
|
||||
static std::wstring ReadAudioDlcWString(const void* data) {
|
||||
return std::wstring(static_cast<const wchar_t*>(data));
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
T ReadAudioDlcValue(const std::uint8_t* data, unsigned int offset = 0) {
|
||||
T value;
|
||||
@@ -53,23 +30,24 @@ void ReadAudioDlcStruct(T* out, const std::uint8_t* data,
|
||||
}
|
||||
|
||||
inline unsigned int AudioParamAdvance(unsigned int wcharCount) {
|
||||
return static_cast<unsigned int>(sizeof(C4JStorage::DLC_FILE_PARAM) +
|
||||
return static_cast<unsigned int>(sizeof(IPlatformStorage::DLC_FILE_PARAM) +
|
||||
wcharCount * AUDIO_DLC_WCHAR_BIN_SIZE);
|
||||
}
|
||||
|
||||
inline unsigned int AudioDetailAdvance(unsigned int wcharCount) {
|
||||
return static_cast<unsigned int>(sizeof(C4JStorage::DLC_FILE_DETAILS) +
|
||||
wcharCount * AUDIO_DLC_WCHAR_BIN_SIZE);
|
||||
return static_cast<unsigned int>(
|
||||
sizeof(IPlatformStorage::DLC_FILE_DETAILS) +
|
||||
wcharCount * AUDIO_DLC_WCHAR_BIN_SIZE);
|
||||
}
|
||||
|
||||
inline std::wstring ReadAudioParamString(const std::uint8_t* data,
|
||||
unsigned int offset) {
|
||||
return ReadAudioDlcWString(data + offset +
|
||||
offsetof(C4JStorage::DLC_FILE_PARAM, wchData));
|
||||
inline std::string ReadAudioParamString(const std::uint8_t* data,
|
||||
unsigned int offset) {
|
||||
return dlc_read_wstring(
|
||||
data + offset + offsetof(IPlatformStorage::DLC_FILE_PARAM, wchData));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
DLCAudioFile::DLCAudioFile(const std::wstring& path)
|
||||
DLCAudioFile::DLCAudioFile(const std::string& path)
|
||||
: DLCFile(DLCManager::e_DLCType_Audio, path) {
|
||||
m_pbData = nullptr;
|
||||
m_dataBytes = 0;
|
||||
@@ -87,13 +65,13 @@ std::uint8_t* DLCAudioFile::getData(std::uint32_t& dataBytes) {
|
||||
return m_pbData;
|
||||
}
|
||||
|
||||
const wchar_t* DLCAudioFile::wchTypeNamesA[] = {
|
||||
L"CUENAME",
|
||||
L"CREDIT",
|
||||
const char* DLCAudioFile::wchTypeNamesA[] = {
|
||||
"CUENAME",
|
||||
"CREDIT",
|
||||
};
|
||||
|
||||
DLCAudioFile::EAudioParameterType DLCAudioFile::getParameterType(
|
||||
const std::wstring& paramName) {
|
||||
const std::string& paramName) {
|
||||
EAudioParameterType type = e_AudioParamType_Invalid;
|
||||
|
||||
for (int i = 0; i < e_AudioParamType_Max; ++i) {
|
||||
@@ -107,7 +85,7 @@ DLCAudioFile::EAudioParameterType DLCAudioFile::getParameterType(
|
||||
}
|
||||
|
||||
void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype,
|
||||
const std::wstring& value) {
|
||||
const std::string& value) {
|
||||
switch (ptype) {
|
||||
case e_AudioParamType_Credit: // If this parameter exists, then mark
|
||||
// this as free
|
||||
@@ -122,8 +100,8 @@ void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype,
|
||||
|
||||
int maximumChars = 55;
|
||||
|
||||
bool bIsSDMode =
|
||||
!RenderManager.IsHiDef() && !RenderManager.IsWidescreen();
|
||||
bool bIsSDMode = !PlatformRenderer.IsHiDef() &&
|
||||
!PlatformRenderer.IsWidescreen();
|
||||
|
||||
if (bIsSDMode) {
|
||||
maximumChars = 45;
|
||||
@@ -136,14 +114,14 @@ void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype,
|
||||
maximumChars = 35;
|
||||
break;
|
||||
}
|
||||
std::wstring creditValue = value;
|
||||
std::string creditValue = value;
|
||||
while (creditValue.length() > maximumChars) {
|
||||
unsigned int i = 1;
|
||||
while (i < creditValue.length() &&
|
||||
(i + 1) <= maximumChars) {
|
||||
i++;
|
||||
}
|
||||
int iLast = (int)creditValue.find_last_of(L" ", i);
|
||||
int iLast = (int)creditValue.find_last_of(" ", i);
|
||||
switch (XGetLanguage()) {
|
||||
case XC_LANGUAGE_JAPANESE:
|
||||
case XC_LANGUAGE_TCHINESE:
|
||||
@@ -151,7 +129,7 @@ void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype,
|
||||
iLast = maximumChars;
|
||||
break;
|
||||
default:
|
||||
iLast = (int)creditValue.find_last_of(L" ", i);
|
||||
iLast = (int)creditValue.find_last_of(" ", i);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -196,14 +174,13 @@ bool DLCAudioFile::processDLCDataFile(std::uint8_t* pbData,
|
||||
unsigned int uiParameterTypeCount =
|
||||
ReadAudioDlcValue<unsigned int>(pbData, uiCurrentByte);
|
||||
uiCurrentByte += sizeof(int);
|
||||
C4JStorage::DLC_FILE_PARAM paramBuf;
|
||||
IPlatformStorage::DLC_FILE_PARAM paramBuf;
|
||||
ReadAudioDlcStruct(¶mBuf, pbData, uiCurrentByte);
|
||||
|
||||
for (unsigned int i = 0; i < uiParameterTypeCount; i++) {
|
||||
// Map DLC strings to application strings, then store the DLC index
|
||||
// mapping to application index
|
||||
std::wstring parameterName =
|
||||
ReadAudioParamString(pbData, uiCurrentByte);
|
||||
std::string parameterName = ReadAudioParamString(pbData, uiCurrentByte);
|
||||
EAudioParameterType type = getParameterType(parameterName);
|
||||
if (type != e_AudioParamType_Invalid) {
|
||||
parameterMapping[paramBuf.dwType] = type;
|
||||
@@ -214,7 +191,7 @@ bool DLCAudioFile::processDLCDataFile(std::uint8_t* pbData,
|
||||
unsigned int uiFileCount =
|
||||
ReadAudioDlcValue<unsigned int>(pbData, uiCurrentByte);
|
||||
uiCurrentByte += sizeof(int);
|
||||
C4JStorage::DLC_FILE_DETAILS fileBuf;
|
||||
IPlatformStorage::DLC_FILE_DETAILS fileBuf;
|
||||
ReadAudioDlcStruct(&fileBuf, pbData, uiCurrentByte);
|
||||
|
||||
unsigned int tempByteOffset = uiCurrentByte;
|
||||
@@ -257,7 +234,7 @@ int DLCAudioFile::GetCountofType(DLCAudioFile::EAudioType eType) {
|
||||
return m_parameters[eType].size();
|
||||
}
|
||||
|
||||
std::wstring& DLCAudioFile::GetSoundName(int iIndex) {
|
||||
std::string& DLCAudioFile::GetSoundName(int iIndex) {
|
||||
int iWorldType = e_AudioType_Overworld;
|
||||
while (iIndex >= m_parameters[iWorldType].size()) {
|
||||
iIndex -= m_parameters[iWorldType].size();
|
||||
@@ -27,16 +27,16 @@ public:
|
||||
e_AudioParamType_Max,
|
||||
|
||||
};
|
||||
static const wchar_t* wchTypeNamesA[e_AudioParamType_Max];
|
||||
static const char* wchTypeNamesA[e_AudioParamType_Max];
|
||||
|
||||
DLCAudioFile(const std::wstring& path);
|
||||
DLCAudioFile(const std::string& path);
|
||||
|
||||
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
|
||||
virtual std::uint8_t* getData(std::uint32_t& dataBytes);
|
||||
|
||||
bool processDLCDataFile(std::uint8_t* pbData, std::uint32_t dataLength);
|
||||
int GetCountofType(DLCAudioFile::EAudioType ptype);
|
||||
std::wstring& GetSoundName(int iIndex);
|
||||
std::string& GetSoundName(int iIndex);
|
||||
|
||||
private:
|
||||
using DLCFile::addParameter;
|
||||
@@ -44,13 +44,13 @@ private:
|
||||
std::uint8_t* m_pbData;
|
||||
std::uint32_t m_dataBytes;
|
||||
static const int CURRENT_AUDIO_VERSION_NUM = 1;
|
||||
// std::unordered_map<int, std::wstring> m_parameters;
|
||||
std::vector<std::wstring> m_parameters[e_AudioType_Max];
|
||||
// std::unordered_map<int, std::string> m_parameters;
|
||||
std::vector<std::string> m_parameters[e_AudioType_Max];
|
||||
|
||||
// use the EAudioType to order these
|
||||
void addParameter(DLCAudioFile::EAudioType type,
|
||||
DLCAudioFile::EAudioParameterType ptype,
|
||||
const std::wstring& value);
|
||||
const std::string& value);
|
||||
DLCAudioFile::EAudioParameterType getParameterType(
|
||||
const std::wstring& paramName);
|
||||
const std::string& paramName);
|
||||
};
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "DLCCapeFile.h"
|
||||
|
||||
#include "DLCManager.h"
|
||||
#include "app/common/src/DLC/DLCFile.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "app/common/DLC/DLCFile.h"
|
||||
#include "app/common/Game.h"
|
||||
|
||||
DLCCapeFile::DLCCapeFile(const std::wstring& path)
|
||||
DLCCapeFile::DLCCapeFile(const std::string& path)
|
||||
: DLCFile(DLCManager::e_DLCType_Cape, path) {}
|
||||
|
||||
void DLCCapeFile::addData(std::uint8_t* pbData, std::uint32_t dataBytes) {
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
class DLCCapeFile : public DLCFile {
|
||||
public:
|
||||
DLCCapeFile(const std::wstring& path);
|
||||
DLCCapeFile(const std::string& path);
|
||||
|
||||
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
|
||||
};
|
||||
@@ -1,14 +1,14 @@
|
||||
#include "DLCColourTableFile.h"
|
||||
|
||||
#include "DLCManager.h"
|
||||
#include "app/common/src/Colours/ColourTable.h"
|
||||
#include "app/common/src/DLC/DLCFile.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "app/common/DLC/DLCFile.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "minecraft/client/Minecraft.h"
|
||||
#include "minecraft/client/resources/Colours/ColourTable.h"
|
||||
#include "minecraft/client/skins/TexturePack.h"
|
||||
#include "minecraft/client/skins/TexturePackRepository.h"
|
||||
|
||||
DLCColourTableFile::DLCColourTableFile(const std::wstring& path)
|
||||
DLCColourTableFile::DLCColourTableFile(const std::string& path)
|
||||
: DLCFile(DLCManager::e_DLCType_ColourTable, path) {
|
||||
m_colourTable = nullptr;
|
||||
}
|
||||
@@ -11,7 +11,7 @@ private:
|
||||
ColourTable* m_colourTable;
|
||||
|
||||
public:
|
||||
DLCColourTableFile(const std::wstring& path);
|
||||
DLCColourTableFile(const std::string& path);
|
||||
~DLCColourTableFile();
|
||||
|
||||
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
|
||||
@@ -2,20 +2,20 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "app/common/Minecraft_Macros.h"
|
||||
#include "app/common/src/DLC/DLCManager.h"
|
||||
#include "app/common/DLC/DLCManager.h"
|
||||
#include "minecraft/Minecraft_Macros.h"
|
||||
|
||||
DLCFile::DLCFile(DLCManager::EDLCType type, const std::wstring& path) {
|
||||
DLCFile::DLCFile(DLCManager::EDLCType type, const std::string& path) {
|
||||
m_type = type;
|
||||
m_path = path;
|
||||
|
||||
// store the id
|
||||
bool dlcSkin = path.substr(0, 3).compare(L"dlc") == 0;
|
||||
bool dlcSkin = path.substr(0, 3).compare("dlc") == 0;
|
||||
|
||||
if (dlcSkin) {
|
||||
std::wstring skinValue = path.substr(7, path.size());
|
||||
skinValue = skinValue.substr(0, skinValue.find_first_of(L'.'));
|
||||
std::wstringstream ss;
|
||||
std::string skinValue = path.substr(7, path.size());
|
||||
skinValue = skinValue.substr(0, skinValue.find_first_of('.'));
|
||||
std::stringstream ss;
|
||||
ss << std::dec << skinValue.c_str();
|
||||
ss >> m_dwSkinId;
|
||||
m_dwSkinId = MAKE_SKIN_BITMASK(true, m_dwSkinId);
|
||||
@@ -7,15 +7,15 @@
|
||||
class DLCFile {
|
||||
protected:
|
||||
DLCManager::EDLCType m_type;
|
||||
std::wstring m_path;
|
||||
std::string m_path;
|
||||
std::uint32_t m_dwSkinId;
|
||||
|
||||
public:
|
||||
DLCFile(DLCManager::EDLCType type, const std::wstring& path);
|
||||
DLCFile(DLCManager::EDLCType type, const std::string& path);
|
||||
virtual ~DLCFile() {}
|
||||
|
||||
DLCManager::EDLCType getType() { return m_type; }
|
||||
std::wstring getPath() { return m_path; }
|
||||
std::string getPath() { return m_path; }
|
||||
std::uint32_t getSkinID() { return m_dwSkinId; }
|
||||
|
||||
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes) {}
|
||||
@@ -24,11 +24,11 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
virtual void addParameter(DLCManager::EDLCParameterType type,
|
||||
const std::wstring& value) {}
|
||||
const std::string& value) {}
|
||||
|
||||
virtual std::wstring getParameterAsString(
|
||||
virtual std::string getParameterAsString(
|
||||
DLCManager::EDLCParameterType type) {
|
||||
return L"";
|
||||
return "";
|
||||
}
|
||||
virtual bool getParameterAsBool(DLCManager::EDLCParameterType type) {
|
||||
return false;
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "DLCFile.h"
|
||||
#include "minecraft/world/level/GameRules/LevelGenerationOptions.h"
|
||||
|
||||
class DLCGameRules : public DLCFile {
|
||||
public:
|
||||
DLCGameRules(DLCManager::EDLCType type, const std::string& path)
|
||||
: DLCFile(type, path) {}
|
||||
};
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "DLCGameRulesFile.h"
|
||||
|
||||
#include "DLCManager.h"
|
||||
#include "app/common/src/DLC/DLCGameRules.h"
|
||||
#include "app/common/DLC/DLCGameRules.h"
|
||||
|
||||
DLCGameRulesFile::DLCGameRulesFile(const std::wstring& path)
|
||||
DLCGameRulesFile::DLCGameRulesFile(const std::string& path)
|
||||
: DLCGameRules(DLCManager::e_DLCType_GameRules, path) {
|
||||
m_pbData = nullptr;
|
||||
m_dataBytes = 0;
|
||||
@@ -10,7 +10,7 @@ private:
|
||||
std::uint32_t m_dataBytes;
|
||||
|
||||
public:
|
||||
DLCGameRulesFile(const std::wstring& path);
|
||||
DLCGameRulesFile(const std::string& path);
|
||||
|
||||
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
|
||||
virtual std::uint8_t* getData(std::uint32_t& dataBytes);
|
||||
@@ -3,20 +3,20 @@
|
||||
#include <string>
|
||||
|
||||
#include "DLCManager.h"
|
||||
#include "app/common/src/DLC/DLCGameRules.h"
|
||||
#include "app/common/src/GameRules/GameRuleManager.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "app/common/DLC/DLCGameRules.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/GameRules/GameRuleManager.h"
|
||||
|
||||
class StringTable;
|
||||
|
||||
DLCGameRulesHeader::DLCGameRulesHeader(const std::wstring& path)
|
||||
DLCGameRulesHeader::DLCGameRulesHeader(const std::string& path)
|
||||
: DLCGameRules(DLCManager::e_DLCType_GameRulesHeader, path) {
|
||||
m_pbData = nullptr;
|
||||
m_dataBytes = 0;
|
||||
|
||||
m_hasData = false;
|
||||
|
||||
m_grfPath = path.substr(0, path.length() - 4) + L".grf";
|
||||
m_grfPath = path.substr(0, path.length() - 4) + ".grf";
|
||||
|
||||
lgo = nullptr;
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "DLCGameRules.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/LevelGenerationOptions.h"
|
||||
#include "minecraft/world/level/GameRules/LevelGenerationOptions.h"
|
||||
|
||||
class StringTable;
|
||||
|
||||
@@ -21,26 +21,26 @@ public:
|
||||
virtual std::uint32_t getRequiredTexturePackId() {
|
||||
return m_requiredTexturePackId;
|
||||
}
|
||||
virtual std::wstring getDefaultSaveName() { return m_defaultSaveName; }
|
||||
virtual const wchar_t* getWorldName() { return m_worldName.c_str(); }
|
||||
virtual const wchar_t* getDisplayName() { return m_displayName.c_str(); }
|
||||
virtual std::wstring getGrfPath() { return L"GameRules.grf"; }
|
||||
virtual std::string getDefaultSaveName() { return m_defaultSaveName; }
|
||||
virtual const char* getWorldName() { return m_worldName.c_str(); }
|
||||
virtual const char* getDisplayName() { return m_displayName.c_str(); }
|
||||
virtual std::string getGrfPath() { return "GameRules.grf"; }
|
||||
|
||||
virtual void setRequiresTexturePack(bool x) { m_bRequiresTexturePack = x; }
|
||||
virtual void setRequiredTexturePackId(std::uint32_t x) {
|
||||
m_requiredTexturePackId = x;
|
||||
}
|
||||
virtual void setDefaultSaveName(const std::wstring& x) {
|
||||
virtual void setDefaultSaveName(const std::string& x) {
|
||||
m_defaultSaveName = x;
|
||||
}
|
||||
virtual void setWorldName(const std::wstring& x) { m_worldName = x; }
|
||||
virtual void setDisplayName(const std::wstring& x) { m_displayName = x; }
|
||||
virtual void setGrfPath(const std::wstring& x) { m_grfPath = x; }
|
||||
virtual void setWorldName(const std::string& x) { m_worldName = x; }
|
||||
virtual void setDisplayName(const std::string& x) { m_displayName = x; }
|
||||
virtual void setGrfPath(const std::string& x) { m_grfPath = x; }
|
||||
|
||||
LevelGenerationOptions* lgo;
|
||||
|
||||
public:
|
||||
DLCGameRulesHeader(const std::wstring& path);
|
||||
DLCGameRulesHeader(const std::string& path);
|
||||
|
||||
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
|
||||
virtual std::uint8_t* getData(std::uint32_t& dataBytes);
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "DLCLocalisationFile.h"
|
||||
|
||||
#include "DLCManager.h"
|
||||
#include "app/common/DLC/DLCFile.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "minecraft/locale/StringTable.h"
|
||||
|
||||
DLCLocalisationFile::DLCLocalisationFile(const std::string& path)
|
||||
: DLCFile(DLCManager::e_DLCType_LocalisationData, path) {
|
||||
m_strings = nullptr;
|
||||
}
|
||||
|
||||
void DLCLocalisationFile::addData(std::uint8_t* pbData,
|
||||
std::uint32_t dataBytes) {
|
||||
m_strings = new StringTable(
|
||||
std::span<const std::uint8_t>(pbData, dataBytes), app.getLocale());
|
||||
}
|
||||
@@ -11,7 +11,7 @@ private:
|
||||
StringTable* m_strings;
|
||||
|
||||
public:
|
||||
DLCLocalisationFile(const std::wstring& path);
|
||||
DLCLocalisationFile(const std::string& path);
|
||||
DLCLocalisationFile(
|
||||
std::uint8_t* pbData,
|
||||
std::uint32_t dataBytes); // when we load in a texture pack details
|
||||
@@ -13,65 +13,45 @@
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
#include "platform/sdl2/Profile.h"
|
||||
#include "platform/sdl2/Storage.h"
|
||||
#include "DLCFile.h"
|
||||
#include "DLCPack.h"
|
||||
#include "app/common/src/GameRules/GameRuleManager.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "app/linux/Linux_UIController.h"
|
||||
#include "platform/PlatformServices.h"
|
||||
#include "util/StringHelpers.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/GameRules/GameRuleManager.h"
|
||||
#include "app/common/UI/ConsoleUIController.h"
|
||||
#include "minecraft/client/Minecraft.h"
|
||||
#include "minecraft/client/skins/TexturePackRepository.h"
|
||||
#include "platform/fs/fs.h"
|
||||
#include "platform/profile/profile.h"
|
||||
#include "platform/storage/storage.h"
|
||||
#include "simdutf.h"
|
||||
#include "strings.h"
|
||||
#include "util/StringHelpers.h"
|
||||
|
||||
// 4jcraft, this is the size of wchar_t on disk
|
||||
// the DLC was created on windows, with wchar_t beeing 2 bytes and UTF-16
|
||||
static const std::size_t DLC_WCHAR_BIN_SIZE = 2;
|
||||
|
||||
#if WCHAR_MAX > 0xFFFF
|
||||
// than sizeof(wchar_t) != DLC_WCHAR_BIN_SIZE
|
||||
// e.g. Linux and all Posix/Unix systems with wchar_t beeing 4B/32bit
|
||||
static_assert(sizeof(wchar_t) == 4,
|
||||
"wchar_t is not 4bytes but larger than 2bytes ???");
|
||||
|
||||
static inline std::wstring dlc_read_wstring(const void* data) {
|
||||
const std::uint16_t* p = static_cast<const std::uint16_t*>(data);
|
||||
// find the end (nullterminated)
|
||||
const std::uint16_t* end = p;
|
||||
while (*end) {
|
||||
std::string dlc_read_wstring(const void* data) {
|
||||
const char16_t* chars = static_cast<const char16_t*>(data);
|
||||
const char16_t* end = chars;
|
||||
while (*end != 0) {
|
||||
++end;
|
||||
}
|
||||
|
||||
std::size_t len = static_cast<std::size_t>(end - p);
|
||||
const std::size_t len16 = static_cast<std::size_t>(end - chars);
|
||||
std::string result(simdutf::utf8_length_from_utf16le(chars, len16), '\0');
|
||||
auto len = simdutf::convert_utf16le_to_utf8(chars, len16, result.data());
|
||||
result.resize(len);
|
||||
|
||||
// allocate wstring with length len
|
||||
// it will be nullterminated internally, do not worry.
|
||||
std::wstring out(len, 0);
|
||||
|
||||
// and copy them into thje string
|
||||
for (std::size_t i = 0; i < len; ++i) {
|
||||
out[i] = static_cast<wchar_t>(p[i]);
|
||||
}
|
||||
|
||||
return out;
|
||||
return result;
|
||||
}
|
||||
|
||||
#define DLC_WSTRING(ptr) dlc_read_wstring(ptr)
|
||||
|
||||
#else
|
||||
// just in case.
|
||||
static_assert(sizeof(wchar_t) == 2,
|
||||
"How did we get here? wide char smaller than 2 bytes");
|
||||
// perfectly fine scince wchar_t will be 2 bytes (UCS-2/UTF-16)
|
||||
#define DLC_WSTRING(ptr) std::wstring((wchar_t*)(ptr))
|
||||
#endif
|
||||
|
||||
#define DLC_PARAM_ADV(n) \
|
||||
(sizeof(C4JStorage::DLC_FILE_PARAM) + (n) * DLC_WCHAR_BIN_SIZE)
|
||||
(sizeof(IPlatformStorage::DLC_FILE_PARAM) + (n) * DLC_WCHAR_BIN_SIZE)
|
||||
#define DLC_DETAIL_ADV(n) \
|
||||
(sizeof(C4JStorage::DLC_FILE_DETAILS) + (n) * DLC_WCHAR_BIN_SIZE)
|
||||
(sizeof(IPlatformStorage::DLC_FILE_DETAILS) + (n) * DLC_WCHAR_BIN_SIZE)
|
||||
|
||||
namespace {
|
||||
template <typename T>
|
||||
@@ -86,13 +66,14 @@ void ReadDlcStruct(T* out, const std::uint8_t* data, unsigned int offset = 0) {
|
||||
std::memcpy(out, data + offset, sizeof(*out));
|
||||
}
|
||||
|
||||
std::wstring getMountedDlcReadPath(const std::string& path) {
|
||||
std::wstring readPath = convStringToWstring(path);
|
||||
std::string getMountedDlcReadPath(const std::string& path) {
|
||||
std::string readPath = path;
|
||||
|
||||
#if defined(_WINDOWS64)
|
||||
const std::string mountedPath = StorageManager.GetMountedPath(path.c_str());
|
||||
const std::string mountedPath =
|
||||
PlatformStorage.GetMountedPath(path.c_str());
|
||||
if (!mountedPath.empty()) {
|
||||
readPath = convStringToWstring(mountedPath);
|
||||
readPath = mountedPath;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -104,15 +85,15 @@ bool readOwnedDlcFile(const std::string& path, std::uint8_t** ppData,
|
||||
*ppData = nullptr;
|
||||
*pBytesRead = 0;
|
||||
|
||||
const std::wstring readPath = getMountedDlcReadPath(path);
|
||||
const std::size_t fSize = PlatformFileIO.fileSize(readPath);
|
||||
const std::string readPath = getMountedDlcReadPath(path);
|
||||
const std::size_t fSize = PlatformFilesystem.fileSize(readPath);
|
||||
if (fSize == 0 || fSize > std::numeric_limits<unsigned int>::max()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::uint8_t* data = new std::uint8_t[fSize];
|
||||
auto result = PlatformFileIO.readFile(readPath, data, fSize);
|
||||
if (result.status != IPlatformFileIO::ReadStatus::Ok) {
|
||||
auto result = PlatformFilesystem.readFile(readPath, data, fSize);
|
||||
if (result.status != IPlatformFilesystem::ReadStatus::Ok) {
|
||||
delete[] data;
|
||||
return false;
|
||||
}
|
||||
@@ -123,20 +104,20 @@ bool readOwnedDlcFile(const std::string& path, std::uint8_t** ppData,
|
||||
}
|
||||
} // namespace
|
||||
|
||||
const wchar_t* DLCManager::wchTypeNamesA[] = {
|
||||
L"DISPLAYNAME",
|
||||
L"THEMENAME",
|
||||
L"FREE",
|
||||
L"CREDIT",
|
||||
L"CAPEPATH",
|
||||
L"BOX",
|
||||
L"ANIM",
|
||||
L"PACKID",
|
||||
L"NETHERPARTICLECOLOUR",
|
||||
L"ENCHANTTEXTCOLOUR",
|
||||
L"ENCHANTTEXTFOCUSCOLOUR",
|
||||
L"DATAPATH",
|
||||
L"PACKVERSION",
|
||||
const char* DLCManager::wchTypeNamesA[] = {
|
||||
"DISPLAYNAME",
|
||||
"THEMENAME",
|
||||
"FREE",
|
||||
"CREDIT",
|
||||
"CAPEPATH",
|
||||
"BOX",
|
||||
"ANIM",
|
||||
"PACKID",
|
||||
"NETHERPARTICLECOLOUR",
|
||||
"ENCHANTTEXTCOLOUR",
|
||||
"ENCHANTTEXTFOCUSCOLOUR",
|
||||
"DATAPATH",
|
||||
"PACKVERSION",
|
||||
};
|
||||
|
||||
DLCManager::DLCManager() {
|
||||
@@ -152,7 +133,7 @@ DLCManager::~DLCManager() {
|
||||
}
|
||||
|
||||
DLCManager::EDLCParameterType DLCManager::getParameterType(
|
||||
const std::wstring& paramName) {
|
||||
const std::string& paramName) {
|
||||
EDLCParameterType type = e_DLCParamType_Invalid;
|
||||
|
||||
for (unsigned int i = 0; i < e_DLCParamType_Max; ++i) {
|
||||
@@ -207,13 +188,13 @@ void DLCManager::LanguageChanged(void) {
|
||||
}
|
||||
}
|
||||
|
||||
DLCPack* DLCManager::getPack(const std::wstring& name) {
|
||||
DLCPack* DLCManager::getPack(const std::string& name) {
|
||||
DLCPack* pack = nullptr;
|
||||
// uint32_t currentIndex = 0;
|
||||
DLCPack* currentPack = nullptr;
|
||||
for (auto it = m_packs.begin(); it != m_packs.end(); ++it) {
|
||||
currentPack = *it;
|
||||
std::wstring wsName = currentPack->getName();
|
||||
std::string wsName = currentPack->getName();
|
||||
|
||||
if (wsName.compare(name) == 0) {
|
||||
pack = currentPack;
|
||||
@@ -259,7 +240,7 @@ unsigned int DLCManager::getPackIndex(DLCPack* pack, bool& found,
|
||||
if (pack == nullptr) {
|
||||
app.DebugPrintf(
|
||||
"DLCManager: Attempting to find the index for a nullptr pack\n");
|
||||
//__debugbreak();
|
||||
// assert(0);
|
||||
return foundIndex;
|
||||
}
|
||||
if (type != e_DLCType_All) {
|
||||
@@ -290,7 +271,7 @@ unsigned int DLCManager::getPackIndex(DLCPack* pack, bool& found,
|
||||
return foundIndex;
|
||||
}
|
||||
|
||||
unsigned int DLCManager::getPackIndexContainingSkin(const std::wstring& path,
|
||||
unsigned int DLCManager::getPackIndexContainingSkin(const std::string& path,
|
||||
bool& found) {
|
||||
unsigned int foundIndex = 0;
|
||||
found = false;
|
||||
@@ -309,7 +290,7 @@ unsigned int DLCManager::getPackIndexContainingSkin(const std::wstring& path,
|
||||
return foundIndex;
|
||||
}
|
||||
|
||||
DLCPack* DLCManager::getPackContainingSkin(const std::wstring& path) {
|
||||
DLCPack* DLCManager::getPackContainingSkin(const std::string& path) {
|
||||
DLCPack* foundPack = nullptr;
|
||||
for (auto it = m_packs.begin(); it != m_packs.end(); ++it) {
|
||||
DLCPack* pack = *it;
|
||||
@@ -323,7 +304,7 @@ DLCPack* DLCManager::getPackContainingSkin(const std::wstring& path) {
|
||||
return foundPack;
|
||||
}
|
||||
|
||||
DLCSkinFile* DLCManager::getSkinFile(const std::wstring& path) {
|
||||
DLCSkinFile* DLCManager::getSkinFile(const std::string& path) {
|
||||
DLCSkinFile* foundSkinfile = nullptr;
|
||||
for (auto it = m_packs.begin(); it != m_packs.end(); ++it) {
|
||||
DLCPack* pack = *it;
|
||||
@@ -355,18 +336,18 @@ unsigned int DLCManager::checkForCorruptDLCAndAlert(
|
||||
uiIDA[0] = IDS_CONFIRM_OK;
|
||||
if (corruptDLCCount == 1 && firstCorruptPack != nullptr) {
|
||||
// pass in the pack format string
|
||||
wchar_t wchFormat[132];
|
||||
swprintf(wchFormat, 132, L"%ls\n\n%%ls",
|
||||
char wchFormat[132];
|
||||
snprintf(wchFormat, 132, "%s\n\n%%s",
|
||||
firstCorruptPack->getName().c_str());
|
||||
|
||||
C4JStorage::EMessageResult result = ui.RequestErrorMessage(
|
||||
IPlatformStorage::EMessageResult result = ui.RequestErrorMessage(
|
||||
IDS_CORRUPT_DLC_TITLE, IDS_CORRUPT_DLC, uiIDA, 1,
|
||||
ProfileManager.GetPrimaryPad(), nullptr, nullptr, wchFormat);
|
||||
PlatformProfile.GetPrimaryPad(), nullptr, nullptr, wchFormat);
|
||||
|
||||
} else {
|
||||
C4JStorage::EMessageResult result = ui.RequestErrorMessage(
|
||||
IPlatformStorage::EMessageResult result = ui.RequestErrorMessage(
|
||||
IDS_CORRUPT_DLC_TITLE, IDS_CORRUPT_DLC_MULTIPLE, uiIDA, 1,
|
||||
ProfileManager.GetPrimaryPad());
|
||||
PlatformProfile.GetPrimaryPad());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,18 +356,18 @@ unsigned int DLCManager::checkForCorruptDLCAndAlert(
|
||||
return corruptDLCCount;
|
||||
}
|
||||
|
||||
bool DLCManager::readDLCDataFile(unsigned int& dwFilesProcessed,
|
||||
const std::wstring& path, DLCPack* pack,
|
||||
bool fromArchive) {
|
||||
return readDLCDataFile(dwFilesProcessed,
|
||||
std::filesystem::path(path).string(), pack,
|
||||
fromArchive);
|
||||
}
|
||||
// bool DLCManager::readDLCDataFile(unsigned int& dwFilesProcessed,
|
||||
// const std::string& path, DLCPack* pack,
|
||||
// bool fromArchive) {
|
||||
// return readDLCDataFile(dwFilesProcessed,
|
||||
// std::filesystem::path(path).string(), pack,
|
||||
// fromArchive);
|
||||
// }
|
||||
|
||||
bool DLCManager::readDLCDataFile(unsigned int& dwFilesProcessed,
|
||||
const std::string& path, DLCPack* pack,
|
||||
bool fromArchive) {
|
||||
std::wstring wPath = convStringToWstring(path);
|
||||
std::string wPath = path;
|
||||
if (fromArchive && app.getArchiveFileSize(wPath) >= 0) {
|
||||
std::vector<uint8_t> bytes = app.getArchiveFile(wPath);
|
||||
return processDLCDataFile(dwFilesProcessed, bytes.data(), bytes.size(),
|
||||
@@ -413,17 +394,19 @@ bool DLCManager::processDLCDataFile(unsigned int& dwFilesProcessed,
|
||||
memcpy((out), (buf) + (off), sizeof(unsigned int))
|
||||
|
||||
#define DLC_READ_PARAM(out, buf, off) \
|
||||
memcpy((out), (buf) + (off), sizeof(C4JStorage::DLC_FILE_PARAM))
|
||||
memcpy((out), (buf) + (off), sizeof(IPlatformStorage::DLC_FILE_PARAM))
|
||||
|
||||
#define DLC_READ_DETAIL(out, buf, off) \
|
||||
memcpy((out), (buf) + (off), sizeof(C4JStorage::DLC_FILE_DETAILS))
|
||||
memcpy((out), (buf) + (off), sizeof(IPlatformStorage::DLC_FILE_DETAILS))
|
||||
|
||||
// for details, read in the function below
|
||||
#define DLC_PARAM_WSTR(buf, off) \
|
||||
DLC_WSTRING((buf) + (off) + offsetof(C4JStorage::DLC_FILE_PARAM, wchData))
|
||||
DLC_WSTRING((buf) + (off) + \
|
||||
offsetof(IPlatformStorage::DLC_FILE_PARAM, wchData))
|
||||
|
||||
#define DLC_DETAIL_WSTR(buf, off) \
|
||||
DLC_WSTRING((buf) + (off) + offsetof(C4JStorage::DLC_FILE_DETAILS, wchFile))
|
||||
DLC_WSTRING((buf) + (off) + \
|
||||
offsetof(IPlatformStorage::DLC_FILE_DETAILS, wchFile))
|
||||
{
|
||||
std::unordered_map<int, DLCManager::EDLCParameterType> parameterMapping;
|
||||
unsigned int uiCurrentByte = 0;
|
||||
@@ -466,13 +449,13 @@ bool DLCManager::processDLCDataFile(unsigned int& dwFilesProcessed,
|
||||
DLC_READ_UINT(&uiParameterCount, pbData, uiCurrentByte);
|
||||
uiCurrentByte += sizeof(int);
|
||||
|
||||
C4JStorage::DLC_FILE_PARAM parBuf;
|
||||
IPlatformStorage::DLC_FILE_PARAM parBuf;
|
||||
DLC_READ_PARAM(&parBuf, pbData, uiCurrentByte);
|
||||
// uint32_t dwwchCount=0;
|
||||
for (unsigned int i = 0; i < uiParameterCount; i++) {
|
||||
// Map DLC strings to application strings, then store the DLC index
|
||||
// mapping to application index
|
||||
std::wstring parameterName = DLC_PARAM_WSTR(pbData, uiCurrentByte);
|
||||
std::string parameterName = DLC_PARAM_WSTR(pbData, uiCurrentByte);
|
||||
DLCManager::EDLCParameterType type =
|
||||
DLCManager::getParameterType(parameterName);
|
||||
if (type != DLCManager::e_DLCParamType_Invalid) {
|
||||
@@ -481,13 +464,14 @@ bool DLCManager::processDLCDataFile(unsigned int& dwFilesProcessed,
|
||||
uiCurrentByte += DLC_PARAM_ADV(parBuf.dwWchCount);
|
||||
DLC_READ_PARAM(&parBuf, pbData, uiCurrentByte);
|
||||
}
|
||||
// ulCurrentByte+=ulParameterCount * sizeof(C4JStorage::DLC_FILE_PARAM);
|
||||
// ulCurrentByte+=ulParameterCount *
|
||||
// sizeof(IPlatformStorage::DLC_FILE_PARAM);
|
||||
|
||||
unsigned int uiFileCount;
|
||||
DLC_READ_UINT(&uiFileCount, pbData, uiCurrentByte);
|
||||
uiCurrentByte += sizeof(int);
|
||||
|
||||
C4JStorage::DLC_FILE_DETAILS fileBuf;
|
||||
IPlatformStorage::DLC_FILE_DETAILS fileBuf;
|
||||
DLC_READ_DETAIL(&fileBuf, pbData, uiCurrentByte);
|
||||
|
||||
unsigned int dwTemp = uiCurrentByte;
|
||||
@@ -496,7 +480,9 @@ bool DLCManager::processDLCDataFile(unsigned int& dwFilesProcessed,
|
||||
DLC_READ_DETAIL(&fileBuf, pbData, dwTemp);
|
||||
}
|
||||
std::uint8_t* pbTemp =
|
||||
&pbData[dwTemp]; //+ sizeof(C4JStorage::DLC_FILE_DETAILS)*ulFileCount;
|
||||
&pbData
|
||||
[dwTemp]; //+
|
||||
// sizeof(IPlatformStorage::DLC_FILE_DETAILS)*ulFileCount;
|
||||
DLC_READ_DETAIL(&fileBuf, pbData, uiCurrentByte);
|
||||
|
||||
for (unsigned int i = 0; i < uiFileCount; i++) {
|
||||
@@ -540,7 +526,7 @@ bool DLCManager::processDLCDataFile(unsigned int& dwFilesProcessed,
|
||||
pbTemp += DLC_PARAM_ADV(parBuf.dwWchCount);
|
||||
DLC_READ_PARAM(&parBuf, pbTemp, 0);
|
||||
}
|
||||
// pbTemp+=ulParameterCount * sizeof(C4JStorage::DLC_FILE_PARAM);
|
||||
// pbTemp+=ulParameterCount * sizeof(IPlatformStorage::DLC_FILE_PARAM);
|
||||
|
||||
if (dlcTexturePack != nullptr) {
|
||||
unsigned int texturePackFilesProcessed = 0;
|
||||
@@ -643,12 +629,12 @@ std::uint32_t DLCManager::retrievePackID(std::uint8_t* pbData,
|
||||
unsigned int uiParameterCount =
|
||||
ReadDlcValue<unsigned int>(pbData, uiCurrentByte);
|
||||
uiCurrentByte += sizeof(int);
|
||||
C4JStorage::DLC_FILE_PARAM paramBuf;
|
||||
IPlatformStorage::DLC_FILE_PARAM paramBuf;
|
||||
ReadDlcStruct(¶mBuf, pbData, uiCurrentByte);
|
||||
for (unsigned int i = 0; i < uiParameterCount; i++) {
|
||||
// Map DLC strings to application strings, then store the DLC index
|
||||
// mapping to application index
|
||||
std::wstring parameterName = DLC_PARAM_WSTR(pbData, uiCurrentByte);
|
||||
std::string parameterName = DLC_PARAM_WSTR(pbData, uiCurrentByte);
|
||||
DLCManager::EDLCParameterType type =
|
||||
DLCManager::getParameterType(parameterName);
|
||||
if (type != DLCManager::e_DLCParamType_Invalid) {
|
||||
@@ -661,7 +647,7 @@ std::uint32_t DLCManager::retrievePackID(std::uint8_t* pbData,
|
||||
unsigned int uiFileCount =
|
||||
ReadDlcValue<unsigned int>(pbData, uiCurrentByte);
|
||||
uiCurrentByte += sizeof(int);
|
||||
C4JStorage::DLC_FILE_DETAILS fileBuf;
|
||||
IPlatformStorage::DLC_FILE_DETAILS fileBuf;
|
||||
ReadDlcStruct(&fileBuf, pbData, uiCurrentByte);
|
||||
|
||||
unsigned int dwTemp = uiCurrentByte;
|
||||
@@ -685,8 +671,8 @@ std::uint32_t DLCManager::retrievePackID(std::uint8_t* pbData,
|
||||
if (it != parameterMapping.end()) {
|
||||
if (type == e_DLCType_PackConfig) {
|
||||
if (it->second == e_DLCParamType_PackId) {
|
||||
std::wstring wsTemp = DLC_PARAM_WSTR(pbTemp, 0);
|
||||
std::wstringstream ss;
|
||||
std::string wsTemp = DLC_PARAM_WSTR(pbTemp, 0);
|
||||
std::stringstream ss;
|
||||
// 4J Stu - numbered using decimal to make it easier for
|
||||
// artists/people to number manually
|
||||
ss << std::dec << wsTemp.c_str();
|
||||
@@ -0,0 +1,139 @@
|
||||
#pragma once
|
||||
// using namespace std;
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "minecraft/world/level/dlc/DLCConstants.h"
|
||||
|
||||
class DLCPack;
|
||||
class DLCSkinFile;
|
||||
|
||||
class DLCManager {
|
||||
public:
|
||||
// Re-export the file-scope enums as nested type aliases so existing
|
||||
// app-side call sites that use DLCManager::EDLCType /
|
||||
// DLCManager::e_DLCType_Texture continue to compile. minecraft/-side
|
||||
// call sites should use the namespaced names from DLCConstants.h
|
||||
// directly.
|
||||
using EDLCType = ::minecraft::dlc::EDLCType;
|
||||
using EDLCParameterType = ::minecraft::dlc::EDLCParameterType;
|
||||
|
||||
static constexpr EDLCType e_DLCType_Skin = ::minecraft::dlc::e_DLCType_Skin;
|
||||
static constexpr EDLCType e_DLCType_Cape = ::minecraft::dlc::e_DLCType_Cape;
|
||||
static constexpr EDLCType e_DLCType_Texture =
|
||||
::minecraft::dlc::e_DLCType_Texture;
|
||||
static constexpr EDLCType e_DLCType_UIData =
|
||||
::minecraft::dlc::e_DLCType_UIData;
|
||||
static constexpr EDLCType e_DLCType_PackConfig =
|
||||
::minecraft::dlc::e_DLCType_PackConfig;
|
||||
static constexpr EDLCType e_DLCType_TexturePack =
|
||||
::minecraft::dlc::e_DLCType_TexturePack;
|
||||
static constexpr EDLCType e_DLCType_LocalisationData =
|
||||
::minecraft::dlc::e_DLCType_LocalisationData;
|
||||
static constexpr EDLCType e_DLCType_GameRules =
|
||||
::minecraft::dlc::e_DLCType_GameRules;
|
||||
static constexpr EDLCType e_DLCType_Audio =
|
||||
::minecraft::dlc::e_DLCType_Audio;
|
||||
static constexpr EDLCType e_DLCType_ColourTable =
|
||||
::minecraft::dlc::e_DLCType_ColourTable;
|
||||
static constexpr EDLCType e_DLCType_GameRulesHeader =
|
||||
::minecraft::dlc::e_DLCType_GameRulesHeader;
|
||||
static constexpr EDLCType e_DLCType_Max = ::minecraft::dlc::e_DLCType_Max;
|
||||
static constexpr EDLCType e_DLCType_All = ::minecraft::dlc::e_DLCType_All;
|
||||
|
||||
static constexpr EDLCParameterType e_DLCParamType_Invalid =
|
||||
::minecraft::dlc::e_DLCParamType_Invalid;
|
||||
static constexpr EDLCParameterType e_DLCParamType_DisplayName =
|
||||
::minecraft::dlc::e_DLCParamType_DisplayName;
|
||||
static constexpr EDLCParameterType e_DLCParamType_ThemeName =
|
||||
::minecraft::dlc::e_DLCParamType_ThemeName;
|
||||
static constexpr EDLCParameterType e_DLCParamType_Free =
|
||||
::minecraft::dlc::e_DLCParamType_Free;
|
||||
static constexpr EDLCParameterType e_DLCParamType_Credit =
|
||||
::minecraft::dlc::e_DLCParamType_Credit;
|
||||
static constexpr EDLCParameterType e_DLCParamType_Cape =
|
||||
::minecraft::dlc::e_DLCParamType_Cape;
|
||||
static constexpr EDLCParameterType e_DLCParamType_Box =
|
||||
::minecraft::dlc::e_DLCParamType_Box;
|
||||
static constexpr EDLCParameterType e_DLCParamType_Anim =
|
||||
::minecraft::dlc::e_DLCParamType_Anim;
|
||||
static constexpr EDLCParameterType e_DLCParamType_PackId =
|
||||
::minecraft::dlc::e_DLCParamType_PackId;
|
||||
static constexpr EDLCParameterType e_DLCParamType_NetherParticleColour =
|
||||
::minecraft::dlc::e_DLCParamType_NetherParticleColour;
|
||||
static constexpr EDLCParameterType e_DLCParamType_EnchantmentTextColour =
|
||||
::minecraft::dlc::e_DLCParamType_EnchantmentTextColour;
|
||||
static constexpr EDLCParameterType
|
||||
e_DLCParamType_EnchantmentTextFocusColour =
|
||||
::minecraft::dlc::e_DLCParamType_EnchantmentTextFocusColour;
|
||||
static constexpr EDLCParameterType e_DLCParamType_DataPath =
|
||||
::minecraft::dlc::e_DLCParamType_DataPath;
|
||||
static constexpr EDLCParameterType e_DLCParamType_PackVersion =
|
||||
::minecraft::dlc::e_DLCParamType_PackVersion;
|
||||
static constexpr EDLCParameterType e_DLCParamType_Max =
|
||||
::minecraft::dlc::e_DLCParamType_Max;
|
||||
|
||||
const static char* wchTypeNamesA[e_DLCParamType_Max];
|
||||
|
||||
private:
|
||||
std::vector<DLCPack*> m_packs;
|
||||
// bool m_bNeedsUpdated;
|
||||
bool m_bNeedsCorruptCheck;
|
||||
unsigned int m_dwUnnamedCorruptDLCCount;
|
||||
|
||||
public:
|
||||
DLCManager();
|
||||
~DLCManager();
|
||||
|
||||
static EDLCParameterType getParameterType(const std::string& paramName);
|
||||
|
||||
unsigned int getPackCount(EDLCType type = e_DLCType_All);
|
||||
|
||||
// bool NeedsUpdated() { return m_bNeedsUpdated; }
|
||||
// void SetNeedsUpdated(bool val) { m_bNeedsUpdated = val; }
|
||||
|
||||
bool NeedsCorruptCheck() { return m_bNeedsCorruptCheck; }
|
||||
void SetNeedsCorruptCheck(bool val) { m_bNeedsCorruptCheck = val; }
|
||||
|
||||
void resetUnnamedCorruptCount() { m_dwUnnamedCorruptDLCCount = 0; }
|
||||
void incrementUnnamedCorruptCount() { ++m_dwUnnamedCorruptDLCCount; }
|
||||
|
||||
void addPack(DLCPack* pack);
|
||||
void removePack(DLCPack* pack);
|
||||
void removeAllPacks(void);
|
||||
void LanguageChanged(void);
|
||||
|
||||
DLCPack* getPack(const std::string& name);
|
||||
DLCPack* getPack(unsigned int index, EDLCType type = e_DLCType_All);
|
||||
unsigned int getPackIndex(DLCPack* pack, bool& found,
|
||||
EDLCType type = e_DLCType_All);
|
||||
DLCSkinFile* getSkinFile(
|
||||
const std::string& path); // Will hunt all packs of type skin to find
|
||||
// the right skinfile
|
||||
|
||||
DLCPack* getPackContainingSkin(const std::string& path);
|
||||
unsigned int getPackIndexContainingSkin(const std::string& path,
|
||||
bool& found);
|
||||
|
||||
unsigned int checkForCorruptDLCAndAlert(bool showMessage = true);
|
||||
|
||||
// bool readDLCDataFile(unsigned int& dwFilesProcessed,
|
||||
// const std::wstring& path, DLCPack* pack,
|
||||
// bool fromArchive = false);
|
||||
bool readDLCDataFile(unsigned int& dwFilesProcessed,
|
||||
const std::string& path, DLCPack* pack,
|
||||
bool fromArchive = false);
|
||||
std::uint32_t retrievePackIDFromDLCDataFile(const std::string& path,
|
||||
DLCPack* pack);
|
||||
|
||||
private:
|
||||
bool processDLCDataFile(unsigned int& dwFilesProcessed,
|
||||
std::uint8_t* pbData, unsigned int dwLength,
|
||||
DLCPack* pack);
|
||||
|
||||
std::uint32_t retrievePackID(std::uint8_t* pbData, unsigned int dwLength,
|
||||
DLCPack* pack);
|
||||
};
|
||||
|
||||
std::string dlc_read_wstring(const void* data);
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
|
||||
#include "platform/sdl2/Profile.h"
|
||||
#include "DLCAudioFile.h"
|
||||
#include "DLCCapeFile.h"
|
||||
#include "DLCColourTableFile.h"
|
||||
@@ -15,17 +14,17 @@
|
||||
#include "DLCLocalisationFile.h"
|
||||
#include "DLCTextureFile.h"
|
||||
#include "DLCUIDataFile.h"
|
||||
#include "app/common/src/Console_Debug_enum.h"
|
||||
#include "app/common/src/DLC/DLCFile.h"
|
||||
#include "app/common/src/DLC/DLCManager.h"
|
||||
#include "app/common/src/DLC/DLCSkinFile.h"
|
||||
#include "app/common/src/Localisation/StringTable.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "app/linux/Stubs/winapi_stubs.h"
|
||||
#include "app/common/DLC/DLCFile.h"
|
||||
#include "app/common/DLC/DLCManager.h"
|
||||
#include "app/common/DLC/DLCSkinFile.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "minecraft/Console_Debug_enum.h"
|
||||
#include "minecraft/locale/StringTable.h"
|
||||
#include "platform/profile/profile.h"
|
||||
#include "util/StringHelpers.h"
|
||||
|
||||
DLCPack::DLCPack(const std::wstring& name, std::uint32_t dwLicenseMask) {
|
||||
m_dataPath = L"";
|
||||
DLCPack::DLCPack(const std::string& name, std::uint32_t dwLicenseMask) {
|
||||
m_dataPath = "";
|
||||
m_packName = name;
|
||||
m_dwLicenseMask = dwLicenseMask;
|
||||
m_ullFullOfferId = 0LL;
|
||||
@@ -55,7 +54,7 @@ DLCPack::~DLCPack() {
|
||||
// invalidates ALL of it's children.
|
||||
if (m_data) {
|
||||
#if !defined(_CONTENT_PACKAGE)
|
||||
wprintf(L"Deleting data for DLC pack %ls\n", m_packName.c_str());
|
||||
printf("Deleting data for DLC pack %s\n", m_packName.c_str());
|
||||
#endif
|
||||
// For the same reason, don't delete data pointer for any child pack as
|
||||
// it just points to a region within the parent pack that has already
|
||||
@@ -84,7 +83,7 @@ void DLCPack::addChildPack(DLCPack* childPack) {
|
||||
const std::uint32_t packId = childPack->GetPackId();
|
||||
#if !defined(_CONTENT_PACKAGE)
|
||||
if (packId < 0 || packId > 15) {
|
||||
__debugbreak();
|
||||
assert(0);
|
||||
}
|
||||
#endif
|
||||
childPack->SetPackId((packId << 24) | m_packId);
|
||||
@@ -96,12 +95,12 @@ void DLCPack::addChildPack(DLCPack* childPack) {
|
||||
void DLCPack::setParentPack(DLCPack* parentPack) { m_parentPack = parentPack; }
|
||||
|
||||
void DLCPack::addParameter(DLCManager::EDLCParameterType type,
|
||||
const std::wstring& value) {
|
||||
const std::string& value) {
|
||||
switch (type) {
|
||||
case DLCManager::e_DLCParamType_PackId: {
|
||||
std::uint32_t packId = 0;
|
||||
|
||||
std::wstringstream ss;
|
||||
std::stringstream ss;
|
||||
// 4J Stu - numbered using decimal to make it easier for
|
||||
// artists/people to number manually
|
||||
ss << std::dec << value.c_str();
|
||||
@@ -112,7 +111,7 @@ void DLCPack::addParameter(DLCManager::EDLCParameterType type,
|
||||
case DLCManager::e_DLCParamType_PackVersion: {
|
||||
std::uint32_t version = 0;
|
||||
|
||||
std::wstringstream ss;
|
||||
std::stringstream ss;
|
||||
// 4J Stu - numbered using decimal to make it easier for
|
||||
// artists/people to number manually
|
||||
ss << std::dec << value.c_str();
|
||||
@@ -140,7 +139,7 @@ bool DLCPack::getParameterAsUInt(DLCManager::EDLCParameterType type,
|
||||
case DLCManager::e_DLCParamType_NetherParticleColour:
|
||||
case DLCManager::e_DLCParamType_EnchantmentTextColour:
|
||||
case DLCManager::e_DLCParamType_EnchantmentTextFocusColour: {
|
||||
std::wstringstream ss;
|
||||
std::stringstream ss;
|
||||
ss << std::hex << it->second.c_str();
|
||||
ss >> param;
|
||||
} break;
|
||||
@@ -152,13 +151,13 @@ bool DLCPack::getParameterAsUInt(DLCManager::EDLCParameterType type,
|
||||
return false;
|
||||
}
|
||||
|
||||
DLCFile* DLCPack::addFile(DLCManager::EDLCType type, const std::wstring& path) {
|
||||
DLCFile* DLCPack::addFile(DLCManager::EDLCType type, const std::string& path) {
|
||||
DLCFile* newFile = nullptr;
|
||||
|
||||
switch (type) {
|
||||
case DLCManager::e_DLCType_Skin: {
|
||||
std::vector<std::wstring> splitPath = stringSplit(path, L'/');
|
||||
std::wstring strippedPath = splitPath.back();
|
||||
std::vector<std::string> splitPath = stringSplit(path, '/');
|
||||
std::string strippedPath = splitPath.back();
|
||||
|
||||
newFile = new DLCSkinFile(strippedPath);
|
||||
|
||||
@@ -170,8 +169,8 @@ DLCFile* DLCPack::addFile(DLCManager::EDLCType type, const std::wstring& path) {
|
||||
}
|
||||
} break;
|
||||
case DLCManager::e_DLCType_Cape: {
|
||||
std::vector<std::wstring> splitPath = stringSplit(path, L'/');
|
||||
std::wstring strippedPath = splitPath.back();
|
||||
std::vector<std::string> splitPath = stringSplit(path, '/');
|
||||
std::string strippedPath = splitPath.back();
|
||||
newFile = new DLCCapeFile(strippedPath);
|
||||
} break;
|
||||
case DLCManager::e_DLCType_Texture:
|
||||
@@ -208,13 +207,13 @@ DLCFile* DLCPack::addFile(DLCManager::EDLCType type, const std::wstring& path) {
|
||||
|
||||
// MGH - added this comp func, as the embedded func in find_if was confusing the
|
||||
// PS3 compiler
|
||||
static const std::wstring* g_pathCmpString = nullptr;
|
||||
static const std::string* g_pathCmpString = nullptr;
|
||||
static bool pathCmp(DLCFile* val) {
|
||||
return (g_pathCmpString->compare(val->getPath()) == 0);
|
||||
}
|
||||
|
||||
bool DLCPack::doesPackContainFile(DLCManager::EDLCType type,
|
||||
const std::wstring& path) {
|
||||
const std::string& path) {
|
||||
bool hasFile = false;
|
||||
if (type == DLCManager::e_DLCType_All) {
|
||||
for (DLCManager::EDLCType currentType = (DLCManager::EDLCType)0;
|
||||
@@ -253,7 +252,7 @@ DLCFile* DLCPack::getFile(DLCManager::EDLCType type, unsigned int index) {
|
||||
return file;
|
||||
}
|
||||
|
||||
DLCFile* DLCPack::getFile(DLCManager::EDLCType type, const std::wstring& path) {
|
||||
DLCFile* DLCPack::getFile(DLCManager::EDLCType type, const std::string& path) {
|
||||
DLCFile* file = nullptr;
|
||||
if (type == DLCManager::e_DLCType_All) {
|
||||
for (DLCManager::EDLCType currentType = (DLCManager::EDLCType)0;
|
||||
@@ -298,11 +297,11 @@ unsigned int DLCPack::getDLCItemsCount(
|
||||
};
|
||||
|
||||
unsigned int DLCPack::getFileIndexAt(DLCManager::EDLCType type,
|
||||
const std::wstring& path, bool& found) {
|
||||
const std::string& path, bool& found) {
|
||||
if (type == DLCManager::e_DLCType_All) {
|
||||
app.DebugPrintf("Unimplemented\n");
|
||||
#if !defined(__CONTENT_PACKAGE)
|
||||
__debugbreak();
|
||||
assert(0);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@@ -323,16 +322,16 @@ unsigned int DLCPack::getFileIndexAt(DLCManager::EDLCType type,
|
||||
}
|
||||
|
||||
bool DLCPack::hasPurchasedFile(DLCManager::EDLCType type,
|
||||
const std::wstring& path) {
|
||||
const std::string& path) {
|
||||
if (type == DLCManager::e_DLCType_All) {
|
||||
app.DebugPrintf("Unimplemented\n");
|
||||
#if !defined(_CONTENT_PACKAGE)
|
||||
__debugbreak();
|
||||
assert(0);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
#if !defined(_CONTENT_PACKAGE)
|
||||
if (app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) &
|
||||
if (app.GetGameSettingsDebugMask(PlatformProfile.GetPrimaryPad()) &
|
||||
(1L << eDebugSetting_UnlockAllDLC)) {
|
||||
return true;
|
||||
} else
|
||||
@@ -350,8 +349,8 @@ void DLCPack::UpdateLanguage() {
|
||||
// find the language file
|
||||
if (m_files[DLCManager::e_DLCType_LocalisationData].size() > 0) {
|
||||
DLCLocalisationFile* localisationFile = (DLCLocalisationFile*)getFile(
|
||||
DLCManager::e_DLCType_LocalisationData, L"languages.loc");
|
||||
DLCManager::e_DLCType_LocalisationData, "languages.loc");
|
||||
StringTable* strTable = localisationFile->getStringTable();
|
||||
strTable->ReloadStringTable();
|
||||
strTable->ReloadStringTable(app.getLocale());
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,9 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "platform/PlatformTypes.h"
|
||||
#include "DLCManager.h"
|
||||
#include "app/common/src/DLC/DLCSkinFile.h"
|
||||
#include "app/common/DLC/DLCSkinFile.h"
|
||||
#include "platform/PlatformTypes.h"
|
||||
|
||||
class DLCFile;
|
||||
class DLCSkinFile;
|
||||
@@ -18,10 +18,10 @@ private:
|
||||
std::vector<DLCPack*> m_childPacks;
|
||||
DLCPack* m_parentPack;
|
||||
|
||||
std::unordered_map<int, std::wstring> m_parameters;
|
||||
std::unordered_map<int, std::string> m_parameters;
|
||||
|
||||
std::wstring m_packName;
|
||||
std::wstring m_dataPath;
|
||||
std::string m_packName;
|
||||
std::string m_dataPath;
|
||||
std::uint32_t m_dwLicenseMask;
|
||||
int m_dlcMountIndex;
|
||||
XCONTENTDEVICEID m_dlcDeviceID;
|
||||
@@ -34,10 +34,10 @@ private:
|
||||
m_data; // This pointer is for all the data used for this pack, so
|
||||
// deleting it invalidates ALL of it's children.
|
||||
public:
|
||||
DLCPack(const std::wstring& name, std::uint32_t dwLicenseMask);
|
||||
DLCPack(const std::string& name, std::uint32_t dwLicenseMask);
|
||||
~DLCPack();
|
||||
|
||||
std::wstring getFullDataPath() { return m_dataPath; }
|
||||
std::string getFullDataPath() { return m_dataPath; }
|
||||
|
||||
void SetDataPointer(std::uint8_t* pbData) { m_data = pbData; }
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
void setParentPack(DLCPack* parentPack);
|
||||
|
||||
void addParameter(DLCManager::EDLCParameterType type,
|
||||
const std::wstring& value);
|
||||
const std::string& value);
|
||||
bool getParameterAsUInt(DLCManager::EDLCParameterType type,
|
||||
unsigned int& param);
|
||||
|
||||
@@ -71,38 +71,38 @@ public:
|
||||
}
|
||||
std::uint32_t getLicenseMask() { return m_dwLicenseMask; }
|
||||
|
||||
std::wstring getName() { return m_packName; }
|
||||
std::string getName() { return m_packName; }
|
||||
|
||||
void UpdateLanguage();
|
||||
uint64_t getPurchaseOfferId() { return m_ullFullOfferId; }
|
||||
|
||||
DLCFile* addFile(DLCManager::EDLCType type, const std::wstring& path);
|
||||
DLCFile* addFile(DLCManager::EDLCType type, const std::string& path);
|
||||
DLCFile* getFile(DLCManager::EDLCType type, unsigned int index);
|
||||
DLCFile* getFile(DLCManager::EDLCType type, const std::wstring& path);
|
||||
DLCFile* getFile(DLCManager::EDLCType type, const std::string& path);
|
||||
|
||||
unsigned int getDLCItemsCount(
|
||||
DLCManager::EDLCType type = DLCManager::e_DLCType_All);
|
||||
unsigned int getFileIndexAt(DLCManager::EDLCType type,
|
||||
const std::wstring& path, bool& found);
|
||||
const std::string& path, bool& found);
|
||||
bool doesPackContainFile(DLCManager::EDLCType type,
|
||||
const std::wstring& path);
|
||||
const std::string& path);
|
||||
std::uint32_t GetPackID() { return m_packId; }
|
||||
|
||||
unsigned int getSkinCount() {
|
||||
return getDLCItemsCount(DLCManager::e_DLCType_Skin);
|
||||
}
|
||||
unsigned int getSkinIndexAt(const std::wstring& path, bool& found) {
|
||||
unsigned int getSkinIndexAt(const std::string& path, bool& found) {
|
||||
return getFileIndexAt(DLCManager::e_DLCType_Skin, path, found);
|
||||
}
|
||||
DLCSkinFile* getSkinFile(const std::wstring& path) {
|
||||
DLCSkinFile* getSkinFile(const std::string& path) {
|
||||
return (DLCSkinFile*)getFile(DLCManager::e_DLCType_Skin, path);
|
||||
}
|
||||
DLCSkinFile* getSkinFile(unsigned int index) {
|
||||
return (DLCSkinFile*)getFile(DLCManager::e_DLCType_Skin, index);
|
||||
}
|
||||
bool doesPackContainSkin(const std::wstring& path) {
|
||||
bool doesPackContainSkin(const std::string& path) {
|
||||
return doesPackContainFile(DLCManager::e_DLCType_Skin, path);
|
||||
}
|
||||
|
||||
bool hasPurchasedFile(DLCManager::EDLCType type, const std::wstring& path);
|
||||
bool hasPurchasedFile(DLCManager::EDLCType type, const std::string& path);
|
||||
};
|
||||
@@ -3,18 +3,18 @@
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include "platform/sdl2/Render.h"
|
||||
#include "DLCManager.h"
|
||||
#include "app/common/src/DLC/DLCFile.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "app/include/SkinBox.h"
|
||||
#include "app/include/XboxStubs.h"
|
||||
#include "app/common/DLC/DLCFile.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "minecraft/client/model/SkinBox.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
#include "platform/renderer/renderer.h"
|
||||
|
||||
DLCSkinFile::DLCSkinFile(const std::wstring& path)
|
||||
DLCSkinFile::DLCSkinFile(const std::string& path)
|
||||
: DLCFile(DLCManager::e_DLCType_Skin, path) {
|
||||
m_displayName = L"";
|
||||
m_themeName = L"";
|
||||
m_cape = L"";
|
||||
m_displayName = "";
|
||||
m_themeName = "";
|
||||
m_cape = "";
|
||||
m_bIsFree = false;
|
||||
m_uiAnimOverrideBitmask = 0L;
|
||||
}
|
||||
@@ -24,13 +24,13 @@ void DLCSkinFile::addData(std::uint8_t* pbData, std::uint32_t dataBytes) {
|
||||
}
|
||||
|
||||
void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type,
|
||||
const std::wstring& value) {
|
||||
const std::string& value) {
|
||||
switch (type) {
|
||||
case DLCManager::e_DLCParamType_DisplayName: {
|
||||
// 4J Stu - In skin pack 2, the name for Zap is mis-spelt with two
|
||||
// p's as Zapp dlcskin00000109.png
|
||||
if (m_path.compare(L"dlcskin00000109.png") == 0) {
|
||||
m_displayName = L"Zap";
|
||||
if (m_path.compare("dlcskin00000109.png") == 0) {
|
||||
m_displayName = "Zap";
|
||||
} else {
|
||||
m_displayName = value;
|
||||
}
|
||||
@@ -52,12 +52,12 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type,
|
||||
{
|
||||
if (app.AlreadySeenCreditText(value)) break;
|
||||
// first add a blank string for spacing
|
||||
app.AddCreditText(L"");
|
||||
app.AddCreditText("");
|
||||
|
||||
int maximumChars = 55;
|
||||
|
||||
bool bIsSDMode =
|
||||
!RenderManager.IsHiDef() && !RenderManager.IsWidescreen();
|
||||
bool bIsSDMode = !PlatformRenderer.IsHiDef() &&
|
||||
!PlatformRenderer.IsWidescreen();
|
||||
|
||||
if (bIsSDMode) {
|
||||
maximumChars = 45;
|
||||
@@ -72,14 +72,14 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
std::wstring creditValue = value;
|
||||
std::string creditValue = value;
|
||||
while (creditValue.length() > maximumChars) {
|
||||
unsigned int i = 1;
|
||||
while (i < creditValue.length() &&
|
||||
(i + 1) <= maximumChars) {
|
||||
i++;
|
||||
}
|
||||
int iLast = (int)creditValue.find_last_of(L" ", i);
|
||||
int iLast = (int)creditValue.find_last_of(" ", i);
|
||||
switch (XGetLanguage()) {
|
||||
case XC_LANGUAGE_JAPANESE:
|
||||
case XC_LANGUAGE_TCHINESE:
|
||||
@@ -87,7 +87,7 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type,
|
||||
iLast = maximumChars;
|
||||
break;
|
||||
default:
|
||||
iLast = (int)creditValue.find_last_of(L" ", i);
|
||||
iLast = (int)creditValue.find_last_of(" ", i);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -106,25 +106,25 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type,
|
||||
m_cape = value;
|
||||
break;
|
||||
case DLCManager::e_DLCParamType_Box: {
|
||||
wchar_t wchBodyPart[10];
|
||||
char wchBodyPart[10];
|
||||
SKIN_BOX* pSkinBox = new SKIN_BOX;
|
||||
memset(pSkinBox, 0, sizeof(SKIN_BOX));
|
||||
|
||||
swscanf(value.c_str(), L"%9ls%f%f%f%f%f%f%f%f", wchBodyPart, 10,
|
||||
&pSkinBox->fX, &pSkinBox->fY, &pSkinBox->fZ, &pSkinBox->fW,
|
||||
&pSkinBox->fH, &pSkinBox->fD, &pSkinBox->fU, &pSkinBox->fV);
|
||||
sscanf(value.c_str(), "%9s%f%f%f%f%f%f%f%f", wchBodyPart,
|
||||
&pSkinBox->fX, &pSkinBox->fY, &pSkinBox->fZ, &pSkinBox->fW,
|
||||
&pSkinBox->fH, &pSkinBox->fD, &pSkinBox->fU, &pSkinBox->fV);
|
||||
|
||||
if (wcscmp(wchBodyPart, L"HEAD") == 0) {
|
||||
if (strcmp(wchBodyPart, "HEAD") == 0) {
|
||||
pSkinBox->ePart = eBodyPart_Head;
|
||||
} else if (wcscmp(wchBodyPart, L"BODY") == 0) {
|
||||
} else if (strcmp(wchBodyPart, "BODY") == 0) {
|
||||
pSkinBox->ePart = eBodyPart_Body;
|
||||
} else if (wcscmp(wchBodyPart, L"ARM0") == 0) {
|
||||
} else if (strcmp(wchBodyPart, "ARM0") == 0) {
|
||||
pSkinBox->ePart = eBodyPart_Arm0;
|
||||
} else if (wcscmp(wchBodyPart, L"ARM1") == 0) {
|
||||
} else if (strcmp(wchBodyPart, "ARM1") == 0) {
|
||||
pSkinBox->ePart = eBodyPart_Arm1;
|
||||
} else if (wcscmp(wchBodyPart, L"LEG0") == 0) {
|
||||
} else if (strcmp(wchBodyPart, "LEG0") == 0) {
|
||||
pSkinBox->ePart = eBodyPart_Leg0;
|
||||
} else if (wcscmp(wchBodyPart, L"LEG1") == 0) {
|
||||
} else if (strcmp(wchBodyPart, "LEG1") == 0) {
|
||||
pSkinBox->ePart = eBodyPart_Leg1;
|
||||
}
|
||||
|
||||
@@ -132,8 +132,7 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type,
|
||||
m_AdditionalBoxes.push_back(pSkinBox);
|
||||
} break;
|
||||
case DLCManager::e_DLCParamType_Anim: {
|
||||
swscanf(value.c_str(), L"%X", &m_uiAnimOverrideBitmask,
|
||||
sizeof(unsigned int));
|
||||
sscanf(value.c_str(), "%X", &m_uiAnimOverrideBitmask);
|
||||
uint32_t skinId = app.getSkinIdFromPath(m_path);
|
||||
app.SetAnimOverrideBitmask(skinId, m_uiAnimOverrideBitmask);
|
||||
break;
|
||||
@@ -155,7 +154,7 @@ std::vector<SKIN_BOX*>* DLCSkinFile::getAdditionalBoxes() {
|
||||
return &m_AdditionalBoxes;
|
||||
}
|
||||
|
||||
std::wstring DLCSkinFile::getParameterAsString(
|
||||
std::string DLCSkinFile::getParameterAsString(
|
||||
DLCManager::EDLCParameterType type) {
|
||||
switch (type) {
|
||||
case DLCManager::e_DLCParamType_DisplayName:
|
||||
@@ -165,7 +164,7 @@ std::wstring DLCSkinFile::getParameterAsString(
|
||||
case DLCManager::e_DLCParamType_Cape:
|
||||
return m_cape;
|
||||
default:
|
||||
return L"";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <format>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "DLCFile.h"
|
||||
#include "app/common/DLC/DLCManager.h"
|
||||
#include "minecraft/client/model/HumanoidModel.h"
|
||||
#include "minecraft/client/model/SkinBox.h"
|
||||
#include "minecraft/client/skins/ISkinAssetData.h"
|
||||
|
||||
class DLCSkinFile : public DLCFile, public ISkinAssetData {
|
||||
private:
|
||||
std::string m_displayName;
|
||||
std::string m_themeName;
|
||||
std::string m_cape;
|
||||
unsigned int m_uiAnimOverrideBitmask;
|
||||
bool m_bIsFree;
|
||||
std::vector<SKIN_BOX*> m_AdditionalBoxes;
|
||||
|
||||
public:
|
||||
DLCSkinFile(const std::string& path);
|
||||
|
||||
void addData(std::uint8_t* pbData, std::uint32_t dataBytes) override;
|
||||
void addParameter(DLCManager::EDLCParameterType type,
|
||||
const std::string& value) override;
|
||||
|
||||
std::string getParameterAsString(
|
||||
DLCManager::EDLCParameterType type) override;
|
||||
bool getParameterAsBool(DLCManager::EDLCParameterType type) override;
|
||||
|
||||
// ISkinAssetData
|
||||
[[nodiscard]] std::uint32_t getSkinID() override {
|
||||
return DLCFile::getSkinID();
|
||||
}
|
||||
[[nodiscard]] unsigned int getAnimOverrideBitmask() override {
|
||||
return m_uiAnimOverrideBitmask;
|
||||
}
|
||||
[[nodiscard]] int getAdditionalBoxesCount() override;
|
||||
[[nodiscard]] std::vector<SKIN_BOX*>* getAdditionalBoxes() override;
|
||||
|
||||
bool isFree() { return m_bIsFree; }
|
||||
};
|
||||
@@ -1,12 +1,12 @@
|
||||
#include "DLCTextureFile.h"
|
||||
|
||||
#include "DLCManager.h"
|
||||
#include "app/common/src/DLC/DLCFile.h"
|
||||
#include "app/common/DLC/DLCFile.h"
|
||||
|
||||
DLCTextureFile::DLCTextureFile(const std::wstring& path)
|
||||
DLCTextureFile::DLCTextureFile(const std::string& path)
|
||||
: DLCFile(DLCManager::e_DLCType_Texture, path) {
|
||||
m_bIsAnim = false;
|
||||
m_animString = L"";
|
||||
m_animString = "";
|
||||
|
||||
m_pbData = nullptr;
|
||||
m_dataBytes = 0;
|
||||
@@ -24,7 +24,7 @@ std::uint8_t* DLCTextureFile::getData(std::uint32_t& dataBytes) {
|
||||
}
|
||||
|
||||
void DLCTextureFile::addParameter(DLCManager::EDLCParameterType type,
|
||||
const std::wstring& value) {
|
||||
const std::string& value) {
|
||||
switch (type) {
|
||||
case DLCManager::e_DLCParamType_Anim:
|
||||
m_animString = value;
|
||||
@@ -36,13 +36,13 @@ void DLCTextureFile::addParameter(DLCManager::EDLCParameterType type,
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring DLCTextureFile::getParameterAsString(
|
||||
std::string DLCTextureFile::getParameterAsString(
|
||||
DLCManager::EDLCParameterType type) {
|
||||
switch (type) {
|
||||
case DLCManager::e_DLCParamType_Anim:
|
||||
return m_animString;
|
||||
default:
|
||||
return L"";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,26 +3,26 @@
|
||||
#include <string>
|
||||
|
||||
#include "DLCFile.h"
|
||||
#include "app/common/src/DLC/DLCManager.h"
|
||||
#include "app/common/DLC/DLCManager.h"
|
||||
|
||||
class DLCTextureFile : public DLCFile {
|
||||
private:
|
||||
bool m_bIsAnim;
|
||||
std::wstring m_animString;
|
||||
std::string m_animString;
|
||||
|
||||
std::uint8_t* m_pbData;
|
||||
std::uint32_t m_dataBytes;
|
||||
|
||||
public:
|
||||
DLCTextureFile(const std::wstring& path);
|
||||
DLCTextureFile(const std::string& path);
|
||||
|
||||
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
|
||||
virtual std::uint8_t* getData(std::uint32_t& dataBytes);
|
||||
|
||||
virtual void addParameter(DLCManager::EDLCParameterType type,
|
||||
const std::wstring& value);
|
||||
const std::string& value);
|
||||
|
||||
virtual std::wstring getParameterAsString(
|
||||
virtual std::string getParameterAsString(
|
||||
DLCManager::EDLCParameterType type);
|
||||
virtual bool getParameterAsBool(DLCManager::EDLCParameterType type);
|
||||
};
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "DLCUIDataFile.h"
|
||||
|
||||
#include "DLCManager.h"
|
||||
#include "app/common/src/DLC/DLCFile.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "app/common/DLC/DLCFile.h"
|
||||
#include "app/common/Game.h"
|
||||
|
||||
DLCUIDataFile::DLCUIDataFile(const std::wstring& path)
|
||||
DLCUIDataFile::DLCUIDataFile(const std::string& path)
|
||||
: DLCFile(DLCManager::e_DLCType_UIData, path) {
|
||||
m_pbData = nullptr;
|
||||
m_dataBytes = 0;
|
||||
@@ -11,7 +11,7 @@ private:
|
||||
bool m_canDeleteData;
|
||||
|
||||
public:
|
||||
DLCUIDataFile(const std::wstring& path);
|
||||
DLCUIDataFile(const std::string& path);
|
||||
~DLCUIDataFile();
|
||||
|
||||
using DLCFile::addData;
|
||||
@@ -0,0 +1,701 @@
|
||||
#include "app/common/DLCController.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <mutex>
|
||||
|
||||
#include "app/common/DLC/DLCManager.h"
|
||||
#include "app/common/DLC/DLCPack.h"
|
||||
#include "app/common/DLC/DLCSkinFile.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/UI/ConsoleUIController.h"
|
||||
#include "minecraft/client/Minecraft.h"
|
||||
#include "minecraft/client/skins/TexturePack.h"
|
||||
#include "minecraft/client/skins/TexturePackRepository.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
#include "platform/profile/profile.h"
|
||||
#include "platform/storage/storage.h"
|
||||
|
||||
DLCController::DLCController() {
|
||||
m_pDLCFileBuffer = nullptr;
|
||||
m_dwDLCFileSize = 0;
|
||||
m_bDefaultCapeInstallAttempted = false;
|
||||
m_bDLCInstallProcessCompleted = false;
|
||||
m_bDLCInstallPending = false;
|
||||
m_iTotalDLC = 0;
|
||||
m_iTotalDLCInstalled = 0;
|
||||
m_bNewDLCAvailable = false;
|
||||
m_bSeenNewDLCTip = false;
|
||||
m_iDLCOfferC = 0;
|
||||
m_bAllDLCContentRetrieved = true;
|
||||
m_bAllTMSContentRetrieved = true;
|
||||
m_bTickTMSDLCFiles = true;
|
||||
}
|
||||
|
||||
std::unordered_map<PlayerUID, MOJANG_DATA*> DLCController::MojangData;
|
||||
std::unordered_map<int, uint64_t> DLCController::DLCTextures_PackID;
|
||||
std::unordered_map<uint64_t, DLC_INFO*> DLCController::DLCInfo_Trial;
|
||||
std::unordered_map<uint64_t, DLC_INFO*> DLCController::DLCInfo_Full;
|
||||
std::unordered_map<std::string, uint64_t> DLCController::DLCInfo_SkinName;
|
||||
|
||||
std::uint32_t DLCController::m_dwContentTypeA[e_Marketplace_MAX] = {
|
||||
XMARKETPLACE_OFFERING_TYPE_CONTENT,
|
||||
XMARKETPLACE_OFFERING_TYPE_THEME,
|
||||
XMARKETPLACE_OFFERING_TYPE_AVATARITEM,
|
||||
XMARKETPLACE_OFFERING_TYPE_TILE,
|
||||
};
|
||||
|
||||
int DLCController::marketplaceCountsCallback(
|
||||
void* pParam, IPlatformStorage::DLC_TMS_DETAILS* pTMSDetails, int iPad) {
|
||||
app.DebugPrintf("Marketplace Counts= New - %d Total - %d\n",
|
||||
pTMSDetails->dwNewOffers, pTMSDetails->dwTotalOffers);
|
||||
|
||||
if (pTMSDetails->dwNewOffers > 0) {
|
||||
app.m_dlcController.m_bNewDLCAvailable = true;
|
||||
app.m_dlcController.m_bSeenNewDLCTip = false;
|
||||
} else {
|
||||
app.m_dlcController.m_bNewDLCAvailable = false;
|
||||
app.m_dlcController.m_bSeenNewDLCTip = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool DLCController::startInstallDLCProcess(int iPad) {
|
||||
app.DebugPrintf("--- DLCController::startInstallDLCProcess: pad=%i.\n",
|
||||
iPad);
|
||||
|
||||
if ((dlcInstallProcessCompleted() == false) &&
|
||||
(m_bDLCInstallPending == false)) {
|
||||
app.m_dlcManager.resetUnnamedCorruptCount();
|
||||
m_bDLCInstallPending = true;
|
||||
m_iTotalDLC = 0;
|
||||
m_iTotalDLCInstalled = 0;
|
||||
app.DebugPrintf(
|
||||
"--- DLCController::startInstallDLCProcess - "
|
||||
"PlatformStorage.GetInstalledDLC\n");
|
||||
|
||||
PlatformStorage.GetInstalledDLC(iPad, [this](int iInstalledC, int pad) {
|
||||
return dlcInstalledCallback(iInstalledC, pad);
|
||||
});
|
||||
return true;
|
||||
} else {
|
||||
app.DebugPrintf(
|
||||
"--- DLCController::startInstallDLCProcess - nothing to do\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int DLCController::dlcInstalledCallback(int iInstalledC, int iPad) {
|
||||
app.DebugPrintf(
|
||||
"--- DLCController::dlcInstalledCallback: totalDLC=%i, pad=%i.\n",
|
||||
iInstalledC, iPad);
|
||||
m_iTotalDLC = iInstalledC;
|
||||
mountNextDLC(iPad);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DLCController::mountNextDLC(int iPad) {
|
||||
app.DebugPrintf("--- DLCController::mountNextDLC: pad=%i.\n", iPad);
|
||||
if (m_iTotalDLCInstalled < m_iTotalDLC) {
|
||||
if (PlatformStorage.MountInstalledDLC(
|
||||
iPad, m_iTotalDLCInstalled,
|
||||
[this](int pad, std::uint32_t dwErr,
|
||||
std::uint32_t dwLicenceMask) {
|
||||
return dlcMountedCallback(pad, dwErr, dwLicenceMask);
|
||||
}) != 997 /* ERROR_IO_PENDING */) {
|
||||
app.DebugPrintf("Failed to mount DLC %d for pad %d\n",
|
||||
m_iTotalDLCInstalled, iPad);
|
||||
++m_iTotalDLCInstalled;
|
||||
mountNextDLC(iPad);
|
||||
} else {
|
||||
app.DebugPrintf("PlatformStorage.MountInstalledDLC ok\n");
|
||||
}
|
||||
} else {
|
||||
m_bDLCInstallPending = false;
|
||||
m_bDLCInstallProcessCompleted = true;
|
||||
ui.HandleDLCMountingComplete();
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_WINDOWS64)
|
||||
#define CONTENT_DATA_DISPLAY_NAME(a) (a.szDisplayName)
|
||||
#else
|
||||
#define CONTENT_DATA_DISPLAY_NAME(a) (a.wszDisplayName)
|
||||
#endif
|
||||
|
||||
int DLCController::dlcMountedCallback(int iPad, std::uint32_t dwErr,
|
||||
std::uint32_t dwLicenceMask) {
|
||||
#if defined(_WINDOWS64)
|
||||
app.DebugPrintf("--- DLCController::dlcMountedCallback\n");
|
||||
|
||||
if (dwErr != 0 /* ERROR_SUCCESS */) {
|
||||
app.DebugPrintf("Failed to mount DLC for pad %d: %u\n", iPad, dwErr);
|
||||
app.m_dlcManager.incrementUnnamedCorruptCount();
|
||||
} else {
|
||||
XCONTENT_DATA ContentData =
|
||||
PlatformStorage.GetDLC(m_iTotalDLCInstalled);
|
||||
|
||||
DLCPack* pack =
|
||||
app.m_dlcManager.getPack(CONTENT_DATA_DISPLAY_NAME(ContentData));
|
||||
|
||||
if (pack != nullptr && pack->IsCorrupt()) {
|
||||
app.DebugPrintf(
|
||||
"Pack '%s' is corrupt, removing it from the DLC Manager.\n",
|
||||
CONTENT_DATA_DISPLAY_NAME(ContentData));
|
||||
app.m_dlcManager.removePack(pack);
|
||||
pack = nullptr;
|
||||
}
|
||||
|
||||
if (pack == nullptr) {
|
||||
app.DebugPrintf("Pack \"%s\" is not installed, so adding it\n",
|
||||
CONTENT_DATA_DISPLAY_NAME(ContentData));
|
||||
|
||||
#if defined(_WINDOWS64)
|
||||
pack = new DLCPack(ContentData.szDisplayName, dwLicenceMask);
|
||||
#else
|
||||
pack = new DLCPack(ContentData.wszDisplayName, dwLicenceMask);
|
||||
#endif
|
||||
pack->SetDLCMountIndex(m_iTotalDLCInstalled);
|
||||
pack->SetDLCDeviceID(ContentData.DeviceID);
|
||||
app.m_dlcManager.addPack(pack);
|
||||
handleDLC(pack);
|
||||
|
||||
if (pack->getDLCItemsCount(DLCManager::e_DLCType_Texture) > 0) {
|
||||
Minecraft::GetInstance()->skins->addTexturePackFromDLC(
|
||||
pack, pack->GetPackId());
|
||||
}
|
||||
} else {
|
||||
app.DebugPrintf(
|
||||
"Pack \"%s\" is already installed. Updating license to %u\n",
|
||||
CONTENT_DATA_DISPLAY_NAME(ContentData), dwLicenceMask);
|
||||
|
||||
pack->SetDLCMountIndex(m_iTotalDLCInstalled);
|
||||
pack->SetDLCDeviceID(ContentData.DeviceID);
|
||||
pack->updateLicenseMask(dwLicenceMask);
|
||||
}
|
||||
|
||||
PlatformStorage.UnmountInstalledDLC();
|
||||
}
|
||||
++m_iTotalDLCInstalled;
|
||||
mountNextDLC(iPad);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#undef CONTENT_DATA_DISPLAY_NAME
|
||||
|
||||
void DLCController::handleDLC(DLCPack* pack) {
|
||||
unsigned int dwFilesProcessed = 0;
|
||||
std::vector<std::string> dlcFilenames;
|
||||
PlatformStorage.GetMountedDLCFileList("DLCDrive", dlcFilenames);
|
||||
for (int i = 0; i < dlcFilenames.size(); i++) {
|
||||
app.m_dlcManager.readDLCDataFile(dwFilesProcessed, dlcFilenames[i],
|
||||
pack);
|
||||
}
|
||||
if (dwFilesProcessed == 0) app.m_dlcManager.removePack(pack);
|
||||
}
|
||||
|
||||
void DLCController::addCreditText(const char* lpStr) {
|
||||
app.DebugPrintf("ADDING CREDIT - %s\n", lpStr);
|
||||
SCreditTextItemDef* pCreditStruct = new SCreditTextItemDef;
|
||||
pCreditStruct->m_eType = eSmallText;
|
||||
pCreditStruct->m_iStringID[0] = NO_TRANSLATED_STRING;
|
||||
pCreditStruct->m_iStringID[1] = NO_TRANSLATED_STRING;
|
||||
pCreditStruct->m_Text = new char[strlen(lpStr) + 1];
|
||||
strcpy((char*)pCreditStruct->m_Text, lpStr);
|
||||
vDLCCredits.push_back(pCreditStruct);
|
||||
}
|
||||
|
||||
bool DLCController::alreadySeenCreditText(const std::string& wstemp) {
|
||||
for (unsigned int i = 0; i < m_vCreditText.size(); i++) {
|
||||
std::string temp = m_vCreditText.at(i);
|
||||
if (temp.compare(wstemp) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
m_vCreditText.push_back((char*)wstemp.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int DLCController::getDLCCreditsCount() {
|
||||
return (unsigned int)vDLCCredits.size();
|
||||
}
|
||||
|
||||
SCreditTextItemDef* DLCController::getDLCCredits(int iIndex) {
|
||||
return vDLCCredits.at(iIndex);
|
||||
}
|
||||
|
||||
int32_t DLCController::registerDLCData(char* pType, char* pBannerName,
|
||||
int iGender, uint64_t ullOfferID_Full,
|
||||
uint64_t ullOfferID_Trial,
|
||||
char* pFirstSkin,
|
||||
unsigned int uiSortIndex, int iConfig,
|
||||
char* pDataFile) {
|
||||
int32_t hr = 0;
|
||||
DLC_INFO* pDLCData = new DLC_INFO;
|
||||
memset(pDLCData, 0, sizeof(DLC_INFO));
|
||||
pDLCData->ullOfferID_Full = ullOfferID_Full;
|
||||
pDLCData->ullOfferID_Trial = ullOfferID_Trial;
|
||||
pDLCData->eDLCType = e_DLC_NotDefined;
|
||||
pDLCData->iGender = iGender;
|
||||
pDLCData->uiSortIndex = uiSortIndex;
|
||||
pDLCData->iConfig = iConfig;
|
||||
|
||||
if (strcmp(pBannerName, "") != 0) {
|
||||
strncpy(pDLCData->wchBanner, pBannerName, MAX_BANNERNAME_SIZE);
|
||||
}
|
||||
if (pDataFile[0] != 0) {
|
||||
strncpy(pDLCData->wchDataFile, pDataFile, MAX_BANNERNAME_SIZE);
|
||||
}
|
||||
|
||||
if (pType != nullptr) {
|
||||
if (strcmp(pType, "Skin") == 0) {
|
||||
pDLCData->eDLCType = e_DLC_SkinPack;
|
||||
} else if (strcmp(pType, "Gamerpic") == 0) {
|
||||
pDLCData->eDLCType = e_DLC_Gamerpics;
|
||||
} else if (strcmp(pType, "Theme") == 0) {
|
||||
pDLCData->eDLCType = e_DLC_Themes;
|
||||
} else if (strcmp(pType, "Avatar") == 0) {
|
||||
pDLCData->eDLCType = e_DLC_AvatarItems;
|
||||
} else if (strcmp(pType, "MashUpPack") == 0) {
|
||||
pDLCData->eDLCType = e_DLC_MashupPacks;
|
||||
DLCTextures_PackID[pDLCData->iConfig] = ullOfferID_Full;
|
||||
} else if (strcmp(pType, "TexturePack") == 0) {
|
||||
pDLCData->eDLCType = e_DLC_TexturePacks;
|
||||
DLCTextures_PackID[pDLCData->iConfig] = ullOfferID_Full;
|
||||
}
|
||||
}
|
||||
|
||||
if (ullOfferID_Trial != 0ll) DLCInfo_Trial[ullOfferID_Trial] = pDLCData;
|
||||
if (ullOfferID_Full != 0ll) DLCInfo_Full[ullOfferID_Full] = pDLCData;
|
||||
if (pFirstSkin[0] != 0) DLCInfo_SkinName[pFirstSkin] = ullOfferID_Full;
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
bool DLCController::getDLCFullOfferIDForSkinID(const std::string& FirstSkin,
|
||||
uint64_t* pullVal) {
|
||||
auto it = DLCInfo_SkinName.find(FirstSkin);
|
||||
if (it == DLCInfo_SkinName.end()) {
|
||||
return false;
|
||||
} else {
|
||||
*pullVal = (uint64_t)it->second;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool DLCController::getDLCFullOfferIDForPackID(const int iPackID,
|
||||
uint64_t* pullVal) {
|
||||
auto it = DLCTextures_PackID.find(iPackID);
|
||||
if (it == DLCTextures_PackID.end()) {
|
||||
*pullVal = (uint64_t)0;
|
||||
return false;
|
||||
} else {
|
||||
*pullVal = (uint64_t)it->second;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
DLC_INFO* DLCController::getDLCInfoForTrialOfferID(uint64_t ullOfferID_Trial) {
|
||||
if (DLCInfo_Trial.size() > 0) {
|
||||
auto it = DLCInfo_Trial.find(ullOfferID_Trial);
|
||||
if (it == DLCInfo_Trial.end()) {
|
||||
return nullptr;
|
||||
} else {
|
||||
return it->second;
|
||||
}
|
||||
} else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DLC_INFO* DLCController::getDLCInfoForFullOfferID(uint64_t ullOfferID_Full) {
|
||||
if (DLCInfo_Full.size() > 0) {
|
||||
auto it = DLCInfo_Full.find(ullOfferID_Full);
|
||||
if (it == DLCInfo_Full.end()) {
|
||||
return nullptr;
|
||||
} else {
|
||||
return it->second;
|
||||
}
|
||||
} else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DLC_INFO* DLCController::getDLCInfoTrialOffer(int iIndex) {
|
||||
std::unordered_map<uint64_t, DLC_INFO*>::iterator it =
|
||||
DLCInfo_Trial.begin();
|
||||
for (int i = 0; i < iIndex; i++) {
|
||||
++it;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
DLC_INFO* DLCController::getDLCInfoFullOffer(int iIndex) {
|
||||
std::unordered_map<uint64_t, DLC_INFO*>::iterator it = DLCInfo_Full.begin();
|
||||
for (int i = 0; i < iIndex; i++) {
|
||||
++it;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
uint64_t DLCController::getDLCInfoTexturesFullOffer(int iIndex) {
|
||||
std::unordered_map<int, uint64_t>::iterator it = DLCTextures_PackID.begin();
|
||||
for (int i = 0; i < iIndex; i++) {
|
||||
++it;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
int DLCController::getDLCInfoTrialOffersCount() {
|
||||
return (int)DLCInfo_Trial.size();
|
||||
}
|
||||
|
||||
int DLCController::getDLCInfoFullOffersCount() {
|
||||
return (int)DLCInfo_Full.size();
|
||||
}
|
||||
|
||||
int DLCController::getDLCInfoTexturesOffersCount() {
|
||||
return (int)DLCTextures_PackID.size();
|
||||
}
|
||||
|
||||
unsigned int DLCController::addDLCRequest(eDLCMarketplaceType eType,
|
||||
bool bPromote) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(csDLCDownloadQueue);
|
||||
|
||||
int iPosition = 0;
|
||||
for (auto it = m_DLCDownloadQueue.begin();
|
||||
it != m_DLCDownloadQueue.end(); ++it) {
|
||||
DLCRequest* pCurrent = *it;
|
||||
if (pCurrent->dwType == m_dwContentTypeA[eType]) {
|
||||
if (pCurrent->eState == e_DLC_ContentState_Retrieving ||
|
||||
pCurrent->eState == e_DLC_ContentState_Retrieved) {
|
||||
return 0;
|
||||
} else {
|
||||
if (bPromote) {
|
||||
m_DLCDownloadQueue.erase(m_DLCDownloadQueue.begin() +
|
||||
iPosition);
|
||||
m_DLCDownloadQueue.insert(m_DLCDownloadQueue.begin(),
|
||||
pCurrent);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
iPosition++;
|
||||
}
|
||||
|
||||
DLCRequest* pDLCreq = new DLCRequest;
|
||||
pDLCreq->dwType = m_dwContentTypeA[eType];
|
||||
pDLCreq->eState = e_DLC_ContentState_Idle;
|
||||
m_DLCDownloadQueue.push_back(pDLCreq);
|
||||
m_bAllDLCContentRetrieved = false;
|
||||
}
|
||||
|
||||
app.DebugPrintf("[Consoles_App] Added DLC request.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool DLCController::retrieveNextDLCContent() {
|
||||
int primPad = PlatformProfile.GetPrimaryPad();
|
||||
if (primPad == -1 || !PlatformProfile.IsSignedInLive(primPad)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(csDLCDownloadQueue);
|
||||
for (auto it = m_DLCDownloadQueue.begin();
|
||||
it != m_DLCDownloadQueue.end(); ++it) {
|
||||
DLCRequest* pCurrent = *it;
|
||||
if (pCurrent->eState == e_DLC_ContentState_Retrieving) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = m_DLCDownloadQueue.begin();
|
||||
it != m_DLCDownloadQueue.end(); ++it) {
|
||||
DLCRequest* pCurrent = *it;
|
||||
if (pCurrent->eState == e_DLC_ContentState_Idle) {
|
||||
#if defined(_DEBUG)
|
||||
app.DebugPrintf("RetrieveNextDLCContent - type = %d\n",
|
||||
pCurrent->dwType);
|
||||
#endif
|
||||
IPlatformStorage::EDLCStatus status =
|
||||
PlatformStorage.GetDLCOffers(
|
||||
PlatformProfile.GetPrimaryPad(),
|
||||
[this](int iOfferC, std::uint32_t dwType, int pad) {
|
||||
return dlcOffersReturned(iOfferC, dwType, pad);
|
||||
},
|
||||
pCurrent->dwType);
|
||||
if (status == IPlatformStorage::EDLC_Pending) {
|
||||
pCurrent->eState = e_DLC_ContentState_Retrieving;
|
||||
} else {
|
||||
app.DebugPrintf("RetrieveNextDLCContent - PROBLEM\n");
|
||||
pCurrent->eState = e_DLC_ContentState_Retrieved;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
app.DebugPrintf("[Consoles_App] Finished downloading dlc content.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DLCController::checkTMSDLCCanStop() {
|
||||
std::lock_guard<std::mutex> lock(csTMSPPDownloadQueue);
|
||||
for (auto it = m_TMSPPDownloadQueue.begin();
|
||||
it != m_TMSPPDownloadQueue.end(); ++it) {
|
||||
TMSPPRequest* pCurrent = *it;
|
||||
if (pCurrent->eState == e_TMS_ContentState_Retrieving) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int DLCController::dlcOffersReturned(int iOfferC, std::uint32_t dwType,
|
||||
int iPad) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(csTMSPPDownloadQueue);
|
||||
for (auto it = m_DLCDownloadQueue.begin();
|
||||
it != m_DLCDownloadQueue.end(); ++it) {
|
||||
DLCRequest* pCurrent = *it;
|
||||
if (pCurrent->dwType == static_cast<std::uint32_t>(dwType)) {
|
||||
m_iDLCOfferC = iOfferC;
|
||||
app.DebugPrintf(
|
||||
"DLCOffersReturned - type %u, count %d - setting to "
|
||||
"retrieved\n",
|
||||
dwType, iOfferC);
|
||||
pCurrent->eState = e_DLC_ContentState_Retrieved;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
eDLCContentType DLCController::find_eDLCContentType(std::uint32_t dwType) {
|
||||
for (int i = 0; i < e_DLC_MAX; i++) {
|
||||
if (m_dwContentTypeA[i] == dwType) {
|
||||
return (eDLCContentType)i;
|
||||
}
|
||||
}
|
||||
return (eDLCContentType)0;
|
||||
}
|
||||
|
||||
bool DLCController::dlcContentRetrieved(eDLCMarketplaceType eType) {
|
||||
std::lock_guard<std::mutex> lock(csDLCDownloadQueue);
|
||||
for (auto it = m_DLCDownloadQueue.begin(); it != m_DLCDownloadQueue.end();
|
||||
++it) {
|
||||
DLCRequest* pCurrent = *it;
|
||||
if ((pCurrent->dwType == m_dwContentTypeA[eType]) &&
|
||||
(pCurrent->eState == e_DLC_ContentState_Retrieved)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DLCController::tickDLCOffersRetrieved() {
|
||||
if (!m_bAllDLCContentRetrieved) {
|
||||
if (!retrieveNextDLCContent()) {
|
||||
app.DebugPrintf("[Consoles_App] All content retrieved.\n");
|
||||
m_bAllDLCContentRetrieved = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DLCController::clearAndResetDLCDownloadQueue() {
|
||||
app.DebugPrintf("[Consoles_App] Clear and reset download queue.\n");
|
||||
|
||||
int iPosition = 0;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(csTMSPPDownloadQueue);
|
||||
for (auto it = m_DLCDownloadQueue.begin();
|
||||
it != m_DLCDownloadQueue.end(); ++it) {
|
||||
DLCRequest* pCurrent = *it;
|
||||
delete pCurrent;
|
||||
iPosition++;
|
||||
}
|
||||
m_DLCDownloadQueue.clear();
|
||||
m_bAllDLCContentRetrieved = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool DLCController::retrieveNextTMSPPContent() { return false; }
|
||||
|
||||
void DLCController::tickTMSPPFilesRetrieved() {
|
||||
if (m_bTickTMSDLCFiles && !m_bAllTMSContentRetrieved) {
|
||||
if (retrieveNextTMSPPContent() == false) {
|
||||
m_bAllTMSContentRetrieved = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DLCController::clearTMSPPFilesRetrieved() {
|
||||
int iPosition = 0;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(csTMSPPDownloadQueue);
|
||||
for (auto it = m_TMSPPDownloadQueue.begin();
|
||||
it != m_TMSPPDownloadQueue.end(); ++it) {
|
||||
TMSPPRequest* pCurrent = *it;
|
||||
delete pCurrent;
|
||||
iPosition++;
|
||||
}
|
||||
m_TMSPPDownloadQueue.clear();
|
||||
m_bAllTMSContentRetrieved = true;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int DLCController::addTMSPPFileTypeRequest(eDLCContentType eType,
|
||||
bool bPromote) {
|
||||
std::lock_guard<std::mutex> lock(csTMSPPDownloadQueue);
|
||||
|
||||
if (eType == e_DLC_TexturePackData) {
|
||||
int iCount = getDLCInfoFullOffersCount();
|
||||
|
||||
for (int i = 0; i < iCount; i++) {
|
||||
DLC_INFO* pDLC = getDLCInfoFullOffer(i);
|
||||
|
||||
if ((pDLC->eDLCType == e_DLC_TexturePacks) ||
|
||||
(pDLC->eDLCType == e_DLC_MashupPacks)) {
|
||||
if (pDLC->wchDataFile[0] != 0) {
|
||||
{
|
||||
bool bPresent = app.IsFileInTPD(pDLC->iConfig);
|
||||
|
||||
if (!bPresent) {
|
||||
bool bAlreadyInQueue = false;
|
||||
for (auto it = m_TMSPPDownloadQueue.begin();
|
||||
it != m_TMSPPDownloadQueue.end(); ++it) {
|
||||
TMSPPRequest* pCurrent = *it;
|
||||
if (strcmp(pDLC->wchDataFile,
|
||||
pCurrent->wchFilename) == 0) {
|
||||
bAlreadyInQueue = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bAlreadyInQueue) {
|
||||
TMSPPRequest* pTMSPPreq = new TMSPPRequest;
|
||||
pTMSPPreq->CallbackFunc =
|
||||
&DLCController::tmsPPFileReturned;
|
||||
pTMSPPreq->lpCallbackParam = this;
|
||||
pTMSPPreq->eStorageFacility =
|
||||
IPlatformStorage::eGlobalStorage_Title;
|
||||
pTMSPPreq->eFileTypeVal =
|
||||
IPlatformStorage::TMS_FILETYPE_BINARY;
|
||||
memcpy(pTMSPPreq->wchFilename,
|
||||
pDLC->wchDataFile,
|
||||
sizeof(char) * MAX_BANNERNAME_SIZE);
|
||||
pTMSPPreq->eType = e_DLC_TexturePackData;
|
||||
pTMSPPreq->eState = e_TMS_ContentState_Queued;
|
||||
m_bAllTMSContentRetrieved = false;
|
||||
m_TMSPPDownloadQueue.push_back(pTMSPPreq);
|
||||
}
|
||||
} else {
|
||||
app.DebugPrintf(
|
||||
"Texture data already present in the TPD\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int iCount;
|
||||
iCount = getDLCInfoFullOffersCount();
|
||||
for (int i = 0; i < iCount; i++) {
|
||||
DLC_INFO* pDLC = getDLCInfoFullOffer(i);
|
||||
if (pDLC->eDLCType == eType) {
|
||||
char* cString = pDLC->wchBanner;
|
||||
{
|
||||
bool bPresent = app.IsFileInMemoryTextures(cString);
|
||||
|
||||
if (!bPresent) {
|
||||
bool bAlreadyInQueue = false;
|
||||
for (auto it = m_TMSPPDownloadQueue.begin();
|
||||
it != m_TMSPPDownloadQueue.end(); ++it) {
|
||||
TMSPPRequest* pCurrent = *it;
|
||||
if (strcmp(pDLC->wchBanner,
|
||||
pCurrent->wchFilename) == 0) {
|
||||
bAlreadyInQueue = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bAlreadyInQueue) {
|
||||
TMSPPRequest* pTMSPPreq = new TMSPPRequest;
|
||||
memset(pTMSPPreq, 0, sizeof(TMSPPRequest));
|
||||
pTMSPPreq->CallbackFunc =
|
||||
&DLCController::tmsPPFileReturned;
|
||||
pTMSPPreq->lpCallbackParam = this;
|
||||
pTMSPPreq->eStorageFacility =
|
||||
IPlatformStorage::eGlobalStorage_Title;
|
||||
pTMSPPreq->eFileTypeVal =
|
||||
IPlatformStorage::TMS_FILETYPE_BINARY;
|
||||
memcpy(pTMSPPreq->wchFilename, pDLC->wchBanner,
|
||||
sizeof(char) * MAX_BANNERNAME_SIZE);
|
||||
pTMSPPreq->eType = eType;
|
||||
pTMSPPreq->eState = e_TMS_ContentState_Queued;
|
||||
m_bAllTMSContentRetrieved = false;
|
||||
m_TMSPPDownloadQueue.push_back(pTMSPPreq);
|
||||
app.DebugPrintf(
|
||||
"===m_TMSPPDownloadQueue Adding %s, q size is "
|
||||
"%d\n",
|
||||
pTMSPPreq->wchFilename,
|
||||
m_TMSPPDownloadQueue.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int DLCController::tmsPPFileReturned(
|
||||
void* pParam, int iPad, int iUserData,
|
||||
IPlatformStorage::PTMSPP_FILEDATA pFileData, const char* szFilename) {
|
||||
DLCController* pClass = (DLCController*)pParam;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(pClass->csTMSPPDownloadQueue);
|
||||
for (auto it = pClass->m_TMSPPDownloadQueue.begin();
|
||||
it != pClass->m_TMSPPDownloadQueue.end(); ++it) {
|
||||
TMSPPRequest* pCurrent = *it;
|
||||
#if defined(_WINDOWS64)
|
||||
char szFile[MAX_TMSFILENAME_SIZE];
|
||||
strncpy(szFile, pCurrent->wchFilename, MAX_TMSFILENAME_SIZE);
|
||||
|
||||
if (strcmp(szFilename, szFile) == 0)
|
||||
#endif
|
||||
{
|
||||
pCurrent->eState = e_TMS_ContentState_Retrieved;
|
||||
|
||||
if (pFileData != nullptr) {
|
||||
switch (pCurrent->eType) {
|
||||
case e_DLC_TexturePackData: {
|
||||
app.DebugPrintf("--- Got texturepack data %s\n",
|
||||
pCurrent->wchFilename);
|
||||
int iConfig =
|
||||
app.GetTPConfigVal(pCurrent->wchFilename);
|
||||
app.AddMemoryTPDFile(iConfig, pFileData->pbData,
|
||||
pFileData->size);
|
||||
} break;
|
||||
default:
|
||||
app.DebugPrintf("--- Got image data - %s\n",
|
||||
pCurrent->wchFilename);
|
||||
app.AddMemoryTextureFile(pCurrent->wchFilename,
|
||||
pFileData->pbData,
|
||||
pFileData->size);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
app.DebugPrintf("TMSImageReturned failed (%s)...\n",
|
||||
szFilename);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "app/common/App_structs.h"
|
||||
#include "app/common/DLC/DLCManager.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
#include "platform/storage/storage.h"
|
||||
|
||||
struct SCreditTextItemDef;
|
||||
|
||||
class DLCPack;
|
||||
|
||||
class DLCController {
|
||||
public:
|
||||
DLCController();
|
||||
|
||||
// Install process
|
||||
bool startInstallDLCProcess(int iPad);
|
||||
int dlcInstalledCallback(int iInstalledC, int iPad);
|
||||
void mountNextDLC(int iPad);
|
||||
int dlcMountedCallback(int iPad, std::uint32_t dwErr,
|
||||
std::uint32_t dwLicenceMask);
|
||||
void handleDLC(DLCPack* pack);
|
||||
|
||||
bool dlcInstallPending() { return m_bDLCInstallPending; }
|
||||
bool dlcInstallProcessCompleted() { return m_bDLCInstallProcessCompleted; }
|
||||
void clearDLCInstalled() { m_bDLCInstallProcessCompleted = false; }
|
||||
|
||||
static int marketplaceCountsCallback(void* pParam,
|
||||
IPlatformStorage::DLC_TMS_DETAILS*,
|
||||
int iPad);
|
||||
|
||||
// DLC info registration
|
||||
static int32_t registerDLCData(char*, char*, int, uint64_t, uint64_t, char*,
|
||||
unsigned int, int, char* pDataFile);
|
||||
bool getDLCFullOfferIDForSkinID(const std::string& FirstSkin,
|
||||
uint64_t* pullVal);
|
||||
bool getDLCFullOfferIDForPackID(const int iPackID, uint64_t* pullVal);
|
||||
DLC_INFO* getDLCInfoForTrialOfferID(uint64_t ullOfferID_Trial);
|
||||
DLC_INFO* getDLCInfoForFullOfferID(uint64_t ullOfferID_Full);
|
||||
DLC_INFO* getDLCInfoTrialOffer(int iIndex);
|
||||
DLC_INFO* getDLCInfoFullOffer(int iIndex);
|
||||
uint64_t getDLCInfoTexturesFullOffer(int iIndex);
|
||||
int getDLCInfoTrialOffersCount();
|
||||
int getDLCInfoFullOffersCount();
|
||||
int getDLCInfoTexturesOffersCount();
|
||||
|
||||
// DLC content/offers
|
||||
unsigned int addDLCRequest(eDLCMarketplaceType eContentType,
|
||||
bool bPromote = false);
|
||||
bool retrieveNextDLCContent();
|
||||
bool checkTMSDLCCanStop();
|
||||
int dlcOffersReturned(int iOfferC, std::uint32_t dwType, int iPad);
|
||||
std::uint32_t getDLCContentType(eDLCContentType eType) {
|
||||
return m_dwContentTypeA[eType];
|
||||
}
|
||||
eDLCContentType find_eDLCContentType(std::uint32_t dwType);
|
||||
int getDLCOffersCount() { return m_iDLCOfferC; }
|
||||
bool dlcContentRetrieved(eDLCMarketplaceType eType);
|
||||
void tickDLCOffersRetrieved();
|
||||
void clearAndResetDLCDownloadQueue();
|
||||
|
||||
// TMS/TMSPP
|
||||
bool retrieveNextTMSPPContent();
|
||||
void tickTMSPPFilesRetrieved();
|
||||
void clearTMSPPFilesRetrieved();
|
||||
unsigned int addTMSPPFileTypeRequest(eDLCContentType eType,
|
||||
bool bPromote = false);
|
||||
static int tmsPPFileReturned(void* pParam, int iPad, int iUserData,
|
||||
IPlatformStorage::PTMSPP_FILEDATA pFileData,
|
||||
const char* szFilename);
|
||||
|
||||
// Credit text
|
||||
void addCreditText(const char* lpStr);
|
||||
bool alreadySeenCreditText(const std::string& wstemp);
|
||||
unsigned int getDLCCreditsCount();
|
||||
SCreditTextItemDef* getDLCCredits(int iIndex);
|
||||
|
||||
// New DLC available
|
||||
void clearNewDLCAvailable() {
|
||||
m_bNewDLCAvailable = false;
|
||||
m_bSeenNewDLCTip = true;
|
||||
}
|
||||
bool getNewDLCAvailable() { return m_bNewDLCAvailable; }
|
||||
void displayNewDLCTipAgain() { m_bSeenNewDLCTip = false; }
|
||||
bool displayNewDLCTip() {
|
||||
if (!m_bSeenNewDLCTip) {
|
||||
m_bSeenNewDLCTip = true;
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
void setTickTMSDLCFiles(bool bVal) { m_bTickTMSDLCFiles = bVal; }
|
||||
|
||||
// Public data needed by other parts
|
||||
std::vector<std::string> m_vCreditText;
|
||||
std::uint8_t* m_pDLCFileBuffer;
|
||||
unsigned int m_dwDLCFileSize;
|
||||
|
||||
// DLC install counters (accessed by dlcMountedCallback)
|
||||
int m_iTotalDLC;
|
||||
int m_iTotalDLCInstalled;
|
||||
|
||||
// Static maps
|
||||
static std::unordered_map<PlayerUID, MOJANG_DATA*> MojangData;
|
||||
static std::unordered_map<int, uint64_t> DLCTextures_PackID;
|
||||
static std::unordered_map<uint64_t, DLC_INFO*> DLCInfo_Trial;
|
||||
static std::unordered_map<uint64_t, DLC_INFO*> DLCInfo_Full;
|
||||
static std::unordered_map<std::string, uint64_t> DLCInfo_SkinName;
|
||||
static std::uint32_t m_dwContentTypeA[e_Marketplace_MAX];
|
||||
|
||||
private:
|
||||
std::vector<SCreditTextItemDef*> vDLCCredits;
|
||||
std::vector<DLCRequest*> m_DLCDownloadQueue;
|
||||
std::vector<TMSPPRequest*> m_TMSPPDownloadQueue;
|
||||
|
||||
int m_iDLCOfferC;
|
||||
bool m_bAllDLCContentRetrieved;
|
||||
bool m_bAllTMSContentRetrieved;
|
||||
bool m_bTickTMSDLCFiles;
|
||||
std::mutex csDLCDownloadQueue;
|
||||
std::mutex csTMSPPDownloadQueue;
|
||||
|
||||
bool m_bDLCInstallProcessCompleted;
|
||||
bool m_bDLCInstallPending;
|
||||
bool m_bDefaultCapeInstallAttempted;
|
||||
|
||||
bool m_bNewDLCAvailable;
|
||||
bool m_bSeenNewDLCTip;
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "app/common/DebugOptions.h"
|
||||
|
||||
DebugOptions::DebugOptions() {
|
||||
#if defined(_DEBUG_MENUS_ENABLED)
|
||||
#if defined(_CONTENT_PACKAGE)
|
||||
m_bDebugOptions =
|
||||
false; // make them off by default in a content package build
|
||||
#else
|
||||
m_bDebugOptions = true;
|
||||
#endif
|
||||
#else
|
||||
m_bDebugOptions = false;
|
||||
#endif
|
||||
|
||||
m_bLoadSavesFromFolderEnabled = false;
|
||||
m_bWriteSavesToFolderEnabled = false;
|
||||
m_bMobsDontAttack = false;
|
||||
m_bMobsDontTick = false;
|
||||
m_bFreezePlayers = false;
|
||||
|
||||
#if defined(_CONTENT_PACAKGE)
|
||||
m_bUseDPadForDebug = false;
|
||||
#else
|
||||
m_bUseDPadForDebug = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(_DEBUG_MENUS_ENABLED)
|
||||
bool DebugOptions::debugArtToolsOn(unsigned int debugMask) {
|
||||
return settingsOn() && (debugMask & (1L << eDebugSetting_ArtTools)) != 0;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include "minecraft/Console_Debug_enum.h"
|
||||
|
||||
class DebugOptions {
|
||||
public:
|
||||
DebugOptions();
|
||||
|
||||
bool settingsOn() const { return m_bDebugOptions; }
|
||||
void setDebugOptions(bool bVal) { m_bDebugOptions = bVal; }
|
||||
|
||||
bool getLoadSavesFromFolderEnabled() const {
|
||||
return m_bLoadSavesFromFolderEnabled;
|
||||
}
|
||||
void setLoadSavesFromFolderEnabled(bool bVal) {
|
||||
m_bLoadSavesFromFolderEnabled = bVal;
|
||||
}
|
||||
|
||||
bool getWriteSavesToFolderEnabled() const {
|
||||
return m_bWriteSavesToFolderEnabled;
|
||||
}
|
||||
void setWriteSavesToFolderEnabled(bool bVal) {
|
||||
m_bWriteSavesToFolderEnabled = bVal;
|
||||
}
|
||||
|
||||
bool getMobsDontAttack() const { return m_bMobsDontAttack; }
|
||||
void setMobsDontAttack(bool bVal) { m_bMobsDontAttack = bVal; }
|
||||
|
||||
bool getUseDPadForDebug() const { return m_bUseDPadForDebug; }
|
||||
void setUseDPadForDebug(bool bVal) { m_bUseDPadForDebug = bVal; }
|
||||
|
||||
bool getMobsDontTick() const { return m_bMobsDontTick; }
|
||||
void setMobsDontTick(bool bVal) { m_bMobsDontTick = bVal; }
|
||||
|
||||
bool getFreezePlayers() const { return m_bFreezePlayers; }
|
||||
void setFreezePlayers(bool bVal) { m_bFreezePlayers = bVal; }
|
||||
|
||||
#if defined(_DEBUG_MENUS_ENABLED)
|
||||
bool debugArtToolsOn(unsigned int debugMask);
|
||||
#else
|
||||
bool debugArtToolsOn(unsigned int) { return false; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
bool m_bDebugOptions;
|
||||
bool m_bLoadSavesFromFolderEnabled;
|
||||
bool m_bWriteSavesToFolderEnabled;
|
||||
bool m_bMobsDontAttack;
|
||||
bool m_bUseDPadForDebug;
|
||||
bool m_bMobsDontTick;
|
||||
bool m_bFreezePlayers;
|
||||
};
|
||||
@@ -0,0 +1,89 @@
|
||||
#include "app/common/GameMenuService.h"
|
||||
|
||||
#include "app/common/Game.h"
|
||||
|
||||
bool GameMenuService::openInventory(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player,
|
||||
bool navigateBack) {
|
||||
return game_.LoadInventoryMenu(iPad, player, navigateBack);
|
||||
}
|
||||
bool GameMenuService::openCreative(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player,
|
||||
bool navigateBack) {
|
||||
return game_.LoadCreativeMenu(iPad, player, navigateBack);
|
||||
}
|
||||
bool GameMenuService::openCrafting2x2(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player) {
|
||||
return game_.LoadCrafting2x2Menu(iPad, player);
|
||||
}
|
||||
bool GameMenuService::openCrafting3x3(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player,
|
||||
int x, int y, int z) {
|
||||
return game_.LoadCrafting3x3Menu(iPad, player, x, y, z);
|
||||
}
|
||||
bool GameMenuService::openEnchanting(int iPad,
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
int x, int y, int z, Level* level,
|
||||
const std::string& name) {
|
||||
return game_.LoadEnchantingMenu(iPad, inventory, x, y, z, level, name);
|
||||
}
|
||||
bool GameMenuService::openFurnace(int iPad,
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<FurnaceTileEntity> furnace) {
|
||||
return game_.LoadFurnaceMenu(iPad, inventory, furnace);
|
||||
}
|
||||
bool GameMenuService::openBrewingStand(
|
||||
int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<BrewingStandTileEntity> brewingStand) {
|
||||
return game_.LoadBrewingStandMenu(iPad, inventory, brewingStand);
|
||||
}
|
||||
bool GameMenuService::openContainer(int iPad,
|
||||
std::shared_ptr<Container> inventory,
|
||||
std::shared_ptr<Container> container) {
|
||||
return game_.LoadContainerMenu(iPad, inventory, container);
|
||||
}
|
||||
bool GameMenuService::openTrap(int iPad, std::shared_ptr<Container> inventory,
|
||||
std::shared_ptr<DispenserTileEntity> trap) {
|
||||
return game_.LoadTrapMenu(iPad, inventory, trap);
|
||||
}
|
||||
bool GameMenuService::openFireworks(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player, int x,
|
||||
int y, int z) {
|
||||
return game_.LoadFireworksMenu(iPad, player, x, y, z);
|
||||
}
|
||||
bool GameMenuService::openSign(int iPad, std::shared_ptr<SignTileEntity> sign) {
|
||||
return game_.LoadSignEntryMenu(iPad, sign);
|
||||
}
|
||||
bool GameMenuService::openRepairing(int iPad,
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
Level* level, int x, int y, int z) {
|
||||
return game_.LoadRepairingMenu(iPad, inventory, level, x, y, z);
|
||||
}
|
||||
bool GameMenuService::openTrading(int iPad,
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Merchant> trader,
|
||||
Level* level, const std::string& name) {
|
||||
return game_.LoadTradingMenu(iPad, inventory, trader, level, name);
|
||||
}
|
||||
bool GameMenuService::openCommandBlock(
|
||||
int iPad, std::shared_ptr<CommandBlockEntity> commandBlock) {
|
||||
return game_.LoadCommandBlockMenu(iPad, commandBlock);
|
||||
}
|
||||
bool GameMenuService::openHopper(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<HopperTileEntity> hopper) {
|
||||
return game_.LoadHopperMenu(iPad, inventory, hopper);
|
||||
}
|
||||
bool GameMenuService::openHopperMinecart(
|
||||
int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<MinecartHopper> hopper) {
|
||||
return game_.LoadHopperMenu(iPad, inventory, hopper);
|
||||
}
|
||||
bool GameMenuService::openHorse(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Container> container,
|
||||
std::shared_ptr<EntityHorse> horse) {
|
||||
return game_.LoadHorseMenu(iPad, inventory, container, horse);
|
||||
}
|
||||
bool GameMenuService::openBeacon(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<BeaconTileEntity> beacon) {
|
||||
return game_.LoadBeaconMenu(iPad, inventory, beacon);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include "minecraft/client/IMenuService.h"
|
||||
|
||||
class Game;
|
||||
|
||||
class GameMenuService : public IMenuService {
|
||||
public:
|
||||
explicit GameMenuService(Game& game) : game_(game) {}
|
||||
|
||||
bool openInventory(int iPad, std::shared_ptr<LocalPlayer> player,
|
||||
bool navigateBack) override;
|
||||
bool openCreative(int iPad, std::shared_ptr<LocalPlayer> player,
|
||||
bool navigateBack) override;
|
||||
bool openCrafting2x2(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player) override;
|
||||
bool openCrafting3x3(int iPad, std::shared_ptr<LocalPlayer> player, int x,
|
||||
int y, int z) override;
|
||||
bool openEnchanting(int iPad, std::shared_ptr<Inventory> inventory, int x,
|
||||
int y, int z, Level* level,
|
||||
const std::string& name) override;
|
||||
bool openFurnace(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<FurnaceTileEntity> furnace) override;
|
||||
bool openBrewingStand(
|
||||
int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<BrewingStandTileEntity> brewingStand) override;
|
||||
bool openContainer(int iPad, std::shared_ptr<Container> inventory,
|
||||
std::shared_ptr<Container> container) override;
|
||||
bool openTrap(int iPad, std::shared_ptr<Container> inventory,
|
||||
std::shared_ptr<DispenserTileEntity> trap) override;
|
||||
bool openFireworks(int iPad, std::shared_ptr<LocalPlayer> player, int x,
|
||||
int y, int z) override;
|
||||
bool openSign(int iPad, std::shared_ptr<SignTileEntity> sign) override;
|
||||
bool openRepairing(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
Level* level, int x, int y, int z) override;
|
||||
bool openTrading(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Merchant> trader, Level* level,
|
||||
const std::string& name) override;
|
||||
bool openCommandBlock(
|
||||
int iPad, std::shared_ptr<CommandBlockEntity> commandBlock) override;
|
||||
bool openHopper(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<HopperTileEntity> hopper) override;
|
||||
bool openHopperMinecart(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<MinecartHopper> hopper) override;
|
||||
bool openHorse(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Container> container,
|
||||
std::shared_ptr<EntityHorse> horse) override;
|
||||
bool openBeacon(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<BeaconTileEntity> beacon) override;
|
||||
|
||||
private:
|
||||
Game& game_;
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
#include "ConsoleGameRulesConstants.h"
|
||||
#include "GameRuleManager.h"
|
||||
#include "app/common/GameRules/LevelGeneration/ApplySchematicRuleDefinition.h"
|
||||
#include "app/common/GameRules/LevelGeneration/BiomeOverride.h"
|
||||
#include "app/common/GameRules/LevelGeneration/ConsoleGenerateStructure.h"
|
||||
#include "app/common/GameRules/LevelGeneration/ConsoleGenerateStructureAction.h"
|
||||
#include "app/common/GameRules/LevelGeneration/StartFeature.h"
|
||||
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionGenerateBox.h"
|
||||
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceBlock.h"
|
||||
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceContainer.h"
|
||||
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceSpawner.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/AddEnchantmentRuleDefinition.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/AddItemRuleDefinition.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/CollectItemRuleDefinition.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/CompleteAllRuleDefinition.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/CompoundGameRuleDefinition.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/LevelRuleset.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/NamedAreaRuleDefinition.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/UpdatePlayerRuleDefinition.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/UseTileRuleDefinition.h"
|
||||
#include "minecraft/world/level/GameRules/GameRule.h"
|
||||
#include "minecraft/world/level/GameRules/GameRuleDefinition.h"
|
||||
#include "minecraft/world/level/GameRules/GameRulesInstance.h"
|
||||
#include "minecraft/world/level/GameRules/LevelGenerationOptions.h"
|
||||
@@ -7,95 +7,95 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "app/common/src/DLC/DLCGameRulesFile.h"
|
||||
#include "app/common/src/DLC/DLCGameRulesHeader.h"
|
||||
#include "app/common/src/DLC/DLCLocalisationFile.h"
|
||||
#include "app/common/src/DLC/DLCManager.h"
|
||||
#include "app/common/src/DLC/DLCPack.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/ConsoleSchematicFile.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/LevelGenerationOptions.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/LevelGenerators.h"
|
||||
#include "app/common/src/GameRules/LevelRules/LevelRules.h"
|
||||
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
|
||||
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/LevelRuleset.h"
|
||||
#include "app/common/src/Localisation/StringTable.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "minecraft/world/level/storage/ConsoleSaveFileIO/compression.h"
|
||||
#include "app/common/DLC/DLCGameRulesFile.h"
|
||||
#include "app/common/DLC/DLCGameRulesHeader.h"
|
||||
#include "app/common/DLC/DLCLocalisationFile.h"
|
||||
#include "app/common/DLC/DLCManager.h"
|
||||
#include "app/common/DLC/DLCPack.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/GameRules/LevelGeneration/LevelGenerators.h"
|
||||
#include "app/common/GameRules/LevelRules/LevelRules.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/LevelRuleset.h"
|
||||
#include "java/File.h"
|
||||
#include "java/InputOutputStream/ByteArrayInputStream.h"
|
||||
#include "java/InputOutputStream/ByteArrayOutputStream.h"
|
||||
#include "java/InputOutputStream/DataInputStream.h"
|
||||
#include "java/InputOutputStream/DataOutputStream.h"
|
||||
#include "minecraft/locale/StringTable.h"
|
||||
#include "minecraft/world/level/GameRules/GameRuleDefinition.h"
|
||||
#include "minecraft/world/level/GameRules/LevelGenerationOptions.h"
|
||||
#include "minecraft/world/level/levelgen/ConsoleSchematicFile.h"
|
||||
#include "minecraft/world/level/storage/ConsoleSaveFileIO/FileHeader.h"
|
||||
#include "minecraft/world/level/storage/ConsoleSaveFileIO/compression.h"
|
||||
#include "strings.h"
|
||||
|
||||
const wchar_t* GameRuleManager::wchTagNameA[] = {
|
||||
L"", // eGameRuleType_Root
|
||||
L"MapOptions", // eGameRuleType_LevelGenerationOptions
|
||||
L"ApplySchematic", // eGameRuleType_ApplySchematic
|
||||
L"GenerateStructure", // eGameRuleType_GenerateStructure
|
||||
L"GenerateBox", // eGameRuleType_GenerateBox
|
||||
L"PlaceBlock", // eGameRuleType_PlaceBlock
|
||||
L"PlaceContainer", // eGameRuleType_PlaceContainer
|
||||
L"PlaceSpawner", // eGameRuleType_PlaceSpawner
|
||||
L"BiomeOverride", // eGameRuleType_BiomeOverride
|
||||
L"StartFeature", // eGameRuleType_StartFeature
|
||||
L"AddItem", // eGameRuleType_AddItem
|
||||
L"AddEnchantment", // eGameRuleType_AddEnchantment
|
||||
L"LevelRules", // eGameRuleType_LevelRules
|
||||
L"NamedArea", // eGameRuleType_NamedArea
|
||||
L"UseTile", // eGameRuleType_UseTileRule
|
||||
L"CollectItem", // eGameRuleType_CollectItemRule
|
||||
L"CompleteAll", // eGameRuleType_CompleteAllRule
|
||||
L"UpdatePlayer", // eGameRuleType_UpdatePlayerRule
|
||||
const char* GameRuleManager::wchTagNameA[] = {
|
||||
"", // eGameRuleType_Root
|
||||
"MapOptions", // eGameRuleType_LevelGenerationOptions
|
||||
"ApplySchematic", // eGameRuleType_ApplySchematic
|
||||
"GenerateStructure", // eGameRuleType_GenerateStructure
|
||||
"GenerateBox", // eGameRuleType_GenerateBox
|
||||
"PlaceBlock", // eGameRuleType_PlaceBlock
|
||||
"PlaceContainer", // eGameRuleType_PlaceContainer
|
||||
"PlaceSpawner", // eGameRuleType_PlaceSpawner
|
||||
"BiomeOverride", // eGameRuleType_BiomeOverride
|
||||
"StartFeature", // eGameRuleType_StartFeature
|
||||
"AddItem", // eGameRuleType_AddItem
|
||||
"AddEnchantment", // eGameRuleType_AddEnchantment
|
||||
"LevelRules", // eGameRuleType_LevelRules
|
||||
"NamedArea", // eGameRuleType_NamedArea
|
||||
"UseTile", // eGameRuleType_UseTileRule
|
||||
"CollectItem", // eGameRuleType_CollectItemRule
|
||||
"CompleteAll", // eGameRuleType_CompleteAllRule
|
||||
"UpdatePlayer", // eGameRuleType_UpdatePlayerRule
|
||||
};
|
||||
|
||||
const wchar_t* GameRuleManager::wchAttrNameA[] = {
|
||||
L"descriptionName", // eGameRuleAttr_descriptionName
|
||||
L"promptName", // eGameRuleAttr_promptName
|
||||
L"dataTag", // eGameRuleAttr_dataTag
|
||||
L"enchantmentId", // eGameRuleAttr_enchantmentId
|
||||
L"enchantmentLevel", // eGameRuleAttr_enchantmentLevel
|
||||
L"itemId", // eGameRuleAttr_itemId
|
||||
L"quantity", // eGameRuleAttr_quantity
|
||||
L"auxValue", // eGameRuleAttr_auxValue
|
||||
L"slot", // eGameRuleAttr_slot
|
||||
L"name", // eGameRuleAttr_name
|
||||
L"food", // eGameRuleAttr_food
|
||||
L"health", // eGameRuleAttr_health
|
||||
L"tileId", // eGameRuleAttr_tileId
|
||||
L"useCoords", // eGameRuleAttr_useCoords
|
||||
L"seed", // eGameRuleAttr_seed
|
||||
L"flatworld", // eGameRuleAttr_flatworld
|
||||
L"filename", // eGameRuleAttr_filename
|
||||
L"rot", // eGameRuleAttr_rot
|
||||
L"data", // eGameRuleAttr_data
|
||||
L"block", // eGameRuleAttr_block
|
||||
L"entity", // eGameRuleAttr_entity
|
||||
L"facing", // eGameRuleAttr_facing
|
||||
L"edgeTile", // eGameRuleAttr_edgeTile
|
||||
L"fillTile", // eGameRuleAttr_fillTile
|
||||
L"skipAir", // eGameRuleAttr_skipAir
|
||||
L"x", // eGameRuleAttr_x
|
||||
L"x0", // eGameRuleAttr_x0
|
||||
L"x1", // eGameRuleAttr_x1
|
||||
L"y", // eGameRuleAttr_y
|
||||
L"y0", // eGameRuleAttr_y0
|
||||
L"y1", // eGameRuleAttr_y1
|
||||
L"z", // eGameRuleAttr_z
|
||||
L"z0", // eGameRuleAttr_z0
|
||||
L"z1", // eGameRuleAttr_z1
|
||||
L"chunkX", // eGameRuleAttr_chunkX
|
||||
L"chunkZ", // eGameRuleAttr_chunkZ
|
||||
L"yRot", // eGameRuleAttr_yRot
|
||||
L"spawnX", // eGameRuleAttr_spawnX
|
||||
L"spawnY", // eGameRuleAttr_spawnY
|
||||
L"spawnZ", // eGameRuleAttr_spawnZ
|
||||
L"orientation",
|
||||
L"dimension",
|
||||
L"topTileId", // eGameRuleAttr_topTileId
|
||||
L"biomeId", // eGameRuleAttr_biomeId
|
||||
L"feature", // eGameRuleAttr_feature
|
||||
const char* GameRuleManager::wchAttrNameA[] = {
|
||||
"descriptionName", // eGameRuleAttr_descriptionName
|
||||
"promptName", // eGameRuleAttr_promptName
|
||||
"dataTag", // eGameRuleAttr_dataTag
|
||||
"enchantmentId", // eGameRuleAttr_enchantmentId
|
||||
"enchantmentLevel", // eGameRuleAttr_enchantmentLevel
|
||||
"itemId", // eGameRuleAttr_itemId
|
||||
"quantity", // eGameRuleAttr_quantity
|
||||
"auxValue", // eGameRuleAttr_auxValue
|
||||
"slot", // eGameRuleAttr_slot
|
||||
"name", // eGameRuleAttr_name
|
||||
"food", // eGameRuleAttr_food
|
||||
"health", // eGameRuleAttr_health
|
||||
"tileId", // eGameRuleAttr_tileId
|
||||
"useCoords", // eGameRuleAttr_useCoords
|
||||
"seed", // eGameRuleAttr_seed
|
||||
"flatworld", // eGameRuleAttr_flatworld
|
||||
"filename", // eGameRuleAttr_filename
|
||||
"rot", // eGameRuleAttr_rot
|
||||
"data", // eGameRuleAttr_data
|
||||
"block", // eGameRuleAttr_block
|
||||
"entity", // eGameRuleAttr_entity
|
||||
"facing", // eGameRuleAttr_facing
|
||||
"edgeTile", // eGameRuleAttr_edgeTile
|
||||
"fillTile", // eGameRuleAttr_fillTile
|
||||
"skipAir", // eGameRuleAttr_skipAir
|
||||
"x", // eGameRuleAttr_x
|
||||
"x0", // eGameRuleAttr_x0
|
||||
"x1", // eGameRuleAttr_x1
|
||||
"y", // eGameRuleAttr_y
|
||||
"y0", // eGameRuleAttr_y0
|
||||
"y1", // eGameRuleAttr_y1
|
||||
"z", // eGameRuleAttr_z
|
||||
"z0", // eGameRuleAttr_z0
|
||||
"z1", // eGameRuleAttr_z1
|
||||
"chunkX", // eGameRuleAttr_chunkX
|
||||
"chunkZ", // eGameRuleAttr_chunkZ
|
||||
"yRot", // eGameRuleAttr_yRot
|
||||
"spawnX", // eGameRuleAttr_spawnX
|
||||
"spawnY", // eGameRuleAttr_spawnY
|
||||
"spawnZ", // eGameRuleAttr_spawnZ
|
||||
"orientation",
|
||||
"dimension",
|
||||
"topTileId", // eGameRuleAttr_topTileId
|
||||
"biomeId", // eGameRuleAttr_biomeId
|
||||
"feature", // eGameRuleAttr_feature
|
||||
};
|
||||
|
||||
GameRuleManager::GameRuleManager() {
|
||||
@@ -107,10 +107,10 @@ void GameRuleManager::loadGameRules(DLCPack* pack) {
|
||||
StringTable* strings = nullptr;
|
||||
|
||||
if (pack->doesPackContainFile(DLCManager::e_DLCType_LocalisationData,
|
||||
L"languages.loc")) {
|
||||
"languages.loc")) {
|
||||
DLCLocalisationFile* localisationFile =
|
||||
(DLCLocalisationFile*)pack->getFile(
|
||||
DLCManager::e_DLCType_LocalisationData, L"languages.loc");
|
||||
DLCManager::e_DLCType_LocalisationData, "languages.loc");
|
||||
strings = localisationFile->getStringTable();
|
||||
}
|
||||
|
||||
@@ -223,15 +223,14 @@ void GameRuleManager::loadGameRules(LevelGenerationOptions* lgo, uint8_t* dIn,
|
||||
unsigned int bStringTableSize = dis2.readInt();
|
||||
std::vector<uint8_t> bStringTable(bStringTableSize);
|
||||
dis2.read(bStringTable);
|
||||
StringTable* strings =
|
||||
new StringTable(bStringTable.data(), bStringTable.size());
|
||||
StringTable* strings = new StringTable(bStringTable, app.getLocale());
|
||||
|
||||
// Read RuleFile.
|
||||
std::vector<uint8_t> bRuleFile(content.size() - bStringTable.size());
|
||||
dis2.read(bRuleFile);
|
||||
|
||||
// 4J-JEV: I don't believe that the path-name is ever used.
|
||||
// DLCGameRulesFile *dlcgr = new DLCGameRulesFile(L"__PLACEHOLDER__");
|
||||
// DLCGameRulesFile *dlcgr = new DLCGameRulesFile("__PLACEHOLDER__");
|
||||
// dlcgr->addData(bRuleFile.data(),bRuleFile.size());
|
||||
|
||||
if (readRuleFile(lgo, bRuleFile.data(), bRuleFile.size(), strings)) {
|
||||
@@ -358,11 +357,11 @@ void GameRuleManager::writeRuleFile(DataOutputStream* dos) {
|
||||
dos->writeUTF(wchAttrNameA[i]);
|
||||
|
||||
// Write schematic files.
|
||||
std::unordered_map<std::wstring, ConsoleSchematicFile*>* files;
|
||||
std::unordered_map<std::string, ConsoleSchematicFile*>* files;
|
||||
files = getLevelGenerationOptions()->getUnfinishedSchematicFiles();
|
||||
dos->writeInt(files->size());
|
||||
for (auto it = files->begin(); it != files->end(); it++) {
|
||||
std::wstring filename = it->first;
|
||||
std::string filename = it->first;
|
||||
ConsoleSchematicFile* file = it->second;
|
||||
|
||||
ByteArrayOutputStream fileBaos;
|
||||
@@ -473,7 +472,7 @@ bool GameRuleManager::readRuleFile(
|
||||
compressedBuffer.data(), compressedSize); break; default:
|
||||
app.DebugPrintf("Invalid compression
|
||||
type %d found\n", compressionType);
|
||||
__debugbreak();
|
||||
assert(0);
|
||||
|
||||
[] decompressedBuffer.data(); dis.close(); bais.reset();
|
||||
|
||||
@@ -488,7 +487,7 @@ bool GameRuleManager::readRuleFile(
|
||||
|
||||
// string lookup.
|
||||
unsigned int numStrings = contentDis->readInt();
|
||||
std::vector<std::wstring> tagsAndAtts;
|
||||
std::vector<std::string> tagsAndAtts;
|
||||
for (unsigned int i = 0; i < numStrings; i++)
|
||||
tagsAndAtts.push_back(contentDis->readUTF());
|
||||
|
||||
@@ -525,7 +524,7 @@ bool GameRuleManager::readRuleFile(
|
||||
// subfile
|
||||
unsigned int numFiles = contentDis->readInt();
|
||||
for (unsigned int i = 0; i < numFiles; i++) {
|
||||
std::wstring sFilename = contentDis->readUTF();
|
||||
std::string sFilename = contentDis->readUTF();
|
||||
int length = contentDis->readInt();
|
||||
std::vector<uint8_t> ba(length);
|
||||
|
||||
@@ -550,13 +549,13 @@ bool GameRuleManager::readRuleFile(
|
||||
if (tagVal == ConsoleGameRules::eGameRuleType_LevelGenerationOptions) {
|
||||
rule = levelGenerator;
|
||||
levelGenAdded = true;
|
||||
// m_levelGenerators.addLevelGenerator(L"",levelGenerator);
|
||||
// m_levelGenerators.addLevelGenerator("",levelGenerator);
|
||||
lgoID = addLevelGenerationOptions(levelGenerator);
|
||||
levelGenerator->loadStringTable(strings);
|
||||
} else if (tagVal == ConsoleGameRules::eGameRuleType_LevelRules) {
|
||||
rule = gameRules;
|
||||
gameRulesAdded = true;
|
||||
m_levelRules.addLevelRule(L"", gameRules);
|
||||
m_levelRules.addLevelRule("", gameRules);
|
||||
levelGenerator->setRequiredGameRules(gameRules);
|
||||
gameRules->loadStringTable(strings);
|
||||
}
|
||||
@@ -593,20 +592,20 @@ LevelGenerationOptions* GameRuleManager::readHeader(DLCGameRulesHeader* grh) {
|
||||
}
|
||||
|
||||
void GameRuleManager::readAttributes(DataInputStream* dis,
|
||||
std::vector<std::wstring>* tagsAndAtts,
|
||||
std::vector<std::string>* tagsAndAtts,
|
||||
GameRuleDefinition* rule) {
|
||||
int numAttrs = dis->readInt();
|
||||
for (unsigned int att = 0; att < static_cast<unsigned int>(numAttrs);
|
||||
++att) {
|
||||
int attID = dis->readInt();
|
||||
std::wstring value = dis->readUTF();
|
||||
std::string value = dis->readUTF();
|
||||
|
||||
if (rule != nullptr) rule->addAttribute(tagsAndAtts->at(attID), value);
|
||||
}
|
||||
}
|
||||
|
||||
void GameRuleManager::readChildren(
|
||||
DataInputStream* dis, std::vector<std::wstring>* tagsAndAtts,
|
||||
DataInputStream* dis, std::vector<std::string>* tagsAndAtts,
|
||||
std::unordered_map<int, ConsoleGameRules::EGameRuleType>* tagIdMap,
|
||||
GameRuleDefinition* rule) {
|
||||
int numChildren = dis->readInt();
|
||||
@@ -641,25 +640,27 @@ void GameRuleManager::processSchematicsLighting(LevelChunk* levelChunk) {
|
||||
}
|
||||
|
||||
void GameRuleManager::loadDefaultGameRules() {
|
||||
#if !defined(__linux__)
|
||||
#if 0
|
||||
#if defined(_WINDOWS64)
|
||||
File packedTutorialFile(L"Windows64Media\\Tutorial\\Tutorial.pck");
|
||||
File packedTutorialFile("Windows64Media\\Tutorial\\Tutorial.pck");
|
||||
if (!packedTutorialFile.exists())
|
||||
packedTutorialFile = File(L"Windows64\\Tutorial\\Tutorial.pck");
|
||||
packedTutorialFile = File("Windows64\\Tutorial\\Tutorial.pck");
|
||||
#else
|
||||
File packedTutorialFile(L"Tutorial\\Tutorial.pck");
|
||||
File packedTutorialFile("Tutorial\\Tutorial.pck");
|
||||
#endif
|
||||
if (loadGameRulesPack(&packedTutorialFile)) {
|
||||
m_levelGenerators.getLevelGenerators()->at(0)->setWorldName(
|
||||
app.GetString(IDS_PLAY_TUTORIAL));
|
||||
// m_levelGenerators.getLevelGenerators()->at(0)->setDefaultSaveName(L"Tutorial");
|
||||
// m_levelGenerators.getLevelGenerators()->at(0)->setDefaultSaveName("Tutorial");
|
||||
m_levelGenerators.getLevelGenerators()->at(0)->setDefaultSaveName(
|
||||
app.GetString(IDS_TUTORIALSAVENAME));
|
||||
}
|
||||
#else
|
||||
std::wstring fpTutorial = L"Tutorial.pck";
|
||||
// 4jcraft: brought over from TU18 so the tutorial world loads from assets
|
||||
// TODO clean this up
|
||||
std::string fpTutorial = "Tutorial.pck";
|
||||
if (app.getArchiveFileSize(fpTutorial) >= 0) {
|
||||
DLCPack* pack = new DLCPack(L"", 0xffffffff);
|
||||
DLCPack* pack = new DLCPack("", 0xffffffff);
|
||||
uint32_t dwFilesProcessed = 0;
|
||||
if (app.m_dlcManager.readDLCDataFile(dwFilesProcessed, fpTutorial, pack,
|
||||
true)) {
|
||||
@@ -677,7 +678,7 @@ void GameRuleManager::loadDefaultGameRules() {
|
||||
bool GameRuleManager::loadGameRulesPack(File* path) {
|
||||
bool success = false;
|
||||
if (path->exists()) {
|
||||
DLCPack* pack = new DLCPack(L"", 0xffffffff);
|
||||
DLCPack* pack = new DLCPack("", 0xffffffff);
|
||||
unsigned int dwFilesProcessed = 0;
|
||||
if (app.m_dlcManager.readDLCDataFile(dwFilesProcessed, path->getPath(),
|
||||
pack)) {
|
||||
@@ -707,11 +708,11 @@ void GameRuleManager::setLevelGenerationOptions(
|
||||
m_currentLevelGenerationOptions->reset_start();
|
||||
}
|
||||
|
||||
const wchar_t* GameRuleManager::GetGameRulesString(const std::wstring& key) {
|
||||
const char* GameRuleManager::GetGameRulesString(const std::string& key) {
|
||||
if (m_currentGameRuleDefinitions != nullptr && !key.empty()) {
|
||||
return m_currentGameRuleDefinitions->getString(key);
|
||||
} else {
|
||||
return L"";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "app/common/src/DLC/DLCGameRulesHeader.h"
|
||||
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/LevelGenerators.h"
|
||||
#include "app/common/src/GameRules/LevelRules/LevelRules.h"
|
||||
#include "app/common/DLC/DLCGameRulesHeader.h"
|
||||
#include "app/common/GameRules/LevelGeneration/LevelGenerators.h"
|
||||
#include "app/common/GameRules/LevelRules/LevelRules.h"
|
||||
#include "minecraft/world/level/ConsoleGameRulesConstants.h"
|
||||
|
||||
class LevelGenerationOptions;
|
||||
class RootGameRulesDefinition;
|
||||
@@ -27,16 +27,14 @@ class DLCGameRulesHeader;
|
||||
class File;
|
||||
class LevelRuleset;
|
||||
|
||||
#define GAME_RULE_SAVENAME L"requiredGameRules.grf"
|
||||
|
||||
// 4J-JEV:
|
||||
#define LEVEL_GEN_ID int
|
||||
#define LEVEL_GEN_ID_NULL 0
|
||||
|
||||
class GameRuleManager {
|
||||
public:
|
||||
static const wchar_t* wchTagNameA[ConsoleGameRules::eGameRuleType_Count];
|
||||
static const wchar_t* wchAttrNameA[ConsoleGameRules::eGameRuleAttr_Count];
|
||||
static const char* wchTagNameA[ConsoleGameRules::eGameRuleType_Count];
|
||||
static const char* wchAttrNameA[ConsoleGameRules::eGameRuleAttr_Count];
|
||||
|
||||
static const short version_number = 2;
|
||||
|
||||
@@ -70,10 +68,10 @@ public:
|
||||
|
||||
private:
|
||||
void readAttributes(DataInputStream* dis,
|
||||
std::vector<std::wstring>* tagsAndAtts,
|
||||
std::vector<std::string>* tagsAndAtts,
|
||||
GameRuleDefinition* rule);
|
||||
void readChildren(
|
||||
DataInputStream* dis, std::vector<std::wstring>* tagsAndAtts,
|
||||
DataInputStream* dis, std::vector<std::string>* tagsAndAtts,
|
||||
std::unordered_map<int, ConsoleGameRules::EGameRuleType>* tagIdMap,
|
||||
GameRuleDefinition* rule);
|
||||
|
||||
@@ -98,7 +96,7 @@ public:
|
||||
LevelGenerationOptions* getLevelGenerationOptions() {
|
||||
return m_currentLevelGenerationOptions;
|
||||
}
|
||||
const wchar_t* GetGameRulesString(const std::wstring& key);
|
||||
const char* GetGameRulesString(const std::string& key);
|
||||
|
||||
// 4J-JEV:
|
||||
// Properly cleans-up and unloads the current set of gameRules.
|
||||
@@ -3,17 +3,17 @@
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
#include "ConsoleSchematicFile.h"
|
||||
#include "LevelGenerationOptions.h"
|
||||
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
|
||||
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "util/StringHelpers.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "java/InputOutputStream/DataOutputStream.h"
|
||||
#include "minecraft/world/level/ConsoleGameRulesConstants.h"
|
||||
#include "minecraft/world/level/GameRules/GameRuleDefinition.h"
|
||||
#include "minecraft/world/level/GameRules/LevelGenerationOptions.h"
|
||||
#include "minecraft/world/level/Level.h"
|
||||
#include "minecraft/world/level/chunk/LevelChunk.h"
|
||||
#include "minecraft/world/level/dimension/Dimension.h"
|
||||
#include "minecraft/world/level/levelgen/ConsoleSchematicFile.h"
|
||||
#include "minecraft/world/phys/AABB.h"
|
||||
#include "util/StringHelpers.h"
|
||||
|
||||
ApplySchematicRuleDefinition::ApplySchematicRuleDefinition(
|
||||
LevelGenerationOptions* levelGenOptions) {
|
||||
@@ -65,8 +65,8 @@ void ApplySchematicRuleDefinition::writeAttributes(DataOutputStream* dos,
|
||||
}
|
||||
|
||||
void ApplySchematicRuleDefinition::addAttribute(
|
||||
const std::wstring& attributeName, const std::wstring& attributeValue) {
|
||||
if (attributeName.compare(L"filename") == 0) {
|
||||
const std::string& attributeName, const std::string& attributeValue) {
|
||||
if (attributeName.compare("filename") == 0) {
|
||||
m_schematicName = attributeValue;
|
||||
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
|
||||
// filename=%s\n",m_schematicName.c_str());
|
||||
@@ -75,28 +75,28 @@ void ApplySchematicRuleDefinition::addAttribute(
|
||||
if (m_schematicName
|
||||
.substr(m_schematicName.length() - 4,
|
||||
m_schematicName.length())
|
||||
.compare(L".sch") != 0) {
|
||||
m_schematicName.append(L".sch");
|
||||
.compare(".sch") != 0) {
|
||||
m_schematicName.append(".sch");
|
||||
}
|
||||
m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
|
||||
}
|
||||
} else if (attributeName.compare(L"x") == 0) {
|
||||
} else if (attributeName.compare("x") == 0) {
|
||||
m_location.x = fromWString<int>(attributeValue);
|
||||
if (((int)std::abs(m_location.x)) % 2 != 0) m_location.x -= 1;
|
||||
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
|
||||
// x=%f\n",m_location->x);
|
||||
} else if (attributeName.compare(L"y") == 0) {
|
||||
} else if (attributeName.compare("y") == 0) {
|
||||
m_location.y = fromWString<int>(attributeValue);
|
||||
if (((int)std::abs(m_location.y)) % 2 != 0) m_location.y -= 1;
|
||||
if (m_location.y < 0) m_location.y = 0;
|
||||
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
|
||||
// y=%f\n",m_location->y);
|
||||
} else if (attributeName.compare(L"z") == 0) {
|
||||
} else if (attributeName.compare("z") == 0) {
|
||||
m_location.z = fromWString<int>(attributeValue);
|
||||
if (((int)std::abs(m_location.z)) % 2 != 0) m_location.z -= 1;
|
||||
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
|
||||
// z=%f\n",m_location->z);
|
||||
} else if (attributeName.compare(L"rot") == 0) {
|
||||
} else if (attributeName.compare("rot") == 0) {
|
||||
int degrees = fromWString<int>(attributeValue);
|
||||
|
||||
while (degrees < 0) degrees += 360;
|
||||
@@ -122,7 +122,7 @@ void ApplySchematicRuleDefinition::addAttribute(
|
||||
|
||||
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
|
||||
// rot=%d\n",m_rotation);
|
||||
} else if (attributeName.compare(L"dim") == 0) {
|
||||
} else if (attributeName.compare("dim") == 0) {
|
||||
m_dimension = fromWString<int>(attributeValue);
|
||||
if (m_dimension > 1 || m_dimension < -1) m_dimension = 0;
|
||||
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
|
||||
@@ -173,7 +173,7 @@ void ApplySchematicRuleDefinition::processSchematic(AABB* chunkBox,
|
||||
std::min((double)Level::maxBuildHeight, m_locationBox->y1);
|
||||
|
||||
#ifdef _DEBUG
|
||||
app.DebugPrintf("Applying schematic %ls to chunk (%d,%d)\n",
|
||||
app.DebugPrintf("Applying schematic %s to chunk (%d,%d)\n",
|
||||
m_schematicName.c_str(), chunk->x, chunk->z);
|
||||
#endif
|
||||
m_totalBlocksChanged += m_schematic->applyBlocksAndData(
|
||||
@@ -211,7 +211,7 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB* chunkBox,
|
||||
std::min((double)Level::maxBuildHeight, m_locationBox->y1);
|
||||
|
||||
#ifdef _DEBUG
|
||||
app.DebugPrintf("Applying schematic %ls to chunk (%d,%d)\n",
|
||||
app.DebugPrintf("Applying schematic %s to chunk (%d,%d)\n",
|
||||
m_schematicName.c_str(), chunk->x, chunk->z);
|
||||
#endif
|
||||
m_totalBlocksChangedLighting += m_schematic->applyLighting(
|
||||
@@ -4,9 +4,9 @@
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "ConsoleSchematicFile.h"
|
||||
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
|
||||
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
|
||||
#include "minecraft/world/level/ConsoleGameRulesConstants.h"
|
||||
#include "minecraft/world/level/GameRules/GameRuleDefinition.h"
|
||||
#include "minecraft/world/level/levelgen/ConsoleSchematicFile.h"
|
||||
#include "minecraft/world/phys/AABB.h"
|
||||
#include "minecraft/world/phys/Vec3.h"
|
||||
|
||||
@@ -19,7 +19,7 @@ class GRFObject;
|
||||
class ApplySchematicRuleDefinition : public GameRuleDefinition {
|
||||
private:
|
||||
LevelGenerationOptions* m_levelGenOptions;
|
||||
std::wstring m_schematicName;
|
||||
std::string m_schematicName;
|
||||
ConsoleSchematicFile* m_schematic;
|
||||
Vec3 m_location;
|
||||
std::optional<AABB> m_locationBox;
|
||||
@@ -41,8 +41,8 @@ public:
|
||||
}
|
||||
|
||||
virtual void writeAttributes(DataOutputStream* dos, unsigned int numAttrs);
|
||||
virtual void addAttribute(const std::wstring& attributeName,
|
||||
const std::wstring& attributeValue);
|
||||
virtual void addAttribute(const std::string& attributeName,
|
||||
const std::string& attributeValue);
|
||||
|
||||
void processSchematic(AABB* chunkBox, LevelChunk* chunk);
|
||||
void processSchematicLighting(AABB* chunkBox, LevelChunk* chunk);
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
|
||||
bool isComplete() { return m_completed; }
|
||||
|
||||
std::wstring getSchematicName() { return m_schematicName; }
|
||||
std::string getSchematicName() { return m_schematicName; }
|
||||
|
||||
/** 4J-JEV:
|
||||
* This GameRuleDefinition contains limited game state.
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "BiomeOverride.h"
|
||||
|
||||
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
|
||||
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "util/StringHelpers.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "java/InputOutputStream/DataOutputStream.h"
|
||||
#include "minecraft/world/level/ConsoleGameRulesConstants.h"
|
||||
#include "minecraft/world/level/GameRules/GameRuleDefinition.h"
|
||||
#include "util/StringHelpers.h"
|
||||
|
||||
BiomeOverride::BiomeOverride() {
|
||||
m_tile = 0;
|
||||
@@ -24,18 +24,18 @@ void BiomeOverride::writeAttributes(DataOutputStream* dos,
|
||||
dos->writeUTF(toWString(m_topTile));
|
||||
}
|
||||
|
||||
void BiomeOverride::addAttribute(const std::wstring& attributeName,
|
||||
const std::wstring& attributeValue) {
|
||||
if (attributeName.compare(L"tileId") == 0) {
|
||||
void BiomeOverride::addAttribute(const std::string& attributeName,
|
||||
const std::string& attributeValue) {
|
||||
if (attributeName.compare("tileId") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_tile = value;
|
||||
app.DebugPrintf("BiomeOverride: Adding parameter tileId=%d\n", m_tile);
|
||||
} else if (attributeName.compare(L"topTileId") == 0) {
|
||||
} else if (attributeName.compare("topTileId") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_topTile = value;
|
||||
app.DebugPrintf("BiomeOverride: Adding parameter topTileId=%d\n",
|
||||
m_topTile);
|
||||
} else if (attributeName.compare(L"biomeId") == 0) {
|
||||
} else if (attributeName.compare("biomeId") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_biomeId = value;
|
||||
app.DebugPrintf("BiomeOverride: Adding parameter biomeId=%d\n",
|
||||
@@ -4,8 +4,8 @@
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
|
||||
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
|
||||
#include "minecraft/world/level/ConsoleGameRulesConstants.h"
|
||||
#include "minecraft/world/level/GameRules/GameRuleDefinition.h"
|
||||
|
||||
class BiomeOverride : public GameRuleDefinition {
|
||||
private:
|
||||
@@ -21,8 +21,8 @@ public:
|
||||
}
|
||||
|
||||
virtual void writeAttributes(DataOutputStream* dos, unsigned int numAttrs);
|
||||
virtual void addAttribute(const std::wstring& attributeName,
|
||||
const std::wstring& attributeValue);
|
||||
virtual void addAttribute(const std::string& attributeName,
|
||||
const std::string& attributeValue);
|
||||
|
||||
bool isBiome(int id);
|
||||
void getTileValues(std::uint8_t& tile, std::uint8_t& topTile);
|
||||
@@ -4,20 +4,20 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/ConsoleGenerateStructureAction.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/StructureActions/XboxStructureActionGenerateBox.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceBlock.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceContainer.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceSpawner.h"
|
||||
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "util/StringHelpers.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/GameRules/LevelGeneration/ConsoleGenerateStructureAction.h"
|
||||
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionGenerateBox.h"
|
||||
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceBlock.h"
|
||||
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceContainer.h"
|
||||
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceSpawner.h"
|
||||
#include "java/InputOutputStream/DataOutputStream.h"
|
||||
#include "minecraft/Direction.h"
|
||||
#include "minecraft/world/level/ConsoleGameRulesConstants.h"
|
||||
#include "minecraft/world/level/GameRules/GameRuleDefinition.h"
|
||||
#include "minecraft/world/level/Level.h"
|
||||
#include "minecraft/world/level/dimension/Dimension.h"
|
||||
#include "minecraft/world/level/levelgen/structure/BoundingBox.h"
|
||||
#include "util/StringHelpers.h"
|
||||
|
||||
ConsoleGenerateStructure::ConsoleGenerateStructure() : StructurePiece(0) {
|
||||
m_x = m_y = m_z = 0;
|
||||
@@ -51,9 +51,9 @@ GameRuleDefinition* ConsoleGenerateStructure::addChild(
|
||||
m_actions.push_back((XboxStructureActionPlaceSpawner*)rule);
|
||||
} else {
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
wprintf(
|
||||
L"ConsoleGenerateStructure: Attempted to add invalid child rule - "
|
||||
L"%d\n",
|
||||
printf(
|
||||
"ConsoleGenerateStructure: Attempted to add invalid child rule - "
|
||||
"%d\n",
|
||||
ruleType);
|
||||
#endif
|
||||
}
|
||||
@@ -77,30 +77,30 @@ void ConsoleGenerateStructure::writeAttributes(DataOutputStream* dos,
|
||||
dos->writeUTF(toWString(m_dimension));
|
||||
}
|
||||
|
||||
void ConsoleGenerateStructure::addAttribute(
|
||||
const std::wstring& attributeName, const std::wstring& attributeValue) {
|
||||
if (attributeName.compare(L"x") == 0) {
|
||||
void ConsoleGenerateStructure::addAttribute(const std::string& attributeName,
|
||||
const std::string& attributeValue) {
|
||||
if (attributeName.compare("x") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_x = value;
|
||||
app.DebugPrintf("ConsoleGenerateStructure: Adding parameter x=%d\n",
|
||||
m_x);
|
||||
} else if (attributeName.compare(L"y") == 0) {
|
||||
} else if (attributeName.compare("y") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_y = value;
|
||||
app.DebugPrintf("ConsoleGenerateStructure: Adding parameter y=%d\n",
|
||||
m_y);
|
||||
} else if (attributeName.compare(L"z") == 0) {
|
||||
} else if (attributeName.compare("z") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_z = value;
|
||||
app.DebugPrintf("ConsoleGenerateStructure: Adding parameter z=%d\n",
|
||||
m_z);
|
||||
} else if (attributeName.compare(L"orientation") == 0) {
|
||||
} else if (attributeName.compare("orientation") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
orientation = value;
|
||||
app.DebugPrintf(
|
||||
"ConsoleGenerateStructure: Adding parameter orientation=%d\n",
|
||||
orientation);
|
||||
} else if (attributeName.compare(L"dim") == 0) {
|
||||
} else if (attributeName.compare("dim") == 0) {
|
||||
m_dimension = fromWString<int>(attributeValue);
|
||||
if (m_dimension > 1 || m_dimension < -1) m_dimension = 0;
|
||||
app.DebugPrintf(
|
||||
@@ -2,8 +2,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
|
||||
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
|
||||
#include "minecraft/world/level/ConsoleGameRulesConstants.h"
|
||||
#include "minecraft/world/level/GameRules/GameRuleDefinition.h"
|
||||
#include "minecraft/world/level/levelgen/structure/StructureFeatureIO.h"
|
||||
#include "minecraft/world/level/levelgen/structure/StructurePiece.h"
|
||||
|
||||
@@ -33,8 +33,8 @@ public:
|
||||
ConsoleGameRules::EGameRuleType ruleType);
|
||||
|
||||
virtual void writeAttributes(DataOutputStream* dos, unsigned int numAttrs);
|
||||
virtual void addAttribute(const std::wstring& attributeName,
|
||||
const std::wstring& attributeValue);
|
||||
virtual void addAttribute(const std::string& attributeName,
|
||||
const std::string& attributeValue);
|
||||
|
||||
// StructurePiece
|
||||
virtual BoundingBox* getBoundingBox();
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
|
||||
#include "minecraft/world/level/GameRules/GameRuleDefinition.h"
|
||||
|
||||
class ConsoleGenerateStructureAction : public GameRuleDefinition {
|
||||
public:
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "LevelGenerationOptions.h"
|
||||
#include "minecraft/world/level/GameRules/LevelGenerationOptions.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <wchar.h>
|
||||
@@ -6,43 +6,42 @@
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
|
||||
#include "app/common/App_enums.h"
|
||||
#include "app/common/src/DLC/DLCGameRulesHeader.h"
|
||||
#include "app/common/src/DLC/DLCManager.h"
|
||||
#include "app/common/src/DLC/DLCPack.h"
|
||||
#include "app/common/src/GameRules/GameRuleManager.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/ApplySchematicRuleDefinition.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/BiomeOverride.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/ConsoleGenerateStructure.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/ConsoleSchematicFile.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/StartFeature.h"
|
||||
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
|
||||
#include "app/common/src/Localisation/StringTable.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "app/linux/Stubs/winapi_stubs.h"
|
||||
#include "app/common/DLC/DLCGameRulesHeader.h"
|
||||
#include "app/common/DLC/DLCManager.h"
|
||||
#include "app/common/DLC/DLCPack.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/GameRules/GameRuleManager.h"
|
||||
#include "app/common/GameRules/LevelGeneration/ApplySchematicRuleDefinition.h"
|
||||
#include "app/common/GameRules/LevelGeneration/BiomeOverride.h"
|
||||
#include "app/common/GameRules/LevelGeneration/ConsoleGenerateStructure.h"
|
||||
#include "app/common/GameRules/LevelGeneration/StartFeature.h"
|
||||
#include "java/File.h"
|
||||
#include "java/InputOutputStream/ByteArrayInputStream.h"
|
||||
#include "java/InputOutputStream/DataInputStream.h"
|
||||
#include "java/InputOutputStream/DataOutputStream.h"
|
||||
#include "minecraft/GameEnums.h"
|
||||
#include "minecraft/Pos.h"
|
||||
#include "minecraft/locale/StringTable.h"
|
||||
#include "minecraft/world/level/GameRules/GameRuleDefinition.h"
|
||||
#include "minecraft/world/level/Level.h"
|
||||
#include "minecraft/world/level/chunk/LevelChunk.h"
|
||||
#include "minecraft/world/level/dimension/Dimension.h"
|
||||
#include "minecraft/world/level/levelgen/ConsoleSchematicFile.h"
|
||||
#include "minecraft/world/level/levelgen/structure/BoundingBox.h"
|
||||
#include "minecraft/world/phys/AABB.h"
|
||||
#include "platform/PlatformServices.h"
|
||||
#include "platform/sdl2/Profile.h"
|
||||
#include "platform/sdl2/Storage.h"
|
||||
#include "platform/fs/fs.h"
|
||||
#include "platform/profile/profile.h"
|
||||
#include "platform/storage/storage.h"
|
||||
#include "strings.h"
|
||||
#include "util/StringHelpers.h"
|
||||
|
||||
JustGrSource::JustGrSource() {
|
||||
m_displayName = L"Default_DisplayName";
|
||||
m_worldName = L"Default_WorldName";
|
||||
m_defaultSaveName = L"Default_DefaultSaveName";
|
||||
m_displayName = "Default_DisplayName";
|
||||
m_worldName = "Default_WorldName";
|
||||
m_defaultSaveName = "Default_DefaultSaveName";
|
||||
m_bRequiresTexturePack = false;
|
||||
m_requiredTexturePackId = 0;
|
||||
m_grfPath = L"__NO_GRF_PATH__";
|
||||
m_grfPath = "__NO_GRF_PATH__";
|
||||
m_bRequiresBaseSave = false;
|
||||
}
|
||||
|
||||
@@ -50,12 +49,12 @@ bool JustGrSource::requiresTexturePack() { return m_bRequiresTexturePack; }
|
||||
std::uint32_t JustGrSource::getRequiredTexturePackId() {
|
||||
return m_requiredTexturePackId;
|
||||
}
|
||||
std::wstring JustGrSource::getDefaultSaveName() { return m_defaultSaveName; }
|
||||
const wchar_t* JustGrSource::getWorldName() { return m_worldName.c_str(); }
|
||||
const wchar_t* JustGrSource::getDisplayName() { return m_displayName.c_str(); }
|
||||
std::wstring JustGrSource::getGrfPath() { return m_grfPath; }
|
||||
std::string JustGrSource::getDefaultSaveName() { return m_defaultSaveName; }
|
||||
const char* JustGrSource::getWorldName() { return m_worldName.c_str(); }
|
||||
const char* JustGrSource::getDisplayName() { return m_displayName.c_str(); }
|
||||
std::string JustGrSource::getGrfPath() { return m_grfPath; }
|
||||
bool JustGrSource::requiresBaseSave() { return m_bRequiresBaseSave; };
|
||||
std::wstring JustGrSource::getBaseSavePath() { return m_baseSavePath; };
|
||||
std::string JustGrSource::getBaseSavePath() { return m_baseSavePath; };
|
||||
|
||||
void JustGrSource::setRequiresTexturePack(bool x) {
|
||||
m_bRequiresTexturePack = x;
|
||||
@@ -63,13 +62,13 @@ void JustGrSource::setRequiresTexturePack(bool x) {
|
||||
void JustGrSource::setRequiredTexturePackId(std::uint32_t x) {
|
||||
m_requiredTexturePackId = x;
|
||||
}
|
||||
void JustGrSource::setDefaultSaveName(const std::wstring& x) {
|
||||
void JustGrSource::setDefaultSaveName(const std::string& x) {
|
||||
m_defaultSaveName = x;
|
||||
}
|
||||
void JustGrSource::setWorldName(const std::wstring& x) { m_worldName = x; }
|
||||
void JustGrSource::setDisplayName(const std::wstring& x) { m_displayName = x; }
|
||||
void JustGrSource::setGrfPath(const std::wstring& x) { m_grfPath = x; }
|
||||
void JustGrSource::setBaseSavePath(const std::wstring& x) {
|
||||
void JustGrSource::setWorldName(const std::string& x) { m_worldName = x; }
|
||||
void JustGrSource::setDisplayName(const std::string& x) { m_displayName = x; }
|
||||
void JustGrSource::setGrfPath(const std::string& x) { m_grfPath = x; }
|
||||
void JustGrSource::setBaseSavePath(const std::string& x) {
|
||||
m_baseSavePath = x;
|
||||
m_bRequiresBaseSave = true;
|
||||
}
|
||||
@@ -179,88 +178,88 @@ GameRuleDefinition* LevelGenerationOptions::addChild(
|
||||
m_features.push_back((StartFeature*)rule);
|
||||
} else {
|
||||
#if !defined(_CONTENT_PACKAGE)
|
||||
wprintf(
|
||||
L"LevelGenerationOptions: Attempted to add invalid child rule - "
|
||||
L"%d\n",
|
||||
printf(
|
||||
"LevelGenerationOptions: Attempted to add invalid child rule - "
|
||||
"%d\n",
|
||||
ruleType);
|
||||
#endif
|
||||
}
|
||||
return rule;
|
||||
}
|
||||
|
||||
void LevelGenerationOptions::addAttribute(const std::wstring& attributeName,
|
||||
const std::wstring& attributeValue) {
|
||||
if (attributeName.compare(L"seed") == 0) {
|
||||
void LevelGenerationOptions::addAttribute(const std::string& attributeName,
|
||||
const std::string& attributeValue) {
|
||||
if (attributeName.compare("seed") == 0) {
|
||||
m_seed = fromWString<int64_t>(attributeValue);
|
||||
app.DebugPrintf(
|
||||
"LevelGenerationOptions: Adding parameter m_seed=%I64d\n", m_seed);
|
||||
} else if (attributeName.compare(L"spawnX") == 0) {
|
||||
} else if (attributeName.compare("spawnX") == 0) {
|
||||
if (m_spawnPos == nullptr) m_spawnPos = new Pos();
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_spawnPos->x = value;
|
||||
app.DebugPrintf("LevelGenerationOptions: Adding parameter spawnX=%d\n",
|
||||
value);
|
||||
} else if (attributeName.compare(L"spawnY") == 0) {
|
||||
} else if (attributeName.compare("spawnY") == 0) {
|
||||
if (m_spawnPos == nullptr) m_spawnPos = new Pos();
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_spawnPos->y = value;
|
||||
app.DebugPrintf("LevelGenerationOptions: Adding parameter spawnY=%d\n",
|
||||
value);
|
||||
} else if (attributeName.compare(L"spawnZ") == 0) {
|
||||
} else if (attributeName.compare("spawnZ") == 0) {
|
||||
if (m_spawnPos == nullptr) m_spawnPos = new Pos();
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_spawnPos->z = value;
|
||||
app.DebugPrintf("LevelGenerationOptions: Adding parameter spawnZ=%d\n",
|
||||
value);
|
||||
} else if (attributeName.compare(L"flatworld") == 0) {
|
||||
if (attributeValue.compare(L"true") == 0) m_useFlatWorld = true;
|
||||
} else if (attributeName.compare("flatworld") == 0) {
|
||||
if (attributeValue.compare("true") == 0) m_useFlatWorld = true;
|
||||
app.DebugPrintf(
|
||||
"LevelGenerationOptions: Adding parameter flatworld=%s\n",
|
||||
m_useFlatWorld ? "true" : "false");
|
||||
} else if (attributeName.compare(L"saveName") == 0) {
|
||||
std::wstring string(getString(attributeValue));
|
||||
} else if (attributeName.compare("saveName") == 0) {
|
||||
std::string string(getString(attributeValue));
|
||||
if (!string.empty())
|
||||
setDefaultSaveName(string);
|
||||
else
|
||||
setDefaultSaveName(attributeValue);
|
||||
app.DebugPrintf(
|
||||
"LevelGenerationOptions: Adding parameter saveName=%ls\n",
|
||||
"LevelGenerationOptions: Adding parameter saveName=%s\n",
|
||||
getDefaultSaveName().c_str());
|
||||
} else if (attributeName.compare(L"worldName") == 0) {
|
||||
std::wstring string(getString(attributeValue));
|
||||
} else if (attributeName.compare("worldName") == 0) {
|
||||
std::string string(getString(attributeValue));
|
||||
if (!string.empty())
|
||||
setWorldName(string);
|
||||
else
|
||||
setWorldName(attributeValue);
|
||||
app.DebugPrintf(
|
||||
"LevelGenerationOptions: Adding parameter worldName=%ls\n",
|
||||
"LevelGenerationOptions: Adding parameter worldName=%s\n",
|
||||
getWorldName());
|
||||
} else if (attributeName.compare(L"displayName") == 0) {
|
||||
std::wstring string(getString(attributeValue));
|
||||
} else if (attributeName.compare("displayName") == 0) {
|
||||
std::string string(getString(attributeValue));
|
||||
if (!string.empty())
|
||||
setDisplayName(string);
|
||||
else
|
||||
setDisplayName(attributeValue);
|
||||
app.DebugPrintf(
|
||||
"LevelGenerationOptions: Adding parameter displayName=%ls\n",
|
||||
"LevelGenerationOptions: Adding parameter displayName=%s\n",
|
||||
getDisplayName());
|
||||
} else if (attributeName.compare(L"texturePackId") == 0) {
|
||||
} else if (attributeName.compare("texturePackId") == 0) {
|
||||
setRequiredTexturePackId(fromWString<unsigned int>(attributeValue));
|
||||
setRequiresTexturePack(true);
|
||||
app.DebugPrintf(
|
||||
"LevelGenerationOptions: Adding parameter texturePackId=%0x\n",
|
||||
getRequiredTexturePackId());
|
||||
} else if (attributeName.compare(L"isTutorial") == 0) {
|
||||
if (attributeValue.compare(L"true") == 0) setSrc(eSrc_tutorial);
|
||||
} else if (attributeName.compare("isTutorial") == 0) {
|
||||
if (attributeValue.compare("true") == 0) setSrc(eSrc_tutorial);
|
||||
app.DebugPrintf(
|
||||
"LevelGenerationOptions: Adding parameter isTutorial=%s\n",
|
||||
isTutorial() ? "true" : "false");
|
||||
} else if (attributeName.compare(L"baseSaveName") == 0) {
|
||||
} else if (attributeName.compare("baseSaveName") == 0) {
|
||||
setBaseSavePath(attributeValue);
|
||||
app.DebugPrintf(
|
||||
"LevelGenerationOptions: Adding parameter baseSaveName=%ls\n",
|
||||
"LevelGenerationOptions: Adding parameter baseSaveName=%s\n",
|
||||
getBaseSavePath().c_str());
|
||||
} else if (attributeName.compare(L"hasBeenInCreative") == 0) {
|
||||
} else if (attributeName.compare("hasBeenInCreative") == 0) {
|
||||
bool value = fromWString<bool>(attributeValue);
|
||||
m_bHasBeenInCreative = value;
|
||||
app.DebugPrintf(
|
||||
@@ -435,14 +434,13 @@ void LevelGenerationOptions::clearSchematics() {
|
||||
void LevelGenerationOptions::clearChunkRuleCache() { m_chunkRuleCache.clear(); }
|
||||
|
||||
ConsoleSchematicFile* LevelGenerationOptions::loadSchematicFile(
|
||||
const std::wstring& filename, std::uint8_t* pbData,
|
||||
const std::string& filename, std::uint8_t* pbData,
|
||||
unsigned int dataLength) {
|
||||
// If we have already loaded this, just return
|
||||
auto it = m_schematics.find(filename);
|
||||
if (it != m_schematics.end()) {
|
||||
#if !defined(_CONTENT_PACKAGE)
|
||||
wprintf(L"We have already loaded schematic file %ls\n",
|
||||
filename.c_str());
|
||||
printf("We have already loaded schematic file %s\n", filename.c_str());
|
||||
#endif
|
||||
it->second->incrementRefCount();
|
||||
return it->second;
|
||||
@@ -461,7 +459,7 @@ ConsoleSchematicFile* LevelGenerationOptions::loadSchematicFile(
|
||||
}
|
||||
|
||||
ConsoleSchematicFile* LevelGenerationOptions::getSchematicFile(
|
||||
const std::wstring& filename) {
|
||||
const std::string& filename) {
|
||||
ConsoleSchematicFile* schematic = nullptr;
|
||||
// If we have already loaded this, just return
|
||||
auto it = m_schematics.find(filename);
|
||||
@@ -471,8 +469,7 @@ ConsoleSchematicFile* LevelGenerationOptions::getSchematicFile(
|
||||
return schematic;
|
||||
}
|
||||
|
||||
void LevelGenerationOptions::releaseSchematicFile(
|
||||
const std::wstring& filename) {
|
||||
void LevelGenerationOptions::releaseSchematicFile(const std::string& filename) {
|
||||
// 4J Stu - We don't want to delete them when done, but probably want to
|
||||
// keep a set of active schematics for the current world
|
||||
// auto it = m_schematics.find(filename);
|
||||
@@ -492,9 +489,9 @@ void LevelGenerationOptions::loadStringTable(StringTable* table) {
|
||||
m_stringTable = table;
|
||||
}
|
||||
|
||||
const wchar_t* LevelGenerationOptions::getString(const std::wstring& key) {
|
||||
const char* LevelGenerationOptions::getString(const std::string& key) {
|
||||
if (m_stringTable == nullptr) {
|
||||
return L"";
|
||||
return "";
|
||||
} else {
|
||||
return m_stringTable->getString(key);
|
||||
}
|
||||
@@ -527,19 +524,19 @@ bool LevelGenerationOptions::isFeatureChunk(
|
||||
return isFeature;
|
||||
}
|
||||
|
||||
std::unordered_map<std::wstring, ConsoleSchematicFile*>*
|
||||
std::unordered_map<std::string, ConsoleSchematicFile*>*
|
||||
LevelGenerationOptions::getUnfinishedSchematicFiles() {
|
||||
// Clean schematic rules.
|
||||
std::unordered_set<std::wstring> usedFiles =
|
||||
std::unordered_set<std::wstring>();
|
||||
std::unordered_set<std::string> usedFiles =
|
||||
std::unordered_set<std::string>();
|
||||
for (auto it = m_schematicRules.begin(); it != m_schematicRules.end(); it++)
|
||||
if (!(*it)->isComplete()) usedFiles.insert((*it)->getSchematicName());
|
||||
|
||||
// Clean schematic files.
|
||||
std::unordered_map<std::wstring, ConsoleSchematicFile*>* out =
|
||||
new std::unordered_map<std::wstring, ConsoleSchematicFile*>();
|
||||
std::unordered_map<std::string, ConsoleSchematicFile*>* out =
|
||||
new std::unordered_map<std::string, ConsoleSchematicFile*>();
|
||||
for (auto it = usedFiles.begin(); it != usedFiles.end(); it++)
|
||||
out->insert(std::pair<std::wstring, ConsoleSchematicFile*>(
|
||||
out->insert(std::pair<std::string, ConsoleSchematicFile*>(
|
||||
*it, getSchematicFile(*it)));
|
||||
|
||||
return out;
|
||||
@@ -551,16 +548,16 @@ void LevelGenerationOptions::loadBaseSaveData() {
|
||||
mountIndex = m_parentDLCPack->GetDLCMountIndex();
|
||||
|
||||
if (mountIndex > -1) {
|
||||
if (StorageManager.MountInstalledDLC(
|
||||
ProfileManager.GetPrimaryPad(), mountIndex,
|
||||
if (PlatformStorage.MountInstalledDLC(
|
||||
PlatformProfile.GetPrimaryPad(), mountIndex,
|
||||
[this](int pad, std::uint32_t err, std::uint32_t lic) {
|
||||
return onPackMounted(pad, err, lic);
|
||||
},
|
||||
"WPACK") != ERROR_IO_PENDING) {
|
||||
"WPACK") != 997 /* ERROR_IO_PENDING */) {
|
||||
// corrupt DLC
|
||||
setLoadedData();
|
||||
app.DebugPrintf("Failed to mount LGO DLC %d for pad %d\n",
|
||||
mountIndex, ProfileManager.GetPrimaryPad());
|
||||
mountIndex, PlatformProfile.GetPrimaryPad());
|
||||
} else {
|
||||
m_bLoadingData = true;
|
||||
app.DebugPrintf("Attempted to mount DLC data for LGO %d\n",
|
||||
@@ -568,7 +565,7 @@ void LevelGenerationOptions::loadBaseSaveData() {
|
||||
}
|
||||
} else {
|
||||
setLoadedData();
|
||||
app.SetAction(ProfileManager.GetPrimaryPad(),
|
||||
app.SetAction(PlatformProfile.GetPrimaryPad(),
|
||||
eAppAction_ReloadTexturePack);
|
||||
}
|
||||
}
|
||||
@@ -577,7 +574,7 @@ int LevelGenerationOptions::onPackMounted(int iPad, uint32_t dwErr,
|
||||
uint32_t dwLicenceMask) {
|
||||
LevelGenerationOptions* lgo = this;
|
||||
lgo->m_bLoadingData = false;
|
||||
if (dwErr != ERROR_SUCCESS) {
|
||||
if (dwErr != 0 /* ERROR_SUCCESS */) {
|
||||
// corrupt DLC
|
||||
app.DebugPrintf("Failed to mount LGO DLC for pad %d: %d\n", iPad,
|
||||
dwErr);
|
||||
@@ -594,15 +591,15 @@ int LevelGenerationOptions::onPackMounted(int iPad, uint32_t dwErr,
|
||||
if (!dlcFile->getGrfPath().empty()) {
|
||||
File grf(app.getFilePath(lgo->m_parentDLCPack->GetPackID(),
|
||||
dlcFile->getGrfPath(), true,
|
||||
L"WPACK:"));
|
||||
"WPACK:"));
|
||||
if (grf.exists()) {
|
||||
uint32_t dwFileSize = grf.length();
|
||||
if (dwFileSize > 0) {
|
||||
uint8_t* pbData = (uint8_t*)new uint8_t[dwFileSize];
|
||||
auto readResult = PlatformFileIO.readFile(
|
||||
auto readResult = PlatformFilesystem.readFile(
|
||||
grf.getPath(), pbData, dwFileSize);
|
||||
if (readResult.status !=
|
||||
IPlatformFileIO::ReadStatus::Ok) {
|
||||
IPlatformFilesystem::ReadStatus::Ok) {
|
||||
app.FatalLoadError();
|
||||
}
|
||||
|
||||
@@ -620,15 +617,16 @@ int LevelGenerationOptions::onPackMounted(int iPad, uint32_t dwErr,
|
||||
}
|
||||
if (lgo->requiresBaseSave() && !lgo->getBaseSavePath().empty()) {
|
||||
File save(app.getFilePath(lgo->m_parentDLCPack->GetPackID(),
|
||||
lgo->getBaseSavePath(), true, L"WPACK:"));
|
||||
lgo->getBaseSavePath(), true, "WPACK:"));
|
||||
if (save.exists()) {
|
||||
std::size_t dwFileSize =
|
||||
PlatformFileIO.fileSize(save.getPath());
|
||||
PlatformFilesystem.fileSize(save.getPath());
|
||||
if (dwFileSize > 0) {
|
||||
uint8_t* pbData = (uint8_t*)new uint8_t[dwFileSize];
|
||||
auto readResult = PlatformFileIO.readFile(
|
||||
auto readResult = PlatformFilesystem.readFile(
|
||||
save.getPath(), pbData, dwFileSize);
|
||||
if (readResult.status != IPlatformFileIO::ReadStatus::Ok) {
|
||||
if (readResult.status !=
|
||||
IPlatformFilesystem::ReadStatus::Ok) {
|
||||
app.FatalLoadError();
|
||||
}
|
||||
|
||||
@@ -638,7 +636,7 @@ int LevelGenerationOptions::onPackMounted(int iPad, uint32_t dwErr,
|
||||
}
|
||||
}
|
||||
}
|
||||
uint32_t result = StorageManager.UnmountInstalledDLC("WPACK");
|
||||
uint32_t result = PlatformStorage.UnmountInstalledDLC("WPACK");
|
||||
}
|
||||
|
||||
lgo->setLoadedData();
|
||||
@@ -679,7 +677,7 @@ bool LevelGenerationOptions::requiresTexturePack() {
|
||||
std::uint32_t LevelGenerationOptions::getRequiredTexturePackId() {
|
||||
return info()->getRequiredTexturePackId();
|
||||
}
|
||||
std::wstring LevelGenerationOptions::getDefaultSaveName() {
|
||||
std::string LevelGenerationOptions::getDefaultSaveName() {
|
||||
switch (getSrc()) {
|
||||
case eSrc_fromSave:
|
||||
return getString(info()->getDefaultSaveName());
|
||||
@@ -690,9 +688,9 @@ std::wstring LevelGenerationOptions::getDefaultSaveName() {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return L"";
|
||||
return "";
|
||||
}
|
||||
const wchar_t* LevelGenerationOptions::getWorldName() {
|
||||
const char* LevelGenerationOptions::getWorldName() {
|
||||
switch (getSrc()) {
|
||||
case eSrc_fromSave:
|
||||
return getString(info()->getWorldName());
|
||||
@@ -703,28 +701,28 @@ const wchar_t* LevelGenerationOptions::getWorldName() {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return L"";
|
||||
return "";
|
||||
}
|
||||
const wchar_t* LevelGenerationOptions::getDisplayName() {
|
||||
const char* LevelGenerationOptions::getDisplayName() {
|
||||
switch (getSrc()) {
|
||||
case eSrc_fromSave:
|
||||
return getString(info()->getDisplayName());
|
||||
case eSrc_fromDLC:
|
||||
return getString(info()->getDisplayName());
|
||||
case eSrc_tutorial:
|
||||
return L"";
|
||||
return "";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return L"";
|
||||
return "";
|
||||
}
|
||||
std::wstring LevelGenerationOptions::getGrfPath() {
|
||||
std::string LevelGenerationOptions::getGrfPath() {
|
||||
return info()->getGrfPath();
|
||||
}
|
||||
bool LevelGenerationOptions::requiresBaseSave() {
|
||||
return info()->requiresBaseSave();
|
||||
}
|
||||
std::wstring LevelGenerationOptions::getBaseSavePath() {
|
||||
std::string LevelGenerationOptions::getBaseSavePath() {
|
||||
return info()->getBaseSavePath();
|
||||
}
|
||||
|
||||
@@ -736,19 +734,19 @@ void LevelGenerationOptions::setRequiresTexturePack(bool x) {
|
||||
void LevelGenerationOptions::setRequiredTexturePackId(std::uint32_t x) {
|
||||
info()->setRequiredTexturePackId(x);
|
||||
}
|
||||
void LevelGenerationOptions::setDefaultSaveName(const std::wstring& x) {
|
||||
void LevelGenerationOptions::setDefaultSaveName(const std::string& x) {
|
||||
info()->setDefaultSaveName(x);
|
||||
}
|
||||
void LevelGenerationOptions::setWorldName(const std::wstring& x) {
|
||||
void LevelGenerationOptions::setWorldName(const std::string& x) {
|
||||
info()->setWorldName(x);
|
||||
}
|
||||
void LevelGenerationOptions::setDisplayName(const std::wstring& x) {
|
||||
void LevelGenerationOptions::setDisplayName(const std::string& x) {
|
||||
info()->setDisplayName(x);
|
||||
}
|
||||
void LevelGenerationOptions::setGrfPath(const std::wstring& x) {
|
||||
void LevelGenerationOptions::setGrfPath(const std::string& x) {
|
||||
info()->setGrfPath(x);
|
||||
}
|
||||
void LevelGenerationOptions::setBaseSavePath(const std::wstring& x) {
|
||||
void LevelGenerationOptions::setBaseSavePath(const std::string& x) {
|
||||
info()->setBaseSavePath(x);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "LevelGenerationOptions.h"
|
||||
#include "minecraft/world/level/GameRules/LevelGenerationOptions.h"
|
||||
|
||||
LevelGenerators::LevelGenerators() {}
|
||||
|
||||
void LevelGenerators::addLevelGenerator(const std::wstring& displayName,
|
||||
void LevelGenerators::addLevelGenerator(const std::string& displayName,
|
||||
LevelGenerationOptions* generator) {
|
||||
if (!displayName.empty()) generator->setDisplayName(displayName);
|
||||
m_levelGenerators.push_back(generator);
|
||||
@@ -14,7 +14,7 @@ private:
|
||||
public:
|
||||
LevelGenerators();
|
||||
|
||||
void addLevelGenerator(const std::wstring& displayName,
|
||||
void addLevelGenerator(const std::string& displayName,
|
||||
LevelGenerationOptions* generator);
|
||||
void removeLevelGenerator(LevelGenerationOptions* generator);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "StartFeature.h"
|
||||
|
||||
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
|
||||
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "util/StringHelpers.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "java/InputOutputStream/DataOutputStream.h"
|
||||
#include "minecraft/world/level/ConsoleGameRulesConstants.h"
|
||||
#include "minecraft/world/level/GameRules/GameRuleDefinition.h"
|
||||
#include "util/StringHelpers.h"
|
||||
|
||||
StartFeature::StartFeature() {
|
||||
m_chunkX = 0;
|
||||
@@ -27,22 +27,22 @@ void StartFeature::writeAttributes(DataOutputStream* dos,
|
||||
dos->writeUTF(toWString(m_orientation));
|
||||
}
|
||||
|
||||
void StartFeature::addAttribute(const std::wstring& attributeName,
|
||||
const std::wstring& attributeValue) {
|
||||
if (attributeName.compare(L"chunkX") == 0) {
|
||||
void StartFeature::addAttribute(const std::string& attributeName,
|
||||
const std::string& attributeValue) {
|
||||
if (attributeName.compare("chunkX") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_chunkX = value;
|
||||
app.DebugPrintf("StartFeature: Adding parameter chunkX=%d\n", m_chunkX);
|
||||
} else if (attributeName.compare(L"chunkZ") == 0) {
|
||||
} else if (attributeName.compare("chunkZ") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_chunkZ = value;
|
||||
app.DebugPrintf("StartFeature: Adding parameter chunkZ=%d\n", m_chunkZ);
|
||||
} else if (attributeName.compare(L"orientation") == 0) {
|
||||
} else if (attributeName.compare("orientation") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_orientation = value;
|
||||
app.DebugPrintf("StartFeature: Adding parameter orientation=%d\n",
|
||||
m_orientation);
|
||||
} else if (attributeName.compare(L"feature") == 0) {
|
||||
} else if (attributeName.compare("feature") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_feature = (StructureFeature::EFeatureTypes)value;
|
||||
app.DebugPrintf("StartFeature: Adding parameter feature=%d\n",
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
|
||||
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
|
||||
#include "minecraft/world/level/ConsoleGameRulesConstants.h"
|
||||
#include "minecraft/world/level/GameRules/GameRuleDefinition.h"
|
||||
#include "minecraft/world/level/levelgen/structure/StructureFeature.h"
|
||||
|
||||
class StartFeature : public GameRuleDefinition {
|
||||
@@ -20,8 +20,8 @@ public:
|
||||
}
|
||||
|
||||
virtual void writeAttributes(DataOutputStream* dos, unsigned int numAttrs);
|
||||
virtual void addAttribute(const std::wstring& attributeName,
|
||||
const std::wstring& attributeValue);
|
||||
virtual void addAttribute(const std::string& attributeName,
|
||||
const std::string& attributeValue);
|
||||
|
||||
bool isFeatureChunk(int chunkX, int chunkZ,
|
||||
StructureFeature::EFeatureTypes feature,
|
||||
@@ -1,12 +1,12 @@
|
||||
#include "XboxStructureActionGenerateBox.h"
|
||||
|
||||
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/ConsoleGenerateStructureAction.h"
|
||||
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "util/StringHelpers.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/GameRules/LevelGeneration/ConsoleGenerateStructureAction.h"
|
||||
#include "java/InputOutputStream/DataOutputStream.h"
|
||||
#include "minecraft/world/level/ConsoleGameRulesConstants.h"
|
||||
#include "minecraft/world/level/GameRules/GameRuleDefinition.h"
|
||||
#include "minecraft/world/level/levelgen/structure/StructurePiece.h"
|
||||
#include "util/StringHelpers.h"
|
||||
|
||||
XboxStructureActionGenerateBox::XboxStructureActionGenerateBox() {
|
||||
m_x0 = m_y0 = m_z0 = m_x1 = m_y1 = m_z1 = m_edgeTile = m_fillTile = 0;
|
||||
@@ -40,51 +40,51 @@ void XboxStructureActionGenerateBox::writeAttributes(DataOutputStream* dos,
|
||||
}
|
||||
|
||||
void XboxStructureActionGenerateBox::addAttribute(
|
||||
const std::wstring& attributeName, const std::wstring& attributeValue) {
|
||||
if (attributeName.compare(L"x0") == 0) {
|
||||
const std::string& attributeName, const std::string& attributeValue) {
|
||||
if (attributeName.compare("x0") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_x0 = value;
|
||||
app.DebugPrintf(
|
||||
"XboxStructureActionGenerateBox: Adding parameter x0=%d\n", m_x0);
|
||||
} else if (attributeName.compare(L"y0") == 0) {
|
||||
} else if (attributeName.compare("y0") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_y0 = value;
|
||||
app.DebugPrintf(
|
||||
"XboxStructureActionGenerateBox: Adding parameter y0=%d\n", m_y0);
|
||||
} else if (attributeName.compare(L"z0") == 0) {
|
||||
} else if (attributeName.compare("z0") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_z0 = value;
|
||||
app.DebugPrintf(
|
||||
"XboxStructureActionGenerateBox: Adding parameter z0=%d\n", m_z0);
|
||||
} else if (attributeName.compare(L"x1") == 0) {
|
||||
} else if (attributeName.compare("x1") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_x1 = value;
|
||||
app.DebugPrintf(
|
||||
"XboxStructureActionGenerateBox: Adding parameter x1=%d\n", m_x1);
|
||||
} else if (attributeName.compare(L"y1") == 0) {
|
||||
} else if (attributeName.compare("y1") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_y1 = value;
|
||||
app.DebugPrintf(
|
||||
"XboxStructureActionGenerateBox: Adding parameter y1=%d\n", m_y1);
|
||||
} else if (attributeName.compare(L"z1") == 0) {
|
||||
} else if (attributeName.compare("z1") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_z1 = value;
|
||||
app.DebugPrintf(
|
||||
"XboxStructureActionGenerateBox: Adding parameter z1=%d\n", m_z1);
|
||||
} else if (attributeName.compare(L"edgeTile") == 0) {
|
||||
} else if (attributeName.compare("edgeTile") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_edgeTile = value;
|
||||
app.DebugPrintf(
|
||||
"XboxStructureActionGenerateBox: Adding parameter edgeTile=%d\n",
|
||||
m_edgeTile);
|
||||
} else if (attributeName.compare(L"fillTile") == 0) {
|
||||
} else if (attributeName.compare("fillTile") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_fillTile = value;
|
||||
app.DebugPrintf(
|
||||
"XboxStructureActionGenerateBox: Adding parameter fillTile=%d\n",
|
||||
m_fillTile);
|
||||
} else if (attributeName.compare(L"skipAir") == 0) {
|
||||
if (attributeValue.compare(L"true") == 0) m_skipAir = true;
|
||||
} else if (attributeName.compare("skipAir") == 0) {
|
||||
if (attributeValue.compare("true") == 0) m_skipAir = true;
|
||||
app.DebugPrintf(
|
||||
"XboxStructureActionGenerateBox: Adding parameter skipAir=%s\n",
|
||||
m_skipAir ? "true" : "false");
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/ConsoleGenerateStructureAction.h"
|
||||
#include "app/common/GameRules/LevelGeneration/ConsoleGenerateStructureAction.h"
|
||||
#include "minecraft/world/level/ConsoleGameRulesConstants.h"
|
||||
|
||||
class StructurePiece;
|
||||
class Level;
|
||||
@@ -25,8 +25,8 @@ public:
|
||||
virtual int getEndZ() { return m_z1; }
|
||||
|
||||
virtual void writeAttributes(DataOutputStream* dos, unsigned int numAttrs);
|
||||
virtual void addAttribute(const std::wstring& attributeName,
|
||||
const std::wstring& attributeValue);
|
||||
virtual void addAttribute(const std::string& attributeName,
|
||||
const std::string& attributeValue);
|
||||
|
||||
bool generateBoxInLevel(StructurePiece* structure, Level* level,
|
||||
BoundingBox* chunkBB);
|
||||
@@ -1,12 +1,12 @@
|
||||
#include "XboxStructureActionPlaceBlock.h"
|
||||
|
||||
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/ConsoleGenerateStructureAction.h"
|
||||
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "util/StringHelpers.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/GameRules/LevelGeneration/ConsoleGenerateStructureAction.h"
|
||||
#include "java/InputOutputStream/DataOutputStream.h"
|
||||
#include "minecraft/world/level/ConsoleGameRulesConstants.h"
|
||||
#include "minecraft/world/level/GameRules/GameRuleDefinition.h"
|
||||
#include "minecraft/world/level/levelgen/structure/StructurePiece.h"
|
||||
#include "util/StringHelpers.h"
|
||||
|
||||
XboxStructureActionPlaceBlock::XboxStructureActionPlaceBlock() {
|
||||
m_x = m_y = m_z = m_tile = m_data = 0;
|
||||
@@ -30,29 +30,29 @@ void XboxStructureActionPlaceBlock::writeAttributes(DataOutputStream* dos,
|
||||
}
|
||||
|
||||
void XboxStructureActionPlaceBlock::addAttribute(
|
||||
const std::wstring& attributeName, const std::wstring& attributeValue) {
|
||||
if (attributeName.compare(L"x") == 0) {
|
||||
const std::string& attributeName, const std::string& attributeValue) {
|
||||
if (attributeName.compare("x") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_x = value;
|
||||
app.DebugPrintf(
|
||||
"XboxStructureActionPlaceBlock: Adding parameter x=%d\n", m_x);
|
||||
} else if (attributeName.compare(L"y") == 0) {
|
||||
} else if (attributeName.compare("y") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_y = value;
|
||||
app.DebugPrintf(
|
||||
"XboxStructureActionPlaceBlock: Adding parameter y=%d\n", m_y);
|
||||
} else if (attributeName.compare(L"z") == 0) {
|
||||
} else if (attributeName.compare("z") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_z = value;
|
||||
app.DebugPrintf(
|
||||
"XboxStructureActionPlaceBlock: Adding parameter z=%d\n", m_z);
|
||||
} else if (attributeName.compare(L"block") == 0) {
|
||||
} else if (attributeName.compare("block") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_tile = value;
|
||||
app.DebugPrintf(
|
||||
"XboxStructureActionPlaceBlock: Adding parameter block=%d\n",
|
||||
m_tile);
|
||||
} else if (attributeName.compare(L"data") == 0) {
|
||||
} else if (attributeName.compare("data") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_data = value;
|
||||
app.DebugPrintf(
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/ConsoleGenerateStructureAction.h"
|
||||
#include "app/common/GameRules/LevelGeneration/ConsoleGenerateStructureAction.h"
|
||||
#include "minecraft/world/level/ConsoleGameRulesConstants.h"
|
||||
|
||||
class StructurePiece;
|
||||
class Level;
|
||||
@@ -24,8 +24,8 @@ public:
|
||||
virtual int getEndZ() { return m_z; }
|
||||
|
||||
virtual void writeAttributes(DataOutputStream* dos, unsigned int numAttrs);
|
||||
virtual void addAttribute(const std::wstring& attributeName,
|
||||
const std::wstring& attributeValue);
|
||||
virtual void addAttribute(const std::string& attributeName,
|
||||
const std::string& attributeValue);
|
||||
|
||||
bool placeBlockInLevel(StructurePiece* structure, Level* level,
|
||||
BoundingBox* chunkBB);
|
||||
@@ -4,17 +4,17 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceBlock.h"
|
||||
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/AddItemRuleDefinition.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "util/StringHelpers.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceBlock.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/AddItemRuleDefinition.h"
|
||||
#include "minecraft/world/Container.h"
|
||||
#include "minecraft/world/level/ConsoleGameRulesConstants.h"
|
||||
#include "minecraft/world/level/Level.h"
|
||||
#include "minecraft/world/level/levelgen/structure/BoundingBox.h"
|
||||
#include "minecraft/world/level/levelgen/structure/StructurePiece.h"
|
||||
#include "minecraft/world/level/tile/Tile.h"
|
||||
#include "minecraft/world/level/tile/entity/TileEntity.h"
|
||||
#include "util/StringHelpers.h"
|
||||
|
||||
XboxStructureActionPlaceContainer::XboxStructureActionPlaceContainer() {
|
||||
m_tile = Tile::chest_Id;
|
||||
@@ -45,9 +45,9 @@ GameRuleDefinition* XboxStructureActionPlaceContainer::addChild(
|
||||
m_items.push_back((AddItemRuleDefinition*)rule);
|
||||
} else {
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
wprintf(
|
||||
L"XboxStructureActionPlaceContainer: Attempted to add invalid "
|
||||
L"child rule - %d\n",
|
||||
printf(
|
||||
"XboxStructureActionPlaceContainer: Attempted to add invalid "
|
||||
"child rule - %d\n",
|
||||
ruleType);
|
||||
#endif
|
||||
}
|
||||
@@ -55,8 +55,8 @@ GameRuleDefinition* XboxStructureActionPlaceContainer::addChild(
|
||||
}
|
||||
|
||||
void XboxStructureActionPlaceContainer::addAttribute(
|
||||
const std::wstring& attributeName, const std::wstring& attributeValue) {
|
||||
if (attributeName.compare(L"facing") == 0) {
|
||||
const std::string& attributeName, const std::string& attributeValue) {
|
||||
if (attributeName.compare("facing") == 0) {
|
||||
int value = fromWString<int>(attributeValue);
|
||||
m_data = value;
|
||||
app.DebugPrintf(
|
||||
@@ -3,8 +3,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
|
||||
#include "XboxStructureActionPlaceBlock.h"
|
||||
#include "minecraft/world/level/ConsoleGameRulesConstants.h"
|
||||
|
||||
class AddItemRuleDefinition;
|
||||
class StructurePiece;
|
||||
@@ -31,8 +31,8 @@ public:
|
||||
// virtual void writeAttributes(DataOutputStream *dos, uint32_t
|
||||
// numAttributes);
|
||||
|
||||
virtual void addAttribute(const std::wstring& attributeName,
|
||||
const std::wstring& attributeValue);
|
||||
virtual void addAttribute(const std::string& attributeName,
|
||||
const std::string& attributeValue);
|
||||
|
||||
bool placeContainerInLevel(StructurePiece* structure, Level* level,
|
||||
BoundingBox* chunkBB);
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceBlock.h"
|
||||
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceBlock.h"
|
||||
#include "java/InputOutputStream/DataOutputStream.h"
|
||||
#include "minecraft/world/level/ConsoleGameRulesConstants.h"
|
||||
#include "minecraft/world/level/Level.h"
|
||||
#include "minecraft/world/level/levelgen/structure/BoundingBox.h"
|
||||
#include "minecraft/world/level/levelgen/structure/StructurePiece.h"
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
XboxStructureActionPlaceSpawner::XboxStructureActionPlaceSpawner() {
|
||||
m_tile = Tile::mobSpawner_Id;
|
||||
m_entityId = L"Pig";
|
||||
m_entityId = "Pig";
|
||||
}
|
||||
|
||||
XboxStructureActionPlaceSpawner::~XboxStructureActionPlaceSpawner() {}
|
||||
@@ -29,13 +29,12 @@ void XboxStructureActionPlaceSpawner::writeAttributes(DataOutputStream* dos,
|
||||
}
|
||||
|
||||
void XboxStructureActionPlaceSpawner::addAttribute(
|
||||
const std::wstring& attributeName, const std::wstring& attributeValue) {
|
||||
if (attributeName.compare(L"entity") == 0) {
|
||||
const std::string& attributeName, const std::string& attributeValue) {
|
||||
if (attributeName.compare("entity") == 0) {
|
||||
m_entityId = attributeValue;
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
wprintf(
|
||||
L"XboxStructureActionPlaceSpawner: Adding parameter entity=%ls\n",
|
||||
m_entityId.c_str());
|
||||
printf("XboxStructureActionPlaceSpawner: Adding parameter entity=%s\n",
|
||||
m_entityId.c_str());
|
||||
#endif
|
||||
} else {
|
||||
XboxStructureActionPlaceBlock::addAttribute(attributeName,
|
||||
@@ -64,9 +63,9 @@ bool XboxStructureActionPlaceSpawner::placeSpawnerInLevel(
|
||||
level->getTileEntity(worldX, worldY, worldZ));
|
||||
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
wprintf(
|
||||
L"XboxStructureActionPlaceSpawner - placing a %ls spawner at "
|
||||
L"(%d,%d,%d)\n",
|
||||
printf(
|
||||
"XboxStructureActionPlaceSpawner - placing a %s spawner at "
|
||||
"(%d,%d,%d)\n",
|
||||
m_entityId.c_str(), worldX, worldY, worldZ);
|
||||
#endif
|
||||
if (entity != nullptr) {
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
|
||||
#include "XboxStructureActionPlaceBlock.h"
|
||||
#include "minecraft/world/level/ConsoleGameRulesConstants.h"
|
||||
|
||||
class StructurePiece;
|
||||
class Level;
|
||||
@@ -12,7 +12,7 @@ class GRFObject;
|
||||
|
||||
class XboxStructureActionPlaceSpawner : public XboxStructureActionPlaceBlock {
|
||||
private:
|
||||
std::wstring m_entityId;
|
||||
std::string m_entityId;
|
||||
|
||||
public:
|
||||
XboxStructureActionPlaceSpawner();
|
||||
@@ -23,8 +23,8 @@ public:
|
||||
}
|
||||
|
||||
virtual void writeAttributes(DataOutputStream* dos, unsigned int numAttrs);
|
||||
virtual void addAttribute(const std::wstring& attributeName,
|
||||
const std::wstring& attributeValue);
|
||||
virtual void addAttribute(const std::string& attributeName,
|
||||
const std::string& attributeValue);
|
||||
|
||||
bool placeSpawnerInLevel(StructurePiece* structure, Level* level,
|
||||
BoundingBox* chunkBB);
|
||||