57 Commits

Author SHA1 Message Date
itsRevela 5079622a6f ci: revert chunked-upload and full-history workarounds 2026-05-17 06:39:57 -05:00
itsRevela 6e31a8c0b8 ci: point workflow at git.revela.dev 2026-05-17 06:36:52 -05:00
itsRevela 61a8a13245 ci: enable buildx docker-container driver for OCI export 2026-05-17 02:01:49 -05:00
itsRevela c0cb7b7809 ci: push docker images via crane with chunked uploads 2026-05-17 01:30:12 -05:00
itsRevela 289225e07d ci: use REGISTRY_TOKEN for Forgejo container registry push 2026-05-15 03:04:29 -05:00
itsRevela ea02b5ee36 ci: full-history checkout for release tag push 2026-05-15 01:09:30 -05:00
itsRevela 59c39428fa ci: log file sizes and HTTP status on release asset upload 2026-05-14 16:44:10 -05:00
itsRevela 8ad207368b ci: pin artifact actions to v3 for Forgejo compatibility 2026-05-14 15:37:04 -05:00
itsRevela 07f0eb95dd ci: port nightly release pipeline to Forgejo 2026-05-14 15:24:32 -05:00
itsRevela 9c9238c6c4 ci: pin action uses to full GitHub URLs 2026-05-14 14:28:27 -05:00
itsRevela cf22f5f5f4 ci: switch workflows to self-hosted runner labels 2026-05-14 14:22:28 -05:00
itsRevela 386b9c430b Revert "chore(server): re-enable console QuickEdit mode"
This reverts commit 99120e5323.
2026-05-02 14:47:46 -05:00
itsRevela 68c2994523 chore: sync upstream MinecraftConsoles through d3df5350 2026-04-30 15:49:27 -05:00
itsRevela 1d9e79b9b3 docs: add submodule clone hint to compile instructions 2026-04-30 15:49:12 -05:00
itsRevela 50746cd3de revert(server): empty-dim entity tick gate 2026-04-30 15:46:26 -05:00
Loki d3df53503a Update COMPILE.md 2026-04-30 13:21:31 -05:00
Loki 5bccf89fe2 Update COMPILE.md 2026-04-30 13:21:25 -05:00
itsRevela 99120e5323 chore(server): re-enable console QuickEdit mode 2026-04-30 11:19:58 -05:00
itsRevela ca0619939c chore: sync upstream MinecraftConsoles through 5f931d74 2026-04-30 10:51:06 -05:00
itsRevela e4005d6b76 docs: add submodule clone hint to build instructions 2026-04-30 10:50:45 -05:00
itsRevela bddcc13bff chore(server): raise perf log thresholds to reduce noise 2026-04-30 10:47:08 -05:00
Loki Rautio 5f931d74fc Update 4JLibs, adjust README 2026-04-29 17:02:40 -05:00
itsRevela 5c90744677 docs: document fourkit docker image alongside vanilla in readme 2026-04-29 13:35:30 -05:00
itsRevela 750c4696ae chore: rewrite code comments 2026-04-29 13:33:19 -05:00
itsRevela ff3241cfee fix: server save-on-exit reliability and logging 2026-04-29 13:28:20 -05:00
itsRevela 17fdc78567 chore: bump 4JLibs to include PNG text section fix 2026-04-29 12:06:26 -05:00
itsRevela 3064afc9b2 chore: point 4JLibs submodule to itsRevela fork 2026-04-29 11:47:18 -05:00
itsRevela 3c1a7c174a feat: wire docker job into nightly workflow and update Dockerfile for both flavours 2026-04-28 17:31:58 -05:00
itsRevela 54b60867d4 feat: build vanilla and fourkit dedicated server docker images in nightly 2026-04-28 17:31:34 -05:00
itsRevela 8495baf83e fix: remove 30-second sprint auto-stop 2026-04-28 17:12:50 -05:00
itsRevela cc68899cec fix: iron door no longer blocks held-item use on right-click 2026-04-28 15:33:14 -05:00
itsRevela 89ed116fe0 fix: beacon outer halo washed out behind water 2026-04-28 14:19:22 -05:00
itsRevela 0df5cd865b chore: sync upstream MinecraftConsoles through 585455ce 2026-04-26 15:40:23 -05:00
ModMaker101 cbdb92d045 Replace MSVC __debugbreak with cross-compiler DEBUG_BREAK macro. (#1540) 2026-04-26 15:38:13 -05:00
ModMaker101 0625db38f5 Fix autosave thread compression TLS crash. (#1544) 2026-04-26 15:38:13 -05:00
Loki Rautio fc0e32f346 Fix PR workflow
Per patoke
2026-04-26 15:38:13 -05:00
Loki Rautio 3cef7f17dc fix: Control mappings wrong (update 4JLibs)
fixes #1531 and #1528
2026-04-26 15:38:13 -05:00
Loki Rautio d467b10e39 Remove redundant gitignore line 2026-04-26 15:38:13 -05:00
gsds 54ecbed263 Include 4JLibs as a submodule (#1535)
* feat: 4JLibs as a submodule

* fix: forgot submodule

* fix: actions didn't recurse submodules on checkout

* fix: oops, using old commit
2026-04-26 15:38:13 -05:00
dtentiion 7f18fe1236 fix: Nether portal trigger and travel sounds not playing (#1523) 2026-04-26 15:38:13 -05:00
Revela f583495958 Merge pull request #2 from Firebladedoge229/main
fix: paper doll transformations on non-16:9 aspect ratios
2026-04-26 15:10:39 -05:00
itsRevela 6b7d81a92b revert: /ping command and kernel TCP RTT plumbing 2026-04-26 14:52:46 -05:00
ModMaker101 585455cef0 Replace MSVC __debugbreak with cross-compiler DEBUG_BREAK macro. (#1540) 2026-04-26 12:23:52 -05:00
ModMaker101 3ab29ec26e Remove HTML escape for apostrophe in chat (#1541)
Fixes #1537
2026-04-26 12:22:51 -05:00
ModMaker101 e5351b51c0 Fix autosave thread compression TLS crash. (#1544) 2026-04-26 12:21:33 -05:00
itsRevela 44283e5971 fix(server): empty-dim tick gate broke block updates 2026-04-26 00:00:24 -05:00
itsRevela 70a610fd2c feat(server): kernel TCP RTT for Player.getPing() 2026-04-25 23:26:13 -05:00
itsRevela 0708120ae8 feat: add TpsPlugin sample with /tps and /ping 2026-04-25 22:45:35 -05:00
itsRevela f105952140 docs: README entry for TPS recovery at scale 2026-04-25 13:46:01 -05:00
itsRevela ce9ffefba6 perf(server): hold 20 TPS at 50-player scale 2026-04-25 13:42:29 -05:00
Loki Rautio 42e75876f2 Fix PR workflow
Per patoke
2026-04-24 07:11:34 -05:00
Loki Rautio 5e5b685c72 fix: Control mappings wrong (update 4JLibs)
fixes #1531 and #1528
2026-04-21 19:55:46 -05:00
Loki Rautio d4ac3cd645 Remove redundant gitignore line 2026-04-21 18:57:30 -05:00
gsds 1b8a14357c Include 4JLibs as a submodule (#1535)
* feat: 4JLibs as a submodule

* fix: forgot submodule

* fix: actions didn't recurse submodules on checkout

* fix: oops, using old commit
2026-04-21 18:32:02 -05:00
Sylvessa 7c1606837f fix: worlds without worlds won't open (#1529) 2026-04-18 19:14:42 -05:00
dtentiion 4a7b34f4c2 fix: Display save thumbnail in world detail view on Windows64 (#1519) 2026-04-18 17:49:43 -05:00
dtentiion 9167454767 fix: Nether portal trigger and travel sounds not playing (#1523) 2026-04-18 17:47:18 -05:00
120 changed files with 1292 additions and 1289 deletions
+206 -77
View File
@@ -7,6 +7,7 @@ permissions:
contents: write
id-token: write
attestations: write
packages: write
concurrency:
group: nightly
@@ -15,20 +16,22 @@ concurrency:
jobs:
build-client:
name: Build Client
runs-on: windows-latest
runs-on: [self-hosted, windows]
steps:
- name: Checkout
uses: actions/checkout@v6
uses: https://github.com/actions/checkout@v6
with:
submodules: recursive
- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1
uses: https://github.com/ilammy/msvc-dev-cmd@v1
- name: Setup CMake
uses: lukka/get-cmake@latest
uses: https://github.com/lukka/get-cmake@latest
- name: Run CMake
uses: lukka/run-cmake@v10
uses: https://github.com/lukka/run-cmake@v10
env:
VCPKG_ROOT: ""
with:
@@ -83,32 +86,34 @@ jobs:
Copy-Item ./build/windows64/Minecraft.Client/Release/Minecraft.Client.pdb staging/
- name: Upload artifacts
uses: actions/upload-artifact@v6
uses: https://github.com/actions/upload-artifact@v3
with:
name: client-build
path: staging/*
build-server:
name: Build Server
runs-on: windows-latest
runs-on: [self-hosted, windows]
steps:
- name: Checkout
uses: actions/checkout@v6
uses: https://github.com/actions/checkout@v6
with:
submodules: recursive
- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1
uses: https://github.com/ilammy/msvc-dev-cmd@v1
- name: Setup CMake
uses: lukka/get-cmake@latest
uses: https://github.com/lukka/get-cmake@latest
- name: Setup .NET
uses: actions/setup-dotnet@v4
uses: https://github.com/actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Run CMake
uses: lukka/run-cmake@v10
uses: https://github.com/lukka/run-cmake@v10
env:
VCPKG_ROOT: ""
with:
@@ -194,49 +199,119 @@ jobs:
Copy-Item LCE-Revelations-Server-Win64-FourKit.zip staging/
- name: Upload artifacts
uses: actions/upload-artifact@v6
uses: https://github.com/actions/upload-artifact@v3
with:
name: server-build
path: staging/*
release-server:
name: Release Server
docker:
name: Build Docker (${{ matrix.variant }})
needs: build-server
runs-on: ubuntu-latest
runs-on: [self-hosted, linux]
strategy:
fail-fast: false
matrix:
include:
- variant: vanilla
zip: LCE-Revelations-Server-Win64.zip
subdir: LCE-Revelations-Server-Win64
image: lce-revelations-dedicated-server
- variant: fourkit
zip: LCE-Revelations-Server-Win64-FourKit.zip
subdir: LCE-Revelations-Server-Win64-FourKit
image: lce-revelations-dedicated-server-fourkit
steps:
- name: Checkout
uses: actions/checkout@v6
uses: https://github.com/actions/checkout@v6
- name: Download server artifacts
uses: actions/download-artifact@v7
uses: https://github.com/actions/download-artifact@v3
with:
name: server-build
path: .artifacts/
- name: Prepare runtime directory
shell: bash
run: |
set -euo pipefail
rm -rf runtime .extracted
unzip -q ".artifacts/${{ matrix.zip }}" -d .extracted
mv ".extracted/${{ matrix.subdir }}" runtime
# Strip debug symbols to keep image small (zip includes .pdb).
find runtime -name '*.pdb' -delete
- name: Compute image name
id: image
shell: bash
run: |
owner="$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')"
echo "image=git.revela.dev/$owner/${{ matrix.image }}" >> "$GITHUB_OUTPUT"
- name: Extract Docker metadata
id: meta
uses: https://github.com/docker/metadata-action@v5
with:
images: ${{ steps.image.outputs.image }}
tags: |
type=raw,value=nightly
- name: Login to Forgejo registry
uses: https://github.com/docker/login-action@v3
with:
registry: git.revela.dev
username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push image
uses: https://github.com/docker/build-push-action@v6
with:
context: .
file: docker/dedicated-server/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
MC_RUNTIME_DIR=runtime
release-server:
name: Release Server
needs: build-server
runs-on: [self-hosted, linux]
steps:
- name: Checkout
uses: https://github.com/actions/checkout@v6
- name: Download server artifacts
uses: https://github.com/actions/download-artifact@v3
with:
name: server-build
path: artifacts
- name: Attest artifacts
uses: actions/attest-build-provenance@v2
with:
subject-path: |
artifacts/LCE-Revelations-Server-Win64.zip
artifacts/LCE-Revelations-Server-Win64-FourKit.zip
- name: Install jq
run: apt-get update && apt-get install -y --no-install-recommends jq
- name: Get short SHA
id: sha
run: echo "short=$(echo '${{ github.sha }}' | cut -c1-7)" >> "$GITHUB_OUTPUT"
- name: Delete old release
- name: Delete old release and tag
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release delete Nightly-Dedicated-Server --yes || true
- name: Delete old tag
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh api repos/${{ github.repository }}/git/refs/tags/Nightly-Dedicated-Server --method DELETE || true
FORGEJO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
TAG="Nightly-Dedicated-Server"
API="${{ github.server_url }}/api/v1/repos/${{ github.repository }}"
AUTH="Authorization: token $FORGEJO_TOKEN"
EXISTING_ID=$(curl -sf -H "$AUTH" "$API/releases/tags/$TAG" 2>/dev/null | jq -r '.id // empty' || true)
if [ -n "$EXISTING_ID" ]; then
curl -sf -X DELETE -H "$AUTH" "$API/releases/$EXISTING_ID"
fi
curl -s -X DELETE -H "$AUTH" "$API/tags/$TAG" > /dev/null || true
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
uses: https://github.com/crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
@@ -248,60 +323,94 @@ jobs:
git tag -s -f Nightly-Dedicated-Server -m "Nightly server release ${{ steps.sha.outputs.short }}"
git push origin Nightly-Dedicated-Server --force
- name: Create release
- name: Create release on Forgejo
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FORGEJO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create Nightly-Dedicated-Server artifacts/* \
--title "Server: ${{ steps.sha.outputs.short }}" \
--notes "Dedicated Server runtime for Windows64.
set -euo pipefail
TAG="Nightly-Dedicated-Server"
TITLE="Server: ${{ steps.sha.outputs.short }}"
API="${{ github.server_url }}/api/v1/repos/${{ github.repository }}"
AUTH="Authorization: token $FORGEJO_TOKEN"
NOTES=$(cat <<'EOF'
Dedicated Server runtime for Windows64.
Two flavours are attached:
- \`LCE-Revelations-Server-Win64.zip\`: vanilla server, no plugin support, smallest download.
- \`LCE-Revelations-Server-Win64-FourKit.zip\`: server with the FourKit plugin host, bundled .NET 10 runtime, and an empty \`plugins/\` folder ready for plugin authors to drop DLLs into.
- `LCE-Revelations-Server-Win64.zip`: vanilla server, no plugin support, smallest download.
- `LCE-Revelations-Server-Win64-FourKit.zip`: server with the FourKit plugin host, bundled .NET 10 runtime, and an empty `plugins/` folder ready for plugin authors to drop DLLs into.
Pick the flavour you want and extract it to a folder where you'd like to keep the server runtime." \
--latest=false
Pick the flavour you want and extract it to a folder where you'd like to keep the server runtime.
EOF
)
PAYLOAD=$(jq -nc --arg tag "$TAG" --arg name "$TITLE" --arg body "$NOTES" \
'{tag_name:$tag, name:$name, body:$body, draft:false, prerelease:false}')
RID=$(curl -sf -X POST -H "$AUTH" -H "Content-Type: application/json" \
-d "$PAYLOAD" "$API/releases" | jq -r '.id')
if [ -z "$RID" ] || [ "$RID" = "null" ]; then
echo "Failed to create release" >&2
exit 1
fi
echo "Created release id=$RID"
for asset in artifacts/*; do
name=$(basename "$asset")
size=$(stat -c%s "$asset")
echo "Uploading $name ($size bytes)"
HTTP=$(curl -sS -w '%{http_code}' -o /tmp/upload-resp -X POST -H "$AUTH" \
-F "attachment=@$asset" \
"$API/releases/$RID/assets?name=$name")
if [ "$HTTP" -lt 200 ] || [ "$HTTP" -ge 300 ]; then
echo "Upload failed: HTTP $HTTP" >&2
echo "--- response body ---" >&2
cat /tmp/upload-resp >&2 || true
echo "" >&2
exit 1
fi
echo "Uploaded $name OK (HTTP $HTTP)"
done
release-client:
name: Release Client
needs: [build-client, release-server]
runs-on: ubuntu-latest
runs-on: [self-hosted, linux]
steps:
- name: Checkout
uses: actions/checkout@v6
uses: https://github.com/actions/checkout@v6
- name: Download client artifacts
uses: actions/download-artifact@v7
uses: https://github.com/actions/download-artifact@v3
with:
name: client-build
path: artifacts
- name: Attest artifacts
uses: actions/attest-build-provenance@v2
with:
subject-path: |
artifacts/LCE-Revelations-Client-Win64.zip
artifacts/Minecraft.Client.exe
artifacts/Minecraft.Client.pdb
- name: Install jq
run: apt-get update && apt-get install -y --no-install-recommends jq
- name: Get short SHA
id: sha
run: echo "short=$(echo '${{ github.sha }}' | cut -c1-7)" >> "$GITHUB_OUTPUT"
- name: Delete old release
- name: Delete old release and tag
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release delete Nightly --yes || true
- name: Delete old tag
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh api repos/${{ github.repository }}/git/refs/tags/Nightly --method DELETE || true
FORGEJO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
TAG="Nightly"
API="${{ github.server_url }}/api/v1/repos/${{ github.repository }}"
AUTH="Authorization: token $FORGEJO_TOKEN"
EXISTING_ID=$(curl -sf -H "$AUTH" "$API/releases/tags/$TAG" 2>/dev/null | jq -r '.id // empty' || true)
if [ -n "$EXISTING_ID" ]; then
curl -sf -X DELETE -H "$AUTH" "$API/releases/$EXISTING_ID"
fi
curl -s -X DELETE -H "$AUTH" "$API/tags/$TAG" > /dev/null || true
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
uses: https://github.com/crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
@@ -348,22 +457,42 @@ jobs:
- After creating your tunnel, navigate to the "Tunnels" main page. You'll see the IP address and port for your tunnel. This is what your friends will input when adding your server in order to join your online game!
NOTES
- name: Create release
- name: Create release on Forgejo
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FORGEJO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create Nightly artifacts/* \
--title "Client: ${{ steps.sha.outputs.short }}" \
--notes-file notes.md
set -euo pipefail
TAG="Nightly"
TITLE="Client: ${{ steps.sha.outputs.short }}"
API="${{ github.server_url }}/api/v1/repos/${{ github.repository }}"
AUTH="Authorization: token $FORGEJO_TOKEN"
cleanup:
needs: [release-client, release-server]
if: always()
runs-on: ubuntu-latest
steps:
- name: Cleanup artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: |
client-build
server-build
BODY=$(cat notes.md)
PAYLOAD=$(jq -nc --arg tag "$TAG" --arg name "$TITLE" --arg body "$BODY" \
'{tag_name:$tag, name:$name, body:$body, draft:false, prerelease:false}')
RID=$(curl -sf -X POST -H "$AUTH" -H "Content-Type: application/json" \
-d "$PAYLOAD" "$API/releases" | jq -r '.id')
if [ -z "$RID" ] || [ "$RID" = "null" ]; then
echo "Failed to create release" >&2
exit 1
fi
echo "Created release id=$RID"
for asset in artifacts/*; do
name=$(basename "$asset")
size=$(stat -c%s "$asset")
echo "Uploading $name ($size bytes)"
HTTP=$(curl -sS -w '%{http_code}' -o /tmp/upload-resp -X POST -H "$AUTH" \
-F "attachment=@$asset" \
"$API/releases/$RID/assets?name=$name")
if [ "$HTTP" -lt 200 ] || [ "$HTTP" -ge 300 ]; then
echo "Upload failed: HTTP $HTTP" >&2
echo "--- response body ---" >&2
cat /tmp/upload-resp >&2 || true
echo "" >&2
exit 1
fi
echo "Uploaded $name OK (HTTP $HTTP)"
done
+8 -6
View File
@@ -11,25 +11,27 @@ on:
jobs:
build:
runs-on: windows-latest
runs-on: [self-hosted, windows]
steps:
- name: Checkout
uses: actions/checkout@v6
uses: https://github.com/actions/checkout@v6
with:
submodules: recursive
- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1
uses: https://github.com/ilammy/msvc-dev-cmd@v1
- name: Setup CMake
uses: lukka/get-cmake@latest
uses: https://github.com/lukka/get-cmake@latest
- name: Setup .NET
uses: actions/setup-dotnet@v4
uses: https://github.com/actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Run CMake
uses: lukka/run-cmake@v10
uses: https://github.com/lukka/run-cmake@v10
env:
VCPKG_ROOT: "" # Disable vcpkg for CI builds
with:
+3
View File
@@ -0,0 +1,3 @@
[submodule "Minecraft.Client/Windows64/4JLibs"]
path = Minecraft.Client/Windows64/4JLibs
url = https://github.com/itsRevela/4JLibs.git
+2
View File
@@ -81,6 +81,8 @@ list(APPEND MINECRAFT_SHARED_DEFINES ${PLATFORM_DEFINES})
# ---
# Sources
# ---
add_subdirectory("Minecraft.Client/${PLATFORM_NAME}/4JLibs")
add_subdirectory(Minecraft.World)
add_subdirectory(Minecraft.Client)
if(PLATFORM_NAME STREQUAL "Windows64") # Server is only supported on Windows for now
+2 -1
View File
@@ -15,7 +15,8 @@
VS 2022 has built-in CMake support, so there is no need to generate a `.sln` file by hand.
1. Install the prerequisites above.
2. Clone the repo.
2. Clone the repo with submodules. If you don't, you will get a build error!
- `git clone --recurse-submodules https://github.com/itsRevela/LCE-Revelations.git`
3. In Visual Studio: `File > Open > Folder...` and select the **repo root** (the folder that contains `CMakeLists.txt`).
4. Wait for CMake to configure (~5 seconds on a warm cache, a few minutes on the first run while assets copy).
5. Pick a build configuration in the dropdown, for example `windows64-release`.
+1 -1
View File
@@ -104,7 +104,7 @@ byteArray ArchiveFile::getFile(const wstring &filename)
app.DebugPrintf("Couldn't find file in archive\n");
app.DebugPrintf("Failed to find file '%ls' in archive\n", filename.c_str());
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
app.FatalLoadError();
}
+18 -19
View File
@@ -6,6 +6,8 @@
ResourceLocation BeaconRenderer::BEAM_LOCATION = ResourceLocation(TN_MISC_BEACON_BEAM);
bool BeaconRenderer::s_renderOuterHalo = false;
void BeaconRenderer::render(shared_ptr<TileEntity> _beacon, double x, double y, double z, float a, bool setColor, float alpha, bool useCompiled)
{
shared_ptr<BeaconTileEntity> beacon = dynamic_pointer_cast<BeaconTileEntity>(_beacon);
@@ -18,21 +20,18 @@ void BeaconRenderer::render(shared_ptr<TileEntity> _beacon, double x, double y,
bindTexture(&BEAM_LOCATION);
// TODO: 4J: Put this back in
//assert(0);
//glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
//glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glDisable(GL_LIGHTING);
glDisable(GL_CULL_FACE);
glDisable(GL_BLEND);
glDepthMask(true);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
float tt = beacon->getLevel()->getGameTime() + a;
float texVOff = -tt * .20f - floor(-tt * .10f);
if (!s_renderOuterHalo)
{
glDisable(GL_BLEND);
glDepthMask(true);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
int r = 1;
double rot = tt * .025 * (1 - (r & 1) * 2.5);
@@ -73,20 +72,20 @@ void BeaconRenderer::render(shared_ptr<TileEntity> _beacon, double x, double y,
t->vertexUV(x + enx, y, z + enz, uu2, vv2);
t->vertexUV(x + esx, y, z + esz, uu1, vv2);
t->vertexUV(x + esx, y + top, z + esz, uu1, vv1);
t->vertexUV(x + wsx, y + top, z + wsz, uu2, vv1);
t->vertexUV(x + wsx, y, z + wsz, uu2, vv2);
t->vertexUV(x + wnx, y, z + wnz, uu1, vv2);
t->vertexUV(x + wnx, y + top, z + wnz, uu1, vv1);
t->end();
}
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthMask(false);
else
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthMask(false);
t->begin();
t->color(255, 255, 255, 32);
@@ -111,22 +110,22 @@ void BeaconRenderer::render(shared_ptr<TileEntity> _beacon, double x, double y,
t->vertexUV(x + wnx, y, z + wnz, uu2, vv2);
t->vertexUV(x + enx, y, z + enz, uu1, vv2);
t->vertexUV(x + enx, y + top, z + enz, uu1, vv1);
t->vertexUV(x + esx, y + top, z + esz, uu2, vv1);
t->vertexUV(x + esx, y, z + esz, uu2, vv2);
t->vertexUV(x + wsx, y, z + wsz, uu1, vv2);
t->vertexUV(x + wsx, y + top, z + wsz, uu1, vv1);
t->vertexUV(x + enx, y + top, z + enz, uu2, vv1);
t->vertexUV(x + enx, y, z + enz, uu2, vv2);
t->vertexUV(x + esx, y, z + esz, uu1, vv2);
t->vertexUV(x + esx, y + top, z + esz, uu1, vv1);
t->vertexUV(x + wsx, y + top, z + wsz, uu2, vv1);
t->vertexUV(x + wsx, y, z + wsz, uu2, vv2);
t->vertexUV(x + wnx, y, z + wnz, uu1, vv2);
t->vertexUV(x + wnx, y + top, z + wnz, uu1, vv1);
t->end();
}
+2
View File
@@ -9,5 +9,7 @@ private:
static ResourceLocation BEAM_LOCATION;
public:
static bool s_renderOuterHalo;
virtual void render(shared_ptr<TileEntity> _beacon, double x, double y, double z, float a, bool setColor, float alpha, bool useCompiled);
};
+4 -10
View File
@@ -57,16 +57,10 @@ target_link_libraries(Minecraft.Client PRIVATE
XInput9_1_0
wsock32
legacy_stdio_definitions
$<$<CONFIG:Debug>: # Debug 4J libraries
"${CMAKE_CURRENT_SOURCE_DIR}/${PLATFORM_NAME}/4JLibs/libs/4J_Input_d.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/${PLATFORM_NAME}/4JLibs/libs/4J_Storage_d.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/${PLATFORM_NAME}/4JLibs/libs/4J_Render_PC_d.lib"
>
$<$<NOT:$<CONFIG:Debug>>: # Release 4J libraries
"${CMAKE_CURRENT_SOURCE_DIR}/${PLATFORM_NAME}/4JLibs/libs/4J_Input.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/${PLATFORM_NAME}/4JLibs/libs/4J_Storage.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/${PLATFORM_NAME}/4JLibs/libs/4J_Render_PC.lib"
>
4JLibs.${PLATFORM_NAME}.Input
4JLibs.${PLATFORM_NAME}.Profile
4JLibs.${PLATFORM_NAME}.Storage
4JLibs.${PLATFORM_NAME}.Render
)
# Iggy libs
+1 -1
View File
@@ -1016,7 +1016,7 @@ bool Chunk::isEmpty()
void Chunk::setDirty()
{
// 4J - not used, but if this starts being used again then we'll need to investigate how best to handle it.
__debugbreak();
DEBUG_BREAK();
levelRenderer->setGlobalChunkFlag(x, y, z, level, LevelRenderer::CHUNK_FLAG_DIRTY);
}
@@ -595,23 +595,26 @@ void SoundEngine::playUI(int iSound, float volume, float pitch)
{
U8 szSoundName[256];
wstring name;
const char* soundDir;
if (iSound >= eSFX_MAX)
{
strcpy((char*)szSoundName, "Minecraft/");
name = wchSoundNames[iSound];
soundDir = "Minecraft";
}
else
{
strcpy((char*)szSoundName, "Minecraft/UI/");
name = wchUISoundNames[iSound];
soundDir = "Minecraft/UI";
}
char* SoundName = (char*)ConvertSoundPathToName(name);
strcat((char*)szSoundName, SoundName);
char basePath[256];
sprintf_s(basePath, "Windows64Media/Sound/Minecraft/UI/%s", ConvertSoundPathToName(name));
sprintf_s(basePath, "Windows64Media/Sound/%s/%s", soundDir, ConvertSoundPathToName(name));
char finalPath[256];
+2 -5
View File
@@ -96,7 +96,7 @@ CMinecraftApp::CMinecraftApp()
// 4J Stu - See comment for GAME_SETTINGS_PROFILE_DATA_BYTES in Xbox_App.h
DebugPrintf("WARNING: The size of the profile GAME_SETTINGS struct has changed, so all stat data is likely incorrect. Is: %d, Should be: %d\n",sizeof(GAME_SETTINGS),GAME_SETTINGS_PROFILE_DATA_BYTES);
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
}
@@ -1303,9 +1303,6 @@ int CMinecraftApp::OldProfileVersionCallback(LPVOID pParam,unsigned char *pucDat
{
// This might be from a version during testing of new profile updates
app.DebugPrintf("Don't know what to do with this profile version!\n");
#ifndef _CONTENT_PACKAGE
// __debugbreak();
#endif
GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData;
pGameSettings->ucMenuSensitivity=100; //eGameSetting_Sensitivity_InMenu
@@ -6479,7 +6476,7 @@ void CMinecraftApp::InitialiseTips()
{
// the m_TriviaTipA or the m_GameTipA are out of sync
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
}
}
+1 -2
View File
@@ -171,7 +171,7 @@ DLCPack *DLCManager::getPack(DWORD index, EDLCType type /*= e_DLCType_All*/)
if(index >= m_packs.size())
{
app.DebugPrintf("DLCManager: Trying to access a DLC pack beyond the range of valid packs\n");
__debugbreak();
DEBUG_BREAK();
}
pack = m_packs[index];
}
@@ -186,7 +186,6 @@ DWORD DLCManager::getPackIndex(DLCPack *pack, bool &found, EDLCType type /*= e_D
if(pack == nullptr)
{
app.DebugPrintf("DLCManager: Attempting to find the index for a nullptr pack\n");
//__debugbreak();
return foundIndex;
}
if( type != e_DLCType_All )
+2 -5
View File
@@ -107,7 +107,7 @@ void DLCPack::addChildPack(DLCPack *childPack)
#ifndef _CONTENT_PACKAGE
if(packId < 0 || packId > 15)
{
__debugbreak();
DEBUG_BREAK();
}
#endif
childPack->SetPackId( (packId<<24) | m_packId );
@@ -362,7 +362,7 @@ DWORD DLCPack::getFileIndexAt(DLCManager::EDLCType type, const wstring &path, bo
{
app.DebugPrintf("Unimplemented\n");
#ifndef __CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
return 0;
}
@@ -392,9 +392,6 @@ bool DLCPack::hasPurchasedFile(DLCManager::EDLCType type, const wstring &path)
/*if(type == DLCManager::e_DLCType_All)
{
app.DebugPrintf("Unimplemented\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
#endif
return false;
}
#ifndef _CONTENT_PACKAGE
@@ -122,7 +122,7 @@ void ConsoleSchematicFile::load(DataInputStream *dis)
{
#ifndef _CONTENT_PACKAGE
app.DebugPrintf("ConsoleSchematicFile has read a nullptr tile entity\n");
__debugbreak();
DEBUG_BREAK();
#endif
}
else
@@ -635,7 +635,7 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l
}
#ifndef _CONTENT_PACKAGE
if(p!=blockCount) __debugbreak();
if(p!=blockCount) DEBUG_BREAK();
#endif
// We don't know how this will compress - just make a fixed length buffer to initially decompress into
@@ -24,7 +24,7 @@ GameRule::ValueType GameRule::getParameter(const wstring &parameterName)
{
#ifndef _CONTENT_PACKAGE
wprintf(L"WARNING: Parameter %ls was not set before being fetched\n", parameterName.c_str());
__debugbreak();
DEBUG_BREAK();
#endif
}
return m_parameters[parameterName];
@@ -238,7 +238,7 @@ HRESULT SonyLeaderboardManager::fillByIdsQuery(const SceNpId &myNpId, SceNpId* &
{
// 4J-JEV: Something terrible must have happend,
// 'getFriendslist' was supposed to be a synchronous operation.
__debugbreak();
DEBUG_BREAK();
// 4J-JEV: We can at least fall-back to just the players score.
len = 1;
@@ -247,8 +247,6 @@ void CPlatformNetworkManagerSony::HandlePlayerJoined(SQRNetworkPlayer *
void CPlatformNetworkManagerSony::HandlePlayerLeaving(SQRNetworkPlayer *pSQRPlayer)
{
//__debugbreak();
app.DebugPrintf( "Player 0x%p leaving.\n",
pSQRPlayer );
+17 -24
View File
@@ -327,7 +327,7 @@ void UIScene::loadMovie()
{
app.DebugPrintf("ERROR: Could not find any iggy movie for %ls!\n", moviePath.c_str());
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
app.FatalLoadError();
}
@@ -343,7 +343,7 @@ void UIScene::loadMovie()
{
app.DebugPrintf("ERROR: Failed to load iggy scene!\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
app.FatalLoadError();
}
@@ -949,9 +949,6 @@ void UIScene::_customDrawSlotControl(CustomDrawData *region, int iPad, shared_pt
// if(m_parentLayer == nullptr)
// {
// app.DebugPrintf("A scene is trying to navigate forwards, but it's parent layer is nullptr!\n");
//#ifndef _CONTENT_PACKAGE
// __debugbreak();
//#endif
// }
// else
// {
@@ -968,10 +965,6 @@ void UIScene::navigateBack()
if(m_parentLayer == nullptr)
{
// app.DebugPrintf("A scene is trying to navigate back, but it's parent layer is nullptr!\n");
#ifndef _CONTENT_PACKAGE
// __debugbreak();
#endif
}
else
{
@@ -1202,7 +1195,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
{
app.DebugPrintf("Callback for handlePress did not have the correct number of arguments\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
return;
}
@@ -1210,7 +1203,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
{
app.DebugPrintf("Arguments for handlePress were not of the correct type\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
return;
}
@@ -1222,7 +1215,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
{
app.DebugPrintf("Callback for handleFocusChange did not have the correct number of arguments\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
return;
}
@@ -1230,7 +1223,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
{
app.DebugPrintf("Arguments for handleFocusChange were not of the correct type\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
return;
}
@@ -1242,7 +1235,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
{
app.DebugPrintf("Callback for handleInitFocus did not have the correct number of arguments\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
return;
}
@@ -1250,7 +1243,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
{
app.DebugPrintf("Arguments for handleInitFocus were not of the correct type\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
return;
}
@@ -1262,7 +1255,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
{
app.DebugPrintf("Callback for handleCheckboxToggled did not have the correct number of arguments\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
return;
}
@@ -1270,7 +1263,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
{
app.DebugPrintf("Arguments for handleCheckboxToggled were not of the correct type\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
return;
}
@@ -1282,7 +1275,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
{
app.DebugPrintf("Callback for handleSliderMove did not have the correct number of arguments\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
return;
}
@@ -1290,7 +1283,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
{
app.DebugPrintf("Arguments for handleSliderMove were not of the correct type\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
return;
}
@@ -1302,7 +1295,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
{
app.DebugPrintf("Callback for handleAnimationEnd did not have the correct number of arguments\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
return;
}
@@ -1314,7 +1307,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
{
app.DebugPrintf("Callback for handleSelectionChanged did not have the correct number of arguments\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
return;
}
@@ -1322,7 +1315,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
{
app.DebugPrintf("Arguments for handleSelectionChanged were not of the correct type\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
return;
}
@@ -1340,7 +1333,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
{
app.DebugPrintf("Callback for handleRequestMoreData did not have the correct number of arguments\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
return;
}
@@ -1348,7 +1341,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
{
app.DebugPrintf("Arguments for handleRequestMoreData were not of the correct type\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
return;
}
@@ -390,7 +390,7 @@ void UIScene_MainMenu::handlePress(F64 controlId, F64 childId)
break;
#endif
default: __debugbreak();
default: DEBUG_BREAK();
}
bool confirmUser = false;
+2 -2
View File
@@ -106,7 +106,7 @@ wstring DLCTexturePack::getResource(const wstring& name)
{
// 4J Stu - We should never call this function
#ifndef __CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
return L"";
}
@@ -115,7 +115,7 @@ InputStream *DLCTexturePack::getResourceImplementation(const wstring &name) //th
{
// 4J Stu - We should never call this function
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
if(hasFile(name)) return nullptr;
#endif
return nullptr; //resource;
+1 -1
View File
@@ -641,7 +641,7 @@ int CConsoleMinecraftApp::Callback_TMSPPReadDLCFile(void *pParam,int iPad, int i
{
DWORD error = GetLastError();
app.DebugPrintf("Failed to open DLCXbox1.cmp with error code %d (%x)\n", error, error);
__debugbreak();
DEBUG_BREAK();
return 0;
}
@@ -20,7 +20,7 @@ void ConsoleUIController::init(Microsoft::WRL::ComPtr<ID3D11Device> dev, Microso
{
app.DebugPrintf("Failed to initialise GDraw!\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
app.FatalLoadError();
}
@@ -1619,7 +1619,7 @@ RADDEFSTART
#define RR_BREAK() __builtin_trap()
#define RR_CACHE_LINE_SIZE 32
#elif defined(__RADXENON__)
#define RR_BREAK() __debugbreak()
#define RR_BREAK() DEBUG_BREAK()
#define RR_CACHE_LINE_SIZE 128
#elif defined(__RADANDROID__)
#define RR_BREAK() __builtin_trap()
@@ -1619,7 +1619,7 @@ RADDEFSTART
#define RR_BREAK() __builtin_trap()
#define RR_CACHE_LINE_SIZE 32
#elif defined(__RADXENON__)
#define RR_BREAK() __debugbreak()
#define RR_BREAK() DEBUG_BREAK()
#define RR_CACHE_LINE_SIZE 128
#elif defined(__RADANDROID__)
#define RR_BREAK() __builtin_trap()
@@ -187,8 +187,6 @@ void CPlatformNetworkManagerDurango::HandlePlayerJoined(DQRNetworkPlayer *pDQRPl
void CPlatformNetworkManagerDurango::HandlePlayerLeaving(DQRNetworkPlayer *pDQRPlayer)
{
//__debugbreak();
app.DebugPrintf( "Player 0x%p leaving.\n",
pDQRPlayer );
+1 -1
View File
@@ -187,7 +187,7 @@ EntityRenderer *EntityRenderDispatcher::getRenderer(eINSTANCEOF e)
{
app.DebugPrintf("Couldn't find renderer for entity of type %d\n", e);
// New renderer mapping required in above table
__debugbreak();
DEBUG_BREAK();
}
/* 4J - not doing this hierarchical search anymore. We need to explicitly add renderers for any eINSTANCEOF type that we want to be able to render
if (it == renderers.end() && e != Entity::_class)
+1 -1
View File
@@ -87,7 +87,7 @@ void EntityTracker::addEntity(shared_ptr<Entity> e, int range, int updateInterva
}
if( e->entityId >= 16384 )
{
__debugbreak();
DEBUG_BREAK();
}
shared_ptr<TrackedEntity> te = std::make_shared<TrackedEntity>(e, range, updateInterval, trackDeltas);
entities.insert(te);
+5 -1
View File
@@ -1558,6 +1558,10 @@ void GameRenderer::renderLevel(float a, int64_t until)
PIXEndNamedEvent();
}
PIXBeginNamedEvent(0,"Beacon beam halo (after water)");
levelRenderer->renderBeaconBeams(a);
PIXEndNamedEvent();
// 4J - added - have split out translucent particle rendering so that it happens after the water is rendered, primarily for fireworks
PIXBeginNamedEvent(0,"Particle render (translucent)");
Lighting::turnOn();
@@ -2112,7 +2116,7 @@ void GameRenderer::setupFog(int i, float alpha)
if (i == 999)
{
__debugbreak();
DEBUG_BREAK();
// 4J TODO
/*
glFog(GL_FOG_COLOR, getBuffer(0, 0, 0, 1));
+25
View File
@@ -6,6 +6,7 @@
#include "Chunk.h"
#include "EntityRenderDispatcher.h"
#include "TileEntityRenderDispatcher.h"
#include "BeaconRenderer.h"
#include "DistanceChunkSorter.h"
#include "DirtyChunkSorter.h"
#include "MobSkinTextureProcessor.h"
@@ -653,6 +654,30 @@ void LevelRenderer::renderEntities(Vec3 *cam, Culler *culler, float a)
mc->gameRenderer->turnOffLightLayer(a); // 4J - brought forward from 1.8.2
}
void LevelRenderer::renderBeaconBeams(float a)
{
if (mc == nullptr || mc->player == nullptr) return;
int playerIndex = mc->player->GetXboxPad();
if (level[playerIndex] == nullptr) return;
BeaconRenderer::s_renderOuterHalo = true;
EnterCriticalSection(&m_csRenderableTileEntities);
for (auto & it : renderableTileEntities)
{
if (!isGlobalIndexInSameDimension(it.first, level[playerIndex])) continue;
for (auto& te : it.second)
{
if (te->GetType() != eTYPE_BEACONTILEENTITY) continue;
TileEntityRenderDispatcher::instance->render(te, a);
}
}
LeaveCriticalSection(&m_csRenderableTileEntities);
BeaconRenderer::s_renderOuterHalo = false;
}
wstring LevelRenderer::gatherStats1()
{
return L"C: " + std::to_wstring(renderedChunks) + L"/" + std::to_wstring(totalChunks) + L". F: " + std::to_wstring(offscreenChunks) + L", O: " + std::to_wstring(occludedChunks) + L", E: " + std::to_wstring(emptyChunks);
+1
View File
@@ -77,6 +77,7 @@ public:
void AddDLCSkinsToMemTextures();
public:
void renderEntities(Vec3 *cam, Culler *culler, float a);
void renderBeaconBeams(float a);
wstring gatherStats1();
wstring gatherStats2();
private:
+2 -9
View File
@@ -164,14 +164,7 @@ bool LocalPlayer::isEffectiveAi()
void LocalPlayer::aiStep()
{
if (sprintTime > 0)
{
sprintTime--;
if (sprintTime == 0)
{
setSprinting(false);
}
}
if (sprintTime > 0) sprintTime--;
if (sprintTriggerTime > 0) sprintTriggerTime--;
if (minecraft->gameMode->isCutScene())
{
@@ -518,7 +511,7 @@ void LocalPlayer::changeDimension(int i)
//minecraft.setScreen(new WinScreen());
#ifndef _CONTENT_PACKAGE
app.DebugPrintf("LocalPlayer::changeDimension from 1 to 1 but WinScreen has not been implemented.\n");
__debugbreak();
DEBUG_BREAK();
#endif
}
else
+1 -1
View File
@@ -4812,7 +4812,7 @@ void Minecraft::main()
app.DebugPrintf("<xs:enumeration value=\"%d\"><xs:annotation><xs:documentation>%ls</xs:documentation></xs:annotation></xs:enumeration>\n", i, app.GetString( Tile::tiles[i]->getDescriptionId() ));
}
}
__debugbreak();
DEBUG_BREAK();
#endif
// 4J-PB - Can't call this for the first 5 seconds of a game - MS rule
+180 -14
View File
@@ -85,6 +85,9 @@ vector<INetworkPlayer *> MinecraftServer::s_sentTo;
int MinecraftServer::s_slowQueuePlayerIndex = 0;
int MinecraftServer::s_slowQueueLastTime = 0;
bool MinecraftServer::s_slowQueuePacketSent = false;
#ifdef MINECRAFT_SERVER_BUILD
int MinecraftServer::s_dedicatedChunkSendsThisTick = 0;
#endif
#endif
unordered_map<wstring, int> MinecraftServer::ironTimers;
@@ -1541,6 +1544,12 @@ void MinecraftServer::stopServer(bool didInit)
}
}
}
// connection->stop() enqueued disconnects; the run loop is gone, so
// drain now or DisconnectPacket + sendAndQuit() never fire.
if (players != nullptr)
{
players->drainPendingDisconnects();
}
// reset the primary player signout flag
m_bPrimaryPlayerSignedOut=false;
s_bServerHalted = false;
@@ -1770,6 +1779,12 @@ void MinecraftServer::run(int64_t seed, void *lpParameter)
int64_t unprocessedTime = 0;
while (running && !s_bServerHalted)
{
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
// Full wall-clock cost of one run loop iteration (catch-up ticks
// + setTime handlers + XUI delayed actions + Sleep).
int64_t outerIterStart = getCurrentTimeMillis();
int64_t outerIterTickWork = 0;
#endif
int64_t now = getCurrentTimeMillis();
// 4J Stu - When we pause the server, we don't want to count that as time passed
@@ -1807,15 +1822,39 @@ void MinecraftServer::run(int64_t seed, void *lpParameter)
while (unprocessedTime > MS_PER_TICK)
{
unprocessedTime -= MS_PER_TICK;
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
// Per-iteration pre/tick/post timing.
int64_t iter_t0 = System::currentTimeMillis();
#endif
chunkPacketManagement_PreTick();
// int64_t before = System::currentTimeMillis();
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
int64_t iter_t1 = System::currentTimeMillis();
#endif
tick();
// int64_t after = System::currentTimeMillis();
// PIXReportCounter(L"Server time",(float)(after-before));
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
int64_t iter_t2 = System::currentTimeMillis();
#endif
chunkPacketManagement_PostTick();
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
int64_t iter_t3 = System::currentTimeMillis();
int64_t iter_total = iter_t3 - iter_t0;
outerIterTickWork += iter_total;
if (iter_total > 200)
{
ServerRuntime::LogInfof("perf",
"iter total=%lldms pre=%lld tick=%lld post=%lld",
(long long)iter_total,
(long long)(iter_t1 - iter_t0),
(long long)(iter_t2 - iter_t1),
(long long)(iter_t3 - iter_t2));
}
#endif
}
lastTime = getCurrentTimeMillis();
// Do NOT reset lastTime here. Resetting discards the wall
// time spent in the catch-up so passedTime restarts from
// post-tick, capping effective TPS at 1000 / (MS_PER_TICK
// + avgTickBody). Runaway after a real freeze is bounded
// by the passedTime > MS_PER_TICK * 40 cap above.
// int64_t afterall = System::currentTimeMillis();
// PIXReportCounter(L"Server time all",(float)(afterall-beforeall));
// PIXReportCounter(L"Server ticks",(float)tickcount);
@@ -2101,6 +2140,73 @@ void MinecraftServer::run(int64_t seed, void *lpParameter)
}
Sleep(1);
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
int64_t outerIterTotal = getCurrentTimeMillis() - outerIterStart;
// Distribution histogram (gated). Buckets every outer iter, dumps
// the bucket counts + a self-computed TPS every ~10 seconds.
if (ServerRuntime::g_serverPerfTrace)
{
static const int kBucketCount = 14;
static int64_t s_bucketEdges[kBucketCount] = {
2, 5, 10, 20, 30, 40, 50, 60, 80, 100, 200, 500, 1000, INT64_MAX
};
static unsigned int s_buckets[kBucketCount] = {0};
static int64_t s_histWindowStartMs = 0;
static int s_histWindowStartTick = 0;
static int64_t s_histTotalIterMs = 0;
static unsigned int s_histTotalIters = 0;
static unsigned int s_histTickIters = 0;
int64_t nowMsForHist = getCurrentTimeMillis();
if (s_histWindowStartMs == 0)
{
s_histWindowStartMs = nowMsForHist;
s_histWindowStartTick = (int)tickCount;
}
for (int b = 0; b < kBucketCount; b++)
{
if (outerIterTotal <= s_bucketEdges[b])
{
s_buckets[b]++;
break;
}
}
s_histTotalIterMs += outerIterTotal;
s_histTotalIters++;
if (outerIterTickWork > 0) s_histTickIters++;
int ticksThisWindow = (int)tickCount - s_histWindowStartTick;
if (ticksThisWindow >= 200)
{
int64_t windowMs = nowMsForHist - s_histWindowStartMs;
double calcTps = windowMs > 0 ? (ticksThisWindow * 1000.0) / windowMs : 0.0;
double avgIterMs = s_histTotalIters > 0 ? (double)s_histTotalIterMs / s_histTotalIters : 0.0;
ServerRuntime::LogInfof("perf",
"histogram window: %d ticks in %lldms calcTps=%.2f iters=%u tickIters=%u avgIter=%.2fms | "
"<=2:%u <=5:%u <=10:%u <=20:%u <=30:%u <=40:%u <=50:%u <=60:%u <=80:%u <=100:%u <=200:%u <=500:%u <=1000:%u >1000:%u",
ticksThisWindow, (long long)windowMs, calcTps,
s_histTotalIters, s_histTickIters, avgIterMs,
s_buckets[0], s_buckets[1], s_buckets[2], s_buckets[3],
s_buckets[4], s_buckets[5], s_buckets[6], s_buckets[7],
s_buckets[8], s_buckets[9], s_buckets[10], s_buckets[11],
s_buckets[12], s_buckets[13]);
for (int b = 0; b < kBucketCount; b++) s_buckets[b] = 0;
s_histWindowStartMs = nowMsForHist;
s_histWindowStartTick = (int)tickCount;
s_histTotalIterMs = 0;
s_histTotalIters = 0;
s_histTickIters = 0;
}
}
if (outerIterTotal > 200)
{
ServerRuntime::LogInfof("perf",
"outerIter total=%lldms tickWork=%lld postTickOverhead=%lld",
(long long)outerIterTotal,
(long long)outerIterTickWork,
(long long)(outerIterTotal - outerIterTickWork));
}
#endif
}
}
//else
@@ -2155,6 +2261,17 @@ void MinecraftServer::broadcastStopSavingPacket()
void MinecraftServer::tick()
{
// Per-substep wall-clock timing. Logs one summary line when total tick
// exceeds TICK_SLOW_THRESHOLD_MS.
const int64_t TICK_SLOW_THRESHOLD_MS = 200;
const int kMaxLevelsRecorded = 8;
int64_t tickStart = System::currentTimeMillis();
int64_t lvlTickMs[kMaxLevelsRecorded] = {0};
int64_t lvlEntMs[kMaxLevelsRecorded] = {0};
int64_t lvlTrkMs[kMaxLevelsRecorded] = {0};
int lvlDimId[kMaxLevelsRecorded] = {0};
unsigned int recordedLevels = 0;
vector<wstring> toRemove;
for ( auto& it : ironTimers )
{
@@ -2218,13 +2335,9 @@ void MinecraftServer::tick()
int64_t st2 = System::currentTimeMillis();
PIXEndNamedEvent();
PIXBeginNamedEvent(0,"Entity tick %d",i);
// 4J added to stop ticking entities in levels when players are not in those levels.
// Note: now changed so that we also tick if there are entities to be removed, as this also happens as a result of calling tickEntities. If we don't do this, then the
// entities get removed at the first point that there is a player count in the level - this has been causing a problem when going from normal dimension -> nether -> normal,
// as the player is getting flagged as to be removed (from the normal dimension) when going to the nether, but Actually gets removed only when it returns
if( ( players->getPlayerCount(level) > 0) || ( level->hasEntitiesToRemove() ) )
{
#ifdef __PSVITA__
if ((players->getPlayerCount(level) > 0) || level->hasEntitiesToRemove())
{
// AP - the PlayerList->viewDistance initially starts out at 3 to make starting a level speedy
// the problem with this is that spawned monsters are always generated on the edge of the known map
// which means they wont process (unless they are surrounded by 2 visible chunks). This means
@@ -2234,11 +2347,13 @@ void MinecraftServer::tick()
level->getServer()->getPlayers()->setViewDistance(newViewDistance);
level->getTracker()->updateMaxRange();
level->getChunkMap()->setRadius(level->getServer()->getPlayers()->getViewDistance());
#endif
level->tickEntities();
}
#endif
level->tickEntities();
PIXEndNamedEvent();
int64_t stEntDone = System::currentTimeMillis();
PIXBeginNamedEvent(0,"Entity tracker tick");
level->getTracker()->tick();
PIXEndNamedEvent();
@@ -2247,9 +2362,21 @@ void MinecraftServer::tick()
// printf(">>>>>>>>>>>>>>>>>>>>>> Tick %d %d %d : %d\n", st1 - st0, st2 - st1, st3 - st2, st0 - stc );
stc = st0;
// #endif// __PS3__
// Record per-level breakdown for the slow-tick summary.
if (i < kMaxLevelsRecorded)
{
lvlTickMs[i] = st1 - st0; // Level::tick (mob spawner, chunk source, tile ticks, etc.)
lvlEntMs[i] = stEntDone - st2; // tickEntities (per-entity AI/physics)
lvlTrkMs[i] = st3 - stEntDone; // EntityTracker::tick (visibility & broadcasts)
lvlDimId[i] = level->dimension->id;
recordedLevels = i + 1;
}
}
}
int64_t afterLevels = System::currentTimeMillis();
Entity::tickExtraWandering(); // 4J added
int64_t afterExtraW = System::currentTimeMillis();
// Process player disconnect/kick queue BEFORE ticking connections.
// PendingConnection::handleLogin rejects duplicate XUIDs, so the old
@@ -2258,9 +2385,11 @@ void MinecraftServer::tick()
PIXBeginNamedEvent(0,"Players tick");
players->tick();
PIXEndNamedEvent();
int64_t afterPlayers = System::currentTimeMillis();
PIXBeginNamedEvent(0,"Connection tick");
connection->tick();
PIXEndNamedEvent();
int64_t afterConn = System::currentTimeMillis();
// 4J - removed
#if 0
@@ -2274,6 +2403,35 @@ void MinecraftServer::tick()
// } catch (Exception e) {
// logger.log(Level.WARNING, "Unexpected exception while parsing console command", e);
// }
int64_t totalMs = System::currentTimeMillis() - tickStart;
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
if (totalMs > TICK_SLOW_THRESHOLD_MS)
{
// Build a single one-line breakdown so it greps cleanly. Per-level:
// Level::tick / tickEntities / tracker tick. Then global subsystems.
char buf[512];
int n = 0;
for (unsigned int i = 0; i < recordedLevels && n >= 0 && n < (int)sizeof(buf); i++)
{
n += snprintf(buf + n, sizeof(buf) - n,
" L%d:tick=%lld ent=%lld trk=%lld",
lvlDimId[i],
(long long)lvlTickMs[i],
(long long)lvlEntMs[i],
(long long)lvlTrkMs[i]);
}
ServerRuntime::LogInfof("perf",
"slow tick total=%lldms%s | extraW=%lld players=%lld conn=%lld",
(long long)totalMs,
buf,
(long long)(afterExtraW - afterLevels),
(long long)(afterPlayers - afterExtraW),
(long long)(afterConn - afterPlayers));
}
#else
(void)totalMs;
#endif
}
void MinecraftServer::handleConsoleInput(const wstring& msg, ConsoleInputSource *source)
@@ -2417,7 +2575,9 @@ bool MinecraftServer::chunkPacketManagement_CanSendTo(INetworkPlayer *player)
if( player == nullptr ) return false;
#ifdef MINECRAFT_SERVER_BUILD
return true;
// Cap chunk-data sends per tick. Other players are served on later ticks
// via the per-tick rotation in ServerConnection::tick.
return s_dedicatedChunkSendsThisTick < DEDICATED_MAX_CHUNK_SENDS_PER_TICK;
#else
int time = GetTickCount();
DWORD currentPlayerCount = g_NetworkManager.GetPlayerCount();
@@ -2436,10 +2596,16 @@ bool MinecraftServer::chunkPacketManagement_CanSendTo(INetworkPlayer *player)
void MinecraftServer::chunkPacketManagement_DidSendTo(INetworkPlayer *player)
{
s_slowQueuePacketSent = true;
#ifdef MINECRAFT_SERVER_BUILD
s_dedicatedChunkSendsThisTick++;
#endif
}
void MinecraftServer::chunkPacketManagement_PreTick()
{
#ifdef MINECRAFT_SERVER_BUILD
s_dedicatedChunkSendsThisTick = 0;
#endif
}
void MinecraftServer::chunkPacketManagement_PostTick()
+6
View File
@@ -258,6 +258,12 @@ private:
static int s_slowQueuePlayerIndex;
static int s_slowQueueLastTime;
static bool s_slowQueuePacketSent;
#ifdef MINECRAFT_SERVER_BUILD
// Cap on chunk-data packet sends per tick. Paired with per-tick rotation
// in ServerConnection::tick so every player gets a turn even when bound.
static int s_dedicatedChunkSendsThisTick;
static const int DEDICATED_MAX_CHUNK_SENDS_PER_TICK = 10;
#endif
#endif
bool IsServerPaused() { return m_isServerPaused; }
+1 -1
View File
@@ -1619,7 +1619,7 @@ RADDEFSTART
#define RR_BREAK() __builtin_trap()
#define RR_CACHE_LINE_SIZE 32
#elif defined(__RADXENON__)
#define RR_BREAK() __debugbreak()
#define RR_BREAK() DEBUG_BREAK()
#define RR_CACHE_LINE_SIZE 128
#elif defined(__RADANDROID__)
#define RR_BREAK() __builtin_trap()
@@ -245,7 +245,7 @@ bool OrbisLeaderboardManager::getScoreByIds()
{
// 4J-JEV: Something terrible must have happend,
// 'getFriendslist' was supposed to be a synchronous operation.
__debugbreak();
DEBUG_BREAK();
// 4J-JEV: We can at least fall-back to just the players score.
num = 1;
@@ -1619,7 +1619,7 @@ RADDEFSTART
#define RR_BREAK() __builtin_trap()
#define RR_CACHE_LINE_SIZE 32
#elif defined(__RADXENON__)
#define RR_BREAK() __debugbreak()
#define RR_BREAK() DEBUG_BREAK()
#define RR_CACHE_LINE_SIZE 128
#elif defined(__RADANDROID__)
#define RR_BREAK() __builtin_trap()
+1 -1
View File
@@ -1619,7 +1619,7 @@ RADDEFSTART
#define RR_BREAK() __builtin_trap()
#define RR_CACHE_LINE_SIZE 32
#elif defined(__RADXENON__)
#define RR_BREAK() __debugbreak()
#define RR_BREAK() DEBUG_BREAK()
#define RR_CACHE_LINE_SIZE 128
#elif defined(__RADANDROID__)
#define RR_BREAK() __builtin_trap()
+1 -1
View File
@@ -1619,7 +1619,7 @@ RADDEFSTART
#define RR_BREAK() __builtin_trap()
#define RR_CACHE_LINE_SIZE 32
#elif defined(__RADXENON__)
#define RR_BREAK() __debugbreak()
#define RR_BREAK() DEBUG_BREAK()
#define RR_CACHE_LINE_SIZE 128
#elif defined(__RADANDROID__)
#define RR_BREAK() __builtin_trap()
@@ -1619,7 +1619,7 @@ RADDEFSTART
#define RR_BREAK() __builtin_trap()
#define RR_CACHE_LINE_SIZE 32
#elif defined(__RADXENON__)
#define RR_BREAK() __debugbreak()
#define RR_BREAK() DEBUG_BREAK()
#define RR_CACHE_LINE_SIZE 128
#elif defined(__RADANDROID__)
#define RR_BREAK() __builtin_trap()
@@ -1619,7 +1619,7 @@ RADDEFSTART
#define RR_BREAK() __builtin_trap()
#define RR_CACHE_LINE_SIZE 32
#elif defined(__RADXENON__)
#define RR_BREAK() __debugbreak()
#define RR_BREAK() DEBUG_BREAK()
#define RR_CACHE_LINE_SIZE 128
#elif defined(__RADANDROID__)
#define RR_BREAK() __builtin_trap()
+2 -2
View File
@@ -218,7 +218,7 @@ void Particle::setTex(Textures *textures, Icon *icon)
{
#ifndef _CONTENT_PACKAGE
printf("Invalid call to Particle.setTex, use coordinate methods\n");
__debugbreak();
DEBUG_BREAK();
#endif
//throw new RuntimeException("Invalid call to Particle.setTex, use coordinate methods");
}
@@ -230,7 +230,7 @@ void Particle::setMiscTex(int slotIndex)
{
#ifndef _CONTENT_PACKAGE
printf("Invalid call to Particle.setMixTex\n");
__debugbreak();
DEBUG_BREAK();
//throw new RuntimeException("Invalid call to Particle.setMiscTex");
#endif
}
+66 -4
View File
@@ -13,6 +13,14 @@
#include "../Minecraft.World/System.h"
#include "PlayerList.h"
#include <unordered_set>
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
#include "../Minecraft.Server/ServerLogger.h"
// Per-tick accumulators for tickAddRequests timing.
static int64_t g_findUsAccum = 0;
static int64_t g_addUsAccum = 0;
static int g_addCount = 0;
#endif
PlayerChunkMap::PlayerChunk::PlayerChunk(int x, int z, PlayerChunkMap *pcm) : pos(x,z)
{
@@ -74,7 +82,7 @@ void PlayerChunkMap::PlayerChunk::add(shared_ptr<ServerPlayer> player, bool send
players.push_back(player);
player->chunksToSend.push_back(pos);
player->chunksToSend.insert(pos);
#ifdef _LARGE_WORLDS
parent->getLevel()->cache->dontDrop(pos.x, pos.z); // 4J Added;
@@ -118,7 +126,7 @@ void PlayerChunkMap::PlayerChunk::remove(shared_ptr<ServerPlayer> player)
parent->getLevel()->cache->drop(pos.x, pos.z);
}
player->chunksToSend.remove(pos);
player->chunksToSend.erase(pos);
// 4J - I don't think there's any point sending these anymore, as we don't need to unload chunks with fixed sized maps
// 4J - We do need to send these to unload entities in chunks when players are dead. If we do not and the entity is removed
// while they are dead, that entity will remain in the clients world
@@ -369,6 +377,15 @@ ServerLevel *PlayerChunkMap::getLevel()
void PlayerChunkMap::tick()
{
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
// Substep timing for slow chunkMap diagnostics.
const int64_t CHUNKMAP_SLOW_THRESHOLD_MS = 150;
int64_t cm_t0 = System::currentTimeMillis();
int cm_addReqStart = (int)addRequests.size();
g_findUsAccum = 0;
g_addUsAccum = 0;
g_addCount = 0;
#endif
int64_t time = level->getGameTime();
if (time - lastInhabitedUpdate > Level::TICKS_PER_DAY / 3)
@@ -385,6 +402,9 @@ void PlayerChunkMap::tick()
chunk->updateInhabitedTime();
}
}
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
int64_t cm_t1 = System::currentTimeMillis();
#endif
// 4J - some changes here so that we only send one region update per tick. The chunks themselves also
// limit their resend rate to once every MIN_TICKS_BETWEEN_REGION_UPDATE ticks
@@ -404,11 +424,35 @@ void PlayerChunkMap::tick()
i++;
}
}
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
int64_t cm_t2 = System::currentTimeMillis();
#endif
for( unsigned int i = 0; i < players.size(); i++ )
{
tickAddRequests(players[i]);
}
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
int64_t cm_t3 = System::currentTimeMillis();
int64_t cm_total = cm_t3 - cm_t0;
if (cm_total > CHUNKMAP_SLOW_THRESHOLD_MS)
{
ServerRuntime::LogInfof("perf",
"L%d chunkMap total=%lldms inhabited=%lld changed=%lld addReq=%lld | players=%d addReqQueue=%d->%d | adds=%d findUs=%lld addUs=%lld avgAddUs=%lld",
this->dimension,
(long long)cm_total,
(long long)(cm_t1 - cm_t0),
(long long)(cm_t2 - cm_t1),
(long long)(cm_t3 - cm_t2),
(int)players.size(),
cm_addReqStart,
(int)addRequests.size(),
g_addCount,
(long long)g_findUsAccum,
(long long)g_addUsAccum,
g_addCount > 0 ? (long long)(g_addUsAccum / g_addCount) : 0LL);
}
#endif
// 4J Stu - Added 1.1 but not relevant to us as we never no 0 players anyway, and don't think we should be dropping stuff
//if (players.isEmpty()) {
@@ -490,7 +534,11 @@ void PlayerChunkMap::getChunkAndRemovePlayer(int x, int z, shared_ptr<ServerPlay
// Processes up to CHUNKS_PER_PLAYER_PER_TICK requests per call to speed up initial chunk loading.
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
static const int CHUNKS_PER_PLAYER_PER_TICK = 16;
// Per-player drain rate for the addRequest queue. Each PlayerChunk::add
// issues a synchronous ChunkVisibilityPacket, so per-tick send volume
// scales as players * this. Pair with DEDICATED_MAX_CHUNK_SENDS_PER_TICK
// on the chunk-data side.
static const int CHUNKS_PER_PLAYER_PER_TICK = 4;
#else
static const int CHUNKS_PER_PLAYER_PER_TICK = 1;
#endif
@@ -504,6 +552,11 @@ void PlayerChunkMap::tickAddRequests(shared_ptr<ServerPlayer> player)
for (int processed = 0; processed < CHUNKS_PER_PLAYER_PER_TICK; processed++)
{
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
LARGE_INTEGER qpcFreq, qpcA, qpcB, qpcC;
QueryPerformanceFrequency(&qpcFreq);
QueryPerformanceCounter(&qpcA);
#endif
// Find the nearest chunk request to the player
int minDistSq = -1;
auto itNearest = addRequests.end();
@@ -522,12 +575,21 @@ void PlayerChunkMap::tickAddRequests(shared_ptr<ServerPlayer> player)
}
}
}
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
QueryPerformanceCounter(&qpcB);
g_findUsAccum += (qpcB.QuadPart - qpcA.QuadPart) * 1000000 / qpcFreq.QuadPart;
#endif
// If we found one, process it and continue; otherwise done
if( itNearest != addRequests.end() )
{
getChunk(itNearest->x, itNearest->z, true)->add(itNearest->player);
addRequests.erase(itNearest);
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
QueryPerformanceCounter(&qpcC);
g_addUsAccum += (qpcC.QuadPart - qpcB.QuadPart) * 1000000 / qpcFreq.QuadPart;
g_addCount++;
#endif
}
else
{
@@ -781,7 +843,7 @@ bool PlayerChunkMap::isPlayerIn(shared_ptr<ServerPlayer> player, int xChunk, int
else
{
auto it1 = find(chunk->players.begin(), chunk->players.end(), player);
auto it2 = find(player->chunksToSend.begin(), player->chunksToSend.end(), chunk->pos);
auto it2 = player->chunksToSend.find(chunk->pos);
return it1 != chunk->players.end() && it2 == player->chunksToSend.end();
}
+42 -39
View File
@@ -121,6 +121,45 @@ void PlayerList::queueDisconnect(shared_ptr<ServerPlayer> player, int reason, co
LeaveCriticalSection(&m_disconnectCS);
}
void PlayerList::drainPendingDisconnects()
{
std::deque<PendingDisconnect> dcCopy;
EnterCriticalSection(&m_disconnectCS);
dcCopy.swap(m_pendingDisconnects);
LeaveCriticalSection(&m_disconnectCS);
while (!dcCopy.empty())
{
PendingDisconnect pd = dcCopy.front();
dcCopy.pop_front();
server->getPlayers()->removePlayerFromReceiving(pd.player);
if (pd.player->connection != nullptr)
{
pd.player->connection->send(std::make_shared<DisconnectPacket>(static_cast<DisconnectPacket::eDisconnectReason>(pd.reason)));
pd.player->connection->connection->sendAndQuit();
}
if (!pd.kickMessage.empty())
{
broadcastAll(std::make_shared<ChatPacket>(pd.kickMessage));
}
else if (!pd.fourKitHandledQuit)
{
if (pd.wasKicked)
{
broadcastAll(std::make_shared<ChatPacket>(pd.player->name, ChatPacket::e_ChatPlayerKickedFromGame));
}
else
{
broadcastAll(std::make_shared<ChatPacket>(pd.player->name, ChatPacket::e_ChatPlayerLeftGame));
}
}
remove(pd.player);
}
}
bool PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer> player, shared_ptr<LoginPacket> packet)
{
CompoundTag *playerTag = load(player);
@@ -874,7 +913,7 @@ shared_ptr<ServerPlayer> PlayerList::respawn(shared_ptr<ServerPlayer> serverPlay
// necessary)
updatePlayerGameMode(player, serverPlayer, level);
// 4J Added: Hardcore mode force Adventure mode on respawn
// 4J Added: Hardcore mode forces Adventure mode on respawn
if (server->getLevel(0)->getLevelData()->isHardcore())
{
player->gameMode->setGameModeForPlayer(GameType::ADVENTURE);
@@ -1300,43 +1339,7 @@ void PlayerList::tick()
// Drain the pending disconnect queue. disconnect() enqueues here so it
// can release done_cs before the heavy cleanup runs on the tick thread.
{
std::deque<PendingDisconnect> dcCopy;
EnterCriticalSection(&m_disconnectCS);
dcCopy.swap(m_pendingDisconnects);
LeaveCriticalSection(&m_disconnectCS);
while (!dcCopy.empty())
{
PendingDisconnect pd = dcCopy.front();
dcCopy.pop_front();
server->getPlayers()->removePlayerFromReceiving(pd.player);
if (pd.player->connection != nullptr)
{
pd.player->connection->send(std::make_shared<DisconnectPacket>(static_cast<DisconnectPacket::eDisconnectReason>(pd.reason)));
pd.player->connection->connection->sendAndQuit();
}
if (!pd.kickMessage.empty())
{
broadcastAll(std::make_shared<ChatPacket>(pd.kickMessage));
}
else if (!pd.fourKitHandledQuit)
{
if (pd.wasKicked)
{
broadcastAll(std::make_shared<ChatPacket>(pd.player->name, ChatPacket::e_ChatPlayerKickedFromGame));
}
else
{
broadcastAll(std::make_shared<ChatPacket>(pd.player->name, ChatPacket::e_ChatPlayerLeftGame));
}
}
remove(pd.player);
}
}
drainPendingDisconnects();
// Drain the close queue: snapshot the deque, then release the CS before
// calling disconnect() which may itself try to acquire other locks.
@@ -1372,7 +1375,7 @@ void PlayerList::tick()
#ifdef _WINDOWS64
// The old Connection's read/write threads are now dead (disconnect waits
// for them). Safe to recycle the smallId no stale write thread can
// for them). Safe to recycle the smallId: no stale write thread can
// resolve getPlayer() to a new connection that reuses this slot.
WinsockNetLayer::PushFreeSmallId(smallId);
WinsockNetLayer::ClearSocketForSmallId(smallId);
+1
View File
@@ -98,6 +98,7 @@ public:
void move(shared_ptr<ServerPlayer> player);
void remove(shared_ptr<ServerPlayer> player);
void queueDisconnect(shared_ptr<ServerPlayer> player, int reason, const wstring& kickMessage, bool wasKicked, bool fourKitHandledQuit);
void drainPendingDisconnects();
shared_ptr<ServerPlayer> getPlayerForLogin(PendingConnection *pendingConnection, const wstring& userName, PlayerUID xuid, PlayerUID OnlineXuid);
shared_ptr<ServerPlayer> respawn(shared_ptr<ServerPlayer> serverPlayer, int targetDimension, bool keepAllPlayerData);
void toggleDimension(shared_ptr<ServerPlayer> player, int targetDimension);
+3 -4
View File
@@ -227,7 +227,6 @@ void PreStitchedTextureMap::makeTextureAnimated(TexturePack *texturePack, Stitch
if(first->getWidth() != tex->getWidth() || first->getHeight() != tex->getHeight())
{
app.DebugPrintf("%ls - first w - %d, h - %d, tex w - %d, h - %d\n",textureFileName.c_str(),first->getWidth(),tex->getWidth(),first->getHeight(),tex->getHeight());
//__debugbreak();
}
#endif
@@ -246,7 +245,7 @@ StitchedTexture *PreStitchedTextureMap::getTexture(const wstring &name)
{
#ifndef _CONTENT_PACKAGE
app.DebugPrintf("Not implemented!\n");
__debugbreak();
DEBUG_BREAK();
#endif
return nullptr;
#if 0
@@ -277,7 +276,7 @@ Icon *PreStitchedTextureMap::registerIcon(const wstring &name)
{
app.DebugPrintf("Don't register nullptr\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
result = missingPosition;
//new RuntimeException("Don't register null!").printStackTrace();
@@ -290,7 +289,7 @@ Icon *PreStitchedTextureMap::registerIcon(const wstring &name)
{
#ifndef _CONTENT_PACKAGE
app.DebugPrintf("Could not find uv data for icon %ls\n", name.c_str() );
__debugbreak();
DEBUG_BREAK();
#endif
result = missingPosition;
}
+53 -1
View File
@@ -13,6 +13,8 @@
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
#include "../Minecraft.Server/Security/SecurityConfig.h"
#include "../Minecraft.Server/ServerLogManager.h"
#include "../Minecraft.Server/ServerLogger.h"
#include "../Minecraft.World/System.h"
#endif
ServerConnection::ServerConnection(MinecraftServer *server)
@@ -129,16 +131,45 @@ void ServerConnection::tick()
vector< shared_ptr<PlayerConnection> > tempPlayers = players;
LeaveCriticalSection(&players_cs);
for (unsigned int i = 0; i < tempPlayers.size(); i++)
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
// Substep timing for chunk / tick / flush across all players.
LARGE_INTEGER scFreq, scA, scB, scC, scD;
QueryPerformanceFrequency(&scFreq);
int64_t sc_chunkUs = 0;
int64_t sc_tickUs = 0;
int64_t sc_flushUs = 0;
int64_t sc_loopT0 = System::currentTimeMillis();
#endif
// Rotate the per-tick start offset so the chunk-send cap doesn't
// starve players at the back of the vector.
static unsigned int s_chunkRotationOffset = 0;
s_chunkRotationOffset++;
size_t playerCount = tempPlayers.size();
size_t startIdx = playerCount > 0 ? (s_chunkRotationOffset % playerCount) : 0;
for (unsigned int k = 0; k < tempPlayers.size(); k++)
{
unsigned int i = (unsigned int)((startIdx + k) % playerCount);
shared_ptr<PlayerConnection> player = tempPlayers[i];
shared_ptr<ServerPlayer> serverPlayer = player->getPlayer();
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
QueryPerformanceCounter(&scA);
#endif
if( serverPlayer )
{
serverPlayer->updateFrameTick();
serverPlayer->doChunkSendingTick(false);
}
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
QueryPerformanceCounter(&scB);
sc_chunkUs += (scB.QuadPart - scA.QuadPart) * 1000000 / scFreq.QuadPart;
#endif
player->tick();
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
QueryPerformanceCounter(&scC);
sc_tickUs += (scC.QuadPart - scB.QuadPart) * 1000000 / scFreq.QuadPart;
#endif
if (player->done)
{
EnterCriticalSection(&players_cs);
@@ -150,7 +181,28 @@ void ServerConnection::tick()
{
player->connection->flush();
}
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
QueryPerformanceCounter(&scD);
sc_flushUs += (scD.QuadPart - scC.QuadPart) * 1000000 / scFreq.QuadPart;
#endif
}
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
int64_t sc_loopTotal = System::currentTimeMillis() - sc_loopT0;
if (sc_loopTotal > 150)
{
ServerRuntime::LogInfof("perf",
"conn playerLoop total=%lldms players=%d chunkUs=%lld tickUs=%lld flushUs=%lld | avg chunk=%lld tick=%lld flush=%lld",
(long long)sc_loopTotal,
(int)tempPlayers.size(),
(long long)sc_chunkUs,
(long long)sc_tickUs,
(long long)sc_flushUs,
tempPlayers.size() > 0 ? (long long)(sc_chunkUs / tempPlayers.size()) : 0LL,
tempPlayers.size() > 0 ? (long long)(sc_tickUs / tempPlayers.size()) : 0LL,
tempPlayers.size() > 0 ? (long long)(sc_flushUs / tempPlayers.size()) : 0LL);
}
#endif
}
}
+65
View File
@@ -41,6 +41,7 @@
#include "PlayerChunkMap.h"
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
#include "../Minecraft.Server/FourKitBridge.h"
#include "../Minecraft.Server/ServerLogger.h"
#endif
WeighedTreasureArray ServerLevel::RANDOM_BONUS_ITEMS;
@@ -197,6 +198,14 @@ ServerLevel::~ServerLevel()
void ServerLevel::tick()
{
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
// ts[N] = wall-clock at substep N. Logged when level total exceeds
// LEVEL_SLOW_THRESHOLD_MS to pinpoint the dominant substep.
const int64_t LEVEL_SLOW_THRESHOLD_MS = 150;
int64_t ts[13];
ts[0] = System::currentTimeMillis();
#endif
Level::tick();
if (getLevelData()->isHardcore() && difficulty < 3)
{
@@ -218,6 +227,9 @@ void ServerLevel::tick()
}
awakenAllPlayers();
}
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
ts[1] = System::currentTimeMillis();
#endif
PIXBeginNamedEvent(0,"Mob spawner tick");
// for Minecraft 1.8, spawn friendlies really rarely - 4J - altered from once every 400 ticks to 40 ticks as we depend on this a more than the original since we don't have chunk post-process spawning
@@ -233,6 +245,9 @@ void ServerLevel::tick()
mobSpawner->tick(this, finalSpawnEnemies, finalSpawnFriendlies, finalSpawnPersistent);
}
PIXEndNamedEvent();
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
ts[2] = System::currentTimeMillis();
#endif
PIXBeginNamedEvent(0,"Chunk source tick");
chunkSource->tick();
PIXEndNamedEvent();
@@ -248,6 +263,9 @@ void ServerLevel::tick()
}
}
}
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
ts[3] = System::currentTimeMillis();
#endif
//4J - temporarily disabling saves as they are causing gameplay to generally stutter quite a lot
@@ -263,6 +281,9 @@ void ServerLevel::tick()
save(false, nullptr);
PIXEndNamedEvent();
}
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
ts[4] = System::currentTimeMillis();
#endif
// 4J : WESTY : Changed so that time update goes through stats tracking update code.
//levelData->setTime(time);
@@ -278,19 +299,31 @@ void ServerLevel::tick()
setDayTime(levelData->getDayTime() + 1);
}
}
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
ts[5] = System::currentTimeMillis();
#endif
PIXBeginNamedEvent(0,"Tick pending ticks");
// if (tickCount % 5 == 0) {
tickPendingTicks(false);
PIXEndNamedEvent();
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
ts[6] = System::currentTimeMillis();
#endif
PIXBeginNamedEvent(0,"Tick tiles");
MemSect(18);
tickTiles();
MemSect(0);
PIXEndNamedEvent();
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
ts[7] = System::currentTimeMillis();
#endif
chunkMap->tick();
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
ts[8] = System::currentTimeMillis();
#endif
PIXBeginNamedEvent(0,"Tick villages");
//MemSect(18);
@@ -298,18 +331,50 @@ void ServerLevel::tick()
villageSiege->tick();
//MemSect(0);
PIXEndNamedEvent();
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
ts[9] = System::currentTimeMillis();
#endif
PIXBeginNamedEvent(0,"Tick portal forcer");
portalForcer->tick(getGameTime());
PIXEndNamedEvent();
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
ts[10] = System::currentTimeMillis();
#endif
// repeat after tile ticks
PIXBeginNamedEvent(0,"runTileEvents");
runTileEvents();
PIXEndNamedEvent();
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
ts[11] = System::currentTimeMillis();
#endif
// 4J Added
runQueuedSendTileUpdates();
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
ts[12] = System::currentTimeMillis();
int64_t levelTotal = ts[12] - ts[0];
if (levelTotal > LEVEL_SLOW_THRESHOLD_MS)
{
ServerRuntime::LogInfof("perf",
"L%d substep total=%lldms base=%lld spawn=%lld chunkSrc=%lld save=%lld time=%lld pending=%lld tiles=%lld chunkMap=%lld villages=%lld portal=%lld evt=%lld sendTU=%lld",
dimension->id,
(long long)levelTotal,
(long long)(ts[1] - ts[0]),
(long long)(ts[2] - ts[1]),
(long long)(ts[3] - ts[2]),
(long long)(ts[4] - ts[3]),
(long long)(ts[5] - ts[4]),
(long long)(ts[6] - ts[5]),
(long long)(ts[7] - ts[6]),
(long long)(ts[8] - ts[7]),
(long long)(ts[9] - ts[8]),
(long long)(ts[10] - ts[9]),
(long long)(ts[11] - ts[10]),
(long long)(ts[12] - ts[11]));
}
#endif
}
Biome::MobSpawnerData *ServerLevel::getRandomMobSpawnAt(MobCategory *mobCategory, int x, int y, int z)
+77 -13
View File
@@ -8,6 +8,9 @@
#include "Settings.h"
#include "PlayerList.h"
#include "MultiPlayerLevel.h"
#include "Minecraft.h"
#include "Common/Audio/SoundEngine.h"
#include "../Minecraft.World/SoundTypes.h"
#include "../Minecraft.World/net.minecraft.network.packet.h"
#include "../Minecraft.World/net.minecraft.world.damagesource.h"
@@ -474,28 +477,82 @@ void ServerPlayer::doTickA()
}
// 4J - split off the chunk sending bit of the tick here from ::doTick so we can do this exactly once per player per server tick
//
// Find-nearest uses spiral iteration from the player's chunk position with
// O(1) hash lookups against chunksToSend. A bounded fallback walk covers
// the rare case of a stale entry outside the spiral radius.
void ServerPlayer::doChunkSendingTick(bool dontDelayChunks)
{
// printf("[%d] %s: sendChunks: %d, empty: %d\n",tickCount, connection->getNetworkPlayer()->GetUID().getOnlineID(),sendChunks,chunksToSend.empty());
if (!chunksToSend.empty())
{
ChunkPos nearest = chunksToSend.front();
ChunkPos nearest(0, 0);
bool nearestValid = false;
// 4J - reinstated and optimised some code that was commented out in the original, to make sure that we always
// send the nearest chunk to the player. The original uses the bukkit sorting thing to try and avoid doing this, but
// the player can quickly wander away from the centre of the spiral of chunks that that method creates, long before transmission
// of them is complete.
double dist = DBL_MAX;
for(ChunkPos chunk : chunksToSend)
const int px = (int)floor(x) >> 4;
const int pz = (int)floor(z) >> 4;
// Bound on spiral radius. Configured view distance is much smaller.
const int kMaxSpiralRadius = 32;
// Inline distance: ChunkPos::distanceToSqr is non-const so it can't
// be called on the const refs we get when iterating an unordered_set.
auto chunkDistSq = [&](int cx, int cz) -> double {
double xPos = cx * 16.0 + 8.0;
double zPos = cz * 16.0 + 8.0;
double xd = xPos - this->x;
double zd = zPos - this->z;
return xd * xd + zd * zd;
};
// Ring r=0: the player's own chunk.
{
if( level->isChunkFinalised(chunk.x, chunk.z) )
ChunkPos cp(px, pz);
auto it = chunksToSend.find(cp);
if (it != chunksToSend.end() && level->isChunkFinalised(cp.x, cp.z))
{
double newDist = chunk.distanceToSqr(x, z);
if ( (!nearestValid) || (newDist < dist) )
nearest = cp;
dist = chunkDistSq(cp.x, cp.z);
nearestValid = true;
}
}
// Rings r>=1: Chebyshev perimeter. First ring with a match wins;
// within it pick the closest by true Euclidean distance.
for (int r = 1; r <= kMaxSpiralRadius && !nearestValid; r++)
{
for (int dx = -r; dx <= r; dx++)
{
for (int dz = -r; dz <= r; dz++)
{
nearest = chunk;
dist = chunk.distanceToSqr(x, z);
int adx = dx < 0 ? -dx : dx;
int adz = dz < 0 ? -dz : dz;
if ((adx > adz ? adx : adz) != r) continue; // perimeter only
ChunkPos cp(px + dx, pz + dz);
if (chunksToSend.find(cp) == chunksToSend.end()) continue;
if (!level->isChunkFinalised(cp.x, cp.z)) continue;
double d = chunkDistSq(cp.x, cp.z);
if (!nearestValid || d < dist)
{
nearest = cp;
dist = d;
nearestValid = true;
}
}
}
}
// Fallback for chunks outside the spiral radius (rare).
if (!nearestValid)
{
for (const ChunkPos& cp : chunksToSend)
{
if (!level->isChunkFinalised(cp.x, cp.z)) continue;
double d = chunkDistSq(cp.x, cp.z);
if (!nearestValid || d < dist)
{
nearest = cp;
dist = d;
nearestValid = true;
}
}
@@ -564,7 +621,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks)
{
ServerLevel *level = server->getLevel(dimension);
int flagIndex = getFlagIndexForChunk(nearest,this->level->dimension->id);
chunksToSend.remove(nearest);
chunksToSend.erase(nearest);
bool chunkDataSent = false;
@@ -1035,6 +1092,13 @@ void ServerPlayer::changeDimension(int i)
// 4J: Removed on the advice of the mighty King of Achievments (JV)
// awardStat(GenericStats::portal(), GenericStats::param_portal());
}
// play the travel whoosh right before the actual dimension swap
Minecraft *mc = Minecraft::GetInstance();
if (mc != nullptr && mc->soundEngine != nullptr)
{
mc->soundEngine->playUI(eSoundType_PORTAL_TRAVEL, 1, 1.0f);
}
server->getPlayers()->toggleDimension( dynamic_pointer_cast<ServerPlayer>(shared_from_this()), i);
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
if (portalDestModified)
+3 -1
View File
@@ -25,7 +25,9 @@ public:
MinecraftServer *server;
ServerPlayerGameMode *gameMode;
double lastMoveX, lastMoveZ;
list<ChunkPos> chunksToSend;
// Hash set for O(1) membership/erase. Find-nearest is done via
// spiral iteration in ServerPlayer::doChunkSendingTick, not a sweep.
unordered_set<ChunkPos, ChunkPosKeyHash, ChunkPosKeyEq> chunksToSend;
vector<int> entitiesToRemove;
unordered_set<ChunkPos, ChunkPosKeyHash, ChunkPosKeyEq> seenChunks;
int spewTimer;
+1 -1
View File
@@ -87,7 +87,7 @@ void Stitcher::stitch()
{
app.DebugPrintf("Stitcher exception!\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
//throw new StitcherException(textureHolder);
}
+2 -2
View File
@@ -144,7 +144,7 @@ LPCWSTR StringTable::getString(const wstring &id)
#ifndef _CONTENT_PACKAGE
if (isStatic)
{
__debugbreak();
DEBUG_BREAK();
return L"";
}
#endif
@@ -166,7 +166,7 @@ LPCWSTR StringTable::getString(int id)
#ifndef _CONTENT_PACKAGE
if (!isStatic)
{
__debugbreak();
DEBUG_BREAK();
return L"";
}
#endif
+1 -1
View File
@@ -214,7 +214,7 @@ Icon *TextureMap::registerIcon(const wstring &name)
{
app.DebugPrintf("Don't register nullptr\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
//new RuntimeException("Don't register null!").printStackTrace();
}
@@ -339,7 +339,6 @@ bool TexturePackRepository::selectTexturePackById(DWORD id)
app.DebugPrintf("Failed to select texture pack %d as it is not in the list\n", id);
#ifndef _CONTENT_PACKAGE
// TODO - 4J Stu: We should report this to the player in some way
//__debugbreak();
#endif
// Fail safely
if( selectSkin( DEFAULT_TEXTURE_PACK ) )
@@ -1,137 +0,0 @@
#pragma once
#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_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_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_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
// Trigger map - to allow for swap triggers in-game
#define TRIGGER_MAP_0 0
#define TRIGGER_MAP_1 1
enum EKeyboardResult
{
EKeyboard_Pending,
EKeyboard_Cancelled,
EKeyboard_ResultAccept,
EKeyboard_ResultDecline,
};
typedef struct _STRING_VERIFY_RESPONSE
{
WORD wNumStrings;
HRESULT *pStringResult;
}
STRING_VERIFY_RESPONSE;
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)(LPVOID),LPVOID lpParam );
FLOAT GetIdleSeconds(int iPad);
bool IsPadConnected(int iPad);
// 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 SetMenuDisplayed(int iPad, bool bVal);
// 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=nullptr);
// 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=nullptr);
EKeyboardResult RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int( *Func)(LPVOID,const bool),LPVOID lpParam,C_4JInput::EKeyboardMode eMode);
void GetText(uint16_t *UTF16String);
// 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 **pwStringA,int iStringC,int( *Func)(LPVOID,STRING_VERIFY_RESPONSE *),LPVOID lpParam);
void CancelQueuedVerifyStrings(int( *Func)(LPVOID,STRING_VERIFY_RESPONSE *),LPVOID lpParam);
void CancelAllVerifyInProgress(void);
//bool InputDetected(DWORD dwUserIndex,WCHAR *pwchInput);
};
// Singleton
extern C_4JInput InputManager;
@@ -1,128 +0,0 @@
#pragma once
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 eUpsellResponse
{
eUpsellResponse_Declined,
eUpsellResponse_Accepted_NoPurchase,
eUpsellResponse_Accepted_Purchase,
};
class C_4JProfile
{
public:
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( 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)(LPVOID,const bool, const int iPad),LPVOID lpParam,int iQuadrant=XUSER_INDEX_ANY);
UINT DisplayOfflineProfile(int( *Func)(LPVOID,const bool, const int iPad),LPVOID lpParam,int iQuadrant=XUSER_INDEX_ANY);
UINT RequestConvertOfflineToGuestUI(int( *Func)(LPVOID,const bool, const int iPad),LPVOID 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, DWORD dwXuidCount );
void ShowProfileCard(int iPad, PlayerUID targetUid);
bool GetProfileAvatar(int iPad,int( *Func)(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes), LPVOID lpParam);
void CancelProfileAvatarRequest();
// SYS
int GetPrimaryPad();
void SetPrimaryPad(int iPad);
char* GetGamertag(int iPad);
wstring GetDisplayName(int iPad);
bool IsFullVersion();
void SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam);
void SetNotificationsCallback(void ( *Func)(LPVOID, DWORD, unsigned int),LPVOID lpParam);
bool RegionIsNorthAmerica(void);
bool LocaleIsUSorCanada(void);
HRESULT GetLiveConnectionStatus();
bool IsSystemUIDisplayed();
void SetProfileReadErrorCallback(void ( *Func)(LPVOID), LPVOID lpParam);
// PROFILE DATA
int SetDefaultOptionsCallback(int( *Func)(LPVOID,PROFILESETTINGS *, const int iPad),LPVOID lpParam);
int SetOldProfileVersionCallback(int( *Func)(LPVOID,unsigned char *, const unsigned short,const int),LPVOID 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
void RegisterAward(int iAwardNumber,int iGamerconfigID, eAwardType eType, bool bLeaderboardAffected=false,
CXuiStringTable*pStringTable=nullptr, int iTitleStr=-1, int iTextStr=-1, int iAcceptStr=-1, char *pszThemeName=nullptr, 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);
// 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)(LPVOID lpParam, eUpsellType type, eUpsellResponse response, int iUserData),LPVOID 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,302 +0,0 @@
#pragma once
class ImageFileBuffer
{
public:
enum EImageType
{
e_typePNG,
e_typeJPG
};
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 = nullptr; }
bool Allocated() { return m_pBuffer != nullptr; }
};
typedef struct
{
int Width;
int Height;
}D3DXIMAGE_INFO;
typedef struct _XSOCIAL_PREVIEWIMAGE {
BYTE *pBytes;
DWORD Pitch;
DWORD Width;
DWORD Height;
// D3DFORMAT Format;
} XSOCIAL_PREVIEWIMAGE, *PXSOCIAL_PREVIEWIMAGE;
class C4JRender
{
public:
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();
// Core
void Initialise(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain);
void InitialiseContext();
void StartFrame();
void DoScreenGrabOnNextPresent();
void Present();
void Clear(int flags, D3D11_RECT *pRect = nullptr);
void SetClearColour(const float colourRGBA[4]);
bool IsWidescreen();
bool IsHiDef();
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;
// 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
{
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 DrawVertexBuffer(ePrimitiveType PrimitiveType, int count, ID3D11Buffer *buffer, C4JRender::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();
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);
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();
ID3D11ShaderResourceView *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);
// Event tracking
void BeginEvent(LPCWSTR eventName);
void EndEvent();
// PLM event handling
void Suspend();
bool Suspended();
void Resume();
};
const int GL_MODELVIEW_MATRIX = 0;
const int GL_PROJECTION_MATRIX = 1;
const int GL_MODELVIEW = 0;
const int GL_PROJECTION = 1;
const int GL_TEXTURE = 2;
// These things required for tex gen
const int GL_S = 0;
const int GL_T = 1;
const int GL_R = 2;
const int GL_Q = 3;
const int GL_TEXTURE_GEN_S = 0;
const int GL_TEXTURE_GEN_T = 1;
const int GL_TEXTURE_GEN_Q = 2;
const int GL_TEXTURE_GEN_R = 3;
const int GL_TEXTURE_GEN_MODE = 0;
const int GL_OBJECT_LINEAR = 0;
const int GL_EYE_LINEAR = 1;
const int GL_OBJECT_PLANE = 0;
const int GL_EYE_PLANE = 1;
// 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 = 1;
const int GL_BLEND = 2;
const int GL_CULL_FACE = 3;
const int GL_ALPHA_TEST = 4;
const int GL_DEPTH_TEST = 5;
const int GL_FOG = 6;
const int GL_LIGHTING = 7;
const int GL_LIGHT0 = 8;
const int GL_LIGHT1 = 9;
const int CLEAR_DEPTH_FLAG = 1;
const int CLEAR_COLOUR_FLAG = 2;
const int GL_DEPTH_BUFFER_BIT = CLEAR_DEPTH_FLAG;
const int GL_COLOR_BUFFER_BIT = CLEAR_COLOUR_FLAG;
const int GL_SRC_ALPHA = D3D11_BLEND_SRC_ALPHA;
const int GL_ONE_MINUS_SRC_ALPHA = D3D11_BLEND_INV_SRC_ALPHA;
const int GL_ONE = D3D11_BLEND_ONE;
const int GL_ZERO = D3D11_BLEND_ZERO;
const int GL_DST_ALPHA = D3D11_BLEND_DEST_ALPHA;
const int GL_SRC_COLOR = D3D11_BLEND_SRC_COLOR;
const int GL_DST_COLOR = D3D11_BLEND_DEST_COLOR;
const int GL_ONE_MINUS_DST_COLOR = D3D11_BLEND_INV_DEST_COLOR;
const int GL_ONE_MINUS_SRC_COLOR = D3D11_BLEND_INV_SRC_COLOR;
const int GL_CONSTANT_ALPHA = D3D11_BLEND_BLEND_FACTOR;
const int GL_ONE_MINUS_CONSTANT_ALPHA = D3D11_BLEND_INV_BLEND_FACTOR;
const int GL_GREATER = D3D11_COMPARISON_GREATER;
const int GL_EQUAL = D3D11_COMPARISON_EQUAL;
const int GL_LEQUAL = D3D11_COMPARISON_LESS_EQUAL;
const int GL_GEQUAL = D3D11_COMPARISON_GREATER_EQUAL;
const int GL_ALWAYS = D3D11_COMPARISON_ALWAYS;
const int GL_TEXTURE_MIN_FILTER = 1;
const int GL_TEXTURE_MAG_FILTER = 2;
const int GL_TEXTURE_WRAP_S = 3;
const int GL_TEXTURE_WRAP_T = 4;
const int GL_NEAREST = 0;
const int GL_LINEAR = 1;
const int GL_EXP = 2;
const int GL_NEAREST_MIPMAP_LINEAR = 0; // TODO - mipmapping bit of this
const int GL_CLAMP = 0;
const int GL_REPEAT = 1;
const int GL_FOG_START = 1;
const int GL_FOG_END = 2;
const int GL_FOG_MODE = 3;
const int GL_FOG_DENSITY = 4;
const int GL_FOG_COLOR = 5;
const int GL_POSITION = 1;
const int GL_AMBIENT = 2;
const int GL_DIFFUSE = 3;
const int GL_SPECULAR = 4;
const int GL_LIGHT_MODEL_AMBIENT = 1;
const int GL_LINES = C4JRender::PRIMITIVE_TYPE_LINE_LIST;
const int GL_LINE_STRIP = C4JRender::PRIMITIVE_TYPE_LINE_STRIP;
const int GL_QUADS = C4JRender::PRIMITIVE_TYPE_QUAD_LIST;
const int GL_TRIANGLE_FAN = C4JRender::PRIMITIVE_TYPE_TRIANGLE_FAN;
const int GL_TRIANGLE_STRIP = C4JRender::PRIMITIVE_TYPE_TRIANGLE_STRIP;
// Singleton
extern C4JRender RenderManager;
@@ -1,344 +0,0 @@
#pragma once
#include <vector>
//#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
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
{
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;
// Current version of the dlc data creator
#define CURRENT_DLC_VERSION_NUM 3
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;
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
{
WCHAR wchDisplayName[XCONTENT_MAX_DISPLAYNAME_LENGTH];
CHAR szFileName[XCONTENT_MAX_FILENAME_LENGTH];
DWORD dwImageOffset;
DWORD 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;
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 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 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
};
enum ELoadGameStatus
{
ELoadGame_Idle=0,
ELoadGame_InProgress,
ELoadGame_NoSaves,
ELoadGame_ChangedDevice,
ELoadGame_DeviceRemoved
};
enum EDeleteGameStatus
{
EDeleteGame_Idle=0,
EDeleteGame_InProgress,
};
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 ESavingMessage
{
ESavingMessage_None=0,
ESavingMessage_Short,
ESavingMessage_Long
};
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_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
{
DWORD dwSize;
PBYTE pbData;
}
TMSPP_FILEDATA, *PTMSPP_FILEDATA;
C4JStorage();
void Tick(void);
// Messages
C4JStorage::EMessageResult RequestMessageBox(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad=XUSER_INDEX_ANY,
int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)=nullptr,LPVOID lpParam=nullptr, C4JStringTable *pStringTable=nullptr, WCHAR *pwchFormatString=nullptr,DWORD dwFocusButton=0);
C4JStorage::EMessageResult GetMessageBoxResult();
// save device
bool SetSaveDevice(int( *Func)(LPVOID,const bool),LPVOID lpParam, bool bForceResetOfSaveDevice=false);
// savegame
void Init(unsigned int uiSaveVersion,LPCWSTR pwchDefaultSaveName,char *pszSavePackName,int iMinimumSaveSize,int( *Func)(LPVOID, const ESavingMessage, int),LPVOID 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)(LPVOID,const bool),LPVOID 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)(LPVOID ,const bool),LPVOID lpParam);
void CopySaveDataToNewSave(PBYTE pbThumbnail,DWORD cbThumbnail,WCHAR *wchNewName,int ( *Func)(LPVOID lpParam, bool), LPVOID 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)(LPVOID lpParam,SAVE_DETAILS *pSaveDetails,const bool),LPVOID lpParam,char *pszSavePackName);
PSAVE_DETAILS ReturnSavesInfo();
void ClearSavesInfo(); // Clears results
C4JStorage::ESaveGameState LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo,int( *Func)(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes), LPVOID lpParam); // Get the thumbnail for an individual save referenced by pSaveInfo
void GetSaveCacheFileInfo(DWORD dwFile,XCONTENT_DATA &xContentData);
void GetSaveCacheFileInfo(DWORD dwFile, PBYTE *ppbImageData, DWORD *pdwImageBytes);
// Load the save. Need to call GetSaveData once the callback is called
C4JStorage::ESaveGameState LoadSaveData(PSAVE_INFO pSaveInfo,int( *Func)(LPVOID lpParam,const bool, const bool), LPVOID lpParam);
C4JStorage::ESaveGameState DeleteSaveData(PSAVE_INFO pSaveInfo,int( *Func)(LPVOID lpParam,const bool), LPVOID lpParam);
// DLC
void RegisterMarketplaceCountsCallback(int ( *Func)(LPVOID lpParam, C4JStorage::DLC_TMS_DETAILS *, int), LPVOID lpParam );
void SetDLCPackageRoot(char *pszDLCRoot);
C4JStorage::EDLCStatus GetDLCOffers(int iPad,int( *Func)(LPVOID, int, DWORD, int),LPVOID lpParam, DWORD dwOfferTypesBitmask=XMARKETPLACE_OFFERING_TYPE_CONTENT);
DWORD CancelGetDLCOffers();
void ClearDLCOffers();
XMARKETPLACE_CONTENTOFFER_INFO& GetOffer(DWORD dw);
int GetOfferCount();
DWORD InstallOffer(int iOfferIDC, uint64_t *ullOfferIDA,int( *Func)(LPVOID, int, int),LPVOID lpParam, bool bTrial=false);
DWORD GetAvailableDLCCount( int iPad);
C4JStorage::EDLCStatus GetInstalledDLC(int iPad,int( *Func)(LPVOID, int, int),LPVOID lpParam);
XCONTENT_DATA& GetDLC(DWORD dw);
DWORD MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPCSTR szMountDrive=nullptr);
DWORD UnmountInstalledDLC(LPCSTR szMountDrive = nullptr);
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)(LPVOID, WCHAR *,int, bool, int)=nullptr,LPVOID lpParam=nullptr, 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=nullptr);
// 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);
#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)=nullptr,LPVOID lpParam=nullptr, 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)(LPVOID,int,int,PTMSPP_FILEDATA, LPCSTR)=nullptr,LPVOID lpParam=nullptr, int iUserData=0);
// C4JStorage::ETMSStatus TMSPP_ReadFileList(int iPad,C4JStorage::eGlobalStorage eStorageFacility,CHAR *pchFilePath,int( *Func)(LPVOID,int,int,PTMSPP_FILE_LIST)=nullptr,LPVOID lpParam=nullptr, int iUserData=0);
// C4JStorage::ETMSStatus TMSPP_DeleteFile(int iPad,LPCSTR szFilePath,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,int( *Func)(LPVOID,int,int),LPVOID lpParam=nullptr, int iUserData=0);
// bool TMSPP_InFileList(eGlobalStorage eStorageFacility, int iPad,const 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);
unsigned int CRC(unsigned char *buf, int len);
// #ifdef _DEBUG
// void SetSaveName(int i);
// #endif
// string table for all the Storage problems. Loaded by the application
C4JStringTable *m_pStringTable;
};
extern C4JStorage StorageManager;
Binary file not shown.
@@ -1619,7 +1619,7 @@ RADDEFSTART
#define RR_BREAK() __builtin_trap()
#define RR_CACHE_LINE_SIZE 32
#elif defined(__RADXENON__)
#define RR_BREAK() __debugbreak()
#define RR_BREAK() DEBUG_BREAK()
#define RR_CACHE_LINE_SIZE 128
#elif defined(__RADANDROID__)
#define RR_BREAK() __builtin_trap()
@@ -24,7 +24,7 @@ void ConsoleUIController::init(ID3D11Device *dev, ID3D11DeviceContext *ctx, ID3D
{
app.DebugPrintf("Failed to initialise GDraw!\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
app.FatalLoadError();
}
+1 -1
View File
@@ -487,7 +487,7 @@ void SoundEngine::play(int iSound, float x, float y, float z, float volume, floa
{
#ifndef _CONTENT_PACKAGE
#ifdef _DEBUG
__debugbreak();
DEBUG_BREAK();
#endif
//wprintf(L"WARNING: Sound cue not found - %ls\n", name.c_str() );
app.DebugPrintf("Not found: %s\n",xboxName);
@@ -183,7 +183,7 @@ bool XboxLeaderboardManager::WriteStats(unsigned int viewCount, ViewIn views)
// some debug code to catch the leaderboard write with 7 views
#ifndef _CONTENT_PACKAGE
if(viewCount>5) __debugbreak();
if(viewCount>5) DEBUG_BREAK();
#endif
// 4J Stu - If we are online we already have a session, so use that
@@ -211,8 +211,6 @@ VOID CPlatformNetworkManagerXbox::NotifyPlayerLeaving(
__in IQNetPlayer * pQNetPlayer
)
{
//__debugbreak();
app.DebugPrintf( "Player 0x%p \"%ls\" leaving.\n",
pQNetPlayer,
pQNetPlayer->GetGamertag() );
-2
View File
@@ -315,8 +315,6 @@ int __cdecl main()
HRESULT hr;
static bool bTrialTimerDisplayed=true;
//__debugbreak();
#ifdef MEMORY_TRACKING
ResetMem();
MEMORYSTATUS memStat;
+1
View File
@@ -148,6 +148,7 @@ typedef XUID GameSessionUID;
#endif
#include "../Minecraft.World/Definitions.h"
#include "../Minecraft.World/Debug.h"
#include "../Minecraft.World/Class.h"
#include "../Minecraft.World/ArrayWithLength.h"
#include "../Minecraft.World/SharedConstants.h"
+2
View File
@@ -15,6 +15,8 @@ static volatile LONG g_minLogLevel = (LONG)eServerLogLevel_Info;
static FILE *g_logFile = NULL;
static std::once_flag g_logFileOnce;
bool g_serverPerfTrace = false;
static void OpenLogFile()
{
if (g_logFile != NULL)
+5
View File
@@ -41,4 +41,9 @@ namespace ServerRuntime
void LogStartupStep(const char *message);
void LogWorldIO(const char *message);
void LogWorldName(const char *prefix, const std::wstring &name);
// When true, noisy [perf] sampling output (histograms, per-iter samples)
// is enabled. Threshold-fired warnings remain always-on. Toggled via the
// -perftrace CLI flag.
extern bool g_serverPerfTrace;
}
+38 -3
View File
@@ -166,6 +166,7 @@ static void PrintUsage()
ServerRuntime::LogInfo("usage", " -maxplayers <1-8> Public slots (default: server.properties:max-players)");
ServerRuntime::LogInfo("usage", " -seed <int64> World seed (overrides server.properties:level-seed)");
ServerRuntime::LogInfo("usage", " -loglevel <level> debug|info|warn|error (default: server.properties:log-level)");
ServerRuntime::LogInfo("usage", " -perftrace Enable noisy [perf] sampling output (histograms, per-iter samples)");
ServerRuntime::LogInfo("usage", " -help Show this help");
}
@@ -272,6 +273,10 @@ static bool ParseCommandLine(int argc, char **argv, DedicatedServerConfig *confi
return false;
}
}
else if (_stricmp(arg, "-perftrace") == 0)
{
ServerRuntime::g_serverPerfTrace = true;
}
else
{
LogErrorf("startup", "Unknown or incomplete argument: %s", arg);
@@ -779,6 +784,16 @@ int main(int argc, char **argv)
MinecraftServer *server = MinecraftServer::getInstance();
if (server != NULL)
{
// A queued autosave action would spawn a bg save that races with the
// exit save's Flush() on the singleton CSaveGame::m_pSaveData buffer.
if (app.GetXuiServerAction(kServerActionPad) != eXuiServerAction_Idle)
{
LogWorldIO("Waiting for pending XUI server action before exit save...");
if (!WaitForWorldActionIdle(kServerActionPad, 30000, &TickCoreSystems, &HandleXuiActions))
{
LogWorldIO("XUI server action drain timed out; continuing with exit save");
}
}
// Drain any in-flight autosave before requesting the exit save so the
// async autosave can't overwrite the exit save with an older snapshot,
// and so m_saveOnExit gets set (prior logic skipped it when a save was
@@ -817,10 +832,30 @@ int main(int argc, char **argv)
waitThread.WaitForCompletion(INFINITE);
}
while (ConsoleSaveFileOriginal::hasPendingBackgroundSave())
if (ConsoleSaveFileOriginal::hasPendingBackgroundSave())
{
TickCoreSystems();
Sleep(10);
LogWorldIO("waiting for exit save to land on disk...");
const DWORD kExitDrainTimeoutMs = 60000;
const DWORD drainStart = GetTickCount();
bool timedOut = false;
while (ConsoleSaveFileOriginal::hasPendingBackgroundSave())
{
if ((LONG)(GetTickCount() - drainStart) > (LONG)kExitDrainTimeoutMs)
{
timedOut = true;
break;
}
TickCoreSystems();
Sleep(10);
}
if (timedOut)
{
LogWarn("world-io", "exit save drain TIMED OUT; save may be incomplete");
}
else
{
LogWorldIO("exit save drain complete");
}
}
LogInfof("shutdown", "Cleaning up and exiting.");
+1 -1
View File
@@ -208,7 +208,7 @@ void ArmorItem::setColor(shared_ptr<ItemInstance> item, int color)
{
#ifndef _CONTENT_PACKAGE
printf("Can't dye non-leather!");
__debugbreak();
DEBUG_BREAK();
#endif
//throw new UnsupportedOperationException("Can't dye non-leather!");
}
+1 -1
View File
@@ -23,7 +23,7 @@ void BiomeDecorator::decorate(Level *level, Random *random, int xo, int zo)
{
app.DebugPrintf("BiomeDecorator::decorate - Already decorating!!\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
//throw new RuntimeException("Already decorating!!");
#endif
}
+2 -2
View File
@@ -32,7 +32,7 @@ BiomeOverrideLayer::BiomeOverrideLayer(int seedMixup) : Layer(seedMixup)
{
#ifdef _DURANGO
__debugbreak(); // TODO
DEBUG_BREAK(); // TODO
DWORD bytesRead,dwFileSize = 0;
#else
DWORD bytesRead,dwFileSize = GetFileSize(file,nullptr);
@@ -40,7 +40,7 @@ BiomeOverrideLayer::BiomeOverrideLayer(int seedMixup) : Layer(seedMixup)
if(dwFileSize > m_biomeOverride.length)
{
app.DebugPrintf("Biomemap binary is too large!!\n");
__debugbreak();
DEBUG_BREAK();
}
BOOL bSuccess = ReadFile(file,m_biomeOverride.data,dwFileSize,&bytesRead,nullptr);
+1 -1
View File
@@ -184,7 +184,7 @@ void BiomeSource::getRawBiomeBlock(BiomeArray &biomes, int x, int z, int w, int
if(biomes[i] == nullptr)
{
app.DebugPrintf("Tried to assign null biome %d\n", result[i]);
__debugbreak();
DEBUG_BREAK();
}
#endif
}
+2 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#include "Debug.h"
using namespace std;
class InputStream;
@@ -598,7 +599,7 @@ public:
if ( (m_falsePositives.size() > 0) || (m_falseNegatives.size() > 0) )
{
__debugbreak();
DEBUG_BREAK();
}
}
};
+1 -1
View File
@@ -36,7 +36,7 @@ public:
{
#ifndef _CONTENT_PACKAGE
printf("Tried to read NBT tag with too high complexity, depth > %d" , MAX_DEPTH);
__debugbreak();
DEBUG_BREAK();
#endif
return;
}
+1 -1
View File
@@ -1065,7 +1065,7 @@ void CompressedTileStorage::compress(int upgradeBlock/*=-1*/)
#ifndef _DURANGO
MEMORYSTATUS memStatus;
GlobalMemoryStatus(&memStatus);
__debugbreak();
DEBUG_BREAK();
#endif
}
unsigned char *pucData = newIndicesAndData + 1024;
+79 -15
View File
@@ -16,6 +16,7 @@
#include <thread>
#include <atomic>
#include <mutex>
#include "ServerLogger.h"
static std::atomic<bool> s_bgSaveActive{false};
static std::mutex s_bgSaveMutex;
@@ -28,8 +29,20 @@ struct BackgroundSaveResult
BYTE textMeta[88] = {};
int textMetaBytes = 0;
bool pending = false;
bool isAutosave = false;
int64_t startTickMs = 0;
unsigned int rawBytes = 0;
unsigned int compressedBytes = 0;
};
static BackgroundSaveResult s_bgResult;
// Snapshotted under s_bgSaveMutex; SaveSaveDataCallback reads without
// re-locking (std::mutex is non-recursive, callback fires synchronously
// inside SaveSaveData while flushPendingBackgroundSave holds the lock).
static bool s_lastSaveIsAutosave = false;
static int64_t s_lastSaveStartTickMs = 0;
static unsigned int s_lastSaveRawBytes = 0;
static unsigned int s_lastSaveCompressedBytes = 0;
#endif
@@ -90,7 +103,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID
if( pagesCommitted != 0 )
{
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
}
@@ -101,7 +114,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID
{
#ifndef _CONTENT_PACKAGE
// Out of physical memory
__debugbreak();
DEBUG_BREAK();
#endif
}
pagesCommitted = pagesRequired;
@@ -206,7 +219,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const wstring &fileName, LPVOID
if( pvRet == nullptr )
{
// Out of physical memory
__debugbreak();
DEBUG_BREAK();
}
pagesCommitted = pagesRequired;
}
@@ -497,7 +510,7 @@ void ConsoleSaveFileOriginal::finalizeWrite()
void *pvRet = VirtualAlloc(pvHeap, pagesRequired * CSF_PAGE_SIZE, COMMIT_ALLOCATION, PAGE_READWRITE);
if( pvRet == NULL )
{
__debugbreak();
DEBUG_BREAK();
}
pagesCommitted = pagesRequired;
}
@@ -531,7 +544,7 @@ void ConsoleSaveFileOriginal::MoveDataBeyond(FileEntry *file, DWORD nNumberOfByt
if( pvRet == nullptr )
{
// Out of physical memory
__debugbreak();
DEBUG_BREAK();
}
pagesCommitted = pagesRequired;
}
@@ -729,10 +742,18 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
StorageManager.GetSaveUniqueNumber(&uid);
TelemetryManager->RecordLevelSaveOrCheckpoint(ProfileManager.GetPrimaryPad(), uid, fileSize);
const int64_t startMs = static_cast<int64_t>(GetTickCount());
const bool modeAutosave = autosave;
ServerRuntime::LogInfof("world-io",
"save started: mode=%s raw=%u bytes",
modeAutosave ? "autosave" : "exit", fileSize);
ReleaseSaveAccess();
s_bgSaveActive.store(true, std::memory_order_release);
std::thread([snap, fileSize, thumb, thumbSz, meta, metaLen, this]() {
std::thread([snap, fileSize, thumb, thumbSz, meta, metaLen, modeAutosave, startMs, this]() {
Compression::UseDefaultThreadStorage();
const int64_t compStartMs = static_cast<int64_t>(GetTickCount());
unsigned int compLen = fileSize + 8;
byte *buf = static_cast<byte *>(StorageManager.AllocateSaveData(compLen));
if (!buf)
@@ -750,6 +771,11 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
ZeroMemory(buf, 8);
memcpy(buf + 4, &fileSize, sizeof(fileSize));
const int64_t compMs = static_cast<int64_t>(GetTickCount()) - compStartMs;
ServerRuntime::LogInfof("world-io",
"save compressed: %u->%u bytes in %lldms",
fileSize, compLen, (long long)compMs);
// store the result so flushPendingBackgroundSave() can pick it up on the main thread next tick
// StorageManager isnt thread safe so we cant call SetSaveImages or SaveSaveData from here. Bwoomp
std::lock_guard<std::mutex> lk(s_bgSaveMutex);
@@ -758,11 +784,17 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
s_bgResult.thumbSize = thumbSz;
memcpy(s_bgResult.textMeta, meta, sizeof(meta));
s_bgResult.textMetaBytes = metaLen;
s_bgResult.isAutosave = modeAutosave;
s_bgResult.startTickMs = startMs;
s_bgResult.rawBytes = fileSize;
s_bgResult.compressedBytes = compLen;
s_bgResult.pending = true;
}
else
{
app.DebugPrintf("save buf alloc failed\n");
ServerRuntime::LogError("world-io",
"save compression failed: out of memory; save dropped");
s_bgSaveActive.store(false, std::memory_order_release);
}
delete[] snap;
@@ -770,6 +802,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
return;
}
app.DebugPrintf("snapshot alloc failed (%u bytes)\n", fileSize);
ServerRuntime::LogError("world-io", "save snapshot allocation failed; save dropped");
#endif
// Assume that the compression will make it smaller so initially attempt to allocate the current file size
@@ -983,6 +1016,22 @@ int ConsoleSaveFileOriginal::SaveSaveDataCallback(LPVOID lpParam,bool bRes)
#endif
#ifdef MINECRAFT_SERVER_BUILD
{
const int64_t totalMs = static_cast<int64_t>(GetTickCount()) - s_lastSaveStartTickMs;
const char *mode = s_lastSaveIsAutosave ? "autosave" : "exit";
if (bRes)
{
ServerRuntime::LogInfof("world-io",
"save write completed: mode=%s raw=%u compressed=%u total=%lldms",
mode, s_lastSaveRawBytes, s_lastSaveCompressedBytes, (long long)totalMs);
}
else
{
ServerRuntime::LogErrorf("world-io",
"save write FAILED: mode=%s raw=%u compressed=%u total=%lldms",
mode, s_lastSaveRawBytes, s_lastSaveCompressedBytes, (long long)totalMs);
}
}
s_bgSaveActive.store(false, std::memory_order_release);
#endif
@@ -1237,17 +1286,32 @@ void *ConsoleSaveFileOriginal::getWritePointer(FileEntry *file)
#ifdef MINECRAFT_SERVER_BUILD
void ConsoleSaveFileOriginal::flushPendingBackgroundSave()
{
std::lock_guard<std::mutex> lk(s_bgSaveMutex);
if (!s_bgResult.pending)
return;
PBYTE thumbData = nullptr;
DWORD thumbSize = 0;
BYTE textMeta[88] = {};
int textMetaBytes = 0;
void *owner = nullptr;
{
std::lock_guard<std::mutex> lk(s_bgSaveMutex);
if (!s_bgResult.pending)
return;
StorageManager.SetSaveImages(
s_bgResult.thumbData, s_bgResult.thumbSize,
nullptr, 0, s_bgResult.textMeta, s_bgResult.textMetaBytes);
StorageManager.SaveSaveData(&ConsoleSaveFileOriginal::SaveSaveDataCallback, s_bgResult.owner);
thumbData = s_bgResult.thumbData;
thumbSize = s_bgResult.thumbSize;
memcpy(textMeta, s_bgResult.textMeta, sizeof(textMeta));
textMetaBytes = s_bgResult.textMetaBytes;
owner = s_bgResult.owner;
s_bgResult.pending = false;
// the actual write isnt done until SaveSaveDataCallback fires
s_lastSaveIsAutosave = s_bgResult.isAutosave;
s_lastSaveStartTickMs = s_bgResult.startTickMs;
s_lastSaveRawBytes = s_bgResult.rawBytes;
s_lastSaveCompressedBytes = s_bgResult.compressedBytes;
s_bgResult.pending = false;
}
StorageManager.SetSaveImages(thumbData, thumbSize, nullptr, 0, textMeta, textMetaBytes);
StorageManager.SaveSaveData(&ConsoleSaveFileOriginal::SaveSaveDataCallback, owner);
}
bool ConsoleSaveFileOriginal::hasPendingBackgroundSave()
+4 -4
View File
@@ -41,7 +41,7 @@ CustomLevelSource::CustomLevelSource(Level *level, int64_t seed, bool generateSt
{
#ifdef _DURANGO
__debugbreak(); // TODO
DEBUG_BREAK(); // TODO
DWORD bytesRead,dwFileSize = 0;
#else
DWORD bytesRead,dwFileSize = GetFileSize(file,nullptr);
@@ -49,7 +49,7 @@ CustomLevelSource::CustomLevelSource(Level *level, int64_t seed, bool generateSt
if(dwFileSize > m_heightmapOverride.length)
{
app.DebugPrintf("Heightmap binary is too large!!\n");
__debugbreak();
DEBUG_BREAK();
}
BOOL bSuccess = ReadFile(file,m_heightmapOverride.data,dwFileSize,&bytesRead,nullptr);
@@ -83,7 +83,7 @@ CustomLevelSource::CustomLevelSource(Level *level, int64_t seed, bool generateSt
{
#ifdef _DURANGO
__debugbreak(); // TODO
DEBUG_BREAK(); // TODO
DWORD bytesRead,dwFileSize = 0;
#else
DWORD bytesRead,dwFileSize = GetFileSize(file,nullptr);
@@ -91,7 +91,7 @@ CustomLevelSource::CustomLevelSource(Level *level, int64_t seed, bool generateSt
if(dwFileSize > m_waterheightOverride.length)
{
app.DebugPrintf("waterheight binary is too large!!\n");
__debugbreak();
DEBUG_BREAK();
}
BOOL bSuccess = ReadFile(file,m_waterheightOverride.data,dwFileSize,&bytesRead,nullptr);
+1 -1
View File
@@ -44,7 +44,7 @@ CustomPayloadPacket::CustomPayloadPacket(const wstring &identifier, byteArray da
{
app.DebugPrintf("Payload may not be larger than 32K\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
//throw new IllegalArgumentException("Payload may not be larger than 32k");
}
+12
View File
@@ -0,0 +1,12 @@
#pragma once
#include <csignal>
#if defined(_MSC_VER)
#define DEBUG_BREAK() __debugbreak()
#elif defined(__GNUC__) || defined(__clang__)
#define DEBUG_BREAK() __builtin_trap()
#elif defined(SIGTRAP)
#define DEBUG_BREAK() std::raise(SIGTRAP)
#else
#define DEBUG_BREAK() ((void)0)
#endif
+2 -2
View File
@@ -43,7 +43,7 @@ int _MapDataMappings::getDimension(int id)
default:
#ifndef _CONTENT_PACKAGE
printf("Read invalid dimension from MapDataMapping\n");
__debugbreak();
DEBUG_BREAK();
#endif
break;
}
@@ -72,7 +72,7 @@ void _MapDataMappings::setMapping(int id, PlayerUID xuid, int dimension)
default:
#ifndef _CONTENT_PACKAGE
printf("Trinyg to set a MapDataMapping for an invalid dimension.\n");
__debugbreak();
DEBUG_BREAK();
#endif
break;
}
+2 -1
View File
@@ -194,7 +194,8 @@ bool DoorTile::use(Level *level, int x, int y, int z, shared_ptr<Player> player,
return false;
}
if (material == Material::metal) return true;
// Match vanilla Java: iron doors don't consume right-click so held items still fire.
if (material == Material::metal) return false;
int compositeData = getCompositeData(level, x, y, z);
int lowerData = compositeData & C_LOWER_DATA_MASK;
+1 -1
View File
@@ -83,7 +83,7 @@ void Enchantment::_init(int id)
{
app.DebugPrintf("Duplicate enchantment id!");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
//throw new IllegalArgumentException("Duplicate enchantment id!");
}
+1 -1
View File
@@ -111,7 +111,7 @@ int Entity::getSmallId()
return fallbackId;
#else
app.DebugPrintf("Out of small entity Ids... possible leak?\n");
__debugbreak();
DEBUG_BREAK();
return -1;
#endif
}
+1 -1
View File
@@ -239,7 +239,7 @@ bool File::renameTo(File dest)
std::string sourcePath = wstringtofilename(getPath());
const char *destPath = wstringtofilename(dest.getPath());
#ifdef _DURANGO
__debugbreak(); // TODO
DEBUG_BREAK(); // TODO
BOOL result = false;
#else
BOOL result = MoveFile(sourcePath.c_str(), destPath);
+1 -1
View File
@@ -298,7 +298,7 @@ void FileHeader::ReadHeader( LPVOID saveMem, ESavePlatform plat /*= SAVE_FILE_PL
default:
#ifndef _CONTENT_PACKAGE
app.DebugPrintf("********** Invalid save version %d\n",m_saveVersion);
__debugbreak();
DEBUG_BREAK();
#endif
break;
}
-1
View File
@@ -44,7 +44,6 @@ FileInputStream::FileInputStream(const File &file)
if( m_fileHandle == INVALID_HANDLE_VALUE )
{
// TODO 4J Stu - Any form of error/exception handling
//__debugbreak();
app.FatalLoadError();
}
}
+1 -1
View File
@@ -23,7 +23,7 @@ GameCommandPacket::GameCommandPacket(EGameCommand command, byteArray data)
{
app.DebugPrintf("Payload may not be larger than 32K\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
DEBUG_BREAK();
#endif
//throw new IllegalArgumentException("Payload may not be larger than 32k");
}
+1 -1
View File
@@ -2411,7 +2411,7 @@ void Level::tickEntities()
{
if(isClientSide)
{
__debugbreak();
DEBUG_BREAK();
}
it = tileEntityList.erase(it);
}
+1 -1
View File
@@ -38,7 +38,7 @@ void MoveEntityPacket::write(DataOutputStream *dos) //throws IOException
if( (id < 0 ) || (id >= 16384 ) )
{
// We shouln't be tracking an entity that doesn't have a short type of id
__debugbreak();
DEBUG_BREAK();
}
dos->writeShort(static_cast<short>(id));
}
+5 -5
View File
@@ -22,7 +22,7 @@ MoveEntityPacketSmall::MoveEntityPacketSmall(int id)
if( (id < 0 ) || (id >= 16384 ) )
{
// We shouln't be tracking an entity that doesn't have a short type of id
__debugbreak();
DEBUG_BREAK();
}
this->id = id;
@@ -45,7 +45,7 @@ void MoveEntityPacketSmall::write(DataOutputStream *dos) //throws IOException
if( (id < 0 ) || (id >= 16384 ) )
{
// We shouln't be tracking an entity that doesn't have a short type of id
__debugbreak();
DEBUG_BREAK();
}
dos->writeShort(static_cast<short>(id));
}
@@ -102,7 +102,7 @@ void MoveEntityPacketSmall::PosRot::write(DataOutputStream *dos) //throws IOExce
if( (id < 0 ) || (id >= 16384 ) )
{
// We shouln't be tracking an entity that doesn't have a short type of id
__debugbreak();
DEBUG_BREAK();
}
short idAndRot = id | yRot << 11;
dos->writeShort(idAndRot);
@@ -141,7 +141,7 @@ void MoveEntityPacketSmall::Pos::write(DataOutputStream *dos) //throws IOExcepti
if( (id < 0 ) || (id >= 16384 ) )
{
// We shouln't be tracking an entity that doesn't have a short type of id
__debugbreak();
DEBUG_BREAK();
}
short idAndY = id | ya << 11;
dos->writeShort(idAndY);
@@ -179,7 +179,7 @@ void MoveEntityPacketSmall::Rot::write(DataOutputStream *dos) //throws IOExcepti
if( (id < 0 ) || (id >= 16384 ) )
{
// We shouln't be tracking an entity that doesn't have a short type of id
__debugbreak();
DEBUG_BREAK();
}
short idAndRot = id | yRot << 11;
dos->writeShort(idAndRot);

Some files were not shown because too many files have changed in this diff Show More