Merge branch 'dev' into feat/restore-java-gui
4
.clang-format
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
BasedOnStyle: Google
|
||||
IndentWidth: 4
|
||||
AccessModifierOffset: -4
|
||||
SortIncludes: false # FIXME: https://github.com/4jcraft/4jcraft/issues/225
|
||||
|
|
@ -15,10 +15,10 @@ RUN apt-get update \
|
|||
libsdl2-dev \
|
||||
libgl-dev \
|
||||
libglu1-mesa-dev \
|
||||
libpthread-stubs0-dev
|
||||
libpthread-stubs0-dev \
|
||||
# Clean up lol
|
||||
&& apt-get autoremove -y \
|
||||
&& apt-get clean -y \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV DEBIAN_FRONTEND=dialog
|
||||
ENV DEBIAN_FRONTEND=dialog
|
||||
|
|
|
|||
3
.git-blame-ignore-revs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
e8424f2000222490850d2a5227b6b6b0c0a5d6ce
|
||||
33d0737d1d4a6d8a7f0fa3bf2af2b242b545dc69
|
||||
631873465238400f8ed8113ac87d63c3d6edf617
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
BIN
.github-assets/adobe_getflash2.gif
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
.github-assets/flash_get_20010813.gif
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
.github-assets/ieget-an.gif
Normal file
|
After Width: | Height: | Size: 7.2 KiB |
BIN
.github-assets/internetarchive.gif
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
.github-assets/minecraft.gif
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
.github-assets/opengl.gif
Normal file
|
After Width: | Height: | Size: 3 KiB |
BIN
.github-assets/powered-llvm.gif
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
.github-assets/progress.png
Normal file
|
After Width: | Height: | Size: 438 B |
BIN
.github-assets/transrights.png
Normal file
|
After Width: | Height: | Size: 477 B |
34
.github/scripts/check-clang-format.sh
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
formatter="${CLANG_FORMAT_BIN:-clang-format-19}"
|
||||
base_ref="${1:-}"
|
||||
head_ref="${2:-HEAD}"
|
||||
|
||||
if [[ -z "$base_ref" ]]; then
|
||||
if git rev-parse --verify HEAD^ >/dev/null 2>&1; then
|
||||
base_ref="$(git rev-parse HEAD^)"
|
||||
else
|
||||
echo "No comparison base available; skipping clang-format check."
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
diff_output="$(
|
||||
git diff --name-only --diff-filter=ACMR "$base_ref" "$head_ref" -- \
|
||||
'*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' '*.inl'
|
||||
)"
|
||||
|
||||
if [[ -z "$diff_output" ]]; then
|
||||
echo "No changed C/C++ files to check."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mapfile -t files <<<"$diff_output"
|
||||
|
||||
echo "Checking formatting for changed files:"
|
||||
printf ' %s\n' "${files[@]}"
|
||||
|
||||
"$formatter" --version
|
||||
"$formatter" --dry-run --Werror "${files[@]}"
|
||||
50
.github/workflows/build-doxygen.yml
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
name: Publish Documentation
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["dev"]
|
||||
paths:
|
||||
- "4J.Input/**"
|
||||
- "4J.Profile/**"
|
||||
- "4J.Render/**"
|
||||
- "4J.Storage/**"
|
||||
- "Minecraft.Assets/**"
|
||||
- "Minecraft.Client/**"
|
||||
- "Minecraft.World/**"
|
||||
- "docs/**"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Doxygen
|
||||
run: sudo apt-get update && sudo apt-get install -y doxygen graphviz build-essential libsdl2-dev libgl-dev libglu1-mesa-dev libpthread-stubs0-dev
|
||||
- name: Update doxygen-awesome
|
||||
run: git submodule update --init --recursive
|
||||
- name: Generate Docs
|
||||
run: cd docs && doxygen
|
||||
- name: Configure Pages
|
||||
uses: actions/configure-pages@v4
|
||||
- name: Upload Pages Artifacts
|
||||
uses: actions/upload-pages-artifact@v4
|
||||
with:
|
||||
path: ./docs/html
|
||||
deploy:
|
||||
needs: build
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
steps:
|
||||
- name: Deploy Github Pages
|
||||
uses: actions/deploy-pages@v4
|
||||
id: deployment
|
||||
69
.github/workflows/clang-format.yml
vendored
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
name: Clang Format
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.cpp'
|
||||
- '**.h'
|
||||
- '**.c'
|
||||
- '**.cc'
|
||||
- '**.cxx'
|
||||
- '**.hh'
|
||||
- '**.hpp'
|
||||
- '**.hxx'
|
||||
- '**.inl'
|
||||
- '.clang-format'
|
||||
- '.github/workflows/clang-format.yml'
|
||||
- '.github/scripts/check-clang-format.sh'
|
||||
pull_request:
|
||||
paths:
|
||||
- '**.cpp'
|
||||
- '**.h'
|
||||
- '**.c'
|
||||
- '**.cc'
|
||||
- '**.cxx'
|
||||
- '**.hh'
|
||||
- '**.hpp'
|
||||
- '**.hxx'
|
||||
- '**.inl'
|
||||
- '.clang-format'
|
||||
- '.github/workflows/clang-format.yml'
|
||||
- '.github/scripts/check-clang-format.sh'
|
||||
|
||||
jobs:
|
||||
clang-format:
|
||||
runs-on: ubuntu-24.04
|
||||
concurrency:
|
||||
group: clang-format-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install clang-format
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y clang-format-19
|
||||
|
||||
- name: Check changed files
|
||||
env:
|
||||
CLANG_FORMAT_BIN: clang-format-19
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
|
||||
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
BEFORE_SHA: ${{ github.event.before }}
|
||||
CURRENT_SHA: ${{ github.sha }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
BASE_SHA=""
|
||||
if [ "$EVENT_NAME" = "pull_request" ]; then
|
||||
git fetch --no-tags origin "$PR_BASE_REF" --depth=1
|
||||
BASE_SHA="$(git merge-base "origin/$PR_BASE_REF" "$CURRENT_SHA")"
|
||||
elif [ -n "$BEFORE_SHA" ] && [ "$BEFORE_SHA" != "0000000000000000000000000000000000000000" ]; then
|
||||
BASE_SHA="$BEFORE_SHA"
|
||||
fi
|
||||
|
||||
bash ./.github/scripts/check-clang-format.sh "$BASE_SHA" "$CURRENT_SHA"
|
||||
32
.gitignore
vendored
|
|
@ -4,40 +4,19 @@ builddir/
|
|||
.cache/
|
||||
.idea/
|
||||
build_meson/
|
||||
cmake-build-debug/
|
||||
|
||||
# meson subprojects (git clone'd on build)
|
||||
/subprojects/*
|
||||
!/subprojects/*.wrap
|
||||
|
||||
# Nix flake output
|
||||
result
|
||||
|
||||
# Final binaries and platform output
|
||||
/Linux/
|
||||
/x64/
|
||||
|
||||
# CMake generated artifacts
|
||||
CMakeCache.txt
|
||||
CMakeFiles/
|
||||
cmake_install.cmake
|
||||
Makefile
|
||||
|
||||
# Meson generated artifacts (inside source tree, e.g. per-subdir)
|
||||
meson-private/
|
||||
meson-info/
|
||||
meson-logs/
|
||||
|
||||
# Compiler/linker intermediates
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
*.so.*
|
||||
*.out
|
||||
*.d
|
||||
compile_commands.json
|
||||
.clangd
|
||||
|
||||
|
||||
# ----- Scratch / legacy -----
|
||||
oldimpl/
|
||||
|
||||
# ----- IDE / editor -----
|
||||
.cache/
|
||||
.idea/
|
||||
|
|
@ -46,3 +25,6 @@ oldimpl/
|
|||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
|
||||
# ----- Documentation -----
|
||||
docs/
|
||||
|
|
|
|||
3
.gitmodules
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[submodule "docs/doxygen-awesome-css"]
|
||||
path = docs/doxygen-awesome-css
|
||||
url = https://github.com/jothepro/doxygen-awesome-css.git
|
||||
|
|
@ -8,53 +8,136 @@
|
|||
|
||||
C_4JInput InputManager;
|
||||
|
||||
static const int KEY_COUNT = SDL_NUM_SCANCODES;
|
||||
static const int KEY_COUNT = SDL_NUM_SCANCODES;
|
||||
static const int BTN_COUNT = SDL_CONTROLLER_BUTTON_MAX;
|
||||
static const int AXS_COUNT = SDL_CONTROLLER_AXIS_MAX;
|
||||
static const float MOUSE_SCALE = 0.015f;
|
||||
// Vars
|
||||
static bool s_sdlInitialized = false;
|
||||
static bool s_keysCurrent[KEY_COUNT] = {};
|
||||
static bool s_keysPrev [KEY_COUNT] = {};
|
||||
static bool s_mouseLeftCurrent = false, s_mouseLeftPrev = false;
|
||||
static bool s_keysPrev[KEY_COUNT] = {};
|
||||
static bool s_btnsCurrent[BTN_COUNT] = {};
|
||||
static bool s_btnsPrev[BTN_COUNT] = {};
|
||||
static bool s_axisCurrent[AXS_COUNT] = {};
|
||||
static bool s_axisPrev[AXS_COUNT] = {};
|
||||
static float axisVal[AXS_COUNT] = {};
|
||||
static bool s_mouseLeftCurrent = false, s_mouseLeftPrev = false;
|
||||
static bool s_mouseRightCurrent = false, s_mouseRightPrev = false;
|
||||
static bool s_menuDisplayed[4] = {};
|
||||
static bool s_menuDisplayed[4] = {};
|
||||
static bool s_prevMenuDisplayed = false;
|
||||
static bool s_snapTaken = false;
|
||||
static float s_accumRelX = 0, s_accumRelY = 0;
|
||||
static float s_snapRelX = 0, s_snapRelY = 0;
|
||||
static int s_mouseX = 0, s_mouseY = 0;
|
||||
static float s_snapRelX = 0, s_snapRelY = 0;
|
||||
static int s_mouseX = 0, s_mouseY = 0;
|
||||
|
||||
static int s_scrollTicksForButtonPressed = 0;
|
||||
static int s_scrollTicksForGetValue = 0;
|
||||
static int s_scrollTicksSnap = 0;
|
||||
static bool s_scrollSnapTaken = false;
|
||||
static int s_scrollTicksForButtonPressed = 0;
|
||||
static int s_scrollTicksForGetValue = 0;
|
||||
static int s_scrollTicksSnap = 0;
|
||||
static bool s_scrollSnapTaken = false;
|
||||
|
||||
// We set all the watched keys
|
||||
// I don't know if I'll need to change this if we add chat support soon.
|
||||
static const int s_watchedKeys[] = {
|
||||
SDL_SCANCODE_W, SDL_SCANCODE_A, SDL_SCANCODE_S, SDL_SCANCODE_D,
|
||||
SDL_SCANCODE_SPACE, SDL_SCANCODE_LSHIFT, SDL_SCANCODE_RSHIFT,
|
||||
SDL_SCANCODE_E, SDL_SCANCODE_Q, SDL_SCANCODE_F,
|
||||
SDL_SCANCODE_C, SDL_SCANCODE_ESCAPE, SDL_SCANCODE_RETURN,
|
||||
SDL_SCANCODE_F3, SDL_SCANCODE_F5,
|
||||
SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT,
|
||||
SDL_SCANCODE_PAGEUP, SDL_SCANCODE_PAGEDOWN,
|
||||
SDL_SCANCODE_TAB, SDL_SCANCODE_LCTRL, SDL_SCANCODE_RCTRL,
|
||||
SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_3, SDL_SCANCODE_4,
|
||||
SDL_SCANCODE_5, SDL_SCANCODE_6, SDL_SCANCODE_7, SDL_SCANCODE_8,
|
||||
SDL_SCANCODE_9,
|
||||
};
|
||||
static const int s_watchedKeyCount = (int)(sizeof(s_watchedKeys) / sizeof(s_watchedKeys[0]));
|
||||
SDL_SCANCODE_W, SDL_SCANCODE_A, SDL_SCANCODE_S,
|
||||
SDL_SCANCODE_D, SDL_SCANCODE_SPACE, SDL_SCANCODE_LSHIFT,
|
||||
SDL_SCANCODE_RSHIFT, SDL_SCANCODE_E, SDL_SCANCODE_Q,
|
||||
SDL_SCANCODE_F, SDL_SCANCODE_C, SDL_SCANCODE_ESCAPE,
|
||||
SDL_SCANCODE_RETURN, SDL_SCANCODE_F3, SDL_SCANCODE_F5,
|
||||
SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT,
|
||||
SDL_SCANCODE_RIGHT, SDL_SCANCODE_PAGEUP, SDL_SCANCODE_PAGEDOWN,
|
||||
SDL_SCANCODE_TAB, SDL_SCANCODE_LCTRL, SDL_SCANCODE_RCTRL,
|
||||
SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_3,
|
||||
SDL_SCANCODE_4, SDL_SCANCODE_5, SDL_SCANCODE_6,
|
||||
SDL_SCANCODE_7, SDL_SCANCODE_8, SDL_SCANCODE_9,
|
||||
SDL_SCANCODE_Z, SDL_SCANCODE_X, SDL_SCANCODE_C,
|
||||
SDL_SCANCODE_V};
|
||||
static const int s_watchedKeyCount =
|
||||
(int)(sizeof(s_watchedKeys) / sizeof(s_watchedKeys[0]));
|
||||
|
||||
static inline bool KDown (int sc) { return (sc > 0 && sc < KEY_COUNT) ? s_keysCurrent[sc] : false; }
|
||||
static inline bool KPressed (int sc) { return (sc > 0 && sc < KEY_COUNT) ? !s_keysPrev[sc] && s_keysCurrent[sc] : false; }
|
||||
static inline bool KReleased(int sc) { return (sc > 0 && sc < KEY_COUNT) ? s_keysPrev[sc] && !s_keysCurrent[sc] : false; }
|
||||
static inline bool KDown(int sc) {
|
||||
return (sc > 0 && sc < KEY_COUNT) ? s_keysCurrent[sc] : false;
|
||||
}
|
||||
static inline bool KPressed(int sc) {
|
||||
return (sc > 0 && sc < KEY_COUNT) ? !s_keysPrev[sc] && s_keysCurrent[sc]
|
||||
: false;
|
||||
}
|
||||
static inline bool KReleased(int sc) {
|
||||
return (sc > 0 && sc < KEY_COUNT) ? s_keysPrev[sc] && !s_keysCurrent[sc]
|
||||
: false;
|
||||
}
|
||||
|
||||
static inline bool MouseLDown () { return s_mouseLeftCurrent; }
|
||||
static inline bool MouseLPressed () { return s_mouseLeftCurrent && !s_mouseLeftPrev; }
|
||||
static inline bool MouseLReleased() { return !s_mouseLeftCurrent && s_mouseLeftPrev; }
|
||||
static inline bool MouseRDown () { return s_mouseRightCurrent; }
|
||||
static inline bool MouseRPressed () { return s_mouseRightCurrent && !s_mouseRightPrev; }
|
||||
static inline bool MouseRReleased() { return !s_mouseRightCurrent && s_mouseRightPrev; }
|
||||
static inline bool MouseLDown() { return s_mouseLeftCurrent; }
|
||||
static inline bool MouseLPressed() {
|
||||
return s_mouseLeftCurrent && !s_mouseLeftPrev;
|
||||
}
|
||||
static inline bool MouseLReleased() {
|
||||
return !s_mouseLeftCurrent && s_mouseLeftPrev;
|
||||
}
|
||||
static inline bool MouseRDown() { return s_mouseRightCurrent; }
|
||||
static inline bool MouseRPressed() {
|
||||
return s_mouseRightCurrent && !s_mouseRightPrev;
|
||||
}
|
||||
static inline bool MouseRReleased() {
|
||||
return !s_mouseRightCurrent && s_mouseRightPrev;
|
||||
}
|
||||
|
||||
// holds controller object
|
||||
static SDL_GameController* controller = nullptr;
|
||||
|
||||
// Watched controller buttons set
|
||||
static const SDL_GameControllerButton s_watchedBtns[] = {
|
||||
SDL_CONTROLLER_BUTTON_A,
|
||||
SDL_CONTROLLER_BUTTON_B,
|
||||
SDL_CONTROLLER_BUTTON_X,
|
||||
SDL_CONTROLLER_BUTTON_Y,
|
||||
SDL_CONTROLLER_BUTTON_BACK,
|
||||
SDL_CONTROLLER_BUTTON_GUIDE,
|
||||
SDL_CONTROLLER_BUTTON_START,
|
||||
SDL_CONTROLLER_BUTTON_LEFTSTICK,
|
||||
SDL_CONTROLLER_BUTTON_RIGHTSTICK,
|
||||
SDL_CONTROLLER_BUTTON_LEFTSHOULDER,
|
||||
SDL_CONTROLLER_BUTTON_RIGHTSHOULDER,
|
||||
SDL_CONTROLLER_BUTTON_DPAD_UP,
|
||||
SDL_CONTROLLER_BUTTON_DPAD_DOWN,
|
||||
SDL_CONTROLLER_BUTTON_DPAD_LEFT,
|
||||
SDL_CONTROLLER_BUTTON_DPAD_RIGHT};
|
||||
static const int s_watchedBtnsCount =
|
||||
(int)(sizeof(s_watchedBtns) / sizeof(s_watchedBtns[0]));
|
||||
|
||||
static inline bool CDown(int cb) {
|
||||
return (cb >= 0 && cb < BTN_COUNT) ? s_btnsCurrent[cb] : false;
|
||||
}
|
||||
static inline bool CPressed(int cb) {
|
||||
return (cb >= 0 && cb < BTN_COUNT) ? !s_btnsPrev[cb] && s_btnsCurrent[cb]
|
||||
: false;
|
||||
}
|
||||
static inline bool CReleased(int cb) {
|
||||
return (cb >= 0 && cb < BTN_COUNT) ? s_btnsPrev[cb] && !s_btnsCurrent[cb]
|
||||
: false;
|
||||
}
|
||||
|
||||
// Sets controller dead zone
|
||||
static int deadZone = 8000;
|
||||
|
||||
// Watched controller axes set
|
||||
static const SDL_GameControllerAxis s_watchedAxis[] = {
|
||||
SDL_CONTROLLER_AXIS_LEFTX, SDL_CONTROLLER_AXIS_LEFTY,
|
||||
SDL_CONTROLLER_AXIS_RIGHTX, SDL_CONTROLLER_AXIS_RIGHTY,
|
||||
SDL_CONTROLLER_AXIS_TRIGGERLEFT, SDL_CONTROLLER_AXIS_TRIGGERRIGHT};
|
||||
static const int s_watchedAxisCount =
|
||||
(int)(sizeof(s_watchedAxis) / sizeof(s_watchedAxis[0]));
|
||||
|
||||
static inline bool ADown(int ca) {
|
||||
return (ca >= 0 && ca < AXS_COUNT) ? s_axisCurrent[ca] : false;
|
||||
}
|
||||
static inline bool APressed(int ca) {
|
||||
return (ca >= 0 && ca < AXS_COUNT) ? !s_axisPrev[ca] && s_axisCurrent[ca]
|
||||
: false;
|
||||
}
|
||||
static inline bool AReleased(int ca) {
|
||||
return (ca >= 0 && ca < AXS_COUNT) ? s_axisPrev[ca] && !s_axisCurrent[ca]
|
||||
: false;
|
||||
}
|
||||
|
||||
// get directly into SDL events before the game queue can steal them.
|
||||
// this took me a while.
|
||||
|
|
@ -77,6 +160,31 @@ static int SDLCALL EventWatcher(void*, SDL_Event* e) {
|
|||
} else if (e->type == SDL_MOUSEMOTION) {
|
||||
s_accumRelX += (float)e->motion.xrel;
|
||||
s_accumRelY += (float)e->motion.yrel;
|
||||
} else if (e->type == SDL_CONTROLLERDEVICEADDED) { // Will search for
|
||||
// controller if none
|
||||
for (int i = 0; i < SDL_NumJoysticks(); i++) {
|
||||
if (SDL_IsGameController(i)) {
|
||||
controller = SDL_GameControllerOpen(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (controller) { // only checks when a controller exists
|
||||
if (e->type == SDL_CONTROLLERDEVICEREMOVED) {
|
||||
SDL_Joystick* joy = SDL_GameControllerGetJoystick(controller);
|
||||
if (SDL_JoystickInstanceID(joy) == e->cdevice.which) {
|
||||
SDL_GameControllerClose(controller);
|
||||
controller = nullptr;
|
||||
}
|
||||
} else if (e->type == SDL_CONTROLLERBUTTONDOWN) {
|
||||
if (e->cbutton.button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER) {
|
||||
s_scrollTicksForGetValue++;
|
||||
s_scrollTicksForButtonPressed++;
|
||||
} else if (e->cbutton.button ==
|
||||
SDL_CONTROLLER_BUTTON_RIGHTSHOULDER) {
|
||||
s_scrollTicksForGetValue--;
|
||||
s_scrollTicksForButtonPressed--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -92,8 +200,10 @@ static int ScrollSnap() {
|
|||
|
||||
static void TakeSnapIfNeeded() {
|
||||
if (!s_snapTaken) {
|
||||
s_snapRelX = s_accumRelX; s_accumRelX = 0;
|
||||
s_snapRelY = s_accumRelY; s_accumRelY = 0;
|
||||
s_snapRelX = s_accumRelX;
|
||||
s_accumRelX = 0;
|
||||
s_snapRelY = s_accumRelY;
|
||||
s_accumRelY = 0;
|
||||
s_snapTaken = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -103,31 +213,52 @@ void C_4JInput::Initialise(int, unsigned char, unsigned char, unsigned char) {
|
|||
if (SDL_WasInit(SDL_INIT_VIDEO) == 0) {
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
}
|
||||
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0) {
|
||||
SDL_Init(SDL_INIT_GAMECONTROLLER);
|
||||
}
|
||||
SDL_AddEventWatch(EventWatcher, NULL);
|
||||
s_sdlInitialized = true;
|
||||
}
|
||||
|
||||
memset(s_keysCurrent, 0, sizeof(s_keysCurrent));
|
||||
memset(s_keysPrev, 0, sizeof(s_keysPrev));
|
||||
memset(s_keysCurrent, 0, sizeof(s_keysCurrent));
|
||||
memset(s_keysPrev, 0, sizeof(s_keysPrev));
|
||||
memset(s_btnsCurrent, 0, sizeof(s_btnsCurrent));
|
||||
memset(s_btnsPrev, 0, sizeof(s_btnsPrev));
|
||||
memset(s_axisCurrent, 0, sizeof(s_axisCurrent));
|
||||
memset(s_axisPrev, 0, sizeof(s_axisPrev));
|
||||
memset(s_menuDisplayed, 0, sizeof(s_menuDisplayed));
|
||||
|
||||
s_mouseLeftCurrent = s_mouseLeftPrev = s_mouseRightCurrent = s_mouseRightPrev = false;
|
||||
s_mouseLeftCurrent = s_mouseLeftPrev = s_mouseRightCurrent =
|
||||
s_mouseRightPrev = false;
|
||||
s_accumRelX = s_accumRelY = s_snapRelX = s_snapRelY = 0;
|
||||
// i really gotta name these vars better..
|
||||
s_scrollTicksForButtonPressed = s_scrollTicksForGetValue = s_scrollTicksSnap = 0;
|
||||
s_scrollTicksForButtonPressed = s_scrollTicksForGetValue =
|
||||
s_scrollTicksSnap = 0;
|
||||
s_snapTaken = s_scrollSnapTaken = s_prevMenuDisplayed = false;
|
||||
|
||||
if (s_sdlInitialized)
|
||||
if (s_sdlInitialized) {
|
||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||
|
||||
// looks for controller
|
||||
for (int i = 0; i < SDL_NumJoysticks(); i++) {
|
||||
if (SDL_IsGameController(i)) {
|
||||
controller = SDL_GameControllerOpen(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Each tick we update the input state by polling SDL, this is where we get the kbd and mouse state.
|
||||
// Each tick we update the input state by polling SDL, this is where we get the
|
||||
// kbd and mouse state.
|
||||
void C_4JInput::Tick() {
|
||||
if (!s_sdlInitialized) return;
|
||||
|
||||
memcpy(s_keysPrev, s_keysCurrent, sizeof(s_keysCurrent));
|
||||
s_mouseLeftPrev = s_mouseLeftCurrent;
|
||||
memcpy(s_btnsPrev, s_btnsCurrent, sizeof(s_btnsCurrent));
|
||||
memcpy(s_axisPrev, s_axisCurrent, sizeof(s_axisCurrent));
|
||||
s_mouseLeftPrev = s_mouseLeftCurrent;
|
||||
s_mouseRightPrev = s_mouseRightCurrent;
|
||||
s_snapTaken = false;
|
||||
s_snapTaken = false;
|
||||
s_scrollSnapTaken = false;
|
||||
s_snapRelX = s_snapRelY = 0;
|
||||
s_scrollTicksSnap = 0;
|
||||
|
|
@ -138,14 +269,14 @@ void C_4JInput::Tick() {
|
|||
s_scrollTicksForGetValue = 0;
|
||||
}
|
||||
|
||||
const Uint8 *state = SDL_GetKeyboardState(NULL);
|
||||
const Uint8* state = SDL_GetKeyboardState(NULL);
|
||||
for (int i = 0; i < s_watchedKeyCount; ++i) {
|
||||
int sc = s_watchedKeys[i];
|
||||
if (sc > 0 && sc < KEY_COUNT) s_keysCurrent[sc] = state[sc] != 0;
|
||||
}
|
||||
|
||||
Uint32 btns = SDL_GetMouseState(&s_mouseX, &s_mouseY);
|
||||
s_mouseLeftCurrent = (btns & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0;
|
||||
s_mouseLeftCurrent = (btns & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0;
|
||||
s_mouseRightCurrent = (btns & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
|
||||
|
||||
if (!SDL_GetRelativeMouseMode()) {
|
||||
|
|
@ -154,8 +285,35 @@ void C_4JInput::Tick() {
|
|||
}
|
||||
|
||||
if (!SDL_GetKeyboardFocus()) {
|
||||
SDL_Window *mf = SDL_GetMouseFocus();
|
||||
if (mf) { SDL_RaiseWindow(mf); SDL_SetWindowGrab(mf, SDL_TRUE); }
|
||||
SDL_Window* mf = SDL_GetMouseFocus();
|
||||
if (mf) {
|
||||
SDL_RaiseWindow(mf);
|
||||
SDL_SetWindowGrab(mf, SDL_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
// If there is a controller update the buttons and sticks
|
||||
if (controller) {
|
||||
for (int i = 0; i < s_watchedBtnsCount; ++i) {
|
||||
int cb = s_watchedBtns[i];
|
||||
if (cb >= 0 && cb < BTN_COUNT)
|
||||
s_btnsCurrent[cb] =
|
||||
SDL_GameControllerGetButton(controller, s_watchedBtns[i]);
|
||||
}
|
||||
for (int i = 0; i < s_watchedAxisCount; ++i) {
|
||||
int ca = s_watchedAxis[i];
|
||||
if (ca >= 0 && ca < AXS_COUNT) {
|
||||
int aVal =
|
||||
SDL_GameControllerGetAxis(controller, s_watchedAxis[i]);
|
||||
if (s_watchedAxis[i] == SDL_CONTROLLER_AXIS_TRIGGERLEFT ||
|
||||
s_watchedAxis[i] == SDL_CONTROLLER_AXIS_TRIGGERRIGHT)
|
||||
s_axisCurrent[ca] = aVal > deadZone;
|
||||
else {
|
||||
s_axisCurrent[ca] = (aVal > deadZone || aVal < -deadZone);
|
||||
axisVal[ca] = aVal / 32768.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -165,9 +323,9 @@ int C_4JInput::GetHotbarSlotPressed(int iPad) {
|
|||
constexpr size_t NUM_HOTBAR_SLOTS = 9;
|
||||
|
||||
static const int sc[NUM_HOTBAR_SLOTS] = {
|
||||
SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_3, SDL_SCANCODE_4,
|
||||
SDL_SCANCODE_5, SDL_SCANCODE_6, SDL_SCANCODE_7, SDL_SCANCODE_8,
|
||||
SDL_SCANCODE_9,
|
||||
SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_3,
|
||||
SDL_SCANCODE_4, SDL_SCANCODE_5, SDL_SCANCODE_6,
|
||||
SDL_SCANCODE_7, SDL_SCANCODE_8, SDL_SCANCODE_9,
|
||||
};
|
||||
static bool s_wasDown[NUM_HOTBAR_SLOTS] = {};
|
||||
|
||||
|
|
@ -180,31 +338,70 @@ int C_4JInput::GetHotbarSlotPressed(int iPad) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
#define ACTION_CASES(FN) \
|
||||
case ACTION_MENU_UP: return FN(SDL_SCANCODE_UP); \
|
||||
case ACTION_MENU_DOWN: return FN(SDL_SCANCODE_DOWN); \
|
||||
case ACTION_MENU_LEFT: return FN(SDL_SCANCODE_LEFT); \
|
||||
case ACTION_MENU_RIGHT: return FN(SDL_SCANCODE_RIGHT); \
|
||||
case ACTION_MENU_PAGEUP: return FN(SDL_SCANCODE_PAGEUP); \
|
||||
case ACTION_MENU_PAGEDOWN: return FN(SDL_SCANCODE_PAGEDOWN); \
|
||||
case ACTION_MENU_OK: return FN(SDL_SCANCODE_RETURN); \
|
||||
case ACTION_MENU_CANCEL: return FN(SDL_SCANCODE_ESCAPE); \
|
||||
case MINECRAFT_ACTION_JUMP: return FN(SDL_SCANCODE_SPACE); \
|
||||
case MINECRAFT_ACTION_FORWARD: return FN(SDL_SCANCODE_W); \
|
||||
case MINECRAFT_ACTION_BACKWARD: return FN(SDL_SCANCODE_S); \
|
||||
case MINECRAFT_ACTION_LEFT: return FN(SDL_SCANCODE_A); \
|
||||
case MINECRAFT_ACTION_RIGHT: return FN(SDL_SCANCODE_D); \
|
||||
case MINECRAFT_ACTION_INVENTORY: return FN(SDL_SCANCODE_E); \
|
||||
case MINECRAFT_ACTION_PAUSEMENU: return FN(SDL_SCANCODE_ESCAPE); \
|
||||
case MINECRAFT_ACTION_DROP: return FN(SDL_SCANCODE_Q); \
|
||||
case MINECRAFT_ACTION_CRAFTING: return FN(SDL_SCANCODE_C); \
|
||||
case MINECRAFT_ACTION_RENDER_THIRD_PERSON:return FN(SDL_SCANCODE_F5); \
|
||||
case MINECRAFT_ACTION_GAME_INFO: return FN(SDL_SCANCODE_F3); \
|
||||
case MINECRAFT_ACTION_DPAD_LEFT: return FN(SDL_SCANCODE_LEFT); \
|
||||
case MINECRAFT_ACTION_DPAD_RIGHT: return FN(SDL_SCANCODE_RIGHT); \
|
||||
case MINECRAFT_ACTION_DPAD_UP: return FN(SDL_SCANCODE_UP); \
|
||||
case MINECRAFT_ACTION_DPAD_DOWN: return FN(SDL_SCANCODE_DOWN); \
|
||||
default: return false;
|
||||
// KFN = Keyboard functions, CFN = Controller functions, AFN = Axis functions
|
||||
#define ACTION_CASES(KFN, CFN, AFN) \
|
||||
case ACTION_MENU_UP: \
|
||||
return KFN(SDL_SCANCODE_UP) || CFN(SDL_CONTROLLER_BUTTON_DPAD_UP); \
|
||||
case ACTION_MENU_DOWN: \
|
||||
return KFN(SDL_SCANCODE_DOWN) || CFN(SDL_CONTROLLER_BUTTON_DPAD_DOWN); \
|
||||
case ACTION_MENU_LEFT: \
|
||||
return KFN(SDL_SCANCODE_LEFT) || CFN(SDL_CONTROLLER_BUTTON_DPAD_LEFT); \
|
||||
case ACTION_MENU_RIGHT: \
|
||||
return KFN(SDL_SCANCODE_RIGHT) || \
|
||||
CFN(SDL_CONTROLLER_BUTTON_DPAD_RIGHT); \
|
||||
case ACTION_MENU_PAGEUP: \
|
||||
return KFN(SDL_SCANCODE_PAGEUP); \
|
||||
case ACTION_MENU_PAGEDOWN: \
|
||||
return KFN(SDL_SCANCODE_PAGEDOWN); \
|
||||
case ACTION_MENU_OK: \
|
||||
return KFN(SDL_SCANCODE_RETURN) || KFN(SDL_SCANCODE_Z) || \
|
||||
CFN(SDL_CONTROLLER_BUTTON_A); \
|
||||
case ACTION_MENU_CANCEL: \
|
||||
return KFN(SDL_SCANCODE_ESCAPE) || KFN(SDL_SCANCODE_X) || \
|
||||
CFN(SDL_CONTROLLER_BUTTON_B); \
|
||||
case ACTION_MENU_A: \
|
||||
return KFN(SDL_SCANCODE_Z) || KFN(SDL_SCANCODE_RETURN) || \
|
||||
CFN(SDL_CONTROLLER_BUTTON_A); \
|
||||
case ACTION_MENU_B: \
|
||||
return KFN(SDL_SCANCODE_X) || KFN(SDL_SCANCODE_ESCAPE) || \
|
||||
CFN(SDL_CONTROLLER_BUTTON_B); \
|
||||
case ACTION_MENU_X: \
|
||||
return KFN(SDL_SCANCODE_C) || CFN(SDL_CONTROLLER_BUTTON_X); \
|
||||
case ACTION_MENU_Y: \
|
||||
return KFN(SDL_SCANCODE_V) || CFN(SDL_CONTROLLER_BUTTON_Y); \
|
||||
case MINECRAFT_ACTION_JUMP: \
|
||||
return KFN(SDL_SCANCODE_SPACE) || CFN(SDL_CONTROLLER_BUTTON_A); \
|
||||
case MINECRAFT_ACTION_FORWARD: \
|
||||
return KFN(SDL_SCANCODE_W) || AFN(SDL_CONTROLLER_AXIS_LEFTY); \
|
||||
case MINECRAFT_ACTION_BACKWARD: \
|
||||
return KFN(SDL_SCANCODE_S) || AFN(SDL_CONTROLLER_AXIS_LEFTY); \
|
||||
case MINECRAFT_ACTION_LEFT: \
|
||||
return KFN(SDL_SCANCODE_A) || AFN(SDL_CONTROLLER_AXIS_LEFTX); \
|
||||
case MINECRAFT_ACTION_RIGHT: \
|
||||
return KFN(SDL_SCANCODE_D) || AFN(SDL_CONTROLLER_AXIS_LEFTX); \
|
||||
case MINECRAFT_ACTION_INVENTORY: \
|
||||
return KFN(SDL_SCANCODE_E) || CFN(SDL_CONTROLLER_BUTTON_Y); \
|
||||
case MINECRAFT_ACTION_PAUSEMENU: \
|
||||
return KFN(SDL_SCANCODE_ESCAPE) || CFN(SDL_CONTROLLER_BUTTON_START); \
|
||||
case MINECRAFT_ACTION_DROP: \
|
||||
return KFN(SDL_SCANCODE_Q) || CFN(SDL_CONTROLLER_BUTTON_B); \
|
||||
case MINECRAFT_ACTION_CRAFTING: \
|
||||
return KFN(SDL_SCANCODE_C) || CFN(SDL_CONTROLLER_BUTTON_X); \
|
||||
case MINECRAFT_ACTION_RENDER_THIRD_PERSON: \
|
||||
return KFN(SDL_SCANCODE_F5) || CFN(SDL_CONTROLLER_BUTTON_LEFTSTICK); \
|
||||
case MINECRAFT_ACTION_GAME_INFO: \
|
||||
return KFN(SDL_SCANCODE_F3); \
|
||||
case MINECRAFT_ACTION_DPAD_LEFT: \
|
||||
return KFN(SDL_SCANCODE_LEFT) || CFN(SDL_CONTROLLER_BUTTON_DPAD_LEFT); \
|
||||
case MINECRAFT_ACTION_DPAD_RIGHT: \
|
||||
return KFN(SDL_SCANCODE_RIGHT) || \
|
||||
CFN(SDL_CONTROLLER_BUTTON_DPAD_RIGHT); \
|
||||
case MINECRAFT_ACTION_DPAD_UP: \
|
||||
return KFN(SDL_SCANCODE_UP) || CFN(SDL_CONTROLLER_BUTTON_DPAD_UP); \
|
||||
case MINECRAFT_ACTION_DPAD_DOWN: \
|
||||
return KFN(SDL_SCANCODE_DOWN) || CFN(SDL_CONTROLLER_BUTTON_DPAD_DOWN); \
|
||||
default: \
|
||||
return false;
|
||||
|
||||
bool C_4JInput::ButtonDown(int iPad, unsigned char ucAction) {
|
||||
if (iPad != 0) return false;
|
||||
|
|
@ -214,45 +411,73 @@ bool C_4JInput::ButtonDown(int iPad, unsigned char ucAction) {
|
|||
return s_mouseLeftCurrent || s_mouseRightCurrent;
|
||||
}
|
||||
switch (ucAction) {
|
||||
case MINECRAFT_ACTION_ACTION: return MouseLDown() || KDown(SDL_SCANCODE_RETURN);
|
||||
case MINECRAFT_ACTION_USE: return MouseRDown() || KDown(SDL_SCANCODE_F);
|
||||
case MINECRAFT_ACTION_SNEAK_TOGGLE: return KDown(SDL_SCANCODE_LSHIFT) || KDown(SDL_SCANCODE_RSHIFT);
|
||||
case MINECRAFT_ACTION_SPRINT: return KDown(SDL_SCANCODE_LCTRL) || KDown(SDL_SCANCODE_RCTRL);
|
||||
case MINECRAFT_ACTION_ACTION:
|
||||
return MouseLDown() || KDown(SDL_SCANCODE_RETURN) ||
|
||||
ADown(SDL_CONTROLLER_AXIS_TRIGGERRIGHT);
|
||||
case MINECRAFT_ACTION_USE:
|
||||
return MouseRDown() || KDown(SDL_SCANCODE_F) ||
|
||||
ADown(SDL_CONTROLLER_AXIS_TRIGGERLEFT);
|
||||
case MINECRAFT_ACTION_SNEAK_TOGGLE:
|
||||
return KDown(SDL_SCANCODE_LSHIFT) || KDown(SDL_SCANCODE_RSHIFT) ||
|
||||
CDown(SDL_CONTROLLER_BUTTON_RIGHTSTICK);
|
||||
case MINECRAFT_ACTION_SPRINT:
|
||||
return KDown(SDL_SCANCODE_LCTRL) || KDown(SDL_SCANCODE_RCTRL);
|
||||
case MINECRAFT_ACTION_LEFT_SCROLL:
|
||||
case ACTION_MENU_LEFT_SCROLL: return ScrollSnap() > 0;
|
||||
case ACTION_MENU_LEFT_SCROLL:
|
||||
return ScrollSnap() > 0;
|
||||
case MINECRAFT_ACTION_RIGHT_SCROLL:
|
||||
case ACTION_MENU_RIGHT_SCROLL: return ScrollSnap() < 0;
|
||||
ACTION_CASES(KDown)
|
||||
case ACTION_MENU_RIGHT_SCROLL:
|
||||
return ScrollSnap() < 0;
|
||||
ACTION_CASES(KDown, CDown, ADown)
|
||||
}
|
||||
}
|
||||
// The part that handles completing the action of pressing a button.
|
||||
bool C_4JInput::ButtonPressed(int iPad, unsigned char ucAction) {
|
||||
if (iPad != 0 || ucAction == 255) return false;
|
||||
switch (ucAction) {
|
||||
case MINECRAFT_ACTION_ACTION: return MouseLPressed() || KPressed(SDL_SCANCODE_RETURN);
|
||||
case MINECRAFT_ACTION_USE: return MouseRPressed() || KPressed(SDL_SCANCODE_F);
|
||||
case MINECRAFT_ACTION_SNEAK_TOGGLE: return KPressed(SDL_SCANCODE_LSHIFT) || KPressed(SDL_SCANCODE_RSHIFT);
|
||||
case MINECRAFT_ACTION_SPRINT: return KPressed(SDL_SCANCODE_LCTRL) || KPressed(SDL_SCANCODE_RCTRL);
|
||||
case MINECRAFT_ACTION_ACTION:
|
||||
return MouseLPressed() || KPressed(SDL_SCANCODE_RETURN) ||
|
||||
APressed(SDL_CONTROLLER_AXIS_TRIGGERRIGHT);
|
||||
case MINECRAFT_ACTION_USE:
|
||||
return MouseRPressed() || KPressed(SDL_SCANCODE_F) ||
|
||||
APressed(SDL_CONTROLLER_AXIS_TRIGGERLEFT);
|
||||
case MINECRAFT_ACTION_SNEAK_TOGGLE:
|
||||
return KPressed(SDL_SCANCODE_LSHIFT) ||
|
||||
KPressed(SDL_SCANCODE_RSHIFT) ||
|
||||
CPressed(SDL_CONTROLLER_BUTTON_RIGHTSTICK);
|
||||
case MINECRAFT_ACTION_SPRINT:
|
||||
return KPressed(SDL_SCANCODE_LCTRL) || KPressed(SDL_SCANCODE_RCTRL);
|
||||
case MINECRAFT_ACTION_LEFT_SCROLL:
|
||||
case ACTION_MENU_LEFT_SCROLL: return ScrollSnap() > 0;
|
||||
case ACTION_MENU_LEFT_SCROLL:
|
||||
return ScrollSnap() > 0;
|
||||
case MINECRAFT_ACTION_RIGHT_SCROLL:
|
||||
case ACTION_MENU_RIGHT_SCROLL: return ScrollSnap() < 0;
|
||||
ACTION_CASES(KPressed)
|
||||
case ACTION_MENU_RIGHT_SCROLL:
|
||||
return ScrollSnap() < 0;
|
||||
ACTION_CASES(KPressed, CPressed, APressed)
|
||||
}
|
||||
}
|
||||
// The part that handles Releasing a button.
|
||||
bool C_4JInput::ButtonReleased(int iPad, unsigned char ucAction) {
|
||||
if (iPad != 0 || ucAction == 255) return false;
|
||||
switch (ucAction) {
|
||||
case MINECRAFT_ACTION_ACTION: return MouseLReleased() || KReleased(SDL_SCANCODE_RETURN);
|
||||
case MINECRAFT_ACTION_USE: return MouseRReleased() || KReleased(SDL_SCANCODE_F);
|
||||
case MINECRAFT_ACTION_SNEAK_TOGGLE: return KReleased(SDL_SCANCODE_LSHIFT) || KReleased(SDL_SCANCODE_RSHIFT);
|
||||
case MINECRAFT_ACTION_SPRINT: KReleased(SDL_SCANCODE_LCTRL) || KReleased(SDL_SCANCODE_RCTRL);
|
||||
case MINECRAFT_ACTION_ACTION:
|
||||
return MouseLReleased() || KReleased(SDL_SCANCODE_RETURN) ||
|
||||
AReleased(SDL_CONTROLLER_AXIS_TRIGGERRIGHT);
|
||||
case MINECRAFT_ACTION_USE:
|
||||
return MouseRReleased() || KReleased(SDL_SCANCODE_F) ||
|
||||
AReleased(SDL_CONTROLLER_AXIS_TRIGGERLEFT);
|
||||
case MINECRAFT_ACTION_SNEAK_TOGGLE:
|
||||
return KReleased(SDL_SCANCODE_LSHIFT) ||
|
||||
KReleased(SDL_SCANCODE_RSHIFT) ||
|
||||
CReleased(SDL_CONTROLLER_BUTTON_RIGHTSTICK);
|
||||
case MINECRAFT_ACTION_SPRINT:
|
||||
KReleased(SDL_SCANCODE_LCTRL) || KReleased(SDL_SCANCODE_RCTRL);
|
||||
case MINECRAFT_ACTION_LEFT_SCROLL:
|
||||
case ACTION_MENU_LEFT_SCROLL:
|
||||
case MINECRAFT_ACTION_RIGHT_SCROLL:
|
||||
case ACTION_MENU_RIGHT_SCROLL: return false;
|
||||
ACTION_CASES(KReleased)
|
||||
case ACTION_MENU_RIGHT_SCROLL:
|
||||
return false;
|
||||
ACTION_CASES(KReleased, CReleased, AReleased)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -276,44 +501,61 @@ unsigned int C_4JInput::GetValue(int iPad, unsigned char ucAction, bool) {
|
|||
}
|
||||
return ButtonDown(iPad, ucAction) ? 1u : 0u;
|
||||
}
|
||||
// Left stick movement, the one that moves the player around or selects menu options. (Soon be tested.)
|
||||
// Left stick movement, the one that moves the player around or selects menu
|
||||
// options. (Soon be tested.)
|
||||
float C_4JInput::GetJoypadStick_LX(int, bool) {
|
||||
return (KDown(SDL_SCANCODE_D) ? 1.f : 0.f) - (KDown(SDL_SCANCODE_A) ? 1.f : 0.f);
|
||||
if (ADown(SDL_CONTROLLER_AXIS_LEFTX))
|
||||
return axisVal[SDL_CONTROLLER_AXIS_LEFTX];
|
||||
return (KDown(SDL_SCANCODE_D) ? 1.f : 0.f) -
|
||||
(KDown(SDL_SCANCODE_A) ? 1.f : 0.f);
|
||||
}
|
||||
float C_4JInput::GetJoypadStick_LY(int, bool) {
|
||||
return (KDown(SDL_SCANCODE_W) ? 1.f : 0.f) - (KDown(SDL_SCANCODE_S) ? 1.f : 0.f);
|
||||
if (ADown(SDL_CONTROLLER_AXIS_LEFTY))
|
||||
return -axisVal[SDL_CONTROLLER_AXIS_LEFTY];
|
||||
return (KDown(SDL_SCANCODE_W) ? 1.f : 0.f) -
|
||||
(KDown(SDL_SCANCODE_S) ? 1.f : 0.f);
|
||||
}
|
||||
// We use mouse movement and convert it into a Right Stick output using logarithmic scaling
|
||||
// This is the most important mouse part. Yet it's so small.
|
||||
// We use mouse movement and convert it into a Right Stick output using
|
||||
// logarithmic scaling This is the most important mouse part. Yet it's so small.
|
||||
static float MouseAxis(float raw) {
|
||||
if (fabsf(raw) < 0.0001f) return 0.f; // from 4j previous code
|
||||
if (fabsf(raw) < 0.0001f) return 0.f; // from 4j previous code
|
||||
return (raw >= 0.f ? 1.f : -1.f) * sqrtf(fabsf(raw));
|
||||
}
|
||||
// We apply the Stick movement on the R(Right) X(2D Position)
|
||||
float C_4JInput::GetJoypadStick_RX(int, bool) {
|
||||
if (ADown(SDL_CONTROLLER_AXIS_RIGHTX))
|
||||
return axisVal[SDL_CONTROLLER_AXIS_RIGHTX];
|
||||
if (!SDL_GetRelativeMouseMode()) return 0.f;
|
||||
TakeSnapIfNeeded();
|
||||
return MouseAxis(s_snapRelX * MOUSE_SCALE);
|
||||
}
|
||||
// Bis. but with Y(2D Position)
|
||||
float C_4JInput::GetJoypadStick_RY(int, bool) {
|
||||
if (ADown(SDL_CONTROLLER_AXIS_RIGHTY))
|
||||
return -axisVal[SDL_CONTROLLER_AXIS_RIGHTY];
|
||||
if (!SDL_GetRelativeMouseMode()) return 0.f;
|
||||
TakeSnapIfNeeded();
|
||||
return MouseAxis(-s_snapRelY * MOUSE_SCALE);
|
||||
}
|
||||
|
||||
unsigned char C_4JInput::GetJoypadLTrigger(int, bool) { return s_mouseRightCurrent ? 255 : 0; }
|
||||
unsigned char C_4JInput::GetJoypadRTrigger(int, bool) { return s_mouseLeftCurrent ? 255 : 0; }
|
||||
|
||||
int C_4JInput::GetMouseX() {
|
||||
return s_mouseX;
|
||||
unsigned char C_4JInput::GetJoypadLTrigger(int, bool) {
|
||||
return (s_mouseRightCurrent ||
|
||||
s_axisCurrent[SDL_CONTROLLER_AXIS_TRIGGERLEFT])
|
||||
? 255
|
||||
: 0;
|
||||
}
|
||||
int C_4JInput::GetMouseY() {
|
||||
return s_mouseY;
|
||||
unsigned char C_4JInput::GetJoypadRTrigger(int, bool) {
|
||||
return (s_mouseLeftCurrent ||
|
||||
s_axisCurrent[SDL_CONTROLLER_AXIS_TRIGGERRIGHT])
|
||||
? 255
|
||||
: 0;
|
||||
}
|
||||
|
||||
int C_4JInput::GetMouseX() { return s_mouseX; }
|
||||
int C_4JInput::GetMouseY() { return s_mouseY; }
|
||||
|
||||
// We detect if a Menu is visible on the player's screen to the mouse being stuck.
|
||||
// We detect if a Menu is visible on the player's screen to the mouse being
|
||||
// stuck.
|
||||
void C_4JInput::SetMenuDisplayed(int iPad, bool bVal) {
|
||||
if (iPad >= 0 && iPad < 4) s_menuDisplayed[iPad] = bVal;
|
||||
if (!s_sdlInitialized || bVal == s_prevMenuDisplayed) return;
|
||||
|
|
@ -321,31 +563,43 @@ void C_4JInput::SetMenuDisplayed(int iPad, bool bVal) {
|
|||
s_prevMenuDisplayed = bVal;
|
||||
}
|
||||
|
||||
int C_4JInput::GetScrollDelta() {
|
||||
int C_4JInput::GetScrollDelta() {
|
||||
int v = s_scrollTicksForButtonPressed;
|
||||
s_scrollTicksForButtonPressed = 0;
|
||||
return v;
|
||||
}
|
||||
|
||||
void C_4JInput::SetDeadzoneAndMovementRange(unsigned int, unsigned int){}
|
||||
void C_4JInput::SetGameJoypadMaps(unsigned char, unsigned char, unsigned int){}
|
||||
unsigned int C_4JInput::GetGameJoypadMaps(unsigned char, unsigned char){ return 0; }
|
||||
void C_4JInput::SetJoypadMapVal(int, unsigned char){}
|
||||
unsigned char C_4JInput::GetJoypadMapVal(int){ return 0; }
|
||||
void C_4JInput::SetJoypadSensitivity(int, float){}
|
||||
void C_4JInput::SetJoypadStickAxisMap(int, unsigned int, unsigned int){}
|
||||
void C_4JInput::SetJoypadStickTriggerMap(int, unsigned int, unsigned int){}
|
||||
void C_4JInput::SetKeyRepeatRate(float, float){}
|
||||
void C_4JInput::SetDebugSequence(const char*, int(*)(void *), void *){}
|
||||
FLOAT C_4JInput::GetIdleSeconds(int){ return 0.f; }
|
||||
bool C_4JInput::IsPadConnected(int iPad){ return iPad == 0; }
|
||||
void C_4JInput::SetDeadzoneAndMovementRange(unsigned int, unsigned int) {}
|
||||
void C_4JInput::SetGameJoypadMaps(unsigned char, unsigned char, unsigned int) {}
|
||||
unsigned int C_4JInput::GetGameJoypadMaps(unsigned char, unsigned char) {
|
||||
return 0;
|
||||
}
|
||||
void C_4JInput::SetJoypadMapVal(int, unsigned char) {}
|
||||
unsigned char C_4JInput::GetJoypadMapVal(int) { return 0; }
|
||||
void C_4JInput::SetJoypadSensitivity(int, float) {}
|
||||
void C_4JInput::SetJoypadStickAxisMap(int, unsigned int, unsigned int) {}
|
||||
void C_4JInput::SetJoypadStickTriggerMap(int, unsigned int, unsigned int) {}
|
||||
void C_4JInput::SetKeyRepeatRate(float, float) {}
|
||||
void C_4JInput::SetDebugSequence(const char*, int (*)(void*), void*) {}
|
||||
float C_4JInput::GetIdleSeconds(int) { return 0.f; }
|
||||
bool C_4JInput::IsPadConnected(int iPad) { return iPad == 0; }
|
||||
|
||||
// Silly check, we check if we have a keyboard.
|
||||
EKeyboardResult C_4JInput::RequestKeyboard(const wchar_t *, const wchar_t *, int, unsigned int,
|
||||
int(*)(void *, const bool), void *, C_4JInput::EKeyboardMode)
|
||||
{ return EKeyboard_Cancelled; }
|
||||
EKeyboardResult C_4JInput::RequestKeyboard(const wchar_t*, const wchar_t*, int,
|
||||
unsigned int,
|
||||
int (*)(void*, const bool), void*,
|
||||
C_4JInput::EKeyboardMode) {
|
||||
return EKeyboard_Cancelled;
|
||||
}
|
||||
|
||||
void C_4JInput::GetText(uint16_t *s){ if (s) s[0] = 0; }
|
||||
bool C_4JInput::VerifyStrings(wchar_t **, int, int(*)(void *, STRING_VERIFY_RESPONSE *), void *){ return true; }
|
||||
void C_4JInput::CancelQueuedVerifyStrings(int(*)(void *, STRING_VERIFY_RESPONSE *), void *){}
|
||||
void C_4JInput::CancelAllVerifyInProgress(){}
|
||||
void C_4JInput::GetText(uint16_t* s) {
|
||||
if (s) s[0] = 0;
|
||||
}
|
||||
bool C_4JInput::VerifyStrings(wchar_t**, int,
|
||||
int (*)(void*, STRING_VERIFY_RESPONSE*), void*) {
|
||||
return true;
|
||||
}
|
||||
void C_4JInput::CancelQueuedVerifyStrings(int (*)(void*,
|
||||
STRING_VERIFY_RESPONSE*),
|
||||
void*) {}
|
||||
void C_4JInput::CancelAllVerifyInProgress() {}
|
||||
|
|
|
|||
|
|
@ -1,141 +1,166 @@
|
|||
#pragma once
|
||||
|
||||
#define MAP_STYLE_0 0
|
||||
#define MAP_STYLE_1 1
|
||||
#define MAP_STYLE_2 2
|
||||
#define MAP_STYLE_0 0
|
||||
#define MAP_STYLE_1 1
|
||||
#define MAP_STYLE_2 2
|
||||
|
||||
#define _360_JOY_BUTTON_A 0x00000001
|
||||
#define _360_JOY_BUTTON_B 0x00000002
|
||||
#define _360_JOY_BUTTON_X 0x00000004
|
||||
#define _360_JOY_BUTTON_Y 0x00000008
|
||||
#define _360_JOY_BUTTON_A 0x00000001
|
||||
#define _360_JOY_BUTTON_B 0x00000002
|
||||
#define _360_JOY_BUTTON_X 0x00000004
|
||||
#define _360_JOY_BUTTON_Y 0x00000008
|
||||
|
||||
#define _360_JOY_BUTTON_START 0x00000010
|
||||
#define _360_JOY_BUTTON_BACK 0x00000020
|
||||
#define _360_JOY_BUTTON_RB 0x00000040
|
||||
#define _360_JOY_BUTTON_LB 0x00000080
|
||||
#define _360_JOY_BUTTON_START 0x00000010
|
||||
#define _360_JOY_BUTTON_BACK 0x00000020
|
||||
#define _360_JOY_BUTTON_RB 0x00000040
|
||||
#define _360_JOY_BUTTON_LB 0x00000080
|
||||
|
||||
#define _360_JOY_BUTTON_RTHUMB 0x00000100
|
||||
#define _360_JOY_BUTTON_LTHUMB 0x00000200
|
||||
#define _360_JOY_BUTTON_DPAD_UP 0x00000400
|
||||
#define _360_JOY_BUTTON_DPAD_DOWN 0x00000800
|
||||
#define _360_JOY_BUTTON_RTHUMB 0x00000100
|
||||
#define _360_JOY_BUTTON_LTHUMB 0x00000200
|
||||
#define _360_JOY_BUTTON_DPAD_UP 0x00000400
|
||||
#define _360_JOY_BUTTON_DPAD_DOWN 0x00000800
|
||||
|
||||
#define _360_JOY_BUTTON_DPAD_LEFT 0x00001000
|
||||
#define _360_JOY_BUTTON_DPAD_RIGHT 0x00002000
|
||||
// fake digital versions of analog values
|
||||
#define _360_JOY_BUTTON_LSTICK_RIGHT 0x00004000
|
||||
#define _360_JOY_BUTTON_LSTICK_LEFT 0x00008000
|
||||
#define _360_JOY_BUTTON_DPAD_LEFT 0x00001000
|
||||
#define _360_JOY_BUTTON_DPAD_RIGHT 0x00002000
|
||||
// fake digital versions of analog values
|
||||
#define _360_JOY_BUTTON_LSTICK_RIGHT 0x00004000
|
||||
#define _360_JOY_BUTTON_LSTICK_LEFT 0x00008000
|
||||
|
||||
#define _360_JOY_BUTTON_RSTICK_DOWN 0x00010000
|
||||
#define _360_JOY_BUTTON_RSTICK_UP 0x00020000
|
||||
#define _360_JOY_BUTTON_RSTICK_RIGHT 0x00040000
|
||||
#define _360_JOY_BUTTON_RSTICK_LEFT 0x00080000
|
||||
#define _360_JOY_BUTTON_RSTICK_DOWN 0x00010000
|
||||
#define _360_JOY_BUTTON_RSTICK_UP 0x00020000
|
||||
#define _360_JOY_BUTTON_RSTICK_RIGHT 0x00040000
|
||||
#define _360_JOY_BUTTON_RSTICK_LEFT 0x00080000
|
||||
|
||||
#define _360_JOY_BUTTON_LSTICK_DOWN 0x00100000
|
||||
#define _360_JOY_BUTTON_LSTICK_UP 0x00200000
|
||||
#define _360_JOY_BUTTON_RT 0x00400000
|
||||
#define _360_JOY_BUTTON_LT 0x00800000
|
||||
#define _360_JOY_BUTTON_LSTICK_DOWN 0x00100000
|
||||
#define _360_JOY_BUTTON_LSTICK_UP 0x00200000
|
||||
#define _360_JOY_BUTTON_RT 0x00400000
|
||||
#define _360_JOY_BUTTON_LT 0x00800000
|
||||
|
||||
// Stick axis maps - to allow changes for SouthPaw in-game axis mapping
|
||||
#define AXIS_MAP_LX 0
|
||||
#define AXIS_MAP_LY 1
|
||||
#define AXIS_MAP_RX 2
|
||||
#define AXIS_MAP_RY 3
|
||||
#define AXIS_MAP_LX 0
|
||||
#define AXIS_MAP_LY 1
|
||||
#define AXIS_MAP_RX 2
|
||||
#define AXIS_MAP_RY 3
|
||||
|
||||
// Trigger map - to allow for swap triggers in-game
|
||||
#define TRIGGER_MAP_0 0
|
||||
#define TRIGGER_MAP_1 1
|
||||
#define TRIGGER_MAP_0 0
|
||||
#define TRIGGER_MAP_1 1
|
||||
|
||||
enum EKeyboardResult
|
||||
{
|
||||
EKeyboard_Pending,
|
||||
EKeyboard_Cancelled,
|
||||
EKeyboard_ResultAccept,
|
||||
EKeyboard_ResultDecline,
|
||||
enum EKeyboardResult {
|
||||
EKeyboard_Pending,
|
||||
EKeyboard_Cancelled,
|
||||
EKeyboard_ResultAccept,
|
||||
EKeyboard_ResultDecline,
|
||||
};
|
||||
|
||||
typedef struct _STRING_VERIFY_RESPONSE
|
||||
{
|
||||
WORD wNumStrings;
|
||||
HRESULT *pStringResult;
|
||||
}
|
||||
STRING_VERIFY_RESPONSE;
|
||||
typedef struct _STRING_VERIFY_RESPONSE {
|
||||
std::uint16_t wNumStrings;
|
||||
HRESULT* pStringResult;
|
||||
} STRING_VERIFY_RESPONSE;
|
||||
|
||||
class C_4JInput
|
||||
{
|
||||
class C_4JInput {
|
||||
public:
|
||||
enum EKeyboardMode {
|
||||
EKeyboardMode_Default,
|
||||
EKeyboardMode_Numeric,
|
||||
EKeyboardMode_Password,
|
||||
EKeyboardMode_Alphabet,
|
||||
EKeyboardMode_Full,
|
||||
EKeyboardMode_Alphabet_Extended,
|
||||
EKeyboardMode_IP_Address,
|
||||
EKeyboardMode_Phone
|
||||
};
|
||||
|
||||
void Initialise(int iInputStateC, unsigned char ucMapC,
|
||||
unsigned char ucActionC, unsigned char ucMenuActionC);
|
||||
void Tick(void);
|
||||
void SetDeadzoneAndMovementRange(unsigned int uiDeadzone,
|
||||
unsigned int uiMovementRangeMax);
|
||||
void SetGameJoypadMaps(unsigned char ucMap, unsigned char ucAction,
|
||||
unsigned int uiActionVal);
|
||||
unsigned int GetGameJoypadMaps(unsigned char ucMap, unsigned char ucAction);
|
||||
void SetJoypadMapVal(int iPad, unsigned char ucMap);
|
||||
unsigned char GetJoypadMapVal(int iPad);
|
||||
void SetJoypadSensitivity(int iPad, float fSensitivity);
|
||||
unsigned int GetValue(int iPad, unsigned char ucAction,
|
||||
bool bRepeat = false);
|
||||
bool ButtonPressed(int iPad, unsigned char ucAction = 255); // toggled
|
||||
bool ButtonReleased(int iPad, unsigned char ucAction); // toggled
|
||||
bool ButtonDown(int iPad,
|
||||
unsigned char ucAction = 255); // button held down
|
||||
// Functions to remap the axis and triggers for in-game (not menus) -
|
||||
// SouthPaw, etc
|
||||
void SetJoypadStickAxisMap(int iPad, unsigned int uiFrom,
|
||||
unsigned int uiTo);
|
||||
void SetJoypadStickTriggerMap(int iPad, unsigned int uiFrom,
|
||||
unsigned int uiTo);
|
||||
void SetKeyRepeatRate(float fRepeatDelaySecs, float fRepeatRateSecs);
|
||||
void SetDebugSequence(const char* chSequenceA, int (*Func)(void*),
|
||||
void* lpParam);
|
||||
float GetIdleSeconds(int iPad);
|
||||
bool IsPadConnected(int iPad);
|
||||
|
||||
enum EKeyboardMode
|
||||
{
|
||||
EKeyboardMode_Default,
|
||||
EKeyboardMode_Numeric,
|
||||
EKeyboardMode_Password,
|
||||
EKeyboardMode_Alphabet,
|
||||
EKeyboardMode_Full,
|
||||
EKeyboardMode_Alphabet_Extended,
|
||||
EKeyboardMode_IP_Address,
|
||||
EKeyboardMode_Phone
|
||||
};
|
||||
// In-Game values which may have been remapped due to Southpaw, swap
|
||||
// triggers, etc
|
||||
float GetJoypadStick_LX(int iPad, bool bCheckMenuDisplay = true);
|
||||
float GetJoypadStick_LY(int iPad, bool bCheckMenuDisplay = true);
|
||||
float GetJoypadStick_RX(int iPad, bool bCheckMenuDisplay = true);
|
||||
float GetJoypadStick_RY(int iPad, bool bCheckMenuDisplay = true);
|
||||
unsigned char GetJoypadLTrigger(int iPad, bool bCheckMenuDisplay = true);
|
||||
unsigned char GetJoypadRTrigger(int iPad, bool bCheckMenuDisplay = true);
|
||||
|
||||
void Initialise( int iInputStateC, unsigned char ucMapC,unsigned char ucActionC, unsigned char ucMenuActionC );
|
||||
void Tick(void);
|
||||
void SetDeadzoneAndMovementRange(unsigned int uiDeadzone, unsigned int uiMovementRangeMax );
|
||||
void SetGameJoypadMaps(unsigned char ucMap,unsigned char ucAction,unsigned int uiActionVal);
|
||||
unsigned int GetGameJoypadMaps(unsigned char ucMap,unsigned char ucAction);
|
||||
void SetJoypadMapVal(int iPad,unsigned char ucMap);
|
||||
unsigned char GetJoypadMapVal(int iPad);
|
||||
void SetJoypadSensitivity(int iPad, float fSensitivity);
|
||||
unsigned int GetValue(int iPad,unsigned char ucAction, bool bRepeat=false);
|
||||
bool ButtonPressed(int iPad,unsigned char ucAction=255); // toggled
|
||||
bool ButtonReleased(int iPad,unsigned char ucAction); //toggled
|
||||
bool ButtonDown(int iPad,unsigned char ucAction=255); // button held down
|
||||
// Functions to remap the axis and triggers for in-game (not menus) - SouthPaw, etc
|
||||
void SetJoypadStickAxisMap(int iPad,unsigned int uiFrom, unsigned int uiTo);
|
||||
void SetJoypadStickTriggerMap(int iPad,unsigned int uiFrom, unsigned int uiTo);
|
||||
void SetKeyRepeatRate(float fRepeatDelaySecs,float fRepeatRateSecs);
|
||||
void SetDebugSequence( const char *chSequenceA,int( *Func)(void *),void *lpParam );
|
||||
FLOAT GetIdleSeconds(int iPad);
|
||||
bool IsPadConnected(int iPad);
|
||||
void SetMenuDisplayed(int iPad, bool bVal);
|
||||
int GetHotbarSlotPressed(int iPad);
|
||||
int GetScrollDelta();
|
||||
|
||||
// In-Game values which may have been remapped due to Southpaw, swap triggers, etc
|
||||
float GetJoypadStick_LX(int iPad, bool bCheckMenuDisplay=true);
|
||||
float GetJoypadStick_LY(int iPad, bool bCheckMenuDisplay=true);
|
||||
float GetJoypadStick_RX(int iPad, bool bCheckMenuDisplay=true);
|
||||
float GetJoypadStick_RY(int iPad, bool bCheckMenuDisplay=true);
|
||||
unsigned char GetJoypadLTrigger(int iPad, bool bCheckMenuDisplay=true);
|
||||
unsigned char GetJoypadRTrigger(int iPad, bool bCheckMenuDisplay=true);
|
||||
// EKeyboardResult RequestKeyboard(UINT uiTitle, UINT uiText, UINT
|
||||
// uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int(
|
||||
// *Func)(LPVOID,const bool),LPVOID lpParam,EKeyboardMode
|
||||
// eMode,C4JStringTable *pStringTable=NULL); EKeyboardResult
|
||||
// RequestKeyboard(UINT uiTitle, LPCWSTR pwchDefault, UINT uiDesc, DWORD
|
||||
// dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const
|
||||
// bool),LPVOID lpParam, EKeyboardMode eMode,C4JStringTable
|
||||
// *pStringTable=NULL);
|
||||
EKeyboardResult RequestKeyboard(const wchar_t* Title, const wchar_t* Text,
|
||||
int iPad, unsigned int uiMaxChars,
|
||||
int (*Func)(void*, const bool),
|
||||
void* lpParam,
|
||||
C_4JInput::EKeyboardMode eMode);
|
||||
void GetText(uint16_t* UTF16String);
|
||||
|
||||
void SetMenuDisplayed(int iPad, bool bVal);
|
||||
int GetHotbarSlotPressed(int iPad);
|
||||
int GetScrollDelta();
|
||||
// Online check strings against offensive list - TCR 92
|
||||
// TCR # 092 CMTV Player Text String Verification
|
||||
// Requirement Any player-entered text visible to another player on
|
||||
// Xbox LIVE must be verified using the Xbox LIVE service before being
|
||||
// transmitted. Text that is rejected by the Xbox LIVE service must not be
|
||||
// displayed.
|
||||
//
|
||||
// Remarks
|
||||
// This requirement applies to any player-entered string that can
|
||||
// be exposed to other players on Xbox LIVE. It includes session names,
|
||||
// content descriptions, text messages, tags, team names, mottos, comments,
|
||||
// and so on.
|
||||
//
|
||||
// Games may decide to not send the text, blank it out, or use
|
||||
// generic text if the text was rejected by the Xbox LIVE service.
|
||||
//
|
||||
// Games verify the text by calling the XStringVerify function.
|
||||
//
|
||||
// Exemption It is not required to use the Xbox LIVE service to
|
||||
// verify real-time text communication. An example of real-time text
|
||||
// communication is in-game text chat.
|
||||
//
|
||||
// Intent Protect players from inappropriate language.
|
||||
bool VerifyStrings(wchar_t** pwStringA, int iStringC,
|
||||
int (*Func)(void*, STRING_VERIFY_RESPONSE*),
|
||||
void* lpParam);
|
||||
void CancelQueuedVerifyStrings(int (*Func)(void*, STRING_VERIFY_RESPONSE*),
|
||||
void* lpParam);
|
||||
void CancelAllVerifyInProgress(void);
|
||||
|
||||
// EKeyboardResult RequestKeyboard(UINT uiTitle, UINT uiText, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam,EKeyboardMode eMode,C4JStringTable *pStringTable=NULL);
|
||||
// EKeyboardResult RequestKeyboard(UINT uiTitle, LPCWSTR pwchDefault, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam, EKeyboardMode eMode,C4JStringTable *pStringTable=NULL);
|
||||
EKeyboardResult RequestKeyboard(const wchar_t *Title, const wchar_t *Text, int iPad, unsigned int uiMaxChars, int( *Func)(void *,const bool), void *lpParam, C_4JInput::EKeyboardMode eMode);
|
||||
void GetText(uint16_t *UTF16String);
|
||||
int GetMouseX();
|
||||
int GetMouseY();
|
||||
|
||||
// Online check strings against offensive list - TCR 92
|
||||
// TCR # 092 CMTV Player Text String Verification
|
||||
// Requirement Any player-entered text visible to another player on Xbox LIVE must be verified using the Xbox LIVE service before being transmitted. Text that is rejected by the Xbox LIVE service must not be displayed.
|
||||
//
|
||||
// Remarks
|
||||
// This requirement applies to any player-entered string that can be exposed to other players on Xbox LIVE. It includes session names, content descriptions, text messages, tags, team names, mottos, comments, and so on.
|
||||
//
|
||||
// Games may decide to not send the text, blank it out, or use generic text if the text was rejected by the Xbox LIVE service.
|
||||
//
|
||||
// Games verify the text by calling the XStringVerify function.
|
||||
//
|
||||
// Exemption It is not required to use the Xbox LIVE service to verify real-time text communication. An example of real-time text communication is in-game text chat.
|
||||
//
|
||||
// Intent Protect players from inappropriate language.
|
||||
bool VerifyStrings(wchar_t **pwStringA,int iStringC,int( *Func)(void *,STRING_VERIFY_RESPONSE *),void *lpParam);
|
||||
void CancelQueuedVerifyStrings(int( *Func)(void *,STRING_VERIFY_RESPONSE *),void *lpParam);
|
||||
void CancelAllVerifyInProgress(void);
|
||||
|
||||
//bool InputDetected(DWORD dwUserIndex,WCHAR *pwchInput);
|
||||
|
||||
int GetMouseX();
|
||||
int GetMouseY();
|
||||
// bool InputDetected(DWORD dwUserIndex,WCHAR *pwchInput);
|
||||
};
|
||||
|
||||
// Singleton
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@
|
|||
#include "../Minecraft.Client/Platform/Linux/Stubs/LinuxStubs.h"
|
||||
#endif
|
||||
|
||||
#endif //_4J_INPUT_STADAFX_H
|
||||
#endif //_4J_INPUT_STADAFX_H
|
||||
|
|
@ -1,86 +1,271 @@
|
|||
#include "4J_Profile.h"
|
||||
#include "../Minecraft.Client/Platform/Common/App_Defines.h"
|
||||
#include "../Minecraft.Client/Platform/Common/Tutorial/TutorialEnum.h"
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
C_4JProfile ProfileManager;
|
||||
|
||||
static void *s_profileData[4] = {};
|
||||
namespace {
|
||||
constexpr PlayerUID kFakeXuidBase = 0xe000d45248242f2eULL;
|
||||
|
||||
void C_4JProfile::Initialise(DWORD dwTitleID, DWORD dwOfferID, unsigned short usProfileVersion,
|
||||
UINT uiProfileValuesC, UINT uiProfileSettingsC, DWORD *pdwProfileSettingsA,
|
||||
int iGameDefinedDataSizeX4, unsigned int *puiGameDefinedDataChangedBitmask)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
struct ProfileGameSettings {
|
||||
bool bSettingsChanged;
|
||||
unsigned char ucMusicVolume;
|
||||
unsigned char ucSoundFXVolume;
|
||||
unsigned char ucSensitivity;
|
||||
unsigned char ucGamma;
|
||||
unsigned char ucPad01;
|
||||
unsigned short usBitmaskValues;
|
||||
unsigned int uiDebugBitmask;
|
||||
union {
|
||||
struct {
|
||||
unsigned char ucTutorialCompletion[TUTORIAL_PROFILE_STORAGE_BYTES];
|
||||
std::uint32_t dwSelectedSkin;
|
||||
unsigned char ucMenuSensitivity;
|
||||
unsigned char ucInterfaceOpacity;
|
||||
unsigned char ucPad02;
|
||||
unsigned char usPad03;
|
||||
unsigned int uiBitmaskValues;
|
||||
unsigned int uiSpecialTutorialBitmask;
|
||||
std::uint32_t dwSelectedCape;
|
||||
unsigned int uiFavoriteSkinA[MAX_FAVORITE_SKINS];
|
||||
unsigned char ucCurrentFavoriteSkinPos;
|
||||
unsigned int uiMashUpPackWorldsDisplay;
|
||||
unsigned char ucLanguage;
|
||||
};
|
||||
|
||||
unsigned char ucReservedSpace[192];
|
||||
};
|
||||
};
|
||||
|
||||
static_assert(sizeof(ProfileGameSettings) == 204,
|
||||
"ProfileGameSettings must match GAME_SETTINGS profile storage");
|
||||
|
||||
void* s_profileData[XUSER_MAX_COUNT] = {};
|
||||
C_4JProfile::PROFILESETTINGS s_dashboardSettings[XUSER_MAX_COUNT] = {};
|
||||
char s_gamertags[XUSER_MAX_COUNT][16] = {};
|
||||
std::wstring s_displayNames[XUSER_MAX_COUNT];
|
||||
int s_primaryPad = 0;
|
||||
int s_lockedProfile = 0;
|
||||
bool s_profileIsFullVersion = true;
|
||||
int (*s_defaultOptionsCallback)(void*, C_4JProfile::PROFILESETTINGS*,
|
||||
const int iPad) = nullptr;
|
||||
void* s_defaultOptionsCallbackParam = nullptr;
|
||||
|
||||
bool isValidPad(int iPad) { return iPad >= 0 && iPad < XUSER_MAX_COUNT; }
|
||||
|
||||
void ensureFakeIdentity(int iPad) {
|
||||
if (!isValidPad(iPad) || s_gamertags[iPad][0] != '\0') {
|
||||
return;
|
||||
}
|
||||
|
||||
std::snprintf(s_gamertags[iPad], sizeof(s_gamertags[iPad]), "Player%d",
|
||||
iPad + 1);
|
||||
s_displayNames[iPad] = std::wstring(L"Player") + std::to_wstring(iPad + 1);
|
||||
}
|
||||
|
||||
void initialiseDefaultGameSettings(ProfileGameSettings* gameSettings) {
|
||||
gameSettings->ucMenuSensitivity = 100;
|
||||
gameSettings->ucInterfaceOpacity = 80;
|
||||
gameSettings->usBitmaskValues |= 0x0200;
|
||||
gameSettings->usBitmaskValues |= 0x0400;
|
||||
gameSettings->usBitmaskValues |= 0x1000;
|
||||
gameSettings->usBitmaskValues |= 0x8000;
|
||||
gameSettings->uiBitmaskValues = 0L;
|
||||
gameSettings->uiBitmaskValues |= GAMESETTING_CLOUDS;
|
||||
gameSettings->uiBitmaskValues |= GAMESETTING_ONLINE;
|
||||
gameSettings->uiBitmaskValues |= GAMESETTING_FRIENDSOFFRIENDS;
|
||||
gameSettings->uiBitmaskValues |= GAMESETTING_DISPLAYUPDATEMSG;
|
||||
gameSettings->uiBitmaskValues &= ~GAMESETTING_BEDROCKFOG;
|
||||
gameSettings->uiBitmaskValues |= GAMESETTING_DISPLAYHUD;
|
||||
gameSettings->uiBitmaskValues |= GAMESETTING_DISPLAYHAND;
|
||||
gameSettings->uiBitmaskValues |= GAMESETTING_CUSTOMSKINANIM;
|
||||
gameSettings->uiBitmaskValues |= GAMESETTING_DEATHMESSAGES;
|
||||
gameSettings->uiBitmaskValues |= (GAMESETTING_UISIZE & 0x00000800);
|
||||
gameSettings->uiBitmaskValues |=
|
||||
(GAMESETTING_UISIZE_SPLITSCREEN & 0x00004000);
|
||||
gameSettings->uiBitmaskValues |= GAMESETTING_ANIMATEDCHARACTER;
|
||||
|
||||
for (int i = 0; i < MAX_FAVORITE_SKINS; ++i) {
|
||||
gameSettings->uiFavoriteSkinA[i] = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
gameSettings->ucCurrentFavoriteSkinPos = 0;
|
||||
gameSettings->uiMashUpPackWorldsDisplay = 0xFFFFFFFF;
|
||||
gameSettings->uiBitmaskValues &= ~GAMESETTING_PS3EULAREAD;
|
||||
gameSettings->ucLanguage = MINECRAFT_LANGUAGE_DEFAULT;
|
||||
gameSettings->uiBitmaskValues &= ~GAMESETTING_PSVITANETWORKMODEADHOC;
|
||||
gameSettings->ucTutorialCompletion[0] = 0xFF;
|
||||
gameSettings->ucTutorialCompletion[1] = 0xFF;
|
||||
gameSettings->ucTutorialCompletion[2] = 0x0F;
|
||||
gameSettings->ucTutorialCompletion[28] |= 1 << 0;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void C_4JProfile::Initialise(std::uint32_t dwTitleID,
|
||||
std::uint32_t dwOfferID,
|
||||
unsigned short usProfileVersion,
|
||||
unsigned int uiProfileValuesC,
|
||||
unsigned int uiProfileSettingsC,
|
||||
std::uint32_t* pdwProfileSettingsA,
|
||||
int iGameDefinedDataSizeX4,
|
||||
unsigned int* puiGameDefinedDataChangedBitmask) {
|
||||
s_primaryPad = 0;
|
||||
s_lockedProfile = 0;
|
||||
std::memset(s_dashboardSettings, 0, sizeof(s_dashboardSettings));
|
||||
|
||||
for (int i = 0; i < XUSER_MAX_COUNT; ++i) {
|
||||
delete[] static_cast<unsigned char*>(s_profileData[i]);
|
||||
s_profileData[i] = new unsigned char[iGameDefinedDataSizeX4 / 4];
|
||||
memset(s_profileData[i], 0, iGameDefinedDataSizeX4 / 4);
|
||||
std::memset(s_profileData[i], 0, iGameDefinedDataSizeX4 / 4);
|
||||
initialiseDefaultGameSettings(
|
||||
static_cast<ProfileGameSettings*>(s_profileData[i]));
|
||||
ensureFakeIdentity(i);
|
||||
}
|
||||
}
|
||||
void C_4JProfile::SetTrialTextStringTable(CXuiStringTable *pStringTable, int iAccept, int iReject) {}
|
||||
void C_4JProfile::SetTrialAwardText(eAwardType AwardType, int iTitle, int iText) {}
|
||||
int C_4JProfile::GetLockedProfile() { return -1; }
|
||||
void C_4JProfile::SetLockedProfile(int iProf) {}
|
||||
void C_4JProfile::SetTrialTextStringTable(CXuiStringTable* pStringTable,
|
||||
int iAccept, int iReject) {}
|
||||
void C_4JProfile::SetTrialAwardText(eAwardType AwardType, int iTitle,
|
||||
int iText) {}
|
||||
int C_4JProfile::GetLockedProfile() { return s_lockedProfile; }
|
||||
void C_4JProfile::SetLockedProfile(int iProf) { s_lockedProfile = iProf; }
|
||||
bool C_4JProfile::IsSignedIn(int iQuadrant) { return iQuadrant == 0; }
|
||||
bool C_4JProfile::IsSignedInLive(int iProf) { return false; }
|
||||
bool C_4JProfile::IsSignedInLive(int iProf) { return IsSignedIn(iProf); }
|
||||
bool C_4JProfile::IsGuest(int iQuadrant) { return false; }
|
||||
UINT C_4JProfile::RequestSignInUI(bool bFromInvite, bool bLocalGame, bool bNoGuestsAllowed, bool bMultiplayerSignIn, bool bAddUser, int(*Func)(void *, const bool, const int iPad), void *lpParam, int iQuadrant) { return 0; }
|
||||
UINT C_4JProfile::DisplayOfflineProfile(int(*Func)(void *, const bool, const int iPad), void *lpParam, int iQuadrant) { return 0; }
|
||||
UINT C_4JProfile::RequestConvertOfflineToGuestUI(int(*Func)(void *, const bool, const int iPad), void *lpParam, int iQuadrant) { return 0; }
|
||||
unsigned int C_4JProfile::RequestSignInUI(
|
||||
bool bFromInvite, bool bLocalGame, bool bNoGuestsAllowed,
|
||||
bool bMultiplayerSignIn, bool bAddUser,
|
||||
int (*Func)(void*, const bool, const int iPad), void* lpParam,
|
||||
int iQuadrant) {
|
||||
return 0;
|
||||
}
|
||||
unsigned int C_4JProfile::DisplayOfflineProfile(
|
||||
int (*Func)(void*, const bool, const int iPad), void* lpParam,
|
||||
int iQuadrant) {
|
||||
return 0;
|
||||
}
|
||||
unsigned int C_4JProfile::RequestConvertOfflineToGuestUI(
|
||||
int (*Func)(void*, const bool, const int iPad), void* lpParam,
|
||||
int iQuadrant) {
|
||||
return 0;
|
||||
}
|
||||
void C_4JProfile::SetPrimaryPlayerChanged(bool bVal) {}
|
||||
bool C_4JProfile::QuerySigninStatus(void) { return true; }
|
||||
void C_4JProfile::GetXUID(int iPad, PlayerUID *pXuid, bool bOnlineXuid) { if (pXuid) *pXuid = 0; }
|
||||
bool C_4JProfile::AreXUIDSEqual(PlayerUID xuid1, PlayerUID xuid2) { return xuid1 == xuid2; }
|
||||
void C_4JProfile::GetXUID(int iPad, PlayerUID* pXuid, bool bOnlineXuid) {
|
||||
if (pXuid) *pXuid = kFakeXuidBase + static_cast<PlayerUID>(isValidPad(iPad) ? iPad : 0);
|
||||
}
|
||||
bool C_4JProfile::AreXUIDSEqual(PlayerUID xuid1, PlayerUID xuid2) {
|
||||
return xuid1 == xuid2;
|
||||
}
|
||||
bool C_4JProfile::XUIDIsGuest(PlayerUID xuid) { return false; }
|
||||
bool C_4JProfile::AllowedToPlayMultiplayer(int iProf) { return true; }
|
||||
bool C_4JProfile::GetChatAndContentRestrictions(int iPad, bool *pbChatRestricted, bool *pbContentRestricted, int *piAge) {
|
||||
bool C_4JProfile::GetChatAndContentRestrictions(int iPad,
|
||||
bool* pbChatRestricted,
|
||||
bool* pbContentRestricted,
|
||||
int* piAge) {
|
||||
if (pbChatRestricted) *pbChatRestricted = false;
|
||||
if (pbContentRestricted) *pbContentRestricted = false;
|
||||
if (piAge) *piAge = 18;
|
||||
return true;
|
||||
}
|
||||
void C_4JProfile::StartTrialGame() {}
|
||||
void C_4JProfile::AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly, bool *allAllowed, bool *friendsAllowed) {
|
||||
void C_4JProfile::AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly,
|
||||
bool* allAllowed,
|
||||
bool* friendsAllowed) {
|
||||
if (allAllowed) *allAllowed = true;
|
||||
if (friendsAllowed) *friendsAllowed = true;
|
||||
}
|
||||
bool C_4JProfile::CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly, PPlayerUID pXuids, unsigned int xuidCount) { return true; }
|
||||
bool C_4JProfile::CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly,
|
||||
PPlayerUID pXuids,
|
||||
unsigned int xuidCount) {
|
||||
return true;
|
||||
}
|
||||
void C_4JProfile::ShowProfileCard(int iPad, PlayerUID targetUid) {}
|
||||
bool C_4JProfile::GetProfileAvatar(int iPad, int(*Func)(void *lpParam, std::uint8_t *thumbnailData, unsigned int thumbnailBytes), void *lpParam) { return false; }
|
||||
bool C_4JProfile::GetProfileAvatar(int iPad,
|
||||
int (*Func)(void* lpParam,
|
||||
std::uint8_t* thumbnailData,
|
||||
unsigned int thumbnailBytes),
|
||||
void* lpParam) {
|
||||
return false;
|
||||
}
|
||||
void C_4JProfile::CancelProfileAvatarRequest() {}
|
||||
int C_4JProfile::GetPrimaryPad() { return 0; }
|
||||
void C_4JProfile::SetPrimaryPad(int iPad) {}
|
||||
int C_4JProfile::GetPrimaryPad() { return s_primaryPad; }
|
||||
void C_4JProfile::SetPrimaryPad(int iPad) { s_primaryPad = iPad; }
|
||||
|
||||
static char s_gamertag[64] = "Player";
|
||||
char* C_4JProfile::GetGamertag(int iPad) { return s_gamertag; }
|
||||
std::wstring C_4JProfile::GetDisplayName(int iPad) { return L"Player"; }
|
||||
bool C_4JProfile::IsFullVersion() { return true; }
|
||||
void C_4JProfile::SetSignInChangeCallback(void(*Func)(void *, bool, unsigned int), void *lpParam) {}
|
||||
void C_4JProfile::SetNotificationsCallback(void(*Func)(void *, std::uint32_t, unsigned int), void *lpParam) {}
|
||||
bool C_4JProfile::RegionIsNorthAmerica(void) { return true; }
|
||||
bool C_4JProfile::LocaleIsUSorCanada(void) { return true; }
|
||||
char* C_4JProfile::GetGamertag(int iPad) {
|
||||
const int resolvedPad = isValidPad(iPad) ? iPad : 0;
|
||||
ensureFakeIdentity(resolvedPad);
|
||||
return s_gamertags[resolvedPad];
|
||||
}
|
||||
std::wstring C_4JProfile::GetDisplayName(int iPad) {
|
||||
const int resolvedPad = isValidPad(iPad) ? iPad : 0;
|
||||
ensureFakeIdentity(resolvedPad);
|
||||
return s_displayNames[resolvedPad];
|
||||
}
|
||||
bool C_4JProfile::IsFullVersion() { return s_profileIsFullVersion; }
|
||||
void C_4JProfile::SetSignInChangeCallback(void (*Func)(void*, bool,
|
||||
unsigned int),
|
||||
void* lpParam) {}
|
||||
void C_4JProfile::SetNotificationsCallback(void (*Func)(void*, std::uint32_t,
|
||||
unsigned int),
|
||||
void* lpParam) {}
|
||||
bool C_4JProfile::RegionIsNorthAmerica(void) { return false; }
|
||||
bool C_4JProfile::LocaleIsUSorCanada(void) { return false; }
|
||||
HRESULT C_4JProfile::GetLiveConnectionStatus() { return S_OK; }
|
||||
bool C_4JProfile::IsSystemUIDisplayed() { return false; }
|
||||
void C_4JProfile::SetProfileReadErrorCallback(void(*Func)(void *), void *lpParam) {}
|
||||
int C_4JProfile::SetDefaultOptionsCallback(int(*Func)(void *, PROFILESETTINGS *, const int iPad), void *lpParam) { return 0; }
|
||||
int C_4JProfile::SetOldProfileVersionCallback(int(*Func)(void *, unsigned char *, const unsigned short, const int), void *lpParam) { return 0; }
|
||||
|
||||
static C_4JProfile::PROFILESETTINGS s_defaultSettings = {};
|
||||
C_4JProfile::PROFILESETTINGS* C_4JProfile::GetDashboardProfileSettings(int iPad) { return &s_defaultSettings; }
|
||||
void C_4JProfile::WriteToProfile(int iQuadrant, bool bGameDefinedDataChanged, bool bOverride5MinuteLimitOnProfileWrites) {}
|
||||
void C_4JProfile::SetProfileReadErrorCallback(void (*Func)(void*),
|
||||
void* lpParam) {}
|
||||
int C_4JProfile::SetDefaultOptionsCallback(int (*Func)(void*, PROFILESETTINGS*,
|
||||
const int iPad),
|
||||
void* lpParam) {
|
||||
s_defaultOptionsCallback = Func;
|
||||
s_defaultOptionsCallbackParam = lpParam;
|
||||
return 0;
|
||||
}
|
||||
int C_4JProfile::SetOldProfileVersionCallback(int (*Func)(void*, unsigned char*,
|
||||
const unsigned short,
|
||||
const int),
|
||||
void* lpParam) {
|
||||
return 0;
|
||||
}
|
||||
C_4JProfile::PROFILESETTINGS* C_4JProfile::GetDashboardProfileSettings(
|
||||
int iPad) {
|
||||
return &s_dashboardSettings[isValidPad(iPad) ? iPad : 0];
|
||||
}
|
||||
void C_4JProfile::WriteToProfile(int iQuadrant, bool bGameDefinedDataChanged,
|
||||
bool bOverride5MinuteLimitOnProfileWrites) {}
|
||||
void C_4JProfile::ForceQueuedProfileWrites(int iPad) {}
|
||||
void* C_4JProfile::GetGameDefinedProfileData(int iQuadrant) { return s_profileData[iQuadrant]; }
|
||||
void* C_4JProfile::GetGameDefinedProfileData(int iQuadrant) {
|
||||
return isValidPad(iQuadrant) ? s_profileData[iQuadrant] : nullptr;
|
||||
}
|
||||
void C_4JProfile::ResetProfileProcessState() {}
|
||||
void C_4JProfile::Tick(void) {}
|
||||
void C_4JProfile::RegisterAward(int iAwardNumber, int iGamerconfigID, eAwardType eType, bool bLeaderboardAffected,
|
||||
CXuiStringTable *pStringTable, int iTitleStr, int iTextStr, int iAcceptStr, char *pszThemeName, unsigned int uiThemeSize) {}
|
||||
void C_4JProfile::RegisterAward(int iAwardNumber, int iGamerconfigID,
|
||||
eAwardType eType, bool bLeaderboardAffected,
|
||||
CXuiStringTable* pStringTable, int iTitleStr,
|
||||
int iTextStr, int iAcceptStr,
|
||||
char* pszThemeName, unsigned int uiThemeSize) {}
|
||||
int C_4JProfile::GetAwardId(int iAwardNumber) { return 0; }
|
||||
eAwardType C_4JProfile::GetAwardType(int iAwardNumber) { return eAwardType_Achievement; }
|
||||
bool C_4JProfile::CanBeAwarded(int iQuadrant, int iAwardNumber) { return false; }
|
||||
eAwardType C_4JProfile::GetAwardType(int iAwardNumber) {
|
||||
return eAwardType_Achievement;
|
||||
}
|
||||
bool C_4JProfile::CanBeAwarded(int iQuadrant, int iAwardNumber) {
|
||||
return false;
|
||||
}
|
||||
void C_4JProfile::Award(int iQuadrant, int iAwardNumber, bool bForce) {}
|
||||
bool C_4JProfile::IsAwardsFlagSet(int iQuadrant, int iAward) { return false; }
|
||||
void C_4JProfile::RichPresenceInit(int iPresenceCount, int iContextCount) {}
|
||||
void C_4JProfile::RegisterRichPresenceContext(int iGameConfigContextID) {}
|
||||
void C_4JProfile::SetRichPresenceContextValue(int iPad, int iContextID, int iVal) {}
|
||||
void C_4JProfile::SetCurrentGameActivity(int iPad, int iNewPresence, bool bSetOthersToIdle) {}
|
||||
void C_4JProfile::DisplayFullVersionPurchase(bool bRequired, int iQuadrant, int iUpsellParam) {}
|
||||
void C_4JProfile::SetUpsellCallback(void(*Func)(void *lpParam, eUpsellType type, eUpsellResponse response, int iUserData), void *lpParam) {}
|
||||
void C_4JProfile::SetDebugFullOverride(bool bVal) {}
|
||||
void C_4JProfile::SetRichPresenceContextValue(int iPad, int iContextID,
|
||||
int iVal) {}
|
||||
void C_4JProfile::SetCurrentGameActivity(int iPad, int iNewPresence,
|
||||
bool bSetOthersToIdle) {}
|
||||
void C_4JProfile::DisplayFullVersionPurchase(bool bRequired, int iQuadrant,
|
||||
int iUpsellParam) {}
|
||||
void C_4JProfile::SetUpsellCallback(void (*Func)(void* lpParam,
|
||||
eUpsellType type,
|
||||
eUpsellResponse response,
|
||||
int iUserData),
|
||||
void* lpParam) {}
|
||||
void C_4JProfile::SetDebugFullOverride(bool bVal) { s_profileIsFullVersion = bVal; }
|
||||
|
|
|
|||
|
|
@ -2,129 +2,159 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
enum eAwardType
|
||||
{
|
||||
eAwardType_Achievement = 0,
|
||||
eAwardType_GamerPic,
|
||||
eAwardType_Theme,
|
||||
eAwardType_AvatarItem,
|
||||
enum eAwardType {
|
||||
eAwardType_Achievement = 0,
|
||||
eAwardType_GamerPic,
|
||||
eAwardType_Theme,
|
||||
eAwardType_AvatarItem,
|
||||
};
|
||||
|
||||
enum eUpsellType
|
||||
{
|
||||
eUpsellType_Custom = 0, // This is the default, and means that the upsell dialog was initiated in the app code
|
||||
eUpsellType_Achievement,
|
||||
eUpsellType_GamerPic,
|
||||
eUpsellType_Theme,
|
||||
eUpsellType_AvatarItem,
|
||||
enum eUpsellType {
|
||||
eUpsellType_Custom = 0, // This is the default, and means that the upsell
|
||||
// dialog was initiated in the app code
|
||||
eUpsellType_Achievement,
|
||||
eUpsellType_GamerPic,
|
||||
eUpsellType_Theme,
|
||||
eUpsellType_AvatarItem,
|
||||
};
|
||||
|
||||
enum eUpsellResponse
|
||||
{
|
||||
eUpsellResponse_Declined,
|
||||
eUpsellResponse_Accepted_NoPurchase,
|
||||
eUpsellResponse_Accepted_Purchase,
|
||||
enum eUpsellResponse {
|
||||
eUpsellResponse_Declined,
|
||||
eUpsellResponse_Accepted_NoPurchase,
|
||||
eUpsellResponse_Accepted_Purchase,
|
||||
};
|
||||
|
||||
|
||||
|
||||
class C_4JProfile
|
||||
{
|
||||
class C_4JProfile {
|
||||
public:
|
||||
struct PROFILESETTINGS
|
||||
{
|
||||
int iYAxisInversion;
|
||||
int iControllerSensitivity;
|
||||
int iVibration;
|
||||
bool bSwapSticks;
|
||||
};
|
||||
struct PROFILESETTINGS {
|
||||
int iYAxisInversion;
|
||||
int iControllerSensitivity;
|
||||
int iVibration;
|
||||
bool bSwapSticks;
|
||||
};
|
||||
|
||||
// 4 players have game defined data, puiGameDefinedDataChangedBitmask needs
|
||||
// to be checked by the game side to see if there's an update needed - it'll
|
||||
// have the bits set for players to be updated
|
||||
void Initialise(std::uint32_t dwTitleID, std::uint32_t dwOfferID,
|
||||
unsigned short usProfileVersion,
|
||||
unsigned int uiProfileValuesC,
|
||||
unsigned int uiProfileSettingsC,
|
||||
std::uint32_t* pdwProfileSettingsA,
|
||||
int iGameDefinedDataSizeX4,
|
||||
unsigned int* puiGameDefinedDataChangedBitmask);
|
||||
void SetTrialTextStringTable(CXuiStringTable* pStringTable, int iAccept,
|
||||
int iReject);
|
||||
void SetTrialAwardText(eAwardType AwardType, int iTitle,
|
||||
int iText); // achievement popup in the trial game
|
||||
int GetLockedProfile();
|
||||
void SetLockedProfile(int iProf);
|
||||
bool IsSignedIn(int iQuadrant);
|
||||
bool IsSignedInLive(int iProf);
|
||||
bool IsGuest(int iQuadrant);
|
||||
unsigned int RequestSignInUI(bool bFromInvite, bool bLocalGame,
|
||||
bool bNoGuestsAllowed,
|
||||
bool bMultiplayerSignIn, bool bAddUser,
|
||||
int (*Func)(void*, const bool, const int iPad),
|
||||
void* lpParam,
|
||||
int iQuadrant = XUSER_INDEX_ANY);
|
||||
unsigned int DisplayOfflineProfile(
|
||||
int (*Func)(void*, const bool, const int iPad), void* lpParam,
|
||||
int iQuadrant = XUSER_INDEX_ANY);
|
||||
unsigned int RequestConvertOfflineToGuestUI(
|
||||
int (*Func)(void*, const bool, const int iPad), void* lpParam,
|
||||
int iQuadrant = XUSER_INDEX_ANY);
|
||||
void SetPrimaryPlayerChanged(bool bVal);
|
||||
bool QuerySigninStatus(void);
|
||||
void GetXUID(int iPad, PlayerUID* pXuid, bool bOnlineXuid);
|
||||
bool AreXUIDSEqual(PlayerUID xuid1, PlayerUID xuid2);
|
||||
bool XUIDIsGuest(PlayerUID xuid);
|
||||
bool AllowedToPlayMultiplayer(int iProf);
|
||||
bool GetChatAndContentRestrictions(int iPad, bool* pbChatRestricted,
|
||||
bool* pbContentRestricted, int* piAge);
|
||||
void StartTrialGame(); // disables saves and leaderboard, and change state
|
||||
// to readyforgame from pregame
|
||||
void AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly,
|
||||
bool* allAllowed, bool* friendsAllowed);
|
||||
bool CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly,
|
||||
PPlayerUID pXuids, unsigned int xuidCount);
|
||||
void ShowProfileCard(int iPad, PlayerUID targetUid);
|
||||
bool GetProfileAvatar(int iPad,
|
||||
int (*Func)(void* lpParam,
|
||||
std::uint8_t* thumbnailData,
|
||||
unsigned int thumbnailBytes),
|
||||
void* lpParam);
|
||||
void CancelProfileAvatarRequest();
|
||||
|
||||
// 4 players have game defined data, puiGameDefinedDataChangedBitmask needs to be checked by the game side to see if there's an update needed - it'll have the bits set for players to be updated
|
||||
void Initialise( DWORD dwTitleID,
|
||||
DWORD dwOfferID,
|
||||
unsigned short usProfileVersion,
|
||||
UINT uiProfileValuesC,
|
||||
UINT uiProfileSettingsC,
|
||||
DWORD *pdwProfileSettingsA,
|
||||
int iGameDefinedDataSizeX4,
|
||||
unsigned int *puiGameDefinedDataChangedBitmask);
|
||||
void SetTrialTextStringTable(CXuiStringTable *pStringTable,int iAccept,int iReject);
|
||||
void SetTrialAwardText(eAwardType AwardType,int iTitle,int iText); // achievement popup in the trial game
|
||||
int GetLockedProfile();
|
||||
void SetLockedProfile(int iProf);
|
||||
bool IsSignedIn(int iQuadrant);
|
||||
bool IsSignedInLive(int iProf);
|
||||
bool IsGuest(int iQuadrant);
|
||||
UINT RequestSignInUI(bool bFromInvite,bool bLocalGame,bool bNoGuestsAllowed,bool bMultiplayerSignIn,bool bAddUser, int( *Func)(void *,const bool, const int iPad),void *lpParam,int iQuadrant=XUSER_INDEX_ANY);
|
||||
UINT DisplayOfflineProfile(int( *Func)(void *,const bool, const int iPad),void *lpParam,int iQuadrant=XUSER_INDEX_ANY);
|
||||
UINT RequestConvertOfflineToGuestUI(int( *Func)(void *,const bool, const int iPad),void *lpParam,int iQuadrant=XUSER_INDEX_ANY);
|
||||
void SetPrimaryPlayerChanged(bool bVal);
|
||||
bool QuerySigninStatus(void);
|
||||
void GetXUID(int iPad, PlayerUID *pXuid,bool bOnlineXuid);
|
||||
bool AreXUIDSEqual(PlayerUID xuid1,PlayerUID xuid2);
|
||||
bool XUIDIsGuest(PlayerUID xuid);
|
||||
bool AllowedToPlayMultiplayer(int iProf);
|
||||
bool GetChatAndContentRestrictions(int iPad,bool *pbChatRestricted,bool *pbContentRestricted,int *piAge);
|
||||
void StartTrialGame(); // disables saves and leaderboard, and change state to readyforgame from pregame
|
||||
void AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly, bool *allAllowed, bool *friendsAllowed);
|
||||
bool CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly, PPlayerUID pXuids, unsigned int xuidCount);
|
||||
void ShowProfileCard(int iPad, PlayerUID targetUid);
|
||||
bool GetProfileAvatar(int iPad,int( *Func)(void *lpParam,std::uint8_t *thumbnailData,unsigned int thumbnailBytes), void *lpParam);
|
||||
void CancelProfileAvatarRequest();
|
||||
// SYS
|
||||
int GetPrimaryPad();
|
||||
void SetPrimaryPad(int iPad);
|
||||
char* GetGamertag(int iPad);
|
||||
std::wstring GetDisplayName(int iPad);
|
||||
bool IsFullVersion();
|
||||
void SetSignInChangeCallback(void (*Func)(void*, bool, unsigned int),
|
||||
void* lpParam);
|
||||
void SetNotificationsCallback(void (*Func)(void*, std::uint32_t,
|
||||
unsigned int),
|
||||
void* lpParam);
|
||||
bool RegionIsNorthAmerica(void);
|
||||
bool LocaleIsUSorCanada(void);
|
||||
HRESULT GetLiveConnectionStatus();
|
||||
bool IsSystemUIDisplayed();
|
||||
void SetProfileReadErrorCallback(void (*Func)(void*), void* lpParam);
|
||||
|
||||
|
||||
// SYS
|
||||
int GetPrimaryPad();
|
||||
void SetPrimaryPad(int iPad);
|
||||
char* GetGamertag(int iPad);
|
||||
std::wstring GetDisplayName(int iPad);
|
||||
bool IsFullVersion();
|
||||
void SetSignInChangeCallback(void ( *Func)(void *, bool, unsigned int),void *lpParam);
|
||||
void SetNotificationsCallback(void ( *Func)(void *, std::uint32_t, unsigned int),void *lpParam);
|
||||
bool RegionIsNorthAmerica(void);
|
||||
bool LocaleIsUSorCanada(void);
|
||||
HRESULT GetLiveConnectionStatus();
|
||||
bool IsSystemUIDisplayed();
|
||||
void SetProfileReadErrorCallback(void ( *Func)(void *), void *lpParam);
|
||||
// PROFILE DATA
|
||||
int SetDefaultOptionsCallback(int (*Func)(void*, PROFILESETTINGS*,
|
||||
const int iPad),
|
||||
void* lpParam);
|
||||
int SetOldProfileVersionCallback(int (*Func)(void*, unsigned char*,
|
||||
const unsigned short,
|
||||
const int),
|
||||
void* lpParam);
|
||||
PROFILESETTINGS* GetDashboardProfileSettings(int iPad);
|
||||
void WriteToProfile(int iQuadrant, bool bGameDefinedDataChanged = false,
|
||||
bool bOverride5MinuteLimitOnProfileWrites = false);
|
||||
void ForceQueuedProfileWrites(int iPad = XUSER_INDEX_ANY);
|
||||
void* GetGameDefinedProfileData(int iQuadrant);
|
||||
void ResetProfileProcessState(); // after a sign out from the primary
|
||||
// player, call this
|
||||
void Tick(void);
|
||||
|
||||
// ACHIEVEMENTS & AWARDS
|
||||
|
||||
// PROFILE DATA
|
||||
int SetDefaultOptionsCallback(int( *Func)(void *,PROFILESETTINGS *, const int iPad),void *lpParam);
|
||||
int SetOldProfileVersionCallback(int( *Func)(void *,unsigned char *, const unsigned short,const int),void *lpParam);
|
||||
PROFILESETTINGS * GetDashboardProfileSettings(int iPad);
|
||||
void WriteToProfile(int iQuadrant, bool bGameDefinedDataChanged=false, bool bOverride5MinuteLimitOnProfileWrites=false);
|
||||
void ForceQueuedProfileWrites(int iPad=XUSER_INDEX_ANY);
|
||||
void *GetGameDefinedProfileData(int iQuadrant);
|
||||
void ResetProfileProcessState(); // after a sign out from the primary player, call this
|
||||
void Tick( void );
|
||||
void RegisterAward(int iAwardNumber, int iGamerconfigID, eAwardType eType,
|
||||
bool bLeaderboardAffected = false,
|
||||
CXuiStringTable* pStringTable = NULL, int iTitleStr = -1,
|
||||
int iTextStr = -1, int iAcceptStr = -1,
|
||||
char* pszThemeName = NULL,
|
||||
unsigned int uiThemeSize = 0L);
|
||||
int GetAwardId(int iAwardNumber);
|
||||
eAwardType GetAwardType(int iAwardNumber);
|
||||
bool CanBeAwarded(int iQuadrant, int iAwardNumber);
|
||||
void Award(int iQuadrant, int iAwardNumber, bool bForce = false);
|
||||
bool IsAwardsFlagSet(int iQuadrant, int iAward);
|
||||
|
||||
// ACHIEVEMENTS & AWARDS
|
||||
// RICH PRESENCE
|
||||
|
||||
void RegisterAward(int iAwardNumber,int iGamerconfigID, eAwardType eType, bool bLeaderboardAffected=false,
|
||||
CXuiStringTable*pStringTable=NULL, int iTitleStr=-1, int iTextStr=-1, int iAcceptStr=-1, char *pszThemeName=NULL, unsigned int uiThemeSize=0L);
|
||||
int GetAwardId(int iAwardNumber);
|
||||
eAwardType GetAwardType(int iAwardNumber);
|
||||
bool CanBeAwarded(int iQuadrant, int iAwardNumber);
|
||||
void Award(int iQuadrant, int iAwardNumber, bool bForce=false);
|
||||
bool IsAwardsFlagSet(int iQuadrant, int iAward);
|
||||
void RichPresenceInit(int iPresenceCount, int iContextCount);
|
||||
void RegisterRichPresenceContext(int iGameConfigContextID);
|
||||
void SetRichPresenceContextValue(int iPad, int iContextID, int iVal);
|
||||
void SetCurrentGameActivity(int iPad, int iNewPresence,
|
||||
bool bSetOthersToIdle = false);
|
||||
|
||||
// RICH PRESENCE
|
||||
|
||||
void RichPresenceInit(int iPresenceCount, int iContextCount);
|
||||
void RegisterRichPresenceContext(int iGameConfigContextID);
|
||||
void SetRichPresenceContextValue(int iPad,int iContextID, int iVal);
|
||||
void SetCurrentGameActivity(int iPad,int iNewPresence, bool bSetOthersToIdle=false);
|
||||
|
||||
// PURCHASE
|
||||
void DisplayFullVersionPurchase(bool bRequired, int iQuadrant, int iUpsellParam = -1);
|
||||
void SetUpsellCallback(void ( *Func)(void *lpParam, eUpsellType type, eUpsellResponse response, int iUserData),void *lpParam);
|
||||
|
||||
// Debug
|
||||
void SetDebugFullOverride(bool bVal); // To override the license version (trail/full). Only in debug/release, not ContentPackage
|
||||
// PURCHASE
|
||||
void DisplayFullVersionPurchase(bool bRequired, int iQuadrant,
|
||||
int iUpsellParam = -1);
|
||||
void SetUpsellCallback(void (*Func)(void* lpParam, eUpsellType type,
|
||||
eUpsellResponse response,
|
||||
int iUserData),
|
||||
void* lpParam);
|
||||
|
||||
// Debug
|
||||
void SetDebugFullOverride(
|
||||
bool bVal); // To override the license version (trail/full). Only in
|
||||
// debug/release, not ContentPackage
|
||||
};
|
||||
|
||||
// Singleton
|
||||
extern C_4JProfile ProfileManager;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
#ifndef _4J_PROFILE_STADAFX_H
|
||||
#define _4J_PROFILE_STADAFX_H
|
||||
|
||||
|
||||
#ifdef __linux__
|
||||
#include "../Minecraft.Client/Platform/Linux/Stubs/LinuxStubs.h"
|
||||
#endif
|
||||
|
||||
#include "../Minecraft.World/Platform/x64headers/extraX64.h"
|
||||
|
||||
#endif //_4J_PROFILE_STADAFX_H
|
||||
#endif //_4J_PROFILE_STADAFX_H
|
||||
|
|
@ -6,218 +6,230 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
class ImageFileBuffer
|
||||
{
|
||||
class ImageFileBuffer {
|
||||
public:
|
||||
enum EImageType
|
||||
{
|
||||
e_typePNG,
|
||||
e_typeJPG
|
||||
};
|
||||
enum EImageType { e_typePNG, e_typeJPG };
|
||||
|
||||
EImageType m_type;
|
||||
void* m_pBuffer;
|
||||
int m_bufferSize;
|
||||
EImageType m_type;
|
||||
void* m_pBuffer;
|
||||
int m_bufferSize;
|
||||
|
||||
int GetType() { return m_type; }
|
||||
void *GetBufferPointer() { return m_pBuffer; }
|
||||
int GetBufferSize() { return m_bufferSize; }
|
||||
void Release() { free(m_pBuffer); m_pBuffer = NULL; }
|
||||
bool Allocated() { return m_pBuffer != NULL; }
|
||||
int GetType() { return m_type; }
|
||||
void* GetBufferPointer() { return m_pBuffer; }
|
||||
int GetBufferSize() { return m_bufferSize; }
|
||||
void Release() {
|
||||
free(m_pBuffer);
|
||||
m_pBuffer = NULL;
|
||||
}
|
||||
bool Allocated() { return m_pBuffer != NULL; }
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int Width;
|
||||
int Height;
|
||||
}D3DXIMAGE_INFO;
|
||||
typedef struct {
|
||||
int Width;
|
||||
int Height;
|
||||
} D3DXIMAGE_INFO;
|
||||
|
||||
typedef struct _XSOCIAL_PREVIEWIMAGE {
|
||||
BYTE *pBytes;
|
||||
DWORD Pitch;
|
||||
DWORD Width;
|
||||
DWORD Height;
|
||||
// D3DFORMAT Format;
|
||||
std::uint8_t* pBytes;
|
||||
std::uint32_t Pitch;
|
||||
std::uint32_t Width;
|
||||
std::uint32_t Height;
|
||||
// D3DFORMAT Format;
|
||||
} XSOCIAL_PREVIEWIMAGE, *PXSOCIAL_PREVIEWIMAGE;
|
||||
|
||||
class C4JRender
|
||||
{
|
||||
class C4JRender {
|
||||
public:
|
||||
void Tick();
|
||||
void UpdateGamma(unsigned short usGamma);
|
||||
void Tick();
|
||||
void UpdateGamma(unsigned short usGamma);
|
||||
|
||||
// Matrix stack
|
||||
void MatrixMode(int type);
|
||||
void MatrixSetIdentity();
|
||||
void MatrixTranslate(float x,float y,float z);
|
||||
void MatrixRotate(float angle, float x, float y, float z);
|
||||
void MatrixScale(float x, float y, float z);
|
||||
void MatrixPerspective(float fovy, float aspect, float zNear, float zFar);
|
||||
void MatrixOrthogonal(float left,float right,float bottom,float top,float zNear,float zFar);
|
||||
void MatrixPop();
|
||||
void MatrixPush();
|
||||
void MatrixMult(float *mat);
|
||||
const float *MatrixGet(int type);
|
||||
void Set_matrixDirty();
|
||||
// Matrix stack
|
||||
void MatrixMode(int type);
|
||||
void MatrixSetIdentity();
|
||||
void MatrixTranslate(float x, float y, float z);
|
||||
void MatrixRotate(float angle, float x, float y, float z);
|
||||
void MatrixScale(float x, float y, float z);
|
||||
void MatrixPerspective(float fovy, float aspect, float zNear, float zFar);
|
||||
void MatrixOrthogonal(float left, float right, float bottom, float top,
|
||||
float zNear, float zFar);
|
||||
void MatrixPop();
|
||||
void MatrixPush();
|
||||
void MatrixMult(float* mat);
|
||||
const float* MatrixGet(int type);
|
||||
void Set_matrixDirty();
|
||||
|
||||
// Core
|
||||
void Initialise();
|
||||
void InitialiseContext();
|
||||
// Call before Initialise() to override window size and/or fullscreen mode.
|
||||
// If not called, the primary monitor's native resolution is used.
|
||||
void SetWindowSize(int w, int h);
|
||||
void SetFullscreen(bool fs);
|
||||
void StartFrame();
|
||||
void DoScreenGrabOnNextPresent();
|
||||
void Present();
|
||||
void Clear(int flags);
|
||||
void SetClearColour(const float colourRGBA[4]);
|
||||
bool IsWidescreen();
|
||||
bool IsHiDef();
|
||||
void GetFramebufferSize(int &width, int &height);
|
||||
void CaptureThumbnail(ImageFileBuffer *pngOut);
|
||||
void CaptureScreen(ImageFileBuffer *jpgOut, XSOCIAL_PREVIEWIMAGE *previewOut);
|
||||
void BeginConditionalSurvey(int identifier);
|
||||
void EndConditionalSurvey();
|
||||
void BeginConditionalRendering(int identifier);
|
||||
void EndConditionalRendering();
|
||||
// Core
|
||||
void Initialise();
|
||||
void InitialiseContext();
|
||||
// Call before Initialise() to override window size and/or fullscreen mode.
|
||||
// If not called, the primary monitor's native resolution is used.
|
||||
void SetWindowSize(int w, int h);
|
||||
void SetFullscreen(bool fs);
|
||||
void StartFrame();
|
||||
void DoScreenGrabOnNextPresent();
|
||||
void Present();
|
||||
void Clear(int flags);
|
||||
void SetClearColour(const float colourRGBA[4]);
|
||||
bool IsWidescreen();
|
||||
bool IsHiDef();
|
||||
void GetFramebufferSize(int& width, int& height);
|
||||
void CaptureThumbnail(ImageFileBuffer* pngOut);
|
||||
void CaptureScreen(ImageFileBuffer* jpgOut,
|
||||
XSOCIAL_PREVIEWIMAGE* previewOut);
|
||||
void BeginConditionalSurvey(int identifier);
|
||||
void EndConditionalSurvey();
|
||||
void BeginConditionalRendering(int identifier);
|
||||
void EndConditionalRendering();
|
||||
|
||||
// Vertex data handling
|
||||
typedef enum
|
||||
{
|
||||
VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1, // Position 3 x float, texture 2 x float, colour 4 x byte, normal 4 x byte, padding 1 DWORD
|
||||
VERTEX_TYPE_COMPRESSED, // Compressed format - see comment at top of VS_PS3_TS2_CS1.hlsl for description of layout
|
||||
VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_LIT, // as VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1 with lighting applied,
|
||||
VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN, // as VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1 with tex gen
|
||||
VERTEX_TYPE_COUNT
|
||||
} eVertexType;
|
||||
// Vertex data handling
|
||||
typedef enum {
|
||||
VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1, // Position 3 x float, texture 2 x
|
||||
// float, colour 4 x byte, normal 4 x
|
||||
// byte, padding 1 DWORD
|
||||
VERTEX_TYPE_COMPRESSED, // Compressed format - see comment at top of
|
||||
// VS_PS3_TS2_CS1.hlsl for description of
|
||||
// layout
|
||||
VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_LIT, // as
|
||||
// VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1
|
||||
// with lighting applied,
|
||||
VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN, // as
|
||||
// VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1
|
||||
// with tex gen
|
||||
VERTEX_TYPE_COUNT
|
||||
} eVertexType;
|
||||
|
||||
// Pixel shader
|
||||
typedef enum
|
||||
{
|
||||
PIXEL_SHADER_TYPE_STANDARD,
|
||||
PIXEL_SHADER_TYPE_PROJECTION,
|
||||
PIXEL_SHADER_TYPE_FORCELOD,
|
||||
PIXEL_SHADER_COUNT
|
||||
} ePixelShaderType;
|
||||
// Pixel shader
|
||||
typedef enum {
|
||||
PIXEL_SHADER_TYPE_STANDARD,
|
||||
PIXEL_SHADER_TYPE_PROJECTION,
|
||||
PIXEL_SHADER_TYPE_FORCELOD,
|
||||
PIXEL_SHADER_COUNT
|
||||
} ePixelShaderType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
VIEWPORT_TYPE_FULLSCREEN,
|
||||
VIEWPORT_TYPE_SPLIT_TOP,
|
||||
VIEWPORT_TYPE_SPLIT_BOTTOM,
|
||||
VIEWPORT_TYPE_SPLIT_LEFT,
|
||||
VIEWPORT_TYPE_SPLIT_RIGHT,
|
||||
VIEWPORT_TYPE_QUADRANT_TOP_LEFT,
|
||||
VIEWPORT_TYPE_QUADRANT_TOP_RIGHT,
|
||||
VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT,
|
||||
VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT,
|
||||
} eViewportType;
|
||||
typedef enum {
|
||||
VIEWPORT_TYPE_FULLSCREEN,
|
||||
VIEWPORT_TYPE_SPLIT_TOP,
|
||||
VIEWPORT_TYPE_SPLIT_BOTTOM,
|
||||
VIEWPORT_TYPE_SPLIT_LEFT,
|
||||
VIEWPORT_TYPE_SPLIT_RIGHT,
|
||||
VIEWPORT_TYPE_QUADRANT_TOP_LEFT,
|
||||
VIEWPORT_TYPE_QUADRANT_TOP_RIGHT,
|
||||
VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT,
|
||||
VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT,
|
||||
} eViewportType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PRIMITIVE_TYPE_TRIANGLE_LIST,
|
||||
PRIMITIVE_TYPE_TRIANGLE_STRIP,
|
||||
PRIMITIVE_TYPE_TRIANGLE_FAN,
|
||||
PRIMITIVE_TYPE_QUAD_LIST,
|
||||
PRIMITIVE_TYPE_LINE_LIST,
|
||||
PRIMITIVE_TYPE_LINE_STRIP,
|
||||
PRIMITIVE_TYPE_COUNT
|
||||
} ePrimitiveType;
|
||||
typedef enum {
|
||||
PRIMITIVE_TYPE_TRIANGLE_LIST,
|
||||
PRIMITIVE_TYPE_TRIANGLE_STRIP,
|
||||
PRIMITIVE_TYPE_TRIANGLE_FAN,
|
||||
PRIMITIVE_TYPE_QUAD_LIST,
|
||||
PRIMITIVE_TYPE_LINE_LIST,
|
||||
PRIMITIVE_TYPE_LINE_STRIP,
|
||||
PRIMITIVE_TYPE_COUNT
|
||||
} ePrimitiveType;
|
||||
|
||||
void DrawVertices(ePrimitiveType PrimitiveType, int count, void *dataIn, eVertexType vType, C4JRender::ePixelShaderType psType);
|
||||
void DrawVertices(ePrimitiveType PrimitiveType, int count, void* dataIn,
|
||||
eVertexType vType, C4JRender::ePixelShaderType psType);
|
||||
|
||||
// Command buffers
|
||||
void CBuffLockStaticCreations();
|
||||
int CBuffCreate(int count);
|
||||
void CBuffDelete(int first, int count);
|
||||
void CBuffStart(int index, bool full = false);
|
||||
void CBuffClear(int index);
|
||||
int CBuffSize(int index);
|
||||
void CBuffEnd();
|
||||
bool CBuffCall(int index, bool full = true);
|
||||
void CBuffTick();
|
||||
void CBuffDeferredModeStart();
|
||||
void CBuffDeferredModeEnd();
|
||||
// Command buffers
|
||||
void CBuffLockStaticCreations();
|
||||
int CBuffCreate(int count);
|
||||
void CBuffDelete(int first, int count);
|
||||
void CBuffStart(int index, bool full = false);
|
||||
void CBuffClear(int index);
|
||||
int CBuffSize(int index);
|
||||
void CBuffEnd();
|
||||
bool CBuffCall(int index, bool full = true);
|
||||
void CBuffTick();
|
||||
void CBuffDeferredModeStart();
|
||||
void CBuffDeferredModeEnd();
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TEXTURE_FORMAT_RxGyBzAw, // Normal 32-bit RGBA texture, 8 bits per component
|
||||
/* Don't think these are all directly available on D3D 11 - leaving for now
|
||||
TEXTURE_FORMAT_R0G0B0Ax, // One 8-bit component mapped to alpha channel, R=G=B=0
|
||||
TEXTURE_FORMAT_R1G1B1Ax, // One 8-bit component mapped to alpha channel, R=G=B=1
|
||||
TEXTURE_FORMAT_RxGxBxAx, // One 8-bit component mapped to all channels
|
||||
*/
|
||||
MAX_TEXTURE_FORMATS
|
||||
} eTextureFormat;
|
||||
typedef enum {
|
||||
TEXTURE_FORMAT_RxGyBzAw, // Normal 32-bit RGBA texture, 8 bits per
|
||||
// component
|
||||
/* Don't think these are all directly available on D3D 11 - leaving for
|
||||
now TEXTURE_FORMAT_R0G0B0Ax, // One 8-bit component mapped to
|
||||
alpha channel, R=G=B=0 TEXTURE_FORMAT_R1G1B1Ax, // One 8-bit
|
||||
component mapped to alpha channel, R=G=B=1 TEXTURE_FORMAT_RxGxBxAx,
|
||||
// One 8-bit component mapped to all channels
|
||||
*/
|
||||
MAX_TEXTURE_FORMATS
|
||||
} eTextureFormat;
|
||||
|
||||
// Textures
|
||||
int TextureCreate();
|
||||
void TextureFree(int idx);
|
||||
void TextureBind(int idx);
|
||||
void TextureBindVertex(int idx, bool scaleLight = false);
|
||||
void TextureSetTextureLevels(int levels);
|
||||
int TextureGetTextureLevels();
|
||||
void TextureData(int width, int height, void *data, int level, eTextureFormat format = TEXTURE_FORMAT_RxGyBzAw);
|
||||
void TextureDataUpdate(int xoffset, int yoffset, int width, int height, void *data, int level);
|
||||
void TextureSetParam(int param, int value);
|
||||
void TextureDynamicUpdateStart();
|
||||
void TextureDynamicUpdateEnd();
|
||||
HRESULT LoadTextureData(const char *szFilename,D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut);
|
||||
HRESULT LoadTextureData(BYTE *pbData, DWORD dwBytes,D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut);
|
||||
HRESULT SaveTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int *ppDataOut);
|
||||
HRESULT SaveTextureDataToMemory(void *pOutput, int outputCapacity, int *outputLength, int width, int height, int *ppDataIn);
|
||||
void TextureGetStats();
|
||||
void *TextureGetTexture(int idx);
|
||||
// Textures
|
||||
int TextureCreate();
|
||||
void TextureFree(int idx);
|
||||
void TextureBind(int idx);
|
||||
void TextureBindVertex(int idx, bool scaleLight = false);
|
||||
void TextureSetTextureLevels(int levels);
|
||||
int TextureGetTextureLevels();
|
||||
void TextureData(int width, int height, void* data, int level,
|
||||
eTextureFormat format = TEXTURE_FORMAT_RxGyBzAw);
|
||||
void TextureDataUpdate(int xoffset, int yoffset, int width, int height,
|
||||
void* data, int level);
|
||||
void TextureSetParam(int param, int value);
|
||||
void TextureDynamicUpdateStart();
|
||||
void TextureDynamicUpdateEnd();
|
||||
HRESULT LoadTextureData(const char* szFilename, D3DXIMAGE_INFO* pSrcInfo,
|
||||
int** ppDataOut);
|
||||
HRESULT LoadTextureData(std::uint8_t* pbData, std::uint32_t byteCount,
|
||||
D3DXIMAGE_INFO* pSrcInfo, int** ppDataOut);
|
||||
HRESULT SaveTextureData(const char* szFilename, D3DXIMAGE_INFO* pSrcInfo,
|
||||
int* ppDataOut);
|
||||
HRESULT SaveTextureDataToMemory(void* pOutput, int outputCapacity,
|
||||
int* outputLength, int width, int height,
|
||||
int* ppDataIn);
|
||||
void TextureGetStats();
|
||||
void* TextureGetTexture(int idx);
|
||||
|
||||
// State control
|
||||
void StateSetColour(float r, float g, float b, float a);
|
||||
void StateSetDepthMask(bool enable);
|
||||
void StateSetBlendEnable(bool enable);
|
||||
void StateSetBlendFunc(int src, int dst);
|
||||
void StateSetBlendFactor(unsigned int colour);
|
||||
void StateSetAlphaFunc(int func, float param);
|
||||
void StateSetDepthFunc(int func);
|
||||
void StateSetFaceCull(bool enable);
|
||||
void StateSetFaceCullCW(bool enable);
|
||||
void StateSetLineWidth(float width);
|
||||
void StateSetWriteEnable(bool red, bool green, bool blue, bool alpha);
|
||||
void StateSetDepthTestEnable(bool enable);
|
||||
void StateSetAlphaTestEnable(bool enable);
|
||||
void StateSetDepthSlopeAndBias(float slope, float bias);
|
||||
void StateSetFogEnable(bool enable);
|
||||
void StateSetFogMode(int mode);
|
||||
void StateSetFogNearDistance(float dist);
|
||||
void StateSetFogFarDistance(float dist);
|
||||
void StateSetFogDensity(float density);
|
||||
void StateSetFogColour(float red, float green, float blue);
|
||||
void StateSetLightingEnable(bool enable);
|
||||
void StateSetVertexTextureUV( float u, float v);
|
||||
void StateSetLightColour(int light, float red, float green, float blue);
|
||||
void StateSetLightAmbientColour(float red, float green, float blue);
|
||||
void StateSetLightDirection(int light, float x, float y, float z);
|
||||
void StateSetLightEnable(int light, bool enable);
|
||||
void StateSetViewport(eViewportType viewportType);
|
||||
void StateSetEnableViewportClipPlanes(bool enable);
|
||||
void StateSetTexGenCol(int col, float x, float y, float z, float w, bool eyeSpace);
|
||||
void StateSetStencil(int Function, uint8_t stencil_ref, uint8_t stencil_func_mask, uint8_t stencil_write_mask);
|
||||
void StateSetForceLOD(int LOD);
|
||||
// State control
|
||||
void StateSetColour(float r, float g, float b, float a);
|
||||
void StateSetDepthMask(bool enable);
|
||||
void StateSetBlendEnable(bool enable);
|
||||
void StateSetBlendFunc(int src, int dst);
|
||||
void StateSetBlendFactor(unsigned int colour);
|
||||
void StateSetAlphaFunc(int func, float param);
|
||||
void StateSetDepthFunc(int func);
|
||||
void StateSetFaceCull(bool enable);
|
||||
void StateSetFaceCullCW(bool enable);
|
||||
void StateSetLineWidth(float width);
|
||||
void StateSetWriteEnable(bool red, bool green, bool blue, bool alpha);
|
||||
void StateSetDepthTestEnable(bool enable);
|
||||
void StateSetAlphaTestEnable(bool enable);
|
||||
void StateSetDepthSlopeAndBias(float slope, float bias);
|
||||
void StateSetFogEnable(bool enable);
|
||||
void StateSetFogMode(int mode);
|
||||
void StateSetFogNearDistance(float dist);
|
||||
void StateSetFogFarDistance(float dist);
|
||||
void StateSetFogDensity(float density);
|
||||
void StateSetFogColour(float red, float green, float blue);
|
||||
void StateSetLightingEnable(bool enable);
|
||||
void StateSetVertexTextureUV(float u, float v);
|
||||
void StateSetLightColour(int light, float red, float green, float blue);
|
||||
void StateSetLightAmbientColour(float red, float green, float blue);
|
||||
void StateSetLightDirection(int light, float x, float y, float z);
|
||||
void StateSetLightEnable(int light, bool enable);
|
||||
void StateSetViewport(eViewportType viewportType);
|
||||
void StateSetEnableViewportClipPlanes(bool enable);
|
||||
void StateSetTexGenCol(int col, float x, float y, float z, float w,
|
||||
bool eyeSpace);
|
||||
void StateSetStencil(int Function, uint8_t stencil_ref,
|
||||
uint8_t stencil_func_mask, uint8_t stencil_write_mask);
|
||||
void StateSetForceLOD(int LOD);
|
||||
|
||||
// Event tracking
|
||||
void BeginEvent(LPCWSTR eventName);
|
||||
void EndEvent();
|
||||
// Event tracking
|
||||
void BeginEvent(LPCWSTR eventName);
|
||||
void EndEvent();
|
||||
|
||||
// PLM event handling
|
||||
void Suspend();
|
||||
bool Suspended();
|
||||
void Resume();
|
||||
// PLM event handling
|
||||
void Suspend();
|
||||
bool Suspended();
|
||||
void Resume();
|
||||
|
||||
// Linux window management
|
||||
bool ShouldClose();
|
||||
void Shutdown();
|
||||
// Linux window management
|
||||
bool ShouldClose();
|
||||
void Shutdown();
|
||||
};
|
||||
|
||||
|
||||
const int GL_MODELVIEW_MATRIX = 0x0BA6;
|
||||
const int GL_PROJECTION_MATRIX = 0x0BA7;
|
||||
const int GL_MODELVIEW = 0x1700;
|
||||
|
|
@ -242,8 +254,8 @@ const int GL_EYE_LINEAR = 0x2400;
|
|||
const int GL_OBJECT_PLANE = 0x2501;
|
||||
const int GL_EYE_PLANE = 0x2502;
|
||||
|
||||
|
||||
// These things are used by glEnable/glDisable so must be different and non-zero (zero is used by things we haven't assigned yet)
|
||||
// These things are used by glEnable/glDisable so must be different and non-zero
|
||||
// (zero is used by things we haven't assigned yet)
|
||||
const int GL_TEXTURE_2D = 0x0DE1;
|
||||
const int GL_BLEND = 0x0BE2;
|
||||
const int GL_CULL_FACE = 0x0B44;
|
||||
|
|
@ -286,7 +298,7 @@ const int GL_TEXTURE_WRAP_T = 0x2803;
|
|||
const int GL_NEAREST = 0x2600;
|
||||
const int GL_LINEAR = 0x2601;
|
||||
const int GL_EXP = 0x0800;
|
||||
const int GL_NEAREST_MIPMAP_LINEAR = 0x2702; // TODO - mipmapping bit of this
|
||||
const int GL_NEAREST_MIPMAP_LINEAR = 0x2702; // TODO - mipmapping bit of this
|
||||
|
||||
const int GL_CLAMP = 0x2900;
|
||||
const int GL_REPEAT = 0x2901;
|
||||
|
|
@ -312,5 +324,3 @@ const int GL_TRIANGLE_STRIP = 0x0005;
|
|||
|
||||
// Singleton
|
||||
extern C4JRender RenderManager;
|
||||
|
||||
|
||||
|
|
|
|||
12434
4J.Render/stb_image.h
|
|
@ -5,4 +5,4 @@
|
|||
#include "../Minecraft.Client/Platform/Linux/Stubs/LinuxStubs.h"
|
||||
#endif
|
||||
|
||||
#endif //_4J_RENDER_STADAFX_H
|
||||
#endif //_4J_RENDER_STADAFX_H
|
||||
|
|
@ -12,66 +12,179 @@ C4JStorage::C4JStorage() : m_pStringTable(nullptr) {}
|
|||
|
||||
void C4JStorage::Tick(void) {}
|
||||
|
||||
C4JStorage::EMessageResult C4JStorage::RequestMessageBox(UINT uiTitle, UINT uiText, UINT *uiOptionA, UINT uiOptionC, DWORD dwPad,
|
||||
int(*Func)(void *, int, const C4JStorage::EMessageResult), void *lpParam, C4JStringTable *pStringTable, WCHAR *pwchFormatString, DWORD dwFocusButton) {
|
||||
C4JStorage::EMessageResult C4JStorage::RequestMessageBox(
|
||||
unsigned int uiTitle, unsigned int uiText, unsigned int* uiOptionA,
|
||||
unsigned int uiOptionC, unsigned int pad,
|
||||
int (*Func)(void*, int, const C4JStorage::EMessageResult), void* lpParam,
|
||||
C4JStringTable* pStringTable, WCHAR* pwchFormatString,
|
||||
unsigned int focusButton) {
|
||||
return EMessage_ResultAccept;
|
||||
}
|
||||
|
||||
C4JStorage::EMessageResult C4JStorage::GetMessageBoxResult() { return EMessage_Undefined; }
|
||||
C4JStorage::EMessageResult C4JStorage::GetMessageBoxResult() {
|
||||
return EMessage_Undefined;
|
||||
}
|
||||
|
||||
bool C4JStorage::SetSaveDevice(int(*Func)(void *, const bool), void *lpParam, bool bForceResetOfSaveDevice) { return true; }
|
||||
bool C4JStorage::SetSaveDevice(int (*Func)(void*, const bool), void* lpParam,
|
||||
bool bForceResetOfSaveDevice) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void C4JStorage::Init(unsigned int uiSaveVersion, LPCWSTR pwchDefaultSaveName, char *pszSavePackName, int iMinimumSaveSize, int(*Func)(void *, const ESavingMessage, int), void *lpParam, LPCSTR szGroupID) {}
|
||||
void C4JStorage::Init(unsigned int uiSaveVersion, LPCWSTR pwchDefaultSaveName,
|
||||
char* pszSavePackName, int iMinimumSaveSize,
|
||||
int (*Func)(void*, const ESavingMessage, int),
|
||||
void* lpParam, LPCSTR szGroupID) {}
|
||||
void C4JStorage::ResetSaveData() {}
|
||||
void C4JStorage::SetDefaultSaveNameForKeyboardDisplay(LPCWSTR pwchDefaultSaveName) {}
|
||||
void C4JStorage::SetDefaultSaveNameForKeyboardDisplay(
|
||||
LPCWSTR pwchDefaultSaveName) {}
|
||||
void C4JStorage::SetSaveTitle(LPCWSTR pwchDefaultSaveName) {}
|
||||
bool C4JStorage::GetSaveUniqueNumber(INT *piVal) { if (piVal) *piVal = 0; return true; }
|
||||
bool C4JStorage::GetSaveUniqueFilename(char *pszName) { if (pszName) pszName[0] = '\0'; return true; }
|
||||
void C4JStorage::SetSaveUniqueFilename(char *szFilename) {}
|
||||
void C4JStorage::SetState(ESaveGameControlState eControlState, int(*Func)(void *, const bool), void *lpParam) {}
|
||||
bool C4JStorage::GetSaveUniqueNumber(INT* piVal) {
|
||||
if (piVal) *piVal = 0;
|
||||
return true;
|
||||
}
|
||||
bool C4JStorage::GetSaveUniqueFilename(char* pszName) {
|
||||
if (pszName) pszName[0] = '\0';
|
||||
return true;
|
||||
}
|
||||
void C4JStorage::SetSaveUniqueFilename(char* szFilename) {}
|
||||
void C4JStorage::SetState(ESaveGameControlState eControlState,
|
||||
int (*Func)(void*, const bool), void* lpParam) {}
|
||||
void C4JStorage::SetSaveDisabled(bool bDisable) {}
|
||||
bool C4JStorage::GetSaveDisabled(void) { return false; }
|
||||
unsigned int C4JStorage::GetSaveSize() { return 0; }
|
||||
void C4JStorage::GetSaveData(void *pvData, unsigned int *puiBytes) { if (puiBytes) *puiBytes = 0; }
|
||||
PVOID C4JStorage::AllocateSaveData(unsigned int uiBytes) { return malloc(uiBytes); }
|
||||
void C4JStorage::SetSaveImages(PBYTE pbThumbnail, DWORD dwThumbnailBytes, PBYTE pbImage, DWORD dwImageBytes, PBYTE pbTextData, DWORD dwTextDataBytes) {}
|
||||
C4JStorage::ESaveGameState C4JStorage::SaveSaveData(int(*Func)(void *, const bool), void *lpParam) { return ESaveGame_Idle; }
|
||||
void C4JStorage::CopySaveDataToNewSave(PBYTE pbThumbnail, DWORD cbThumbnail, WCHAR *wchNewName, int(*Func)(void *lpParam, bool), void *lpParam) {}
|
||||
void C4JStorage::GetSaveData(void* pvData, unsigned int* puiBytes) {
|
||||
if (puiBytes) *puiBytes = 0;
|
||||
}
|
||||
PVOID C4JStorage::AllocateSaveData(unsigned int uiBytes) {
|
||||
return malloc(uiBytes);
|
||||
}
|
||||
void C4JStorage::SetSaveImages(std::uint8_t* pbThumbnail,
|
||||
unsigned int thumbnailBytes,
|
||||
std::uint8_t* pbImage,
|
||||
unsigned int imageBytes,
|
||||
std::uint8_t* pbTextData,
|
||||
unsigned int textDataBytes) {}
|
||||
C4JStorage::ESaveGameState C4JStorage::SaveSaveData(int (*Func)(void*,
|
||||
const bool),
|
||||
void* lpParam) {
|
||||
return ESaveGame_Idle;
|
||||
}
|
||||
void C4JStorage::CopySaveDataToNewSave(std::uint8_t* pbThumbnail,
|
||||
unsigned int cbThumbnail,
|
||||
WCHAR* wchNewName,
|
||||
int (*Func)(void* lpParam, bool),
|
||||
void* lpParam) {}
|
||||
void C4JStorage::SetSaveDeviceSelected(unsigned int uiPad, bool bSelected) {}
|
||||
bool C4JStorage::GetSaveDeviceSelected(unsigned int iPad) { return true; }
|
||||
C4JStorage::ESaveGameState C4JStorage::DoesSaveExist(bool *pbExists) { if (pbExists) *pbExists = false; return ESaveGame_Idle; }
|
||||
C4JStorage::ESaveGameState C4JStorage::DoesSaveExist(bool* pbExists) {
|
||||
if (pbExists) *pbExists = false;
|
||||
return ESaveGame_Idle;
|
||||
}
|
||||
bool C4JStorage::EnoughSpaceForAMinSaveGame() { return true; }
|
||||
void C4JStorage::SetSaveMessageVPosition(float fY) {}
|
||||
C4JStorage::ESaveGameState C4JStorage::GetSavesInfo(int iPad, int(*Func)(void *lpParam, SAVE_DETAILS *pSaveDetails, const bool), void *lpParam, char *pszSavePackName) { return ESaveGame_Idle; }
|
||||
C4JStorage::ESaveGameState C4JStorage::GetSavesInfo(
|
||||
int iPad,
|
||||
int (*Func)(void* lpParam, SAVE_DETAILS* pSaveDetails, const bool),
|
||||
void* lpParam, char* pszSavePackName) {
|
||||
return ESaveGame_Idle;
|
||||
}
|
||||
PSAVE_DETAILS C4JStorage::ReturnSavesInfo() { return nullptr; }
|
||||
void C4JStorage::ClearSavesInfo() {}
|
||||
C4JStorage::ESaveGameState C4JStorage::LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo, int(*Func)(void *lpParam, std::uint8_t *thumbnailData, unsigned int thumbnailBytes), void *lpParam) { return ESaveGame_Idle; }
|
||||
void C4JStorage::GetSaveCacheFileInfo(DWORD dwFile, XCONTENT_DATA &xContentData) { memset(&xContentData, 0, sizeof(xContentData)); }
|
||||
void C4JStorage::GetSaveCacheFileInfo(DWORD dwFile, PBYTE *ppbImageData, DWORD *pdwImageBytes) { if (ppbImageData) *ppbImageData = nullptr; if (pdwImageBytes) *pdwImageBytes = 0; }
|
||||
C4JStorage::ESaveGameState C4JStorage::LoadSaveData(PSAVE_INFO pSaveInfo, int(*Func)(void *lpParam, const bool, const bool), void *lpParam) { return ESaveGame_Idle; }
|
||||
C4JStorage::ESaveGameState C4JStorage::DeleteSaveData(PSAVE_INFO pSaveInfo, int(*Func)(void *lpParam, const bool), void *lpParam) { return ESaveGame_Idle; }
|
||||
void C4JStorage::RegisterMarketplaceCountsCallback(int(*Func)(void *lpParam, C4JStorage::DLC_TMS_DETAILS *, int), void *lpParam) {}
|
||||
void C4JStorage::SetDLCPackageRoot(char *pszDLCRoot) {}
|
||||
C4JStorage::EDLCStatus C4JStorage::GetDLCOffers(int iPad, int(*Func)(void *, int, std::uint32_t, int), void *lpParam, DWORD dwOfferTypesBitmask) { return EDLC_NoOffers; }
|
||||
DWORD C4JStorage::CancelGetDLCOffers() { return 0; }
|
||||
C4JStorage::ESaveGameState C4JStorage::LoadSaveDataThumbnail(
|
||||
PSAVE_INFO pSaveInfo,
|
||||
int (*Func)(void* lpParam, std::uint8_t* thumbnailData,
|
||||
unsigned int thumbnailBytes),
|
||||
void* lpParam) {
|
||||
return ESaveGame_Idle;
|
||||
}
|
||||
void C4JStorage::GetSaveCacheFileInfo(unsigned int fileIndex,
|
||||
XCONTENT_DATA& xContentData) {
|
||||
memset(&xContentData, 0, sizeof(xContentData));
|
||||
}
|
||||
void C4JStorage::GetSaveCacheFileInfo(unsigned int fileIndex,
|
||||
std::uint8_t** ppbImageData,
|
||||
unsigned int* pImageBytes) {
|
||||
if (ppbImageData) *ppbImageData = nullptr;
|
||||
if (pImageBytes) *pImageBytes = 0;
|
||||
}
|
||||
C4JStorage::ESaveGameState C4JStorage::LoadSaveData(
|
||||
PSAVE_INFO pSaveInfo, int (*Func)(void* lpParam, const bool, const bool),
|
||||
void* lpParam) {
|
||||
return ESaveGame_Idle;
|
||||
}
|
||||
C4JStorage::ESaveGameState C4JStorage::DeleteSaveData(PSAVE_INFO pSaveInfo,
|
||||
int (*Func)(void* lpParam,
|
||||
const bool),
|
||||
void* lpParam) {
|
||||
return ESaveGame_Idle;
|
||||
}
|
||||
void C4JStorage::RegisterMarketplaceCountsCallback(
|
||||
int (*Func)(void* lpParam, C4JStorage::DLC_TMS_DETAILS*, int),
|
||||
void* lpParam) {}
|
||||
void C4JStorage::SetDLCPackageRoot(char* pszDLCRoot) {}
|
||||
C4JStorage::EDLCStatus C4JStorage::GetDLCOffers(
|
||||
int iPad, int (*Func)(void*, int, std::uint32_t, int), void* lpParam,
|
||||
std::uint32_t dwOfferTypesBitmask) {
|
||||
return EDLC_NoOffers;
|
||||
}
|
||||
unsigned int C4JStorage::CancelGetDLCOffers() { return 0; }
|
||||
void C4JStorage::ClearDLCOffers() {}
|
||||
XMARKETPLACE_CONTENTOFFER_INFO& C4JStorage::GetOffer(DWORD dw) { return s_dummyOffer; }
|
||||
XMARKETPLACE_CONTENTOFFER_INFO& C4JStorage::GetOffer(unsigned int dw) {
|
||||
return s_dummyOffer;
|
||||
}
|
||||
int C4JStorage::GetOfferCount() { return 0; }
|
||||
DWORD C4JStorage::InstallOffer(int iOfferIDC, __uint64 *ullOfferIDA, int(*Func)(void *, int, int), void *lpParam, bool bTrial) { return 0; }
|
||||
DWORD C4JStorage::GetAvailableDLCCount(int iPad) { return 0; }
|
||||
C4JStorage::EDLCStatus C4JStorage::GetInstalledDLC(int iPad, int(*Func)(void *, int, int), void *lpParam) { return EDLC_NoInstalledDLC; }
|
||||
XCONTENT_DATA& C4JStorage::GetDLC(DWORD dw) { return s_dummyContentData; }
|
||||
std::uint32_t C4JStorage::MountInstalledDLC(int iPad, std::uint32_t dwDLC, int(*Func)(void *, int, std::uint32_t, std::uint32_t), void *lpParam, LPCSTR szMountDrive) { return 0; }
|
||||
DWORD C4JStorage::UnmountInstalledDLC(LPCSTR szMountDrive) { return 0; }
|
||||
void C4JStorage::GetMountedDLCFileList(const char *szMountDrive, std::vector<std::string> &fileList) { fileList.clear(); }
|
||||
unsigned int C4JStorage::InstallOffer(int iOfferIDC, __uint64* ullOfferIDA,
|
||||
int (*Func)(void*, int, int),
|
||||
void* lpParam, bool bTrial) {
|
||||
return 0;
|
||||
}
|
||||
unsigned int C4JStorage::GetAvailableDLCCount(int iPad) { return 0; }
|
||||
C4JStorage::EDLCStatus C4JStorage::GetInstalledDLC(int iPad,
|
||||
int (*Func)(void*, int, int),
|
||||
void* lpParam) {
|
||||
if (Func) {
|
||||
Func(lpParam, 0, iPad);
|
||||
}
|
||||
return EDLC_NoInstalledDLC;
|
||||
}
|
||||
XCONTENT_DATA& C4JStorage::GetDLC(unsigned int dw) { return s_dummyContentData; }
|
||||
std::uint32_t C4JStorage::MountInstalledDLC(
|
||||
int iPad, std::uint32_t dwDLC,
|
||||
int (*Func)(void*, int, std::uint32_t, std::uint32_t), void* lpParam,
|
||||
LPCSTR szMountDrive) {
|
||||
return 0;
|
||||
}
|
||||
unsigned int C4JStorage::UnmountInstalledDLC(LPCSTR szMountDrive) { return 0; }
|
||||
void C4JStorage::GetMountedDLCFileList(const char* szMountDrive,
|
||||
std::vector<std::string>& fileList) {
|
||||
fileList.clear();
|
||||
}
|
||||
std::string C4JStorage::GetMountedPath(std::string szMount) { return ""; }
|
||||
C4JStorage::ETMSStatus C4JStorage::ReadTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, C4JStorage::eTMS_FileType eFileType,
|
||||
WCHAR *pwchFilename, BYTE **ppBuffer, DWORD *pdwBufferSize, int(*Func)(void *, WCHAR *, int, bool, int), void *lpParam, int iAction) { return ETMSStatus_Fail; }
|
||||
bool C4JStorage::WriteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, WCHAR *pwchFilename, BYTE *pBuffer, DWORD dwBufferSize) { return false; }
|
||||
bool C4JStorage::DeleteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, WCHAR *pwchFilename) { return false; }
|
||||
void C4JStorage::StoreTMSPathName(WCHAR *pwchName) {}
|
||||
C4JStorage::ETMSStatus C4JStorage::TMSPP_ReadFile(int iPad, C4JStorage::eGlobalStorage eStorageFacility, C4JStorage::eTMS_FILETYPEVAL eFileTypeVal, LPCSTR szFilename, int(*Func)(void *, int, int, PTMSPP_FILEDATA, LPCSTR), void *lpParam, int iUserData) { return ETMSStatus_Fail; }
|
||||
unsigned int C4JStorage::CRC(unsigned char *buf, int len) {
|
||||
C4JStorage::ETMSStatus C4JStorage::ReadTMSFile(
|
||||
int iQuadrant, eGlobalStorage eStorageFacility,
|
||||
C4JStorage::eTMS_FileType eFileType, WCHAR* pwchFilename,
|
||||
std::uint8_t** ppBuffer, unsigned int* pBufferSize,
|
||||
int (*Func)(void*, WCHAR*, int, bool, int), void* lpParam, int iAction) {
|
||||
return ETMSStatus_Fail;
|
||||
}
|
||||
bool C4JStorage::WriteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility,
|
||||
WCHAR* pwchFilename, std::uint8_t* pBuffer,
|
||||
unsigned int bufferSize) {
|
||||
return false;
|
||||
}
|
||||
bool C4JStorage::DeleteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility,
|
||||
WCHAR* pwchFilename) {
|
||||
return false;
|
||||
}
|
||||
void C4JStorage::StoreTMSPathName(WCHAR* pwchName) {}
|
||||
C4JStorage::ETMSStatus C4JStorage::TMSPP_ReadFile(
|
||||
int iPad, C4JStorage::eGlobalStorage eStorageFacility,
|
||||
C4JStorage::eTMS_FILETYPEVAL eFileTypeVal, LPCSTR szFilename,
|
||||
int (*Func)(void*, int, int, PTMSPP_FILEDATA, LPCSTR), void* lpParam,
|
||||
int iUserData) {
|
||||
return ETMSStatus_Fail;
|
||||
}
|
||||
unsigned int C4JStorage::CRC(unsigned char* buf, int len) {
|
||||
unsigned int crc = 0xFFFFFFFF;
|
||||
for (int i = 0; i < len; i++) {
|
||||
crc ^= buf[i];
|
||||
|
|
@ -82,11 +195,26 @@ unsigned int C4JStorage::CRC(unsigned char *buf, int len) {
|
|||
return ~crc;
|
||||
}
|
||||
|
||||
int C4JStorage::AddSubfile(int regionIndex) { (void)regionIndex; return 0; }
|
||||
int C4JStorage::AddSubfile(int regionIndex) {
|
||||
(void)regionIndex;
|
||||
return 0;
|
||||
}
|
||||
unsigned int C4JStorage::GetSubfileCount() { return 0; }
|
||||
void C4JStorage::GetSubfileDetails(unsigned int i, int* regionIndex, void** data, unsigned int* size) { (void)i; if(regionIndex) *regionIndex=0; if(data) *data=0; if(size) *size=0; }
|
||||
void C4JStorage::GetSubfileDetails(unsigned int i, int* regionIndex,
|
||||
void** data, unsigned int* size) {
|
||||
(void)i;
|
||||
if (regionIndex) *regionIndex = 0;
|
||||
if (data) *data = 0;
|
||||
if (size) *size = 0;
|
||||
}
|
||||
void C4JStorage::ResetSubfiles() {}
|
||||
void C4JStorage::UpdateSubfile(int index, void* data, unsigned int size) { (void)index; (void)data; (void)size; }
|
||||
void C4JStorage::SaveSubfiles(int (*Func)(void*, const bool), void* param) { if(Func) Func(param, true); }
|
||||
void C4JStorage::UpdateSubfile(int index, void* data, unsigned int size) {
|
||||
(void)index;
|
||||
(void)data;
|
||||
(void)size;
|
||||
}
|
||||
void C4JStorage::SaveSubfiles(int (*Func)(void*, const bool), void* param) {
|
||||
if (Func) Func(param, true);
|
||||
}
|
||||
C4JStorage::ESaveGameState C4JStorage::GetSaveState() { return ESaveGame_Idle; }
|
||||
void C4JStorage::ContinueIncompleteOperation() {}
|
||||
|
|
|
|||
|
|
@ -1,354 +1,386 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
//#include <xtms.h>
|
||||
// #include <xtms.h>
|
||||
|
||||
class C4JStringTable;
|
||||
|
||||
#define MAX_DISPLAYNAME_LENGTH 128 // CELL_SAVEDATA_SYSP_SUBTITLE_SIZE on PS3
|
||||
#define MAX_DETAILS_LENGTH 128 // CELL_SAVEDATA_SYSP_SUBTITLE_SIZE on PS3
|
||||
#define MAX_SAVEFILENAME_LENGTH 32 // CELL_SAVEDATA_DIRNAME_SIZE
|
||||
#define MAX_DISPLAYNAME_LENGTH 128 // CELL_SAVEDATA_SYSP_SUBTITLE_SIZE on PS3
|
||||
#define MAX_DETAILS_LENGTH 128 // CELL_SAVEDATA_SYSP_SUBTITLE_SIZE on PS3
|
||||
#define MAX_SAVEFILENAME_LENGTH 32 // CELL_SAVEDATA_DIRNAME_SIZE
|
||||
|
||||
typedef struct
|
||||
{
|
||||
time_t modifiedTime;
|
||||
unsigned int dataSize;
|
||||
unsigned int thumbnailSize;
|
||||
}
|
||||
CONTAINER_METADATA;
|
||||
typedef struct {
|
||||
time_t modifiedTime;
|
||||
unsigned int dataSize;
|
||||
unsigned int thumbnailSize;
|
||||
} CONTAINER_METADATA;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char UTF8SaveFilename[MAX_SAVEFILENAME_LENGTH];
|
||||
char UTF8SaveTitle[MAX_DISPLAYNAME_LENGTH];
|
||||
CONTAINER_METADATA metaData;
|
||||
PBYTE thumbnailData;
|
||||
}
|
||||
SAVE_INFO,*PSAVE_INFO;
|
||||
typedef struct {
|
||||
char UTF8SaveFilename[MAX_SAVEFILENAME_LENGTH];
|
||||
char UTF8SaveTitle[MAX_DISPLAYNAME_LENGTH];
|
||||
CONTAINER_METADATA metaData;
|
||||
std::uint8_t* thumbnailData;
|
||||
} SAVE_INFO, *PSAVE_INFO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int iSaveC;
|
||||
PSAVE_INFO SaveInfoA;
|
||||
}
|
||||
SAVE_DETAILS,*PSAVE_DETAILS;
|
||||
typedef struct {
|
||||
int iSaveC;
|
||||
PSAVE_INFO SaveInfoA;
|
||||
} SAVE_DETAILS, *PSAVE_DETAILS;
|
||||
|
||||
typedef std::vector <PXMARKETPLACE_CONTENTOFFER_INFO> OfferDataArray;
|
||||
typedef std::vector <PXCONTENT_DATA> XContentDataArray;
|
||||
//typedef std::vector <PSAVE_DETAILS> SaveDetailsArray;
|
||||
typedef std::vector<PXMARKETPLACE_CONTENTOFFER_INFO> OfferDataArray;
|
||||
typedef std::vector<PXCONTENT_DATA> XContentDataArray;
|
||||
// typedef std::vector <PSAVE_DETAILS> SaveDetailsArray;
|
||||
|
||||
// Current version of the dlc data creator
|
||||
#define CURRENT_DLC_VERSION_NUM 3
|
||||
|
||||
class C4JStorage
|
||||
{
|
||||
|
||||
class C4JStorage {
|
||||
public:
|
||||
// Structs defined in the DLC_Creator, but added here to be used in the app
|
||||
typedef struct
|
||||
{
|
||||
unsigned int uiFileSize;
|
||||
DWORD dwType;
|
||||
DWORD dwWchCount; // count of WCHAR in next array
|
||||
WCHAR wchFile[1];
|
||||
}
|
||||
DLC_FILE_DETAILS, *PDLC_FILE_DETAILS;
|
||||
// Structs defined in the DLC_Creator, but added here to be used in the app
|
||||
typedef struct {
|
||||
unsigned int uiFileSize;
|
||||
std::uint32_t dwType;
|
||||
std::uint32_t dwWchCount; // count of WCHAR in next array
|
||||
WCHAR wchFile[1];
|
||||
} DLC_FILE_DETAILS, *PDLC_FILE_DETAILS;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwType;
|
||||
DWORD dwWchCount; // count of WCHAR in next array;
|
||||
WCHAR wchData[1]; // will be an array of size dwBytes
|
||||
}
|
||||
DLC_FILE_PARAM, *PDLC_FILE_PARAM;
|
||||
// End of DLC_Creator structs
|
||||
typedef struct {
|
||||
std::uint32_t dwType;
|
||||
std::uint32_t dwWchCount; // count of WCHAR in next array;
|
||||
WCHAR wchData[1]; // will be an array of size dwBytes
|
||||
} DLC_FILE_PARAM, *PDLC_FILE_PARAM;
|
||||
// End of DLC_Creator structs
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WCHAR wchDisplayName[XCONTENT_MAX_DISPLAYNAME_LENGTH];
|
||||
CHAR szFileName[XCONTENT_MAX_FILENAME_LENGTH];
|
||||
DWORD dwImageOffset;
|
||||
DWORD dwImageBytes;
|
||||
}
|
||||
CACHEINFOSTRUCT;
|
||||
typedef struct {
|
||||
WCHAR wchDisplayName[XCONTENT_MAX_DISPLAYNAME_LENGTH];
|
||||
CHAR szFileName[XCONTENT_MAX_FILENAME_LENGTH];
|
||||
std::uint32_t dwImageOffset;
|
||||
std::uint32_t dwImageBytes;
|
||||
} CACHEINFOSTRUCT;
|
||||
|
||||
// structure to hold DLC info in TMS
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwVersion;
|
||||
DWORD dwNewOffers;
|
||||
DWORD dwTotalOffers;
|
||||
DWORD dwInstalledTotalOffers;
|
||||
BYTE bPadding[1024-sizeof(DWORD)*4]; // future expansion
|
||||
}
|
||||
DLC_TMS_DETAILS;
|
||||
// structure to hold DLC info in TMS
|
||||
typedef struct {
|
||||
std::uint32_t dwVersion;
|
||||
std::uint32_t dwNewOffers;
|
||||
std::uint32_t dwTotalOffers;
|
||||
std::uint32_t dwInstalledTotalOffers;
|
||||
std::uint8_t bPadding[1024 - sizeof(std::uint32_t) * 4];
|
||||
// future expansion
|
||||
} DLC_TMS_DETAILS;
|
||||
|
||||
enum eGTS_FileTypes
|
||||
{
|
||||
eGTS_Type_Skin=0,
|
||||
eGTS_Type_Cape,
|
||||
eGTS_Type_MAX
|
||||
};
|
||||
enum eGTS_FileTypes { eGTS_Type_Skin = 0, eGTS_Type_Cape, eGTS_Type_MAX };
|
||||
|
||||
enum eGlobalStorage
|
||||
{
|
||||
//eGlobalStorage_GameClip=0,
|
||||
eGlobalStorage_Title=0,
|
||||
eGlobalStorage_TitleUser,
|
||||
eGlobalStorage_Max
|
||||
};
|
||||
enum eGlobalStorage {
|
||||
// eGlobalStorage_GameClip=0,
|
||||
eGlobalStorage_Title = 0,
|
||||
eGlobalStorage_TitleUser,
|
||||
eGlobalStorage_Max
|
||||
};
|
||||
|
||||
enum EMessageResult
|
||||
{
|
||||
EMessage_Undefined=0,
|
||||
EMessage_Busy,
|
||||
EMessage_Pending,
|
||||
EMessage_Cancelled,
|
||||
EMessage_ResultAccept,
|
||||
EMessage_ResultDecline,
|
||||
EMessage_ResultThirdOption,
|
||||
EMessage_ResultFourthOption
|
||||
};
|
||||
enum EMessageResult {
|
||||
EMessage_Undefined = 0,
|
||||
EMessage_Busy,
|
||||
EMessage_Pending,
|
||||
EMessage_Cancelled,
|
||||
EMessage_ResultAccept,
|
||||
EMessage_ResultDecline,
|
||||
EMessage_ResultThirdOption,
|
||||
EMessage_ResultFourthOption
|
||||
};
|
||||
|
||||
enum ESaveGameControlState
|
||||
{
|
||||
ESaveGameControl_Idle=0,
|
||||
ESaveGameControl_Save,
|
||||
ESaveGameControl_InternalRequestingDevice,
|
||||
ESaveGameControl_InternalGetSaveName,
|
||||
ESaveGameControl_InternalSaving,
|
||||
ESaveGameControl_CopySave,
|
||||
ESaveGameControl_CopyingSave,
|
||||
};
|
||||
enum ESaveGameControlState {
|
||||
ESaveGameControl_Idle = 0,
|
||||
ESaveGameControl_Save,
|
||||
ESaveGameControl_InternalRequestingDevice,
|
||||
ESaveGameControl_InternalGetSaveName,
|
||||
ESaveGameControl_InternalSaving,
|
||||
ESaveGameControl_CopySave,
|
||||
ESaveGameControl_CopyingSave,
|
||||
};
|
||||
|
||||
enum ESaveGameState
|
||||
{
|
||||
ESaveGame_Idle=0,
|
||||
ESaveGame_Save,
|
||||
ESaveGame_InternalRequestingDevice,
|
||||
ESaveGame_InternalGetSaveName,
|
||||
ESaveGame_InternalSaving,
|
||||
ESaveGame_CopySave,
|
||||
ESaveGame_CopyingSave,
|
||||
ESaveGame_Load,
|
||||
ESaveGame_GetSavesInfo,
|
||||
ESaveGame_Rename,
|
||||
ESaveGame_Delete,
|
||||
enum ESaveGameState {
|
||||
ESaveGame_Idle = 0,
|
||||
ESaveGame_Save,
|
||||
ESaveGame_InternalRequestingDevice,
|
||||
ESaveGame_InternalGetSaveName,
|
||||
ESaveGame_InternalSaving,
|
||||
ESaveGame_CopySave,
|
||||
ESaveGame_CopyingSave,
|
||||
ESaveGame_Load,
|
||||
ESaveGame_GetSavesInfo,
|
||||
ESaveGame_Rename,
|
||||
ESaveGame_Delete,
|
||||
|
||||
ESaveGame_GetSaveThumbnail // Not used as an actual state in the PS4, but the game expects this to be returned to indicate success when getting a thumbnail
|
||||
ESaveGame_GetSaveThumbnail // Not used as an actual state in the PS4,
|
||||
// but the game expects this to be returned
|
||||
// to indicate success when getting a
|
||||
// thumbnail
|
||||
|
||||
};
|
||||
enum ELoadGameStatus
|
||||
{
|
||||
ELoadGame_Idle=0,
|
||||
ELoadGame_InProgress,
|
||||
ELoadGame_NoSaves,
|
||||
ELoadGame_ChangedDevice,
|
||||
ELoadGame_DeviceRemoved
|
||||
};
|
||||
};
|
||||
enum ELoadGameStatus {
|
||||
ELoadGame_Idle = 0,
|
||||
ELoadGame_InProgress,
|
||||
ELoadGame_NoSaves,
|
||||
ELoadGame_ChangedDevice,
|
||||
ELoadGame_DeviceRemoved
|
||||
};
|
||||
|
||||
enum EDeleteGameStatus
|
||||
{
|
||||
EDeleteGame_Idle=0,
|
||||
EDeleteGame_InProgress,
|
||||
};
|
||||
enum EDeleteGameStatus {
|
||||
EDeleteGame_Idle = 0,
|
||||
EDeleteGame_InProgress,
|
||||
};
|
||||
|
||||
enum ESGIStatus {
|
||||
ESGIStatus_Error = 0,
|
||||
ESGIStatus_Idle,
|
||||
ESGIStatus_ReadInProgress,
|
||||
ESGIStatus_NoSaves,
|
||||
};
|
||||
|
||||
enum ESGIStatus
|
||||
{
|
||||
ESGIStatus_Error=0,
|
||||
ESGIStatus_Idle,
|
||||
ESGIStatus_ReadInProgress,
|
||||
ESGIStatus_NoSaves,
|
||||
};
|
||||
enum EDLCStatus {
|
||||
EDLC_Error = 0,
|
||||
EDLC_Idle,
|
||||
EDLC_NoOffers,
|
||||
EDLC_AlreadyEnumeratedAllOffers,
|
||||
EDLC_NoInstalledDLC,
|
||||
EDLC_Pending,
|
||||
EDLC_LoadInProgress,
|
||||
EDLC_Loaded,
|
||||
EDLC_ChangedDevice
|
||||
};
|
||||
|
||||
enum EDLCStatus
|
||||
{
|
||||
EDLC_Error=0,
|
||||
EDLC_Idle,
|
||||
EDLC_NoOffers,
|
||||
EDLC_AlreadyEnumeratedAllOffers,
|
||||
EDLC_NoInstalledDLC,
|
||||
EDLC_Pending,
|
||||
EDLC_LoadInProgress,
|
||||
EDLC_Loaded,
|
||||
EDLC_ChangedDevice
|
||||
};
|
||||
enum ESavingMessage {
|
||||
ESavingMessage_None = 0,
|
||||
ESavingMessage_Short,
|
||||
ESavingMessage_Long
|
||||
};
|
||||
|
||||
enum ESavingMessage
|
||||
{
|
||||
ESavingMessage_None=0,
|
||||
ESavingMessage_Short,
|
||||
ESavingMessage_Long
|
||||
};
|
||||
enum ETMSStatus {
|
||||
ETMSStatus_Idle = 0,
|
||||
ETMSStatus_Fail,
|
||||
ETMSStatus_Fail_ReadInProgress,
|
||||
ETMSStatus_Fail_WriteInProgress,
|
||||
ETMSStatus_Pending,
|
||||
};
|
||||
|
||||
enum ETMSStatus
|
||||
{
|
||||
ETMSStatus_Idle=0,
|
||||
ETMSStatus_Fail,
|
||||
ETMSStatus_Fail_ReadInProgress,
|
||||
ETMSStatus_Fail_WriteInProgress,
|
||||
ETMSStatus_Pending,
|
||||
};
|
||||
enum eTMS_FileType {
|
||||
eTMS_FileType_Normal = 0,
|
||||
eTMS_FileType_Graphic,
|
||||
};
|
||||
|
||||
enum eTMS_FileType
|
||||
{
|
||||
eTMS_FileType_Normal=0,
|
||||
eTMS_FileType_Graphic,
|
||||
};
|
||||
enum eTMS_FILETYPEVAL {
|
||||
TMS_FILETYPE_BINARY,
|
||||
TMS_FILETYPE_CONFIG,
|
||||
TMS_FILETYPE_JSON,
|
||||
TMS_FILETYPE_MAX
|
||||
};
|
||||
enum eTMS_UGCTYPE { TMS_UGCTYPE_NONE, TMS_UGCTYPE_IMAGE, TMS_UGCTYPE_MAX };
|
||||
|
||||
enum eTMS_FILETYPEVAL
|
||||
{
|
||||
TMS_FILETYPE_BINARY,
|
||||
TMS_FILETYPE_CONFIG,
|
||||
TMS_FILETYPE_JSON,
|
||||
TMS_FILETYPE_MAX
|
||||
};
|
||||
enum eTMS_UGCTYPE
|
||||
{
|
||||
TMS_UGCTYPE_NONE,
|
||||
TMS_UGCTYPE_IMAGE,
|
||||
TMS_UGCTYPE_MAX
|
||||
};
|
||||
typedef struct {
|
||||
CHAR szFilename[256];
|
||||
int iFileSize;
|
||||
eTMS_FILETYPEVAL eFileTypeVal;
|
||||
} TMSPP_FILE_DETAILS, *PTMSPP_FILE_DETAILS;
|
||||
|
||||
typedef struct {
|
||||
int iCount;
|
||||
PTMSPP_FILE_DETAILS FileDetailsA;
|
||||
} TMSPP_FILE_LIST, *PTMSPP_FILE_LIST;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CHAR szFilename[256];
|
||||
int iFileSize;
|
||||
eTMS_FILETYPEVAL eFileTypeVal;
|
||||
}
|
||||
TMSPP_FILE_DETAILS, *PTMSPP_FILE_DETAILS;
|
||||
typedef struct {
|
||||
unsigned int size;
|
||||
std::uint8_t* pbData;
|
||||
} TMSPP_FILEDATA, *PTMSPP_FILEDATA;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int iCount;
|
||||
PTMSPP_FILE_DETAILS FileDetailsA;
|
||||
}
|
||||
TMSPP_FILE_LIST, *PTMSPP_FILE_LIST;
|
||||
C4JStorage();
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwSize;
|
||||
PBYTE pbData;
|
||||
}
|
||||
TMSPP_FILEDATA, *PTMSPP_FILEDATA;
|
||||
void Tick(void);
|
||||
|
||||
// Messages
|
||||
C4JStorage::EMessageResult RequestMessageBox(
|
||||
unsigned int uiTitle, unsigned int uiText, unsigned int* uiOptionA,
|
||||
unsigned int uiOptionC, unsigned int pad = XUSER_INDEX_ANY,
|
||||
int (*Func)(void*, int, const C4JStorage::EMessageResult) = NULL,
|
||||
void* lpParam = NULL, C4JStringTable* pStringTable = NULL,
|
||||
WCHAR* pwchFormatString = NULL, unsigned int focusButton = 0);
|
||||
|
||||
C4JStorage();
|
||||
C4JStorage::EMessageResult GetMessageBoxResult();
|
||||
|
||||
void Tick(void);
|
||||
// save device
|
||||
bool SetSaveDevice(int (*Func)(void*, const bool), void* lpParam,
|
||||
bool bForceResetOfSaveDevice = false);
|
||||
|
||||
// Messages
|
||||
C4JStorage::EMessageResult RequestMessageBox(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad=XUSER_INDEX_ANY,
|
||||
int( *Func)(void *,int,const C4JStorage::EMessageResult)=NULL,void *lpParam=NULL, C4JStringTable *pStringTable=NULL, WCHAR *pwchFormatString=NULL,DWORD dwFocusButton=0);
|
||||
// savegame
|
||||
void Init(unsigned int uiSaveVersion, LPCWSTR pwchDefaultSaveName,
|
||||
char* pszSavePackName, int iMinimumSaveSize,
|
||||
int (*Func)(void*, const ESavingMessage, int), void* lpParam,
|
||||
LPCSTR szGroupID);
|
||||
void ResetSaveData(); // Call before a new save to clear out stored save
|
||||
// file name
|
||||
void SetDefaultSaveNameForKeyboardDisplay(LPCWSTR pwchDefaultSaveName);
|
||||
void SetSaveTitle(LPCWSTR pwchDefaultSaveName);
|
||||
bool GetSaveUniqueNumber(INT* piVal);
|
||||
bool GetSaveUniqueFilename(char* pszName);
|
||||
void SetSaveUniqueFilename(char* szFilename);
|
||||
void SetState(ESaveGameControlState eControlState,
|
||||
int (*Func)(void*, const bool), void* lpParam);
|
||||
void SetSaveDisabled(bool bDisable);
|
||||
bool GetSaveDisabled(void);
|
||||
unsigned int GetSaveSize();
|
||||
void GetSaveData(void* pvData, unsigned int* puiBytes);
|
||||
PVOID AllocateSaveData(unsigned int uiBytes);
|
||||
void SetSaveImages(
|
||||
std::uint8_t* pbThumbnail, unsigned int thumbnailBytes,
|
||||
std::uint8_t* pbImage, unsigned int imageBytes,
|
||||
std::uint8_t* pbTextData,
|
||||
unsigned int textDataBytes); // Sets the thumbnail & image for the
|
||||
// save, optionally setting the
|
||||
// metadata in the png
|
||||
C4JStorage::ESaveGameState SaveSaveData(int (*Func)(void*, const bool),
|
||||
void* lpParam);
|
||||
void CopySaveDataToNewSave(std::uint8_t* pbThumbnail,
|
||||
unsigned int cbThumbnail, WCHAR* wchNewName,
|
||||
int (*Func)(void* lpParam, bool), void* lpParam);
|
||||
void SetSaveDeviceSelected(unsigned int uiPad, bool bSelected);
|
||||
bool GetSaveDeviceSelected(unsigned int iPad);
|
||||
C4JStorage::ESaveGameState DoesSaveExist(bool* pbExists);
|
||||
bool EnoughSpaceForAMinSaveGame();
|
||||
|
||||
void SetSaveMessageVPosition(
|
||||
float fY); // The 'Saving' message will display at a default position
|
||||
// unless changed
|
||||
// Get the info for the saves
|
||||
C4JStorage::ESaveGameState GetSavesInfo(
|
||||
int iPad,
|
||||
int (*Func)(void* lpParam, SAVE_DETAILS* pSaveDetails, const bool),
|
||||
void* lpParam, char* pszSavePackName);
|
||||
PSAVE_DETAILS ReturnSavesInfo();
|
||||
void ClearSavesInfo(); // Clears results
|
||||
C4JStorage::ESaveGameState LoadSaveDataThumbnail(
|
||||
PSAVE_INFO pSaveInfo,
|
||||
int (*Func)(void* lpParam, std::uint8_t* thumbnailData,
|
||||
unsigned int thumbnailBytes),
|
||||
void* lpParam); // Get the thumbnail for an individual save referenced
|
||||
// by pSaveInfo
|
||||
|
||||
C4JStorage::EMessageResult GetMessageBoxResult();
|
||||
void GetSaveCacheFileInfo(unsigned int fileIndex, XCONTENT_DATA& xContentData);
|
||||
void GetSaveCacheFileInfo(unsigned int fileIndex,
|
||||
std::uint8_t** ppbImageData,
|
||||
unsigned int* pImageBytes);
|
||||
|
||||
// save device
|
||||
bool SetSaveDevice(int( *Func)(void *,const bool),void *lpParam, bool bForceResetOfSaveDevice=false);
|
||||
// Load the save. Need to call GetSaveData once the callback is called
|
||||
C4JStorage::ESaveGameState LoadSaveData(PSAVE_INFO pSaveInfo,
|
||||
int (*Func)(void* lpParam,
|
||||
const bool, const bool),
|
||||
void* lpParam);
|
||||
C4JStorage::ESaveGameState DeleteSaveData(PSAVE_INFO pSaveInfo,
|
||||
int (*Func)(void* lpParam,
|
||||
const bool),
|
||||
void* lpParam);
|
||||
|
||||
// savegame
|
||||
void Init(unsigned int uiSaveVersion,LPCWSTR pwchDefaultSaveName,char *pszSavePackName,int iMinimumSaveSize,int( *Func)(void *, const ESavingMessage, int),void *lpParam,LPCSTR szGroupID);
|
||||
void ResetSaveData(); // Call before a new save to clear out stored save file name
|
||||
void SetDefaultSaveNameForKeyboardDisplay(LPCWSTR pwchDefaultSaveName);
|
||||
void SetSaveTitle(LPCWSTR pwchDefaultSaveName);
|
||||
bool GetSaveUniqueNumber(INT *piVal);
|
||||
bool GetSaveUniqueFilename(char *pszName);
|
||||
void SetSaveUniqueFilename(char *szFilename);
|
||||
void SetState(ESaveGameControlState eControlState,int( *Func)(void *,const bool),void *lpParam);
|
||||
void SetSaveDisabled(bool bDisable);
|
||||
bool GetSaveDisabled(void);
|
||||
unsigned int GetSaveSize();
|
||||
void GetSaveData(void *pvData,unsigned int *puiBytes);
|
||||
PVOID AllocateSaveData(unsigned int uiBytes);
|
||||
void SetSaveImages( PBYTE pbThumbnail,DWORD dwThumbnailBytes,PBYTE pbImage,DWORD dwImageBytes, PBYTE pbTextData ,DWORD dwTextDataBytes); // Sets the thumbnail & image for the save, optionally setting the metadata in the png
|
||||
C4JStorage::ESaveGameState SaveSaveData(int( *Func)(void * ,const bool),void *lpParam);
|
||||
void CopySaveDataToNewSave(PBYTE pbThumbnail,DWORD cbThumbnail,WCHAR *wchNewName,int ( *Func)(void *lpParam, bool), void *lpParam);
|
||||
void SetSaveDeviceSelected(unsigned int uiPad,bool bSelected);
|
||||
bool GetSaveDeviceSelected(unsigned int iPad);
|
||||
C4JStorage::ESaveGameState DoesSaveExist(bool *pbExists);
|
||||
bool EnoughSpaceForAMinSaveGame();
|
||||
// DLC
|
||||
void RegisterMarketplaceCountsCallback(
|
||||
int (*Func)(void* lpParam, C4JStorage::DLC_TMS_DETAILS*, int),
|
||||
void* lpParam);
|
||||
void SetDLCPackageRoot(char* pszDLCRoot);
|
||||
C4JStorage::EDLCStatus GetDLCOffers(
|
||||
int iPad, int (*Func)(void*, int, std::uint32_t, int), void* lpParam,
|
||||
std::uint32_t dwOfferTypesBitmask =
|
||||
XMARKETPLACE_OFFERING_TYPE_CONTENT);
|
||||
unsigned int CancelGetDLCOffers();
|
||||
void ClearDLCOffers();
|
||||
XMARKETPLACE_CONTENTOFFER_INFO& GetOffer(unsigned int dw);
|
||||
int GetOfferCount();
|
||||
unsigned int InstallOffer(int iOfferIDC, __uint64* ullOfferIDA,
|
||||
int (*Func)(void*, int, int), void* lpParam,
|
||||
bool bTrial = false);
|
||||
unsigned int GetAvailableDLCCount(int iPad);
|
||||
|
||||
void SetSaveMessageVPosition(float fY); // The 'Saving' message will display at a default position unless changed
|
||||
// Get the info for the saves
|
||||
C4JStorage::ESaveGameState GetSavesInfo(int iPad,int ( *Func)(void *lpParam,SAVE_DETAILS *pSaveDetails,const bool),void *lpParam,char *pszSavePackName);
|
||||
PSAVE_DETAILS ReturnSavesInfo();
|
||||
void ClearSavesInfo(); // Clears results
|
||||
C4JStorage::ESaveGameState LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo,int( *Func)(void *lpParam,std::uint8_t *thumbnailData,unsigned int thumbnailBytes), void *lpParam); // Get the thumbnail for an individual save referenced by pSaveInfo
|
||||
C4JStorage::EDLCStatus GetInstalledDLC(int iPad,
|
||||
int (*Func)(void*, int, int),
|
||||
void* lpParam);
|
||||
XCONTENT_DATA& GetDLC(unsigned int dw);
|
||||
std::uint32_t MountInstalledDLC(int iPad, std::uint32_t dwDLC,
|
||||
int (*Func)(void*, int, std::uint32_t,
|
||||
std::uint32_t),
|
||||
void* lpParam, LPCSTR szMountDrive = NULL);
|
||||
unsigned int UnmountInstalledDLC(LPCSTR szMountDrive = NULL);
|
||||
void GetMountedDLCFileList(const char* szMountDrive,
|
||||
std::vector<std::string>& fileList);
|
||||
std::string GetMountedPath(std::string szMount);
|
||||
|
||||
void GetSaveCacheFileInfo(DWORD dwFile,XCONTENT_DATA &xContentData);
|
||||
void GetSaveCacheFileInfo(DWORD dwFile, PBYTE *ppbImageData, DWORD *pdwImageBytes);
|
||||
// Global title storage
|
||||
C4JStorage::ETMSStatus ReadTMSFile(
|
||||
int iQuadrant, eGlobalStorage eStorageFacility,
|
||||
C4JStorage::eTMS_FileType eFileType, WCHAR* pwchFilename,
|
||||
std::uint8_t** ppBuffer, unsigned int* pBufferSize,
|
||||
int (*Func)(void*, WCHAR*, int, bool, int) = NULL, void* lpParam = NULL,
|
||||
int iAction = 0);
|
||||
bool WriteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility,
|
||||
WCHAR* pwchFilename, std::uint8_t* pBuffer,
|
||||
unsigned int bufferSize);
|
||||
bool DeleteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility,
|
||||
WCHAR* pwchFilename);
|
||||
void StoreTMSPathName(WCHAR* pwchName = NULL);
|
||||
|
||||
// Load the save. Need to call GetSaveData once the callback is called
|
||||
C4JStorage::ESaveGameState LoadSaveData(PSAVE_INFO pSaveInfo,int( *Func)(void *lpParam,const bool, const bool), void *lpParam);
|
||||
C4JStorage::ESaveGameState DeleteSaveData(PSAVE_INFO pSaveInfo,int( *Func)(void *lpParam,const bool), void *lpParam);
|
||||
|
||||
// DLC
|
||||
void RegisterMarketplaceCountsCallback(int ( *Func)(void *lpParam, C4JStorage::DLC_TMS_DETAILS *, int), void *lpParam );
|
||||
void SetDLCPackageRoot(char *pszDLCRoot);
|
||||
C4JStorage::EDLCStatus GetDLCOffers(int iPad,int( *Func)(void *, int, std::uint32_t, int),void *lpParam, DWORD dwOfferTypesBitmask=XMARKETPLACE_OFFERING_TYPE_CONTENT);
|
||||
DWORD CancelGetDLCOffers();
|
||||
void ClearDLCOffers();
|
||||
XMARKETPLACE_CONTENTOFFER_INFO& GetOffer(DWORD dw);
|
||||
int GetOfferCount();
|
||||
DWORD InstallOffer(int iOfferIDC, __uint64 *ullOfferIDA,int( *Func)(void *, int, int),void *lpParam, bool bTrial=false);
|
||||
DWORD GetAvailableDLCCount( int iPad);
|
||||
|
||||
C4JStorage::EDLCStatus GetInstalledDLC(int iPad,int( *Func)(void *, int, int),void *lpParam);
|
||||
XCONTENT_DATA& GetDLC(DWORD dw);
|
||||
std::uint32_t MountInstalledDLC(int iPad,std::uint32_t dwDLC,int( *Func)(void *, int, std::uint32_t, std::uint32_t),void *lpParam,LPCSTR szMountDrive=NULL);
|
||||
DWORD UnmountInstalledDLC(LPCSTR szMountDrive = NULL);
|
||||
void GetMountedDLCFileList(const char* szMountDrive, std::vector<std::string>& fileList);
|
||||
std::string GetMountedPath(std::string szMount);
|
||||
|
||||
// Global title storage
|
||||
C4JStorage::ETMSStatus ReadTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,C4JStorage::eTMS_FileType eFileType,
|
||||
WCHAR *pwchFilename,BYTE **ppBuffer,DWORD *pdwBufferSize,int( *Func)(void *, WCHAR *,int, bool, int)=NULL,void *lpParam=NULL, int iAction=0);
|
||||
bool WriteTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,WCHAR *pwchFilename,BYTE *pBuffer,DWORD dwBufferSize);
|
||||
bool DeleteTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,WCHAR *pwchFilename);
|
||||
void StoreTMSPathName(WCHAR *pwchName=NULL);
|
||||
|
||||
// TMS++
|
||||
// TMS++
|
||||
#ifdef _XBOX
|
||||
C4JStorage::ETMSStatus WriteTMSFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FileType eFileType,CHAR *pchFilePath,CHAR *pchBuffer,DWORD dwBufferSize,TMSCLIENT_CALLBACK Func,LPVOID lpParam);
|
||||
HRESULT GetUserQuotaInfo(int iPad,TMSCLIENT_CALLBACK Func,LPVOID lpParam);
|
||||
C4JStorage::ETMSStatus WriteTMSFile(
|
||||
int iPad, C4JStorage::eGlobalStorage eStorageFacility,
|
||||
C4JStorage::eTMS_FileType eFileType, CHAR* pchFilePath, CHAR* pchBuffer,
|
||||
unsigned int bufferSize, TMSCLIENT_CALLBACK Func, LPVOID lpParam);
|
||||
HRESULT GetUserQuotaInfo(int iPad, TMSCLIENT_CALLBACK Func, LPVOID lpParam);
|
||||
#endif
|
||||
|
||||
// C4JStorage::ETMSStatus TMSPP_WriteFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,C4JStorage::eTMS_UGCTYPE eUGCType,CHAR *pchFilePath,CHAR *pchBuffer,DWORD dwBufferSize,int( *Func)(LPVOID,int,int)=NULL,LPVOID lpParam=NULL, int iUserData=0);
|
||||
// C4JStorage::ETMSStatus TMSPP_GetUserQuotaInfo(int iPad,TMSCLIENT_CALLBACK Func,LPVOID lpParam, int iUserData=0);
|
||||
C4JStorage::ETMSStatus TMSPP_ReadFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPCSTR szFilename,int( *Func)(void *,int,int,PTMSPP_FILEDATA, LPCSTR)=NULL,void *lpParam=NULL, int iUserData=0);
|
||||
// C4JStorage::ETMSStatus TMSPP_ReadFileList(int iPad,C4JStorage::eGlobalStorage eStorageFacility,CHAR *pchFilePath,int( *Func)(LPVOID,int,int,PTMSPP_FILE_LIST)=NULL,LPVOID lpParam=NULL, int iUserData=0);
|
||||
// C4JStorage::ETMSStatus TMSPP_DeleteFile(int iPad,LPCSTR szFilePath,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,int( *Func)(LPVOID,int,int),LPVOID lpParam=NULL, int iUserData=0);
|
||||
// bool TMSPP_InFileList(eGlobalStorage eStorageFacility, int iPad,const std::wstring &Filename);
|
||||
// unsigned int CRC(unsigned char *buf, int len);
|
||||
// C4JStorage::ETMSStatus TMSPP_WriteFile(int
|
||||
// iPad,C4JStorage::eGlobalStorage
|
||||
// eStorageFacility,C4JStorage::eTMS_FILETYPEVAL
|
||||
// eFileTypeVal,C4JStorage::eTMS_UGCTYPE eUGCType,CHAR *pchFilePath,CHAR
|
||||
// *pchBuffer,DWORD dwBufferSize,int( *Func)(LPVOID,int,int)=NULL,LPVOID
|
||||
// lpParam=NULL, int iUserData=0); C4JStorage::ETMSStatus
|
||||
// TMSPP_GetUserQuotaInfo(int iPad,TMSCLIENT_CALLBACK Func,LPVOID lpParam,
|
||||
// int iUserData=0);
|
||||
C4JStorage::ETMSStatus TMSPP_ReadFile(
|
||||
int iPad, C4JStorage::eGlobalStorage eStorageFacility,
|
||||
C4JStorage::eTMS_FILETYPEVAL eFileTypeVal, LPCSTR szFilename,
|
||||
int (*Func)(void*, int, int, PTMSPP_FILEDATA, LPCSTR) = NULL,
|
||||
void* lpParam = NULL, int iUserData = 0);
|
||||
// C4JStorage::ETMSStatus TMSPP_ReadFileList(int
|
||||
// iPad,C4JStorage::eGlobalStorage eStorageFacility,CHAR *pchFilePath,int(
|
||||
// *Func)(LPVOID,int,int,PTMSPP_FILE_LIST)=NULL,LPVOID lpParam=NULL, int
|
||||
// iUserData=0); C4JStorage::ETMSStatus
|
||||
// TMSPP_DeleteFile(int iPad,LPCSTR szFilePath,C4JStorage::eTMS_FILETYPEVAL
|
||||
// eFileTypeVal,int( *Func)(LPVOID,int,int),LPVOID lpParam=NULL, int
|
||||
// iUserData=0); bool
|
||||
// TMSPP_InFileList(eGlobalStorage eStorageFacility, int iPad,const
|
||||
// std::wstring &Filename); unsigned int
|
||||
// CRC(unsigned char *buf, int len);
|
||||
|
||||
// enum eXBLWS
|
||||
// {
|
||||
// eXBLWS_GET,
|
||||
// eXBLWS_POST,
|
||||
// eXBLWS_PUT,
|
||||
// eXBLWS_DELETE,
|
||||
// };
|
||||
//bool XBLWS_Command(eXBLWS eCommand);
|
||||
// enum eXBLWS
|
||||
// {
|
||||
// eXBLWS_GET,
|
||||
// eXBLWS_POST,
|
||||
// eXBLWS_PUT,
|
||||
// eXBLWS_DELETE,
|
||||
// };
|
||||
// bool
|
||||
// XBLWS_Command(eXBLWS eCommand);
|
||||
|
||||
unsigned int CRC(unsigned char* buf, int len);
|
||||
|
||||
unsigned int CRC(unsigned char *buf, int len);
|
||||
int AddSubfile(int regionIndex);
|
||||
unsigned int GetSubfileCount();
|
||||
void GetSubfileDetails(unsigned int i, int* regionIndex, void** data,
|
||||
unsigned int* size);
|
||||
void ResetSubfiles();
|
||||
void UpdateSubfile(int index, void* data, unsigned int size);
|
||||
void SaveSubfiles(int (*Func)(void*, const bool), void* param);
|
||||
ESaveGameState GetSaveState();
|
||||
|
||||
int AddSubfile(int regionIndex);
|
||||
unsigned int GetSubfileCount();
|
||||
void GetSubfileDetails(unsigned int i, int* regionIndex, void** data, unsigned int* size);
|
||||
void ResetSubfiles();
|
||||
void UpdateSubfile(int index, void* data, unsigned int size);
|
||||
void SaveSubfiles(int (*Func)(void*, const bool), void* param);
|
||||
ESaveGameState GetSaveState();
|
||||
void ContinueIncompleteOperation();
|
||||
|
||||
void ContinueIncompleteOperation();
|
||||
|
||||
C4JStringTable *m_pStringTable;
|
||||
C4JStringTable* m_pStringTable;
|
||||
};
|
||||
|
||||
extern C4JStorage StorageManager;
|
||||
|
|
|
|||
|
|
@ -7,4 +7,4 @@
|
|||
|
||||
#include "../Minecraft.World/Platform/x64headers/extraX64.h"
|
||||
|
||||
#endif //_4J_STORAGE_STADAFX_H
|
||||
#endif //_4J_STORAGE_STADAFX_H
|
||||
|
|
@ -32,7 +32,9 @@ Commit names should clearly describe what was changed in the commit. [Convention
|
|||
|
||||
### Keep code clean and readable.
|
||||
|
||||
At this time, we do not have a style guide or rules for how code should be formatted. In general, code should be readable and try to match the styling and conventions of whatever is around it.
|
||||
Code formatting is defined by the repository's [`.clang-format`](./.clang-format) file. If you are touching C or C++ source, format the files you changed before opening or updating a pull request.
|
||||
|
||||
CI checks formatting on changed C and C++ files, so local formatting mismatches will fail the relevant workflow.
|
||||
|
||||
### Avoid changing in-game behavior.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Minecraft.Client asset structure
|
||||
# Minecraft.Client Asset Structure
|
||||
This is the minimum asset structure needed for the game to function.
|
||||
```
|
||||
AssetStructure
|
||||
|
|
@ -26,7 +26,7 @@ AssetStructure
|
|||
└── *.binka
|
||||
```
|
||||
## Windows64Media.arc contents
|
||||
The potential contents of the the arc file can be seen in the `.txt` files in this folder (`movies.txt`, `media.txt`, etc...).
|
||||
The contents of the the arc file can be seen in the `.txt` files in this folder (`movies.txt`, `media.txt`, etc...).
|
||||
- `languages.loc` is built from `Platform/Windows64Media/loc`
|
||||
- `HTMLColours.col` is built from `HTMLColours.xml`
|
||||
```
|
||||
|
|
@ -44,12 +44,12 @@ MediaWindows64.arc
|
|||
```
|
||||
## Asset locations
|
||||
### Generic assets should be contained inside this folder:
|
||||
- `movies/` - Flash swf files for UI
|
||||
- `graphics/` - contains images used by the client (only `SaveChest.png` `MinecraftIcon.png`, `TexturePackIcon.png` are packed into the arc)
|
||||
- `font/` - fonts, duh
|
||||
- `res/` - actual minecraft textures and other data
|
||||
- `music/` - contains background music as well as music discs
|
||||
- `levels/` - contains some premade worlds (`Tutorial` is unused as we pull it from somewhere else, atleast on Windows64 asset base)
|
||||
- `movies/` - Flash SWF files for Iggy
|
||||
- `graphics/` - Contains images used by the client (only `SaveChest.png` `MinecraftIcon.png`, `TexturePackIcon.png` are packed into the arc)
|
||||
- `font/` - Fonts, duh
|
||||
- `res/` - Textures and other miscellaneous data
|
||||
- `music/` - Contains background music as well as music discs
|
||||
- `levels/` - Contains some premade worlds (`Tutorial` is unused as we pull it from somewhere else, atleast on Windows64 asset base)
|
||||
### Platform assets are contained in Minecraft.Client/Platform/
|
||||
- `Windows64Media/loc/` - Localisation/language data that we use as a source to build the languages.loc (this file gets included in arc)
|
||||
- `Windows64Media/Media/` - Contains a bunch of Windows64 customised swfs and also the tutorial level (`Tutorial.pck`), these should be included in arc
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#include "Platform/stdafx.h"
|
||||
#include "ClientConstants.h"
|
||||
|
||||
const std::wstring ClientConstants::VERSION_STRING = std::wstring(L"Minecraft Xbox ") + VER_FILEVERSION_STR_W + std::wstring(L" (4jcraft)");//+ SharedConstants::VERSION_STRING;
|
||||
const std::wstring ClientConstants::VERSION_STRING =
|
||||
std::wstring(L"Minecraft Xbox ") + VER_FILEVERSION_STR_W +
|
||||
std::wstring(L" (4jcraft)"); //+ SharedConstants::VERSION_STRING;
|
||||
|
|
|
|||
|
|
@ -1,19 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
class ClientConstants {
|
||||
// This file holds global constants used by the client.
|
||||
// The file should be replaced at compile-time with the
|
||||
// proper settings for the given compilation. For example,
|
||||
// release builds should replace this file with no-cheat
|
||||
// settings.
|
||||
|
||||
class ClientConstants
|
||||
{
|
||||
|
||||
// This file holds global constants used by the client.
|
||||
// The file should be replaced at compile-time with the
|
||||
// proper settings for the given compilation. For example,
|
||||
// release builds should replace this file with no-cheat
|
||||
// settings.
|
||||
|
||||
// INTERNAL DEVELOPMENT SETTINGS
|
||||
// INTERNAL DEVELOPMENT SETTINGS
|
||||
public:
|
||||
static const std::wstring VERSION_STRING;
|
||||
static const std::wstring VERSION_STRING;
|
||||
|
||||
static const bool DEADMAU5_CAMERA_CHEATS = false;
|
||||
static const bool IS_DEMO_VERSION = false;
|
||||
static const bool DEADMAU5_CAMERA_CHEATS = false;
|
||||
static const bool IS_DEMO_VERSION = false;
|
||||
};
|
||||
|
|
@ -9,82 +9,90 @@
|
|||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.dimension.h"
|
||||
#include "TeleportCommand.h"
|
||||
|
||||
EGameCommand TeleportCommand::getId()
|
||||
{
|
||||
return eGameCommand_Teleport;
|
||||
EGameCommand TeleportCommand::getId() { return eGameCommand_Teleport; }
|
||||
|
||||
void TeleportCommand::execute(std::shared_ptr<CommandSender> source,
|
||||
byteArray commandData) {
|
||||
ByteArrayInputStream bais(commandData);
|
||||
DataInputStream dis(&bais);
|
||||
|
||||
PlayerUID subjectID = dis.readPlayerUID();
|
||||
PlayerUID destinationID = dis.readPlayerUID();
|
||||
|
||||
bais.reset();
|
||||
|
||||
PlayerList* players = MinecraftServer::getInstance()->getPlayerList();
|
||||
|
||||
std::shared_ptr<ServerPlayer> subject = players->getPlayer(subjectID);
|
||||
std::shared_ptr<ServerPlayer> destination =
|
||||
players->getPlayer(destinationID);
|
||||
|
||||
if (subject != NULL && destination != NULL &&
|
||||
subject->level->dimension->id == destination->level->dimension->id &&
|
||||
subject->isAlive()) {
|
||||
subject->ride(nullptr);
|
||||
subject->connection->teleport(destination->x, destination->y,
|
||||
destination->z, destination->yRot,
|
||||
destination->xRot);
|
||||
// logAdminAction(source, "commands.tp.success", subject->getAName(),
|
||||
// destination->getAName());
|
||||
logAdminAction(source, ChatPacket::e_ChatCommandTeleportSuccess,
|
||||
subject->getName(), eTYPE_SERVERPLAYER,
|
||||
destination->getName());
|
||||
|
||||
if (subject == source) {
|
||||
destination->sendMessage(subject->getName(),
|
||||
ChatPacket::e_ChatCommandTeleportToMe);
|
||||
} else {
|
||||
subject->sendMessage(destination->getName(),
|
||||
ChatPacket::e_ChatCommandTeleportMe);
|
||||
}
|
||||
}
|
||||
|
||||
// if (args.length >= 1) {
|
||||
// MinecraftServer server = MinecraftServer.getInstance();
|
||||
// ServerPlayer victim;
|
||||
|
||||
// if (args.length == 2 || args.length == 4) {
|
||||
// victim = server.getPlayers().getPlayer(args[0]);
|
||||
// if (victim == null) throw new PlayerNotFoundException();
|
||||
// } else {
|
||||
// victim = (ServerPlayer) convertSourceToPlayer(source);
|
||||
// }
|
||||
|
||||
// if (args.length == 3 || args.length == 4) {
|
||||
// if (victim.level != null) {
|
||||
// int pos = args.length - 3;
|
||||
// int maxPos = Level.MAX_LEVEL_SIZE;
|
||||
// int x = convertArgToInt(source, args[pos++], -maxPos,
|
||||
//maxPos); int y = convertArgToInt(source, args[pos++],
|
||||
//Level.minBuildHeight, Level.maxBuildHeight); int z =
|
||||
//convertArgToInt(source, args[pos++], -maxPos, maxPos);
|
||||
|
||||
// victim.teleportTo(x + 0.5f, y, z + 0.5f);
|
||||
// logAdminAction(source, "commands.tp.coordinates",
|
||||
//victim.getAName(), x, y, z);
|
||||
// }
|
||||
// } else if (args.length == 1 || args.length == 2) {
|
||||
// ServerPlayer destination =
|
||||
//server.getPlayers().getPlayer(args[args.length - 1]); if (destination ==
|
||||
//null) throw new PlayerNotFoundException();
|
||||
|
||||
// victim.connection.teleport(destination.x, destination.y,
|
||||
//destination.z, destination.yRot, destination.xRot); logAdminAction(source,
|
||||
//"commands.tp.success", victim.getAName(), destination.getAName());
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
void TeleportCommand::execute(std::shared_ptr<CommandSender> source, byteArray commandData)
|
||||
{
|
||||
ByteArrayInputStream bais(commandData);
|
||||
DataInputStream dis(&bais);
|
||||
std::shared_ptr<GameCommandPacket> TeleportCommand::preparePacket(
|
||||
PlayerUID subject, PlayerUID destination) {
|
||||
ByteArrayOutputStream baos;
|
||||
DataOutputStream dos(&baos);
|
||||
|
||||
PlayerUID subjectID = dis.readPlayerUID();
|
||||
PlayerUID destinationID = dis.readPlayerUID();
|
||||
|
||||
bais.reset();
|
||||
dos.writePlayerUID(subject);
|
||||
dos.writePlayerUID(destination);
|
||||
|
||||
PlayerList *players = MinecraftServer::getInstance()->getPlayerList();
|
||||
|
||||
std::shared_ptr<ServerPlayer> subject = players->getPlayer(subjectID);
|
||||
std::shared_ptr<ServerPlayer> destination = players->getPlayer(destinationID);
|
||||
|
||||
if(subject != NULL && destination != NULL && subject->level->dimension->id == destination->level->dimension->id && subject->isAlive() )
|
||||
{
|
||||
subject->ride(nullptr);
|
||||
subject->connection->teleport(destination->x, destination->y, destination->z, destination->yRot, destination->xRot);
|
||||
//logAdminAction(source, "commands.tp.success", subject->getAName(), destination->getAName());
|
||||
logAdminAction(source, ChatPacket::e_ChatCommandTeleportSuccess, subject->getName(), eTYPE_SERVERPLAYER, destination->getName());
|
||||
|
||||
if(subject == source)
|
||||
{
|
||||
destination->sendMessage(subject->getName(), ChatPacket::e_ChatCommandTeleportToMe);
|
||||
}
|
||||
else
|
||||
{
|
||||
subject->sendMessage(destination->getName(), ChatPacket::e_ChatCommandTeleportMe);
|
||||
}
|
||||
}
|
||||
|
||||
//if (args.length >= 1) {
|
||||
// MinecraftServer server = MinecraftServer.getInstance();
|
||||
// ServerPlayer victim;
|
||||
|
||||
// if (args.length == 2 || args.length == 4) {
|
||||
// victim = server.getPlayers().getPlayer(args[0]);
|
||||
// if (victim == null) throw new PlayerNotFoundException();
|
||||
// } else {
|
||||
// victim = (ServerPlayer) convertSourceToPlayer(source);
|
||||
// }
|
||||
|
||||
// if (args.length == 3 || args.length == 4) {
|
||||
// if (victim.level != null) {
|
||||
// int pos = args.length - 3;
|
||||
// int maxPos = Level.MAX_LEVEL_SIZE;
|
||||
// int x = convertArgToInt(source, args[pos++], -maxPos, maxPos);
|
||||
// int y = convertArgToInt(source, args[pos++], Level.minBuildHeight, Level.maxBuildHeight);
|
||||
// int z = convertArgToInt(source, args[pos++], -maxPos, maxPos);
|
||||
|
||||
// victim.teleportTo(x + 0.5f, y, z + 0.5f);
|
||||
// logAdminAction(source, "commands.tp.coordinates", victim.getAName(), x, y, z);
|
||||
// }
|
||||
// } else if (args.length == 1 || args.length == 2) {
|
||||
// ServerPlayer destination = server.getPlayers().getPlayer(args[args.length - 1]);
|
||||
// if (destination == null) throw new PlayerNotFoundException();
|
||||
|
||||
// victim.connection.teleport(destination.x, destination.y, destination.z, destination.yRot, destination.xRot);
|
||||
// logAdminAction(source, "commands.tp.success", victim.getAName(), destination.getAName());
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
std::shared_ptr<GameCommandPacket> TeleportCommand::preparePacket(PlayerUID subject, PlayerUID destination)
|
||||
{
|
||||
ByteArrayOutputStream baos;
|
||||
DataOutputStream dos(&baos);
|
||||
|
||||
dos.writePlayerUID(subject);
|
||||
dos.writePlayerUID(destination);
|
||||
|
||||
return std::shared_ptr<GameCommandPacket>( new GameCommandPacket(eGameCommand_Teleport, baos.toByteArray() ));
|
||||
return std::shared_ptr<GameCommandPacket>(
|
||||
new GameCommandPacket(eGameCommand_Teleport, baos.toByteArray()));
|
||||
}
|
||||
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
#include "../../Minecraft.World/Commands/Command.h"
|
||||
|
||||
class TeleportCommand : public Command
|
||||
{
|
||||
class TeleportCommand : public Command {
|
||||
public:
|
||||
virtual EGameCommand getId();
|
||||
virtual void execute(std::shared_ptr<CommandSender> source, byteArray commandData);
|
||||
virtual EGameCommand getId();
|
||||
virtual void execute(std::shared_ptr<CommandSender> source,
|
||||
byteArray commandData);
|
||||
|
||||
static std::shared_ptr<GameCommandPacket> preparePacket(PlayerUID subject, PlayerUID destination);
|
||||
static std::shared_ptr<GameCommandPacket> preparePacket(
|
||||
PlayerUID subject, PlayerUID destination);
|
||||
};
|
||||
|
|
@ -10,121 +10,91 @@
|
|||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
||||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.tile.h"
|
||||
|
||||
CreativeMode::CreativeMode(Minecraft *minecraft) : GameMode(minecraft)
|
||||
{
|
||||
destroyDelay = 0;
|
||||
instaBuild = true;
|
||||
CreativeMode::CreativeMode(Minecraft* minecraft) : GameMode(minecraft) {
|
||||
destroyDelay = 0;
|
||||
instaBuild = true;
|
||||
}
|
||||
|
||||
void CreativeMode::init()
|
||||
{
|
||||
// initPlayer();
|
||||
void CreativeMode::init() {
|
||||
// initPlayer();
|
||||
}
|
||||
|
||||
void CreativeMode::enableCreativeForPlayer(std::shared_ptr<Player> player)
|
||||
{
|
||||
// please check ServerPlayerGameMode.java if you change these
|
||||
player->abilities.mayfly = true;
|
||||
player->abilities.instabuild = true;
|
||||
player->abilities.invulnerable = true;
|
||||
void CreativeMode::enableCreativeForPlayer(std::shared_ptr<Player> player) {
|
||||
// please check ServerPlayerGameMode.java if you change these
|
||||
player->abilities.mayfly = true;
|
||||
player->abilities.instabuild = true;
|
||||
player->abilities.invulnerable = true;
|
||||
}
|
||||
|
||||
void CreativeMode::disableCreativeForPlayer(std::shared_ptr<Player> player)
|
||||
{
|
||||
player->abilities.mayfly = false;
|
||||
player->abilities.flying = false;
|
||||
player->abilities.instabuild = false;
|
||||
player->abilities.invulnerable = false;
|
||||
void CreativeMode::disableCreativeForPlayer(std::shared_ptr<Player> player) {
|
||||
player->abilities.mayfly = false;
|
||||
player->abilities.flying = false;
|
||||
player->abilities.instabuild = false;
|
||||
player->abilities.invulnerable = false;
|
||||
}
|
||||
|
||||
void CreativeMode::adjustPlayer(std::shared_ptr<Player> player)
|
||||
{
|
||||
enableCreativeForPlayer(player);
|
||||
void CreativeMode::adjustPlayer(std::shared_ptr<Player> player) {
|
||||
enableCreativeForPlayer(player);
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
if (player->inventory->items[i] == NULL)
|
||||
{
|
||||
player->inventory->items[i] = std::shared_ptr<ItemInstance>( new ItemInstance(User::allowedTiles[i]) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// 4J-PB - this line is commented out in 1.0.1
|
||||
//player->inventory->items[i]->count = 1;
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (player->inventory->items[i] == NULL) {
|
||||
player->inventory->items[i] = std::shared_ptr<ItemInstance>(
|
||||
new ItemInstance(User::allowedTiles[i]));
|
||||
} else {
|
||||
// 4J-PB - this line is commented out in 1.0.1
|
||||
// player->inventory->items[i]->count = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CreativeMode::creativeDestroyBlock(Minecraft *minecraft, GameMode *gameMode, int x, int y, int z, int face)
|
||||
{
|
||||
if(!minecraft->level->extinguishFire(minecraft->player, x, y, z, face))
|
||||
{
|
||||
gameMode->destroyBlock(x, y, z, face);
|
||||
}
|
||||
void CreativeMode::creativeDestroyBlock(Minecraft* minecraft,
|
||||
GameMode* gameMode, int x, int y, int z,
|
||||
int face) {
|
||||
if (!minecraft->level->extinguishFire(minecraft->player, x, y, z, face)) {
|
||||
gameMode->destroyBlock(x, y, z, face);
|
||||
}
|
||||
}
|
||||
|
||||
bool CreativeMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly, bool *pbUsedItem)
|
||||
{
|
||||
int t = level->getTile(x, y, z);
|
||||
if (t > 0)
|
||||
{
|
||||
if (Tile::tiles[t]->use(level, x, y, z, player)) return true;
|
||||
}
|
||||
if (item == NULL) return false;
|
||||
int aux = item->getAuxValue();
|
||||
int count = item->count;
|
||||
bool success = item->useOn(player, level, x, y, z, face);
|
||||
item->setAuxValue(aux);
|
||||
item->count = count;
|
||||
return success;
|
||||
bool CreativeMode::useItemOn(std::shared_ptr<Player> player, Level* level,
|
||||
std::shared_ptr<ItemInstance> item, int x, int y,
|
||||
int z, int face, bool bTestUseOnOnly,
|
||||
bool* pbUsedItem) {
|
||||
int t = level->getTile(x, y, z);
|
||||
if (t > 0) {
|
||||
if (Tile::tiles[t]->use(level, x, y, z, player)) return true;
|
||||
}
|
||||
if (item == NULL) return false;
|
||||
int aux = item->getAuxValue();
|
||||
int count = item->count;
|
||||
bool success = item->useOn(player, level, x, y, z, face);
|
||||
item->setAuxValue(aux);
|
||||
item->count = count;
|
||||
return success;
|
||||
}
|
||||
|
||||
void CreativeMode::startDestroyBlock(int x, int y, int z, int face)
|
||||
{
|
||||
creativeDestroyBlock(minecraft, this, x, y, z, face);
|
||||
destroyDelay = 5;
|
||||
void CreativeMode::startDestroyBlock(int x, int y, int z, int face) {
|
||||
creativeDestroyBlock(minecraft, this, x, y, z, face);
|
||||
destroyDelay = 5;
|
||||
}
|
||||
|
||||
void CreativeMode::continueDestroyBlock(int x, int y, int z, int face)
|
||||
{
|
||||
destroyDelay--;
|
||||
if (destroyDelay <= 0)
|
||||
{
|
||||
destroyDelay = 5;
|
||||
creativeDestroyBlock(minecraft, this, x, y, z, face);
|
||||
}
|
||||
void CreativeMode::continueDestroyBlock(int x, int y, int z, int face) {
|
||||
destroyDelay--;
|
||||
if (destroyDelay <= 0) {
|
||||
destroyDelay = 5;
|
||||
creativeDestroyBlock(minecraft, this, x, y, z, face);
|
||||
}
|
||||
}
|
||||
|
||||
void CreativeMode::stopDestroyBlock()
|
||||
{
|
||||
}
|
||||
void CreativeMode::stopDestroyBlock() {}
|
||||
|
||||
bool CreativeMode::canHurtPlayer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool CreativeMode::canHurtPlayer() { return false; }
|
||||
|
||||
void CreativeMode::initLevel(Level *level)
|
||||
{
|
||||
GameMode::initLevel(level);
|
||||
}
|
||||
void CreativeMode::initLevel(Level* level) { GameMode::initLevel(level); }
|
||||
|
||||
float CreativeMode::getPickRange()
|
||||
{
|
||||
return 5.0f;
|
||||
}
|
||||
float CreativeMode::getPickRange() { return 5.0f; }
|
||||
|
||||
bool CreativeMode::hasMissTime()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool CreativeMode::hasMissTime() { return false; }
|
||||
|
||||
bool CreativeMode::hasInfiniteItems()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool CreativeMode::hasInfiniteItems() { return true; }
|
||||
|
||||
bool CreativeMode::hasFarPickRange()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool CreativeMode::hasFarPickRange() { return true; }
|
||||
|
|
@ -1,26 +1,29 @@
|
|||
#pragma once
|
||||
#include "GameMode.h"
|
||||
|
||||
class CreativeMode : public GameMode
|
||||
{
|
||||
class CreativeMode : public GameMode {
|
||||
private:
|
||||
int destroyDelay;
|
||||
int destroyDelay;
|
||||
|
||||
public:
|
||||
CreativeMode(Minecraft *minecraft);
|
||||
virtual void init();
|
||||
static void enableCreativeForPlayer(std::shared_ptr<Player> player);
|
||||
static void disableCreativeForPlayer(std::shared_ptr<Player> player);
|
||||
virtual void adjustPlayer(std::shared_ptr<Player> player);
|
||||
static void creativeDestroyBlock(Minecraft *minecraft, GameMode *gameMode, int x, int y, int z, int face);
|
||||
virtual bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly=false, bool *pbUsedItem = NULL);
|
||||
virtual void startDestroyBlock(int x, int y, int z, int face);
|
||||
virtual void continueDestroyBlock(int x, int y, int z, int face);
|
||||
virtual void stopDestroyBlock();
|
||||
virtual bool canHurtPlayer();
|
||||
virtual void initLevel(Level *level);
|
||||
virtual float getPickRange();
|
||||
virtual bool hasMissTime();
|
||||
virtual bool hasInfiniteItems();
|
||||
virtual bool hasFarPickRange();
|
||||
CreativeMode(Minecraft* minecraft);
|
||||
virtual void init();
|
||||
static void enableCreativeForPlayer(std::shared_ptr<Player> player);
|
||||
static void disableCreativeForPlayer(std::shared_ptr<Player> player);
|
||||
virtual void adjustPlayer(std::shared_ptr<Player> player);
|
||||
static void creativeDestroyBlock(Minecraft* minecraft, GameMode* gameMode,
|
||||
int x, int y, int z, int face);
|
||||
virtual bool useItemOn(std::shared_ptr<Player> player, Level* level,
|
||||
std::shared_ptr<ItemInstance> item, int x, int y,
|
||||
int z, int face, bool bTestUseOnOnly = false,
|
||||
bool* pbUsedItem = NULL);
|
||||
virtual void startDestroyBlock(int x, int y, int z, int face);
|
||||
virtual void continueDestroyBlock(int x, int y, int z, int face);
|
||||
virtual void stopDestroyBlock();
|
||||
virtual bool canHurtPlayer();
|
||||
virtual void initLevel(Level* level);
|
||||
virtual float getPickRange();
|
||||
virtual bool hasMissTime();
|
||||
virtual bool hasInfiniteItems();
|
||||
virtual bool hasFarPickRange();
|
||||
};
|
||||
|
|
@ -2,111 +2,107 @@
|
|||
#include "DemoMode.h"
|
||||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
||||
|
||||
DemoMode::DemoMode(Minecraft *minecraft) : SurvivalMode(minecraft)
|
||||
{
|
||||
demoHasEnded = false;
|
||||
DemoMode::DemoMode(Minecraft* minecraft) : SurvivalMode(minecraft) {
|
||||
demoHasEnded = false;
|
||||
demoEndedReminder = 0;
|
||||
}
|
||||
|
||||
void DemoMode::tick()
|
||||
{
|
||||
void DemoMode::tick() {
|
||||
SurvivalMode::tick();
|
||||
|
||||
/* 4J - TODO - seems unlikely we need this demo mode anyway
|
||||
__int64 time = minecraft->level->getTime();
|
||||
__int64 day = (time / Level::TICKS_PER_DAY) + 1;
|
||||
/* 4J - TODO - seems unlikely we need this demo mode anyway
|
||||
__int64 time = minecraft->level->getTime();
|
||||
__int64 day = (time / Level::TICKS_PER_DAY) + 1;
|
||||
|
||||
demoHasEnded = (time > (500 + Level::TICKS_PER_DAY * DEMO_DAYS));
|
||||
if (demoHasEnded)
|
||||
{
|
||||
demoEndedReminder++;
|
||||
}
|
||||
demoHasEnded = (time > (500 + Level::TICKS_PER_DAY * DEMO_DAYS));
|
||||
if (demoHasEnded)
|
||||
{
|
||||
demoEndedReminder++;
|
||||
}
|
||||
|
||||
if ((time % Level::TICKS_PER_DAY) == 500)
|
||||
{
|
||||
if (day <= (DEMO_DAYS + 1))
|
||||
{
|
||||
minecraft->gui->displayClientMessage(L"demo.day." + _toString<__int64>(day));
|
||||
if ((time % Level::TICKS_PER_DAY) == 500)
|
||||
{
|
||||
if (day <= (DEMO_DAYS + 1))
|
||||
{
|
||||
minecraft->gui->displayClientMessage(L"demo.day." +
|
||||
_toString<__int64>(day));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (day == 1)
|
||||
{
|
||||
Options *options = minecraft->options;
|
||||
std::wstring message;
|
||||
else if (day == 1)
|
||||
{
|
||||
Options *options = minecraft->options;
|
||||
std::wstring message;
|
||||
|
||||
if (time == 100) {
|
||||
minecraft.gui.addMessage("Seed: " + minecraft.level.getSeed());
|
||||
message = language.getElement("demo.help.movement");
|
||||
message = String.format(message, Keyboard.getKeyName(options.keyUp.key), Keyboard.getKeyName(options.keyLeft.key), Keyboard.getKeyName(options.keyDown.key),
|
||||
Keyboard.getKeyName(options.keyRight.key));
|
||||
} else if (time == 175) {
|
||||
message = language.getElement("demo.help.jump");
|
||||
message = String.format(message, Keyboard.getKeyName(options.keyJump.key));
|
||||
} else if (time == 250) {
|
||||
message = language.getElement("demo.help.inventory");
|
||||
message = String.format(message, Keyboard.getKeyName(options.keyBuild.key));
|
||||
if (time == 100) {
|
||||
minecraft.gui.addMessage("Seed: " + minecraft.level.getSeed());
|
||||
message = language.getElement("demo.help.movement");
|
||||
message = String.format(message,
|
||||
Keyboard.getKeyName(options.keyUp.key),
|
||||
Keyboard.getKeyName(options.keyLeft.key),
|
||||
Keyboard.getKeyName(options.keyDown.key),
|
||||
Keyboard.getKeyName(options.keyRight.key));
|
||||
} else if (time == 175) {
|
||||
message = language.getElement("demo.help.jump");
|
||||
message = String.format(message,
|
||||
Keyboard.getKeyName(options.keyJump.key)); } else if (time == 250) {
|
||||
message = language.getElement("demo.help.inventory");
|
||||
message = String.format(message,
|
||||
Keyboard.getKeyName(options.keyBuild.key));
|
||||
}
|
||||
if (message != null) {
|
||||
minecraft.gui.addMessage(message);
|
||||
}
|
||||
} else if (day == DEMO_DAYS) {
|
||||
if ((time % Level.TICKS_PER_DAY) == 22000) {
|
||||
minecraft.gui.displayClientMessage("demo.day.warning");
|
||||
}
|
||||
}
|
||||
if (message != null) {
|
||||
minecraft.gui.addMessage(message);
|
||||
}
|
||||
} else if (day == DEMO_DAYS) {
|
||||
if ((time % Level.TICKS_PER_DAY) == 22000) {
|
||||
minecraft.gui.displayClientMessage("demo.day.warning");
|
||||
}
|
||||
}
|
||||
*/
|
||||
*/
|
||||
}
|
||||
|
||||
void DemoMode::outputDemoReminder()
|
||||
{
|
||||
/* 4J - TODO
|
||||
if (demoEndedReminder > 100) {
|
||||
minecraft.gui.displayClientMessage("demo.reminder");
|
||||
demoEndedReminder = 0;
|
||||
}
|
||||
*/
|
||||
void DemoMode::outputDemoReminder() {
|
||||
/* 4J - TODO
|
||||
if (demoEndedReminder > 100) {
|
||||
minecraft.gui.displayClientMessage("demo.reminder");
|
||||
demoEndedReminder = 0;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void DemoMode::startDestroyBlock(int x, int y, int z, int face)
|
||||
{
|
||||
if (demoHasEnded)
|
||||
{
|
||||
void DemoMode::startDestroyBlock(int x, int y, int z, int face) {
|
||||
if (demoHasEnded) {
|
||||
outputDemoReminder();
|
||||
return;
|
||||
}
|
||||
SurvivalMode::startDestroyBlock(x, y, z, face);
|
||||
}
|
||||
|
||||
void DemoMode::continueDestroyBlock(int x, int y, int z, int face)
|
||||
{
|
||||
if (demoHasEnded)
|
||||
{
|
||||
void DemoMode::continueDestroyBlock(int x, int y, int z, int face) {
|
||||
if (demoHasEnded) {
|
||||
return;
|
||||
}
|
||||
SurvivalMode::continueDestroyBlock(x, y, z, face);
|
||||
}
|
||||
|
||||
bool DemoMode::destroyBlock(int x, int y, int z, int face)
|
||||
{
|
||||
if (demoHasEnded)
|
||||
{
|
||||
bool DemoMode::destroyBlock(int x, int y, int z, int face) {
|
||||
if (demoHasEnded) {
|
||||
return false;
|
||||
}
|
||||
return SurvivalMode::destroyBlock(x, y, z, face);
|
||||
}
|
||||
|
||||
bool DemoMode::useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item)
|
||||
{
|
||||
if (demoHasEnded)
|
||||
{
|
||||
bool DemoMode::useItem(std::shared_ptr<Player> player, Level* level,
|
||||
std::shared_ptr<ItemInstance> item) {
|
||||
if (demoHasEnded) {
|
||||
outputDemoReminder();
|
||||
return false;
|
||||
}
|
||||
return SurvivalMode::useItem(player, level, item);
|
||||
}
|
||||
|
||||
bool DemoMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face)
|
||||
{
|
||||
bool DemoMode::useItemOn(std::shared_ptr<Player> player, Level* level,
|
||||
std::shared_ptr<ItemInstance> item, int x, int y,
|
||||
int z, int face) {
|
||||
if (demoHasEnded) {
|
||||
outputDemoReminder();
|
||||
return false;
|
||||
|
|
@ -114,10 +110,9 @@ bool DemoMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shar
|
|||
return SurvivalMode::useItemOn(player, level, item, x, y, z, face);
|
||||
}
|
||||
|
||||
void DemoMode::attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity)
|
||||
{
|
||||
if (demoHasEnded)
|
||||
{
|
||||
void DemoMode::attack(std::shared_ptr<Player> player,
|
||||
std::shared_ptr<Entity> entity) {
|
||||
if (demoHasEnded) {
|
||||
outputDemoReminder();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,32 @@
|
|||
#pragma once
|
||||
#include "SurvivalMode.h"
|
||||
|
||||
class DemoMode : public SurvivalMode
|
||||
{
|
||||
class DemoMode : public SurvivalMode {
|
||||
private:
|
||||
static const int DEMO_DAYS = 5;
|
||||
static const int DEMO_DAYS = 5;
|
||||
|
||||
bool demoHasEnded;
|
||||
int demoEndedReminder;
|
||||
|
||||
public:
|
||||
DemoMode(Minecraft *minecraft);
|
||||
DemoMode(Minecraft* minecraft);
|
||||
virtual void tick();
|
||||
private:
|
||||
void outputDemoReminder();
|
||||
public:
|
||||
using GameMode::useItem;
|
||||
using SurvivalMode::useItemOn;
|
||||
|
||||
virtual void startDestroyBlock(int x, int y, int z, int face);
|
||||
private:
|
||||
void outputDemoReminder();
|
||||
|
||||
public:
|
||||
using GameMode::useItem;
|
||||
using SurvivalMode::useItemOn;
|
||||
|
||||
virtual void startDestroyBlock(int x, int y, int z, int face);
|
||||
virtual void continueDestroyBlock(int x, int y, int z, int face);
|
||||
virtual bool destroyBlock(int x, int y, int z, int face);
|
||||
virtual bool useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item);
|
||||
virtual bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face);
|
||||
virtual void attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
|
||||
virtual bool useItem(std::shared_ptr<Player> player, Level* level,
|
||||
std::shared_ptr<ItemInstance> item);
|
||||
virtual bool useItemOn(std::shared_ptr<Player> player, Level* level,
|
||||
std::shared_ptr<ItemInstance> item, int x, int y,
|
||||
int z, int face);
|
||||
virtual void attack(std::shared_ptr<Player> player,
|
||||
std::shared_ptr<Entity> entity);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
#include "../Platform/stdafx.h"
|
||||
#include "DemoUser.h"
|
||||
|
||||
DemoUser::DemoUser() : User(L"DemoUser", L"n/a")
|
||||
{
|
||||
}
|
||||
DemoUser::DemoUser() : User(L"DemoUser", L"n/a") {}
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
#pragma once
|
||||
#include "../Player/User.h"
|
||||
|
||||
class DemoUser : public User
|
||||
{
|
||||
class DemoUser : public User {
|
||||
public:
|
||||
DemoUser();
|
||||
DemoUser();
|
||||
};
|
||||
|
|
@ -11,60 +11,55 @@
|
|||
#include "../../Minecraft.World/Headers/net.minecraft.world.entity.player.h"
|
||||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.chunk.h"
|
||||
|
||||
GameMode::GameMode(Minecraft *minecraft)
|
||||
{
|
||||
instaBuild = false; // 4J - added
|
||||
this->minecraft = minecraft;
|
||||
GameMode::GameMode(Minecraft* minecraft) {
|
||||
instaBuild = false; // 4J - added
|
||||
this->minecraft = minecraft;
|
||||
}
|
||||
|
||||
void GameMode::initLevel(Level *level)
|
||||
{
|
||||
}
|
||||
void GameMode::initLevel(Level* level) {}
|
||||
|
||||
bool GameMode::destroyBlock(int x, int y, int z, int face)
|
||||
{
|
||||
Level *level = minecraft->level;
|
||||
Tile *oldTile = Tile::tiles[level->getTile(x, y, z)];
|
||||
if (oldTile == NULL) return false;
|
||||
bool GameMode::destroyBlock(int x, int y, int z, int face) {
|
||||
Level* level = minecraft->level;
|
||||
Tile* oldTile = Tile::tiles[level->getTile(x, y, z)];
|
||||
if (oldTile == NULL) return false;
|
||||
|
||||
// 4J - Let the rendering side of thing know we are about to destroy the tile, so we can synchronise collision with async render data upates.
|
||||
minecraft->levelRenderer->destroyedTileManager->destroyingTileAt(level, x, y, z);
|
||||
level->levelEvent(LevelEvent::PARTICLES_DESTROY_BLOCK, x, y, z, oldTile->id + (level->getData(x, y, z) << Tile::TILE_NUM_SHIFT));
|
||||
// 4J - Let the rendering side of thing know we are about to destroy the
|
||||
// tile, so we can synchronise collision with async render data upates.
|
||||
minecraft->levelRenderer->destroyedTileManager->destroyingTileAt(level, x,
|
||||
y, z);
|
||||
level->levelEvent(
|
||||
LevelEvent::PARTICLES_DESTROY_BLOCK, x, y, z,
|
||||
oldTile->id + (level->getData(x, y, z) << Tile::TILE_NUM_SHIFT));
|
||||
int data = level->getData(x, y, z);
|
||||
// 4J - before we remove the tile, recalc the heightmap - setTile depends on this being valid to be able to do
|
||||
// a quick update of skylighting when the block is removed, and there are cases with falling tiles where this can get out of sync
|
||||
level->getChunkAt(x,z)->recalcHeightmapOnly();
|
||||
// 4J - before we remove the tile, recalc the heightmap - setTile depends on
|
||||
// this being valid to be able to do a quick update of skylighting when the
|
||||
// block is removed, and there are cases with falling tiles where this can
|
||||
// get out of sync
|
||||
level->getChunkAt(x, z)->recalcHeightmapOnly();
|
||||
bool changed = level->setTile(x, y, z, 0);
|
||||
|
||||
if (oldTile != NULL && changed)
|
||||
{
|
||||
if (oldTile != NULL && changed) {
|
||||
oldTile->destroy(level, x, y, z, data);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
void GameMode::render(float a)
|
||||
{
|
||||
void GameMode::render(float a) {}
|
||||
|
||||
bool GameMode::useItem(std::shared_ptr<Player> player, Level* level,
|
||||
std::shared_ptr<ItemInstance> item, bool bTestUseOnly) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GameMode::useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, bool bTestUseOnly)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
void GameMode::initPlayer(std::shared_ptr<Player> player) {}
|
||||
|
||||
void GameMode::initPlayer(std::shared_ptr<Player> player)
|
||||
{
|
||||
}
|
||||
void GameMode::tick() {}
|
||||
|
||||
void GameMode::tick()
|
||||
{
|
||||
}
|
||||
void GameMode::adjustPlayer(std::shared_ptr<Player> player) {}
|
||||
|
||||
void GameMode::adjustPlayer(std::shared_ptr<Player> player)
|
||||
{
|
||||
}
|
||||
|
||||
//bool GameMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly)
|
||||
// bool GameMode::useItemOn(std::shared_ptr<Player> player, Level *level,
|
||||
// std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool
|
||||
// bTestUseOnOnly)
|
||||
//{
|
||||
// // 4J-PB - Adding a test only version to allow tooltips to be displayed
|
||||
// int t = level->getTile(x, y, z);
|
||||
|
|
@ -74,9 +69,10 @@ void GameMode::adjustPlayer(std::shared_ptr<Player> player)
|
|||
// {
|
||||
// switch(t)
|
||||
// {
|
||||
// case Tile::recordPlayer_Id:
|
||||
// case Tile::recordPlayer_Id:
|
||||
// case Tile::bed_Id: // special case for a bed
|
||||
// if (Tile::tiles[t]->TestUse(level, x, y, z, player ))
|
||||
// if (Tile::tiles[t]->TestUse(level, x, y, z,
|
||||
//player ))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
|
|
@ -91,94 +87,73 @@ void GameMode::adjustPlayer(std::shared_ptr<Player> player)
|
|||
// break;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// else
|
||||
// {
|
||||
// if (Tile::tiles[t]->use(level, x, y, z, player )) return true;
|
||||
// if (Tile::tiles[t]->use(level, x, y, z, player )) return
|
||||
//true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (item == NULL) return false;
|
||||
// return item->useOn(player, level, x, y, z, face, bTestUseOnOnly);
|
||||
//}
|
||||
//
|
||||
// if (item == NULL) return false;
|
||||
// return item->useOn(player, level, x, y, z, face, bTestUseOnOnly);
|
||||
// }
|
||||
|
||||
|
||||
std::shared_ptr<Player> GameMode::createPlayer(Level *level)
|
||||
{
|
||||
return std::shared_ptr<Player>( new LocalPlayer(minecraft, level, minecraft->user, level->dimension->id) );
|
||||
std::shared_ptr<Player> GameMode::createPlayer(Level* level) {
|
||||
return std::shared_ptr<Player>(new LocalPlayer(
|
||||
minecraft, level, minecraft->user, level->dimension->id));
|
||||
}
|
||||
|
||||
bool GameMode::interact(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity)
|
||||
{
|
||||
return player->interact(entity);
|
||||
bool GameMode::interact(std::shared_ptr<Player> player,
|
||||
std::shared_ptr<Entity> entity) {
|
||||
return player->interact(entity);
|
||||
}
|
||||
|
||||
void GameMode::attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity)
|
||||
{
|
||||
player->attack(entity);
|
||||
void GameMode::attack(std::shared_ptr<Player> player,
|
||||
std::shared_ptr<Entity> entity) {
|
||||
player->attack(entity);
|
||||
}
|
||||
|
||||
std::shared_ptr<ItemInstance> GameMode::handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, bool quickKeyHeld, std::shared_ptr<Player> player)
|
||||
{
|
||||
return nullptr;
|
||||
std::shared_ptr<ItemInstance> GameMode::handleInventoryMouseClick(
|
||||
int containerId, int slotNum, int buttonNum, bool quickKeyHeld,
|
||||
std::shared_ptr<Player> player) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void GameMode::handleCloseInventory(int containerId, std::shared_ptr<Player> player)
|
||||
{
|
||||
void GameMode::handleCloseInventory(int containerId,
|
||||
std::shared_ptr<Player> player) {
|
||||
player->containerMenu->removed(player);
|
||||
delete player->containerMenu;
|
||||
delete player->containerMenu;
|
||||
player->containerMenu = player->inventoryMenu;
|
||||
}
|
||||
|
||||
void GameMode::handleInventoryButtonClick(int containerId, int buttonId)
|
||||
{
|
||||
void GameMode::handleInventoryButtonClick(int containerId, int buttonId) {}
|
||||
|
||||
bool GameMode::isCutScene() { return false; }
|
||||
|
||||
void GameMode::releaseUsingItem(std::shared_ptr<Player> player) {
|
||||
player->releaseUsingItem();
|
||||
}
|
||||
|
||||
bool GameMode::isCutScene()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool GameMode::hasExperience() { return false; }
|
||||
|
||||
void GameMode::releaseUsingItem(std::shared_ptr<Player> player)
|
||||
{
|
||||
player->releaseUsingItem();
|
||||
}
|
||||
bool GameMode::hasMissTime() { return true; }
|
||||
|
||||
bool GameMode::hasExperience()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool GameMode::hasInfiniteItems() { return false; }
|
||||
|
||||
bool GameMode::hasMissTime()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool GameMode::hasFarPickRange() { return false; }
|
||||
|
||||
bool GameMode::hasInfiniteItems()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
void GameMode::handleCreativeModeItemAdd(std::shared_ptr<ItemInstance> clicked,
|
||||
int i) {}
|
||||
|
||||
bool GameMode::hasFarPickRange()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
void GameMode::handleCreativeModeItemDrop(
|
||||
std::shared_ptr<ItemInstance> clicked) {}
|
||||
|
||||
void GameMode::handleCreativeModeItemAdd(std::shared_ptr<ItemInstance> clicked, int i)
|
||||
{
|
||||
}
|
||||
|
||||
void GameMode::handleCreativeModeItemDrop(std::shared_ptr<ItemInstance> clicked)
|
||||
{
|
||||
}
|
||||
|
||||
bool GameMode::handleCraftItem(int recipe, std::shared_ptr<Player> player)
|
||||
{
|
||||
return true;
|
||||
bool GameMode::handleCraftItem(int recipe, std::shared_ptr<Player> player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 4J-PB
|
||||
void GameMode::handleDebugOptions(unsigned int uiVal, std::shared_ptr<Player> player)
|
||||
{
|
||||
player->SetDebugOptions(uiVal);
|
||||
void GameMode::handleDebugOptions(unsigned int uiVal,
|
||||
std::shared_ptr<Player> player) {
|
||||
player->SetDebugOptions(uiVal);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,17 +8,17 @@ class Entity;
|
|||
|
||||
class Tutorial;
|
||||
|
||||
class GameMode
|
||||
{
|
||||
class GameMode {
|
||||
protected:
|
||||
Minecraft *minecraft;
|
||||
Minecraft* minecraft;
|
||||
|
||||
public:
|
||||
bool instaBuild;
|
||||
bool instaBuild;
|
||||
|
||||
GameMode(Minecraft *minecraft);
|
||||
virtual ~GameMode() {}
|
||||
GameMode(Minecraft* minecraft);
|
||||
virtual ~GameMode() {}
|
||||
|
||||
virtual void initLevel(Level *level) ;
|
||||
virtual void initLevel(Level* level);
|
||||
virtual void startDestroyBlock(int x, int y, int z, int face) = 0;
|
||||
virtual bool destroyBlock(int x, int y, int z, int face);
|
||||
virtual void continueDestroyBlock(int x, int y, int z, int face) = 0;
|
||||
|
|
@ -29,31 +29,44 @@ public:
|
|||
virtual void tick();
|
||||
virtual bool canHurtPlayer() = 0;
|
||||
virtual void adjustPlayer(std::shared_ptr<Player> player);
|
||||
virtual bool useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, bool bTestUseOnly=false);
|
||||
virtual bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly=false, bool *pbUsedItem = NULL) = 0;
|
||||
virtual bool useItem(std::shared_ptr<Player> player, Level* level,
|
||||
std::shared_ptr<ItemInstance> item,
|
||||
bool bTestUseOnly = false);
|
||||
virtual bool useItemOn(std::shared_ptr<Player> player, Level* level,
|
||||
std::shared_ptr<ItemInstance> item, int x, int y,
|
||||
int z, int face, bool bTestUseOnOnly = false,
|
||||
bool* pbUsedItem = NULL) = 0;
|
||||
|
||||
virtual std::shared_ptr<Player> createPlayer(Level *level);
|
||||
virtual bool interact(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
|
||||
virtual void attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
|
||||
virtual std::shared_ptr<ItemInstance> handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, bool quickKeyHeld, std::shared_ptr<Player> player);
|
||||
virtual void handleCloseInventory(int containerId, std::shared_ptr<Player> player);
|
||||
virtual void handleInventoryButtonClick(int containerId, int buttonId);
|
||||
virtual std::shared_ptr<Player> createPlayer(Level* level);
|
||||
virtual bool interact(std::shared_ptr<Player> player,
|
||||
std::shared_ptr<Entity> entity);
|
||||
virtual void attack(std::shared_ptr<Player> player,
|
||||
std::shared_ptr<Entity> entity);
|
||||
virtual std::shared_ptr<ItemInstance> handleInventoryMouseClick(
|
||||
int containerId, int slotNum, int buttonNum, bool quickKeyHeld,
|
||||
std::shared_ptr<Player> player);
|
||||
virtual void handleCloseInventory(int containerId,
|
||||
std::shared_ptr<Player> player);
|
||||
virtual void handleInventoryButtonClick(int containerId, int buttonId);
|
||||
|
||||
virtual bool isCutScene();
|
||||
virtual void releaseUsingItem(std::shared_ptr<Player> player);
|
||||
virtual bool hasExperience();
|
||||
virtual bool hasMissTime();
|
||||
virtual bool hasInfiniteItems();
|
||||
virtual bool hasFarPickRange();
|
||||
virtual void handleCreativeModeItemAdd(std::shared_ptr<ItemInstance> clicked, int i);
|
||||
virtual void handleCreativeModeItemDrop(std::shared_ptr<ItemInstance> clicked);
|
||||
virtual bool isCutScene();
|
||||
virtual void releaseUsingItem(std::shared_ptr<Player> player);
|
||||
virtual bool hasExperience();
|
||||
virtual bool hasMissTime();
|
||||
virtual bool hasInfiniteItems();
|
||||
virtual bool hasFarPickRange();
|
||||
virtual void handleCreativeModeItemAdd(
|
||||
std::shared_ptr<ItemInstance> clicked, int i);
|
||||
virtual void handleCreativeModeItemDrop(
|
||||
std::shared_ptr<ItemInstance> clicked);
|
||||
|
||||
// 4J Stu - Added so we can send packets for this in the network game
|
||||
virtual bool handleCraftItem(int recipe, std::shared_ptr<Player> player);
|
||||
virtual void handleDebugOptions(unsigned int uiVal, std::shared_ptr<Player> player);
|
||||
// 4J Stu - Added so we can send packets for this in the network game
|
||||
virtual bool handleCraftItem(int recipe, std::shared_ptr<Player> player);
|
||||
virtual void handleDebugOptions(unsigned int uiVal,
|
||||
std::shared_ptr<Player> player);
|
||||
|
||||
// 4J Stu - Added for tutorial checks
|
||||
virtual bool isInputAllowed(int mapping) { return true; }
|
||||
virtual bool isTutorial() { return false; }
|
||||
virtual Tutorial *getTutorial() { return NULL; }
|
||||
// 4J Stu - Added for tutorial checks
|
||||
virtual bool isInputAllowed(int mapping) { return true; }
|
||||
virtual bool isTutorial() { return false; }
|
||||
virtual Tutorial* getTutorial() { return NULL; }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,100 +14,90 @@
|
|||
#include "../../Minecraft.World/IO/Streams/DataOutputStream.h"
|
||||
#include "../../Minecraft.World/Util/StringHelpers.h"
|
||||
|
||||
// 4J - the Option sub-class used to be an java enumerated type, trying to emulate that functionality here
|
||||
const Options::Option Options::Option::options[17] =
|
||||
{
|
||||
Options::Option(L"options.music", true, false),
|
||||
Options::Option(L"options.sound", true, false),
|
||||
Options::Option(L"options.invertMouse", false, true),
|
||||
Options::Option(L"options.sensitivity", true, false),
|
||||
Options::Option(L"options.renderDistance", false, false),
|
||||
Options::Option(L"options.viewBobbing", false, true),
|
||||
Options::Option(L"options.anaglyph", false, true),
|
||||
Options::Option(L"options.advancedOpengl", false, true),
|
||||
Options::Option(L"options.framerateLimit", false, false),
|
||||
Options::Option(L"options.difficulty", false, false),
|
||||
Options::Option(L"options.graphics", false, false),
|
||||
Options::Option(L"options.ao", false, true),
|
||||
Options::Option(L"options.guiScale", false, false),
|
||||
Options::Option(L"options.fov", true, false),
|
||||
Options::Option(L"options.gamma", true, false),
|
||||
Options::Option(L"options.renderClouds",false, true),
|
||||
Options::Option(L"options.particles", false, false),
|
||||
// 4J - the Option sub-class used to be an java enumerated type, trying to
|
||||
// emulate that functionality here
|
||||
const Options::Option Options::Option::options[17] = {
|
||||
Options::Option(L"options.music", true, false),
|
||||
Options::Option(L"options.sound", true, false),
|
||||
Options::Option(L"options.invertMouse", false, true),
|
||||
Options::Option(L"options.sensitivity", true, false),
|
||||
Options::Option(L"options.renderDistance", false, false),
|
||||
Options::Option(L"options.viewBobbing", false, true),
|
||||
Options::Option(L"options.anaglyph", false, true),
|
||||
Options::Option(L"options.advancedOpengl", false, true),
|
||||
Options::Option(L"options.framerateLimit", false, false),
|
||||
Options::Option(L"options.difficulty", false, false),
|
||||
Options::Option(L"options.graphics", false, false),
|
||||
Options::Option(L"options.ao", false, true),
|
||||
Options::Option(L"options.guiScale", false, false),
|
||||
Options::Option(L"options.fov", true, false),
|
||||
Options::Option(L"options.gamma", true, false),
|
||||
Options::Option(L"options.renderClouds", false, true),
|
||||
Options::Option(L"options.particles", false, false),
|
||||
};
|
||||
|
||||
const Options::Option *Options::Option::MUSIC = &Options::Option::options[0];
|
||||
const Options::Option *Options::Option::SOUND = &Options::Option::options[1];
|
||||
const Options::Option *Options::Option::INVERT_MOUSE = &Options::Option::options[2];
|
||||
const Options::Option *Options::Option::SENSITIVITY = &Options::Option::options[3];
|
||||
const Options::Option *Options::Option::RENDER_DISTANCE = &Options::Option::options[4];
|
||||
const Options::Option *Options::Option::VIEW_BOBBING = &Options::Option::options[5];
|
||||
const Options::Option *Options::Option::ANAGLYPH = &Options::Option::options[6];
|
||||
const Options::Option *Options::Option::ADVANCED_OPENGL = &Options::Option::options[7];
|
||||
const Options::Option *Options::Option::FRAMERATE_LIMIT = &Options::Option::options[8];
|
||||
const Options::Option *Options::Option::DIFFICULTY = &Options::Option::options[9];
|
||||
const Options::Option *Options::Option::GRAPHICS = &Options::Option::options[10];
|
||||
const Options::Option *Options::Option::AMBIENT_OCCLUSION = &Options::Option::options[11];
|
||||
const Options::Option *Options::Option::GUI_SCALE = &Options::Option::options[12];
|
||||
const Options::Option *Options::Option::FOV = &Options::Option::options[13];
|
||||
const Options::Option *Options::Option::GAMMA = &Options::Option::options[14];
|
||||
const Options::Option *Options::Option::RENDER_CLOUDS = &Options::Option::options[15];
|
||||
const Options::Option *Options::Option::PARTICLES = &Options::Option::options[16];
|
||||
const Options::Option* Options::Option::MUSIC = &Options::Option::options[0];
|
||||
const Options::Option* Options::Option::SOUND = &Options::Option::options[1];
|
||||
const Options::Option* Options::Option::INVERT_MOUSE =
|
||||
&Options::Option::options[2];
|
||||
const Options::Option* Options::Option::SENSITIVITY =
|
||||
&Options::Option::options[3];
|
||||
const Options::Option* Options::Option::RENDER_DISTANCE =
|
||||
&Options::Option::options[4];
|
||||
const Options::Option* Options::Option::VIEW_BOBBING =
|
||||
&Options::Option::options[5];
|
||||
const Options::Option* Options::Option::ANAGLYPH = &Options::Option::options[6];
|
||||
const Options::Option* Options::Option::ADVANCED_OPENGL =
|
||||
&Options::Option::options[7];
|
||||
const Options::Option* Options::Option::FRAMERATE_LIMIT =
|
||||
&Options::Option::options[8];
|
||||
const Options::Option* Options::Option::DIFFICULTY =
|
||||
&Options::Option::options[9];
|
||||
const Options::Option* Options::Option::GRAPHICS =
|
||||
&Options::Option::options[10];
|
||||
const Options::Option* Options::Option::AMBIENT_OCCLUSION =
|
||||
&Options::Option::options[11];
|
||||
const Options::Option* Options::Option::GUI_SCALE =
|
||||
&Options::Option::options[12];
|
||||
const Options::Option* Options::Option::FOV = &Options::Option::options[13];
|
||||
const Options::Option* Options::Option::GAMMA = &Options::Option::options[14];
|
||||
const Options::Option* Options::Option::RENDER_CLOUDS =
|
||||
&Options::Option::options[15];
|
||||
const Options::Option* Options::Option::PARTICLES =
|
||||
&Options::Option::options[16];
|
||||
|
||||
const Options::Option* Options::Option::getItem(int id) { return &options[id]; }
|
||||
|
||||
const Options::Option *Options::Option::getItem(int id)
|
||||
{
|
||||
return &options[id];
|
||||
}
|
||||
Options::Option::Option(const std::wstring& captionId, bool hasProgress,
|
||||
bool isBoolean)
|
||||
: _isProgress(hasProgress), _isBoolean(isBoolean), captionId(captionId) {}
|
||||
|
||||
Options::Option::Option(const std::wstring& captionId, bool hasProgress, bool isBoolean) : _isProgress(hasProgress), _isBoolean(isBoolean), captionId(captionId)
|
||||
{
|
||||
}
|
||||
bool Options::Option::isProgress() const { return _isProgress; }
|
||||
|
||||
bool Options::Option::isProgress() const
|
||||
{
|
||||
return _isProgress;
|
||||
}
|
||||
bool Options::Option::isBoolean() const { return _isBoolean; }
|
||||
|
||||
bool Options::Option::isBoolean() const
|
||||
{
|
||||
return _isBoolean;
|
||||
}
|
||||
int Options::Option::getId() const { return (int)(this - options); }
|
||||
|
||||
int Options::Option::getId() const
|
||||
{
|
||||
return (int)(this-options);
|
||||
}
|
||||
std::wstring Options::Option::getCaptionId() const { return captionId; }
|
||||
|
||||
std::wstring Options::Option::getCaptionId() const
|
||||
{
|
||||
return captionId;
|
||||
}
|
||||
const std::wstring Options::RENDER_DISTANCE_NAMES[] = {
|
||||
L"options.renderDistance.far", L"options.renderDistance.normal",
|
||||
L"options.renderDistance.short", L"options.renderDistance.tiny"};
|
||||
const std::wstring Options::DIFFICULTY_NAMES[] = {
|
||||
L"options.difficulty.peaceful", L"options.difficulty.easy",
|
||||
L"options.difficulty.normal", L"options.difficulty.hard"};
|
||||
const std::wstring Options::GUI_SCALE[] = {
|
||||
L"options.guiScale.auto", L"options.guiScale.small",
|
||||
L"options.guiScale.normal", L"options.guiScale.large"};
|
||||
const std::wstring Options::FRAMERATE_LIMITS[] = {
|
||||
L"performance.max", L"performance.balanced", L"performance.powersaver"};
|
||||
|
||||
const std::wstring Options::RENDER_DISTANCE_NAMES[] =
|
||||
{
|
||||
L"options.renderDistance.far", L"options.renderDistance.normal", L"options.renderDistance.short", L"options.renderDistance.tiny"
|
||||
};
|
||||
const std::wstring Options::DIFFICULTY_NAMES[] =
|
||||
{
|
||||
L"options.difficulty.peaceful", L"options.difficulty.easy", L"options.difficulty.normal", L"options.difficulty.hard"
|
||||
};
|
||||
const std::wstring Options::GUI_SCALE[] =
|
||||
{
|
||||
L"options.guiScale.auto", L"options.guiScale.small", L"options.guiScale.normal", L"options.guiScale.large"
|
||||
};
|
||||
const std::wstring Options::FRAMERATE_LIMITS[] =
|
||||
{
|
||||
L"performance.max", L"performance.balanced", L"performance.powersaver"
|
||||
};
|
||||
|
||||
const std::wstring Options::PARTICLES[] = {
|
||||
L"options.particles.all", L"options.particles.decreased", L"options.particles.minimal"
|
||||
};
|
||||
const std::wstring Options::PARTICLES[] = {L"options.particles.all",
|
||||
L"options.particles.decreased",
|
||||
L"options.particles.minimal"};
|
||||
|
||||
// 4J added
|
||||
void Options::init()
|
||||
{
|
||||
void Options::init() {
|
||||
music = 1;
|
||||
sound = 1;
|
||||
sensitivity = 0.5f;
|
||||
|
|
@ -116,16 +106,16 @@ void Options::init()
|
|||
bobView = true;
|
||||
anaglyph3d = false;
|
||||
advancedOpengl = false;
|
||||
|
||||
//4JCRAFT V-Sync / VSync
|
||||
#ifdef ENABLE_VSYNC
|
||||
|
||||
// 4JCRAFT V-Sync / VSync
|
||||
#ifdef ENABLE_VSYNC
|
||||
framerateLimit = 2;
|
||||
#else
|
||||
#else
|
||||
framerateLimit = 3;
|
||||
#endif
|
||||
#endif
|
||||
fancyGraphics = true;
|
||||
ambientOcclusion = true;
|
||||
renderClouds = true;
|
||||
renderClouds = true;
|
||||
skin = L"Default";
|
||||
|
||||
keyUp = new KeyMapping(L"key.forward", Keyboard::KEY_W);
|
||||
|
|
@ -137,398 +127,351 @@ void Options::init()
|
|||
keyDrop = new KeyMapping(L"key.drop", Keyboard::KEY_Q);
|
||||
keyChat = new KeyMapping(L"key.chat", Keyboard::KEY_T);
|
||||
keySneak = new KeyMapping(L"key.sneak", Keyboard::KEY_LSHIFT);
|
||||
keyAttack = new KeyMapping(L"key.attack", -100 + 0);
|
||||
keyAttack = new KeyMapping(L"key.attack", -100 + 0);
|
||||
keyUse = new KeyMapping(L"key.use", -100 + 1);
|
||||
keyPlayerList = new KeyMapping(L"key.playerlist", Keyboard::KEY_TAB);
|
||||
keyPickItem = new KeyMapping(L"key.pickItem", -100 + 2);
|
||||
keyToggleFog = new KeyMapping(L"key.fog", Keyboard::KEY_F);
|
||||
|
||||
keyMappings[0] = keyAttack;
|
||||
keyMappings[1] = keyUse;
|
||||
keyMappings[0] = keyAttack;
|
||||
keyMappings[1] = keyUse;
|
||||
keyMappings[2] = keyUp;
|
||||
keyMappings[3] = keyLeft;
|
||||
keyMappings[4] = keyDown;
|
||||
keyMappings[5] = keyRight;
|
||||
keyMappings[6] = keyJump;
|
||||
keyMappings[7] = keySneak;
|
||||
keyMappings[8] = keyDrop;
|
||||
keyMappings[9] = keyBuild;
|
||||
keyMappings[10] = keyChat;
|
||||
keyMappings[11] = keyPlayerList;
|
||||
keyMappings[12] = keyPickItem;
|
||||
keyMappings[13] = keyToggleFog;
|
||||
keyMappings[3] = keyLeft;
|
||||
keyMappings[4] = keyDown;
|
||||
keyMappings[5] = keyRight;
|
||||
keyMappings[6] = keyJump;
|
||||
keyMappings[7] = keySneak;
|
||||
keyMappings[8] = keyDrop;
|
||||
keyMappings[9] = keyBuild;
|
||||
keyMappings[10] = keyChat;
|
||||
keyMappings[11] = keyPlayerList;
|
||||
keyMappings[12] = keyPickItem;
|
||||
keyMappings[13] = keyToggleFog;
|
||||
|
||||
minecraft = NULL;
|
||||
//optionsFile = NULL;
|
||||
minecraft = NULL;
|
||||
// optionsFile = NULL;
|
||||
|
||||
difficulty = 2;
|
||||
hideGui = false;
|
||||
thirdPersonView = false;
|
||||
renderDebug = false;
|
||||
lastMpIp = L"";
|
||||
difficulty = 2;
|
||||
hideGui = false;
|
||||
thirdPersonView = false;
|
||||
renderDebug = false;
|
||||
lastMpIp = L"";
|
||||
|
||||
isFlying = false;
|
||||
smoothCamera = false;
|
||||
fixedCamera = false;
|
||||
flySpeed = 1;
|
||||
cameraSpeed = 1;
|
||||
guiScale = 0;
|
||||
particles = 0;
|
||||
fov = 0;
|
||||
gamma = 0;
|
||||
isFlying = false;
|
||||
smoothCamera = false;
|
||||
fixedCamera = false;
|
||||
flySpeed = 1;
|
||||
cameraSpeed = 1;
|
||||
guiScale = 0;
|
||||
particles = 0;
|
||||
fov = 0;
|
||||
gamma = 0;
|
||||
}
|
||||
|
||||
Options::Options(Minecraft *minecraft, File workingDirectory)
|
||||
{
|
||||
init();
|
||||
this->minecraft = minecraft;
|
||||
optionsFile = File(workingDirectory, L"options.txt");
|
||||
Options::Options(Minecraft* minecraft, File workingDirectory) {
|
||||
init();
|
||||
this->minecraft = minecraft;
|
||||
optionsFile = File(workingDirectory, L"options.txt");
|
||||
}
|
||||
|
||||
Options::Options()
|
||||
{
|
||||
init();
|
||||
}
|
||||
Options::Options() { init(); }
|
||||
|
||||
std::wstring Options::getKeyDescription(int i)
|
||||
{
|
||||
Language *language = Language::getInstance();
|
||||
std::wstring Options::getKeyDescription(int i) {
|
||||
Language* language = Language::getInstance();
|
||||
return language->getElement(keyMappings[i]->name);
|
||||
}
|
||||
|
||||
std::wstring Options::getKeyMessage(int i)
|
||||
{
|
||||
int key = keyMappings[i]->key;
|
||||
if (key < 0) {
|
||||
return I18n::get(L"key.mouseButton", key + 101);
|
||||
} else {
|
||||
return Keyboard::getKeyName(keyMappings[i]->key);
|
||||
}
|
||||
std::wstring Options::getKeyMessage(int i) {
|
||||
int key = keyMappings[i]->key;
|
||||
if (key < 0) {
|
||||
return I18n::get(L"key.mouseButton", key + 101);
|
||||
} else {
|
||||
return Keyboard::getKeyName(keyMappings[i]->key);
|
||||
}
|
||||
}
|
||||
|
||||
void Options::setKey(int i, int key)
|
||||
{
|
||||
void Options::setKey(int i, int key) {
|
||||
keyMappings[i]->key = key;
|
||||
save();
|
||||
}
|
||||
|
||||
void Options::set(const Options::Option *item, float fVal)
|
||||
{
|
||||
if (item == Option::MUSIC)
|
||||
{
|
||||
void Options::set(const Options::Option* item, float fVal) {
|
||||
if (item == Option::MUSIC) {
|
||||
music = fVal;
|
||||
#ifdef _XBOX
|
||||
minecraft->soundEngine->updateMusicVolume(fVal*2.0f);
|
||||
minecraft->soundEngine->updateMusicVolume(fVal * 2.0f);
|
||||
#else
|
||||
minecraft->soundEngine->updateMusicVolume(fVal);
|
||||
minecraft->soundEngine->updateMusicVolume(fVal);
|
||||
#endif
|
||||
}
|
||||
if (item == Option::SOUND)
|
||||
{
|
||||
if (item == Option::SOUND) {
|
||||
sound = fVal;
|
||||
#ifdef _XBOX
|
||||
minecraft->soundEngine->updateSoundEffectVolume(fVal*2.0f);
|
||||
minecraft->soundEngine->updateSoundEffectVolume(fVal * 2.0f);
|
||||
#else
|
||||
minecraft->soundEngine->updateSoundEffectVolume(fVal);
|
||||
minecraft->soundEngine->updateSoundEffectVolume(fVal);
|
||||
#endif
|
||||
}
|
||||
if (item == Option::SENSITIVITY)
|
||||
{
|
||||
if (item == Option::SENSITIVITY) {
|
||||
sensitivity = fVal;
|
||||
}
|
||||
if (item == Option::FOV)
|
||||
{
|
||||
fov = fVal;
|
||||
}
|
||||
if (item == Option::GAMMA)
|
||||
{
|
||||
gamma = fVal;
|
||||
}
|
||||
if (item == Option::FOV) {
|
||||
fov = fVal;
|
||||
}
|
||||
if (item == Option::GAMMA) {
|
||||
gamma = fVal;
|
||||
}
|
||||
}
|
||||
|
||||
void Options::toggle(const Options::Option *option, int dir)
|
||||
{
|
||||
void Options::toggle(const Options::Option* option, int dir) {
|
||||
if (option == Option::INVERT_MOUSE) invertYMouse = !invertYMouse;
|
||||
if (option == Option::RENDER_DISTANCE) viewDistance = (viewDistance + dir) & 3;
|
||||
if (option == Option::RENDER_DISTANCE)
|
||||
viewDistance = (viewDistance + dir) & 3;
|
||||
if (option == Option::GUI_SCALE) guiScale = (guiScale + dir) & 3;
|
||||
if (option == Option::PARTICLES) particles = (particles + dir) % 3;
|
||||
if (option == Option::PARTICLES) particles = (particles + dir) % 3;
|
||||
|
||||
// 4J-PB - changing
|
||||
//if (option == Option::VIEW_BOBBING) bobView = !bobView;
|
||||
if (option == Option::VIEW_BOBBING) ((dir==0)?bobView=false: bobView=true);
|
||||
if (option == Option::RENDER_CLOUDS) renderClouds = !renderClouds;
|
||||
if (option == Option::ADVANCED_OPENGL)
|
||||
{
|
||||
// 4J-PB - changing
|
||||
// if (option == Option::VIEW_BOBBING) bobView = !bobView;
|
||||
if (option == Option::VIEW_BOBBING)
|
||||
((dir == 0) ? bobView = false : bobView = true);
|
||||
if (option == Option::RENDER_CLOUDS) renderClouds = !renderClouds;
|
||||
if (option == Option::ADVANCED_OPENGL) {
|
||||
advancedOpengl = !advancedOpengl;
|
||||
// 4jcraft: ensure level exists before applying
|
||||
if(minecraft->level) minecraft->levelRenderer->allChanged();
|
||||
}
|
||||
if (option == Option::ANAGLYPH)
|
||||
{
|
||||
if (option == Option::ANAGLYPH) {
|
||||
anaglyph3d = !anaglyph3d;
|
||||
minecraft->textures->reloadAll();
|
||||
}
|
||||
if (option == Option::FRAMERATE_LIMIT) framerateLimit = (framerateLimit + dir + 3) % 3;
|
||||
if (option == Option::FRAMERATE_LIMIT)
|
||||
framerateLimit = (framerateLimit + dir + 3) % 3;
|
||||
|
||||
// 4J-PB - Change for Xbox
|
||||
//if (option == Option::DIFFICULTY) difficulty = (difficulty + dir) & 3;
|
||||
if (option == Option::DIFFICULTY) difficulty = (dir) & 3;
|
||||
// 4J-PB - Change for Xbox
|
||||
// if (option == Option::DIFFICULTY) difficulty = (difficulty + dir) & 3;
|
||||
if (option == Option::DIFFICULTY) difficulty = (dir) & 3;
|
||||
|
||||
app.DebugPrintf("Option::DIFFICULTY = %d",difficulty);
|
||||
app.DebugPrintf("Option::DIFFICULTY = %d", difficulty);
|
||||
|
||||
if (option == Option::GRAPHICS)
|
||||
{
|
||||
if (option == Option::GRAPHICS) {
|
||||
fancyGraphics = !fancyGraphics;
|
||||
// 4jcraft: ensure level exists before applying
|
||||
if(minecraft->level) minecraft->levelRenderer->allChanged();
|
||||
}
|
||||
if (option == Option::AMBIENT_OCCLUSION)
|
||||
{
|
||||
if (option == Option::AMBIENT_OCCLUSION) {
|
||||
ambientOcclusion = !ambientOcclusion;
|
||||
// 4jcraft: ensure level exists before applying
|
||||
if(minecraft->level) minecraft->levelRenderer->allChanged();
|
||||
}
|
||||
|
||||
// 4J-PB - don't do the file save on the xbox
|
||||
// 4J-PB - don't do the file save on the xbox
|
||||
// save();
|
||||
|
||||
}
|
||||
|
||||
float Options::getProgressValue(const Options::Option *item)
|
||||
{
|
||||
if (item == Option::FOV) return fov;
|
||||
if (item == Option::GAMMA) return gamma;
|
||||
float Options::getProgressValue(const Options::Option* item) {
|
||||
if (item == Option::FOV) return fov;
|
||||
if (item == Option::GAMMA) return gamma;
|
||||
if (item == Option::MUSIC) return music;
|
||||
if (item == Option::SOUND) return sound;
|
||||
if (item == Option::SENSITIVITY) return sensitivity;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Options::getBooleanValue(const Options::Option *item)
|
||||
{
|
||||
// 4J - was a switch statement which we can't do with our Option:: pointer types
|
||||
if( item == Option::INVERT_MOUSE) return invertYMouse;
|
||||
if( item == Option::VIEW_BOBBING) return bobView;
|
||||
if( item == Option::ANAGLYPH) return anaglyph3d;
|
||||
if( item == Option::ADVANCED_OPENGL) return advancedOpengl;
|
||||
if( item == Option::AMBIENT_OCCLUSION) return ambientOcclusion;
|
||||
if( item == Option::RENDER_CLOUDS) return renderClouds;
|
||||
return false;
|
||||
bool Options::getBooleanValue(const Options::Option* item) {
|
||||
// 4J - was a switch statement which we can't do with our Option:: pointer
|
||||
// types
|
||||
if (item == Option::INVERT_MOUSE) return invertYMouse;
|
||||
if (item == Option::VIEW_BOBBING) return bobView;
|
||||
if (item == Option::ANAGLYPH) return anaglyph3d;
|
||||
if (item == Option::ADVANCED_OPENGL) return advancedOpengl;
|
||||
if (item == Option::AMBIENT_OCCLUSION) return ambientOcclusion;
|
||||
if (item == Option::RENDER_CLOUDS) return renderClouds;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::wstring Options::getMessage(const Options::Option *item)
|
||||
{
|
||||
// 4J TODO, should these std::wstrings append rather than add?
|
||||
std::wstring Options::getMessage(const Options::Option* item) {
|
||||
// 4J TODO, should these std::wstrings append rather than add?
|
||||
|
||||
Language *language = Language::getInstance();
|
||||
Language* language = Language::getInstance();
|
||||
std::wstring caption = language->getElement(item->getCaptionId()) + L": ";
|
||||
|
||||
if (item->isProgress())
|
||||
{
|
||||
if (item->isProgress()) {
|
||||
float progressValue = getProgressValue(item);
|
||||
|
||||
if (item == Option::SENSITIVITY)
|
||||
{
|
||||
if (progressValue == 0)
|
||||
{
|
||||
return caption + language->getElement(L"options.sensitivity.min");
|
||||
if (item == Option::SENSITIVITY) {
|
||||
if (progressValue == 0) {
|
||||
return caption +
|
||||
language->getElement(L"options.sensitivity.min");
|
||||
}
|
||||
if (progressValue == 1)
|
||||
{
|
||||
return caption + language->getElement(L"options.sensitivity.max");
|
||||
if (progressValue == 1) {
|
||||
return caption +
|
||||
language->getElement(L"options.sensitivity.max");
|
||||
}
|
||||
return caption + _toString<int>((int) (progressValue * 200)) + L"%";
|
||||
} else if (item == Option::FOV)
|
||||
{
|
||||
if (progressValue == 0)
|
||||
{
|
||||
return caption + language->getElement(L"options.fov.min");
|
||||
}
|
||||
if (progressValue == 1)
|
||||
{
|
||||
return caption + language->getElement(L"options.fov.max");
|
||||
}
|
||||
return caption + _toString<int>((int) (70 + progressValue * 40));
|
||||
} else if (item == Option::GAMMA)
|
||||
{
|
||||
if (progressValue == 0)
|
||||
{
|
||||
return caption + language->getElement(L"options.gamma.min");
|
||||
}
|
||||
if (progressValue == 1)
|
||||
{
|
||||
return caption + language->getElement(L"options.gamma.max");
|
||||
}
|
||||
return caption + L"+" + _toString<int>((int) (progressValue * 100)) + L"%";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (progressValue == 0)
|
||||
{
|
||||
return caption + _toString<int>((int)(progressValue * 200)) + L"%";
|
||||
} else if (item == Option::FOV) {
|
||||
if (progressValue == 0) {
|
||||
return caption + language->getElement(L"options.fov.min");
|
||||
}
|
||||
if (progressValue == 1) {
|
||||
return caption + language->getElement(L"options.fov.max");
|
||||
}
|
||||
return caption + _toString<int>((int)(70 + progressValue * 40));
|
||||
} else if (item == Option::GAMMA) {
|
||||
if (progressValue == 0) {
|
||||
return caption + language->getElement(L"options.gamma.min");
|
||||
}
|
||||
if (progressValue == 1) {
|
||||
return caption + language->getElement(L"options.gamma.max");
|
||||
}
|
||||
return caption + L"+" + _toString<int>((int)(progressValue * 100)) +
|
||||
L"%";
|
||||
} else {
|
||||
if (progressValue == 0) {
|
||||
return caption + language->getElement(L"options.off");
|
||||
}
|
||||
return caption + _toString<int>((int) (progressValue * 100)) + L"%";
|
||||
return caption + _toString<int>((int)(progressValue * 100)) + L"%";
|
||||
}
|
||||
} else if (item->isBoolean())
|
||||
{
|
||||
|
||||
} else if (item->isBoolean()) {
|
||||
bool booleanValue = getBooleanValue(item);
|
||||
if (booleanValue)
|
||||
{
|
||||
if (booleanValue) {
|
||||
return caption + language->getElement(L"options.on");
|
||||
}
|
||||
return caption + language->getElement(L"options.off");
|
||||
}
|
||||
else if (item == Option::RENDER_DISTANCE)
|
||||
{
|
||||
return caption + language->getElement(RENDER_DISTANCE_NAMES[viewDistance]);
|
||||
}
|
||||
else if (item == Option::DIFFICULTY)
|
||||
{
|
||||
} else if (item == Option::RENDER_DISTANCE) {
|
||||
return caption +
|
||||
language->getElement(RENDER_DISTANCE_NAMES[viewDistance]);
|
||||
} else if (item == Option::DIFFICULTY) {
|
||||
return caption + language->getElement(DIFFICULTY_NAMES[difficulty]);
|
||||
}
|
||||
else if (item == Option::GUI_SCALE)
|
||||
{
|
||||
} else if (item == Option::GUI_SCALE) {
|
||||
return caption + language->getElement(GUI_SCALE[guiScale]);
|
||||
}
|
||||
else if (item == Option::PARTICLES)
|
||||
{
|
||||
return caption + language->getElement(PARTICLES[particles]);
|
||||
}
|
||||
else if (item == Option::FRAMERATE_LIMIT)
|
||||
{
|
||||
} else if (item == Option::PARTICLES) {
|
||||
return caption + language->getElement(PARTICLES[particles]);
|
||||
} else if (item == Option::FRAMERATE_LIMIT) {
|
||||
return caption + I18n::get(FRAMERATE_LIMITS[framerateLimit]);
|
||||
}
|
||||
else if (item == Option::GRAPHICS)
|
||||
{
|
||||
if (fancyGraphics)
|
||||
{
|
||||
} else if (item == Option::GRAPHICS) {
|
||||
if (fancyGraphics) {
|
||||
return caption + language->getElement(L"options.graphics.fancy");
|
||||
}
|
||||
return caption + language->getElement(L"options.graphics.fast");
|
||||
}
|
||||
|
||||
return caption;
|
||||
|
||||
}
|
||||
|
||||
void Options::load()
|
||||
{
|
||||
// 4J - removed try/catch
|
||||
// try {
|
||||
if (!optionsFile.exists()) return;
|
||||
// 4J - was new BufferedReader(new FileReader(optionsFile));
|
||||
BufferedReader *br = new BufferedReader(new InputStreamReader( new FileInputStream( optionsFile ) ) );
|
||||
|
||||
std::wstring line = L"";
|
||||
while ((line = br->readLine()) != L"") // 4J - was check against NULL - do we need to distinguish between empty lines and a fail here?
|
||||
{
|
||||
// 4J - removed try/catch
|
||||
// try {
|
||||
std::wstring cmds[2];
|
||||
int splitpos = (int)line.find(L":");
|
||||
if( splitpos == std::wstring::npos )
|
||||
{
|
||||
cmds[0] = line;
|
||||
cmds[1] = L"";
|
||||
}
|
||||
else
|
||||
{
|
||||
cmds[0] = line.substr(0,splitpos);
|
||||
cmds[1] = line.substr(splitpos,line.length()-splitpos);
|
||||
}
|
||||
void Options::load() {
|
||||
// 4J - removed try/catch
|
||||
// try {
|
||||
if (!optionsFile.exists()) return;
|
||||
// 4J - was new BufferedReader(new FileReader(optionsFile));
|
||||
BufferedReader* br = new BufferedReader(
|
||||
new InputStreamReader(new FileInputStream(optionsFile)));
|
||||
|
||||
if (cmds[0] == L"music") music = readFloat(cmds[1]);
|
||||
if (cmds[0] == L"sound") sound = readFloat(cmds[1]);
|
||||
if (cmds[0] == L"mouseSensitivity") sensitivity = readFloat(cmds[1]);
|
||||
if (cmds[0] == L"fov") fov = readFloat(cmds[1]);
|
||||
if (cmds[0] == L"gamma") gamma = readFloat(cmds[1]);
|
||||
if (cmds[0] == L"invertYMouse") invertYMouse = cmds[1]==L"true";
|
||||
if (cmds[0] == L"viewDistance") viewDistance = _fromString<int>(cmds[1]);
|
||||
if (cmds[0] == L"guiScale") guiScale =_fromString<int>(cmds[1]);
|
||||
if (cmds[0] == L"particles") particles = _fromString<int>(cmds[1]);
|
||||
if (cmds[0] == L"bobView") bobView = cmds[1]==L"true";
|
||||
if (cmds[0] == L"anaglyph3d") anaglyph3d = cmds[1]==L"true";
|
||||
if (cmds[0] == L"advancedOpengl") advancedOpengl = cmds[1]==L"true";
|
||||
if (cmds[0] == L"fpsLimit") framerateLimit = _fromString<int>(cmds[1]);
|
||||
if (cmds[0] == L"difficulty") difficulty = _fromString<int>(cmds[1]);
|
||||
if (cmds[0] == L"fancyGraphics") fancyGraphics = cmds[1]==L"true";
|
||||
if (cmds[0] == L"ao") ambientOcclusion = cmds[1]==L"true";
|
||||
if (cmds[0] == L"clouds") renderClouds = cmds[1]==L"true";
|
||||
if (cmds[0] == L"skin") skin = cmds[1];
|
||||
if (cmds[0] == L"lastServer") lastMpIp = cmds[1];
|
||||
|
||||
for (int i = 0; i < keyMappings_length; i++)
|
||||
{
|
||||
if (cmds[0] == (L"key_" + keyMappings[i]->name))
|
||||
{
|
||||
keyMappings[i]->key = _fromString<int>(cmds[1]);
|
||||
}
|
||||
}
|
||||
// } catch (Exception e) {
|
||||
// System.out.println("Skipping bad option: " + line);
|
||||
// }
|
||||
std::wstring line = L"";
|
||||
while ((line = br->readLine()) !=
|
||||
L"") // 4J - was check against NULL - do we need to distinguish
|
||||
// between empty lines and a fail here?
|
||||
{
|
||||
// 4J - removed try/catch
|
||||
// try {
|
||||
std::wstring cmds[2];
|
||||
int splitpos = (int)line.find(L":");
|
||||
if (splitpos == std::wstring::npos) {
|
||||
cmds[0] = line;
|
||||
cmds[1] = L"";
|
||||
} else {
|
||||
cmds[0] = line.substr(0, splitpos);
|
||||
cmds[1] = line.substr(splitpos, line.length() - splitpos);
|
||||
}
|
||||
//KeyMapping.resetMapping(); // 4J Not implemented
|
||||
br->close();
|
||||
// } catch (Exception e) {
|
||||
// System.out.println("Failed to load options");
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
if (cmds[0] == L"music") music = readFloat(cmds[1]);
|
||||
if (cmds[0] == L"sound") sound = readFloat(cmds[1]);
|
||||
if (cmds[0] == L"mouseSensitivity") sensitivity = readFloat(cmds[1]);
|
||||
if (cmds[0] == L"fov") fov = readFloat(cmds[1]);
|
||||
if (cmds[0] == L"gamma") gamma = readFloat(cmds[1]);
|
||||
if (cmds[0] == L"invertYMouse") invertYMouse = cmds[1] == L"true";
|
||||
if (cmds[0] == L"viewDistance")
|
||||
viewDistance = _fromString<int>(cmds[1]);
|
||||
if (cmds[0] == L"guiScale") guiScale = _fromString<int>(cmds[1]);
|
||||
if (cmds[0] == L"particles") particles = _fromString<int>(cmds[1]);
|
||||
if (cmds[0] == L"bobView") bobView = cmds[1] == L"true";
|
||||
if (cmds[0] == L"anaglyph3d") anaglyph3d = cmds[1] == L"true";
|
||||
if (cmds[0] == L"advancedOpengl") advancedOpengl = cmds[1] == L"true";
|
||||
if (cmds[0] == L"fpsLimit") framerateLimit = _fromString<int>(cmds[1]);
|
||||
if (cmds[0] == L"difficulty") difficulty = _fromString<int>(cmds[1]);
|
||||
if (cmds[0] == L"fancyGraphics") fancyGraphics = cmds[1] == L"true";
|
||||
if (cmds[0] == L"ao") ambientOcclusion = cmds[1] == L"true";
|
||||
if (cmds[0] == L"clouds") renderClouds = cmds[1] == L"true";
|
||||
if (cmds[0] == L"skin") skin = cmds[1];
|
||||
if (cmds[0] == L"lastServer") lastMpIp = cmds[1];
|
||||
|
||||
for (int i = 0; i < keyMappings_length; i++) {
|
||||
if (cmds[0] == (L"key_" + keyMappings[i]->name)) {
|
||||
keyMappings[i]->key = _fromString<int>(cmds[1]);
|
||||
}
|
||||
}
|
||||
// } catch (Exception e) {
|
||||
// System.out.println("Skipping bad option: " + line);
|
||||
// }
|
||||
}
|
||||
// KeyMapping.resetMapping(); // 4J Not implemented
|
||||
br->close();
|
||||
// } catch (Exception e) {
|
||||
// System.out.println("Failed to load options");
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
float Options::readFloat(std::wstring string)
|
||||
{
|
||||
float Options::readFloat(std::wstring string) {
|
||||
if (string == L"true") return 1;
|
||||
if (string == L"false") return 0;
|
||||
return _fromString<float>(string);
|
||||
}
|
||||
|
||||
void Options::save()
|
||||
{
|
||||
// 4J - try/catch removed
|
||||
// try {
|
||||
void Options::save() {
|
||||
// 4J - try/catch removed
|
||||
// try {
|
||||
|
||||
// 4J - original used a PrintWriter & FileWriter, but seems a bit much implementing these just to do this
|
||||
FileOutputStream fos = FileOutputStream(optionsFile);
|
||||
DataOutputStream dos = DataOutputStream(&fos);
|
||||
// PrintWriter pw = new PrintWriter(new FileWriter(optionsFile));
|
||||
// 4J - original used a PrintWriter & FileWriter, but seems a bit much
|
||||
// implementing these just to do this
|
||||
FileOutputStream fos = FileOutputStream(optionsFile);
|
||||
DataOutputStream dos = DataOutputStream(&fos);
|
||||
// PrintWriter pw = new PrintWriter(new FileWriter(optionsFile));
|
||||
|
||||
dos.writeChars(L"music:" + _toString<float>(music) + L"\n");
|
||||
dos.writeChars(L"sound:" + _toString<float>(sound) + L"\n");
|
||||
dos.writeChars(L"invertYMouse:" + std::wstring(invertYMouse ? L"true" : L"false") + L"\n");
|
||||
dos.writeChars(L"mouseSensitivity:" + _toString<float>(sensitivity));
|
||||
dos.writeChars(L"fov:" + _toString<float>(fov));
|
||||
dos.writeChars(L"gamma:" + _toString<float>(gamma));
|
||||
dos.writeChars(L"viewDistance:" + _toString<int>(viewDistance));
|
||||
dos.writeChars(L"guiScale:" + _toString<int>(guiScale));
|
||||
dos.writeChars(L"particles:" + _toString<int>(particles));
|
||||
dos.writeChars(L"bobView:" + std::wstring(bobView ? L"true" : L"false"));
|
||||
dos.writeChars(L"anaglyph3d:" + std::wstring(anaglyph3d ? L"true" : L"false"));
|
||||
dos.writeChars(L"advancedOpengl:" + std::wstring(advancedOpengl ? L"true" : L"false"));
|
||||
dos.writeChars(L"fpsLimit:" + _toString<int>(framerateLimit));
|
||||
dos.writeChars(L"difficulty:" + _toString<int>(difficulty));
|
||||
dos.writeChars(L"fancyGraphics:" + std::wstring(fancyGraphics ? L"true" : L"false"));
|
||||
dos.writeChars(L"ao:" + std::wstring(ambientOcclusion ? L"true" : L"false"));
|
||||
dos.writeChars(L"clouds:" + _toString<bool>(renderClouds));
|
||||
dos.writeChars(L"skin:" + skin);
|
||||
dos.writeChars(L"lastServer:" + lastMpIp);
|
||||
dos.writeChars(L"music:" + _toString<float>(music) + L"\n");
|
||||
dos.writeChars(L"sound:" + _toString<float>(sound) + L"\n");
|
||||
dos.writeChars(L"invertYMouse:" +
|
||||
std::wstring(invertYMouse ? L"true" : L"false") + L"\n");
|
||||
dos.writeChars(L"mouseSensitivity:" + _toString<float>(sensitivity));
|
||||
dos.writeChars(L"fov:" + _toString<float>(fov));
|
||||
dos.writeChars(L"gamma:" + _toString<float>(gamma));
|
||||
dos.writeChars(L"viewDistance:" + _toString<int>(viewDistance));
|
||||
dos.writeChars(L"guiScale:" + _toString<int>(guiScale));
|
||||
dos.writeChars(L"particles:" + _toString<int>(particles));
|
||||
dos.writeChars(L"bobView:" + std::wstring(bobView ? L"true" : L"false"));
|
||||
dos.writeChars(L"anaglyph3d:" +
|
||||
std::wstring(anaglyph3d ? L"true" : L"false"));
|
||||
dos.writeChars(L"advancedOpengl:" +
|
||||
std::wstring(advancedOpengl ? L"true" : L"false"));
|
||||
dos.writeChars(L"fpsLimit:" + _toString<int>(framerateLimit));
|
||||
dos.writeChars(L"difficulty:" + _toString<int>(difficulty));
|
||||
dos.writeChars(L"fancyGraphics:" +
|
||||
std::wstring(fancyGraphics ? L"true" : L"false"));
|
||||
dos.writeChars(L"ao:" +
|
||||
std::wstring(ambientOcclusion ? L"true" : L"false"));
|
||||
dos.writeChars(L"clouds:" + _toString<bool>(renderClouds));
|
||||
dos.writeChars(L"skin:" + skin);
|
||||
dos.writeChars(L"lastServer:" + lastMpIp);
|
||||
|
||||
for (int i = 0; i < keyMappings_length; i++)
|
||||
{
|
||||
dos.writeChars(L"key_" + keyMappings[i]->name + L":" + _toString<int>(keyMappings[i]->key));
|
||||
}
|
||||
|
||||
dos.close();
|
||||
// } catch (Exception e) {
|
||||
// System.out.println("Failed to save options");
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
for (int i = 0; i < keyMappings_length; i++) {
|
||||
dos.writeChars(L"key_" + keyMappings[i]->name + L":" +
|
||||
_toString<int>(keyMappings[i]->key));
|
||||
}
|
||||
|
||||
dos.close();
|
||||
// } catch (Exception e) {
|
||||
// System.out.println("Failed to save options");
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
bool Options::isCloudsOn()
|
||||
{
|
||||
return viewDistance < 2 && renderClouds;
|
||||
}
|
||||
bool Options::isCloudsOn() { return viewDistance < 2 && renderClouds; }
|
||||
|
|
|
|||
|
|
@ -4,60 +4,58 @@ class Minecraft;
|
|||
class KeyMapping;
|
||||
#include "../../Minecraft.World/IO/Files/File.h"
|
||||
|
||||
class Options
|
||||
{
|
||||
class Options {
|
||||
public:
|
||||
static const int AO_OFF = 0;
|
||||
static const int AO_MIN = 1;
|
||||
static const int AO_MAX = 2;
|
||||
static const int AO_OFF = 0;
|
||||
static const int AO_MIN = 1;
|
||||
static const int AO_MAX = 2;
|
||||
|
||||
// 4J - this used to be an enum
|
||||
class Option
|
||||
{
|
||||
public:
|
||||
static const Option options[17];
|
||||
static const Option *MUSIC;
|
||||
static const Option *SOUND;
|
||||
static const Option *INVERT_MOUSE;
|
||||
static const Option *SENSITIVITY;
|
||||
static const Option *RENDER_DISTANCE;
|
||||
static const Option *VIEW_BOBBING;
|
||||
static const Option *ANAGLYPH;
|
||||
static const Option *ADVANCED_OPENGL;
|
||||
static const Option *FRAMERATE_LIMIT;
|
||||
static const Option *DIFFICULTY;
|
||||
static const Option *GRAPHICS;
|
||||
static const Option *AMBIENT_OCCLUSION;
|
||||
static const Option *GUI_SCALE;
|
||||
static const Option *FOV;
|
||||
static const Option *GAMMA;
|
||||
static const Option *RENDER_CLOUDS;
|
||||
static const Option *PARTICLES;
|
||||
// 4J - this used to be an enum
|
||||
class Option {
|
||||
public:
|
||||
static const Option options[17];
|
||||
static const Option* MUSIC;
|
||||
static const Option* SOUND;
|
||||
static const Option* INVERT_MOUSE;
|
||||
static const Option* SENSITIVITY;
|
||||
static const Option* RENDER_DISTANCE;
|
||||
static const Option* VIEW_BOBBING;
|
||||
static const Option* ANAGLYPH;
|
||||
static const Option* ADVANCED_OPENGL;
|
||||
static const Option* FRAMERATE_LIMIT;
|
||||
static const Option* DIFFICULTY;
|
||||
static const Option* GRAPHICS;
|
||||
static const Option* AMBIENT_OCCLUSION;
|
||||
static const Option* GUI_SCALE;
|
||||
static const Option* FOV;
|
||||
static const Option* GAMMA;
|
||||
static const Option* RENDER_CLOUDS;
|
||||
static const Option* PARTICLES;
|
||||
|
||||
private:
|
||||
const bool _isProgress;
|
||||
private:
|
||||
const bool _isProgress;
|
||||
const bool _isBoolean;
|
||||
const std::wstring captionId;
|
||||
|
||||
public:
|
||||
static const Option *getItem(int id);
|
||||
public:
|
||||
static const Option* getItem(int id);
|
||||
|
||||
Option(const std::wstring& captionId, bool hasProgress, bool isBoolean);
|
||||
bool isProgress() const;
|
||||
bool isBoolean() const;
|
||||
int getId() const;
|
||||
std::wstring getCaptionId() const;
|
||||
bool isProgress() const;
|
||||
bool isBoolean() const;
|
||||
int getId() const;
|
||||
std::wstring getCaptionId() const;
|
||||
};
|
||||
|
||||
private:
|
||||
static const std::wstring RENDER_DISTANCE_NAMES[];
|
||||
static const std::wstring RENDER_DISTANCE_NAMES[];
|
||||
static const std::wstring DIFFICULTY_NAMES[];
|
||||
static const std::wstring GUI_SCALE[];
|
||||
static const std::wstring FRAMERATE_LIMITS[];
|
||||
static const std::wstring PARTICLES[];
|
||||
static const std::wstring PARTICLES[];
|
||||
|
||||
public:
|
||||
float music;
|
||||
float music;
|
||||
float sound;
|
||||
float sensitivity;
|
||||
bool invertYMouse;
|
||||
|
|
@ -68,34 +66,35 @@ public:
|
|||
int framerateLimit;
|
||||
bool fancyGraphics;
|
||||
bool ambientOcclusion;
|
||||
bool renderClouds;
|
||||
bool renderClouds;
|
||||
std::wstring skin;
|
||||
|
||||
KeyMapping *keyUp;
|
||||
KeyMapping *keyLeft;
|
||||
KeyMapping *keyDown;
|
||||
KeyMapping *keyRight;
|
||||
KeyMapping *keyJump;
|
||||
KeyMapping *keyBuild;
|
||||
KeyMapping *keyDrop;
|
||||
KeyMapping *keyChat;
|
||||
KeyMapping *keySneak;
|
||||
KeyMapping *keyAttack;
|
||||
KeyMapping *keyUse;
|
||||
KeyMapping *keyPlayerList;
|
||||
KeyMapping *keyPickItem;
|
||||
KeyMapping *keyToggleFog;
|
||||
KeyMapping* keyUp;
|
||||
KeyMapping* keyLeft;
|
||||
KeyMapping* keyDown;
|
||||
KeyMapping* keyRight;
|
||||
KeyMapping* keyJump;
|
||||
KeyMapping* keyBuild;
|
||||
KeyMapping* keyDrop;
|
||||
KeyMapping* keyChat;
|
||||
KeyMapping* keySneak;
|
||||
KeyMapping* keyAttack;
|
||||
KeyMapping* keyUse;
|
||||
KeyMapping* keyPlayerList;
|
||||
KeyMapping* keyPickItem;
|
||||
KeyMapping* keyToggleFog;
|
||||
|
||||
static const int keyMappings_length = 14;
|
||||
KeyMapping *keyMappings[keyMappings_length];
|
||||
static const int keyMappings_length = 14;
|
||||
KeyMapping* keyMappings[keyMappings_length];
|
||||
|
||||
protected:
|
||||
Minecraft *minecraft;
|
||||
Minecraft* minecraft;
|
||||
|
||||
private:
|
||||
File optionsFile;
|
||||
File optionsFile;
|
||||
|
||||
public:
|
||||
int difficulty;
|
||||
int difficulty;
|
||||
bool hideGui;
|
||||
bool thirdPersonView;
|
||||
bool renderDebug;
|
||||
|
|
@ -107,26 +106,28 @@ public:
|
|||
float flySpeed;
|
||||
float cameraSpeed;
|
||||
int guiScale;
|
||||
int particles; // 0 is all, 1 is decreased and 2 is minimal
|
||||
float fov;
|
||||
float gamma;
|
||||
int particles; // 0 is all, 1 is decreased and 2 is minimal
|
||||
float fov;
|
||||
float gamma;
|
||||
|
||||
void init(); // 4J added
|
||||
Options(Minecraft *minecraft, File workingDirectory);
|
||||
void init(); // 4J added
|
||||
Options(Minecraft* minecraft, File workingDirectory);
|
||||
Options();
|
||||
std::wstring getKeyDescription(int i);
|
||||
std::wstring getKeyMessage(int i);
|
||||
void setKey(int i, int key);
|
||||
void set(const Options::Option *item, float value);
|
||||
void toggle(const Options::Option *option, int dir);
|
||||
float getProgressValue(const Options::Option *item);
|
||||
bool getBooleanValue(const Options::Option *item);
|
||||
std::wstring getMessage(const Options::Option *item);
|
||||
void set(const Options::Option* item, float value);
|
||||
void toggle(const Options::Option* option, int dir);
|
||||
float getProgressValue(const Options::Option* item);
|
||||
bool getBooleanValue(const Options::Option* item);
|
||||
std::wstring getMessage(const Options::Option* item);
|
||||
void load();
|
||||
private:
|
||||
float readFloat(std::wstring string);
|
||||
public:
|
||||
void save();
|
||||
|
||||
bool isCloudsOn();
|
||||
private:
|
||||
float readFloat(std::wstring string);
|
||||
|
||||
public:
|
||||
void save();
|
||||
|
||||
bool isCloudsOn();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,53 +3,41 @@
|
|||
#include "../../Minecraft.World/Util/StringHelpers.h"
|
||||
|
||||
// 4J - TODO - serialise/deserialise from file
|
||||
Settings::Settings(File *file)
|
||||
{
|
||||
Settings::Settings(File* file) {}
|
||||
|
||||
void Settings::generateNewProperties() {}
|
||||
|
||||
void Settings::saveProperties() {}
|
||||
|
||||
std::wstring Settings::getString(const std::wstring& key,
|
||||
const std::wstring& defaultValue) {
|
||||
if (properties.find(key) == properties.end()) {
|
||||
properties[key] = defaultValue;
|
||||
saveProperties();
|
||||
}
|
||||
return properties[key];
|
||||
}
|
||||
|
||||
void Settings::generateNewProperties()
|
||||
{
|
||||
int Settings::getInt(const std::wstring& key, int defaultValue) {
|
||||
if (properties.find(key) == properties.end()) {
|
||||
properties[key] = _toString<int>(defaultValue);
|
||||
saveProperties();
|
||||
}
|
||||
return _fromString<int>(properties[key]);
|
||||
}
|
||||
|
||||
void Settings::saveProperties()
|
||||
{
|
||||
bool Settings::getBoolean(const std::wstring& key, bool defaultValue) {
|
||||
if (properties.find(key) == properties.end()) {
|
||||
properties[key] = _toString<bool>(defaultValue);
|
||||
saveProperties();
|
||||
}
|
||||
MemSect(35);
|
||||
bool retval = _fromString<bool>(properties[key]);
|
||||
MemSect(0);
|
||||
return retval;
|
||||
}
|
||||
|
||||
std::wstring Settings::getString(const std::wstring& key, const std::wstring& defaultValue)
|
||||
{
|
||||
if(properties.find(key) == properties.end())
|
||||
{
|
||||
properties[key] = defaultValue;
|
||||
saveProperties();
|
||||
}
|
||||
return properties[key];
|
||||
}
|
||||
|
||||
int Settings::getInt(const std::wstring& key, int defaultValue)
|
||||
{
|
||||
if(properties.find(key) == properties.end())
|
||||
{
|
||||
properties[key] = _toString<int>(defaultValue);
|
||||
saveProperties();
|
||||
}
|
||||
return _fromString<int>(properties[key]);
|
||||
}
|
||||
|
||||
bool Settings::getBoolean(const std::wstring& key, bool defaultValue)
|
||||
{
|
||||
if(properties.find(key) == properties.end())
|
||||
{
|
||||
properties[key] = _toString<bool>(defaultValue);
|
||||
saveProperties();
|
||||
}
|
||||
MemSect(35);
|
||||
bool retval = _fromString<bool>(properties[key]);
|
||||
MemSect(0);
|
||||
return retval;
|
||||
}
|
||||
|
||||
void Settings::setBooleanAndSave(const std::wstring& key, bool value)
|
||||
{
|
||||
properties[key] = _toString<bool>(value);
|
||||
saveProperties();
|
||||
void Settings::setBooleanAndSave(const std::wstring& key, bool value) {
|
||||
properties[key] = _toString<bool>(value);
|
||||
saveProperties();
|
||||
}
|
||||
|
|
@ -1,20 +1,21 @@
|
|||
#pragma once
|
||||
class File;
|
||||
|
||||
|
||||
class Settings
|
||||
{
|
||||
// public static Logger logger = Logger.getLogger("Minecraft");
|
||||
// private Properties properties = new Properties();
|
||||
class Settings {
|
||||
// public static Logger logger = Logger.getLogger("Minecraft");
|
||||
// private Properties properties = new Properties();
|
||||
private:
|
||||
std::unordered_map<std::wstring,std::wstring> properties; // 4J - TODO was Properties type, will need to implement something we can serialise/deserialise too
|
||||
//File *file;
|
||||
std::unordered_map<std::wstring, std::wstring>
|
||||
properties; // 4J - TODO was Properties type, will need to implement
|
||||
// something we can serialise/deserialise too
|
||||
// File *file;
|
||||
|
||||
public:
|
||||
Settings(File *file);
|
||||
Settings(File* file);
|
||||
void generateNewProperties();
|
||||
void saveProperties();
|
||||
std::wstring getString(const std::wstring& key, const std::wstring& defaultValue);
|
||||
std::wstring getString(const std::wstring& key,
|
||||
const std::wstring& defaultValue);
|
||||
int getInt(const std::wstring& key, int defaultValue);
|
||||
bool getBoolean(const std::wstring& key, bool defaultValue);
|
||||
void setBooleanAndSave(const std::wstring& key, bool value);
|
||||
|
|
|
|||
|
|
@ -5,100 +5,96 @@ class Achievement;
|
|||
class StatsSyncher;
|
||||
class User;
|
||||
|
||||
|
||||
class StatsCounter
|
||||
{
|
||||
class StatsCounter {
|
||||
private:
|
||||
enum eDifficulty {
|
||||
eDifficulty_Peaceful = 0,
|
||||
eDifficulty_Easy,
|
||||
eDifficulty_Normal,
|
||||
eDifficulty_Hard,
|
||||
eDifficulty_Max
|
||||
};
|
||||
|
||||
enum eDifficulty
|
||||
{
|
||||
eDifficulty_Peaceful=0,
|
||||
eDifficulty_Easy,
|
||||
eDifficulty_Normal,
|
||||
eDifficulty_Hard,
|
||||
eDifficulty_Max
|
||||
};
|
||||
struct StatContainer {
|
||||
unsigned int stats[eDifficulty_Max];
|
||||
|
||||
struct StatContainer
|
||||
{
|
||||
unsigned int stats[eDifficulty_Max];
|
||||
StatContainer() {
|
||||
stats[eDifficulty_Peaceful] = stats[eDifficulty_Easy] =
|
||||
stats[eDifficulty_Normal] = stats[eDifficulty_Hard] = 0;
|
||||
}
|
||||
};
|
||||
|
||||
StatContainer()
|
||||
{
|
||||
stats[eDifficulty_Peaceful] = stats[eDifficulty_Easy] = stats[eDifficulty_Normal] = stats[eDifficulty_Hard] = 0;
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::unordered_map<Stat*, StatContainer> StatsMap;
|
||||
typedef std::unordered_map<Stat*, StatContainer> StatsMap;
|
||||
|
||||
//static const int STAT_DATA_OFFSET = 32;
|
||||
static const int LARGE_STATS_COUNT = 8;
|
||||
static Stat** LARGE_STATS[LARGE_STATS_COUNT];
|
||||
static const int SAVE_DELAY = 30*60;
|
||||
static const int FLUSH_DELAY = 30*60*5;
|
||||
// static const int STAT_DATA_OFFSET = 32;
|
||||
static const int LARGE_STATS_COUNT = 8;
|
||||
static Stat** LARGE_STATS[LARGE_STATS_COUNT];
|
||||
static const int SAVE_DELAY = 30 * 60;
|
||||
static const int FLUSH_DELAY = 30 * 60 * 5;
|
||||
|
||||
typedef enum {
|
||||
LEADERBOARD_KILLS_PEACEFUL = 0x00000001,
|
||||
LEADERBOARD_KILLS_EASY = 0x00000002,
|
||||
LEADERBOARD_KILLS_NORMAL = 0x00000004,
|
||||
LEADERBOARD_KILLS_HARD = 0x00000008,
|
||||
LEADERBOARD_MININGBLOCKS_PEACEFUL = 0x00000010,
|
||||
LEADERBOARD_MININGBLOCKS_EASY = 0x00000020,
|
||||
LEADERBOARD_MININGBLOCKS_NORMAL = 0x00000040,
|
||||
LEADERBOARD_MININGBLOCKS_HARD = 0x00000080,
|
||||
LEADERBOARD_MININGORE_PEACEFUL = 0x00000100,
|
||||
LEADERBOARD_MININGORE_EASY = 0x00000200,
|
||||
LEADERBOARD_MININGORE_NORMAL = 0x00000400,
|
||||
LEADERBOARD_MININGORE_HARD = 0x00000800,
|
||||
LEADERBOARD_FARMING_PEACEFUL = 0x00001000,
|
||||
LEADERBOARD_FARMING_EASY = 0x00002000,
|
||||
LEADERBOARD_FARMING_NORMAL = 0x00004000,
|
||||
LEADERBOARD_FARMING_HARD = 0x00008000,
|
||||
LEADERBOARD_TRAVELLING_PEACEFUL = 0x00010000,
|
||||
LEADERBOARD_TRAVELLING_EASY = 0x00020000,
|
||||
LEADERBOARD_TRAVELLING_NORMAL = 0x00040000,
|
||||
LEADERBOARD_TRAVELLING_HARD = 0x00080000,
|
||||
LEADERBOARD_NETHER_PEACEFUL = 0x00100000,
|
||||
LEADERBOARD_NETHER_EASY = 0x00200000,
|
||||
LEADERBOARD_NETHER_NORMAL = 0x00400000,
|
||||
LEADERBOARD_NETHER_HARD = 0x00800000,
|
||||
LEADERBOARD_TRAVELLING_TOTAL = 0x01000000
|
||||
} LEADERBOARD_FLAG;
|
||||
typedef enum {
|
||||
LEADERBOARD_KILLS_PEACEFUL = 0x00000001,
|
||||
LEADERBOARD_KILLS_EASY = 0x00000002,
|
||||
LEADERBOARD_KILLS_NORMAL = 0x00000004,
|
||||
LEADERBOARD_KILLS_HARD = 0x00000008,
|
||||
LEADERBOARD_MININGBLOCKS_PEACEFUL = 0x00000010,
|
||||
LEADERBOARD_MININGBLOCKS_EASY = 0x00000020,
|
||||
LEADERBOARD_MININGBLOCKS_NORMAL = 0x00000040,
|
||||
LEADERBOARD_MININGBLOCKS_HARD = 0x00000080,
|
||||
LEADERBOARD_MININGORE_PEACEFUL = 0x00000100,
|
||||
LEADERBOARD_MININGORE_EASY = 0x00000200,
|
||||
LEADERBOARD_MININGORE_NORMAL = 0x00000400,
|
||||
LEADERBOARD_MININGORE_HARD = 0x00000800,
|
||||
LEADERBOARD_FARMING_PEACEFUL = 0x00001000,
|
||||
LEADERBOARD_FARMING_EASY = 0x00002000,
|
||||
LEADERBOARD_FARMING_NORMAL = 0x00004000,
|
||||
LEADERBOARD_FARMING_HARD = 0x00008000,
|
||||
LEADERBOARD_TRAVELLING_PEACEFUL = 0x00010000,
|
||||
LEADERBOARD_TRAVELLING_EASY = 0x00020000,
|
||||
LEADERBOARD_TRAVELLING_NORMAL = 0x00040000,
|
||||
LEADERBOARD_TRAVELLING_HARD = 0x00080000,
|
||||
LEADERBOARD_NETHER_PEACEFUL = 0x00100000,
|
||||
LEADERBOARD_NETHER_EASY = 0x00200000,
|
||||
LEADERBOARD_NETHER_NORMAL = 0x00400000,
|
||||
LEADERBOARD_NETHER_HARD = 0x00800000,
|
||||
LEADERBOARD_TRAVELLING_TOTAL = 0x01000000
|
||||
} LEADERBOARD_FLAG;
|
||||
|
||||
StatsMap stats;
|
||||
StatsMap stats;
|
||||
bool requiresSave;
|
||||
int saveCounter;
|
||||
int saveCounter;
|
||||
|
||||
int modifiedBoards;
|
||||
static std::unordered_map<Stat*, int> statBoards;
|
||||
int flushCounter;
|
||||
int modifiedBoards;
|
||||
static std::unordered_map<Stat*, int> statBoards;
|
||||
int flushCounter;
|
||||
|
||||
public:
|
||||
StatsCounter();
|
||||
void award(Stat *stat, unsigned int difficulty, unsigned int count);
|
||||
bool hasTaken(Achievement *ach);
|
||||
bool canTake(Achievement *ach);
|
||||
unsigned int getValue(Stat *stat, unsigned int difficulty);
|
||||
unsigned int getTotalValue(Stat *stat);
|
||||
StatsCounter();
|
||||
void award(Stat* stat, unsigned int difficulty, unsigned int count);
|
||||
bool hasTaken(Achievement* ach);
|
||||
bool canTake(Achievement* ach);
|
||||
unsigned int getValue(Stat* stat, unsigned int difficulty);
|
||||
unsigned int getTotalValue(Stat* stat);
|
||||
void tick(int player);
|
||||
void parse(void* data);
|
||||
void clear();
|
||||
void save(int player, bool force=false);
|
||||
void flushLeaderboards();
|
||||
void saveLeaderboards();
|
||||
static void setupStatBoards();
|
||||
void parse(void* data);
|
||||
void clear();
|
||||
void save(int player, bool force = false);
|
||||
void flushLeaderboards();
|
||||
void saveLeaderboards();
|
||||
static void setupStatBoards();
|
||||
#ifdef _DEBUG
|
||||
void WipeLeaderboards();
|
||||
void WipeLeaderboards();
|
||||
#endif
|
||||
|
||||
private:
|
||||
bool isLargeStat(Stat* stat);
|
||||
void dumpStatsToTTY();
|
||||
bool isLargeStat(Stat* stat);
|
||||
void dumpStatsToTTY();
|
||||
|
||||
#ifdef _XBOX
|
||||
static void setLeaderboardProperty(XUSER_PROPERTY* prop, std::uint32_t id, unsigned int value);
|
||||
static void setLeaderboardRating(XUSER_PROPERTY* prop, LONGLONG value);
|
||||
static void setLeaderboardProperty(XUSER_PROPERTY* prop, std::uint32_t id,
|
||||
unsigned int value);
|
||||
static void setLeaderboardRating(XUSER_PROPERTY* prop, LONGLONG value);
|
||||
#endif
|
||||
|
||||
void writeStats();
|
||||
void writeStats();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,42 +5,46 @@ class User;
|
|||
class File;
|
||||
class Stat;
|
||||
|
||||
|
||||
class StatsSyncher
|
||||
{
|
||||
class StatsSyncher {
|
||||
private:
|
||||
static const int SAVE_INTERVAL = 20 * 5;
|
||||
static const int SAVE_INTERVAL = 20 * 5;
|
||||
static const int SEND_INTERVAL = 20 * 60;
|
||||
|
||||
volatile bool busy;
|
||||
|
||||
volatile std::unordered_map<Stat *, int> *serverStats;
|
||||
volatile std::unordered_map<Stat *, int> *failedSentStats;
|
||||
volatile std::unordered_map<Stat*, int>* serverStats;
|
||||
volatile std::unordered_map<Stat*, int>* failedSentStats;
|
||||
|
||||
StatsCounter *statsCounter;
|
||||
StatsCounter* statsCounter;
|
||||
File *unsentFile, *lastServerFile;
|
||||
File *unsentFileTmp, *lastServerFileTmp;
|
||||
File *unsentFileOld, *lastServerFileOld;
|
||||
User *user;
|
||||
User* user;
|
||||
|
||||
int noSaveIn, noSendIn;
|
||||
|
||||
public:
|
||||
StatsSyncher(User *user, StatsCounter *statsCounter, File *dir);
|
||||
StatsSyncher(User* user, StatsCounter* statsCounter, File* dir);
|
||||
|
||||
private:
|
||||
void attemptRename(File *dir, const std::wstring& name, File *to);
|
||||
std::unordered_map<Stat *, int> *loadStatsFromDisk(File *file, File *tmp, File *old);
|
||||
std::unordered_map<Stat *, int> *loadStatsFromDisk(File *file);
|
||||
void doSend(std::unordered_map<Stat *, int> *stats);
|
||||
void doSave(std::unordered_map<Stat *, int> *stats, File *file, File *tmp, File *old);
|
||||
void attemptRename(File* dir, const std::wstring& name, File* to);
|
||||
std::unordered_map<Stat*, int>* loadStatsFromDisk(File* file, File* tmp,
|
||||
File* old);
|
||||
std::unordered_map<Stat*, int>* loadStatsFromDisk(File* file);
|
||||
void doSend(std::unordered_map<Stat*, int>* stats);
|
||||
void doSave(std::unordered_map<Stat*, int>* stats, File* file, File* tmp,
|
||||
File* old);
|
||||
|
||||
protected:
|
||||
std::unordered_map<Stat *, int> *doGetStats();
|
||||
std::unordered_map<Stat*, int>* doGetStats();
|
||||
|
||||
public:
|
||||
void getStatsFromServer();
|
||||
void saveUnsent(std::unordered_map<Stat *, int> *stats);
|
||||
void sendUnsent(std::unordered_map<Stat *, int> *stats, std::unordered_map<Stat *, int> *fullStats);
|
||||
void forceSendUnsent(std::unordered_map<Stat *, int> *stats);
|
||||
void forceSaveUnsent(std::unordered_map<Stat *, int> *stats);
|
||||
void getStatsFromServer();
|
||||
void saveUnsent(std::unordered_map<Stat*, int>* stats);
|
||||
void sendUnsent(std::unordered_map<Stat*, int>* stats,
|
||||
std::unordered_map<Stat*, int>* fullStats);
|
||||
void forceSendUnsent(std::unordered_map<Stat*, int>* stats);
|
||||
void forceSaveUnsent(std::unordered_map<Stat*, int>* stats);
|
||||
bool maySave();
|
||||
bool maySend();
|
||||
void tick();
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
#include "../../Minecraft.World/Headers/net.minecraft.world.item.h"
|
||||
#include "../ClientConstants.h"
|
||||
|
||||
SurvivalMode::SurvivalMode(Minecraft *minecraft) : GameMode(minecraft)
|
||||
{
|
||||
// 4J - added initialisers
|
||||
xDestroyBlock = -1;
|
||||
SurvivalMode::SurvivalMode(Minecraft* minecraft) : GameMode(minecraft) {
|
||||
// 4J - added initialisers
|
||||
xDestroyBlock = -1;
|
||||
yDestroyBlock = -1;
|
||||
zDestroyBlock = -1;
|
||||
destroyProgress = 0;
|
||||
|
|
@ -22,122 +21,103 @@ SurvivalMode::SurvivalMode(Minecraft *minecraft) : GameMode(minecraft)
|
|||
destroyTicks = 0;
|
||||
destroyDelay = 0;
|
||||
|
||||
if (ClientConstants::IS_DEMO_VERSION)
|
||||
{
|
||||
if( dynamic_cast<DemoMode *>(this) == NULL )
|
||||
{
|
||||
assert(false);
|
||||
// throw new IllegalStateException("Invalid game mode"); // 4J - removed
|
||||
if (ClientConstants::IS_DEMO_VERSION) {
|
||||
if (dynamic_cast<DemoMode*>(this) == NULL) {
|
||||
assert(false);
|
||||
// throw new IllegalStateException("Invalid game mode");
|
||||
// // 4J - removed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 4J Stu - Added this ctor so we can exit the tutorial and replace it with a standard
|
||||
// survival mode
|
||||
SurvivalMode::SurvivalMode(SurvivalMode *copy) : GameMode( copy->minecraft )
|
||||
{
|
||||
xDestroyBlock = copy->xDestroyBlock;
|
||||
yDestroyBlock = copy->yDestroyBlock;
|
||||
zDestroyBlock = copy->zDestroyBlock;
|
||||
destroyProgress = copy->destroyProgress;
|
||||
oDestroyProgress = copy->oDestroyProgress;
|
||||
destroyTicks = copy->destroyTicks;
|
||||
// 4J Stu - Added this ctor so we can exit the tutorial and replace it with a
|
||||
// standard survival mode
|
||||
SurvivalMode::SurvivalMode(SurvivalMode* copy) : GameMode(copy->minecraft) {
|
||||
xDestroyBlock = copy->xDestroyBlock;
|
||||
yDestroyBlock = copy->yDestroyBlock;
|
||||
zDestroyBlock = copy->zDestroyBlock;
|
||||
destroyProgress = copy->destroyProgress;
|
||||
oDestroyProgress = copy->oDestroyProgress;
|
||||
destroyTicks = copy->destroyTicks;
|
||||
destroyDelay = copy->destroyDelay;
|
||||
}
|
||||
|
||||
void SurvivalMode::initPlayer(std::shared_ptr<Player> player)
|
||||
{
|
||||
player->yRot = -180;
|
||||
void SurvivalMode::initPlayer(std::shared_ptr<Player> player) {
|
||||
player->yRot = -180;
|
||||
}
|
||||
|
||||
void SurvivalMode::init()
|
||||
{
|
||||
}
|
||||
void SurvivalMode::init() {}
|
||||
|
||||
bool SurvivalMode::canHurtPlayer()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool SurvivalMode::canHurtPlayer() { return true; }
|
||||
|
||||
bool SurvivalMode::destroyBlock(int x, int y, int z, int face)
|
||||
{
|
||||
bool SurvivalMode::destroyBlock(int x, int y, int z, int face) {
|
||||
int t = minecraft->level->getTile(x, y, z);
|
||||
int data = minecraft->level->getData(x, y, z);
|
||||
bool changed = GameMode::destroyBlock(x, y, z, face);
|
||||
|
||||
std::shared_ptr<ItemInstance> item = minecraft->player->getSelectedItem();
|
||||
bool couldDestroy = minecraft->player->canDestroy(Tile::tiles[t]);
|
||||
if (item != NULL)
|
||||
{
|
||||
if (item != NULL) {
|
||||
item->mineBlock(minecraft->level, t, x, y, z, minecraft->player);
|
||||
if (item->count == 0)
|
||||
{
|
||||
if (item->count == 0) {
|
||||
minecraft->player->removeSelectedItem();
|
||||
}
|
||||
}
|
||||
if (changed && couldDestroy)
|
||||
{
|
||||
Tile::tiles[t]->playerDestroy(minecraft->level, minecraft->player, x, y, z, data);
|
||||
}
|
||||
if (changed && couldDestroy) {
|
||||
Tile::tiles[t]->playerDestroy(minecraft->level, minecraft->player, x, y,
|
||||
z, data);
|
||||
}
|
||||
return changed;
|
||||
|
||||
}
|
||||
|
||||
void SurvivalMode::startDestroyBlock(int x, int y, int z, int face)
|
||||
{
|
||||
if (!minecraft->player->mayBuild(x, y, z)) return;
|
||||
void SurvivalMode::startDestroyBlock(int x, int y, int z, int face) {
|
||||
if (!minecraft->player->mayBuild(x, y, z)) return;
|
||||
minecraft->level->extinguishFire(minecraft->player, x, y, z, face);
|
||||
int t = minecraft->level->getTile(x, y, z);
|
||||
if (t > 0 && destroyProgress == 0) Tile::tiles[t]->attack(minecraft->level, x, y, z, minecraft->player);
|
||||
if (t > 0 && Tile::tiles[t]->getDestroyProgress(minecraft->player) >= 1)
|
||||
{
|
||||
if (t > 0 && destroyProgress == 0)
|
||||
Tile::tiles[t]->attack(minecraft->level, x, y, z, minecraft->player);
|
||||
if (t > 0 && Tile::tiles[t]->getDestroyProgress(minecraft->player) >= 1) {
|
||||
destroyBlock(x, y, z, face);
|
||||
}
|
||||
}
|
||||
|
||||
void SurvivalMode::stopDestroyBlock()
|
||||
{
|
||||
void SurvivalMode::stopDestroyBlock() {
|
||||
destroyProgress = 0;
|
||||
destroyDelay = 0;
|
||||
}
|
||||
|
||||
void SurvivalMode::continueDestroyBlock(int x, int y, int z, int face)
|
||||
{
|
||||
if (destroyDelay > 0)
|
||||
{
|
||||
void SurvivalMode::continueDestroyBlock(int x, int y, int z, int face) {
|
||||
if (destroyDelay > 0) {
|
||||
destroyDelay--;
|
||||
return;
|
||||
}
|
||||
if (x == xDestroyBlock && y == yDestroyBlock && z == zDestroyBlock)
|
||||
{
|
||||
if (x == xDestroyBlock && y == yDestroyBlock && z == zDestroyBlock) {
|
||||
int t = minecraft->level->getTile(x, y, z);
|
||||
if (!minecraft->player->mayBuild(x, y, z)) return;
|
||||
if (!minecraft->player->mayBuild(x, y, z)) return;
|
||||
if (t == 0) return;
|
||||
Tile *tile = Tile::tiles[t];
|
||||
Tile* tile = Tile::tiles[t];
|
||||
|
||||
destroyProgress += tile->getDestroyProgress(minecraft->player);
|
||||
|
||||
if (destroyTicks % 4 == 0)
|
||||
{
|
||||
if (tile != NULL)
|
||||
{
|
||||
minecraft->soundEngine->play(tile->soundType->getStepSound(), x + 0.5f, y + 0.5f, z + 0.5f, (tile->soundType->getVolume() + 1) / 8, tile->soundType->getPitch() * 0.5f);
|
||||
if (destroyTicks % 4 == 0) {
|
||||
if (tile != NULL) {
|
||||
minecraft->soundEngine->play(
|
||||
tile->soundType->getStepSound(), x + 0.5f, y + 0.5f,
|
||||
z + 0.5f, (tile->soundType->getVolume() + 1) / 8,
|
||||
tile->soundType->getPitch() * 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
destroyTicks++;
|
||||
|
||||
if (destroyProgress >= 1)
|
||||
{
|
||||
if (destroyProgress >= 1) {
|
||||
destroyBlock(x, y, z, face);
|
||||
destroyProgress = 0;
|
||||
oDestroyProgress = 0;
|
||||
destroyTicks = 0;
|
||||
destroyDelay = 5;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
destroyProgress = 0;
|
||||
oDestroyProgress = 0;
|
||||
destroyTicks = 0;
|
||||
|
|
@ -145,64 +125,49 @@ void SurvivalMode::continueDestroyBlock(int x, int y, int z, int face)
|
|||
yDestroyBlock = y;
|
||||
zDestroyBlock = z;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SurvivalMode::render(float a)
|
||||
{
|
||||
if (destroyProgress <= 0)
|
||||
{
|
||||
void SurvivalMode::render(float a) {
|
||||
if (destroyProgress <= 0) {
|
||||
minecraft->gui->progress = 0;
|
||||
minecraft->levelRenderer->destroyProgress = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
float dp = oDestroyProgress + (destroyProgress - oDestroyProgress) * a;
|
||||
minecraft->gui->progress = dp;
|
||||
minecraft->levelRenderer->destroyProgress = dp;
|
||||
}
|
||||
}
|
||||
|
||||
float SurvivalMode::getPickRange()
|
||||
{
|
||||
return 4.0f;
|
||||
float SurvivalMode::getPickRange() { return 4.0f; }
|
||||
|
||||
void SurvivalMode::initLevel(Level* level) { GameMode::initLevel(level); }
|
||||
|
||||
std::shared_ptr<Player> SurvivalMode::createPlayer(Level* level) {
|
||||
std::shared_ptr<Player> player = GameMode::createPlayer(level);
|
||||
// player.inventory.add(new ItemInstance(Item.pickAxe_diamond));
|
||||
// player.inventory.add(new ItemInstance(Item.hatchet_diamond));
|
||||
// player.inventory.add(new ItemInstance(Tile.torch, 64));
|
||||
// player.inventory.add(new ItemInstance(Item.porkChop_cooked, 4));
|
||||
// player.inventory.add(new ItemInstance(Item.bow, 1));
|
||||
// player.inventory.add(new ItemInstance(Item.arrow, 64));
|
||||
return player;
|
||||
}
|
||||
|
||||
void SurvivalMode::initLevel(Level *level)
|
||||
{
|
||||
GameMode::initLevel(level);
|
||||
}
|
||||
|
||||
std::shared_ptr<Player> SurvivalMode::createPlayer(Level *level)
|
||||
{
|
||||
std::shared_ptr<Player> player = GameMode::createPlayer(level);
|
||||
// player.inventory.add(new ItemInstance(Item.pickAxe_diamond));
|
||||
// player.inventory.add(new ItemInstance(Item.hatchet_diamond));
|
||||
// player.inventory.add(new ItemInstance(Tile.torch, 64));
|
||||
// player.inventory.add(new ItemInstance(Item.porkChop_cooked, 4));
|
||||
// player.inventory.add(new ItemInstance(Item.bow, 1));
|
||||
// player.inventory.add(new ItemInstance(Item.arrow, 64));
|
||||
return player;
|
||||
}
|
||||
|
||||
void SurvivalMode::tick()
|
||||
{
|
||||
void SurvivalMode::tick() {
|
||||
oDestroyProgress = destroyProgress;
|
||||
//minecraft->soundEngine->playMusicTick();
|
||||
// minecraft->soundEngine->playMusicTick();
|
||||
}
|
||||
|
||||
bool SurvivalMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly, bool *pbUsedItem)
|
||||
{
|
||||
int t = level->getTile(x, y, z);
|
||||
if (t > 0)
|
||||
{
|
||||
if (Tile::tiles[t]->use(level, x, y, z, player)) return true;
|
||||
}
|
||||
if (item == NULL) return false;
|
||||
return item->useOn(player, level, x, y, z, face);
|
||||
bool SurvivalMode::useItemOn(std::shared_ptr<Player> player, Level* level,
|
||||
std::shared_ptr<ItemInstance> item, int x, int y,
|
||||
int z, int face, bool bTestUseOnOnly,
|
||||
bool* pbUsedItem) {
|
||||
int t = level->getTile(x, y, z);
|
||||
if (t > 0) {
|
||||
if (Tile::tiles[t]->use(level, x, y, z, player)) return true;
|
||||
}
|
||||
if (item == NULL) return false;
|
||||
return item->useOn(player, level, x, y, z, face);
|
||||
}
|
||||
|
||||
bool SurvivalMode::hasExperience()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool SurvivalMode::hasExperience() { return true; }
|
||||
|
|
@ -1,32 +1,34 @@
|
|||
#pragma once
|
||||
#include "GameMode.h"
|
||||
|
||||
class SurvivalMode : public GameMode
|
||||
{
|
||||
class SurvivalMode : public GameMode {
|
||||
private:
|
||||
int xDestroyBlock;
|
||||
int xDestroyBlock;
|
||||
int yDestroyBlock;
|
||||
int zDestroyBlock;
|
||||
float destroyProgress;
|
||||
float oDestroyProgress;
|
||||
int destroyTicks; // 4J was float but doesn't seem to need to be
|
||||
int destroyTicks; // 4J was float but doesn't seem to need to be
|
||||
int destroyDelay;
|
||||
|
||||
public:
|
||||
SurvivalMode(Minecraft *minecraft);
|
||||
SurvivalMode(SurvivalMode *copy);
|
||||
SurvivalMode(Minecraft* minecraft);
|
||||
SurvivalMode(SurvivalMode* copy);
|
||||
virtual void initPlayer(std::shared_ptr<Player> player);
|
||||
virtual void init();
|
||||
virtual bool canHurtPlayer();
|
||||
virtual bool canHurtPlayer();
|
||||
virtual bool destroyBlock(int x, int y, int z, int face);
|
||||
virtual void startDestroyBlock(int x, int y, int z, int face);
|
||||
virtual void stopDestroyBlock();
|
||||
virtual void continueDestroyBlock(int x, int y, int z, int face);
|
||||
virtual void render(float a);
|
||||
virtual float getPickRange();
|
||||
virtual void initLevel(Level *level);
|
||||
virtual std::shared_ptr<Player> createPlayer(Level *level);
|
||||
virtual void initLevel(Level* level);
|
||||
virtual std::shared_ptr<Player> createPlayer(Level* level);
|
||||
virtual void tick();
|
||||
virtual bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly=false, bool *pbUsedItem=NULL);
|
||||
virtual bool hasExperience();
|
||||
virtual bool useItemOn(std::shared_ptr<Player> player, Level* level,
|
||||
std::shared_ptr<ItemInstance> item, int x, int y,
|
||||
int z, int face, bool bTestUseOnOnly = false,
|
||||
bool* pbUsedItem = NULL);
|
||||
virtual bool hasExperience();
|
||||
};
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
#include "../Platform/stdafx.h"
|
||||
#include "ConsoleInput.h"
|
||||
|
||||
ConsoleInput::ConsoleInput(const std::wstring& msg, ConsoleInputSource *source)
|
||||
{
|
||||
this->msg = msg;
|
||||
this->source = source;
|
||||
ConsoleInput::ConsoleInput(const std::wstring& msg,
|
||||
ConsoleInputSource* source) {
|
||||
this->msg = msg;
|
||||
this->source = source;
|
||||
}
|
||||
|
|
@ -1,12 +1,10 @@
|
|||
#pragma once
|
||||
#include "ConsoleInputSource.h"
|
||||
|
||||
|
||||
class ConsoleInput
|
||||
{
|
||||
class ConsoleInput {
|
||||
public:
|
||||
std::wstring msg;
|
||||
ConsoleInputSource *source;
|
||||
std::wstring msg;
|
||||
ConsoleInputSource* source;
|
||||
|
||||
ConsoleInput(const std::wstring& msg, ConsoleInputSource *source);
|
||||
ConsoleInput(const std::wstring& msg, ConsoleInputSource* source);
|
||||
};
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
class ConsoleInputSource
|
||||
{
|
||||
class ConsoleInputSource {
|
||||
public:
|
||||
virtual ~ConsoleInputSource(){}
|
||||
virtual void info(const std::wstring& string) = 0;
|
||||
virtual ~ConsoleInputSource() {}
|
||||
virtual void info(const std::wstring& string) = 0;
|
||||
virtual void warn(const std::wstring& string) = 0;
|
||||
virtual std::wstring getConsoleName() = 0;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,108 +8,123 @@
|
|||
#include "../Player/LocalPlayer.h"
|
||||
#include "../GameState/Options.h"
|
||||
|
||||
Input::Input()
|
||||
{
|
||||
xa = 0;
|
||||
ya = 0;
|
||||
wasJumping = false;
|
||||
jumping = false;
|
||||
sneaking = false;
|
||||
sprintKey = false;
|
||||
Input::Input() {
|
||||
xa = 0;
|
||||
ya = 0;
|
||||
wasJumping = false;
|
||||
jumping = false;
|
||||
sneaking = false;
|
||||
sprintKey = false;
|
||||
|
||||
lReset = false;
|
||||
lReset = false;
|
||||
rReset = false;
|
||||
}
|
||||
|
||||
void Input::tick(LocalPlayer *player)
|
||||
{
|
||||
// 4J Stu - Assume that we only need one input class, even though the java has subclasses for keyboard/controller
|
||||
// This function is based on the ControllerInput class in the Java, and will probably need changed
|
||||
//OutputDebugString("INPUT: Beginning input tick\n");
|
||||
void Input::tick(LocalPlayer* player) {
|
||||
// 4J Stu - Assume that we only need one input class, even though the java
|
||||
// has subclasses for keyboard/controller This function is based on the
|
||||
// ControllerInput class in the Java, and will probably need changed
|
||||
// OutputDebugString("INPUT: Beginning input tick\n");
|
||||
|
||||
Minecraft *pMinecraft=Minecraft::GetInstance();
|
||||
int iPad=player->GetXboxPad();
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
int iPad = player->GetXboxPad();
|
||||
|
||||
// 4J-PB minecraft movement seems to be the wrong way round, so invert x!
|
||||
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LEFT) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_RIGHT) )
|
||||
xa = -InputManager.GetJoypadStick_LX(iPad);
|
||||
else
|
||||
xa = 0.0f;
|
||||
|
||||
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_FORWARD) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_BACKWARD) )
|
||||
ya = InputManager.GetJoypadStick_LY(iPad);
|
||||
else
|
||||
ya = 0.0f;
|
||||
// 4J-PB minecraft movement seems to be the wrong way round, so invert x!
|
||||
if (pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||
MINECRAFT_ACTION_LEFT) ||
|
||||
pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||
MINECRAFT_ACTION_RIGHT))
|
||||
xa = -InputManager.GetJoypadStick_LX(iPad);
|
||||
else
|
||||
xa = 0.0f;
|
||||
|
||||
if (pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||
MINECRAFT_ACTION_FORWARD) ||
|
||||
pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||
MINECRAFT_ACTION_BACKWARD))
|
||||
ya = InputManager.GetJoypadStick_LY(iPad);
|
||||
else
|
||||
ya = 0.0f;
|
||||
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
if (app.GetFreezePlayers())
|
||||
{
|
||||
xa = ya = 0.0f;
|
||||
player->abilities.flying = true;
|
||||
}
|
||||
if (app.GetFreezePlayers()) {
|
||||
xa = ya = 0.0f;
|
||||
player->abilities.flying = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!lReset)
|
||||
{
|
||||
if (xa*xa+ya*ya==0.0f)
|
||||
{
|
||||
|
||||
if (!lReset) {
|
||||
if (xa * xa + ya * ya == 0.0f) {
|
||||
lReset = true;
|
||||
}
|
||||
xa = ya = 0.0f;
|
||||
}
|
||||
|
||||
// 4J - in flying mode, don't actually toggle sneaking
|
||||
if(!player->abilities.flying)
|
||||
{
|
||||
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_SNEAK_TOGGLE)) && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_SNEAK_TOGGLE))
|
||||
{
|
||||
sneaking=!sneaking;
|
||||
}
|
||||
}
|
||||
// 4J - in flying mode, don't actually toggle sneaking
|
||||
if (!player->abilities.flying) {
|
||||
if ((player->ullButtonsPressed &
|
||||
(1LL << MINECRAFT_ACTION_SNEAK_TOGGLE)) &&
|
||||
pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||
MINECRAFT_ACTION_SNEAK_TOGGLE)) {
|
||||
sneaking = !sneaking;
|
||||
}
|
||||
}
|
||||
|
||||
if(sneaking)
|
||||
{
|
||||
xa*=0.3f;
|
||||
ya*=0.3f;
|
||||
}
|
||||
if (sneaking) {
|
||||
xa *= 0.3f;
|
||||
ya *= 0.3f;
|
||||
}
|
||||
|
||||
float turnSpeed = 50.0f;
|
||||
|
||||
float tx = 0.0f;
|
||||
float ty = 0.0f;
|
||||
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LOOK_LEFT) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LOOK_RIGHT) )
|
||||
tx = InputManager.GetJoypadStick_RX(iPad)*(((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InGame))/100.0f); // apply sensitivity to look
|
||||
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LOOK_UP) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LOOK_DOWN) )
|
||||
ty = InputManager.GetJoypadStick_RY(iPad)*(((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InGame))/100.0f); // apply sensitivity to look
|
||||
|
||||
float tx = 0.0f;
|
||||
float ty = 0.0f;
|
||||
if (pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||
MINECRAFT_ACTION_LOOK_LEFT) ||
|
||||
pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||
MINECRAFT_ACTION_LOOK_RIGHT))
|
||||
tx = InputManager.GetJoypadStick_RX(iPad) *
|
||||
(((float)app.GetGameSettings(iPad,
|
||||
eGameSetting_Sensitivity_InGame)) /
|
||||
100.0f); // apply sensitivity to look
|
||||
if (pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||
MINECRAFT_ACTION_LOOK_UP) ||
|
||||
pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||
MINECRAFT_ACTION_LOOK_DOWN))
|
||||
ty = InputManager.GetJoypadStick_RY(iPad) *
|
||||
(((float)app.GetGameSettings(iPad,
|
||||
eGameSetting_Sensitivity_InGame)) /
|
||||
100.0f); // apply sensitivity to look
|
||||
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
if (app.GetFreezePlayers()) tx = ty = 0.0f;
|
||||
if (app.GetFreezePlayers()) tx = ty = 0.0f;
|
||||
#endif
|
||||
|
||||
// 4J: WESTY : Invert look Y if required.
|
||||
if ( app.GetGameSettings(iPad,eGameSetting_ControlInvertLook) )
|
||||
{
|
||||
ty = -ty;
|
||||
}
|
||||
// 4J: WESTY : Invert look Y if required.
|
||||
if (app.GetGameSettings(iPad, eGameSetting_ControlInvertLook)) {
|
||||
ty = -ty;
|
||||
}
|
||||
|
||||
if (!rReset)
|
||||
{
|
||||
if (tx*tx+ty*ty==0.0f)
|
||||
{
|
||||
if (!rReset) {
|
||||
if (tx * tx + ty * ty == 0.0f) {
|
||||
rReset = true;
|
||||
}
|
||||
tx = ty = 0.0f;
|
||||
}
|
||||
player->interpolateTurn(tx * abs(tx) * turnSpeed, ty * abs(ty) * turnSpeed);
|
||||
|
||||
//jumping = controller.isButtonPressed(0);
|
||||
player->interpolateTurn(tx * abs(tx) * turnSpeed, ty * abs(ty) * turnSpeed);
|
||||
|
||||
sprintKey = InputManager.GetValue(iPad, MINECRAFT_ACTION_SPRINT) && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_SPRINT);
|
||||
jumping = InputManager.GetValue(iPad, MINECRAFT_ACTION_JUMP) && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_JUMP);
|
||||
// jumping = controller.isButtonPressed(0);
|
||||
|
||||
sprintKey = InputManager.GetValue(iPad, MINECRAFT_ACTION_SPRINT) &&
|
||||
pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||
MINECRAFT_ACTION_SPRINT);
|
||||
jumping =
|
||||
InputManager.GetValue(iPad, MINECRAFT_ACTION_JUMP) &&
|
||||
pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_JUMP);
|
||||
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
if (app.GetFreezePlayers()) jumping = false;
|
||||
if (app.GetFreezePlayers()) jumping = false;
|
||||
#endif
|
||||
|
||||
//OutputDebugString("INPUT: End input tick\n");
|
||||
// OutputDebugString("INPUT: End input tick\n");
|
||||
}
|
||||
|
|
@ -1,24 +1,22 @@
|
|||
#pragma once
|
||||
class Player;
|
||||
|
||||
class Input
|
||||
{
|
||||
class Input {
|
||||
public:
|
||||
float xa;
|
||||
float xa;
|
||||
float ya;
|
||||
|
||||
bool wasJumping;
|
||||
bool jumping;
|
||||
bool sneaking;
|
||||
bool sprintKey;
|
||||
|
||||
Input(); // 4J - added
|
||||
virtual ~Input(){}
|
||||
|
||||
virtual void tick(LocalPlayer *player);
|
||||
Input(); // 4J - added
|
||||
virtual ~Input() {}
|
||||
|
||||
virtual void tick(LocalPlayer* player);
|
||||
|
||||
private:
|
||||
|
||||
bool lReset;
|
||||
bool rReset;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
#include "../Platform/stdafx.h"
|
||||
#include "KeyMapping.h"
|
||||
|
||||
KeyMapping::KeyMapping(const std::wstring& name, int key)
|
||||
{
|
||||
this->name = name;
|
||||
this->key = key;
|
||||
KeyMapping::KeyMapping(const std::wstring& name, int key) {
|
||||
this->name = name;
|
||||
this->key = key;
|
||||
}
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
// 4J Stu - Not updated to 1.8.2 as we don't use this
|
||||
class KeyMapping
|
||||
{
|
||||
class KeyMapping {
|
||||
public:
|
||||
std::wstring name;
|
||||
int key;
|
||||
KeyMapping(const std::wstring& name, int key);
|
||||
std::wstring name;
|
||||
int key;
|
||||
KeyMapping(const std::wstring& name, int key);
|
||||
};
|
||||
|
|
@ -2,24 +2,17 @@
|
|||
#include "DemoLevel.h"
|
||||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.storage.h"
|
||||
|
||||
LevelSettings DemoLevel::DEMO_LEVEL_SETTINGS = LevelSettings(
|
||||
DemoLevel::DEMO_LEVEL_SEED,
|
||||
GameType::SURVIVAL,
|
||||
false,
|
||||
false,
|
||||
false, LevelType::lvl_normal_1_1, LEVEL_MAX_WIDTH,
|
||||
1.0
|
||||
);
|
||||
LevelSettings DemoLevel::DEMO_LEVEL_SETTINGS =
|
||||
LevelSettings(DemoLevel::DEMO_LEVEL_SEED, GameType::SURVIVAL, false, false,
|
||||
false, LevelType::lvl_normal_1_1, LEVEL_MAX_WIDTH, 1.0);
|
||||
|
||||
DemoLevel::DemoLevel(std::shared_ptr<LevelStorage> levelStorage, const std::wstring& levelName) : Level(levelStorage, levelName, &DEMO_LEVEL_SETTINGS)
|
||||
{
|
||||
}
|
||||
DemoLevel::DemoLevel(std::shared_ptr<LevelStorage> levelStorage,
|
||||
const std::wstring& levelName)
|
||||
: Level(levelStorage, levelName, &DEMO_LEVEL_SETTINGS) {}
|
||||
|
||||
DemoLevel::DemoLevel(Level *level, Dimension *dimension): Level(level, dimension)
|
||||
{
|
||||
}
|
||||
DemoLevel::DemoLevel(Level* level, Dimension* dimension)
|
||||
: Level(level, dimension) {}
|
||||
|
||||
void DemoLevel::setInitialSpawn()
|
||||
{
|
||||
levelData->setSpawn(DEMO_SPAWN_X, DEMO_SPAWN_Y, DEMO_SPAWN_Z);
|
||||
void DemoLevel::setInitialSpawn() {
|
||||
levelData->setSpawn(DEMO_SPAWN_X, DEMO_SPAWN_Y, DEMO_SPAWN_Z);
|
||||
}
|
||||
|
|
@ -1,17 +1,20 @@
|
|||
#pragma once
|
||||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
||||
|
||||
class DemoLevel : public Level
|
||||
{
|
||||
class DemoLevel : public Level {
|
||||
private:
|
||||
static const __int64 DEMO_LEVEL_SEED = 0; // 4J - TODO - was "Don't Look Back".hashCode();
|
||||
static const __int64 DEMO_LEVEL_SEED =
|
||||
0; // 4J - TODO - was "Don't Look Back".hashCode();
|
||||
static const int DEMO_SPAWN_X = 796;
|
||||
static const int DEMO_SPAWN_Y = 72;
|
||||
static const int DEMO_SPAWN_Z = -731;
|
||||
static LevelSettings DEMO_LEVEL_SETTINGS;
|
||||
|
||||
public:
|
||||
DemoLevel(std::shared_ptr<LevelStorage> levelStorage, const std::wstring& levelName);
|
||||
DemoLevel(Level *level, Dimension *dimension);
|
||||
DemoLevel(std::shared_ptr<LevelStorage> levelStorage,
|
||||
const std::wstring& levelName);
|
||||
DemoLevel(Level* level, Dimension* dimension);
|
||||
|
||||
protected:
|
||||
virtual void setInitialSpawn();
|
||||
virtual void setInitialSpawn();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,27 +3,28 @@
|
|||
#include "../../Minecraft.World/Level/Storage/SavedDataStorage.h"
|
||||
#include "../../Minecraft.World/Level/DerivedLevelData.h"
|
||||
|
||||
DerivedServerLevel::DerivedServerLevel(MinecraftServer *server, std::shared_ptr<LevelStorage> levelStorage, const std::wstring& levelName, int dimension, LevelSettings *levelSettings, ServerLevel *wrapped)
|
||||
: ServerLevel(server, levelStorage, levelName, dimension, levelSettings)
|
||||
{
|
||||
// 4J-PB - we're going to override the savedDataStorage, so we need to delete the current one
|
||||
if(this->savedDataStorage)
|
||||
{
|
||||
delete this->savedDataStorage;
|
||||
this->savedDataStorage=NULL;
|
||||
}
|
||||
this->savedDataStorage = wrapped->savedDataStorage;
|
||||
levelData = new DerivedLevelData(wrapped->getLevelData());
|
||||
DerivedServerLevel::DerivedServerLevel(
|
||||
MinecraftServer* server, std::shared_ptr<LevelStorage> levelStorage,
|
||||
const std::wstring& levelName, int dimension, LevelSettings* levelSettings,
|
||||
ServerLevel* wrapped)
|
||||
: ServerLevel(server, levelStorage, levelName, dimension, levelSettings) {
|
||||
// 4J-PB - we're going to override the savedDataStorage, so we need to
|
||||
// delete the current one
|
||||
if (this->savedDataStorage) {
|
||||
delete this->savedDataStorage;
|
||||
this->savedDataStorage = NULL;
|
||||
}
|
||||
this->savedDataStorage = wrapped->savedDataStorage;
|
||||
levelData = new DerivedLevelData(wrapped->getLevelData());
|
||||
}
|
||||
|
||||
DerivedServerLevel::~DerivedServerLevel()
|
||||
{
|
||||
// we didn't allocate savedDataStorage here, so we don't want the level destructor to delete it
|
||||
this->savedDataStorage=NULL;
|
||||
DerivedServerLevel::~DerivedServerLevel() {
|
||||
// we didn't allocate savedDataStorage here, so we don't want the level
|
||||
// destructor to delete it
|
||||
this->savedDataStorage = NULL;
|
||||
}
|
||||
|
||||
void DerivedServerLevel::saveLevelData()
|
||||
{
|
||||
// Do nothing?
|
||||
// Do nothing!
|
||||
void DerivedServerLevel::saveLevelData() {
|
||||
// Do nothing?
|
||||
// Do nothing!
|
||||
}
|
||||
|
|
@ -1,12 +1,14 @@
|
|||
#pragma once
|
||||
#include "ServerLevel.h"
|
||||
|
||||
class DerivedServerLevel : public ServerLevel
|
||||
{
|
||||
class DerivedServerLevel : public ServerLevel {
|
||||
public:
|
||||
DerivedServerLevel(MinecraftServer *server, std::shared_ptr<LevelStorage>levelStorage, const std::wstring& levelName, int dimension, LevelSettings *levelSettings, ServerLevel *wrapped);
|
||||
~DerivedServerLevel();
|
||||
DerivedServerLevel(MinecraftServer* server,
|
||||
std::shared_ptr<LevelStorage> levelStorage,
|
||||
const std::wstring& levelName, int dimension,
|
||||
LevelSettings* levelSettings, ServerLevel* wrapped);
|
||||
~DerivedServerLevel();
|
||||
|
||||
protected:
|
||||
void saveLevelData();
|
||||
void saveLevelData();
|
||||
};
|
||||
|
|
@ -8,95 +8,111 @@
|
|||
class ClientConnection;
|
||||
class MultiPlayerChunkCache;
|
||||
|
||||
|
||||
|
||||
class MultiPlayerLevel : public Level
|
||||
{
|
||||
class MultiPlayerLevel : public Level {
|
||||
private:
|
||||
static const int TICKS_BEFORE_RESET = 20 * 4;
|
||||
static const int TICKS_BEFORE_RESET = 20 * 4;
|
||||
|
||||
class ResetInfo
|
||||
{
|
||||
public:
|
||||
class ResetInfo {
|
||||
public:
|
||||
int x, y, z, ticks, tile, data;
|
||||
ResetInfo(int x, int y, int z, int tile, int data);
|
||||
};
|
||||
|
||||
std::vector<ResetInfo> updatesToReset; // 4J - was linked list but vector seems more appropriate
|
||||
bool m_bEnableResetChanges; // 4J Added
|
||||
std::vector<ResetInfo> updatesToReset; // 4J - was linked list but vector
|
||||
// seems more appropriate
|
||||
bool m_bEnableResetChanges; // 4J Added
|
||||
public:
|
||||
void unshareChunkAt(int x, int z); // 4J - added
|
||||
void shareChunkAt(int x, int z); // 4J - added
|
||||
void unshareChunkAt(int x, int z); // 4J - added
|
||||
void shareChunkAt(int x, int z); // 4J - added
|
||||
|
||||
void enableResetChanges(bool enable) { m_bEnableResetChanges = enable; } // 4J Added
|
||||
void enableResetChanges(bool enable) {
|
||||
m_bEnableResetChanges = enable;
|
||||
} // 4J Added
|
||||
private:
|
||||
int unshareCheckX; // 4J - added
|
||||
int unshareCheckZ; // 4J - added
|
||||
int compressCheckX; // 4J - added
|
||||
int compressCheckZ; // 4J - added
|
||||
std::vector<ClientConnection *> connections; // 4J Stu - Made this a vector as we can have more than one local connection
|
||||
MultiPlayerChunkCache *chunkCache;
|
||||
Minecraft *minecraft;
|
||||
int unshareCheckX; // 4J - added
|
||||
int unshareCheckZ; // 4J - added
|
||||
int compressCheckX; // 4J - added
|
||||
int compressCheckZ; // 4J - added
|
||||
std::vector<ClientConnection*>
|
||||
connections; // 4J Stu - Made this a vector as we can have more than
|
||||
// one local connection
|
||||
MultiPlayerChunkCache* chunkCache;
|
||||
Minecraft* minecraft;
|
||||
|
||||
public:
|
||||
MultiPlayerLevel(ClientConnection *connection, LevelSettings *levelSettings, int dimension, int difficulty);
|
||||
virtual ~MultiPlayerLevel();
|
||||
virtual void tick() ;
|
||||
MultiPlayerLevel(ClientConnection* connection, LevelSettings* levelSettings,
|
||||
int dimension, int difficulty);
|
||||
virtual ~MultiPlayerLevel();
|
||||
virtual void tick();
|
||||
|
||||
void clearResetRegion(int x0, int y0, int z0, int x1, int y1, int z1);
|
||||
|
||||
void clearResetRegion(int x0, int y0, int z0, int x1, int y1, int z1);
|
||||
protected:
|
||||
ChunkSource *createChunkSource(); // 4J - was virtual, but was called from parent ctor
|
||||
ChunkSource*
|
||||
createChunkSource(); // 4J - was virtual, but was called from parent ctor
|
||||
public:
|
||||
virtual void validateSpawn();
|
||||
virtual void validateSpawn();
|
||||
|
||||
protected:
|
||||
virtual void tickTiles();
|
||||
virtual void tickTiles();
|
||||
|
||||
public:
|
||||
void setChunkVisible(int x, int z, bool visible);
|
||||
|
||||
private:
|
||||
std::unordered_map<int, std::shared_ptr<Entity>, IntKeyHash2, IntKeyEq> entitiesById; // 4J - was IntHashMap
|
||||
std::unordered_map<int, std::shared_ptr<Entity>, IntKeyHash2, IntKeyEq>
|
||||
entitiesById; // 4J - was IntHashMap
|
||||
std::unordered_set<std::shared_ptr<Entity> > forced;
|
||||
std::unordered_set<std::shared_ptr<Entity> > reEntries;
|
||||
|
||||
public:
|
||||
virtual bool addEntity(std::shared_ptr<Entity> e);
|
||||
virtual bool addEntity(std::shared_ptr<Entity> e);
|
||||
virtual void removeEntity(std::shared_ptr<Entity> e);
|
||||
|
||||
protected:
|
||||
virtual void entityAdded(std::shared_ptr<Entity> e);
|
||||
virtual void entityAdded(std::shared_ptr<Entity> e);
|
||||
virtual void entityRemoved(std::shared_ptr<Entity> e);
|
||||
|
||||
public:
|
||||
void putEntity(int id, std::shared_ptr<Entity> e);
|
||||
void putEntity(int id, std::shared_ptr<Entity> e);
|
||||
std::shared_ptr<Entity> getEntity(int id);
|
||||
std::shared_ptr<Entity> removeEntity(int id);
|
||||
virtual void removeEntities(std::vector<std::shared_ptr<Entity> > *list); // 4J Added override
|
||||
virtual void removeEntities(
|
||||
std::vector<std::shared_ptr<Entity> >* list); // 4J Added override
|
||||
virtual bool setDataNoUpdate(int x, int y, int z, int data);
|
||||
virtual bool setTileAndDataNoUpdate(int x, int y, int z, int tile, int data);
|
||||
virtual bool setTileAndDataNoUpdate(int x, int y, int z, int tile,
|
||||
int data);
|
||||
virtual bool setTileNoUpdate(int x, int y, int z, int tile);
|
||||
bool doSetTileAndData(int x, int y, int z, int tile, int data);
|
||||
virtual void disconnect(bool sendDisconnect = true);
|
||||
void animateTick(int xt, int yt, int zt);
|
||||
void animateTick(int xt, int yt, int zt);
|
||||
|
||||
protected:
|
||||
virtual void tickWeather();
|
||||
|
||||
static const int ANIMATE_TICK_MAX_PARTICLES = 500;
|
||||
virtual void tickWeather();
|
||||
|
||||
static const int ANIMATE_TICK_MAX_PARTICLES = 500;
|
||||
|
||||
public:
|
||||
void animateTickDoWork(); // 4J added
|
||||
std::unordered_set<int> chunksToAnimate; // 4J added
|
||||
void animateTickDoWork(); // 4J added
|
||||
std::unordered_set<int> chunksToAnimate; // 4J added
|
||||
|
||||
public:
|
||||
void removeAllPendingEntityRemovals();
|
||||
void removeAllPendingEntityRemovals();
|
||||
|
||||
virtual void playSound(std::shared_ptr<Entity> entity, int iSound, float volume, float pitch);
|
||||
virtual void playSound(std::shared_ptr<Entity> entity, int iSound,
|
||||
float volume, float pitch);
|
||||
|
||||
virtual void playLocalSound(double x, double y, double z, int iSound, float volume, float pitch, float fClipSoundDist=16.0f);
|
||||
virtual void playLocalSound(double x, double y, double z, int iSound,
|
||||
float volume, float pitch,
|
||||
float fClipSoundDist = 16.0f);
|
||||
|
||||
// 4J Stu - Added so we can have multiple local connections
|
||||
void addClientConnection(ClientConnection *c) { connections.push_back( c ); }
|
||||
void removeClientConnection(ClientConnection *c, bool sendDisconnect);
|
||||
// 4J Stu - Added so we can have multiple local connections
|
||||
void addClientConnection(ClientConnection* c) { connections.push_back(c); }
|
||||
void removeClientConnection(ClientConnection* c, bool sendDisconnect);
|
||||
|
||||
void tickAllConnections();
|
||||
void tickAllConnections();
|
||||
|
||||
void dataReceivedForChunk(int x, int z); // 4J added
|
||||
void removeUnusedTileEntitiesInRegion(int x0, int y0, int z0, int x1, int y1, int z1); // 4J added
|
||||
void dataReceivedForChunk(int x, int z); // 4J added
|
||||
void removeUnusedTileEntitiesInRegion(int x0, int y0, int z0, int x1,
|
||||
int y1, int z1); // 4J added
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,165 +7,193 @@ class Node;
|
|||
class EntityTracker;
|
||||
class PlayerChunkMap;
|
||||
|
||||
|
||||
class ServerLevel : public Level
|
||||
{
|
||||
class ServerLevel : public Level {
|
||||
private:
|
||||
static const int EMPTY_TIME_NO_TICK = SharedConstants::TICKS_PER_SECOND * 3;
|
||||
static const int EMPTY_TIME_NO_TICK = SharedConstants::TICKS_PER_SECOND * 3;
|
||||
|
||||
MinecraftServer *server;
|
||||
EntityTracker *tracker;
|
||||
PlayerChunkMap *chunkMap;
|
||||
MinecraftServer* server;
|
||||
EntityTracker* tracker;
|
||||
PlayerChunkMap* chunkMap;
|
||||
|
||||
CRITICAL_SECTION m_tickNextTickCS; // 4J added
|
||||
std::set<TickNextTickData, TickNextTickDataKeyCompare> tickNextTickList; // 4J Was TreeSet
|
||||
std::unordered_set<TickNextTickData, TickNextTickDataKeyHash, TickNextTickDataKeyEq> tickNextTickSet; // 4J Was HashSet
|
||||
CRITICAL_SECTION m_tickNextTickCS; // 4J added
|
||||
std::set<TickNextTickData, TickNextTickDataKeyCompare>
|
||||
tickNextTickList; // 4J Was TreeSet
|
||||
std::unordered_set<TickNextTickData, TickNextTickDataKeyHash,
|
||||
TickNextTickDataKeyEq>
|
||||
tickNextTickSet; // 4J Was HashSet
|
||||
|
||||
std::vector<Pos *> m_queuedSendTileUpdates; // 4J added
|
||||
CRITICAL_SECTION m_csQueueSendTileUpdates;
|
||||
std::vector<Pos*> m_queuedSendTileUpdates; // 4J added
|
||||
CRITICAL_SECTION m_csQueueSendTileUpdates;
|
||||
|
||||
protected:
|
||||
int saveInterval;
|
||||
int saveInterval;
|
||||
|
||||
public:
|
||||
ServerChunkCache *cache;
|
||||
ServerChunkCache* cache;
|
||||
bool canEditSpawn;
|
||||
bool noSave;
|
||||
private:
|
||||
bool allPlayersSleeping;
|
||||
int emptyTime;
|
||||
bool m_bAtLeastOnePlayerSleeping; // 4J Added
|
||||
static WeighedTreasureArray RANDOM_BONUS_ITEMS; // 4J - brought forward from 1.3.2
|
||||
|
||||
std::vector<TileEventData> tileEvents[2];
|
||||
int activeTileEventsList;
|
||||
public:
|
||||
static void staticCtor();
|
||||
ServerLevel(MinecraftServer *server, std::shared_ptr<LevelStorage>levelStorage, const std::wstring& levelName, int dimension, LevelSettings *levelSettings);
|
||||
~ServerLevel();
|
||||
void tick();
|
||||
Biome::MobSpawnerData *getRandomMobSpawnAt(MobCategory *mobCategory, int x, int y, int z);
|
||||
void updateSleepingPlayerList();
|
||||
protected:
|
||||
void awakenAllPlayers();
|
||||
|
||||
private:
|
||||
void stopWeather();
|
||||
bool allPlayersSleeping;
|
||||
int emptyTime;
|
||||
bool m_bAtLeastOnePlayerSleeping; // 4J Added
|
||||
static WeighedTreasureArray
|
||||
RANDOM_BONUS_ITEMS; // 4J - brought forward from 1.3.2
|
||||
|
||||
std::vector<TileEventData> tileEvents[2];
|
||||
int activeTileEventsList;
|
||||
|
||||
public:
|
||||
bool allPlayersAreSleeping();
|
||||
void validateSpawn();
|
||||
static void staticCtor();
|
||||
ServerLevel(MinecraftServer* server,
|
||||
std::shared_ptr<LevelStorage> levelStorage,
|
||||
const std::wstring& levelName, int dimension,
|
||||
LevelSettings* levelSettings);
|
||||
~ServerLevel();
|
||||
void tick();
|
||||
Biome::MobSpawnerData* getRandomMobSpawnAt(MobCategory* mobCategory, int x,
|
||||
int y, int z);
|
||||
void updateSleepingPlayerList();
|
||||
|
||||
protected:
|
||||
void tickTiles();
|
||||
void awakenAllPlayers();
|
||||
|
||||
private:
|
||||
void stopWeather();
|
||||
|
||||
public:
|
||||
void addToTickNextTick(int x, int y, int z, int tileId, int tickDelay);
|
||||
void forceAddTileTick(int x, int y, int z, int tileId, int tickDelay);
|
||||
void tickEntities();
|
||||
bool tickPendingTicks(bool force);
|
||||
std::vector<TickNextTickData> *fetchTicksInChunk(LevelChunk *chunk, bool remove);
|
||||
bool allPlayersAreSleeping();
|
||||
void validateSpawn();
|
||||
|
||||
protected:
|
||||
void tickTiles();
|
||||
|
||||
public:
|
||||
void addToTickNextTick(int x, int y, int z, int tileId, int tickDelay);
|
||||
void forceAddTileTick(int x, int y, int z, int tileId, int tickDelay);
|
||||
void tickEntities();
|
||||
bool tickPendingTicks(bool force);
|
||||
std::vector<TickNextTickData>* fetchTicksInChunk(LevelChunk* chunk,
|
||||
bool remove);
|
||||
virtual void tick(std::shared_ptr<Entity> e, bool actual);
|
||||
void forceTick(std::shared_ptr<Entity> e, bool actual);
|
||||
bool AllPlayersAreSleeping() { return allPlayersSleeping;} // 4J added for a message to other players
|
||||
bool isAtLeastOnePlayerSleeping() { return m_bAtLeastOnePlayerSleeping;}
|
||||
bool AllPlayersAreSleeping() {
|
||||
return allPlayersSleeping;
|
||||
} // 4J added for a message to other players
|
||||
bool isAtLeastOnePlayerSleeping() { return m_bAtLeastOnePlayerSleeping; }
|
||||
|
||||
protected:
|
||||
ChunkSource *createChunkSource(); // 4J - was virtual, but was called from parent ctor
|
||||
ChunkSource*
|
||||
createChunkSource(); // 4J - was virtual, but was called from parent ctor
|
||||
public:
|
||||
std::vector<std::shared_ptr<TileEntity> > *getTileEntitiesInRegion(int x0, int y0, int z0, int x1, int y1, int z1);
|
||||
virtual bool mayInteract(std::shared_ptr<Player> player, int xt, int yt, int zt, int id);
|
||||
std::vector<std::shared_ptr<TileEntity> >* getTileEntitiesInRegion(
|
||||
int x0, int y0, int z0, int x1, int y1, int z1);
|
||||
virtual bool mayInteract(std::shared_ptr<Player> player, int xt, int yt,
|
||||
int zt, int id);
|
||||
|
||||
protected:
|
||||
virtual void initializeLevel(LevelSettings *settings);
|
||||
virtual void setInitialSpawn(LevelSettings *settings);
|
||||
void generateBonusItemsNearSpawn(); // 4J - brought forward from 1.3.2
|
||||
virtual void initializeLevel(LevelSettings* settings);
|
||||
virtual void setInitialSpawn(LevelSettings* settings);
|
||||
void generateBonusItemsNearSpawn(); // 4J - brought forward from 1.3.2
|
||||
|
||||
public:
|
||||
Pos *getDimensionSpecificSpawn();
|
||||
Pos* getDimensionSpecificSpawn();
|
||||
|
||||
void Suspend(); // 4j Added for XboxOne PLM
|
||||
void Suspend(); // 4j Added for XboxOne PLM
|
||||
|
||||
void save(bool force, ProgressListener *progressListener, bool bAutosave=false);
|
||||
void saveToDisc(ProgressListener *progressListener, bool autosave); // 4J Added
|
||||
void save(bool force, ProgressListener* progressListener,
|
||||
bool bAutosave = false);
|
||||
void saveToDisc(ProgressListener* progressListener,
|
||||
bool autosave); // 4J Added
|
||||
|
||||
private:
|
||||
void saveLevelData();
|
||||
void saveLevelData();
|
||||
|
||||
typedef std::unordered_map<int, std::shared_ptr<Entity> , IntKeyHash2, IntKeyEq> intEntityMap;
|
||||
intEntityMap entitiesById; // 4J - was IntHashMap, using same hashing function as this uses
|
||||
typedef std::unordered_map<int, std::shared_ptr<Entity>, IntKeyHash2,
|
||||
IntKeyEq>
|
||||
intEntityMap;
|
||||
intEntityMap entitiesById; // 4J - was IntHashMap, using same hashing
|
||||
// function as this uses
|
||||
protected:
|
||||
virtual void entityAdded(std::shared_ptr<Entity> e);
|
||||
virtual void entityAdded(std::shared_ptr<Entity> e);
|
||||
virtual void entityRemoved(std::shared_ptr<Entity> e);
|
||||
|
||||
public:
|
||||
std::shared_ptr<Entity> getEntity(int id);
|
||||
std::shared_ptr<Entity> getEntity(int id);
|
||||
virtual bool addGlobalEntity(std::shared_ptr<Entity> e);
|
||||
void broadcastEntityEvent(std::shared_ptr<Entity> e, uint8_t event);
|
||||
virtual std::shared_ptr<Explosion> explode(std::shared_ptr<Entity> source, double x, double y, double z, float r, bool fire, bool destroyBlocks);
|
||||
virtual std::shared_ptr<Explosion> explode(std::shared_ptr<Entity> source,
|
||||
double x, double y, double z,
|
||||
float r, bool fire,
|
||||
bool destroyBlocks);
|
||||
virtual void tileEvent(int x, int y, int z, int tile, int b0, int b1);
|
||||
|
||||
private:
|
||||
void runTileEvents();
|
||||
bool doTileEvent(TileEventData *te);
|
||||
void runTileEvents();
|
||||
bool doTileEvent(TileEventData* te);
|
||||
|
||||
public:
|
||||
void closeLevelStorage();
|
||||
|
||||
protected:
|
||||
virtual void tickWeather();
|
||||
virtual void tickWeather();
|
||||
|
||||
public:
|
||||
MinecraftServer *getServer();
|
||||
EntityTracker *getTracker();
|
||||
void setTimeAndAdjustTileTicks(__int64 newTime);
|
||||
PlayerChunkMap *getChunkMap();
|
||||
MinecraftServer* getServer();
|
||||
EntityTracker* getTracker();
|
||||
void setTimeAndAdjustTileTicks(__int64 newTime);
|
||||
PlayerChunkMap* getChunkMap();
|
||||
|
||||
void queueSendTileUpdate(int x, int y, int z); // 4J Added
|
||||
void queueSendTileUpdate(int x, int y, int z); // 4J Added
|
||||
private:
|
||||
void runQueuedSendTileUpdates();// 4J Added
|
||||
void runQueuedSendTileUpdates(); // 4J Added
|
||||
|
||||
// 4J - added for implementation of finite limit to number of item entities, tnt and falling block entities
|
||||
// 4J - added for implementation of finite limit to number of item entities,
|
||||
// tnt and falling block entities
|
||||
public:
|
||||
static const int MAX_HANGING_ENTITIES = 400;
|
||||
static const int MAX_ITEM_ENTITIES = 200;
|
||||
static const int MAX_ARROW_ENTITIES = 200;
|
||||
static const int MAX_EXPERIENCEORB_ENTITIES = 50;
|
||||
static const int MAX_PRIMED_TNT = 20;
|
||||
static const int MAX_FALLING_TILE = 20;
|
||||
|
||||
static const int MAX_HANGING_ENTITIES = 400;
|
||||
static const int MAX_ITEM_ENTITIES = 200;
|
||||
static const int MAX_ARROW_ENTITIES = 200;
|
||||
static const int MAX_EXPERIENCEORB_ENTITIES = 50;
|
||||
static const int MAX_PRIMED_TNT = 20;
|
||||
static const int MAX_FALLING_TILE = 20;
|
||||
int m_primedTntCount;
|
||||
int m_fallingTileCount;
|
||||
CRITICAL_SECTION m_limiterCS;
|
||||
std::list<std::shared_ptr<Entity> > m_itemEntities;
|
||||
std::list<std::shared_ptr<Entity> > m_hangingEntities;
|
||||
std::list<std::shared_ptr<Entity> > m_arrowEntities;
|
||||
std::list<std::shared_ptr<Entity> > m_experienceOrbEntities;
|
||||
|
||||
int m_primedTntCount;
|
||||
int m_fallingTileCount;
|
||||
CRITICAL_SECTION m_limiterCS;
|
||||
std::list< std::shared_ptr<Entity> > m_itemEntities;
|
||||
std::list< std::shared_ptr<Entity> > m_hangingEntities;
|
||||
std::list< std::shared_ptr<Entity> > m_arrowEntities;
|
||||
std::list< std::shared_ptr<Entity> > m_experienceOrbEntities;
|
||||
virtual bool addEntity(std::shared_ptr<Entity> e);
|
||||
void entityAddedExtra(std::shared_ptr<Entity> e);
|
||||
void entityRemovedExtra(std::shared_ptr<Entity> e);
|
||||
|
||||
virtual bool addEntity(std::shared_ptr<Entity> e);
|
||||
void entityAddedExtra(std::shared_ptr<Entity> e);
|
||||
void entityRemovedExtra(std::shared_ptr<Entity> e);
|
||||
|
||||
virtual bool newPrimedTntAllowed();
|
||||
virtual bool newFallingTileAllowed();
|
||||
virtual bool newPrimedTntAllowed();
|
||||
virtual bool newFallingTileAllowed();
|
||||
|
||||
void flagEntitiesToBeRemoved(unsigned int *flags, bool *removedFound); // 4J added
|
||||
void flagEntitiesToBeRemoved(unsigned int* flags,
|
||||
bool* removedFound); // 4J added
|
||||
|
||||
// 4J added
|
||||
static const int MAX_UPDATES = 256;
|
||||
// 4J added
|
||||
static const int MAX_UPDATES = 256;
|
||||
|
||||
// Each of these need to be duplicated for each level in the current game. As we currently only have 2 (over/nether), making this constant
|
||||
static Level *m_level[3];
|
||||
static int m_updateChunkX[3][LEVEL_CHUNKS_TO_UPDATE_MAX];
|
||||
static int m_updateChunkZ[3][LEVEL_CHUNKS_TO_UPDATE_MAX];
|
||||
static int m_updateChunkCount[3];
|
||||
static int m_updateTileX[3][MAX_UPDATES];
|
||||
static int m_updateTileY[3][MAX_UPDATES];
|
||||
static int m_updateTileZ[3][MAX_UPDATES];
|
||||
static int m_updateTileCount[3];
|
||||
static int m_randValue[3];
|
||||
// Each of these need to be duplicated for each level in the current game.
|
||||
// As we currently only have 2 (over/nether), making this constant
|
||||
static Level* m_level[3];
|
||||
static int m_updateChunkX[3][LEVEL_CHUNKS_TO_UPDATE_MAX];
|
||||
static int m_updateChunkZ[3][LEVEL_CHUNKS_TO_UPDATE_MAX];
|
||||
static int m_updateChunkCount[3];
|
||||
static int m_updateTileX[3][MAX_UPDATES];
|
||||
static int m_updateTileY[3][MAX_UPDATES];
|
||||
static int m_updateTileZ[3][MAX_UPDATES];
|
||||
static int m_updateTileCount[3];
|
||||
static int m_randValue[3];
|
||||
|
||||
static C4JThread::EventArray* m_updateTrigger;
|
||||
static CRITICAL_SECTION m_updateCS[3];
|
||||
|
||||
static C4JThread* m_updateThread;
|
||||
static int runUpdate(void* lpParam);
|
||||
static C4JThread::EventArray* m_updateTrigger;
|
||||
static CRITICAL_SECTION m_updateCS[3];
|
||||
|
||||
static C4JThread* m_updateThread;
|
||||
static int runUpdate(void* lpParam);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,116 +11,120 @@
|
|||
#include "../../Minecraft.World/Headers/net.minecraft.network.packet.h"
|
||||
#include "../../Minecraft.World/Level/LevelData.h"
|
||||
|
||||
|
||||
ServerLevelListener::ServerLevelListener(MinecraftServer *server, ServerLevel *level)
|
||||
{
|
||||
this->server = server;
|
||||
this->level = level;
|
||||
ServerLevelListener::ServerLevelListener(MinecraftServer* server,
|
||||
ServerLevel* level) {
|
||||
this->server = server;
|
||||
this->level = level;
|
||||
}
|
||||
|
||||
// 4J removed -
|
||||
// 4J removed -
|
||||
/*
|
||||
void ServerLevelListener::addParticle(const std::wstring& name, double x, double y, double z, double xa, double ya, double za)
|
||||
void ServerLevelListener::addParticle(const std::wstring& name, double x, double
|
||||
y, double z, double xa, double ya, double za)
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
void ServerLevelListener::addParticle(ePARTICLE_TYPE name, double x, double y, double z, double xa, double ya, double za)
|
||||
{
|
||||
void ServerLevelListener::addParticle(ePARTICLE_TYPE name, double x, double y,
|
||||
double z, double xa, double ya,
|
||||
double za) {}
|
||||
|
||||
void ServerLevelListener::allChanged() {}
|
||||
|
||||
void ServerLevelListener::entityAdded(std::shared_ptr<Entity> entity) {
|
||||
MemSect(10);
|
||||
level->getTracker()->addEntity(entity);
|
||||
MemSect(0);
|
||||
}
|
||||
|
||||
void ServerLevelListener::allChanged()
|
||||
{
|
||||
}
|
||||
|
||||
void ServerLevelListener::entityAdded(std::shared_ptr<Entity> entity)
|
||||
{
|
||||
MemSect(10);
|
||||
level->getTracker()->addEntity(entity);
|
||||
MemSect(0);
|
||||
}
|
||||
|
||||
void ServerLevelListener::entityRemoved(std::shared_ptr<Entity> entity)
|
||||
{
|
||||
level->getTracker()->removeEntity(entity);
|
||||
void ServerLevelListener::entityRemoved(std::shared_ptr<Entity> entity) {
|
||||
level->getTracker()->removeEntity(entity);
|
||||
}
|
||||
|
||||
// 4J added
|
||||
void ServerLevelListener::playerRemoved(std::shared_ptr<Entity> entity)
|
||||
{
|
||||
std::shared_ptr<ServerPlayer> player = std::dynamic_pointer_cast<ServerPlayer>(entity);
|
||||
player->getLevel()->getTracker()->removePlayer(entity);
|
||||
void ServerLevelListener::playerRemoved(std::shared_ptr<Entity> entity) {
|
||||
std::shared_ptr<ServerPlayer> player =
|
||||
std::dynamic_pointer_cast<ServerPlayer>(entity);
|
||||
player->getLevel()->getTracker()->removePlayer(entity);
|
||||
}
|
||||
|
||||
void ServerLevelListener::playSound(int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist)
|
||||
{
|
||||
if(iSound < 0)
|
||||
{
|
||||
app.DebugPrintf("ServerLevelListener received request for sound less than 0, so ignoring\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 4J-PB - I don't want to broadcast player sounds to my local machine, since we're already playing these in the LevelRenderer::playSound.
|
||||
// The PC version does seem to do this and the result is I can stop walking , and then I'll hear my footstep sound with a delay
|
||||
server->getPlayers()->broadcast(x, y, z, volume > 1 ? 16 * volume : 16, level->dimension->id, std::shared_ptr<LevelSoundPacket>(new LevelSoundPacket(iSound, x, y, z, volume, pitch)));
|
||||
}
|
||||
void ServerLevelListener::playSound(int iSound, double x, double y, double z,
|
||||
float volume, float pitch,
|
||||
float fClipSoundDist) {
|
||||
if (iSound < 0) {
|
||||
app.DebugPrintf(
|
||||
"ServerLevelListener received request for sound less than 0, so "
|
||||
"ignoring\n");
|
||||
} else {
|
||||
// 4J-PB - I don't want to broadcast player sounds to my local machine,
|
||||
// since we're already playing these in the LevelRenderer::playSound.
|
||||
// The PC version does seem to do this and the result is I can stop
|
||||
// walking , and then I'll hear my footstep sound with a delay
|
||||
server->getPlayers()->broadcast(
|
||||
x, y, z, volume > 1 ? 16 * volume : 16, level->dimension->id,
|
||||
std::shared_ptr<LevelSoundPacket>(
|
||||
new LevelSoundPacket(iSound, x, y, z, volume, pitch)));
|
||||
}
|
||||
}
|
||||
|
||||
void ServerLevelListener::playSound(std::shared_ptr<Entity> entity,int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist)
|
||||
{
|
||||
if(iSound < 0)
|
||||
{
|
||||
app.DebugPrintf("ServerLevelListener received request for sound less than 0, so ignoring\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 4J-PB - I don't want to broadcast player sounds to my local machine, since we're already playing these in the LevelRenderer::playSound.
|
||||
// The PC version does seem to do this and the result is I can stop walking , and then I'll hear my footstep sound with a delay
|
||||
std::shared_ptr<Player> player= std::dynamic_pointer_cast<Player>(entity);
|
||||
server->getPlayers()->broadcast(player,x, y, z, volume > 1 ? 16 * volume : 16, level->dimension->id, std::shared_ptr<LevelSoundPacket>(new LevelSoundPacket(iSound, x, y, z, volume, pitch)));
|
||||
}
|
||||
void ServerLevelListener::playSound(std::shared_ptr<Entity> entity, int iSound,
|
||||
double x, double y, double z, float volume,
|
||||
float pitch, float fClipSoundDist) {
|
||||
if (iSound < 0) {
|
||||
app.DebugPrintf(
|
||||
"ServerLevelListener received request for sound less than 0, so "
|
||||
"ignoring\n");
|
||||
} else {
|
||||
// 4J-PB - I don't want to broadcast player sounds to my local machine,
|
||||
// since we're already playing these in the LevelRenderer::playSound.
|
||||
// The PC version does seem to do this and the result is I can stop
|
||||
// walking , and then I'll hear my footstep sound with a delay
|
||||
std::shared_ptr<Player> player =
|
||||
std::dynamic_pointer_cast<Player>(entity);
|
||||
server->getPlayers()->broadcast(
|
||||
player, x, y, z, volume > 1 ? 16 * volume : 16,
|
||||
level->dimension->id,
|
||||
std::shared_ptr<LevelSoundPacket>(
|
||||
new LevelSoundPacket(iSound, x, y, z, volume, pitch)));
|
||||
}
|
||||
}
|
||||
|
||||
void ServerLevelListener::setTilesDirty(int x0, int y0, int z0, int x1, int y1, int z1, Level *level)
|
||||
{
|
||||
void ServerLevelListener::setTilesDirty(int x0, int y0, int z0, int x1, int y1,
|
||||
int z1, Level* level) {}
|
||||
|
||||
void ServerLevelListener::skyColorChanged() {}
|
||||
|
||||
void ServerLevelListener::tileChanged(int x, int y, int z) {
|
||||
level->getChunkMap()->tileChanged(x, y, z);
|
||||
}
|
||||
|
||||
void ServerLevelListener::skyColorChanged()
|
||||
{
|
||||
void ServerLevelListener::tileLightChanged(int x, int y, int z) {}
|
||||
|
||||
void ServerLevelListener::playStreamingMusic(const std::wstring& name, int x,
|
||||
int y, int z) {}
|
||||
|
||||
void ServerLevelListener::levelEvent(std::shared_ptr<Player> source, int type,
|
||||
int x, int y, int z, int data) {
|
||||
server->getPlayers()->broadcast(
|
||||
source, x, y, z, 64, level->dimension->id,
|
||||
std::shared_ptr<LevelEventPacket>(
|
||||
new LevelEventPacket(type, x, y, z, data)));
|
||||
}
|
||||
|
||||
void ServerLevelListener::tileChanged(int x, int y, int z)
|
||||
{
|
||||
level->getChunkMap()->tileChanged(x, y, z);
|
||||
}
|
||||
void ServerLevelListener::destroyTileProgress(int id, int x, int y, int z,
|
||||
int progress) {
|
||||
// for (ServerPlayer p : server->getPlayers()->players)
|
||||
for (AUTO_VAR(it, server->getPlayers()->players.begin());
|
||||
it != server->getPlayers()->players.end(); ++it) {
|
||||
std::shared_ptr<ServerPlayer> p = *it;
|
||||
if (p == NULL || p->level != level || p->entityId == id) continue;
|
||||
double xd = (double)x - p->x;
|
||||
double yd = (double)y - p->y;
|
||||
double zd = (double)z - p->z;
|
||||
|
||||
void ServerLevelListener::tileLightChanged(int x, int y, int z)
|
||||
{
|
||||
}
|
||||
|
||||
void ServerLevelListener::playStreamingMusic(const std::wstring& name, int x, int y, int z)
|
||||
{
|
||||
}
|
||||
|
||||
void ServerLevelListener::levelEvent(std::shared_ptr<Player> source, int type, int x, int y, int z, int data)
|
||||
{
|
||||
server->getPlayers()->broadcast(source, x, y, z, 64, level->dimension->id, std::shared_ptr<LevelEventPacket>( new LevelEventPacket(type, x, y, z, data) ) );
|
||||
}
|
||||
|
||||
void ServerLevelListener::destroyTileProgress(int id, int x, int y, int z, int progress)
|
||||
{
|
||||
//for (ServerPlayer p : server->getPlayers()->players)
|
||||
for(AUTO_VAR(it, server->getPlayers()->players.begin()); it != server->getPlayers()->players.end(); ++it)
|
||||
{
|
||||
std::shared_ptr<ServerPlayer> p = *it;
|
||||
if (p == NULL || p->level != level || p->entityId == id) continue;
|
||||
double xd = (double) x - p->x;
|
||||
double yd = (double) y - p->y;
|
||||
double zd = (double) z - p->z;
|
||||
|
||||
if (xd * xd + yd * yd + zd * zd < 32 * 32)
|
||||
{
|
||||
p->connection->send(std::shared_ptr<TileDestructionPacket>(new TileDestructionPacket(id, x, y, z, progress)));
|
||||
}
|
||||
}
|
||||
if (xd * xd + yd * yd + zd * zd < 32 * 32) {
|
||||
p->connection->send(std::shared_ptr<TileDestructionPacket>(
|
||||
new TileDestructionPacket(id, x, y, z, progress)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,27 +7,37 @@ class MinecraftServer;
|
|||
class ServerLevel;
|
||||
|
||||
// 4J - renamed class to ServerLevelListener to avoid clash with LevelListener
|
||||
class ServerLevelListener : public LevelListener
|
||||
{
|
||||
class ServerLevelListener : public LevelListener {
|
||||
private:
|
||||
MinecraftServer *server;
|
||||
ServerLevel *level;
|
||||
MinecraftServer* server;
|
||||
ServerLevel* level;
|
||||
|
||||
public:
|
||||
ServerLevelListener(MinecraftServer *server, ServerLevel *level);
|
||||
// 4J removed - virtual void addParticle(const std::wstring& name, double x, double y, double z, double xa, double ya, double za);
|
||||
virtual void addParticle(ePARTICLE_TYPE name, double x, double y, double z, double xa, double ya, double za); // 4J added
|
||||
ServerLevelListener(MinecraftServer* server, ServerLevel* level);
|
||||
// 4J removed - virtual void addParticle(const std::wstring& name, double x,
|
||||
// double y, double z, double xa, double ya, double za);
|
||||
virtual void addParticle(ePARTICLE_TYPE name, double x, double y, double z,
|
||||
double xa, double ya, double za); // 4J added
|
||||
virtual void allChanged();
|
||||
virtual void entityAdded(std::shared_ptr<Entity> entity);
|
||||
virtual void entityRemoved(std::shared_ptr<Entity> entity);
|
||||
virtual void playerRemoved(std::shared_ptr<Entity> entity); // 4J added - for when a player is removed from the level's player array, not just the entity storage
|
||||
virtual void playSound(int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist);
|
||||
virtual void playSound(std::shared_ptr<Entity> entity,int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist);
|
||||
virtual void setTilesDirty(int x0, int y0, int z0, int x1, int y1, int z1, Level *level); // 4J - added level param
|
||||
virtual void playerRemoved(
|
||||
std::shared_ptr<Entity>
|
||||
entity); // 4J added - for when a player is removed from the
|
||||
// level's player array, not just the entity storage
|
||||
virtual void playSound(int iSound, double x, double y, double z,
|
||||
float volume, float pitch, float fClipSoundDist);
|
||||
virtual void playSound(std::shared_ptr<Entity> entity, int iSound, double x,
|
||||
double y, double z, float volume, float pitch,
|
||||
float fClipSoundDist);
|
||||
virtual void setTilesDirty(int x0, int y0, int z0, int x1, int y1, int z1,
|
||||
Level* level); // 4J - added level param
|
||||
virtual void skyColorChanged();
|
||||
virtual void tileChanged(int x, int y, int z);
|
||||
virtual void tileLightChanged(int x, int y, int z);
|
||||
virtual void playStreamingMusic(const std::wstring& name, int x, int y, int z);
|
||||
virtual void levelEvent(std::shared_ptr<Player> source, int type, int x, int y, int z, int data);
|
||||
virtual void destroyTileProgress(int id, int x, int y, int z, int progress);
|
||||
virtual void tileLightChanged(int x, int y, int z);
|
||||
virtual void playStreamingMusic(const std::wstring& name, int x, int y,
|
||||
int z);
|
||||
virtual void levelEvent(std::shared_ptr<Player> source, int type, int x,
|
||||
int y, int z, int data);
|
||||
virtual void destroyTileProgress(int id, int x, int y, int z, int progress);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -46,306 +46,351 @@ class PsPlusUpsellWrapper;
|
|||
#undef linux
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
class Minecraft
|
||||
{
|
||||
private:
|
||||
enum OS{
|
||||
linux, solaris, windows, macos, unknown, xbox
|
||||
};
|
||||
|
||||
class Minecraft {
|
||||
public:
|
||||
static const std::wstring VERSION_STRING;
|
||||
Minecraft(Component *mouseComponent, Canvas *parent, MinecraftApplet *minecraftApplet, int width, int height, bool fullscreen);
|
||||
void init();
|
||||
static const std::wstring VERSION_STRING;
|
||||
Minecraft(Component* mouseComponent, Canvas* parent,
|
||||
MinecraftApplet* minecraftApplet, int width, int height,
|
||||
bool fullscreen);
|
||||
void init();
|
||||
|
||||
// 4J - removed
|
||||
// void crash(CrashReport crash);
|
||||
// public abstract void onCrash(CrashReport crash);
|
||||
// 4J - removed
|
||||
// void crash(CrashReport crash);
|
||||
// public abstract void onCrash(CrashReport crash);
|
||||
|
||||
private:
|
||||
static Minecraft *m_instance;
|
||||
static Minecraft* m_instance;
|
||||
|
||||
public:
|
||||
MultiPlayerGameMode *gameMode;
|
||||
MultiPlayerGameMode* gameMode;
|
||||
|
||||
private:
|
||||
bool fullscreen;
|
||||
bool hasCrashed;
|
||||
bool fullscreen;
|
||||
bool hasCrashed;
|
||||
|
||||
C4JThread::EventQueue* levelTickEventQueue;
|
||||
|
||||
static void levelTickUpdateFunc(void* pParam);
|
||||
static void levelTickThreadInitFunc();
|
||||
C4JThread::EventQueue* levelTickEventQueue;
|
||||
|
||||
static void levelTickUpdateFunc(void* pParam);
|
||||
static void levelTickThreadInitFunc();
|
||||
|
||||
public:
|
||||
int width, height;
|
||||
int width_phys, height_phys; // 4J - added
|
||||
// private OpenGLCapabilities openGLCapabilities;
|
||||
int width, height;
|
||||
int width_phys, height_phys; // 4J - added
|
||||
// private OpenGLCapabilities openGLCapabilities;
|
||||
|
||||
private:
|
||||
Timer *timer;
|
||||
bool reloadTextures;
|
||||
Timer* timer;
|
||||
bool reloadTextures;
|
||||
|
||||
public:
|
||||
Level *oldLevel; // 4J Stu added to keep a handle on an old level so we can delete it
|
||||
//HANDLE m_hPlayerRespawned; // 4J Added so we can wait in menus until it is done (for async in multiplayer)
|
||||
Level* oldLevel; // 4J Stu added to keep a handle on an old level so we can
|
||||
// delete it
|
||||
// HANDLE m_hPlayerRespawned; // 4J Added so we can wait in menus until it
|
||||
// is done (for async in multiplayer)
|
||||
public:
|
||||
MultiPlayerLevel* level;
|
||||
LevelRenderer* levelRenderer;
|
||||
std::shared_ptr<MultiplayerLocalPlayer> player;
|
||||
|
||||
MultiPlayerLevel *level;
|
||||
LevelRenderer *levelRenderer;
|
||||
std::shared_ptr<MultiplayerLocalPlayer> player;
|
||||
MultiPlayerLevelArray levels;
|
||||
|
||||
MultiPlayerLevelArray levels;
|
||||
std::shared_ptr<MultiplayerLocalPlayer> localplayers[XUSER_MAX_COUNT];
|
||||
MultiPlayerGameMode* localgameModes[XUSER_MAX_COUNT];
|
||||
int localPlayerIdx;
|
||||
ItemInHandRenderer* localitemInHandRenderers[XUSER_MAX_COUNT];
|
||||
// 4J-PB - so we can have debugoptions in the server
|
||||
unsigned int uiDebugOptionsA[XUSER_MAX_COUNT];
|
||||
|
||||
std::shared_ptr<MultiplayerLocalPlayer> localplayers[XUSER_MAX_COUNT];
|
||||
MultiPlayerGameMode *localgameModes[XUSER_MAX_COUNT];
|
||||
int localPlayerIdx;
|
||||
ItemInHandRenderer *localitemInHandRenderers[XUSER_MAX_COUNT];
|
||||
// 4J-PB - so we can have debugoptions in the server
|
||||
unsigned int uiDebugOptionsA[XUSER_MAX_COUNT];
|
||||
// 4J Stu - Added these so that we can show a Xui scene while connecting
|
||||
bool m_connectionFailed[XUSER_MAX_COUNT];
|
||||
DisconnectPacket::eDisconnectReason
|
||||
m_connectionFailedReason[XUSER_MAX_COUNT];
|
||||
ClientConnection* m_pendingLocalConnections[XUSER_MAX_COUNT];
|
||||
|
||||
// 4J Stu - Added these so that we can show a Xui scene while connecting
|
||||
bool m_connectionFailed[XUSER_MAX_COUNT];
|
||||
DisconnectPacket::eDisconnectReason m_connectionFailedReason[XUSER_MAX_COUNT];
|
||||
ClientConnection *m_pendingLocalConnections[XUSER_MAX_COUNT];
|
||||
bool addLocalPlayer(
|
||||
int idx); // Re-arrange the screen and start the connection
|
||||
void addPendingLocalConnection(int idx, ClientConnection* connection);
|
||||
void connectionDisconnected(int idx,
|
||||
DisconnectPacket::eDisconnectReason reason) {
|
||||
m_connectionFailed[idx] = true;
|
||||
m_connectionFailedReason[idx] = reason;
|
||||
}
|
||||
|
||||
bool addLocalPlayer(int idx); // Re-arrange the screen and start the connection
|
||||
void addPendingLocalConnection(int idx, ClientConnection *connection);
|
||||
void connectionDisconnected(int idx, DisconnectPacket::eDisconnectReason reason) { m_connectionFailed[idx] = true; m_connectionFailedReason[idx] = reason; }
|
||||
std::shared_ptr<MultiplayerLocalPlayer> createExtraLocalPlayer(
|
||||
int idx, const std::wstring& name, int pad, int iDimension,
|
||||
ClientConnection* clientConnection = NULL,
|
||||
MultiPlayerLevel* levelpassedin = NULL);
|
||||
void createPrimaryLocalPlayer(int iPad);
|
||||
bool setLocalPlayerIdx(int idx);
|
||||
int getLocalPlayerIdx();
|
||||
void removeLocalPlayerIdx(int idx);
|
||||
void storeExtraLocalPlayer(int idx);
|
||||
void updatePlayerViewportAssignments();
|
||||
int unoccupiedQuadrant; // 4J - added
|
||||
|
||||
std::shared_ptr<MultiplayerLocalPlayer> createExtraLocalPlayer(int idx, const std::wstring& name, int pad, int iDimension, ClientConnection *clientConnection = NULL,MultiPlayerLevel *levelpassedin=NULL);
|
||||
void createPrimaryLocalPlayer(int iPad);
|
||||
bool setLocalPlayerIdx(int idx);
|
||||
int getLocalPlayerIdx();
|
||||
void removeLocalPlayerIdx(int idx);
|
||||
void storeExtraLocalPlayer(int idx);
|
||||
void updatePlayerViewportAssignments();
|
||||
int unoccupiedQuadrant; // 4J - added
|
||||
std::shared_ptr<Mob> cameraTargetPlayer;
|
||||
ParticleEngine* particleEngine;
|
||||
User* user;
|
||||
std::wstring serverDomain;
|
||||
Canvas* parent;
|
||||
bool appletMode;
|
||||
|
||||
std::shared_ptr<Mob> cameraTargetPlayer;
|
||||
ParticleEngine *particleEngine;
|
||||
User *user;
|
||||
std::wstring serverDomain;
|
||||
Canvas *parent;
|
||||
bool appletMode;
|
||||
// 4J - per player ?
|
||||
volatile bool pause;
|
||||
|
||||
// 4J - per player ?
|
||||
volatile bool pause;
|
||||
Textures* textures;
|
||||
Font *font, *altFont;
|
||||
Screen* screen;
|
||||
ProgressRenderer* progressRenderer;
|
||||
GameRenderer* gameRenderer;
|
||||
|
||||
Textures *textures;
|
||||
Font *font, *altFont;
|
||||
Screen *screen;
|
||||
ProgressRenderer *progressRenderer;
|
||||
GameRenderer *gameRenderer;
|
||||
private:
|
||||
BackgroundDownloader *bgLoader;
|
||||
BackgroundDownloader* bgLoader;
|
||||
|
||||
int ticks;
|
||||
// 4J-PB - moved to per player
|
||||
int ticks;
|
||||
// 4J-PB - moved to per player
|
||||
|
||||
//int missTime;
|
||||
// int missTime;
|
||||
|
||||
int orgWidth, orgHeight;
|
||||
|
||||
int orgWidth, orgHeight;
|
||||
public:
|
||||
AchievementPopup *achievementPopup;
|
||||
public:
|
||||
Gui *gui;
|
||||
// 4J - move to the per player structure?
|
||||
bool noRender;
|
||||
AchievementPopup* achievementPopup;
|
||||
|
||||
public:
|
||||
Gui* gui;
|
||||
// 4J - move to the per player structure?
|
||||
bool noRender;
|
||||
|
||||
HumanoidModel* humanoidModel;
|
||||
HitResult* hitResult;
|
||||
Options* options;
|
||||
|
||||
HumanoidModel *humanoidModel;
|
||||
HitResult *hitResult;
|
||||
Options *options;
|
||||
protected:
|
||||
MinecraftApplet *minecraftApplet;
|
||||
public:
|
||||
SoundEngine *soundEngine;
|
||||
MouseHandler *mouseHandler;
|
||||
public:
|
||||
TexturePackRepository *skins;
|
||||
File workingDirectory;
|
||||
private:
|
||||
LevelStorageSource *levelSource;
|
||||
public:
|
||||
static const int frameTimes_length = 512;
|
||||
static __int64 frameTimes[frameTimes_length];
|
||||
static const int tickTimes_length = 512;
|
||||
static __int64 tickTimes[tickTimes_length];
|
||||
static int frameTimePos;
|
||||
static __int64 warezTime;
|
||||
private:
|
||||
int rightClickDelay;
|
||||
public:
|
||||
// 4J- this should really be in localplayer
|
||||
StatsCounter* stats[4];
|
||||
|
||||
private:
|
||||
std::wstring connectToIp;
|
||||
int connectToPort;
|
||||
MinecraftApplet* minecraftApplet;
|
||||
|
||||
public:
|
||||
void clearConnectionFailed();
|
||||
void connectTo(const std::wstring& server, int port);
|
||||
|
||||
private:
|
||||
void renderLoadingScreen();
|
||||
SoundEngine* soundEngine;
|
||||
MouseHandler* mouseHandler;
|
||||
|
||||
public:
|
||||
void blit(int x, int y, int sx, int sy, int w, int h);
|
||||
TexturePackRepository* skins;
|
||||
File workingDirectory;
|
||||
|
||||
private:
|
||||
static File workDir;
|
||||
LevelStorageSource* levelSource;
|
||||
|
||||
public:
|
||||
static File getWorkingDirectory();
|
||||
static File getWorkingDirectory(const std::wstring& applicationName);
|
||||
static const int frameTimes_length = 512;
|
||||
static __int64 frameTimes[frameTimes_length];
|
||||
static const int tickTimes_length = 512;
|
||||
static __int64 tickTimes[tickTimes_length];
|
||||
static int frameTimePos;
|
||||
static __int64 warezTime;
|
||||
|
||||
private:
|
||||
static OS getPlatform();
|
||||
int rightClickDelay;
|
||||
|
||||
public:
|
||||
LevelStorageSource *getLevelSource();
|
||||
void setScreen(Screen *screen);
|
||||
// 4J- this should really be in localplayer
|
||||
StatsCounter* stats[4];
|
||||
|
||||
private:
|
||||
void checkGlError(const std::wstring& string);
|
||||
std::wstring connectToIp;
|
||||
int connectToPort;
|
||||
|
||||
public:
|
||||
void clearConnectionFailed();
|
||||
void connectTo(const std::wstring& server, int port);
|
||||
|
||||
private:
|
||||
void renderLoadingScreen();
|
||||
|
||||
public:
|
||||
void blit(int x, int y, int sx, int sy, int w, int h);
|
||||
|
||||
private:
|
||||
static File workDir;
|
||||
|
||||
public:
|
||||
static File getWorkingDirectory();
|
||||
static File getWorkingDirectory(const std::wstring& applicationName);
|
||||
|
||||
public:
|
||||
LevelStorageSource* getLevelSource();
|
||||
void setScreen(Screen* screen);
|
||||
|
||||
private:
|
||||
void checkGlError(const std::wstring& string);
|
||||
|
||||
#ifdef __ORBIS__
|
||||
PsPlusUpsellWrapper *m_pPsPlusUpsell;
|
||||
PsPlusUpsellWrapper* m_pPsPlusUpsell;
|
||||
#endif
|
||||
|
||||
public:
|
||||
void destroy();
|
||||
volatile bool running;
|
||||
std::wstring fpsString;
|
||||
void run();
|
||||
// 4J-PB - split the run into 3 parts so we can run it from our xbox game loop
|
||||
static Minecraft *GetInstance();
|
||||
void run_middle();
|
||||
void run_end();
|
||||
void destroy();
|
||||
volatile bool running;
|
||||
std::wstring fpsString;
|
||||
void run();
|
||||
// 4J-PB - split the run into 3 parts so we can run it from our xbox game
|
||||
// loop
|
||||
static Minecraft* GetInstance();
|
||||
void run_middle();
|
||||
void run_end();
|
||||
|
||||
void emergencySave();
|
||||
void emergencySave();
|
||||
|
||||
// 4J - removed
|
||||
//bool wasDown ;
|
||||
// 4J - removed
|
||||
// bool wasDown ;
|
||||
private:
|
||||
// void checkScreenshot(); // 4J - removed
|
||||
// String grabHugeScreenshot(File workDir2, int width, int height, int ssWidth, int ssHeight); // 4J - removed
|
||||
// void checkScreenshot(); // 4J - removed
|
||||
// String grabHugeScreenshot(File workDir2, int width, int height, int
|
||||
// ssWidth, int ssHeight); // 4J - removed
|
||||
|
||||
// 4J - per player thing?
|
||||
__int64 lastTimer;
|
||||
// 4J - per player thing?
|
||||
__int64 lastTimer;
|
||||
|
||||
void renderFpsMeter(__int64 tickTime);
|
||||
public:
|
||||
void stop();
|
||||
// 4J removed
|
||||
// bool mouseGrabbed;
|
||||
// void grabMouse();
|
||||
// void releaseMouse();
|
||||
// 4J-PB - moved these into localplayer
|
||||
//void handleMouseDown(int button, bool down);
|
||||
//void handleMouseClick(int button);
|
||||
|
||||
void pauseGame();
|
||||
// void toggleFullScreen(); // 4J - removed
|
||||
private:
|
||||
void resize(int width, int height);
|
||||
void renderFpsMeter(__int64 tickTime);
|
||||
|
||||
public:
|
||||
// 4J - Moved to per player
|
||||
//bool isRaining ;
|
||||
void stop();
|
||||
// 4J removed
|
||||
// bool mouseGrabbed;
|
||||
// void grabMouse();
|
||||
// void releaseMouse();
|
||||
// 4J-PB - moved these into localplayer
|
||||
// void handleMouseDown(int button, bool down);
|
||||
// void handleMouseClick(int button);
|
||||
|
||||
// 4J - Moved to per player
|
||||
//__int64 lastTickTime;
|
||||
void pauseGame();
|
||||
// void toggleFullScreen(); // 4J - removed
|
||||
bool pollResize();
|
||||
|
||||
private:
|
||||
// 4J- per player?
|
||||
int recheckPlayerIn;
|
||||
void verify();
|
||||
void resize(int width, int height);
|
||||
|
||||
public:
|
||||
// 4J - added bFirst parameter, which is true for the first active viewport in splitscreen
|
||||
// 4J - added bUpdateTextures, which is true if the actual renderer textures are to be updated - this will be true for the last time this tick runs with bFirst true
|
||||
void tick(bool bFirst, bool bUpdateTextures);
|
||||
// 4J - Moved to per player
|
||||
// bool isRaining ;
|
||||
|
||||
// 4J - Moved to per player
|
||||
//__int64 lastTickTime;
|
||||
|
||||
private:
|
||||
void reloadSound();
|
||||
// 4J- per player?
|
||||
int recheckPlayerIn;
|
||||
void verify();
|
||||
|
||||
public:
|
||||
bool isClientSide();
|
||||
void selectLevel(ConsoleSaveFile *saveFile, const std::wstring& levelId, const std::wstring& levelName, LevelSettings *levelSettings);
|
||||
//void toggleDimension(int targetDimension);
|
||||
bool saveSlot(int slot, const std::wstring& name);
|
||||
bool loadSlot(const std::wstring& userName, int slot);
|
||||
void releaseLevel(int message);
|
||||
// 4J Stu - Added the doForceStatsSave param
|
||||
//void setLevel(Level *level, bool doForceStatsSave = true);
|
||||
//void setLevel(Level *level, const std::wstring& message, bool doForceStatsSave = true);
|
||||
void setLevel(MultiPlayerLevel *level, int message = -1, std::shared_ptr<Player> forceInsertPlayer = nullptr, bool doForceStatsSave = true,bool bPrimaryPlayerSignedOut=false);
|
||||
// 4J-PB - added to force in the 'other' level when the main player creates the level at game load time
|
||||
void forceaddLevel(MultiPlayerLevel *level);
|
||||
void prepareLevel(int title); // 4J - changed to public
|
||||
void fileDownloaded(const std::wstring& name, File *file);
|
||||
// OpenGLCapabilities getOpenGLCapabilities(); // 4J - removed
|
||||
// 4J - added bFirst parameter, which is true for the first active viewport
|
||||
// in splitscreen 4J - added bUpdateTextures, which is true if the actual
|
||||
// renderer textures are to be updated - this will be true for the last time
|
||||
// this tick runs with bFirst true
|
||||
void tick(bool bFirst, bool bUpdateTextures);
|
||||
|
||||
std::wstring gatherStats1();
|
||||
std::wstring gatherStats2();
|
||||
std::wstring gatherStats3();
|
||||
std::wstring gatherStats4();
|
||||
private:
|
||||
void reloadSound();
|
||||
|
||||
void respawnPlayer(int iPad,int dimension,int newEntityId);
|
||||
static void start(const std::wstring& name, const std::wstring& sid);
|
||||
static void startAndConnectTo(const std::wstring& name, const std::wstring& sid, const std::wstring& url);
|
||||
ClientConnection *getConnection(int iPad); // 4J Stu added iPad param
|
||||
static void main();
|
||||
static bool renderNames();
|
||||
static bool useFancyGraphics();
|
||||
static bool useAmbientOcclusion();
|
||||
static bool renderDebug();
|
||||
bool handleClientSideCommand(const std::wstring& chatMessage);
|
||||
public:
|
||||
bool isClientSide();
|
||||
void selectLevel(ConsoleSaveFile* saveFile, const std::wstring& levelId,
|
||||
const std::wstring& levelName,
|
||||
LevelSettings* levelSettings);
|
||||
// void toggleDimension(int targetDimension);
|
||||
bool saveSlot(int slot, const std::wstring& name);
|
||||
bool loadSlot(const std::wstring& userName, int slot);
|
||||
void releaseLevel(int message);
|
||||
// 4J Stu - Added the doForceStatsSave param
|
||||
// void setLevel(Level *level, bool doForceStatsSave = true);
|
||||
// void setLevel(Level *level, const std::wstring& message, bool
|
||||
// doForceStatsSave = true);
|
||||
void setLevel(MultiPlayerLevel* level, int message = -1,
|
||||
std::shared_ptr<Player> forceInsertPlayer = nullptr,
|
||||
bool doForceStatsSave = true,
|
||||
bool bPrimaryPlayerSignedOut = false);
|
||||
// 4J-PB - added to force in the 'other' level when the main player creates
|
||||
// the level at game load time
|
||||
void forceaddLevel(MultiPlayerLevel* level);
|
||||
void prepareLevel(int title); // 4J - changed to public
|
||||
void fileDownloaded(const std::wstring& name, File* file);
|
||||
// OpenGLCapabilities getOpenGLCapabilities(); // 4J - removed
|
||||
|
||||
static int maxSupportedTextureSize();
|
||||
void delayTextureReload();
|
||||
static __int64 currentTimeMillis();
|
||||
std::wstring gatherStats1();
|
||||
std::wstring gatherStats2();
|
||||
std::wstring gatherStats3();
|
||||
std::wstring gatherStats4();
|
||||
|
||||
void respawnPlayer(int iPad, int dimension, int newEntityId);
|
||||
static void start(const std::wstring& name, const std::wstring& sid);
|
||||
static void startAndConnectTo(const std::wstring& name,
|
||||
const std::wstring& sid,
|
||||
const std::wstring& url);
|
||||
ClientConnection* getConnection(int iPad); // 4J Stu added iPad param
|
||||
static void main();
|
||||
static bool renderNames();
|
||||
static bool useFancyGraphics();
|
||||
static bool useAmbientOcclusion();
|
||||
static bool renderDebug();
|
||||
bool handleClientSideCommand(const std::wstring& chatMessage);
|
||||
|
||||
static int maxSupportedTextureSize();
|
||||
void delayTextureReload();
|
||||
static __int64 currentTimeMillis();
|
||||
|
||||
#ifdef _DURANGO
|
||||
static void inGameSignInCheckAllPrivilegesCallback(void *lpParam, bool hasPrivileges, int iPad);
|
||||
static void inGameSignInCheckAllPrivilegesCallback(void* lpParam,
|
||||
bool hasPrivileges,
|
||||
int iPad);
|
||||
#endif
|
||||
static int InGame_SignInReturned(void *pParam,bool bContinue, int iPad);
|
||||
// 4J-PB
|
||||
Screen * getScreen();
|
||||
static int InGame_SignInReturned(void* pParam, bool bContinue, int iPad);
|
||||
// 4J-PB
|
||||
Screen* getScreen();
|
||||
|
||||
// 4J Stu
|
||||
void forceStatsSave(int idx);
|
||||
// 4J Stu
|
||||
void forceStatsSave(int idx);
|
||||
|
||||
CRITICAL_SECTION m_setLevelCS;
|
||||
|
||||
CRITICAL_SECTION m_setLevelCS;
|
||||
private:
|
||||
// A bit field that store whether a particular quadrant is in the full tutorial or not
|
||||
std::uint8_t m_inFullTutorialBits;
|
||||
// A bit field that store whether a particular quadrant is in the full
|
||||
// tutorial or not
|
||||
std::uint8_t m_inFullTutorialBits;
|
||||
|
||||
public:
|
||||
bool isTutorial();
|
||||
void playerStartedTutorial(int iPad);
|
||||
void playerLeftTutorial(int iPad);
|
||||
bool isTutorial();
|
||||
void playerStartedTutorial(int iPad);
|
||||
void playerLeftTutorial(int iPad);
|
||||
|
||||
// 4J Added
|
||||
MultiPlayerLevel *getLevel(int dimension);
|
||||
// 4J Added
|
||||
MultiPlayerLevel* getLevel(int dimension);
|
||||
|
||||
void tickAllConnections();
|
||||
void tickAllConnections();
|
||||
|
||||
Level *animateTickLevel; // 4J added
|
||||
Level* animateTickLevel; // 4J added
|
||||
|
||||
// 4J - When a client requests a texture, it should add it to here while we are waiting for it
|
||||
std::vector<std::wstring> m_pendingTextureRequests;
|
||||
std::vector<std::wstring> m_pendingGeometryRequests; // additional skin box geometry
|
||||
// 4J - When a client requests a texture, it should add it to here while we
|
||||
// are waiting for it
|
||||
std::vector<std::wstring> m_pendingTextureRequests;
|
||||
std::vector<std::wstring>
|
||||
m_pendingGeometryRequests; // additional skin box geometry
|
||||
|
||||
// 4J Added
|
||||
bool addPendingClientTextureRequest(const std::wstring &textureName);
|
||||
void handleClientTextureReceived(const std::wstring &textureName);
|
||||
void clearPendingClientTextureRequests() { m_pendingTextureRequests.clear(); }
|
||||
bool addPendingClientGeometryRequest(const std::wstring &textureName);
|
||||
void handleClientGeometryReceived(const std::wstring &textureName);
|
||||
void clearPendingClientGeometryRequests() { m_pendingGeometryRequests.clear(); }
|
||||
// 4J Added
|
||||
bool addPendingClientTextureRequest(const std::wstring& textureName);
|
||||
void handleClientTextureReceived(const std::wstring& textureName);
|
||||
void clearPendingClientTextureRequests() {
|
||||
m_pendingTextureRequests.clear();
|
||||
}
|
||||
bool addPendingClientGeometryRequest(const std::wstring& textureName);
|
||||
void handleClientGeometryReceived(const std::wstring& textureName);
|
||||
void clearPendingClientGeometryRequests() {
|
||||
m_pendingGeometryRequests.clear();
|
||||
}
|
||||
|
||||
unsigned int getCurrentTexturePackId();
|
||||
ColourTable *getColourTable();
|
||||
unsigned int getCurrentTexturePackId();
|
||||
ColourTable* getColourTable();
|
||||
|
||||
#if defined __ORBIS__
|
||||
static int MustSignInReturnedPSN(void *pParam, int iPad, C4JStorage::EMessageResult result);
|
||||
static int MustSignInReturnedPSN(void* pParam, int iPad,
|
||||
C4JStorage::EMessageResult result);
|
||||
#endif
|
||||
};
|
||||
|
|
|
|||
|
|
@ -22,226 +22,265 @@ class CommandDispatcher;
|
|||
|
||||
#define MINECRAFT_SERVER_SLOW_QUEUE_DELAY 250
|
||||
|
||||
typedef struct _LoadSaveDataThreadParam
|
||||
{
|
||||
void *data;
|
||||
__int64 fileSize;
|
||||
const std::wstring saveName;
|
||||
_LoadSaveDataThreadParam(void *data, __int64 filesize, const std::wstring &saveName) : data( data ), fileSize( filesize ), saveName( saveName ) {}
|
||||
typedef struct _LoadSaveDataThreadParam {
|
||||
void* data;
|
||||
__int64 fileSize;
|
||||
const std::wstring saveName;
|
||||
_LoadSaveDataThreadParam(void* data, __int64 filesize,
|
||||
const std::wstring& saveName)
|
||||
: data(data), fileSize(filesize), saveName(saveName) {}
|
||||
} LoadSaveDataThreadParam;
|
||||
|
||||
typedef struct _NetworkGameInitData
|
||||
{
|
||||
__int64 seed;
|
||||
LoadSaveDataThreadParam *saveData;
|
||||
std::uint32_t settings;
|
||||
LevelGenerationOptions *levelGen;
|
||||
std::uint32_t texturePackId;
|
||||
bool findSeed;
|
||||
unsigned int xzSize;
|
||||
unsigned char hellScale;
|
||||
ESavePlatform savePlatform;
|
||||
typedef struct _NetworkGameInitData {
|
||||
__int64 seed;
|
||||
LoadSaveDataThreadParam* saveData;
|
||||
std::uint32_t settings;
|
||||
LevelGenerationOptions* levelGen;
|
||||
std::uint32_t texturePackId;
|
||||
bool findSeed;
|
||||
unsigned int xzSize;
|
||||
unsigned char hellScale;
|
||||
ESavePlatform savePlatform;
|
||||
|
||||
_NetworkGameInitData()
|
||||
{
|
||||
seed = 0;
|
||||
saveData = NULL;
|
||||
settings = 0;
|
||||
levelGen = NULL;
|
||||
texturePackId = 0;
|
||||
findSeed = false;
|
||||
xzSize = LEVEL_LEGACY_WIDTH;
|
||||
hellScale = HELL_LEVEL_LEGACY_SCALE;
|
||||
savePlatform = SAVE_FILE_PLATFORM_LOCAL;
|
||||
}
|
||||
_NetworkGameInitData() {
|
||||
seed = 0;
|
||||
saveData = NULL;
|
||||
settings = 0;
|
||||
levelGen = NULL;
|
||||
texturePackId = 0;
|
||||
findSeed = false;
|
||||
xzSize = LEVEL_LEGACY_WIDTH;
|
||||
hellScale = HELL_LEVEL_LEGACY_SCALE;
|
||||
savePlatform = SAVE_FILE_PLATFORM_LOCAL;
|
||||
}
|
||||
} NetworkGameInitData;
|
||||
|
||||
|
||||
|
||||
// 4J Stu - 1.0.1 updates the server to implement the ServerInterface class, but I don't think we will use any of the functions that defines so not implementing here
|
||||
class MinecraftServer : public ConsoleInputSource
|
||||
{
|
||||
// 4J Stu - 1.0.1 updates the server to implement the ServerInterface class, but
|
||||
// I don't think we will use any of the functions that defines so not
|
||||
// implementing here
|
||||
class MinecraftServer : public ConsoleInputSource {
|
||||
public:
|
||||
static const std::wstring VERSION;
|
||||
static const int TICK_STATS_SPAN = SharedConstants::TICKS_PER_SECOND * 5;
|
||||
static const std::wstring VERSION;
|
||||
static const int TICK_STATS_SPAN = SharedConstants::TICKS_PER_SECOND * 5;
|
||||
|
||||
// static Logger logger = Logger.getLogger("Minecraft");
|
||||
// static Logger logger = Logger.getLogger("Minecraft");
|
||||
static std::unordered_map<std::wstring, int> ironTimers;
|
||||
|
||||
private:
|
||||
static const int DEFAULT_MINECRAFT_PORT = 25565;
|
||||
static const int MS_PER_TICK = 1000 / SharedConstants::TICKS_PER_SECOND;
|
||||
static const int DEFAULT_MINECRAFT_PORT = 25565;
|
||||
static const int MS_PER_TICK = 1000 / SharedConstants::TICKS_PER_SECOND;
|
||||
|
||||
// 4J Stu - Added 1.0.1, Not needed
|
||||
//std::wstring localIp;
|
||||
//int port;
|
||||
// 4J Stu - Added 1.0.1, Not needed
|
||||
// std::wstring localIp;
|
||||
// int port;
|
||||
public:
|
||||
ServerConnection *connection;
|
||||
Settings *settings;
|
||||
ServerConnection* connection;
|
||||
Settings* settings;
|
||||
ServerLevelArray levels;
|
||||
|
||||
private:
|
||||
PlayerList *players;
|
||||
PlayerList* players;
|
||||
|
||||
// 4J Stu - Added 1.0.1, Not needed
|
||||
//long[] tickTimes = new long[TICK_STATS_SPAN];
|
||||
//long[][] levelTickTimes;
|
||||
// 4J Stu - Added 1.0.1, Not needed
|
||||
// long[] tickTimes = new long[TICK_STATS_SPAN];
|
||||
// long[][] levelTickTimes;
|
||||
private:
|
||||
ConsoleCommands *commands;
|
||||
ConsoleCommands* commands;
|
||||
bool running;
|
||||
bool m_bLoaded;
|
||||
bool m_bLoaded;
|
||||
|
||||
public:
|
||||
bool stopped;
|
||||
bool stopped;
|
||||
int tickCount;
|
||||
|
||||
public:
|
||||
std::wstring progressStatus;
|
||||
std::wstring progressStatus;
|
||||
int progress;
|
||||
|
||||
private:
|
||||
// std::vector<Tickable *> tickables = new ArrayList<Tickable>(); // 4J - removed
|
||||
CommandDispatcher *commandDispatcher;
|
||||
std::vector<ConsoleInput *> consoleInput; // 4J - was synchronizedList - TODO - investigate
|
||||
// std::vector<Tickable *> tickables = new ArrayList<Tickable>(); // 4J -
|
||||
//removed
|
||||
CommandDispatcher* commandDispatcher;
|
||||
std::vector<ConsoleInput*>
|
||||
consoleInput; // 4J - was synchronizedList - TODO - investigate
|
||||
public:
|
||||
bool onlineMode;
|
||||
bool animals;
|
||||
bool npcs;
|
||||
bool npcs;
|
||||
bool pvp;
|
||||
bool allowFlight;
|
||||
std::wstring motd;
|
||||
int maxBuildHeight;
|
||||
std::wstring motd;
|
||||
int maxBuildHeight;
|
||||
|
||||
private:
|
||||
// 4J Added
|
||||
//int m_lastSentDifficulty;
|
||||
// 4J Added
|
||||
// int m_lastSentDifficulty;
|
||||
|
||||
public:
|
||||
// 4J Stu - This value should be incremented every time the list of players with friends-only UGC settings changes
|
||||
// It is sent with PreLoginPacket and compared when it comes back in the LoginPacket
|
||||
std::uint32_t m_ugcPlayersVersion;
|
||||
// 4J Stu - This value should be incremented every time the list of players
|
||||
// with friends-only UGC settings changes It is sent with PreLoginPacket and
|
||||
// compared when it comes back in the LoginPacket
|
||||
std::uint32_t m_ugcPlayersVersion;
|
||||
|
||||
// This value is used to store the texture pack id for the currently loaded world
|
||||
std::uint32_t m_texturePackId;
|
||||
// This value is used to store the texture pack id for the currently loaded
|
||||
// world
|
||||
std::uint32_t m_texturePackId;
|
||||
|
||||
public:
|
||||
MinecraftServer();
|
||||
~MinecraftServer();
|
||||
MinecraftServer();
|
||||
~MinecraftServer();
|
||||
|
||||
private:
|
||||
// 4J Added - LoadSaveDataThreadParam
|
||||
bool initServer(__int64 seed, NetworkGameInitData *initData, std::uint32_t initSettings, bool findSeed);
|
||||
void postProcessTerminate(ProgressRenderer *mcprogress);
|
||||
bool loadLevel(LevelStorageSource *storageSource, const std::wstring& name, __int64 levelSeed, LevelType *pLevelType, NetworkGameInitData *initData);
|
||||
// 4J Added - LoadSaveDataThreadParam
|
||||
bool initServer(__int64 seed, NetworkGameInitData* initData,
|
||||
std::uint32_t initSettings, bool findSeed);
|
||||
void postProcessTerminate(ProgressRenderer* mcprogress);
|
||||
bool loadLevel(LevelStorageSource* storageSource, const std::wstring& name,
|
||||
__int64 levelSeed, LevelType* pLevelType,
|
||||
NetworkGameInitData* initData);
|
||||
void setProgress(const std::wstring& status, int progress);
|
||||
void endProgress();
|
||||
void saveAllChunks();
|
||||
void saveGameRules();
|
||||
void saveGameRules();
|
||||
void stopServer();
|
||||
|
||||
public:
|
||||
void setMaxBuildHeight(int maxBuildHeight);
|
||||
int getMaxBuildHeight();
|
||||
PlayerList *getPlayers();
|
||||
void setPlayers(PlayerList *players);
|
||||
ServerConnection *getConnection();
|
||||
bool isAnimals();
|
||||
void setAnimals(bool animals);
|
||||
bool isNpcsEnabled();
|
||||
void setNpcsEnabled(bool npcs);
|
||||
bool isPvpAllowed();
|
||||
void setPvpAllowed(bool pvp);
|
||||
bool isFlightAllowed();
|
||||
void setFlightAllowed(bool allowFlight);
|
||||
bool isNetherEnabled();
|
||||
bool isHardcore();
|
||||
CommandDispatcher *getCommandDispatcher();
|
||||
void setMaxBuildHeight(int maxBuildHeight);
|
||||
int getMaxBuildHeight();
|
||||
PlayerList* getPlayers();
|
||||
void setPlayers(PlayerList* players);
|
||||
ServerConnection* getConnection();
|
||||
bool isAnimals();
|
||||
void setAnimals(bool animals);
|
||||
bool isNpcsEnabled();
|
||||
void setNpcsEnabled(bool npcs);
|
||||
bool isPvpAllowed();
|
||||
void setPvpAllowed(bool pvp);
|
||||
bool isFlightAllowed();
|
||||
void setFlightAllowed(bool allowFlight);
|
||||
bool isNetherEnabled();
|
||||
bool isHardcore();
|
||||
CommandDispatcher* getCommandDispatcher();
|
||||
|
||||
public:
|
||||
void halt();
|
||||
void run(__int64 seed, void *lpParameter);
|
||||
void halt();
|
||||
void run(__int64 seed, void* lpParameter);
|
||||
|
||||
void broadcastStartSavingPacket();
|
||||
void broadcastStopSavingPacket();
|
||||
void broadcastStartSavingPacket();
|
||||
void broadcastStopSavingPacket();
|
||||
|
||||
private:
|
||||
void tick();
|
||||
public:
|
||||
void handleConsoleInput(const std::wstring& msg, ConsoleInputSource *source);
|
||||
void handleConsoleInputs();
|
||||
// void addTickable(Tickable tickable); // 4J removed
|
||||
static void main(__int64 seed, void *lpParameter);
|
||||
static void HaltServer(bool bPrimaryPlayerSignedOut=false);
|
||||
void tick();
|
||||
|
||||
File *getFile(const std::wstring& name);
|
||||
public:
|
||||
void handleConsoleInput(const std::wstring& msg,
|
||||
ConsoleInputSource* source);
|
||||
void handleConsoleInputs();
|
||||
// void addTickable(Tickable tickable); // 4J removed
|
||||
static void main(__int64 seed, void* lpParameter);
|
||||
static void HaltServer(bool bPrimaryPlayerSignedOut = false);
|
||||
|
||||
File* getFile(const std::wstring& name);
|
||||
void info(const std::wstring& string);
|
||||
void warn(const std::wstring& string);
|
||||
std::wstring getConsoleName();
|
||||
ServerLevel *getLevel(int dimension);
|
||||
void setLevel(int dimension, ServerLevel *level); // 4J added
|
||||
static MinecraftServer *getInstance() { return server; } // 4J added
|
||||
static bool serverHalted() { return s_bServerHalted; }
|
||||
static bool saveOnExitAnswered() { return s_bSaveOnExitAnswered; }
|
||||
static void resetFlags() { s_bServerHalted = false; s_bSaveOnExitAnswered = false; }
|
||||
ServerLevel* getLevel(int dimension);
|
||||
void setLevel(int dimension, ServerLevel* level); // 4J added
|
||||
static MinecraftServer* getInstance() { return server; } // 4J added
|
||||
static bool serverHalted() { return s_bServerHalted; }
|
||||
static bool saveOnExitAnswered() { return s_bSaveOnExitAnswered; }
|
||||
static void resetFlags() {
|
||||
s_bServerHalted = false;
|
||||
s_bSaveOnExitAnswered = false;
|
||||
}
|
||||
|
||||
bool flagEntitiesToBeRemoved(unsigned int *flags); // 4J added
|
||||
bool flagEntitiesToBeRemoved(unsigned int* flags); // 4J added
|
||||
private:
|
||||
//4J Added
|
||||
static MinecraftServer *server;
|
||||
// 4J Added
|
||||
static MinecraftServer* server;
|
||||
|
||||
static bool setTimeOfDayAtEndOfTick;
|
||||
static __int64 setTimeOfDay;
|
||||
static bool setTimeAtEndOfTick;
|
||||
static __int64 setTime;
|
||||
static bool setTimeOfDayAtEndOfTick;
|
||||
static __int64 setTimeOfDay;
|
||||
static bool setTimeAtEndOfTick;
|
||||
static __int64 setTime;
|
||||
|
||||
static bool m_bPrimaryPlayerSignedOut; // 4J-PB added to tell the stopserver not to save the game - another player may have signed in in their place, so ProfileManager.IsSignedIn isn't enough
|
||||
static bool s_bServerHalted; // 4J Stu Added so that we can halt the server even before it's been created properly
|
||||
static bool s_bSaveOnExitAnswered; // 4J Stu Added so that we only ask this question once when we exit
|
||||
static bool
|
||||
m_bPrimaryPlayerSignedOut; // 4J-PB added to tell the stopserver not to
|
||||
// save the game - another player may have
|
||||
// signed in in their place, so
|
||||
// ProfileManager.IsSignedIn isn't enough
|
||||
static bool s_bServerHalted; // 4J Stu Added so that we can halt the server
|
||||
// even before it's been created properly
|
||||
static bool s_bSaveOnExitAnswered; // 4J Stu Added so that we only ask this
|
||||
// question once when we exit
|
||||
|
||||
// 4J - added so that we can have a separate thread for post processing chunks on level creation
|
||||
static int runPostUpdate(void* lpParam);
|
||||
C4JThread* m_postUpdateThread;
|
||||
bool m_postUpdateTerminate;
|
||||
class postProcessRequest
|
||||
{
|
||||
public:
|
||||
int x, z;
|
||||
ChunkSource *chunkSource;
|
||||
postProcessRequest(int x, int z, ChunkSource *chunkSource) : x(x), z(z), chunkSource(chunkSource) {}
|
||||
};
|
||||
std::vector<postProcessRequest> m_postProcessRequests;
|
||||
CRITICAL_SECTION m_postProcessCS;
|
||||
public:
|
||||
void addPostProcessRequest(ChunkSource *chunkSource, int x, int z);
|
||||
// 4J - added so that we can have a separate thread for post processing
|
||||
// chunks on level creation
|
||||
static int runPostUpdate(void* lpParam);
|
||||
C4JThread* m_postUpdateThread;
|
||||
bool m_postUpdateTerminate;
|
||||
class postProcessRequest {
|
||||
public:
|
||||
int x, z;
|
||||
ChunkSource* chunkSource;
|
||||
postProcessRequest(int x, int z, ChunkSource* chunkSource)
|
||||
: x(x), z(z), chunkSource(chunkSource) {}
|
||||
};
|
||||
std::vector<postProcessRequest> m_postProcessRequests;
|
||||
CRITICAL_SECTION m_postProcessCS;
|
||||
|
||||
public:
|
||||
static PlayerList *getPlayerList() { if( server != NULL ) return server->players; else return NULL; }
|
||||
static void SetTimeOfDay(__int64 time) { setTimeOfDayAtEndOfTick = true; setTimeOfDay = time; }
|
||||
static void SetTime(__int64 time) { setTimeAtEndOfTick = true; setTime = time; }
|
||||
|
||||
C4JThread::Event* m_serverPausedEvent;
|
||||
private:
|
||||
// 4J Added
|
||||
bool m_isServerPaused;
|
||||
void addPostProcessRequest(ChunkSource* chunkSource, int x, int z);
|
||||
|
||||
// 4J Added - A static that stores the QNet index of the player that is next allowed to send a packet in the slow queue
|
||||
static int s_slowQueuePlayerIndex;
|
||||
static int s_slowQueueLastTime;
|
||||
public:
|
||||
static bool s_slowQueuePacketSent;
|
||||
static PlayerList* getPlayerList() {
|
||||
if (server != NULL)
|
||||
return server->players;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
static void SetTimeOfDay(__int64 time) {
|
||||
setTimeOfDayAtEndOfTick = true;
|
||||
setTimeOfDay = time;
|
||||
}
|
||||
static void SetTime(__int64 time) {
|
||||
setTimeAtEndOfTick = true;
|
||||
setTime = time;
|
||||
}
|
||||
|
||||
bool IsServerPaused() { return m_isServerPaused; }
|
||||
C4JThread::Event* m_serverPausedEvent;
|
||||
|
||||
private:
|
||||
// 4J Added
|
||||
bool m_saveOnExit;
|
||||
bool m_suspending;
|
||||
// 4J Added
|
||||
bool m_isServerPaused;
|
||||
|
||||
// 4J Added - A static that stores the QNet index of the player that is next
|
||||
// allowed to send a packet in the slow queue
|
||||
static int s_slowQueuePlayerIndex;
|
||||
static int s_slowQueueLastTime;
|
||||
|
||||
public:
|
||||
//static int getSlowQueueIndex() { return s_slowQueuePlayerIndex; }
|
||||
static bool canSendOnSlowQueue(INetworkPlayer *player);
|
||||
static void cycleSlowQueueIndex();
|
||||
static bool s_slowQueuePacketSent;
|
||||
|
||||
void setSaveOnExit(bool save) { m_saveOnExit = save; s_bSaveOnExitAnswered = true; }
|
||||
void Suspend();
|
||||
bool IsSuspending();
|
||||
bool IsServerPaused() { return m_isServerPaused; }
|
||||
|
||||
// 4J Stu - A load of functions were all added in 1.0.1 in the ServerInterface, but I don't think we need any of them
|
||||
private:
|
||||
// 4J Added
|
||||
bool m_saveOnExit;
|
||||
bool m_suspending;
|
||||
|
||||
public:
|
||||
// static int getSlowQueueIndex() { return s_slowQueuePlayerIndex; }
|
||||
static bool canSendOnSlowQueue(INetworkPlayer* player);
|
||||
static void cycleSlowQueueIndex();
|
||||
|
||||
void setSaveOnExit(bool save) {
|
||||
m_saveOnExit = save;
|
||||
s_bSaveOnExitAnswered = true;
|
||||
}
|
||||
void Suspend();
|
||||
bool IsSuspending();
|
||||
|
||||
// 4J Stu - A load of functions were all added in 1.0.1 in the
|
||||
// ServerInterface, but I don't think we need any of them
|
||||
};
|
||||
|
|
|
|||
48
Minecraft.Client/Network Implementation Notes.md
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# 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,45 +0,0 @@
|
|||
NETWORK CODE IMPLEMENTATION NOTES
|
||||
---------------------------------
|
||||
|
||||
The networking classes are organised 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) /
|
||||
|
||||
|
||||
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:
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
|
@ -6,81 +6,97 @@ class SavedDataStorage;
|
|||
class Socket;
|
||||
class MultiplayerLocalPlayer;
|
||||
|
||||
class ClientConnection : public PacketListener
|
||||
{
|
||||
class ClientConnection : public PacketListener {
|
||||
private:
|
||||
enum eClientConnectionConnectingState
|
||||
{
|
||||
eCCPreLoginSent = 0,
|
||||
eCCPreLoginReceived,
|
||||
eCCLoginSent,
|
||||
eCCLoginReceived,
|
||||
eCCConnected
|
||||
};
|
||||
enum eClientConnectionConnectingState {
|
||||
eCCPreLoginSent = 0,
|
||||
eCCPreLoginReceived,
|
||||
eCCLoginSent,
|
||||
eCCLoginReceived,
|
||||
eCCConnected
|
||||
};
|
||||
|
||||
private:
|
||||
bool done;
|
||||
Connection *connection;
|
||||
bool done;
|
||||
Connection* connection;
|
||||
|
||||
public:
|
||||
std::wstring message;
|
||||
bool createdOk; // 4J added
|
||||
std::wstring message;
|
||||
bool createdOk; // 4J added
|
||||
private:
|
||||
Minecraft *minecraft;
|
||||
MultiPlayerLevel *level;
|
||||
Minecraft* minecraft;
|
||||
MultiPlayerLevel* level;
|
||||
bool started;
|
||||
|
||||
// 4J Stu - I don't think we are interested in the PlayerInfo data, so I'm not going to use it at the moment
|
||||
//Map<String, PlayerInfo> playerInfoMap = new HashMap<String, PlayerInfo>();
|
||||
// 4J Stu - I don't think we are interested in the PlayerInfo data, so I'm
|
||||
// not going to use it at the moment
|
||||
// Map<String, PlayerInfo> playerInfoMap = new HashMap<String,
|
||||
// PlayerInfo>();
|
||||
public:
|
||||
//List<PlayerInfo> playerInfos = new ArrayList<PlayerInfo>();
|
||||
// List<PlayerInfo> playerInfos = new ArrayList<PlayerInfo>();
|
||||
|
||||
int maxPlayers;
|
||||
int maxPlayers;
|
||||
|
||||
public:
|
||||
bool isStarted() { return started; } // 4J Added
|
||||
bool isClosed() { return done; } // 4J Added
|
||||
Socket *getSocket() { return connection->getSocket(); } // 4J Added
|
||||
bool isStarted() { return started; } // 4J Added
|
||||
bool isClosed() { return done; } // 4J Added
|
||||
Socket* getSocket() { return connection->getSocket(); } // 4J Added
|
||||
|
||||
private:
|
||||
int m_userIndex; // 4J Added
|
||||
int m_userIndex; // 4J Added
|
||||
public:
|
||||
SavedDataStorage *savedDataStorage;
|
||||
ClientConnection(Minecraft *minecraft, const std::wstring& ip, int port);
|
||||
ClientConnection(Minecraft *minecraft, Socket *socket, int iUserIndex = -1);
|
||||
~ClientConnection();
|
||||
SavedDataStorage* savedDataStorage;
|
||||
ClientConnection(Minecraft* minecraft, const std::wstring& ip, int port);
|
||||
ClientConnection(Minecraft* minecraft, Socket* socket, int iUserIndex = -1);
|
||||
~ClientConnection();
|
||||
void tick();
|
||||
INetworkPlayer *getNetworkPlayer();
|
||||
INetworkPlayer* getNetworkPlayer();
|
||||
virtual void handleLogin(std::shared_ptr<LoginPacket> packet);
|
||||
virtual void handleAddEntity(std::shared_ptr<AddEntityPacket> packet);
|
||||
virtual void handleAddExperienceOrb(std::shared_ptr<AddExperienceOrbPacket> packet);
|
||||
virtual void handleAddGlobalEntity(std::shared_ptr<AddGlobalEntityPacket> packet);
|
||||
virtual void handleAddExperienceOrb(
|
||||
std::shared_ptr<AddExperienceOrbPacket> packet);
|
||||
virtual void handleAddGlobalEntity(
|
||||
std::shared_ptr<AddGlobalEntityPacket> packet);
|
||||
virtual void handleAddPainting(std::shared_ptr<AddPaintingPacket> packet);
|
||||
virtual void handleSetEntityMotion(std::shared_ptr<SetEntityMotionPacket> packet);
|
||||
virtual void handleSetEntityData(std::shared_ptr<SetEntityDataPacket> packet);
|
||||
virtual void handleSetEntityMotion(
|
||||
std::shared_ptr<SetEntityMotionPacket> packet);
|
||||
virtual void handleSetEntityData(
|
||||
std::shared_ptr<SetEntityDataPacket> packet);
|
||||
virtual void handleAddPlayer(std::shared_ptr<AddPlayerPacket> packet);
|
||||
virtual void handleTeleportEntity(std::shared_ptr<TeleportEntityPacket> packet);
|
||||
virtual void handleTeleportEntity(
|
||||
std::shared_ptr<TeleportEntityPacket> packet);
|
||||
virtual void handleMoveEntity(std::shared_ptr<MoveEntityPacket> packet);
|
||||
virtual void handleRotateMob(std::shared_ptr<RotateHeadPacket> packet);
|
||||
virtual void handleMoveEntitySmall(std::shared_ptr<MoveEntityPacketSmall> packet);
|
||||
virtual void handleRemoveEntity(std::shared_ptr<RemoveEntitiesPacket> packet);
|
||||
virtual void handleMovePlayer(std::shared_ptr<MovePlayerPacket> packet);
|
||||
virtual void handleRotateMob(std::shared_ptr<RotateHeadPacket> packet);
|
||||
virtual void handleMoveEntitySmall(
|
||||
std::shared_ptr<MoveEntityPacketSmall> packet);
|
||||
virtual void handleRemoveEntity(
|
||||
std::shared_ptr<RemoveEntitiesPacket> packet);
|
||||
virtual void handleMovePlayer(std::shared_ptr<MovePlayerPacket> packet);
|
||||
|
||||
Random *random;
|
||||
|
||||
// 4J Added
|
||||
virtual void handleChunkVisibilityArea(std::shared_ptr<ChunkVisibilityAreaPacket> packet);
|
||||
Random* random;
|
||||
|
||||
virtual void handleChunkVisibility(std::shared_ptr<ChunkVisibilityPacket> packet);
|
||||
virtual void handleChunkTilesUpdate(std::shared_ptr<ChunkTilesUpdatePacket> packet);
|
||||
virtual void handleBlockRegionUpdate(std::shared_ptr<BlockRegionUpdatePacket> packet);
|
||||
// 4J Added
|
||||
virtual void handleChunkVisibilityArea(
|
||||
std::shared_ptr<ChunkVisibilityAreaPacket> packet);
|
||||
|
||||
virtual void handleChunkVisibility(
|
||||
std::shared_ptr<ChunkVisibilityPacket> packet);
|
||||
virtual void handleChunkTilesUpdate(
|
||||
std::shared_ptr<ChunkTilesUpdatePacket> packet);
|
||||
virtual void handleBlockRegionUpdate(
|
||||
std::shared_ptr<BlockRegionUpdatePacket> packet);
|
||||
virtual void handleTileUpdate(std::shared_ptr<TileUpdatePacket> packet);
|
||||
virtual void handleDisconnect(std::shared_ptr<DisconnectPacket> packet);
|
||||
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects);
|
||||
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason,
|
||||
void* reasonObjects);
|
||||
void sendAndDisconnect(std::shared_ptr<Packet> packet);
|
||||
void send(std::shared_ptr<Packet> packet);
|
||||
virtual void handleTakeItemEntity(std::shared_ptr<TakeItemEntityPacket> packet);
|
||||
virtual void handleTakeItemEntity(
|
||||
std::shared_ptr<TakeItemEntityPacket> packet);
|
||||
virtual void handleChat(std::shared_ptr<ChatPacket> packet);
|
||||
virtual void handleAnimate(std::shared_ptr<AnimatePacket> packet);
|
||||
virtual void handleEntityActionAtPosition(std::shared_ptr<EntityActionAtPositionPacket> packet);
|
||||
virtual void handleEntityActionAtPosition(
|
||||
std::shared_ptr<EntityActionAtPositionPacket> packet);
|
||||
virtual void handlePreLogin(std::shared_ptr<PreLoginPacket> packet);
|
||||
void close();
|
||||
virtual void handleAddMob(std::shared_ptr<AddMobPacket> packet);
|
||||
|
|
@ -88,53 +104,79 @@ public:
|
|||
virtual void handleSetSpawn(std::shared_ptr<SetSpawnPositionPacket> packet);
|
||||
virtual void handleRidePacket(std::shared_ptr<SetRidingPacket> packet);
|
||||
virtual void handleEntityEvent(std::shared_ptr<EntityEventPacket> packet);
|
||||
|
||||
private:
|
||||
std::shared_ptr<Entity> getEntity(int entityId);
|
||||
std::wstring GetDisplayNameByGamertag(std::wstring gamertag);
|
||||
std::shared_ptr<Entity> getEntity(int entityId);
|
||||
std::wstring GetDisplayNameByGamertag(std::wstring gamertag);
|
||||
|
||||
public:
|
||||
virtual void handleSetHealth(std::shared_ptr<SetHealthPacket> packet);
|
||||
virtual void handleSetExperience(std::shared_ptr<SetExperiencePacket> packet);
|
||||
virtual void handleSetExperience(
|
||||
std::shared_ptr<SetExperiencePacket> packet);
|
||||
virtual void handleRespawn(std::shared_ptr<RespawnPacket> packet);
|
||||
virtual void handleExplosion(std::shared_ptr<ExplodePacket> packet);
|
||||
virtual void handleContainerOpen(std::shared_ptr<ContainerOpenPacket> packet);
|
||||
virtual void handleContainerSetSlot(std::shared_ptr<ContainerSetSlotPacket> packet);
|
||||
virtual void handleContainerOpen(
|
||||
std::shared_ptr<ContainerOpenPacket> packet);
|
||||
virtual void handleContainerSetSlot(
|
||||
std::shared_ptr<ContainerSetSlotPacket> packet);
|
||||
virtual void handleContainerAck(std::shared_ptr<ContainerAckPacket> packet);
|
||||
virtual void handleContainerContent(std::shared_ptr<ContainerSetContentPacket> packet);
|
||||
virtual void handleContainerContent(
|
||||
std::shared_ptr<ContainerSetContentPacket> packet);
|
||||
virtual void handleSignUpdate(std::shared_ptr<SignUpdatePacket> packet);
|
||||
virtual void handleTileEntityData(std::shared_ptr<TileEntityDataPacket> packet);
|
||||
virtual void handleContainerSetData(std::shared_ptr<ContainerSetDataPacket> packet);
|
||||
virtual void handleSetEquippedItem(std::shared_ptr<SetEquippedItemPacket> packet);
|
||||
virtual void handleContainerClose(std::shared_ptr<ContainerClosePacket> packet);
|
||||
virtual void handleTileEntityData(
|
||||
std::shared_ptr<TileEntityDataPacket> packet);
|
||||
virtual void handleContainerSetData(
|
||||
std::shared_ptr<ContainerSetDataPacket> packet);
|
||||
virtual void handleSetEquippedItem(
|
||||
std::shared_ptr<SetEquippedItemPacket> packet);
|
||||
virtual void handleContainerClose(
|
||||
std::shared_ptr<ContainerClosePacket> packet);
|
||||
virtual void handleTileEvent(std::shared_ptr<TileEventPacket> packet);
|
||||
virtual void handleTileDestruction(std::shared_ptr<TileDestructionPacket> packet);
|
||||
virtual bool canHandleAsyncPackets();
|
||||
virtual void handleGameEvent(std::shared_ptr<GameEventPacket> gameEventPacket);
|
||||
virtual void handleComplexItemData(std::shared_ptr<ComplexItemDataPacket> packet);
|
||||
virtual void handleTileDestruction(
|
||||
std::shared_ptr<TileDestructionPacket> packet);
|
||||
virtual bool canHandleAsyncPackets();
|
||||
virtual void handleGameEvent(
|
||||
std::shared_ptr<GameEventPacket> gameEventPacket);
|
||||
virtual void handleComplexItemData(
|
||||
std::shared_ptr<ComplexItemDataPacket> packet);
|
||||
virtual void handleLevelEvent(std::shared_ptr<LevelEventPacket> packet);
|
||||
virtual void handleAwardStat(std::shared_ptr<AwardStatPacket> packet);
|
||||
virtual void handleUpdateMobEffect(std::shared_ptr<UpdateMobEffectPacket> packet);
|
||||
virtual void handleRemoveMobEffect(std::shared_ptr<RemoveMobEffectPacket> packet);
|
||||
virtual bool isServerPacketListener();
|
||||
virtual void handlePlayerInfo(std::shared_ptr<PlayerInfoPacket> packet);
|
||||
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
|
||||
virtual void handlePlayerAbilities(std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
|
||||
virtual void handleSoundEvent(std::shared_ptr<LevelSoundPacket> packet);
|
||||
virtual void handleCustomPayload(std::shared_ptr<CustomPayloadPacket> customPayloadPacket);
|
||||
virtual Connection *getConnection();
|
||||
virtual void handleUpdateMobEffect(
|
||||
std::shared_ptr<UpdateMobEffectPacket> packet);
|
||||
virtual void handleRemoveMobEffect(
|
||||
std::shared_ptr<RemoveMobEffectPacket> packet);
|
||||
virtual bool isServerPacketListener();
|
||||
virtual void handlePlayerInfo(std::shared_ptr<PlayerInfoPacket> packet);
|
||||
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
|
||||
virtual void handlePlayerAbilities(
|
||||
std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
|
||||
virtual void handleSoundEvent(std::shared_ptr<LevelSoundPacket> packet);
|
||||
virtual void handleCustomPayload(
|
||||
std::shared_ptr<CustomPayloadPacket> customPayloadPacket);
|
||||
virtual Connection* getConnection();
|
||||
|
||||
// 4J Added
|
||||
virtual void handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet);
|
||||
virtual void handleTexture(std::shared_ptr<TexturePacket> packet);
|
||||
virtual void handleTextureAndGeometry(std::shared_ptr<TextureAndGeometryPacket> packet);
|
||||
virtual void handleUpdateProgress(std::shared_ptr<UpdateProgressPacket> packet);
|
||||
// 4J Added
|
||||
virtual void handleServerSettingsChanged(
|
||||
std::shared_ptr<ServerSettingsChangedPacket> packet);
|
||||
virtual void handleTexture(std::shared_ptr<TexturePacket> packet);
|
||||
virtual void handleTextureAndGeometry(
|
||||
std::shared_ptr<TextureAndGeometryPacket> packet);
|
||||
virtual void handleUpdateProgress(
|
||||
std::shared_ptr<UpdateProgressPacket> packet);
|
||||
|
||||
// 4J Added
|
||||
static int HostDisconnectReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
|
||||
static int ExitGameAndSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
|
||||
virtual void handleTextureChange(std::shared_ptr<TextureChangePacket> packet);
|
||||
virtual void handleTextureAndGeometryChange(std::shared_ptr<TextureAndGeometryChangePacket> packet);
|
||||
virtual void handleUpdateGameRuleProgressPacket(std::shared_ptr<UpdateGameRuleProgressPacket> packet);
|
||||
virtual void handleXZ(std::shared_ptr<XZPacket> packet);
|
||||
// 4J Added
|
||||
static int HostDisconnectReturned(void* pParam, int iPad,
|
||||
C4JStorage::EMessageResult result);
|
||||
static int ExitGameAndSaveReturned(void* pParam, int iPad,
|
||||
C4JStorage::EMessageResult result);
|
||||
virtual void handleTextureChange(
|
||||
std::shared_ptr<TextureChangePacket> packet);
|
||||
virtual void handleTextureAndGeometryChange(
|
||||
std::shared_ptr<TextureAndGeometryChangePacket> packet);
|
||||
virtual void handleUpdateGameRuleProgressPacket(
|
||||
std::shared_ptr<UpdateGameRuleProgressPacket> packet);
|
||||
virtual void handleXZ(std::shared_ptr<XZPacket> packet);
|
||||
|
||||
void displayPrivilegeChanges(std::shared_ptr<MultiplayerLocalPlayer> player, unsigned int oldPrivileges);
|
||||
void displayPrivilegeChanges(std::shared_ptr<MultiplayerLocalPlayer> player,
|
||||
unsigned int oldPrivileges);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,297 +10,287 @@
|
|||
#include "../../Minecraft.World/Blocks/Tile.h"
|
||||
#include "../../Minecraft.World/Level/WaterLevelChunk.h"
|
||||
|
||||
MultiPlayerChunkCache::MultiPlayerChunkCache(Level *level)
|
||||
{
|
||||
XZSIZE = level->dimension->getXZSize(); // 4J Added
|
||||
XZOFFSET = XZSIZE/2; // 4J Added
|
||||
m_XZSize = XZSIZE;
|
||||
hasData = new bool[XZSIZE * XZSIZE];
|
||||
memset(hasData, 0, sizeof(bool) * XZSIZE * XZSIZE);
|
||||
MultiPlayerChunkCache::MultiPlayerChunkCache(Level* level) {
|
||||
XZSIZE = level->dimension->getXZSize(); // 4J Added
|
||||
XZOFFSET = XZSIZE / 2; // 4J Added
|
||||
m_XZSize = XZSIZE;
|
||||
hasData = new bool[XZSIZE * XZSIZE];
|
||||
memset(hasData, 0, sizeof(bool) * XZSIZE * XZSIZE);
|
||||
|
||||
emptyChunk = new EmptyLevelChunk(level, byteArray(16 * 16 * Level::maxBuildHeight), 0, 0);
|
||||
emptyChunk = new EmptyLevelChunk(
|
||||
level, byteArray(16 * 16 * Level::maxBuildHeight), 0, 0);
|
||||
|
||||
// For normal world dimension, create a chunk that can be used to create the illusion of infinite water at the edge of the world
|
||||
if( level->dimension->id == 0 )
|
||||
{
|
||||
byteArray bytes = byteArray(16 * 16 * 128);
|
||||
// For normal world dimension, create a chunk that can be used to create the
|
||||
// illusion of infinite water at the edge of the world
|
||||
if (level->dimension->id == 0) {
|
||||
byteArray bytes = byteArray(16 * 16 * 128);
|
||||
|
||||
// Superflat.... make grass, not water...
|
||||
if(level->getLevelData()->getGenerator() == LevelType::lvl_flat)
|
||||
{
|
||||
for( int x = 0; x < 16; x++ )
|
||||
for( int y = 0; y < 128; y++ )
|
||||
for( int z = 0; z < 16; z++ )
|
||||
{
|
||||
unsigned char tileId = 0;
|
||||
if( y == 3 ) tileId = Tile::grass_Id;
|
||||
else if( y <= 2 ) tileId = Tile::dirt_Id;
|
||||
// Superflat.... make grass, not water...
|
||||
if (level->getLevelData()->getGenerator() == LevelType::lvl_flat) {
|
||||
for (int x = 0; x < 16; x++)
|
||||
for (int y = 0; y < 128; y++)
|
||||
for (int z = 0; z < 16; z++) {
|
||||
unsigned char tileId = 0;
|
||||
if (y == 3)
|
||||
tileId = Tile::grass_Id;
|
||||
else if (y <= 2)
|
||||
tileId = Tile::dirt_Id;
|
||||
|
||||
bytes[x << 11 | z << 7 | y] = tileId;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int x = 0; x < 16; x++ )
|
||||
for( int y = 0; y < 128; y++ )
|
||||
for( int z = 0; z < 16; z++ )
|
||||
{
|
||||
unsigned char tileId = 0;
|
||||
if( y <= ( level->getSeaLevel() - 10 ) ) tileId = Tile::rock_Id;
|
||||
else if( y < level->getSeaLevel() ) tileId = Tile::calmWater_Id;
|
||||
bytes[x << 11 | z << 7 | y] = tileId;
|
||||
}
|
||||
} else {
|
||||
for (int x = 0; x < 16; x++)
|
||||
for (int y = 0; y < 128; y++)
|
||||
for (int z = 0; z < 16; z++) {
|
||||
unsigned char tileId = 0;
|
||||
if (y <= (level->getSeaLevel() - 10))
|
||||
tileId = Tile::rock_Id;
|
||||
else if (y < level->getSeaLevel())
|
||||
tileId = Tile::calmWater_Id;
|
||||
|
||||
bytes[x << 11 | z << 7 | y] = tileId;
|
||||
}
|
||||
}
|
||||
bytes[x << 11 | z << 7 | y] = tileId;
|
||||
}
|
||||
}
|
||||
|
||||
waterChunk = new WaterLevelChunk(level, bytes, 0, 0);
|
||||
waterChunk = new WaterLevelChunk(level, bytes, 0, 0);
|
||||
|
||||
delete[] bytes.data;
|
||||
delete[] bytes.data;
|
||||
|
||||
if(level->getLevelData()->getGenerator() == LevelType::lvl_flat)
|
||||
{
|
||||
for( int x = 0; x < 16; x++ )
|
||||
for( int y = 0; y < 128; y++ )
|
||||
for( int z = 0; z < 16; z++ )
|
||||
{
|
||||
if( y >= 3 )
|
||||
{
|
||||
((WaterLevelChunk *)waterChunk)->setLevelChunkBrightness(LightLayer::Sky,x,y,z,15);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int x = 0; x < 16; x++ )
|
||||
for( int y = 0; y < 128; y++ )
|
||||
for( int z = 0; z < 16; z++ )
|
||||
{
|
||||
if( y >= ( level->getSeaLevel() - 1 ) )
|
||||
{
|
||||
((WaterLevelChunk *)waterChunk)->setLevelChunkBrightness(LightLayer::Sky,x,y,z,15);
|
||||
}
|
||||
else
|
||||
{
|
||||
((WaterLevelChunk *)waterChunk)->setLevelChunkBrightness(LightLayer::Sky,x,y,z,2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
waterChunk = NULL;
|
||||
}
|
||||
if (level->getLevelData()->getGenerator() == LevelType::lvl_flat) {
|
||||
for (int x = 0; x < 16; x++)
|
||||
for (int y = 0; y < 128; y++)
|
||||
for (int z = 0; z < 16; z++) {
|
||||
if (y >= 3) {
|
||||
((WaterLevelChunk*)waterChunk)
|
||||
->setLevelChunkBrightness(LightLayer::Sky, x, y,
|
||||
z, 15);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int x = 0; x < 16; x++)
|
||||
for (int y = 0; y < 128; y++)
|
||||
for (int z = 0; z < 16; z++) {
|
||||
if (y >= (level->getSeaLevel() - 1)) {
|
||||
((WaterLevelChunk*)waterChunk)
|
||||
->setLevelChunkBrightness(LightLayer::Sky, x, y,
|
||||
z, 15);
|
||||
} else {
|
||||
((WaterLevelChunk*)waterChunk)
|
||||
->setLevelChunkBrightness(LightLayer::Sky, x, y,
|
||||
z, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
waterChunk = NULL;
|
||||
}
|
||||
|
||||
this->level = level;
|
||||
this->level = level;
|
||||
|
||||
this->cache = new LevelChunk *[XZSIZE * XZSIZE];
|
||||
memset(this->cache, 0, XZSIZE * XZSIZE * sizeof(LevelChunk *));
|
||||
InitializeCriticalSectionAndSpinCount(&m_csLoadCreate,4000);
|
||||
this->cache = new LevelChunk*[XZSIZE * XZSIZE];
|
||||
memset(this->cache, 0, XZSIZE * XZSIZE * sizeof(LevelChunk*));
|
||||
InitializeCriticalSectionAndSpinCount(&m_csLoadCreate, 4000);
|
||||
}
|
||||
|
||||
MultiPlayerChunkCache::~MultiPlayerChunkCache()
|
||||
{
|
||||
delete emptyChunk;
|
||||
delete waterChunk;
|
||||
delete cache;
|
||||
delete hasData;
|
||||
MultiPlayerChunkCache::~MultiPlayerChunkCache() {
|
||||
delete emptyChunk;
|
||||
delete waterChunk;
|
||||
delete cache;
|
||||
delete hasData;
|
||||
|
||||
AUTO_VAR(itEnd, loadedChunkList.end());
|
||||
for (AUTO_VAR(it, loadedChunkList.begin()); it != itEnd; it++)
|
||||
delete *it;
|
||||
AUTO_VAR(itEnd, loadedChunkList.end());
|
||||
for (AUTO_VAR(it, loadedChunkList.begin()); it != itEnd; it++) delete *it;
|
||||
|
||||
DeleteCriticalSection(&m_csLoadCreate);
|
||||
DeleteCriticalSection(&m_csLoadCreate);
|
||||
}
|
||||
|
||||
|
||||
bool MultiPlayerChunkCache::hasChunk(int x, int z)
|
||||
{
|
||||
// This cache always claims to have chunks, although it might actually just return empty data if it doesn't have anything
|
||||
return true;
|
||||
bool MultiPlayerChunkCache::hasChunk(int x, int z) {
|
||||
// This cache always claims to have chunks, although it might actually just
|
||||
// return empty data if it doesn't have anything
|
||||
return true;
|
||||
}
|
||||
|
||||
// 4J added - find out if we actually really do have a chunk in our cache
|
||||
bool MultiPlayerChunkCache::reallyHasChunk(int x, int z)
|
||||
{
|
||||
int ix = x + XZOFFSET;
|
||||
int iz = z + XZOFFSET;
|
||||
// Check we're in range of the stored level - if we aren't, then consider that we do have that chunk as we'll be able to use the water chunk there
|
||||
if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return true;
|
||||
if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return true;
|
||||
int idx = ix * XZSIZE + iz;
|
||||
bool MultiPlayerChunkCache::reallyHasChunk(int x, int z) {
|
||||
int ix = x + XZOFFSET;
|
||||
int iz = z + XZOFFSET;
|
||||
// Check we're in range of the stored level - if we aren't, then consider
|
||||
// that we do have that chunk as we'll be able to use the water chunk there
|
||||
if ((ix < 0) || (ix >= XZSIZE)) return true;
|
||||
if ((iz < 0) || (iz >= XZSIZE)) return true;
|
||||
int idx = ix * XZSIZE + iz;
|
||||
|
||||
LevelChunk *chunk = cache[idx];
|
||||
if( chunk == NULL )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return hasData[idx];
|
||||
LevelChunk* chunk = cache[idx];
|
||||
if (chunk == NULL) {
|
||||
return false;
|
||||
}
|
||||
return hasData[idx];
|
||||
}
|
||||
|
||||
void MultiPlayerChunkCache::drop(int x, int z)
|
||||
{
|
||||
// 4J Stu - We do want to drop any entities in the chunks, especially for the case when a player is dead as they will
|
||||
// not get the RemoveEntity packet if an entity is removed.
|
||||
LevelChunk *chunk = getChunk(x, z);
|
||||
if (!chunk->isEmpty())
|
||||
{
|
||||
// Added parameter here specifies that we don't want to delete tile entities, as they won't get recreated unless they've got update packets
|
||||
// The tile entities are in general only created on the client by virtue of the chunk rebuild
|
||||
chunk->unload(false);
|
||||
void MultiPlayerChunkCache::drop(int x, int z) {
|
||||
// 4J Stu - We do want to drop any entities in the chunks, especially for
|
||||
// the case when a player is dead as they will not get the RemoveEntity
|
||||
// packet if an entity is removed.
|
||||
LevelChunk* chunk = getChunk(x, z);
|
||||
if (!chunk->isEmpty()) {
|
||||
// Added parameter here specifies that we don't want to delete tile
|
||||
// entities, as they won't get recreated unless they've got update
|
||||
// packets The tile entities are in general only created on the client
|
||||
// by virtue of the chunk rebuild
|
||||
chunk->unload(false);
|
||||
|
||||
// 4J - We just want to clear out the entities in the chunk, but everything else should be valid
|
||||
chunk->loaded = true;
|
||||
// 4J - We just want to clear out the entities in the chunk, but
|
||||
// everything else should be valid
|
||||
chunk->loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
LevelChunk *MultiPlayerChunkCache::create(int x, int z)
|
||||
{
|
||||
int ix = x + XZOFFSET;
|
||||
int iz = z + XZOFFSET;
|
||||
// Check we're in range of the stored level
|
||||
if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk );
|
||||
if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk );
|
||||
int idx = ix * XZSIZE + iz;
|
||||
LevelChunk *chunk = cache[idx];
|
||||
LevelChunk *lastChunk = chunk;
|
||||
LevelChunk* MultiPlayerChunkCache::create(int x, int z) {
|
||||
int ix = x + XZOFFSET;
|
||||
int iz = z + XZOFFSET;
|
||||
// Check we're in range of the stored level
|
||||
if ((ix < 0) || (ix >= XZSIZE))
|
||||
return (waterChunk ? waterChunk : emptyChunk);
|
||||
if ((iz < 0) || (iz >= XZSIZE))
|
||||
return (waterChunk ? waterChunk : emptyChunk);
|
||||
int idx = ix * XZSIZE + iz;
|
||||
LevelChunk* chunk = cache[idx];
|
||||
LevelChunk* lastChunk = chunk;
|
||||
|
||||
if( chunk == NULL )
|
||||
{
|
||||
EnterCriticalSection(&m_csLoadCreate);
|
||||
if (chunk == NULL) {
|
||||
EnterCriticalSection(&m_csLoadCreate);
|
||||
|
||||
//LevelChunk *chunk;
|
||||
if( g_NetworkManager.IsHost() ) // force here to disable sharing of data
|
||||
{
|
||||
// 4J-JEV: We are about to use shared data, abort if the server is stopped and the data is deleted.
|
||||
if (MinecraftServer::getInstance()->serverHalted()) return NULL;
|
||||
// LevelChunk *chunk;
|
||||
if (g_NetworkManager.IsHost()) // force here to disable sharing of data
|
||||
{
|
||||
// 4J-JEV: We are about to use shared data, abort if the server is
|
||||
// stopped and the data is deleted.
|
||||
if (MinecraftServer::getInstance()->serverHalted()) return NULL;
|
||||
|
||||
// If we're the host, then don't create the chunk, share data from the server's copy
|
||||
// If we're the host, then don't create the chunk, share data from
|
||||
// the server's copy
|
||||
#ifdef _LARGE_WORLDS
|
||||
LevelChunk *serverChunk = MinecraftServer::getInstance()->getLevel(level->dimension->id)->cache->getChunkLoadedOrUnloaded(x,z);
|
||||
LevelChunk* serverChunk =
|
||||
MinecraftServer::getInstance()
|
||||
->getLevel(level->dimension->id)
|
||||
->cache->getChunkLoadedOrUnloaded(x, z);
|
||||
#else
|
||||
LevelChunk *serverChunk = MinecraftServer::getInstance()->getLevel(level->dimension->id)->cache->getChunk(x,z);
|
||||
LevelChunk* serverChunk = MinecraftServer::getInstance()
|
||||
->getLevel(level->dimension->id)
|
||||
->cache->getChunk(x, z);
|
||||
#endif
|
||||
chunk = new LevelChunk(level, x, z, serverChunk);
|
||||
// Let renderer know that this chunk has been created - it might have made render data from the EmptyChunk if it got to a chunk before the server sent it
|
||||
level->setTilesDirty( x * 16 , 0 , z * 16 , x * 16 + 15, 127, z * 16 + 15);
|
||||
hasData[idx] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Passing an empty array into the LevelChunk ctor, which it now detects and sets up the chunk as compressed & empty
|
||||
byteArray bytes;
|
||||
chunk = new LevelChunk(level, x, z, serverChunk);
|
||||
// Let renderer know that this chunk has been created - it might
|
||||
// have made render data from the EmptyChunk if it got to a chunk
|
||||
// before the server sent it
|
||||
level->setTilesDirty(x * 16, 0, z * 16, x * 16 + 15, 127,
|
||||
z * 16 + 15);
|
||||
hasData[idx] = true;
|
||||
} else {
|
||||
// Passing an empty array into the LevelChunk ctor, which it now
|
||||
// detects and sets up the chunk as compressed & empty
|
||||
byteArray bytes;
|
||||
|
||||
chunk = new LevelChunk(level, bytes, x, z);
|
||||
chunk = new LevelChunk(level, bytes, x, z);
|
||||
|
||||
// 4J - changed to use new methods for lighting
|
||||
chunk->setSkyLightDataAllBright();
|
||||
// Arrays::fill(chunk->skyLight->data, (uint8_t) 255);
|
||||
}
|
||||
|
||||
chunk->loaded = true;
|
||||
// 4J - changed to use new methods for lighting
|
||||
chunk->setSkyLightDataAllBright();
|
||||
// Arrays::fill(chunk->skyLight->data, (uint8_t)
|
||||
//255);
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&m_csLoadCreate);
|
||||
chunk->loaded = true;
|
||||
|
||||
#if ( defined _WIN64 || defined __LP64__ )
|
||||
if( InterlockedCompareExchangeRelease64((LONG64 *)&cache[idx],(LONG64)chunk,(LONG64)lastChunk) == (LONG64)lastChunk )
|
||||
LeaveCriticalSection(&m_csLoadCreate);
|
||||
|
||||
#if (defined _WIN64 || defined __LP64__)
|
||||
if (InterlockedCompareExchangeRelease64(
|
||||
(LONG64*)&cache[idx], (LONG64)chunk, (LONG64)lastChunk) ==
|
||||
(LONG64)lastChunk)
|
||||
#else
|
||||
if( InterlockedCompareExchangeRelease((LONG *)&cache[idx],(LONG)chunk,(LONG)lastChunk) == (LONG)lastChunk )
|
||||
#endif // _DURANGO
|
||||
{
|
||||
// If we're sharing with the server, we'll need to calculate our heightmap now, which isn't shared. If we aren't sharing with the server,
|
||||
// then this will be calculated when the chunk data arrives.
|
||||
if( g_NetworkManager.IsHost() )
|
||||
{
|
||||
chunk->recalcHeightmapOnly();
|
||||
}
|
||||
if (InterlockedCompareExchangeRelease((LONG*)&cache[idx], (LONG)chunk,
|
||||
(LONG)lastChunk) ==
|
||||
(LONG)lastChunk)
|
||||
#endif // _DURANGO
|
||||
{
|
||||
// If we're sharing with the server, we'll need to calculate our
|
||||
// heightmap now, which isn't shared. If we aren't sharing with the
|
||||
// server, then this will be calculated when the chunk data arrives.
|
||||
if (g_NetworkManager.IsHost()) {
|
||||
chunk->recalcHeightmapOnly();
|
||||
}
|
||||
|
||||
// Successfully updated the cache
|
||||
EnterCriticalSection(&m_csLoadCreate);
|
||||
loadedChunkList.push_back(chunk);
|
||||
LeaveCriticalSection(&m_csLoadCreate);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Something else must have updated the cache. Return that chunk and discard this one. This really shouldn't be happening
|
||||
// in multiplayer
|
||||
delete chunk;
|
||||
return cache[idx];
|
||||
}
|
||||
// Successfully updated the cache
|
||||
EnterCriticalSection(&m_csLoadCreate);
|
||||
loadedChunkList.push_back(chunk);
|
||||
LeaveCriticalSection(&m_csLoadCreate);
|
||||
} else {
|
||||
// Something else must have updated the cache. Return that chunk and
|
||||
// discard this one. This really shouldn't be happening in
|
||||
// multiplayer
|
||||
delete chunk;
|
||||
return cache[idx];
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
chunk->load();
|
||||
}
|
||||
} else {
|
||||
chunk->load();
|
||||
}
|
||||
|
||||
return chunk;
|
||||
return chunk;
|
||||
}
|
||||
|
||||
LevelChunk *MultiPlayerChunkCache::getChunk(int x, int z)
|
||||
{
|
||||
int ix = x + XZOFFSET;
|
||||
int iz = z + XZOFFSET;
|
||||
// Check we're in range of the stored level
|
||||
if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk );
|
||||
if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk );
|
||||
int idx = ix * XZSIZE + iz;
|
||||
LevelChunk* MultiPlayerChunkCache::getChunk(int x, int z) {
|
||||
int ix = x + XZOFFSET;
|
||||
int iz = z + XZOFFSET;
|
||||
// Check we're in range of the stored level
|
||||
if ((ix < 0) || (ix >= XZSIZE))
|
||||
return (waterChunk ? waterChunk : emptyChunk);
|
||||
if ((iz < 0) || (iz >= XZSIZE))
|
||||
return (waterChunk ? waterChunk : emptyChunk);
|
||||
int idx = ix * XZSIZE + iz;
|
||||
|
||||
LevelChunk *chunk = cache[idx];
|
||||
if( chunk == NULL )
|
||||
{
|
||||
return emptyChunk;
|
||||
}
|
||||
else
|
||||
{
|
||||
return chunk;
|
||||
}
|
||||
LevelChunk* chunk = cache[idx];
|
||||
if (chunk == NULL) {
|
||||
return emptyChunk;
|
||||
} else {
|
||||
return chunk;
|
||||
}
|
||||
}
|
||||
|
||||
bool MultiPlayerChunkCache::save(bool force, ProgressListener *progressListener)
|
||||
{
|
||||
return true;
|
||||
bool MultiPlayerChunkCache::save(bool force,
|
||||
ProgressListener* progressListener) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MultiPlayerChunkCache::tick()
|
||||
{
|
||||
return false;
|
||||
bool MultiPlayerChunkCache::tick() { return false; }
|
||||
|
||||
bool MultiPlayerChunkCache::shouldSave() { return false; }
|
||||
|
||||
void MultiPlayerChunkCache::postProcess(ChunkSource* parent, int x, int z) {}
|
||||
|
||||
std::vector<Biome::MobSpawnerData*>* MultiPlayerChunkCache::getMobsAt(
|
||||
MobCategory* mobCategory, int x, int y, int z) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool MultiPlayerChunkCache::shouldSave()
|
||||
{
|
||||
return false;
|
||||
TilePos* MultiPlayerChunkCache::findNearestMapFeature(
|
||||
Level* level, const std::wstring& featureName, int x, int y, int z) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void MultiPlayerChunkCache::postProcess(ChunkSource *parent, int x, int z)
|
||||
{
|
||||
std::wstring MultiPlayerChunkCache::gatherStats() {
|
||||
EnterCriticalSection(&m_csLoadCreate);
|
||||
int size = (int)loadedChunkList.size();
|
||||
LeaveCriticalSection(&m_csLoadCreate);
|
||||
return L"MultiplayerChunkCache: " + _toString<int>(size);
|
||||
}
|
||||
|
||||
std::vector<Biome::MobSpawnerData *> *MultiPlayerChunkCache::getMobsAt(MobCategory *mobCategory, int x, int y, int z)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TilePos *MultiPlayerChunkCache::findNearestMapFeature(Level *level, const std::wstring &featureName, int x, int y, int z)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::wstring MultiPlayerChunkCache::gatherStats()
|
||||
{
|
||||
EnterCriticalSection(&m_csLoadCreate);
|
||||
int size = (int)loadedChunkList.size();
|
||||
LeaveCriticalSection(&m_csLoadCreate);
|
||||
return L"MultiplayerChunkCache: " + _toString<int>(size);
|
||||
|
||||
}
|
||||
|
||||
void MultiPlayerChunkCache::dataReceived(int x, int z)
|
||||
{
|
||||
int ix = x + XZOFFSET;
|
||||
int iz = z + XZOFFSET;
|
||||
// Check we're in range of the stored level
|
||||
if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return;
|
||||
if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return;
|
||||
int idx = ix * XZSIZE + iz;
|
||||
hasData[idx] = true;
|
||||
void MultiPlayerChunkCache::dataReceived(int x, int z) {
|
||||
int ix = x + XZOFFSET;
|
||||
int iz = z + XZOFFSET;
|
||||
// Check we're in range of the stored level
|
||||
if ((ix < 0) || (ix >= XZSIZE)) return;
|
||||
if ((iz < 0) || (iz >= XZSIZE)) return;
|
||||
int idx = ix * XZSIZE + iz;
|
||||
hasData[idx] = true;
|
||||
}
|
||||
|
|
@ -3,45 +3,48 @@
|
|||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.chunk.h"
|
||||
#include "../../Minecraft.World/Level/RandomLevelSource.h"
|
||||
|
||||
|
||||
class ServerChunkCache;
|
||||
|
||||
// 4J - various alterations here to make this thread safe, and operate as a fixed sized cache
|
||||
class MultiPlayerChunkCache : public ChunkSource
|
||||
{
|
||||
friend class LevelRenderer;
|
||||
// 4J - various alterations here to make this thread safe, and operate as a
|
||||
// fixed sized cache
|
||||
class MultiPlayerChunkCache : public ChunkSource {
|
||||
friend class LevelRenderer;
|
||||
|
||||
private:
|
||||
LevelChunk *emptyChunk;
|
||||
LevelChunk *waterChunk;
|
||||
LevelChunk* emptyChunk;
|
||||
LevelChunk* waterChunk;
|
||||
|
||||
std::vector<LevelChunk *> loadedChunkList;
|
||||
std::vector<LevelChunk*> loadedChunkList;
|
||||
|
||||
LevelChunk **cache;
|
||||
// 4J - added for multithreaded support
|
||||
CRITICAL_SECTION m_csLoadCreate;
|
||||
// 4J - size of cache is defined by size of one side - must be even
|
||||
int XZSIZE;
|
||||
int XZOFFSET;
|
||||
bool *hasData;
|
||||
LevelChunk** cache;
|
||||
// 4J - added for multithreaded support
|
||||
CRITICAL_SECTION m_csLoadCreate;
|
||||
// 4J - size of cache is defined by size of one side - must be even
|
||||
int XZSIZE;
|
||||
int XZOFFSET;
|
||||
bool* hasData;
|
||||
|
||||
Level *level;
|
||||
Level* level;
|
||||
|
||||
public:
|
||||
MultiPlayerChunkCache(Level *level);
|
||||
~MultiPlayerChunkCache();
|
||||
MultiPlayerChunkCache(Level* level);
|
||||
~MultiPlayerChunkCache();
|
||||
virtual bool hasChunk(int x, int z);
|
||||
virtual bool reallyHasChunk(int x, int z);
|
||||
virtual bool reallyHasChunk(int x, int z);
|
||||
virtual void drop(int x, int z);
|
||||
virtual LevelChunk *create(int x, int z);
|
||||
virtual LevelChunk *getChunk(int x, int z);
|
||||
virtual bool save(bool force, ProgressListener *progressListener);
|
||||
virtual LevelChunk* create(int x, int z);
|
||||
virtual LevelChunk* getChunk(int x, int z);
|
||||
virtual bool save(bool force, ProgressListener* progressListener);
|
||||
virtual bool tick();
|
||||
virtual bool shouldSave();
|
||||
virtual void postProcess(ChunkSource *parent, int x, int z);
|
||||
virtual void postProcess(ChunkSource* parent, int x, int z);
|
||||
virtual std::wstring gatherStats();
|
||||
virtual std::vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, int x, int y, int z);
|
||||
virtual TilePos *findNearestMapFeature(Level *level, const std::wstring &featureName, int x, int y, int z);
|
||||
virtual void dataReceived(int x, int z); // 4J added
|
||||
virtual std::vector<Biome::MobSpawnerData*>* getMobsAt(
|
||||
MobCategory* mobCategory, int x, int y, int z);
|
||||
virtual TilePos* findNearestMapFeature(Level* level,
|
||||
const std::wstring& featureName,
|
||||
int x, int y, int z);
|
||||
virtual void dataReceived(int x, int z); // 4J added
|
||||
|
||||
virtual LevelChunk **getCache() { return cache; } // 4J added
|
||||
virtual LevelChunk** getCache() { return cache; } // 4J added
|
||||
};
|
||||
|
|
@ -19,112 +19,108 @@
|
|||
// #include "PS3/Network/NetworkPlayerSony.h"
|
||||
// #endif
|
||||
|
||||
Random *PendingConnection::random = new Random();
|
||||
Random* PendingConnection::random = new Random();
|
||||
|
||||
PendingConnection::PendingConnection(MinecraftServer *server, Socket *socket, const std::wstring& id)
|
||||
{
|
||||
// 4J - added initialisers
|
||||
done = false;
|
||||
PendingConnection::PendingConnection(MinecraftServer* server, Socket* socket,
|
||||
const std::wstring& id) {
|
||||
// 4J - added initialisers
|
||||
done = false;
|
||||
_tick = 0;
|
||||
name = L"";
|
||||
acceptedLogin = nullptr;
|
||||
loginKey = L"";
|
||||
loginKey = L"";
|
||||
|
||||
this->server = server;
|
||||
connection = new Connection(socket, id, this);
|
||||
connection->fakeLag = FAKE_LAG;
|
||||
}
|
||||
|
||||
PendingConnection::~PendingConnection()
|
||||
{
|
||||
delete connection;
|
||||
}
|
||||
PendingConnection::~PendingConnection() { delete connection; }
|
||||
|
||||
void PendingConnection::tick()
|
||||
{
|
||||
if (acceptedLogin != NULL)
|
||||
{
|
||||
void PendingConnection::tick() {
|
||||
if (acceptedLogin != NULL) {
|
||||
this->handleAcceptedLogin(acceptedLogin);
|
||||
acceptedLogin = nullptr;
|
||||
}
|
||||
if (_tick++ == MAX_TICKS_BEFORE_LOGIN)
|
||||
{
|
||||
if (_tick++ == MAX_TICKS_BEFORE_LOGIN) {
|
||||
disconnect(DisconnectPacket::eDisconnect_LoginTooLong);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
connection->tick();
|
||||
}
|
||||
}
|
||||
|
||||
void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason)
|
||||
{
|
||||
// try { // 4J - removed try/catch
|
||||
// logger.info("Disconnecting " + getName() + ": " + reason);
|
||||
fprintf(stderr, "[PENDING] disconnect called with reason=%d at tick=%d\n", reason, _tick);
|
||||
app.DebugPrintf("Pending connection disconnect: %d\n", reason );
|
||||
connection->send( std::shared_ptr<DisconnectPacket>( new DisconnectPacket(reason) ) );
|
||||
connection->sendAndQuit();
|
||||
done = true;
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason) {
|
||||
// try { // 4J - removed try/catch
|
||||
// logger.info("Disconnecting " + getName() + ": " + reason);
|
||||
fprintf(stderr, "[PENDING] disconnect called with reason=%d at tick=%d\n",
|
||||
reason, _tick);
|
||||
app.DebugPrintf("Pending connection disconnect: %d\n", reason);
|
||||
connection->send(
|
||||
std::shared_ptr<DisconnectPacket>(new DisconnectPacket(reason)));
|
||||
connection->sendAndQuit();
|
||||
done = true;
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
void PendingConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet)
|
||||
{
|
||||
if (packet->m_netcodeVersion != MINECRAFT_NET_VERSION)
|
||||
{
|
||||
app.DebugPrintf("Netcode version is %d not equal to %d\n", packet->m_netcodeVersion, MINECRAFT_NET_VERSION);
|
||||
if (packet->m_netcodeVersion > MINECRAFT_NET_VERSION)
|
||||
{
|
||||
void PendingConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet) {
|
||||
if (packet->m_netcodeVersion != MINECRAFT_NET_VERSION) {
|
||||
app.DebugPrintf("Netcode version is %d not equal to %d\n",
|
||||
packet->m_netcodeVersion, MINECRAFT_NET_VERSION);
|
||||
if (packet->m_netcodeVersion > MINECRAFT_NET_VERSION) {
|
||||
disconnect(DisconnectPacket::eDisconnect_OutdatedServer);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
disconnect(DisconnectPacket::eDisconnect_OutdatedClient);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// printf("Server: handlePreLogin\n");
|
||||
name = packet->loginKey; // 4J Stu - Change from the login packet as we know better on client end during the pre-login packet
|
||||
sendPreLoginResponse();
|
||||
// printf("Server: handlePreLogin\n");
|
||||
name =
|
||||
packet->loginKey; // 4J Stu - Change from the login packet as we know
|
||||
// better on client end during the pre-login packet
|
||||
sendPreLoginResponse();
|
||||
}
|
||||
|
||||
void PendingConnection::sendPreLoginResponse()
|
||||
{
|
||||
// 4J Stu - Calculate the players with UGC privileges set
|
||||
PlayerUID *ugcXuids = new PlayerUID[MINECRAFT_NET_MAX_PLAYERS];
|
||||
std::uint8_t ugcXuidCount = 0;
|
||||
std::uint8_t hostIndex = 0;
|
||||
std::uint8_t ugcFriendsOnlyBits = 0;
|
||||
char szUniqueMapName[14];
|
||||
void PendingConnection::sendPreLoginResponse() {
|
||||
// 4J Stu - Calculate the players with UGC privileges set
|
||||
PlayerUID* ugcXuids = new PlayerUID[MINECRAFT_NET_MAX_PLAYERS];
|
||||
std::uint8_t ugcXuidCount = 0;
|
||||
std::uint8_t hostIndex = 0;
|
||||
std::uint8_t ugcFriendsOnlyBits = 0;
|
||||
char szUniqueMapName[14];
|
||||
|
||||
StorageManager.GetSaveUniqueFilename(szUniqueMapName);
|
||||
StorageManager.GetSaveUniqueFilename(szUniqueMapName);
|
||||
|
||||
PlayerList *playerList = MinecraftServer::getInstance()->getPlayers();
|
||||
for(AUTO_VAR(it, playerList->players.begin()); it != playerList->players.end(); ++it)
|
||||
{
|
||||
std::shared_ptr<ServerPlayer> player = *it;
|
||||
// If the offline Xuid is invalid but the online one is not then that's guest which we should ignore
|
||||
// If the online Xuid is invalid but the offline one is not then we are definitely an offline game so dont care about UGC
|
||||
|
||||
// PADDY - this is failing when a local player with chat restrictions joins an online game
|
||||
PlayerList* playerList = MinecraftServer::getInstance()->getPlayers();
|
||||
for (AUTO_VAR(it, playerList->players.begin());
|
||||
it != playerList->players.end(); ++it) {
|
||||
std::shared_ptr<ServerPlayer> player = *it;
|
||||
// If the offline Xuid is invalid but the online one is not then that's
|
||||
// guest which we should ignore If the online Xuid is invalid but the
|
||||
// offline one is not then we are definitely an offline game so dont
|
||||
// care about UGC
|
||||
|
||||
if( player != NULL && player->connection->m_offlineXUID != INVALID_XUID && player->connection->m_onlineXUID != INVALID_XUID )
|
||||
{
|
||||
if( player->connection->m_friendsOnlyUGC )
|
||||
{
|
||||
ugcFriendsOnlyBits |= (1<<ugcXuidCount);
|
||||
}
|
||||
// Need to use the online XUID otherwise friend checks will fail on the client
|
||||
ugcXuids[ugcXuidCount] = player->connection->m_onlineXUID;
|
||||
// PADDY - this is failing when a local player with chat restrictions
|
||||
// joins an online game
|
||||
|
||||
if( player->connection->getNetworkPlayer() != NULL && player->connection->getNetworkPlayer()->IsHost() ) hostIndex = ugcXuidCount;
|
||||
if (player != NULL &&
|
||||
player->connection->m_offlineXUID != INVALID_XUID &&
|
||||
player->connection->m_onlineXUID != INVALID_XUID) {
|
||||
if (player->connection->m_friendsOnlyUGC) {
|
||||
ugcFriendsOnlyBits |= (1 << ugcXuidCount);
|
||||
}
|
||||
// Need to use the online XUID otherwise friend checks will fail on
|
||||
// the client
|
||||
ugcXuids[ugcXuidCount] = player->connection->m_onlineXUID;
|
||||
|
||||
++ugcXuidCount;
|
||||
}
|
||||
}
|
||||
if (player->connection->getNetworkPlayer() != NULL &&
|
||||
player->connection->getNetworkPlayer()->IsHost())
|
||||
hostIndex = ugcXuidCount;
|
||||
|
||||
++ugcXuidCount;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (false)// server->onlineMode) // 4J - removed
|
||||
|
|
@ -134,47 +130,44 @@ void PendingConnection::sendPreLoginResponse()
|
|||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
connection->send( std::shared_ptr<PreLoginPacket>( new PreLoginPacket(L"-", ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion,szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex, server->m_texturePackId) ) );
|
||||
{
|
||||
connection->send(std::shared_ptr<PreLoginPacket>(
|
||||
new PreLoginPacket(L"-", ugcXuids, ugcXuidCount, ugcFriendsOnlyBits,
|
||||
server->m_ugcPlayersVersion, szUniqueMapName,
|
||||
app.GetGameHostOption(eGameHostOption_All),
|
||||
hostIndex, server->m_texturePackId)));
|
||||
}
|
||||
}
|
||||
|
||||
void PendingConnection::handleLogin(std::shared_ptr<LoginPacket> packet)
|
||||
{
|
||||
fprintf(stderr, "[LOGIN-SRV] handleLogin called! clientVersion=%d\n", packet->clientVersion);
|
||||
//name = packet->userName;
|
||||
if (packet->clientVersion != SharedConstants::NETWORK_PROTOCOL_VERSION)
|
||||
{
|
||||
app.DebugPrintf("Client version is %d not equal to %d\n", packet->clientVersion, SharedConstants::NETWORK_PROTOCOL_VERSION);
|
||||
if (packet->clientVersion > SharedConstants::NETWORK_PROTOCOL_VERSION)
|
||||
{
|
||||
void PendingConnection::handleLogin(std::shared_ptr<LoginPacket> packet) {
|
||||
fprintf(stderr, "[LOGIN-SRV] handleLogin called! clientVersion=%d\n",
|
||||
packet->clientVersion);
|
||||
// name = packet->userName;
|
||||
if (packet->clientVersion != SharedConstants::NETWORK_PROTOCOL_VERSION) {
|
||||
app.DebugPrintf("Client version is %d not equal to %d\n",
|
||||
packet->clientVersion,
|
||||
SharedConstants::NETWORK_PROTOCOL_VERSION);
|
||||
if (packet->clientVersion > SharedConstants::NETWORK_PROTOCOL_VERSION) {
|
||||
disconnect(DisconnectPacket::eDisconnect_OutdatedServer);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
disconnect(DisconnectPacket::eDisconnect_OutdatedClient);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//if (true)// 4J removed !server->onlineMode)
|
||||
bool sentDisconnect = false;
|
||||
// if (true)// 4J removed !server->onlineMode)
|
||||
bool sentDisconnect = false;
|
||||
|
||||
if( sentDisconnect )
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
else if( server->getPlayers()->isXuidBanned( packet->m_onlineXuid ) )
|
||||
{
|
||||
disconnect(DisconnectPacket::eDisconnect_Banned);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sentDisconnect) {
|
||||
// Do nothing
|
||||
} else if (server->getPlayers()->isXuidBanned(packet->m_onlineXuid)) {
|
||||
disconnect(DisconnectPacket::eDisconnect_Banned);
|
||||
} else {
|
||||
handleAcceptedLogin(packet);
|
||||
}
|
||||
//else
|
||||
{
|
||||
//4J - removed
|
||||
// else
|
||||
{
|
||||
// 4J - removed
|
||||
#if 0
|
||||
new Thread() {
|
||||
public void run() {
|
||||
|
|
@ -197,75 +190,71 @@ void PendingConnection::handleLogin(std::shared_ptr<LoginPacket> packet)
|
|||
}.start();
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PendingConnection::handleAcceptedLogin(std::shared_ptr<LoginPacket> packet)
|
||||
{
|
||||
if(packet->m_ugcPlayersVersion != server->m_ugcPlayersVersion)
|
||||
{
|
||||
// Send the pre-login packet again with the new list of players
|
||||
sendPreLoginResponse();
|
||||
return;
|
||||
}
|
||||
void PendingConnection::handleAcceptedLogin(
|
||||
std::shared_ptr<LoginPacket> packet) {
|
||||
if (packet->m_ugcPlayersVersion != server->m_ugcPlayersVersion) {
|
||||
// Send the pre-login packet again with the new list of players
|
||||
sendPreLoginResponse();
|
||||
return;
|
||||
}
|
||||
|
||||
// Guests use the online xuid, everyone else uses the offline one
|
||||
PlayerUID playerXuid = packet->m_offlineXuid;
|
||||
if(playerXuid == INVALID_XUID) playerXuid = packet->m_onlineXuid;
|
||||
// Guests use the online xuid, everyone else uses the offline one
|
||||
PlayerUID playerXuid = packet->m_offlineXuid;
|
||||
if (playerXuid == INVALID_XUID) playerXuid = packet->m_onlineXuid;
|
||||
|
||||
std::shared_ptr<ServerPlayer> playerEntity = server->getPlayers()->getPlayerForLogin(this, name, playerXuid,packet->m_onlineXuid);
|
||||
if (playerEntity != NULL)
|
||||
{
|
||||
std::shared_ptr<ServerPlayer> playerEntity =
|
||||
server->getPlayers()->getPlayerForLogin(this, name, playerXuid,
|
||||
packet->m_onlineXuid);
|
||||
if (playerEntity != NULL) {
|
||||
server->getPlayers()->placeNewPlayer(connection, playerEntity, packet);
|
||||
connection = NULL; // We've moved responsibility for this over to the new PlayerConnection, NULL so we don't delete our reference to it here in our dtor
|
||||
connection = NULL; // We've moved responsibility for this over to the
|
||||
// new PlayerConnection, NULL so we don't delete our
|
||||
// reference to it here in our dtor
|
||||
}
|
||||
done = true;
|
||||
|
||||
}
|
||||
|
||||
void PendingConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects)
|
||||
{
|
||||
// logger.info(getName() + " lost connection");
|
||||
void PendingConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason,
|
||||
void* reasonObjects) {
|
||||
// logger.info(getName() + " lost connection");
|
||||
done = true;
|
||||
}
|
||||
|
||||
void PendingConnection::handleGetInfo(std::shared_ptr<GetInfoPacket> packet)
|
||||
{
|
||||
//try {
|
||||
//String message = server->motd + "§" + server->players->getPlayerCount() + "§" + server->players->getMaxPlayers();
|
||||
//connection->send(new DisconnectPacket(message));
|
||||
connection->send(std::shared_ptr<DisconnectPacket>(new DisconnectPacket(DisconnectPacket::eDisconnect_ServerFull) ) );
|
||||
connection->sendAndQuit();
|
||||
server->connection->removeSpamProtection(connection->getSocket());
|
||||
done = true;
|
||||
//} catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
//}
|
||||
void PendingConnection::handleGetInfo(std::shared_ptr<GetInfoPacket> packet) {
|
||||
// try {
|
||||
// String message = server->motd + "§" + server->players->getPlayerCount() +
|
||||
// "§" + server->players->getMaxPlayers(); connection->send(new
|
||||
// DisconnectPacket(message));
|
||||
connection->send(std::shared_ptr<DisconnectPacket>(
|
||||
new DisconnectPacket(DisconnectPacket::eDisconnect_ServerFull)));
|
||||
connection->sendAndQuit();
|
||||
server->connection->removeSpamProtection(connection->getSocket());
|
||||
done = true;
|
||||
//} catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
//}
|
||||
}
|
||||
|
||||
void PendingConnection::handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet)
|
||||
{
|
||||
// Ignore
|
||||
void PendingConnection::handleKeepAlive(
|
||||
std::shared_ptr<KeepAlivePacket> packet) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
void PendingConnection::onUnhandledPacket(std::shared_ptr<Packet> packet)
|
||||
{
|
||||
disconnect(DisconnectPacket::eDisconnect_UnexpectedPacket);
|
||||
void PendingConnection::onUnhandledPacket(std::shared_ptr<Packet> packet) {
|
||||
disconnect(DisconnectPacket::eDisconnect_UnexpectedPacket);
|
||||
}
|
||||
|
||||
void PendingConnection::send(std::shared_ptr<Packet> packet)
|
||||
{
|
||||
connection->send(packet);
|
||||
void PendingConnection::send(std::shared_ptr<Packet> packet) {
|
||||
connection->send(packet);
|
||||
}
|
||||
|
||||
std::wstring PendingConnection::getName()
|
||||
{
|
||||
return L"Unimplemented";
|
||||
// if (name != null) return name + " [" + connection.getRemoteAddress().toString() + "]";
|
||||
// return connection.getRemoteAddress().toString();
|
||||
std::wstring PendingConnection::getName() {
|
||||
return L"Unimplemented";
|
||||
// if (name != null) return name + " [" +
|
||||
// connection.getRemoteAddress().toString() + "]"; return
|
||||
// connection.getRemoteAddress().toString();
|
||||
}
|
||||
|
||||
bool PendingConnection::isServerPacketListener()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool PendingConnection::isServerPacketListener() { return true; }
|
||||
|
|
|
|||
|
|
@ -6,43 +6,47 @@ class LoginPacket;
|
|||
class Connection;
|
||||
class Random;
|
||||
|
||||
|
||||
class PendingConnection : public PacketListener
|
||||
{
|
||||
class PendingConnection : public PacketListener {
|
||||
private:
|
||||
static const int FAKE_LAG = 0;
|
||||
static const int MAX_TICKS_BEFORE_LOGIN = 20 * 30 * 10; // 10 minutes instead of 20 sec for Linux theres just no login yet
|
||||
static const int FAKE_LAG = 0;
|
||||
static const int MAX_TICKS_BEFORE_LOGIN =
|
||||
20 * 30 *
|
||||
10; // 10 minutes instead of 20 sec for Linux theres just no login yet
|
||||
|
||||
// public static Logger logger = Logger.getLogger("Minecraft");
|
||||
static Random *random;
|
||||
// public static Logger logger = Logger.getLogger("Minecraft");
|
||||
static Random* random;
|
||||
|
||||
public:
|
||||
Connection *connection;
|
||||
Connection* connection;
|
||||
|
||||
public:
|
||||
bool done;
|
||||
bool done;
|
||||
|
||||
private:
|
||||
MinecraftServer *server;
|
||||
MinecraftServer* server;
|
||||
int _tick;
|
||||
std::wstring name;
|
||||
std::shared_ptr<LoginPacket> acceptedLogin;
|
||||
std::wstring loginKey;
|
||||
|
||||
public:
|
||||
PendingConnection(MinecraftServer *server, Socket *socket, const std::wstring& id);
|
||||
~PendingConnection();
|
||||
PendingConnection(MinecraftServer* server, Socket* socket,
|
||||
const std::wstring& id);
|
||||
~PendingConnection();
|
||||
void tick();
|
||||
void disconnect(DisconnectPacket::eDisconnectReason reason);
|
||||
virtual void handlePreLogin(std::shared_ptr<PreLoginPacket> packet);
|
||||
virtual void handleLogin(std::shared_ptr<LoginPacket> packet);
|
||||
virtual void handleAcceptedLogin(std::shared_ptr<LoginPacket> packet);
|
||||
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects);
|
||||
virtual void handleGetInfo(std::shared_ptr<GetInfoPacket> packet);
|
||||
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
|
||||
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason,
|
||||
void* reasonObjects);
|
||||
virtual void handleGetInfo(std::shared_ptr<GetInfoPacket> packet);
|
||||
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
|
||||
virtual void onUnhandledPacket(std::shared_ptr<Packet> packet);
|
||||
void send(std::shared_ptr<Packet> packet);
|
||||
std::wstring getName();
|
||||
virtual bool isServerPacketListener();
|
||||
|
||||
private:
|
||||
void sendPreLoginResponse();
|
||||
void sendPreLoginResponse();
|
||||
};
|
||||
|
|
@ -7,35 +7,34 @@ class MinecraftServer;
|
|||
class Packet;
|
||||
class TileEntity;
|
||||
|
||||
|
||||
class PlayerChunkMap
|
||||
{
|
||||
class PlayerChunkMap {
|
||||
public:
|
||||
#ifdef _LARGE_WORLDS
|
||||
static const int MAX_VIEW_DISTANCE = 30;
|
||||
static const int MAX_VIEW_DISTANCE = 30;
|
||||
#else
|
||||
static const int MAX_VIEW_DISTANCE = 15;
|
||||
static const int MAX_VIEW_DISTANCE = 15;
|
||||
#endif
|
||||
static const int MIN_VIEW_DISTANCE = 3;
|
||||
static const int MAX_CHANGES_BEFORE_RESEND = 10;
|
||||
static const int MIN_TICKS_BETWEEN_REGION_UPDATE = 10;
|
||||
static const int MIN_VIEW_DISTANCE = 3;
|
||||
static const int MAX_CHANGES_BEFORE_RESEND = 10;
|
||||
static const int MIN_TICKS_BETWEEN_REGION_UPDATE = 10;
|
||||
|
||||
// 4J - added
|
||||
class PlayerChunkAddRequest
|
||||
{
|
||||
public:
|
||||
int x,z;
|
||||
std::shared_ptr<ServerPlayer> player;
|
||||
PlayerChunkAddRequest(int x, int z, std::shared_ptr<ServerPlayer> player ) : x(x), z(z), player(player) {}
|
||||
};
|
||||
// 4J - added
|
||||
class PlayerChunkAddRequest {
|
||||
public:
|
||||
int x, z;
|
||||
std::shared_ptr<ServerPlayer> player;
|
||||
PlayerChunkAddRequest(int x, int z,
|
||||
std::shared_ptr<ServerPlayer> player)
|
||||
: x(x), z(z), player(player) {}
|
||||
};
|
||||
|
||||
class PlayerChunk
|
||||
{
|
||||
friend class PlayerChunkMap;
|
||||
private:
|
||||
PlayerChunkMap *parent; // 4J added
|
||||
std::vector<std::shared_ptr<ServerPlayer> > players;
|
||||
//int x, z;
|
||||
class PlayerChunk {
|
||||
friend class PlayerChunkMap;
|
||||
|
||||
private:
|
||||
PlayerChunkMap* parent; // 4J added
|
||||
std::vector<std::shared_ptr<ServerPlayer> > players;
|
||||
// int x, z;
|
||||
ChunkPos pos;
|
||||
|
||||
shortArray changedTiles;
|
||||
|
|
@ -43,63 +42,73 @@ public:
|
|||
int xChangeMin, xChangeMax;
|
||||
int yChangeMin, yChangeMax;
|
||||
int zChangeMin, zChangeMax;
|
||||
int ticksToNextRegionUpdate; // 4J added
|
||||
bool prioritised; // 4J added
|
||||
int ticksToNextRegionUpdate; // 4J added
|
||||
bool prioritised; // 4J added
|
||||
|
||||
public:
|
||||
PlayerChunk(int x, int z, PlayerChunkMap *pcm);
|
||||
~PlayerChunk();
|
||||
public:
|
||||
PlayerChunk(int x, int z, PlayerChunkMap* pcm);
|
||||
~PlayerChunk();
|
||||
|
||||
// 4J Added sendPacket param so we can aggregate the initial send into one much smaller packet
|
||||
// 4J Added sendPacket param so we can aggregate the initial send into
|
||||
// one much smaller packet
|
||||
void add(std::shared_ptr<ServerPlayer> player, bool sendPacket = true);
|
||||
void remove(std::shared_ptr<ServerPlayer> player);
|
||||
void tileChanged(int x, int y, int z);
|
||||
void prioritiseTileChanges(); // 4J added
|
||||
void prioritiseTileChanges(); // 4J added
|
||||
void broadcast(std::shared_ptr<Packet> packet);
|
||||
bool broadcastChanges(bool allowRegionUpdate); // 4J - added parm
|
||||
bool broadcastChanges(bool allowRegionUpdate); // 4J - added parm
|
||||
|
||||
private:
|
||||
void broadcast(std::shared_ptr<TileEntity> te);
|
||||
private:
|
||||
void broadcast(std::shared_ptr<TileEntity> te);
|
||||
};
|
||||
|
||||
public:
|
||||
std::vector<std::shared_ptr<ServerPlayer> > players;
|
||||
void flagEntitiesToBeRemoved(unsigned int *flags, bool *removedFound); // 4J added
|
||||
std::vector<std::shared_ptr<ServerPlayer> > players;
|
||||
void flagEntitiesToBeRemoved(unsigned int* flags,
|
||||
bool* removedFound); // 4J added
|
||||
private:
|
||||
std::unordered_map<__int64,PlayerChunk *,LongKeyHash,LongKeyEq> chunks; // 4J - was LongHashMap
|
||||
std::vector<PlayerChunk *> changedChunks;
|
||||
std::vector<PlayerChunkAddRequest> addRequests; // 4J added
|
||||
void tickAddRequests(std::shared_ptr<ServerPlayer> player); // 4J added
|
||||
std::unordered_map<__int64, PlayerChunk*, LongKeyHash, LongKeyEq>
|
||||
chunks; // 4J - was LongHashMap
|
||||
std::vector<PlayerChunk*> changedChunks;
|
||||
std::vector<PlayerChunkAddRequest> addRequests; // 4J added
|
||||
void tickAddRequests(std::shared_ptr<ServerPlayer> player); // 4J added
|
||||
|
||||
ServerLevel *level;
|
||||
ServerLevel* level;
|
||||
int radius;
|
||||
int dimension;
|
||||
int dimension;
|
||||
|
||||
public:
|
||||
PlayerChunkMap(ServerLevel *level, int dimension, int radius);
|
||||
~PlayerChunkMap();
|
||||
ServerLevel *getLevel();
|
||||
PlayerChunkMap(ServerLevel* level, int dimension, int radius);
|
||||
~PlayerChunkMap();
|
||||
ServerLevel* getLevel();
|
||||
void tick();
|
||||
bool hasChunk(int x, int z);
|
||||
bool hasChunk(int x, int z);
|
||||
|
||||
private:
|
||||
PlayerChunk *getChunk(int x, int z, bool create);
|
||||
void getChunkAndAddPlayer(int x, int z, std::shared_ptr<ServerPlayer> player); // 4J added
|
||||
void getChunkAndRemovePlayer(int x, int z, std::shared_ptr<ServerPlayer> player); // 4J added
|
||||
PlayerChunk* getChunk(int x, int z, bool create);
|
||||
void getChunkAndAddPlayer(
|
||||
int x, int z, std::shared_ptr<ServerPlayer> player); // 4J added
|
||||
void getChunkAndRemovePlayer(
|
||||
int x, int z, std::shared_ptr<ServerPlayer> player); // 4J added
|
||||
public:
|
||||
void broadcastTileUpdate(std::shared_ptr<Packet> packet, int x, int y, int z);
|
||||
void broadcastTileUpdate(std::shared_ptr<Packet> packet, int x, int y,
|
||||
int z);
|
||||
void tileChanged(int x, int y, int z);
|
||||
bool isTrackingTile(int x, int y, int z); // 4J added
|
||||
void prioritiseTileChanges(int x, int y, int z); // 4J added
|
||||
bool isTrackingTile(int x, int y, int z); // 4J added
|
||||
void prioritiseTileChanges(int x, int y, int z); // 4J added
|
||||
void add(std::shared_ptr<ServerPlayer> player);
|
||||
void remove(std::shared_ptr<ServerPlayer> player);
|
||||
private:
|
||||
bool chunkInRange(int x, int z, int xc, int zc);
|
||||
public:
|
||||
void move(std::shared_ptr<ServerPlayer> player);
|
||||
int getMaxRange();
|
||||
bool isPlayerIn(std::shared_ptr<ServerPlayer> player, int xChunk, int zChunk);
|
||||
static int convertChunkRangeToBlock(int radius);
|
||||
|
||||
// AP added for Vita
|
||||
void setRadius(int newRadius);
|
||||
private:
|
||||
bool chunkInRange(int x, int z, int xc, int zc);
|
||||
|
||||
public:
|
||||
void move(std::shared_ptr<ServerPlayer> player);
|
||||
int getMaxRange();
|
||||
bool isPlayerIn(std::shared_ptr<ServerPlayer> player, int xChunk,
|
||||
int zChunk);
|
||||
static int convertChunkRangeToBlock(int radius);
|
||||
|
||||
// AP added for Vita
|
||||
void setRadius(int newRadius);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,132 +8,152 @@ class Connection;
|
|||
class ServerPlayer;
|
||||
class INetworkPlayer;
|
||||
|
||||
|
||||
|
||||
class PlayerConnection : public PacketListener, public ConsoleInputSource
|
||||
{
|
||||
// public static Logger logger = Logger.getLogger("Minecraft");
|
||||
class PlayerConnection : public PacketListener, public ConsoleInputSource {
|
||||
// public static Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
public:
|
||||
Connection *connection;
|
||||
Connection* connection;
|
||||
bool done;
|
||||
CRITICAL_SECTION done_cs;
|
||||
CRITICAL_SECTION done_cs;
|
||||
|
||||
// 4J Stu - Added this so that we can manage UGC privileges
|
||||
PlayerUID m_offlineXUID, m_onlineXUID;
|
||||
bool m_friendsOnlyUGC;
|
||||
// 4J Stu - Added this so that we can manage UGC privileges
|
||||
PlayerUID m_offlineXUID, m_onlineXUID;
|
||||
bool m_friendsOnlyUGC;
|
||||
|
||||
private:
|
||||
MinecraftServer *server;
|
||||
MinecraftServer* server;
|
||||
std::shared_ptr<ServerPlayer> player;
|
||||
int tickCount;
|
||||
int aboveGroundTickCount;
|
||||
|
||||
bool didTick;
|
||||
int lastKeepAliveId;
|
||||
__int64 lastKeepAliveTime;
|
||||
static Random random;
|
||||
__int64 lastKeepAliveTick;
|
||||
int chatSpamTickCount;
|
||||
int dropSpamTickCount;
|
||||
int lastKeepAliveId;
|
||||
__int64 lastKeepAliveTime;
|
||||
static Random random;
|
||||
__int64 lastKeepAliveTick;
|
||||
int chatSpamTickCount;
|
||||
int dropSpamTickCount;
|
||||
|
||||
bool m_bHasClientTickedOnce;
|
||||
bool m_bHasClientTickedOnce;
|
||||
|
||||
public:
|
||||
PlayerConnection(MinecraftServer *server, Connection *connection, std::shared_ptr<ServerPlayer> player);
|
||||
~PlayerConnection();
|
||||
PlayerConnection(MinecraftServer* server, Connection* connection,
|
||||
std::shared_ptr<ServerPlayer> player);
|
||||
~PlayerConnection();
|
||||
void tick();
|
||||
void disconnect(DisconnectPacket::eDisconnectReason reason);
|
||||
|
||||
private:
|
||||
double xLastOk, yLastOk, zLastOk;
|
||||
double xLastOk, yLastOk, zLastOk;
|
||||
bool synched;
|
||||
|
||||
public:
|
||||
virtual void handlePlayerInput(std::shared_ptr<PlayerInputPacket> packet);
|
||||
virtual void handlePlayerInput(std::shared_ptr<PlayerInputPacket> packet);
|
||||
virtual void handleMovePlayer(std::shared_ptr<MovePlayerPacket> packet);
|
||||
void teleport(double x, double y, double z, float yRot, float xRot, bool sendPacket = true); // 4J Added sendPacket param
|
||||
void teleport(double x, double y, double z, float yRot, float xRot,
|
||||
bool sendPacket = true); // 4J Added sendPacket param
|
||||
virtual void handlePlayerAction(std::shared_ptr<PlayerActionPacket> packet);
|
||||
virtual void handleUseItem(std::shared_ptr<UseItemPacket> packet);
|
||||
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects);
|
||||
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason,
|
||||
void* reasonObjects);
|
||||
virtual void onUnhandledPacket(std::shared_ptr<Packet> packet);
|
||||
void send(std::shared_ptr<Packet> packet);
|
||||
void queueSend(std::shared_ptr<Packet> packet); // 4J Added
|
||||
virtual void handleSetCarriedItem(std::shared_ptr<SetCarriedItemPacket> packet);
|
||||
void queueSend(std::shared_ptr<Packet> packet); // 4J Added
|
||||
virtual void handleSetCarriedItem(
|
||||
std::shared_ptr<SetCarriedItemPacket> packet);
|
||||
virtual void handleChat(std::shared_ptr<ChatPacket> packet);
|
||||
|
||||
private:
|
||||
void handleCommand(const std::wstring& message);
|
||||
void handleCommand(const std::wstring& message);
|
||||
|
||||
public:
|
||||
virtual void handleAnimate(std::shared_ptr<AnimatePacket> packet);
|
||||
virtual void handlePlayerCommand(std::shared_ptr<PlayerCommandPacket> packet);
|
||||
virtual void handleAnimate(std::shared_ptr<AnimatePacket> packet);
|
||||
virtual void handlePlayerCommand(
|
||||
std::shared_ptr<PlayerCommandPacket> packet);
|
||||
virtual void handleDisconnect(std::shared_ptr<DisconnectPacket> packet);
|
||||
int countDelayedPackets();
|
||||
virtual void info(const std::wstring& string);
|
||||
virtual void warn(const std::wstring& string);
|
||||
virtual std::wstring getConsoleName();
|
||||
virtual void handleInteract(std::shared_ptr<InteractPacket> packet);
|
||||
bool canHandleAsyncPackets();
|
||||
virtual void handleClientCommand(std::shared_ptr<ClientCommandPacket> packet);
|
||||
bool canHandleAsyncPackets();
|
||||
virtual void handleClientCommand(
|
||||
std::shared_ptr<ClientCommandPacket> packet);
|
||||
virtual void handleRespawn(std::shared_ptr<RespawnPacket> packet);
|
||||
virtual void handleContainerClose(std::shared_ptr<ContainerClosePacket> packet);
|
||||
virtual void handleContainerClose(
|
||||
std::shared_ptr<ContainerClosePacket> packet);
|
||||
|
||||
private:
|
||||
std::unordered_map<int, short, IntKeyHash, IntKeyEq> expectedAcks;
|
||||
std::unordered_map<int, short, IntKeyHash, IntKeyEq> expectedAcks;
|
||||
|
||||
public:
|
||||
// 4J Stu - Handlers only valid in debug mode
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
virtual void handleContainerSetSlot(std::shared_ptr<ContainerSetSlotPacket> packet);
|
||||
// 4J Stu - Handlers only valid in debug mode
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
virtual void handleContainerSetSlot(
|
||||
std::shared_ptr<ContainerSetSlotPacket> packet);
|
||||
#endif
|
||||
virtual void handleContainerClick(std::shared_ptr<ContainerClickPacket> packet);
|
||||
virtual void handleContainerButtonClick(std::shared_ptr<ContainerButtonClickPacket> packet);
|
||||
virtual void handleSetCreativeModeSlot(std::shared_ptr<SetCreativeModeSlotPacket> packet);
|
||||
virtual void handleContainerClick(
|
||||
std::shared_ptr<ContainerClickPacket> packet);
|
||||
virtual void handleContainerButtonClick(
|
||||
std::shared_ptr<ContainerButtonClickPacket> packet);
|
||||
virtual void handleSetCreativeModeSlot(
|
||||
std::shared_ptr<SetCreativeModeSlotPacket> packet);
|
||||
virtual void handleContainerAck(std::shared_ptr<ContainerAckPacket> packet);
|
||||
virtual void handleSignUpdate(std::shared_ptr<SignUpdatePacket> packet);
|
||||
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
|
||||
virtual void handlePlayerInfo(std::shared_ptr<PlayerInfoPacket> packet); // 4J Added
|
||||
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
|
||||
virtual void handlePlayerInfo(
|
||||
std::shared_ptr<PlayerInfoPacket> packet); // 4J Added
|
||||
virtual bool isServerPacketListener();
|
||||
virtual void handlePlayerAbilities(std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
|
||||
virtual void handleCustomPayload(std::shared_ptr<CustomPayloadPacket> customPayloadPacket);
|
||||
virtual void handlePlayerAbilities(
|
||||
std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
|
||||
virtual void handleCustomPayload(
|
||||
std::shared_ptr<CustomPayloadPacket> customPayloadPacket);
|
||||
|
||||
// 4J Added
|
||||
virtual void handleCraftItem(std::shared_ptr<CraftItemPacket> packet);
|
||||
virtual void handleTradeItem(std::shared_ptr<TradeItemPacket> packet);
|
||||
virtual void handleDebugOptions(std::shared_ptr<DebugOptionsPacket> packet);
|
||||
virtual void handleTexture(std::shared_ptr<TexturePacket> packet);
|
||||
virtual void handleTextureAndGeometry(std::shared_ptr<TextureAndGeometryPacket> packet);
|
||||
virtual void handleTextureChange(std::shared_ptr<TextureChangePacket> packet);
|
||||
virtual void handleTextureAndGeometryChange(std::shared_ptr<TextureAndGeometryChangePacket> packet);
|
||||
virtual void handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet);
|
||||
virtual void handleKickPlayer(std::shared_ptr<KickPlayerPacket> packet);
|
||||
virtual void handleGameCommand(std::shared_ptr<GameCommandPacket> packet);
|
||||
// 4J Added
|
||||
virtual void handleCraftItem(std::shared_ptr<CraftItemPacket> packet);
|
||||
virtual void handleTradeItem(std::shared_ptr<TradeItemPacket> packet);
|
||||
virtual void handleDebugOptions(std::shared_ptr<DebugOptionsPacket> packet);
|
||||
virtual void handleTexture(std::shared_ptr<TexturePacket> packet);
|
||||
virtual void handleTextureAndGeometry(
|
||||
std::shared_ptr<TextureAndGeometryPacket> packet);
|
||||
virtual void handleTextureChange(
|
||||
std::shared_ptr<TextureChangePacket> packet);
|
||||
virtual void handleTextureAndGeometryChange(
|
||||
std::shared_ptr<TextureAndGeometryChangePacket> packet);
|
||||
virtual void handleServerSettingsChanged(
|
||||
std::shared_ptr<ServerSettingsChangedPacket> packet);
|
||||
virtual void handleKickPlayer(std::shared_ptr<KickPlayerPacket> packet);
|
||||
virtual void handleGameCommand(std::shared_ptr<GameCommandPacket> packet);
|
||||
|
||||
INetworkPlayer *getNetworkPlayer();
|
||||
bool isLocal();
|
||||
bool isGuest();
|
||||
INetworkPlayer* getNetworkPlayer();
|
||||
bool isLocal();
|
||||
bool isGuest();
|
||||
|
||||
// 4J Added as we need to set this from outside sometimes
|
||||
void setPlayer(std::shared_ptr<ServerPlayer> player) { this->player = player; }
|
||||
std::shared_ptr<ServerPlayer> getPlayer() { return player; }
|
||||
// 4J Added as we need to set this from outside sometimes
|
||||
void setPlayer(std::shared_ptr<ServerPlayer> player) {
|
||||
this->player = player;
|
||||
}
|
||||
std::shared_ptr<ServerPlayer> getPlayer() { return player; }
|
||||
|
||||
// 4J Added to signal a disconnect from another thread
|
||||
void closeOnTick() { m_bCloseOnTick = true; }
|
||||
// 4J Added to signal a disconnect from another thread
|
||||
void closeOnTick() { m_bCloseOnTick = true; }
|
||||
|
||||
// 4J Added so that we can send on textures that get received after this connection requested them
|
||||
void handleTextureReceived(const std::wstring &textureName);
|
||||
void handleTextureAndGeometryReceived(const std::wstring &textureName);
|
||||
// 4J Added so that we can send on textures that get received after this
|
||||
// connection requested them
|
||||
void handleTextureReceived(const std::wstring& textureName);
|
||||
void handleTextureAndGeometryReceived(const std::wstring& textureName);
|
||||
|
||||
void setShowOnMaps(bool bVal);
|
||||
void setShowOnMaps(bool bVal);
|
||||
|
||||
void setWasKicked() { m_bWasKicked = true; }
|
||||
bool getWasKicked() { return m_bWasKicked; }
|
||||
void setWasKicked() { m_bWasKicked = true; }
|
||||
bool getWasKicked() { return m_bWasKicked; }
|
||||
|
||||
// 4J Added
|
||||
bool hasClientTickedOnce() { return m_bHasClientTickedOnce; }
|
||||
// 4J Added
|
||||
bool hasClientTickedOnce() { return m_bHasClientTickedOnce; }
|
||||
|
||||
private:
|
||||
bool m_bCloseOnTick;
|
||||
std::vector<std::wstring> m_texturesRequested;
|
||||
bool m_bCloseOnTick;
|
||||
std::vector<std::wstring> m_texturesRequested;
|
||||
|
||||
bool m_bWasKicked;
|
||||
bool m_bWasKicked;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
class PlayerInfo
|
||||
{
|
||||
class PlayerInfo {
|
||||
public:
|
||||
std::wstring name;
|
||||
int latency;
|
||||
std::wstring name;
|
||||
int latency;
|
||||
|
||||
PlayerInfo(const std::wstring &name)
|
||||
{
|
||||
this->name = name;
|
||||
latency = 0;
|
||||
}
|
||||
PlayerInfo(const std::wstring& name) {
|
||||
this->name = name;
|
||||
latency = 0;
|
||||
}
|
||||
};
|
||||
|
|
@ -15,114 +15,136 @@ class ProgressListener;
|
|||
class GameType;
|
||||
class LoginPacket;
|
||||
|
||||
|
||||
|
||||
class PlayerList
|
||||
{
|
||||
class PlayerList {
|
||||
private:
|
||||
static const int SEND_PLAYER_INFO_INTERVAL = 20 * 10; // 4J - brought forward from 1.2.3
|
||||
// public static Logger logger = Logger.getLogger("Minecraft");
|
||||
static const int SEND_PLAYER_INFO_INTERVAL =
|
||||
20 * 10; // 4J - brought forward from 1.2.3
|
||||
// public static Logger logger = Logger.getLogger("Minecraft");
|
||||
public:
|
||||
std::vector<std::shared_ptr<ServerPlayer> > players;
|
||||
std::vector<std::shared_ptr<ServerPlayer> > players;
|
||||
|
||||
private:
|
||||
MinecraftServer *server;
|
||||
MinecraftServer* server;
|
||||
unsigned int maxPlayers;
|
||||
|
||||
// 4J Added
|
||||
std::vector<PlayerUID> m_bannedXuids;
|
||||
std::deque<std::uint8_t> m_smallIdsToKick;
|
||||
CRITICAL_SECTION m_kickPlayersCS;
|
||||
std::deque<std::uint8_t> m_smallIdsToClose;
|
||||
CRITICAL_SECTION m_closePlayersCS;
|
||||
/* 4J - removed
|
||||
Set<String> bans = new HashSet<String>();
|
||||
Set<String> ipBans = new HashSet<String>();
|
||||
Set<String> ops = new HashSet<String>();
|
||||
Set<String> whitelist = new HashSet<String>();
|
||||
File banFile, ipBanFile, opFile, whiteListFile;
|
||||
*/
|
||||
PlayerIO *playerIo;
|
||||
// 4J Added
|
||||
std::vector<PlayerUID> m_bannedXuids;
|
||||
std::deque<std::uint8_t> m_smallIdsToKick;
|
||||
CRITICAL_SECTION m_kickPlayersCS;
|
||||
std::deque<std::uint8_t> m_smallIdsToClose;
|
||||
CRITICAL_SECTION m_closePlayersCS;
|
||||
/* 4J - removed
|
||||
Set<String> bans = new HashSet<String>();
|
||||
Set<String> ipBans = new HashSet<String>();
|
||||
Set<String> ops = new HashSet<String>();
|
||||
Set<String> whitelist = new HashSet<String>();
|
||||
File banFile, ipBanFile, opFile, whiteListFile;
|
||||
*/
|
||||
PlayerIO* playerIo;
|
||||
bool doWhiteList;
|
||||
|
||||
GameType *overrideGameMode;
|
||||
bool allowCheatsForAllPlayers;
|
||||
int viewDistance;
|
||||
GameType* overrideGameMode;
|
||||
bool allowCheatsForAllPlayers;
|
||||
int viewDistance;
|
||||
|
||||
int sendAllPlayerInfoIn;
|
||||
int sendAllPlayerInfoIn;
|
||||
|
||||
// 4J Added to maintain which players in which dimensions can receive all
|
||||
// packet types
|
||||
std::vector<std::shared_ptr<ServerPlayer> > receiveAllPlayers[3];
|
||||
|
||||
// 4J Added to maintain which players in which dimensions can receive all packet types
|
||||
std::vector<std::shared_ptr<ServerPlayer> > receiveAllPlayers[3];
|
||||
private:
|
||||
std::shared_ptr<ServerPlayer> findAlivePlayerOnSystem(std::shared_ptr<ServerPlayer> currentPlayer);
|
||||
std::shared_ptr<ServerPlayer> findAlivePlayerOnSystem(
|
||||
std::shared_ptr<ServerPlayer> currentPlayer);
|
||||
|
||||
public:
|
||||
void removePlayerFromReceiving(std::shared_ptr<ServerPlayer> player, bool usePlayerDimension = true, int dimension = 0);
|
||||
void addPlayerToReceiving(std::shared_ptr<ServerPlayer> player);
|
||||
bool canReceiveAllPackets(std::shared_ptr<ServerPlayer> player);
|
||||
void removePlayerFromReceiving(std::shared_ptr<ServerPlayer> player,
|
||||
bool usePlayerDimension = true,
|
||||
int dimension = 0);
|
||||
void addPlayerToReceiving(std::shared_ptr<ServerPlayer> player);
|
||||
bool canReceiveAllPackets(std::shared_ptr<ServerPlayer> player);
|
||||
|
||||
public:
|
||||
PlayerList(MinecraftServer *server);
|
||||
~PlayerList();
|
||||
void placeNewPlayer(Connection *connection, std::shared_ptr<ServerPlayer> player, std::shared_ptr<LoginPacket> packet);
|
||||
PlayerList(MinecraftServer* server);
|
||||
~PlayerList();
|
||||
void placeNewPlayer(Connection* connection,
|
||||
std::shared_ptr<ServerPlayer> player,
|
||||
std::shared_ptr<LoginPacket> packet);
|
||||
void setLevel(ServerLevelArray levels);
|
||||
void changeDimension(std::shared_ptr<ServerPlayer> player, ServerLevel *from);
|
||||
void changeDimension(std::shared_ptr<ServerPlayer> player,
|
||||
ServerLevel* from);
|
||||
int getMaxRange();
|
||||
bool load(std::shared_ptr<ServerPlayer> player); // 4J Changed return val to bool to check if new player or loaded player
|
||||
bool load(std::shared_ptr<ServerPlayer>
|
||||
player); // 4J Changed return val to bool to check if new
|
||||
// player or loaded player
|
||||
protected:
|
||||
void save(std::shared_ptr<ServerPlayer> player);
|
||||
void save(std::shared_ptr<ServerPlayer> player);
|
||||
|
||||
public:
|
||||
void validatePlayerSpawnPosition(std::shared_ptr<ServerPlayer> player); // 4J Added
|
||||
void validatePlayerSpawnPosition(
|
||||
std::shared_ptr<ServerPlayer> player); // 4J Added
|
||||
void add(std::shared_ptr<ServerPlayer> player);
|
||||
void move(std::shared_ptr<ServerPlayer> player);
|
||||
void remove(std::shared_ptr<ServerPlayer> player);
|
||||
std::shared_ptr<ServerPlayer> getPlayerForLogin(PendingConnection *pendingConnection, const std::wstring& userName, PlayerUID xuid, PlayerUID OnlineXuid);
|
||||
std::shared_ptr<ServerPlayer> respawn(std::shared_ptr<ServerPlayer> serverPlayer, int targetDimension, bool keepAllPlayerData);
|
||||
void toggleDimension(std::shared_ptr<ServerPlayer> player, int targetDimension);
|
||||
std::shared_ptr<ServerPlayer> getPlayerForLogin(
|
||||
PendingConnection* pendingConnection, const std::wstring& userName,
|
||||
PlayerUID xuid, PlayerUID OnlineXuid);
|
||||
std::shared_ptr<ServerPlayer> respawn(
|
||||
std::shared_ptr<ServerPlayer> serverPlayer, int targetDimension,
|
||||
bool keepAllPlayerData);
|
||||
void toggleDimension(std::shared_ptr<ServerPlayer> player,
|
||||
int targetDimension);
|
||||
void tick();
|
||||
bool isTrackingTile(int x, int y, int z, int dimension); // 4J added
|
||||
void prioritiseTileChanges(int x, int y, int z, int dimension); // 4J added
|
||||
bool isTrackingTile(int x, int y, int z, int dimension); // 4J added
|
||||
void prioritiseTileChanges(int x, int y, int z, int dimension); // 4J added
|
||||
void broadcastAll(std::shared_ptr<Packet> packet);
|
||||
void broadcastAll(std::shared_ptr<Packet> packet, int dimension);
|
||||
|
||||
std::wstring getPlayerNames();
|
||||
|
||||
public:
|
||||
bool isWhiteListed(const std::wstring& name);
|
||||
bool isWhiteListed(const std::wstring& name);
|
||||
bool isOp(const std::wstring& name);
|
||||
bool isOp(std::shared_ptr<ServerPlayer> player); // 4J Added
|
||||
bool isOp(std::shared_ptr<ServerPlayer> player); // 4J Added
|
||||
std::shared_ptr<ServerPlayer> getPlayer(const std::wstring& name);
|
||||
std::shared_ptr<ServerPlayer> getPlayer(PlayerUID uid);
|
||||
std::shared_ptr<ServerPlayer> getPlayer(PlayerUID uid);
|
||||
void sendMessage(const std::wstring& name, const std::wstring& message);
|
||||
void broadcast(double x, double y, double z, double range, int dimension, std::shared_ptr<Packet> packet);
|
||||
void broadcast(std::shared_ptr<Player> except, double x, double y, double z, double range, int dimension, std::shared_ptr<Packet> packet);
|
||||
void broadcast(double x, double y, double z, double range, int dimension,
|
||||
std::shared_ptr<Packet> packet);
|
||||
void broadcast(std::shared_ptr<Player> except, double x, double y, double z,
|
||||
double range, int dimension, std::shared_ptr<Packet> packet);
|
||||
void broadcastToAllOps(const std::wstring& message);
|
||||
bool sendTo(const std::wstring& name, std::shared_ptr<Packet> packet);
|
||||
// 4J Added ProgressListener *progressListener param and bDeleteGuestMaps param
|
||||
void saveAll(ProgressListener *progressListener, bool bDeleteGuestMaps = false);
|
||||
// 4J Added ProgressListener *progressListener param and bDeleteGuestMaps
|
||||
// param
|
||||
void saveAll(ProgressListener* progressListener,
|
||||
bool bDeleteGuestMaps = false);
|
||||
void whiteList(const std::wstring& playerName);
|
||||
void blackList(const std::wstring& playerName);
|
||||
// Set<String> getWhiteList(); / 4J removed
|
||||
// Set<String> getWhiteList(); / 4J removed
|
||||
void reloadWhitelist();
|
||||
void sendLevelInfo(std::shared_ptr<ServerPlayer> player, ServerLevel *level);
|
||||
void sendLevelInfo(std::shared_ptr<ServerPlayer> player,
|
||||
ServerLevel* level);
|
||||
void sendAllPlayerInfo(std::shared_ptr<ServerPlayer> player);
|
||||
int getPlayerCount();
|
||||
int getPlayerCount(ServerLevel *level); // 4J Added
|
||||
int getMaxPlayers();
|
||||
MinecraftServer *getServer();
|
||||
int getViewDistance();
|
||||
void setOverrideGameMode(GameType *gameMode);
|
||||
int getPlayerCount();
|
||||
int getPlayerCount(ServerLevel* level); // 4J Added
|
||||
int getMaxPlayers();
|
||||
MinecraftServer* getServer();
|
||||
int getViewDistance();
|
||||
void setOverrideGameMode(GameType* gameMode);
|
||||
|
||||
private:
|
||||
void updatePlayerGameMode(std::shared_ptr<ServerPlayer> newPlayer, std::shared_ptr<ServerPlayer> oldPlayer, Level *level);
|
||||
void updatePlayerGameMode(std::shared_ptr<ServerPlayer> newPlayer,
|
||||
std::shared_ptr<ServerPlayer> oldPlayer,
|
||||
Level* level);
|
||||
|
||||
public:
|
||||
void setAllowCheatsForAllPlayers(bool allowCommands);
|
||||
void setAllowCheatsForAllPlayers(bool allowCommands);
|
||||
|
||||
// 4J Added
|
||||
void kickPlayerByShortId(std::uint8_t networkSmallId);
|
||||
void closePlayerConnectionBySmallId(std::uint8_t networkSmallId);
|
||||
bool isXuidBanned(PlayerUID xuid);
|
||||
// AP added for Vita so the range can be increased once the level starts
|
||||
void setViewDistance(int newViewDistance);
|
||||
// 4J Added
|
||||
void kickPlayerByShortId(std::uint8_t networkSmallId);
|
||||
void closePlayerConnectionBySmallId(std::uint8_t networkSmallId);
|
||||
bool isXuidBanned(PlayerUID xuid);
|
||||
// AP added for Vita so the range can be increased once the level starts
|
||||
void setViewDistance(int newViewDistance);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,94 +8,99 @@
|
|||
|
||||
class ServerLevel;
|
||||
|
||||
class ServerChunkCache : public ChunkSource
|
||||
{
|
||||
class ServerChunkCache : public ChunkSource {
|
||||
private:
|
||||
// std::unordered_set<int,IntKeyHash, IntKeyEq> toDrop;
|
||||
private:
|
||||
LevelChunk* emptyChunk;
|
||||
ChunkSource* source;
|
||||
ChunkStorage* storage;
|
||||
|
||||
public:
|
||||
bool autoCreate;
|
||||
|
||||
private:
|
||||
// std::unordered_set<int,IntKeyHash, IntKeyEq> toDrop;
|
||||
private:
|
||||
LevelChunk *emptyChunk;
|
||||
ChunkSource *source;
|
||||
ChunkStorage *storage;
|
||||
public:
|
||||
bool autoCreate;
|
||||
private:
|
||||
LevelChunk **cache;
|
||||
std::vector<LevelChunk *> m_loadedChunkList;
|
||||
ServerLevel *level;
|
||||
LevelChunk** cache;
|
||||
std::vector<LevelChunk*> m_loadedChunkList;
|
||||
ServerLevel* level;
|
||||
|
||||
#ifdef _LARGE_WORLDS
|
||||
std::deque<LevelChunk *> m_toDrop;
|
||||
LevelChunk **m_unloadedCache;
|
||||
std::deque<LevelChunk*> m_toDrop;
|
||||
LevelChunk** m_unloadedCache;
|
||||
#endif
|
||||
|
||||
// 4J - added for multithreaded support
|
||||
CRITICAL_SECTION m_csLoadCreate;
|
||||
// 4J - size of cache is defined by size of one side - must be even
|
||||
int XZSIZE;
|
||||
int XZOFFSET;
|
||||
// 4J - added for multithreaded support
|
||||
CRITICAL_SECTION m_csLoadCreate;
|
||||
// 4J - size of cache is defined by size of one side - must be even
|
||||
int XZSIZE;
|
||||
int XZOFFSET;
|
||||
|
||||
public:
|
||||
ServerChunkCache(ServerLevel *level, ChunkStorage *storage, ChunkSource *source);
|
||||
virtual ~ServerChunkCache();
|
||||
ServerChunkCache(ServerLevel* level, ChunkStorage* storage,
|
||||
ChunkSource* source);
|
||||
virtual ~ServerChunkCache();
|
||||
virtual bool hasChunk(int x, int z);
|
||||
std::vector<LevelChunk *> *getLoadedChunkList();
|
||||
std::vector<LevelChunk*>* getLoadedChunkList();
|
||||
void drop(int x, int z);
|
||||
void dropAll();
|
||||
virtual LevelChunk *create(int x, int z);
|
||||
LevelChunk *create(int x, int z, bool asyncPostProcess ); // 4J added
|
||||
virtual LevelChunk *getChunk(int x, int z);
|
||||
#ifdef _LARGE_WORLDS
|
||||
LevelChunk *getChunkLoadedOrUnloaded(int x, int z); // 4J added
|
||||
void dropAll();
|
||||
virtual LevelChunk* create(int x, int z);
|
||||
LevelChunk* create(int x, int z, bool asyncPostProcess); // 4J added
|
||||
virtual LevelChunk* getChunk(int x, int z);
|
||||
#ifdef _LARGE_WORLDS
|
||||
LevelChunk* getChunkLoadedOrUnloaded(int x, int z); // 4J added
|
||||
#endif
|
||||
virtual LevelChunk **getCache() { return cache; } // 4J added
|
||||
virtual LevelChunk** getCache() { return cache; } // 4J added
|
||||
|
||||
// 4J-JEV Added; Remove chunk from the toDrop queue.
|
||||
#ifdef _LARGE_WORLDS
|
||||
void dontDrop(int x, int z);
|
||||
// 4J-JEV Added; Remove chunk from the toDrop queue.
|
||||
#ifdef _LARGE_WORLDS
|
||||
void dontDrop(int x, int z);
|
||||
#endif
|
||||
|
||||
private:
|
||||
LevelChunk *load(int x, int z);
|
||||
void saveEntities(LevelChunk *levelChunk);
|
||||
void save(LevelChunk *levelChunk);
|
||||
LevelChunk* load(int x, int z);
|
||||
void saveEntities(LevelChunk* levelChunk);
|
||||
void save(LevelChunk* levelChunk);
|
||||
|
||||
void updatePostProcessFlag(short flag, int x, int z, int xo, int zo, LevelChunk *lc); // 4J added
|
||||
void updatePostProcessFlags(int x, int z); // 4J added
|
||||
void flagPostProcessComplete(short flag, int x, int z); // 4J added
|
||||
void updatePostProcessFlag(short flag, int x, int z, int xo, int zo,
|
||||
LevelChunk* lc); // 4J added
|
||||
void updatePostProcessFlags(int x, int z); // 4J added
|
||||
void flagPostProcessComplete(short flag, int x, int z); // 4J added
|
||||
public:
|
||||
virtual void postProcess(ChunkSource *parent, int x, int z);
|
||||
|
||||
virtual void postProcess(ChunkSource* parent, int x, int z);
|
||||
|
||||
private:
|
||||
#ifdef _LARGE_WORLDS
|
||||
static const int MAX_SAVES = 20;
|
||||
static const int MAX_SAVES = 20;
|
||||
#else
|
||||
// 4J Stu - Was 24, but lowering it drastically so that we can trickle save chunks
|
||||
static const int MAX_SAVES = 1;
|
||||
// 4J Stu - Was 24, but lowering it drastically so that we can trickle save
|
||||
// chunks
|
||||
static const int MAX_SAVES = 1;
|
||||
#endif
|
||||
|
||||
public:
|
||||
virtual bool saveAllEntities();
|
||||
virtual bool save(bool force, ProgressListener *progressListener);
|
||||
virtual bool saveAllEntities();
|
||||
virtual bool save(bool force, ProgressListener* progressListener);
|
||||
virtual bool tick();
|
||||
virtual bool shouldSave();
|
||||
virtual std::wstring gatherStats();
|
||||
|
||||
virtual std::vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, int x, int y, int z);
|
||||
virtual TilePos *findNearestMapFeature(Level *level, const std::wstring &featureName, int x, int y, int z);
|
||||
virtual std::vector<Biome::MobSpawnerData*>* getMobsAt(
|
||||
MobCategory* mobCategory, int x, int y, int z);
|
||||
virtual TilePos* findNearestMapFeature(Level* level,
|
||||
const std::wstring& featureName,
|
||||
int x, int y, int z);
|
||||
|
||||
private:
|
||||
typedef struct _SaveThreadData
|
||||
{
|
||||
ServerChunkCache *cache;
|
||||
LevelChunk *chunkToSave;
|
||||
bool saveEntities;
|
||||
bool useSharedThreadStorage;
|
||||
C4JThread::Event *notificationEvent;
|
||||
C4JThread::Event *wakeEvent; // This is a handle to the one fired by the producer thread
|
||||
} SaveThreadData;
|
||||
typedef struct _SaveThreadData {
|
||||
ServerChunkCache* cache;
|
||||
LevelChunk* chunkToSave;
|
||||
bool saveEntities;
|
||||
bool useSharedThreadStorage;
|
||||
C4JThread::Event* notificationEvent;
|
||||
C4JThread::Event* wakeEvent; // This is a handle to the one fired by
|
||||
// the producer thread
|
||||
} SaveThreadData;
|
||||
|
||||
public:
|
||||
static int runSaveThreadProc(void *lpParam);
|
||||
static int runSaveThreadProc(void* lpParam);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,69 +7,72 @@
|
|||
#include "../Commands/TeleportCommand.h"
|
||||
#include "ServerCommandDispatcher.h"
|
||||
|
||||
ServerCommandDispatcher::ServerCommandDispatcher()
|
||||
{
|
||||
addCommand(new TimeCommand());
|
||||
addCommand(new GameModeCommand());
|
||||
addCommand(new DefaultGameModeCommand());
|
||||
addCommand(new KillCommand());
|
||||
addCommand(new ToggleDownfallCommand());
|
||||
addCommand(new ExperienceCommand());
|
||||
addCommand(new TeleportCommand());
|
||||
addCommand(new GiveItemCommand());
|
||||
addCommand(new EnchantItemCommand());
|
||||
//addCommand(new EmoteCommand());
|
||||
//addCommand(new ShowSeedCommand());
|
||||
//addCommand(new HelpCommand());
|
||||
//addCommand(new DebugCommand());
|
||||
//addCommand(new MessageCommand());
|
||||
ServerCommandDispatcher::ServerCommandDispatcher() {
|
||||
addCommand(new TimeCommand());
|
||||
addCommand(new GameModeCommand());
|
||||
addCommand(new DefaultGameModeCommand());
|
||||
addCommand(new KillCommand());
|
||||
addCommand(new ToggleDownfallCommand());
|
||||
addCommand(new ExperienceCommand());
|
||||
addCommand(new TeleportCommand());
|
||||
addCommand(new GiveItemCommand());
|
||||
addCommand(new EnchantItemCommand());
|
||||
// addCommand(new EmoteCommand());
|
||||
// addCommand(new ShowSeedCommand());
|
||||
// addCommand(new HelpCommand());
|
||||
// addCommand(new DebugCommand());
|
||||
// addCommand(new MessageCommand());
|
||||
|
||||
//if (MinecraftServer::getInstance()->isDedicatedServer())
|
||||
//{
|
||||
// addCommand(new OpCommand());
|
||||
// addCommand(new DeOpCommand());
|
||||
// addCommand(new StopCommand());
|
||||
// addCommand(new SaveAllCommand());
|
||||
// addCommand(new SaveOffCommand());
|
||||
// addCommand(new SaveOnCommand());
|
||||
// addCommand(new BanIpCommand());
|
||||
// addCommand(new PardonIpCommand());
|
||||
// addCommand(new BanPlayerCommand());
|
||||
// addCommand(new ListBansCommand());
|
||||
// addCommand(new PardonPlayerCommand());
|
||||
// addCommand(new KickCommand());
|
||||
// addCommand(new ListPlayersCommand());
|
||||
// addCommand(new BroadcastCommand());
|
||||
// addCommand(new WhitelistCommand());
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// addCommand(new PublishLocalServerCommand());
|
||||
//}
|
||||
// if (MinecraftServer::getInstance()->isDedicatedServer())
|
||||
//{
|
||||
// addCommand(new OpCommand());
|
||||
// addCommand(new DeOpCommand());
|
||||
// addCommand(new StopCommand());
|
||||
// addCommand(new SaveAllCommand());
|
||||
// addCommand(new SaveOffCommand());
|
||||
// addCommand(new SaveOnCommand());
|
||||
// addCommand(new BanIpCommand());
|
||||
// addCommand(new PardonIpCommand());
|
||||
// addCommand(new BanPlayerCommand());
|
||||
// addCommand(new ListBansCommand());
|
||||
// addCommand(new PardonPlayerCommand());
|
||||
// addCommand(new KickCommand());
|
||||
// addCommand(new ListPlayersCommand());
|
||||
// addCommand(new BroadcastCommand());
|
||||
// addCommand(new WhitelistCommand());
|
||||
// }
|
||||
// else
|
||||
//{
|
||||
// addCommand(new PublishLocalServerCommand());
|
||||
// }
|
||||
|
||||
// addCommand(new ServerTempDebugCommand());
|
||||
// addCommand(new ServerTempDebugCommand());
|
||||
|
||||
Command::setLogger(this);
|
||||
Command::setLogger(this);
|
||||
}
|
||||
|
||||
void ServerCommandDispatcher::logAdminCommand(std::shared_ptr<CommandSender> source, int type, ChatPacket::EChatPacketMessage messageType, const std::wstring& message, int customData, const std::wstring& additionalMessage)
|
||||
{
|
||||
PlayerList *playerList = MinecraftServer::getInstance()->getPlayers();
|
||||
//for (Player player : MinecraftServer.getInstance().getPlayers().players)
|
||||
for(AUTO_VAR(it, playerList->players.begin()); it != playerList->players.end(); ++it)
|
||||
{
|
||||
std::shared_ptr<ServerPlayer> player = *it;
|
||||
if (player != source && playerList->isOp(player))
|
||||
{
|
||||
// TODO: Change chat packet to be able to send more bits of data
|
||||
// 4J Stu - Take this out until we can add the name of the player performing the action. Also if the target is a mod then maybe don't need the message?
|
||||
//player->sendMessage(message, messageType, customData, additionalMessage);
|
||||
//player->sendMessage("\u00A77\u00A7o[" + source.getName() + ": " + player.localize(message, args) + "]");
|
||||
}
|
||||
}
|
||||
void ServerCommandDispatcher::logAdminCommand(
|
||||
std::shared_ptr<CommandSender> source, int type,
|
||||
ChatPacket::EChatPacketMessage messageType, const std::wstring& message,
|
||||
int customData, const std::wstring& additionalMessage) {
|
||||
PlayerList* playerList = MinecraftServer::getInstance()->getPlayers();
|
||||
// for (Player player : MinecraftServer.getInstance().getPlayers().players)
|
||||
for (AUTO_VAR(it, playerList->players.begin());
|
||||
it != playerList->players.end(); ++it) {
|
||||
std::shared_ptr<ServerPlayer> player = *it;
|
||||
if (player != source && playerList->isOp(player)) {
|
||||
// TODO: Change chat packet to be able to send more bits of data
|
||||
// 4J Stu - Take this out until we can add the name of the player
|
||||
// performing the action. Also if the target is a mod then maybe
|
||||
// don't need the message?
|
||||
// player->sendMessage(message, messageType, customData,
|
||||
// additionalMessage); player->sendMessage("\u00A77\u00A7o[" +
|
||||
// source.getName() + ": " + player.localize(message, args) + "]");
|
||||
}
|
||||
}
|
||||
|
||||
if ((type & LOGTYPE_DONT_SHOW_TO_SELF) != LOGTYPE_DONT_SHOW_TO_SELF)
|
||||
{
|
||||
source->sendMessage(message, messageType, customData, additionalMessage);
|
||||
}
|
||||
if ((type & LOGTYPE_DONT_SHOW_TO_SELF) != LOGTYPE_DONT_SHOW_TO_SELF) {
|
||||
source->sendMessage(message, messageType, customData,
|
||||
additionalMessage);
|
||||
}
|
||||
}
|
||||
|
|
@ -3,9 +3,12 @@
|
|||
#include "../../Minecraft.World/Commands/CommandDispatcher.h"
|
||||
#include "../../Minecraft.World/Commands/AdminLogCommand.h"
|
||||
|
||||
class ServerCommandDispatcher : public CommandDispatcher, public AdminLogCommand
|
||||
{
|
||||
class ServerCommandDispatcher : public CommandDispatcher,
|
||||
public AdminLogCommand {
|
||||
public:
|
||||
ServerCommandDispatcher();
|
||||
void logAdminCommand(std::shared_ptr<CommandSender> source, int type, ChatPacket::EChatPacketMessage messageType, const std::wstring& message = L"", int customData = -1, const std::wstring& additionalMessage = L"");
|
||||
ServerCommandDispatcher();
|
||||
void logAdminCommand(std::shared_ptr<CommandSender> source, int type,
|
||||
ChatPacket::EChatPacketMessage messageType,
|
||||
const std::wstring& message = L"", int customData = -1,
|
||||
const std::wstring& additionalMessage = L"");
|
||||
};
|
||||
|
|
@ -9,196 +9,187 @@
|
|||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
||||
#include "../Level/MultiPlayerLevel.h"
|
||||
|
||||
ServerConnection::ServerConnection(MinecraftServer *server)
|
||||
{
|
||||
// 4J - added initialiser
|
||||
connectionCounter = 0;
|
||||
InitializeCriticalSection(&pending_cs);
|
||||
ServerConnection::ServerConnection(MinecraftServer* server) {
|
||||
// 4J - added initialiser
|
||||
connectionCounter = 0;
|
||||
InitializeCriticalSection(&pending_cs);
|
||||
|
||||
this->server = server;
|
||||
this->server = server;
|
||||
}
|
||||
|
||||
ServerConnection::~ServerConnection()
|
||||
{
|
||||
DeleteCriticalSection(&pending_cs);
|
||||
ServerConnection::~ServerConnection() { DeleteCriticalSection(&pending_cs); }
|
||||
|
||||
// 4J - added to handle incoming connections, to replace thread that original
|
||||
// used to have
|
||||
void ServerConnection::NewIncomingSocket(Socket* socket) {
|
||||
std::shared_ptr<PendingConnection> unconnectedClient =
|
||||
std::shared_ptr<PendingConnection>(new PendingConnection(
|
||||
server, socket,
|
||||
L"Connection #" + _toString<int>(connectionCounter++)));
|
||||
handleConnection(unconnectedClient);
|
||||
}
|
||||
|
||||
// 4J - added to handle incoming connections, to replace thread that original used to have
|
||||
void ServerConnection::NewIncomingSocket(Socket *socket)
|
||||
{
|
||||
std::shared_ptr<PendingConnection> unconnectedClient = std::shared_ptr<PendingConnection>(new PendingConnection(server, socket, L"Connection #" + _toString<int>(connectionCounter++)));
|
||||
handleConnection(unconnectedClient);
|
||||
void ServerConnection::addPlayerConnection(
|
||||
std::shared_ptr<PlayerConnection> uc) {
|
||||
players.push_back(uc);
|
||||
}
|
||||
|
||||
void ServerConnection::addPlayerConnection(std::shared_ptr<PlayerConnection> uc)
|
||||
{
|
||||
players.push_back(uc);
|
||||
void ServerConnection::handleConnection(std::shared_ptr<PendingConnection> uc) {
|
||||
EnterCriticalSection(&pending_cs);
|
||||
pending.push_back(uc);
|
||||
LeaveCriticalSection(&pending_cs);
|
||||
}
|
||||
|
||||
void ServerConnection::handleConnection(std::shared_ptr<PendingConnection> uc)
|
||||
{
|
||||
EnterCriticalSection(&pending_cs);
|
||||
pending.push_back(uc);
|
||||
LeaveCriticalSection(&pending_cs);
|
||||
}
|
||||
|
||||
void ServerConnection::stop()
|
||||
{
|
||||
EnterCriticalSection(&pending_cs);
|
||||
for (unsigned int i = 0; i < pending.size(); i++)
|
||||
{
|
||||
void ServerConnection::stop() {
|
||||
EnterCriticalSection(&pending_cs);
|
||||
for (unsigned int i = 0; i < pending.size(); i++) {
|
||||
std::shared_ptr<PendingConnection> uc = pending[i];
|
||||
uc->connection->close(DisconnectPacket::eDisconnect_Closed);
|
||||
}
|
||||
LeaveCriticalSection(&pending_cs);
|
||||
LeaveCriticalSection(&pending_cs);
|
||||
|
||||
for (unsigned int i = 0; i < players.size(); i++)
|
||||
{
|
||||
for (unsigned int i = 0; i < players.size(); i++) {
|
||||
std::shared_ptr<PlayerConnection> player = players[i];
|
||||
player->connection->close(DisconnectPacket::eDisconnect_Closed);
|
||||
}
|
||||
}
|
||||
|
||||
void ServerConnection::tick()
|
||||
{
|
||||
{
|
||||
// MGH - changed this so that the the CS lock doesn't cover the tick (was causing a lockup when 2 players tried to join)
|
||||
EnterCriticalSection(&pending_cs);
|
||||
std::vector< std::shared_ptr<PendingConnection> > tempPending = pending;
|
||||
LeaveCriticalSection(&pending_cs);
|
||||
void ServerConnection::tick() {
|
||||
{
|
||||
// MGH - changed this so that the the CS lock doesn't cover the tick
|
||||
// (was causing a lockup when 2 players tried to join)
|
||||
EnterCriticalSection(&pending_cs);
|
||||
std::vector<std::shared_ptr<PendingConnection> > tempPending = pending;
|
||||
LeaveCriticalSection(&pending_cs);
|
||||
|
||||
for (unsigned int i = 0; i < tempPending.size(); i++)
|
||||
{
|
||||
std::shared_ptr<PendingConnection> uc = tempPending[i];
|
||||
// try { // 4J - removed try/catch
|
||||
uc->tick();
|
||||
// } catch (Exception e) {
|
||||
// uc.disconnect("Internal server error");
|
||||
// logger.log(Level.WARNING, "Failed to handle packet: " + e, e);
|
||||
// }
|
||||
if(uc->connection != NULL) uc->connection->flush();
|
||||
}
|
||||
}
|
||||
for (unsigned int i = 0; i < tempPending.size(); i++) {
|
||||
std::shared_ptr<PendingConnection> uc = tempPending[i];
|
||||
// try { // 4J - removed try/catch
|
||||
uc->tick();
|
||||
// } catch (Exception e) {
|
||||
// uc.disconnect("Internal server error");
|
||||
// logger.log(Level.WARNING, "Failed to handle packet: "
|
||||
// + e, e);
|
||||
// }
|
||||
if (uc->connection != NULL) uc->connection->flush();
|
||||
}
|
||||
}
|
||||
|
||||
// now remove from the pending list
|
||||
EnterCriticalSection(&pending_cs);
|
||||
for (unsigned int i = 0; i < pending.size(); i++)
|
||||
if (pending[i]->done)
|
||||
{
|
||||
pending.erase(pending.begin()+i);
|
||||
i--;
|
||||
}
|
||||
LeaveCriticalSection(&pending_cs);
|
||||
// now remove from the pending list
|
||||
EnterCriticalSection(&pending_cs);
|
||||
for (unsigned int i = 0; i < pending.size(); i++)
|
||||
if (pending[i]->done) {
|
||||
pending.erase(pending.begin() + i);
|
||||
i--;
|
||||
}
|
||||
LeaveCriticalSection(&pending_cs);
|
||||
|
||||
for (unsigned int i = 0; i < players.size(); i++)
|
||||
{
|
||||
for (unsigned int i = 0; i < players.size(); i++) {
|
||||
std::shared_ptr<PlayerConnection> player = players[i];
|
||||
std::shared_ptr<ServerPlayer> serverPlayer = player->getPlayer();
|
||||
if( serverPlayer )
|
||||
{
|
||||
serverPlayer->doChunkSendingTick(false);
|
||||
}
|
||||
// try { // 4J - removed try/catch
|
||||
player->tick();
|
||||
// } catch (Exception e) {
|
||||
// logger.log(Level.WARNING, "Failed to handle packet: " + e, e);
|
||||
// player.disconnect("Internal server error");
|
||||
// }
|
||||
if (player->done)
|
||||
{
|
||||
players.erase(players.begin()+i);
|
||||
i--;
|
||||
std::shared_ptr<ServerPlayer> serverPlayer = player->getPlayer();
|
||||
if (serverPlayer) {
|
||||
serverPlayer->doChunkSendingTick(false);
|
||||
}
|
||||
// try { // 4J - removed try/catch
|
||||
player->tick();
|
||||
// } catch (Exception e) {
|
||||
// logger.log(Level.WARNING, "Failed to handle packet: " + e,
|
||||
// e); player.disconnect("Internal server error");
|
||||
// }
|
||||
if (player->done) {
|
||||
players.erase(players.begin() + i);
|
||||
i--;
|
||||
}
|
||||
player->connection->flush();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool ServerConnection::addPendingTextureRequest(const std::wstring &textureName)
|
||||
{
|
||||
AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
|
||||
if( it == m_pendingTextureRequests.end() )
|
||||
{
|
||||
m_pendingTextureRequests.push_back(textureName);
|
||||
return true;
|
||||
}
|
||||
bool ServerConnection::addPendingTextureRequest(
|
||||
const std::wstring& textureName) {
|
||||
AUTO_VAR(it, find(m_pendingTextureRequests.begin(),
|
||||
m_pendingTextureRequests.end(), textureName));
|
||||
if (it == m_pendingTextureRequests.end()) {
|
||||
m_pendingTextureRequests.push_back(textureName);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 4J Stu - We want to request this texture from everyone, if we have a duplicate it's most likely because the first person we asked for it didn't have it
|
||||
// eg They selected a skin then deleted the skin pack. The side effect of this change is that in certain cases we can send a few more requests, and receive
|
||||
// a few more responses if people join with the same skin in a short space of time
|
||||
return true;
|
||||
// 4J Stu - We want to request this texture from everyone, if we have a
|
||||
// duplicate it's most likely because the first person we asked for it
|
||||
// didn't have it eg They selected a skin then deleted the skin pack. The
|
||||
// side effect of this change is that in certain cases we can send a few
|
||||
// more requests, and receive a few more responses if people join with the
|
||||
// same skin in a short space of time
|
||||
return true;
|
||||
}
|
||||
|
||||
void ServerConnection::handleTextureReceived(const std::wstring &textureName)
|
||||
{
|
||||
AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
|
||||
if( it != m_pendingTextureRequests.end() )
|
||||
{
|
||||
m_pendingTextureRequests.erase(it);
|
||||
}
|
||||
for (unsigned int i = 0; i < players.size(); i++)
|
||||
{
|
||||
void ServerConnection::handleTextureReceived(const std::wstring& textureName) {
|
||||
AUTO_VAR(it, find(m_pendingTextureRequests.begin(),
|
||||
m_pendingTextureRequests.end(), textureName));
|
||||
if (it != m_pendingTextureRequests.end()) {
|
||||
m_pendingTextureRequests.erase(it);
|
||||
}
|
||||
for (unsigned int i = 0; i < players.size(); i++) {
|
||||
std::shared_ptr<PlayerConnection> player = players[i];
|
||||
if (!player->done)
|
||||
{
|
||||
player->handleTextureReceived(textureName);
|
||||
if (!player->done) {
|
||||
player->handleTextureReceived(textureName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ServerConnection::handleTextureAndGeometryReceived(const std::wstring &textureName)
|
||||
{
|
||||
AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
|
||||
if( it != m_pendingTextureRequests.end() )
|
||||
{
|
||||
m_pendingTextureRequests.erase(it);
|
||||
}
|
||||
for (unsigned int i = 0; i < players.size(); i++)
|
||||
{
|
||||
std::shared_ptr<PlayerConnection> player = players[i];
|
||||
if (!player->done)
|
||||
{
|
||||
player->handleTextureAndGeometryReceived(textureName);
|
||||
}
|
||||
}
|
||||
void ServerConnection::handleTextureAndGeometryReceived(
|
||||
const std::wstring& textureName) {
|
||||
AUTO_VAR(it, find(m_pendingTextureRequests.begin(),
|
||||
m_pendingTextureRequests.end(), textureName));
|
||||
if (it != m_pendingTextureRequests.end()) {
|
||||
m_pendingTextureRequests.erase(it);
|
||||
}
|
||||
for (unsigned int i = 0; i < players.size(); i++) {
|
||||
std::shared_ptr<PlayerConnection> player = players[i];
|
||||
if (!player->done) {
|
||||
player->handleTextureAndGeometryReceived(textureName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ServerConnection::handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet)
|
||||
{
|
||||
Minecraft *pMinecraft = Minecraft::GetInstance();
|
||||
void ServerConnection::handleServerSettingsChanged(
|
||||
std::shared_ptr<ServerSettingsChangedPacket> packet) {
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
if(packet->action==ServerSettingsChangedPacket::HOST_DIFFICULTY)
|
||||
{
|
||||
for(unsigned int i = 0; i < pMinecraft->levels.length; ++i)
|
||||
{
|
||||
if( pMinecraft->levels[i] != NULL )
|
||||
{
|
||||
app.DebugPrintf("ClientConnection::handleServerSettingsChanged - Difficulty = %d",packet->data);
|
||||
pMinecraft->levels[i]->difficulty = packet->data;
|
||||
}
|
||||
}
|
||||
}
|
||||
// else if(packet->action==ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS)// options
|
||||
// {
|
||||
// app.SetGameHostOption(eGameHostOption_All,packet->m_serverSettings)
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// unsigned char ucData=(unsigned char)packet->data;
|
||||
// if(ucData&1)
|
||||
// {
|
||||
// // hide gamertags
|
||||
// pMinecraft->options->SetGamertagSetting(true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// pMinecraft->options->SetGamertagSetting(false);
|
||||
// }
|
||||
//
|
||||
// for (unsigned int i = 0; i < players.size(); i++)
|
||||
// {
|
||||
// std::shared_ptr<PlayerConnection> playerconnection = players[i];
|
||||
// playerconnection->setShowOnMaps(pMinecraft->options->GetGamertagSetting());
|
||||
// }
|
||||
// }
|
||||
if (packet->action == ServerSettingsChangedPacket::HOST_DIFFICULTY) {
|
||||
for (unsigned int i = 0; i < pMinecraft->levels.length; ++i) {
|
||||
if (pMinecraft->levels[i] != NULL) {
|
||||
app.DebugPrintf(
|
||||
"ClientConnection::handleServerSettingsChanged - "
|
||||
"Difficulty = %d",
|
||||
packet->data);
|
||||
pMinecraft->levels[i]->difficulty = packet->data;
|
||||
}
|
||||
}
|
||||
}
|
||||
// else
|
||||
// if(packet->action==ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS)//
|
||||
// options
|
||||
// {
|
||||
// app.SetGameHostOption(eGameHostOption_All,packet->m_serverSettings)
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// unsigned char ucData=(unsigned char)packet->data;
|
||||
// if(ucData&1)
|
||||
// {
|
||||
// // hide gamertags
|
||||
// pMinecraft->options->SetGamertagSetting(true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// pMinecraft->options->SetGamertagSetting(false);
|
||||
// }
|
||||
//
|
||||
// for (unsigned int i = 0; i < players.size(); i++)
|
||||
// {
|
||||
// std::shared_ptr<PlayerConnection> playerconnection =
|
||||
// players[i];
|
||||
// playerconnection->setShowOnMaps(pMinecraft->options->GetGamertagSetting());
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
@ -5,45 +5,52 @@ class MinecraftServer;
|
|||
class Socket;
|
||||
class ServerSettingsChangedPacket;
|
||||
|
||||
|
||||
|
||||
class ServerConnection
|
||||
{
|
||||
// public static Logger logger = Logger.getLogger("Minecraft");
|
||||
class ServerConnection {
|
||||
// public static Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
private:
|
||||
// ServerSocket serverSocket;
|
||||
// private Thread listenThread;
|
||||
// ServerSocket serverSocket;
|
||||
// private Thread listenThread;
|
||||
public:
|
||||
volatile bool running;
|
||||
volatile bool running;
|
||||
|
||||
private:
|
||||
int connectionCounter;
|
||||
int connectionCounter;
|
||||
|
||||
private:
|
||||
CRITICAL_SECTION pending_cs; // 4J added
|
||||
std::vector< std::shared_ptr<PendingConnection> > pending;
|
||||
std::vector< std::shared_ptr<PlayerConnection> > players;
|
||||
CRITICAL_SECTION pending_cs; // 4J added
|
||||
std::vector<std::shared_ptr<PendingConnection> > pending;
|
||||
std::vector<std::shared_ptr<PlayerConnection> > players;
|
||||
|
||||
// 4J - When the server requests a texture, it should add it to here while we are waiting for it
|
||||
std::vector<std::wstring> m_pendingTextureRequests;
|
||||
public:
|
||||
MinecraftServer *server;
|
||||
// 4J - When the server requests a texture, it should add it to here while
|
||||
// we are waiting for it
|
||||
std::vector<std::wstring> m_pendingTextureRequests;
|
||||
|
||||
public:
|
||||
ServerConnection(MinecraftServer *server); // 4J - removed params InetAddress address, int port);
|
||||
~ServerConnection();
|
||||
void NewIncomingSocket(Socket *socket); // 4J - added
|
||||
MinecraftServer* server;
|
||||
|
||||
void removeSpamProtection(Socket *socket) { }// 4J Stu - Not implemented as not required
|
||||
public:
|
||||
ServerConnection(
|
||||
MinecraftServer*
|
||||
server); // 4J - removed params InetAddress address, int port);
|
||||
~ServerConnection();
|
||||
void NewIncomingSocket(Socket* socket); // 4J - added
|
||||
|
||||
void removeSpamProtection(Socket* socket) {
|
||||
} // 4J Stu - Not implemented as not required
|
||||
void addPlayerConnection(std::shared_ptr<PlayerConnection> uc);
|
||||
|
||||
private:
|
||||
void handleConnection(std::shared_ptr<PendingConnection> uc);
|
||||
void handleConnection(std::shared_ptr<PendingConnection> uc);
|
||||
|
||||
public:
|
||||
void stop();
|
||||
void stop();
|
||||
void tick();
|
||||
|
||||
// 4J Added
|
||||
bool addPendingTextureRequest(const std::wstring &textureName);
|
||||
void handleTextureReceived(const std::wstring &textureName);
|
||||
void handleTextureAndGeometryReceived(const std::wstring &textureName);
|
||||
void handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet);
|
||||
// 4J Added
|
||||
bool addPendingTextureRequest(const std::wstring& textureName);
|
||||
void handleTextureReceived(const std::wstring& textureName);
|
||||
void handleTextureAndGeometryReceived(const std::wstring& textureName);
|
||||
void handleServerSettingsChanged(
|
||||
std::shared_ptr<ServerSettingsChangedPacket> packet);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,29 +1,29 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
class ServerInterface
|
||||
{
|
||||
virtual int getConfigInt(const std::wstring &name, int defaultValue) = 0;
|
||||
virtual std::wstring getConfigString(const std::wstring &name, const std::wstring &defaultValue) = 0;
|
||||
virtual bool getConfigBoolean(const std::wstring &name, bool defaultValue) = 0;
|
||||
virtual void setProperty(std::wstring &propertyName, void *value) = 0;
|
||||
virtual void configSave() = 0;
|
||||
virtual std::wstring getConfigPath() = 0;
|
||||
virtual std::wstring getServerIp() = 0;
|
||||
virtual int getServerPort() = 0;
|
||||
virtual std::wstring getServerName() = 0;
|
||||
virtual std::wstring getServerVersion() = 0;
|
||||
virtual int getPlayerCount() = 0;
|
||||
virtual int getMaxPlayers() = 0;
|
||||
virtual std::wstring[] getPlayerNames() = 0;
|
||||
virtual std::wstring getWorldName() = 0;
|
||||
virtual std::wstring getPluginNames() = 0;
|
||||
virtual void disablePlugin() = 0;
|
||||
virtual std::wstring runCommand(const std::wstring &command) = 0;
|
||||
virtual bool isDebugging() = 0;
|
||||
// Logging
|
||||
virtual void info(const std::wstring &string) = 0;
|
||||
virtual void warn(const std::wstring &string) = 0;
|
||||
virtual void error(const std::wstring &string) = 0;
|
||||
virtual void debug(const std::wstring &string) = 0;
|
||||
class ServerInterface {
|
||||
virtual int getConfigInt(const std::wstring& name, int defaultValue) = 0;
|
||||
virtual std::wstring getConfigString(const std::wstring& name,
|
||||
const std::wstring& defaultValue) = 0;
|
||||
virtual bool getConfigBoolean(const std::wstring& name,
|
||||
bool defaultValue) = 0;
|
||||
virtual void setProperty(std::wstring& propertyName, void* value) = 0;
|
||||
virtual void configSave() = 0;
|
||||
virtual std::wstring getConfigPath() = 0;
|
||||
virtual std::wstring getServerIp() = 0;
|
||||
virtual int getServerPort() = 0;
|
||||
virtual std::wstring getServerName() = 0;
|
||||
virtual std::wstring getServerVersion() = 0;
|
||||
virtual int getPlayerCount() = 0;
|
||||
virtual int getMaxPlayers() = 0;
|
||||
virtual std::wstring[] getPlayerNames() = 0;
|
||||
virtual std::wstring getWorldName() = 0;
|
||||
virtual std::wstring getPluginNames() = 0;
|
||||
virtual void disablePlugin() = 0;
|
||||
virtual std::wstring runCommand(const std::wstring& command) = 0;
|
||||
virtual bool isDebugging() = 0;
|
||||
// Logging
|
||||
virtual void info(const std::wstring& string) = 0;
|
||||
virtual void warn(const std::wstring& string) = 0;
|
||||
virtual void error(const std::wstring& string) = 0;
|
||||
virtual void debug(const std::wstring& string) = 0;
|
||||
};
|
||||
|
|
@ -16,7 +16,7 @@ TMS_FILE;
|
|||
typedef struct
|
||||
{
|
||||
std::uint8_t *pbData;
|
||||
unsigned int dwBytes;
|
||||
unsigned int byteCount;
|
||||
std::uint8_t ucRefCount;
|
||||
}
|
||||
MEMDATA,*PMEMDATA;
|
||||
|
|
@ -197,7 +197,7 @@ FEATURE_DATA;
|
|||
typedef struct
|
||||
{
|
||||
std::uint8_t *pBannedList;
|
||||
unsigned int dwBytes;
|
||||
unsigned int byteCount;
|
||||
}
|
||||
BANNEDLIST;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@
|
|||
// Desc: Internal helper function
|
||||
//--------------------------------------------------------------------------------------
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
static VOID DebugSpewV( const CHAR* strFormat, va_list pArgList )
|
||||
static void DebugSpewV(const char* strFormat, va_list pArgList)
|
||||
{
|
||||
#if defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ || defined(__linux__)
|
||||
assert(0);
|
||||
#else
|
||||
CHAR str[2048];
|
||||
char str[2048];
|
||||
// Use the secure CRT to avoid buffer overruns. Specify a count of
|
||||
// _TRUNCATE so that too long strings will be silently truncated
|
||||
// rather than triggering an error.
|
||||
|
|
@ -27,9 +27,9 @@ static VOID DebugSpewV( const CHAR* strFormat, va_list pArgList )
|
|||
// Desc: Prints formatted debug spew
|
||||
//--------------------------------------------------------------------------------------
|
||||
#ifdef _Printf_format_string_ // VC++ 2008 and later support this annotation
|
||||
VOID CDECL DebugSpew( _In_z_ _Printf_format_string_ const CHAR* strFormat, ... )
|
||||
void CDECL DebugSpew(_In_z_ _Printf_format_string_ const char* strFormat, ...)
|
||||
#else
|
||||
VOID CDECL DebugPrintf( const CHAR* strFormat, ... )
|
||||
void CDECL DebugPrintf(const char* strFormat, ...)
|
||||
#endif
|
||||
{
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
|
|
@ -39,4 +39,3 @@ VOID CDECL DebugPrintf( const CHAR* strFormat, ... )
|
|||
va_end( pArgList );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||