mirror of
https://github.com/celisej567/mcpe.git
synced 2026-01-05 18:10:09 +03:00
macOS Support & AppPlatform Cleanup (#57)
* macOS Support & Cleanup * Fix malformed comments in build-wasm.bat * Emscripten Fixes * * Add shebang to the grabsounds.py script Since it was changed from rw- to rwx, I'll add the shebang so that it actually runs properly. * * Re-add the patch_data and readme files. * * Remove sound data. * Fix some more things. * Think it's ready to pull now... --------- Co-authored-by: BrentDaMage <BrentDaMage@users.noreply.github.com> Co-authored-by: iProgramInCpp <iprogramincpp@gmail.com>
This commit is contained in:
10
.gitignore
vendored
10
.gitignore
vendored
@@ -365,6 +365,16 @@ MigrationBackup/
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
## Xcode User settings
|
||||
xcuserdata/
|
||||
|
||||
## Xcode 8 and earlier
|
||||
*.xcscmblueprint
|
||||
*.xccheckout
|
||||
|
||||
## Kill .DS_Store
|
||||
**/.DS_Store
|
||||
|
||||
/minecraftpe/assets/font
|
||||
/minecraftpe/assets/gui
|
||||
/minecraftpe/assets/item
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
@echo off
|
||||
|
||||
:set the path where your web server's root is (iProgramInCpp's is at C:\gtcache -- don't ask why)
|
||||
::set the path where your web server's root is (iProgramInCpp's is at C:\gtcache -- don't ask why)
|
||||
set WEBSRVROOT=C:\gtcache
|
||||
|
||||
:set the emscripten root to your emscripten installation (iProgramInCpp's is at C:\emsdk)
|
||||
::set the emscripten root to your emscripten installation (iProgramInCpp's is at C:\emsdk)
|
||||
echo * Calling emsdk_env.bat.
|
||||
set EMSCRIPTEN_ROOT=C:\emsdk
|
||||
set OLDCD=%cd%
|
||||
@@ -11,46 +11,46 @@ cd /d %EMSCRIPTEN_ROOT%
|
||||
call emsdk_env.bat
|
||||
cd %OLDCD%
|
||||
|
||||
:working directory
|
||||
::working directory
|
||||
echo * Creating wasm working directory.
|
||||
md wasm
|
||||
cd wasm
|
||||
|
||||
:create output directory
|
||||
::create output directory
|
||||
echo * Creating output directory.
|
||||
del /s /q dist
|
||||
md dist
|
||||
|
||||
:create build directory
|
||||
::create build directory
|
||||
echo * Creating build directory
|
||||
md build
|
||||
cd build
|
||||
|
||||
:note: Why the hell do I need to pop it into a separate window? When I don't, the batch
|
||||
:file just stops...
|
||||
::note: Why the hell do I need to pop it into a separate window? When I don't, the batch
|
||||
::file just stops...
|
||||
|
||||
:configure build
|
||||
::configure build
|
||||
echo * Configuring build.
|
||||
start emcmake cmake -GNinja "$@" ..\..\platforms/sdl
|
||||
echo * PRESS ANY KEY when emcmake is done.
|
||||
pause > nul
|
||||
|
||||
:build
|
||||
::build
|
||||
echo * Starting build.
|
||||
cmake --build .
|
||||
echo * PRESS ANY KEY when CMake is done.
|
||||
pause > nul
|
||||
|
||||
:bundle
|
||||
::bundle
|
||||
echo * Copying bundle data over.
|
||||
copy reminecraftpe.* ..\dist\
|
||||
copy ..\..\platforms\sdl\wasm_shell.html ..\dist\reminecraftpe.html
|
||||
copy reminecraftpe.* ..\dist
|
||||
copy ..\..\platforms\emscripten\wasm_shell.html ..\dist\reminecraftpe.html
|
||||
copy ..\..\thirdparty\coi-serviceworker\coi-serviceworker.min.js ..\dist
|
||||
|
||||
:for me only
|
||||
::for me only
|
||||
echo * Copying to your webserver.
|
||||
copy ..\dist\* %WEBSRVROOT%\dist
|
||||
xcopy /E /Y ..\dist\ %WEBSRVROOT%\dist\
|
||||
|
||||
:cd back
|
||||
::cd back
|
||||
echo * And we are done!!
|
||||
cd %OLDCD%
|
||||
|
||||
@@ -48,8 +48,12 @@ static inline void gluPerspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, G
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <SDL2/SDL_opengl.h>
|
||||
#include <SDL2/SDL_opengl_glext.h>
|
||||
#ifdef __APPLE__
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define xglBindBuffer glBindBuffer
|
||||
#define xglBufferData glBufferData
|
||||
|
||||
33
platforms/emscripten/AppPlatform_emscripten.cpp
Normal file
33
platforms/emscripten/AppPlatform_emscripten.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "AppPlatform_emscripten.hpp"
|
||||
|
||||
#include <emscripten.h>
|
||||
|
||||
#include "client/common/Utils.hpp"
|
||||
|
||||
AppPlatform_emscripten::AppPlatform_emscripten(std::string storageDir, SDL_Window *window)
|
||||
: AppPlatform_sdlbase(storageDir, window)
|
||||
{
|
||||
}
|
||||
|
||||
Texture AppPlatform_emscripten::loadTexture(const std::string& path, bool b)
|
||||
{
|
||||
Texture out;
|
||||
out.field_C = 1;
|
||||
out.field_D = 0;
|
||||
|
||||
std::string realPath = getAssetPath(path);
|
||||
|
||||
char *data = emscripten_get_preloaded_image_data(("/" + realPath).c_str(), &out.m_width, &out.m_height);
|
||||
if (data != NULL)
|
||||
{
|
||||
size_t data_size = out.m_width * out.m_height * 4;
|
||||
out.m_pixels = (uint32_t *) new unsigned char[data_size];
|
||||
memcpy(out.m_pixels, data, data_size);
|
||||
free(data);
|
||||
return out;
|
||||
}
|
||||
|
||||
// I don't think this logic makes any sense
|
||||
LogMsg("Couldn't find file: %s", realPath.c_str());
|
||||
return out;
|
||||
}
|
||||
13
platforms/emscripten/AppPlatform_emscripten.hpp
Normal file
13
platforms/emscripten/AppPlatform_emscripten.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "../sdl/AppPlatform_sdl.hpp"
|
||||
|
||||
class AppPlatform_emscripten : public AppPlatform_sdlbase
|
||||
{
|
||||
public:
|
||||
AppPlatform_emscripten(std::string storageDir, SDL_Window *window);
|
||||
|
||||
Texture loadTexture(const std::string& path, bool b = false) override;
|
||||
};
|
||||
2584
platforms/macos/Minecraft/Minecraft.xcodeproj/project.pbxproj
Normal file
2584
platforms/macos/Minecraft/Minecraft.xcodeproj/project.pbxproj
Normal file
File diff suppressed because it is too large
Load Diff
7
platforms/macos/Minecraft/Minecraft.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
platforms/macos/Minecraft/Minecraft.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>PreviewsEnabled</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1420"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8489B0962A86D4B2004CA8EC"
|
||||
BuildableName = "Minecraft"
|
||||
BlueprintName = "Minecraft"
|
||||
ReferencedContainer = "container:Minecraft.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "YES"
|
||||
customWorkingDirectory = "$(PROJECT_DIR)/../../../game/"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
enableGPUValidationMode = "1"
|
||||
allowLocationSimulation = "YES"
|
||||
viewDebuggingEnabled = "No">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8489B0962A86D4B2004CA8EC"
|
||||
BuildableName = "Minecraft"
|
||||
BlueprintName = "Minecraft"
|
||||
ReferencedContainer = "container:Minecraft.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8489B0962A86D4B2004CA8EC"
|
||||
BuildableName = "Minecraft"
|
||||
BlueprintName = "Minecraft"
|
||||
ReferencedContainer = "container:Minecraft.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -6,6 +6,9 @@
|
||||
#include <thirdparty/OpenAL/Include/al.h>
|
||||
#include <thirdparty/OpenAL/Include/alc.h>
|
||||
#pragma comment( lib, "OpenAl32.lib" )
|
||||
#elif defined(__APPLE__)
|
||||
#include <OpenAL/al.h>
|
||||
#include <OpenAL/alc.h>
|
||||
#else
|
||||
#include <AL/al.h>
|
||||
#include <AL/alc.h>
|
||||
|
||||
@@ -1,29 +1,16 @@
|
||||
#include "AppPlatform_sdl.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
#include <png.h>
|
||||
|
||||
#include "compat/GL.hpp"
|
||||
#else
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
|
||||
#include "client/common/Utils.hpp"
|
||||
|
||||
AppPlatform_sdl::AppPlatform_sdl(std::string storageDir, SDL_Window *window)
|
||||
: AppPlatform_sdlbase(storageDir, window, loadTexture("gui/default_world.png"))
|
||||
{
|
||||
_storageDir = storageDir;
|
||||
_window = window;
|
||||
}
|
||||
|
||||
int AppPlatform_sdl::checkLicense()
|
||||
{
|
||||
// we own the game!!
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Ensure Screenshots Folder Exists
|
||||
@@ -48,7 +35,6 @@ void ensure_screenshots_folder(const char *screenshots)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
// Take Screenshot
|
||||
static int save_png(const char *filename, unsigned char *pixels, int line_size, int width, int height)
|
||||
{
|
||||
@@ -123,6 +109,7 @@ ret:
|
||||
// Return
|
||||
return ret;
|
||||
}
|
||||
|
||||
void AppPlatform_sdl::saveScreenshot(const std::string& filename, int glWidth, int glHeight)
|
||||
{
|
||||
// Get Directory
|
||||
@@ -199,47 +186,25 @@ void AppPlatform_sdl::saveScreenshot(const std::string& filename, int glWidth, i
|
||||
free(pixels);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int AppPlatform_sdl::getScreenWidth() const
|
||||
{
|
||||
int width;
|
||||
SDL_GL_GetDrawableSize(_window, &width, nullptr);
|
||||
return width;
|
||||
}
|
||||
|
||||
int AppPlatform_sdl::getScreenHeight() const
|
||||
{
|
||||
int height;
|
||||
SDL_GL_GetDrawableSize(_window, nullptr, &height);
|
||||
return height;
|
||||
}
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
static void png_read_sdl(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
SDL_RWread((SDL_RWops *) png_get_io_ptr(png_ptr), (char *) data, length, 1);
|
||||
}
|
||||
|
||||
static void nop_png_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||
{
|
||||
// Do Nothing
|
||||
}
|
||||
#endif
|
||||
Texture AppPlatform_sdl::loadTexture(const std::string& str, bool b)
|
||||
|
||||
Texture AppPlatform_sdl::loadTexture(const std::string& path, bool b)
|
||||
{
|
||||
Texture out;
|
||||
out.field_C = 1;
|
||||
out.field_D = 0;
|
||||
|
||||
std::string realPath = str;
|
||||
if (realPath.size() && realPath[0] == '/')
|
||||
{
|
||||
// trim it off
|
||||
realPath = realPath.substr(1);
|
||||
}
|
||||
realPath = "assets/" + realPath;
|
||||
std::string realPath = getAssetPath(path);
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
SDL_RWops *io = SDL_RWFromFile(realPath.c_str(), "rb");
|
||||
|
||||
if (io != NULL)
|
||||
@@ -314,57 +279,8 @@ Texture AppPlatform_sdl::loadTexture(const std::string& str, bool b)
|
||||
delete[](png_bytep) rowPtrs;
|
||||
SDL_RWclose(io);
|
||||
}
|
||||
#else
|
||||
char *data = emscripten_get_preloaded_image_data(("/" + realPath).c_str(), &out.m_width, &out.m_height);
|
||||
if (data != NULL)
|
||||
{
|
||||
size_t data_size = out.m_width * out.m_height * 4;
|
||||
out.m_pixels = (uint32_t *) new unsigned char[data_size];
|
||||
memcpy(out.m_pixels, data, data_size);
|
||||
free(data);
|
||||
return out;
|
||||
}
|
||||
#endif
|
||||
|
||||
LogMsg("Couldn't find file: %s", str.c_str());
|
||||
// I don't think this logic makes any sense
|
||||
LogMsg("Couldn't find file: %s", path.c_str());
|
||||
return out;
|
||||
}
|
||||
|
||||
void AppPlatform_sdl::setMouseGrabbed(bool b)
|
||||
{
|
||||
SDL_SetWindowGrab(_window, b ? SDL_TRUE : SDL_FALSE);
|
||||
SDL_SetRelativeMouseMode(b ? SDL_TRUE : SDL_FALSE);
|
||||
}
|
||||
|
||||
void AppPlatform_sdl::setMouseDiff(int x, int y)
|
||||
{
|
||||
xrel = x;
|
||||
yrel = y;
|
||||
}
|
||||
|
||||
void AppPlatform_sdl::getMouseDiff(int& x, int& y)
|
||||
{
|
||||
x = xrel;
|
||||
y = yrel;
|
||||
}
|
||||
|
||||
void AppPlatform_sdl::clearDiff()
|
||||
{
|
||||
xrel = 0;
|
||||
yrel = 0;
|
||||
}
|
||||
|
||||
bool AppPlatform_sdl::shiftPressed()
|
||||
{
|
||||
return m_bShiftPressed[0] || m_bShiftPressed[1];
|
||||
}
|
||||
|
||||
void AppPlatform_sdl::setShiftPressed(bool b, bool isLeft)
|
||||
{
|
||||
m_bShiftPressed[isLeft ? 0 : 1] = b;
|
||||
}
|
||||
|
||||
int AppPlatform_sdl::getUserInputStatus()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -4,43 +4,15 @@
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
#include "AppPlatform.hpp"
|
||||
|
||||
#ifdef ORIGINAL_CODE
|
||||
#error "This isn't original code. You probably shouldn't try to compile this"
|
||||
#endif
|
||||
#include "AppPlatform_sdlbase.hpp"
|
||||
|
||||
void ensure_screenshots_folder(const char *screenshots);
|
||||
|
||||
class AppPlatform_sdl : public AppPlatform
|
||||
class AppPlatform_sdl : public AppPlatform_sdlbase
|
||||
{
|
||||
public:
|
||||
AppPlatform_sdl(std::string storageDir, SDL_Window *window);
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
void saveScreenshot(const std::string& fileName, int width, int height) override;
|
||||
#endif
|
||||
int checkLicense() override;
|
||||
int getScreenWidth() const override;
|
||||
int getScreenHeight() const override;
|
||||
Texture loadTexture(const std::string& str, bool b) override;
|
||||
int getUserInputStatus() override;
|
||||
|
||||
// Also add these to allow proper turning within the game.
|
||||
void setMouseGrabbed(bool b) override;
|
||||
void setMouseDiff(int x, int y);
|
||||
void getMouseDiff(int& x, int& y) override;
|
||||
void clearDiff() override;
|
||||
|
||||
// Also add these to allow proper text input within the game.
|
||||
bool shiftPressed() override;
|
||||
void setShiftPressed(bool b, bool isLeft);
|
||||
private:
|
||||
std::string _storageDir;
|
||||
SDL_Window *_window;
|
||||
|
||||
bool m_bShiftPressed[2] = {false, false};
|
||||
|
||||
int xrel;
|
||||
int yrel;
|
||||
Texture loadTexture(const std::string& path, bool b = false) override;
|
||||
};
|
||||
|
||||
122
platforms/sdl/AppPlatform_sdlbase.cpp
Normal file
122
platforms/sdl/AppPlatform_sdlbase.cpp
Normal file
@@ -0,0 +1,122 @@
|
||||
#include "AppPlatform_sdlbase.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#else
|
||||
#include <png.h>
|
||||
|
||||
#include "compat/GL.hpp"
|
||||
#endif
|
||||
|
||||
#include "client/common/Utils.hpp"
|
||||
|
||||
void AppPlatform_sdlbase::_init(std::string storageDir, SDL_Window *window)
|
||||
{
|
||||
_storageDir = storageDir;
|
||||
_window = window;
|
||||
|
||||
_iconTexture = nullptr;
|
||||
_icon = nullptr;
|
||||
|
||||
m_bShiftPressed[0] = false;
|
||||
m_bShiftPressed[1] = false;
|
||||
}
|
||||
|
||||
void AppPlatform_sdlbase::_init(std::string storageDir, SDL_Window *window, const Texture& icon)
|
||||
{
|
||||
_init(storageDir, window);
|
||||
|
||||
_iconTexture = new Texture(icon);
|
||||
_icon = getSurfaceForTexture(_iconTexture);
|
||||
if (_icon)
|
||||
SDL_SetWindowIcon(window, _icon);
|
||||
}
|
||||
|
||||
AppPlatform_sdlbase::~AppPlatform_sdlbase()
|
||||
{
|
||||
SDL_FreeSurface(_icon);
|
||||
delete _iconTexture;
|
||||
}
|
||||
|
||||
SDL_Surface* AppPlatform_sdlbase::getSurfaceForTexture(const Texture* const texture)
|
||||
{
|
||||
if (!texture) return nullptr;
|
||||
|
||||
void * const pixels = texture->m_pixels;
|
||||
const int width = texture->m_width;
|
||||
const int height = texture->m_height;
|
||||
const int depth = 32; // Color depth (32-bit by default)
|
||||
SDL_Surface* surface = SDL_CreateRGBSurfaceFrom(
|
||||
pixels, width, height, depth,
|
||||
width * 4, // Pitch
|
||||
0x000000FF, 0x0000FF00, 0x00FF0000,
|
||||
0xFF000000
|
||||
);
|
||||
if (!surface)
|
||||
LogMsg("Error loading SDL_Surface from Texture: %s", SDL_GetError());
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
int AppPlatform_sdlbase::checkLicense()
|
||||
{
|
||||
// we own the game!!
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AppPlatform_sdlbase::getScreenWidth() const
|
||||
{
|
||||
int width;
|
||||
SDL_GL_GetDrawableSize(_window, &width, nullptr);
|
||||
return width;
|
||||
}
|
||||
|
||||
int AppPlatform_sdlbase::getScreenHeight() const
|
||||
{
|
||||
int height;
|
||||
SDL_GL_GetDrawableSize(_window, nullptr, &height);
|
||||
return height;
|
||||
}
|
||||
|
||||
void AppPlatform_sdlbase::setMouseGrabbed(bool b)
|
||||
{
|
||||
SDL_SetWindowGrab(_window, b ? SDL_TRUE : SDL_FALSE);
|
||||
SDL_SetRelativeMouseMode(b ? SDL_TRUE : SDL_FALSE);
|
||||
}
|
||||
|
||||
void AppPlatform_sdlbase::setMouseDiff(int x, int y)
|
||||
{
|
||||
xrel = x;
|
||||
yrel = y;
|
||||
}
|
||||
|
||||
void AppPlatform_sdlbase::getMouseDiff(int& x, int& y)
|
||||
{
|
||||
x = xrel;
|
||||
y = yrel;
|
||||
}
|
||||
|
||||
void AppPlatform_sdlbase::clearDiff()
|
||||
{
|
||||
xrel = 0;
|
||||
yrel = 0;
|
||||
}
|
||||
|
||||
bool AppPlatform_sdlbase::shiftPressed()
|
||||
{
|
||||
return m_bShiftPressed[0] || m_bShiftPressed[1];
|
||||
}
|
||||
|
||||
void AppPlatform_sdlbase::setShiftPressed(bool b, bool isLeft)
|
||||
{
|
||||
m_bShiftPressed[isLeft ? 0 : 1] = b;
|
||||
}
|
||||
|
||||
int AppPlatform_sdlbase::getUserInputStatus()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
59
platforms/sdl/AppPlatform_sdlbase.hpp
Normal file
59
platforms/sdl/AppPlatform_sdlbase.hpp
Normal file
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
#include "AppPlatform.hpp"
|
||||
|
||||
#ifdef ORIGINAL_CODE
|
||||
#error "This isn't original code. You probably shouldn't try to compile this"
|
||||
#endif
|
||||
|
||||
void ensure_screenshots_folder(const char *screenshots);
|
||||
|
||||
class AppPlatform_sdlbase : public AppPlatform
|
||||
{
|
||||
public:
|
||||
void _init(std::string storageDir, SDL_Window *window);
|
||||
void _init(std::string storageDir, SDL_Window *window, const Texture& icon);
|
||||
AppPlatform_sdlbase(std::string storageDir, SDL_Window *window)
|
||||
{
|
||||
_init(storageDir, window);
|
||||
}
|
||||
AppPlatform_sdlbase(std::string storageDir, SDL_Window *window, const Texture& icon)
|
||||
{
|
||||
_init(storageDir, window, icon);
|
||||
}
|
||||
~AppPlatform_sdlbase();
|
||||
|
||||
int checkLicense() override;
|
||||
int getScreenWidth() const override;
|
||||
int getScreenHeight() const override;
|
||||
Texture loadTexture(const std::string& path, bool b = false) override = 0;
|
||||
int getUserInputStatus() override;
|
||||
|
||||
// Also add these to allow proper turning within the game.
|
||||
void setMouseGrabbed(bool b) override;
|
||||
void setMouseDiff(int x, int y);
|
||||
void getMouseDiff(int& x, int& y) override;
|
||||
void clearDiff() override;
|
||||
|
||||
// Also add these to allow proper text input within the game.
|
||||
bool shiftPressed() override;
|
||||
void setShiftPressed(bool b, bool isLeft);
|
||||
private:
|
||||
SDL_Window *_window;
|
||||
|
||||
const Texture *_iconTexture;
|
||||
SDL_Surface *_icon;
|
||||
|
||||
bool m_bShiftPressed[2];
|
||||
|
||||
int xrel;
|
||||
int yrel;
|
||||
|
||||
static SDL_Surface* getSurfaceForTexture(const Texture* const texture);
|
||||
protected:
|
||||
std::string _storageDir;
|
||||
};
|
||||
@@ -27,11 +27,21 @@ else()
|
||||
endif()
|
||||
|
||||
# Build
|
||||
if(EMSCRIPTEN)
|
||||
add_executable(reminecraftpe
|
||||
main.cpp
|
||||
AppPlatform_sdlbase.cpp
|
||||
../emscripten/AppPlatform_emscripten.cpp
|
||||
../openal/SoundSystemAL.cpp
|
||||
)
|
||||
else()
|
||||
add_executable(reminecraftpe
|
||||
main.cpp
|
||||
AppPlatform_sdlbase.cpp
|
||||
AppPlatform_sdl.cpp
|
||||
../openal/SoundSystemAL.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
# Core
|
||||
add_subdirectory(../../source source)
|
||||
@@ -58,7 +68,7 @@ endif()
|
||||
|
||||
# Assets
|
||||
if(EMSCRIPTEN)
|
||||
target_link_options(reminecraftpe PRIVATE --use-preload-plugins --preload-file "${CMAKE_CURRENT_SOURCE_DIR}/assets@/assets")
|
||||
target_link_options(reminecraftpe PRIVATE --use-preload-plugins --preload-file "${CMAKE_CURRENT_SOURCE_DIR}/../../game/assets@/assets")
|
||||
elseif(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/assets")
|
||||
file(CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR}/assets" "${CMAKE_CURRENT_BINARY_DIR}/assets" SYMBOLIC)
|
||||
endif()
|
||||
|
||||
@@ -5,12 +5,22 @@
|
||||
#include "compat/GL.hpp"
|
||||
#include "compat/AKeyCodes.hpp"
|
||||
#include "App.hpp"
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include "../emscripten/AppPlatform_emscripten.hpp"
|
||||
#define APP_PLATFORM_TYPE AppPlatform_emscripten
|
||||
#else
|
||||
#include "AppPlatform_sdl.hpp"
|
||||
#define APP_PLATFORM_TYPE AppPlatform_sdl
|
||||
#endif
|
||||
#include "NinecraftApp.hpp"
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#include <emscripten/html5.h>
|
||||
#else
|
||||
#define EM_BOOL bool
|
||||
#define EM_TRUE true
|
||||
#define EM_FALSE false
|
||||
#endif
|
||||
|
||||
void LogMsg(const char* fmt, ...)
|
||||
@@ -34,7 +44,7 @@ void LogMsgNoCR(const char* fmt, ...)
|
||||
va_end(lst);
|
||||
}
|
||||
|
||||
AppPlatform_sdl *g_AppPlatform;
|
||||
APP_PLATFORM_TYPE *g_AppPlatform;
|
||||
NinecraftApp *g_pApp;
|
||||
|
||||
SDL_Window *window = NULL;
|
||||
@@ -88,18 +98,23 @@ static void handle_events()
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
{
|
||||
Mouse::feed(event.button.button == SDL_BUTTON_LEFT ? 1 : 2, event.button.state == SDL_PRESSED ? 1 : 0, event.button.x, event.button.y);
|
||||
const float scale = Minecraft::getDrawScale();
|
||||
Mouse::feed(event.button.button == SDL_BUTTON_LEFT ? 1 : 2, event.button.state == SDL_PRESSED ? 1 : 0, event.button.x * scale, event.button.y * scale);
|
||||
break;
|
||||
}
|
||||
case SDL_MOUSEMOTION:
|
||||
{
|
||||
Mouse::feed(0, 0, event.motion.x, event.motion.y);
|
||||
g_AppPlatform->setMouseDiff(event.motion.xrel, event.motion.yrel);
|
||||
const float scale = Minecraft::getDrawScale();
|
||||
float x = event.motion.x * scale;
|
||||
float y = event.motion.y * scale;
|
||||
Mouse::setX(x); Mouse::setY(y);
|
||||
Mouse::feed(0, 0, x, y);
|
||||
g_AppPlatform->setMouseDiff(event.motion.xrel * scale, event.motion.yrel * scale);
|
||||
break;
|
||||
}
|
||||
case SDL_MOUSEWHEEL:
|
||||
{
|
||||
Mouse::feed(3, event.wheel.y, Mouse::getX(), Mouse::getY());
|
||||
Mouse::feed(3, event.wheel.y * Minecraft::getDrawScale(), Mouse::getX(), Mouse::getY());
|
||||
break;
|
||||
}
|
||||
case SDL_TEXTINPUT:
|
||||
@@ -131,46 +146,24 @@ static void handle_events()
|
||||
}
|
||||
}
|
||||
|
||||
// GUI Scale
|
||||
static void calculate_gui_scale()
|
||||
{
|
||||
int width = Minecraft::width;
|
||||
|
||||
// Modified Version Of https://github.com/MCPI-Revival/Ninecraft/blob/3f71638a10b581f6a50669edb24bc1ef1a92fbea/ninecraft/src/main.c#L243-L255
|
||||
if (width < 1000)
|
||||
{
|
||||
if (width < 400)
|
||||
{
|
||||
Gui::InvGuiScale = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
Gui::InvGuiScale = 0.5f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Gui::InvGuiScale = 0.25f;
|
||||
}
|
||||
}
|
||||
|
||||
// Resizing
|
||||
static void resize()
|
||||
{
|
||||
SDL_GL_GetDrawableSize(window, &Minecraft::width, &Minecraft::height);
|
||||
|
||||
if (g_pApp != nullptr)
|
||||
{
|
||||
int drawWidth, drawHeight;
|
||||
SDL_GL_GetDrawableSize(window,
|
||||
&drawWidth, &drawHeight);
|
||||
|
||||
int windowWidth, windowHeight;
|
||||
SDL_GetWindowSize(window,
|
||||
&windowWidth, &windowHeight);
|
||||
|
||||
Minecraft::setDisplayProperties(drawWidth, drawHeight, windowWidth, windowHeight);
|
||||
|
||||
if (g_pApp)
|
||||
g_pApp->sizeUpdate(Minecraft::width, Minecraft::height);
|
||||
}
|
||||
}
|
||||
|
||||
// Main Loop
|
||||
#ifndef __EMSCRIPTEN__
|
||||
#define EM_BOOL bool
|
||||
#define EM_TRUE true
|
||||
#define EM_FALSE false
|
||||
#endif
|
||||
static bool is_first_window_resize = true;
|
||||
static EM_BOOL main_loop(double time, void *user_data)
|
||||
{
|
||||
@@ -245,7 +238,8 @@ int main(int argc, char *argv[])
|
||||
CheckOptionalTextureAvailability();
|
||||
|
||||
// Create Window
|
||||
window = SDL_CreateWindow("ReMinecraftPE", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, Minecraft::width, Minecraft::height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
|
||||
window = SDL_CreateWindow("ReMinecraftPE", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, Minecraft::width, Minecraft::height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE |
|
||||
SDL_WINDOW_ALLOW_HIGHDPI);
|
||||
if (!window)
|
||||
{
|
||||
LOGE("Unable To Create SDL Window\n");
|
||||
@@ -273,26 +267,29 @@ int main(int argc, char *argv[])
|
||||
atexit(teardown);
|
||||
#endif
|
||||
|
||||
// Set Size
|
||||
resize();
|
||||
|
||||
// Storage Directory
|
||||
std::string storagePath;
|
||||
#ifdef _WIN32
|
||||
std::string storagePath = getenv("APPDATA");
|
||||
storagePath = getenv("APPDATA");
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
std::string storagePath = "";
|
||||
storagePath = "";
|
||||
#else
|
||||
std::string storagePath = getenv("HOME");
|
||||
storagePath = getenv("HOME");
|
||||
#endif
|
||||
storagePath += "/.reminecraftpe";
|
||||
#ifndef __EMSCRIPTEN__
|
||||
ensure_screenshots_folder(storagePath.c_str());
|
||||
|
||||
#endif
|
||||
|
||||
// Start MCPE
|
||||
g_pApp = new NinecraftApp;
|
||||
g_pApp->m_externalStorageDir = storagePath;
|
||||
g_AppPlatform = new AppPlatform_sdl(g_pApp->m_externalStorageDir, window);
|
||||
g_AppPlatform = new APP_PLATFORM_TYPE(g_pApp->m_externalStorageDir, window);
|
||||
g_pApp->m_pPlatform = g_AppPlatform;
|
||||
g_pApp->init();
|
||||
|
||||
// Set Size
|
||||
resize();
|
||||
|
||||
// Loop
|
||||
#ifndef __EMSCRIPTEN__
|
||||
|
||||
@@ -131,3 +131,16 @@ std::string AppPlatform::getPatchData()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string AppPlatform::getAssetPath(const std::string &path) const
|
||||
{
|
||||
std::string realPath = path;
|
||||
if (realPath.size() && realPath[0] == '/')
|
||||
{
|
||||
// trim it off
|
||||
realPath = realPath.substr(1);
|
||||
}
|
||||
realPath = "assets/" + realPath;
|
||||
|
||||
return realPath;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,8 @@ public:
|
||||
virtual std::string getPatchData();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual std::string getAssetPath(const std::string& path) const;
|
||||
|
||||
private:
|
||||
virtual void _tick();
|
||||
|
||||
@@ -31,18 +31,22 @@ add_library(reminecraftpe-core STATIC
|
||||
client/renderer/TileRenderer.cpp
|
||||
client/renderer/LightLayer.cpp
|
||||
client/renderer/WaterTexture.cpp
|
||||
client/network/packets/UpdateBlockPacket.cpp
|
||||
client/network/packets/RequestChunkPacket.cpp
|
||||
client/network/packets/PlayerEquipmentPacket.cpp
|
||||
client/network/packets/ChunkDataPacket.cpp
|
||||
client/network/packets/PlaceBlockPacket.cpp
|
||||
client/network/packets/LoginPacket.cpp
|
||||
client/network/packets/StartGamePacket.cpp
|
||||
client/network/packets/RemoveEntityPacket.cpp
|
||||
client/network/packets/AddPlayerPacket.cpp
|
||||
client/network/packets/RemoveBlockPacket.cpp
|
||||
client/network/packets/MovePlayerPacket.cpp
|
||||
client/network/packets/MessagePacket.cpp
|
||||
client/renderer/PatchManager.cpp
|
||||
client/renderer/LavaTexture.cpp
|
||||
client/renderer/LavaSideTexture.cpp
|
||||
client/renderer/FireTexture.cpp
|
||||
client/network/Packets/UpdateBlockPacket.cpp
|
||||
client/network/Packets/RequestChunkPacket.cpp
|
||||
client/network/Packets/PlayerEquipmentPacket.cpp
|
||||
client/network/Packets/ChunkDataPacket.cpp
|
||||
client/network/Packets/PlaceBlockPacket.cpp
|
||||
client/network/Packets/LoginPacket.cpp
|
||||
client/network/Packets/StartGamePacket.cpp
|
||||
client/network/Packets/RemoveEntityPacket.cpp
|
||||
client/network/Packets/AddPlayerPacket.cpp
|
||||
client/network/Packets/RemoveBlockPacket.cpp
|
||||
client/network/Packets/MovePlayerPacket.cpp
|
||||
client/network/Packets/MessagePacket.cpp
|
||||
client/network/ServerSideNetworkHandler.cpp
|
||||
client/network/RakNetInstance.cpp
|
||||
client/network/ClientSideNetworkHandler.cpp
|
||||
|
||||
@@ -29,9 +29,11 @@
|
||||
// custom:
|
||||
#include "client/renderer/PatchManager.hpp"
|
||||
|
||||
// note: Nothing changes these, so it'll think we're always running at 854x480 even if not
|
||||
int Minecraft::width = C_DEFAULT_SCREEN_WIDTH;
|
||||
int Minecraft::height = C_DEFAULT_SCREEN_HEIGHT;
|
||||
int Minecraft::_windowWidth = width;
|
||||
int Minecraft::_windowHeight = height;
|
||||
float Minecraft::_drawScale = 1.0f;
|
||||
bool Minecraft::useAmbientOcclusion = false;
|
||||
int Minecraft::customDebugId = 0;
|
||||
|
||||
@@ -47,7 +49,8 @@ const char* Minecraft::progressMessages[] =
|
||||
"Saving chunks",
|
||||
};
|
||||
|
||||
Minecraft::Minecraft() : m_gui(this)
|
||||
Minecraft::Minecraft() :
|
||||
m_gui(this)
|
||||
{
|
||||
field_18 = false;
|
||||
field_288 = false;
|
||||
@@ -286,7 +289,7 @@ label_3:
|
||||
// @BUG: This is only done on the client side.
|
||||
m_pLevel->extinguishFire(hr.m_tileX, hr.m_tileY, hr.m_tileZ, hr.m_hitSide);
|
||||
|
||||
if (pTile != Tile::unbreakable || m_pLocalPlayer->field_B94 > 99 && !hr.m_bUnk24)
|
||||
if (pTile != Tile::unbreakable || (m_pLocalPlayer->field_B94 > 99 && !hr.m_bUnk24))
|
||||
{
|
||||
m_pGameMode->startDestroyBlock(hr.m_tileX, hr.m_tileY, hr.m_tileZ, hr.m_hitSide);
|
||||
}
|
||||
@@ -312,12 +315,13 @@ label_3:
|
||||
{
|
||||
switch (hr.m_hitSide)
|
||||
{
|
||||
case DIR_YNEG: dy--; break;
|
||||
case DIR_YPOS: dy++; break;
|
||||
case DIR_ZNEG: dz--; break;
|
||||
case DIR_ZPOS: dz++; break;
|
||||
case DIR_XNEG: dx--; break;
|
||||
case DIR_XPOS: dx++; break;
|
||||
case HitResult::eHitSide::NOHIT: break;
|
||||
case HitResult::eHitSide::MINY: dy--; break;
|
||||
case HitResult::eHitSide::MAXY: dy++; break;
|
||||
case HitResult::eHitSide::MINZ: dz--; break;
|
||||
case HitResult::eHitSide::MAXZ: dz++; break;
|
||||
case HitResult::eHitSide::MINX: dx--; break;
|
||||
case HitResult::eHitSide::MAXX: dx++; break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -880,6 +884,7 @@ void Minecraft::prepareLevel(const std::string& unused)
|
||||
|
||||
void Minecraft::sizeUpdate(int newWidth, int newHeight)
|
||||
{
|
||||
|
||||
// re-calculate the GUI scale.
|
||||
Gui::InvGuiScale = getBestScaleForThisScreenSize(newWidth, newHeight);
|
||||
|
||||
@@ -966,6 +971,17 @@ void* Minecraft::prepareLevel_tspawn(void* ptr)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Minecraft::setDisplayProperties(
|
||||
int drawWidth, int drawHeight,
|
||||
int windowWidth, int windowHeight)
|
||||
{
|
||||
width = drawWidth; height = drawHeight;
|
||||
_windowWidth = windowWidth; _windowHeight = windowHeight;
|
||||
// Calculates the scale for the resolution at which the scene is drawn.
|
||||
// This assumes the aspect ratio is the same between the window and the actual drawing process.
|
||||
_drawScale = width / _windowWidth;
|
||||
}
|
||||
|
||||
void Minecraft::pauseGame()
|
||||
{
|
||||
if (m_pScreen) return;
|
||||
|
||||
@@ -72,6 +72,14 @@ public:
|
||||
bool isOnline();
|
||||
bool isOnlineClient();
|
||||
static void* prepareLevel_tspawn(void* pMinecraft);
|
||||
static void setDisplayProperties(
|
||||
int drawWidth, int drawHeight,
|
||||
int windowWidth, int windowHeight);
|
||||
static const int getWindowWidth() { return _windowWidth; }
|
||||
static const int getWindowHeight() { return _windowHeight; }
|
||||
static const int getDrawWidth() { return width; }
|
||||
static const int getDrawHeight() { return height; }
|
||||
static const int getDrawScale() { return _drawScale; }
|
||||
|
||||
const char* getProgressMessage();
|
||||
LevelStorageSource* getLevelSource();
|
||||
@@ -80,7 +88,12 @@ public:
|
||||
|
||||
virtual int getFpsIntlCounter();
|
||||
|
||||
private:
|
||||
static int _windowWidth, _windowHeight;
|
||||
//static int _drawWidth, _drawHeight;
|
||||
static float _drawScale;
|
||||
public:
|
||||
// DEPRECATED: Use getDrawWidth() & getDrawHeight() instead
|
||||
static int width, height;
|
||||
static bool useAmbientOcclusion;
|
||||
static const char* progressMessages[];
|
||||
|
||||
@@ -131,7 +131,6 @@ void ImprovedNoise::add(float* a2, float a3, float a4, float a5, int a6, int a7,
|
||||
|
||||
int* x13 = &m_permutation[uint8_t(x10) + m_permutation[*x6]];
|
||||
int* x15 = &m_permutation[uint8_t(x10) + m_permutation[*x8]];
|
||||
int* x14 = x8;
|
||||
|
||||
float x16 = grad2(*x13, x5, x12);
|
||||
float x17 = grad(*x15, x5 - 1, 0, x12);
|
||||
|
||||
@@ -148,8 +148,8 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY)
|
||||
|
||||
field_4 = -90.0f;
|
||||
|
||||
int width = Minecraft::width * InvGuiScale,
|
||||
height = Minecraft::height * InvGuiScale;
|
||||
int width = Minecraft::getDrawWidth() * InvGuiScale,
|
||||
height = Minecraft::getDrawHeight() * InvGuiScale;
|
||||
|
||||
#ifdef ENH_TRANSPARENT_HOTBAR
|
||||
glEnable(GL_BLEND);
|
||||
@@ -430,8 +430,8 @@ void Gui::handleKeyPressed(int keyCode)
|
||||
|
||||
void Gui::renderMessages(bool bShowAll)
|
||||
{
|
||||
int width = Minecraft::width * InvGuiScale,
|
||||
height = Minecraft::height * InvGuiScale;
|
||||
//int width = Minecraft::width * InvGuiScale,
|
||||
int height = Minecraft::height * InvGuiScale;
|
||||
|
||||
int topEdge = height - 49;
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ void GuiComponent::blit(int dx, int dy, int sx, int sy, int tw, int th, int sw,
|
||||
if (!sh) sh = th;
|
||||
if (!sw) sw = tw;
|
||||
|
||||
int width = sw, height = sh;
|
||||
|
||||
t.begin();
|
||||
t.vertexUV(dx, dy + th, field_4, float(sx) / 256.0f, float(sy + sh) / 256.0f);
|
||||
t.vertexUV(dx + tw, dy + th, field_4, float(sx + sw) / 256.0f, float(sy + sh) / 256.0f);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "SelectWorldScreen.hpp"
|
||||
#include "JoinGameScreen.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) || defined(TARGET_OS_MAC)
|
||||
#define CAN_QUIT
|
||||
#endif
|
||||
|
||||
@@ -499,7 +499,8 @@ void StartMenuScreen::render(int a, int b, float c)
|
||||
glPushMatrix();
|
||||
|
||||
std::string splashText = getSplashString();
|
||||
int textWidth = m_pFont->width(splashText), textHeight = m_pFont->height(splashText);
|
||||
int textWidth = m_pFont->width(splashText);
|
||||
//int textHeight = m_pFont->height(splashText);
|
||||
|
||||
glTranslatef(float(m_width) / 2.0f + 90.0f, 70.0f, 0.0f);
|
||||
glRotatef(-20.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
@@ -251,7 +251,7 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, RemoveBloc
|
||||
int z = packet->m_z;
|
||||
|
||||
Tile* pTile = Tile::tiles[m_pLevel->getTile(x, y, z)];
|
||||
int data = m_pLevel->getData(x, y, z);
|
||||
//int data = m_pLevel->getData(x, y, z);
|
||||
bool setTileResult = m_pLevel->setTile(x, y, z, TILE_AIR);
|
||||
if (pTile && setTileResult)
|
||||
{
|
||||
|
||||
@@ -71,7 +71,7 @@ ITurnInput::Delta ControllerTurnInput::getTurnDelta()
|
||||
deltaX = deltaTime * xt;
|
||||
deltaY = deltaTime * -yt;
|
||||
}
|
||||
else if (field_8 != 2 || !field_18 && !isTouched)
|
||||
else if (field_8 != 2 || (!field_18 && !isTouched))
|
||||
{
|
||||
deltaX = 0.0f;
|
||||
deltaY = -0.0f;
|
||||
@@ -108,7 +108,7 @@ ITurnInput::Delta ControllerTurnInput::getTurnDelta()
|
||||
if (fabsf(x1) > 0.0f)
|
||||
x2 = x1 - x3;
|
||||
|
||||
float ndy = 0.0f, x5;
|
||||
float x5;
|
||||
if (x4 >= 0.0f)
|
||||
x5 = 0.0f;
|
||||
else
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
struct Delta
|
||||
{
|
||||
float x, y;
|
||||
Delta() { x = 0.0f, y = 0.0f; }
|
||||
Delta() { x = 0.0f; y = 0.0f; }
|
||||
Delta(float x, float y) : x(x), y(y) {}
|
||||
};
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ int t_keepPic;
|
||||
|
||||
void GameRenderer::_init()
|
||||
{
|
||||
ItemInHandRenderer* m_pItemInHandRenderer = nullptr;
|
||||
//ItemInHandRenderer* m_pItemInHandRenderer = nullptr;
|
||||
|
||||
field_8 = 0.0f;
|
||||
field_C = 0;
|
||||
|
||||
@@ -267,7 +267,7 @@ void ItemInHandRenderer::renderFire(float f)
|
||||
|
||||
void ItemInHandRenderer::renderTex(float f, int texture)
|
||||
{
|
||||
float unused = m_pMinecraft->m_pLocalPlayer->getBrightness(f);
|
||||
//float brightness = m_pMinecraft->m_pLocalPlayer->getBrightness(f);
|
||||
glColor4f(0.1f, 0.1f, 0.1f, 0.5f);
|
||||
glPushMatrix();
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ void LevelRenderer::generateSky()
|
||||
t.begin();
|
||||
field_DC = 0;
|
||||
|
||||
float m = 16.0f;
|
||||
//float m = 16.0f;
|
||||
int n = 4;
|
||||
int p = 128;
|
||||
|
||||
@@ -497,11 +497,11 @@ void LevelRenderer::render(Mob* pMob, int a, float b)
|
||||
if (!a)
|
||||
field_54 = field_58 = field_5C = field_60 = field_64 = 0;
|
||||
|
||||
float mobX1 = pMob->m_pos.x;
|
||||
//float mobX1 = pMob->m_pos.x;
|
||||
float mobX2 = pMob->field_98.x + (pMob->m_pos.x - pMob->field_98.x) * b;
|
||||
float mobY1 = pMob->m_pos.y;
|
||||
//float mobY1 = pMob->m_pos.y;
|
||||
float mobY2 = pMob->field_98.y + (pMob->m_pos.y - pMob->field_98.y) * b;
|
||||
float mobZ1 = pMob->m_pos.z;
|
||||
//float mobZ1 = pMob->m_pos.z;
|
||||
float mobZ2 = pMob->field_98.z + (pMob->m_pos.z - pMob->field_98.z) * b;
|
||||
|
||||
float dX = pMob->m_pos.x - field_4, dY = pMob->m_pos.y - field_8, dZ = pMob->m_pos.z - field_C;
|
||||
|
||||
@@ -136,16 +136,13 @@ void LightUpdate::update(Level* pLevel)
|
||||
x5 = x3;
|
||||
}
|
||||
LABEL_8:
|
||||
m_z2 = this->m_z2;
|
||||
++x3;
|
||||
++x4;
|
||||
} while (x5 <= m_z2);
|
||||
m_x2 = this->m_x2;
|
||||
LABEL_53:
|
||||
++x1;
|
||||
if (x1_1 > m_x2)
|
||||
break;
|
||||
m_z1 = this->m_z1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,9 @@
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include "compat/GL.hpp"
|
||||
#include "Tesselator.hpp"
|
||||
#include "compat/GL.hpp"
|
||||
#include "client/common/Utils.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
|
||||
@@ -83,7 +83,6 @@ void Textures::clear()
|
||||
{
|
||||
// note: Textures::clear() does not touch the dynamic textures vector
|
||||
|
||||
size_t size = m_textures.size();
|
||||
for (auto it = m_textures.begin(); it != m_textures.end(); it++)
|
||||
glDeleteTextures(1, &it->second);
|
||||
|
||||
|
||||
@@ -2530,9 +2530,9 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusionV2(Tile* tile, int
|
||||
if (tile == Tile::grass)
|
||||
r = g = b = 1.0f;
|
||||
|
||||
Tesselator& t = Tesselator::instance;
|
||||
//Tesselator& t = Tesselator::instance;
|
||||
|
||||
float fLightHere = tile->getBrightness(m_pLevelSource, x, y, z);
|
||||
//float fLightHere = tile->getBrightness(m_pLevelSource, x, y, z);
|
||||
|
||||
float lights[EDIR_COUNT];
|
||||
|
||||
|
||||
@@ -15,14 +15,14 @@ struct VertexPT
|
||||
|
||||
VertexPT()
|
||||
{
|
||||
x = 0, y = 0, z = 0;
|
||||
u = 0, v = 0;
|
||||
x = 0; y = 0; z = 0;
|
||||
u = 0; v = 0;
|
||||
}
|
||||
VertexPT(float x, float y, float z) : x(x), y(y), z(z) {}
|
||||
VertexPT(float x, float y, float z, float(u), float(v)) : x(x), y(y), z(z), u(u), v(v) {}
|
||||
|
||||
void setUV(float _u, float _v)
|
||||
{
|
||||
u = _u, v = _v;
|
||||
u = _u; v = _v;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -14,10 +14,10 @@ void ItemSpriteRenderer::render(Entity* pEntity, float x, float y, float z, floa
|
||||
glScalef(0.5f, 0.5f, 0.5f);
|
||||
bindTexture(C_ITEMS_NAME);
|
||||
|
||||
float texU_1 = float(16 * (m_sprite % 16)) / 256.0f;
|
||||
/*float texU_1 = float(16 * (m_sprite % 16)) / 256.0f;
|
||||
float texU_2 = float(16 * (m_sprite % 16 + 1)) / 256.0f;
|
||||
float texV_1 = float(16 * (m_sprite / 16)) / 256.0f;
|
||||
float texV_2 = float(16 * (m_sprite / 16 + 1)) / 256.0f;
|
||||
float texV_2 = float(16 * (m_sprite / 16 + 1)) / 256.0f;*/
|
||||
|
||||
glRotatef(180.0f - m_pDispatcher->m_yaw, 0.0f, 1.0f, 0.0f);
|
||||
glRotatef(-m_pDispatcher->m_pitch, 1.0f, 0.0f, 0.0f);
|
||||
|
||||
@@ -132,7 +132,7 @@ int Entity::move(float x, float y, float z)
|
||||
bool b1, b2, b3, b4, b5, b6;
|
||||
AABB hitold;
|
||||
|
||||
oldX = m_pos.x, oldZ = m_pos.z;
|
||||
oldX = m_pos.x; oldZ = m_pos.z;
|
||||
|
||||
x7 = m_hitbox.max.z;
|
||||
x8 = m_hitbox.max.y;
|
||||
@@ -319,7 +319,7 @@ label_5:
|
||||
goto label_45;
|
||||
}
|
||||
|
||||
if (field_A4 >= 0.05f || x_2 == x_1 && z_2 == z_1)
|
||||
if (field_A4 >= 0.05f || (x_2 == x_1 && z_2 == z_1))
|
||||
goto label_44;
|
||||
|
||||
// oh come on, undoing all our work??
|
||||
|
||||
@@ -38,14 +38,14 @@ struct EntityPos
|
||||
|
||||
EntityPos()
|
||||
{
|
||||
m_yaw = 0, m_pitch = 0;
|
||||
m_bHasRot = false, m_bHasPos = false;
|
||||
m_yaw = 0; m_pitch = 0;
|
||||
m_bHasRot = false; m_bHasPos = false;
|
||||
};
|
||||
|
||||
EntityPos(const Vec3& pos)
|
||||
{
|
||||
m_pos = pos;
|
||||
m_yaw = 0, m_pitch = 0;
|
||||
m_yaw = 0; m_pitch = 0;
|
||||
m_bHasPos = true;
|
||||
m_bHasRot = false;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RakNetTypes.h"
|
||||
#include "thirdparty/raknet/RakNetTypes.h"
|
||||
#include "world/item/Inventory.hpp"
|
||||
#include "world/entity/Mob.hpp"
|
||||
#include "world/entity/ItemEntity.hpp"
|
||||
|
||||
@@ -16,8 +16,8 @@ public:
|
||||
SurvivalMode(Minecraft*);
|
||||
|
||||
void startDestroyBlock(int x, int y, int z, int i) override;
|
||||
bool destroyBlock(int x, int y, int z, int i);
|
||||
void continueDestroyBlock(int x, int y, int z, int i);
|
||||
bool destroyBlock(int x, int y, int z, int i) override;
|
||||
void continueDestroyBlock(int x, int y, int z, int i) override;
|
||||
void stopDestroyBlock() override;
|
||||
void tick() override;
|
||||
void render(float f) override;
|
||||
|
||||
@@ -60,7 +60,7 @@ bool DoorItem::useOn(ItemInstance* inst, Player* player, Level* level, int x, in
|
||||
int equal6 = level->getTile(x + offsetX, y + 1, z + offsetZ) == pTile->m_ID ||
|
||||
level->getTile(x + offsetX, y + 2, z + offsetZ) == pTile->m_ID;
|
||||
|
||||
if (equal5 && !equal6 || solid2 + solid1 < solid4 + solid3)
|
||||
if ((equal5 && !equal6) || solid2 + solid1 < solid4 + solid3)
|
||||
faceDir = 4 + ((faceDir - 1) & 3);
|
||||
|
||||
// congratulations! You can now have a door.
|
||||
|
||||
@@ -467,7 +467,7 @@ void Level::updateLight(const LightLayer& ll, int a, int b, int c, int d, int e,
|
||||
{
|
||||
static int nUpdateLevels;
|
||||
|
||||
if (m_pDimension->field_E && &ll == &LightLayer::Sky || !m_bUpdateLights)
|
||||
if ((m_pDimension->field_E && &ll == &LightLayer::Sky) || !m_bUpdateLights)
|
||||
return;
|
||||
|
||||
nUpdateLevels++;
|
||||
|
||||
@@ -467,7 +467,7 @@ void LevelChunk::recalcHeight(int x, int y, int z)
|
||||
for (int i = 0; i < hmap; i++)
|
||||
{
|
||||
int v15 = (i | index) >> 1;
|
||||
int v16 = (i | index) <<31;
|
||||
//int v16 = (i | index) <<31;
|
||||
|
||||
if ((i | index) & 1)
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ RandomLevelSource::RandomLevelSource(Level* level, TLong seed, int x) :
|
||||
// @BUG: Potential collisions.
|
||||
inline int GetChunkHash(int x, int z)
|
||||
{
|
||||
int v6 = z & 0x7FFF | ((x & 0x7FFF) << 16) | x & 0x80000000, v7;
|
||||
int v6 = (z & 0x7FFF) | ((x & 0x7FFF) << 16) | (x & 0x80000000), v7;
|
||||
if (z >= 0)
|
||||
v7 = 0;
|
||||
else
|
||||
@@ -275,7 +275,7 @@ void RandomLevelSource::buildSurfaces(int x, int z, TileID* tiles, Biome** biome
|
||||
|
||||
// @NOTE: Again, extracted from Java Beta 1.6. Probably accurate
|
||||
constexpr int byte0 = 64;
|
||||
constexpr float d = 0.03125f;
|
||||
//constexpr float d = 0.03125f;
|
||||
for (int k = 0; k < 16; k++)
|
||||
{
|
||||
for (int l = 0; l < 16; l++)
|
||||
|
||||
@@ -82,11 +82,11 @@ bool BirchFeature::place(Level* level, Random* random, int x, int y, int z)
|
||||
if (c2 < 0)
|
||||
c3 = -c2;
|
||||
|
||||
int c5 = c3;
|
||||
//int c5 = c3;
|
||||
|
||||
for (int az = z - c1; az <= z + c1; az++, c4++)
|
||||
{
|
||||
if ((abs(ax - x) != c1 || abs(az - z) != c1 || random->nextInt(2) != 0 && diff != 0) && !Tile::solid[level->getTile(ax, i, az)])
|
||||
if ((abs(ax - x) != c1 || abs(az - z) != c1 || (random->nextInt(2) != 0 && diff != 0)) && !Tile::solid[level->getTile(ax, i, az)])
|
||||
{
|
||||
level->setTileAndDataNoUpdate(ax, i, az, Tile::leaves->m_ID, 2);
|
||||
}
|
||||
@@ -96,7 +96,7 @@ bool BirchFeature::place(Level* level, Random* random, int x, int y, int z)
|
||||
|
||||
for (int i = 0; i < treeHeight; i++)
|
||||
{
|
||||
int y1 = i + y;
|
||||
//int y1 = i + y;
|
||||
TileID tile = level->getTile(x, y + i, z);
|
||||
if (tile && tile != Tile::leaves->m_ID)
|
||||
continue;
|
||||
|
||||
@@ -115,8 +115,8 @@ void LargeCaveFeature::addTunnel(int x, int z, TileID* tiles, float rx, float ry
|
||||
}
|
||||
if (singleStep == 1 || random.nextInt(4) != 0)
|
||||
{
|
||||
float v55 = rx - xMid;
|
||||
float v54 = rz - zMid;
|
||||
//float v55 = rx - xMid;
|
||||
//float v54 = rz - zMid;
|
||||
float v53 = (dist - step);
|
||||
float v52 = (x1 + 2.0f) + 16.0f;
|
||||
if (((((rx - xMid) * (rx - xMid))
|
||||
|
||||
@@ -19,7 +19,7 @@ bool PineFeature::place(Level* level, Random* random, int x, int y, int z)
|
||||
return false;
|
||||
|
||||
int x1 = height - random->nextInt(2) - 3;
|
||||
int p1 = height - x1;
|
||||
//int p1 = height - x1;
|
||||
int x2 = 1 + random->nextInt(1 + x1);
|
||||
int upperY = y + 1 + height;
|
||||
|
||||
@@ -100,4 +100,4 @@ bool PineFeature::place(Level* level, Random* random, int x, int y, int z)
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,11 +82,11 @@ bool TreeFeature::place(Level* level, Random* random, int x, int y, int z)
|
||||
if (c2 < 0)
|
||||
c3 = -c2;
|
||||
|
||||
int c5 = c3;
|
||||
//int c5 = c3;
|
||||
|
||||
for (int az = z - c1; az <= z + c1; az++, c4++)
|
||||
{
|
||||
if ((abs(ax - x) != c1 || abs(az - z) != c1 || random->nextInt(2) != 0 && diff != 0) && !Tile::solid[level->getTile(ax, i, az)])
|
||||
if ((abs(ax - x) != c1 || abs(az - z) != c1 || (random->nextInt(2) != 0 && diff != 0)) && !Tile::solid[level->getTile(ax, i, az)])
|
||||
{
|
||||
level->setTileNoUpdate(ax, i, az, Tile::leaves->m_ID);
|
||||
}
|
||||
@@ -96,7 +96,7 @@ bool TreeFeature::place(Level* level, Random* random, int x, int y, int z)
|
||||
|
||||
for (int i = 0; i < treeHeight; i++)
|
||||
{
|
||||
int y1 = i + y;
|
||||
//int y1 = i + y;
|
||||
TileID tile = level->getTile(x, y + i, z);
|
||||
if (tile && tile != Tile::leaves->m_ID)
|
||||
continue;
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
std::string getName() override;
|
||||
LevelStorage* selectLevel(const std::string&, bool) override;
|
||||
void getLevelList(std::vector<LevelSummary>&);
|
||||
void getLevelList(std::vector<LevelSummary>&) override;
|
||||
void clearAll() override;
|
||||
int getDataTagFor(const std::string&) override;
|
||||
bool isNewLevelIdAcceptable(const std::string&) override;
|
||||
|
||||
@@ -96,7 +96,7 @@ void ParticleEngine::crack(int x, int y, int z, int dir)
|
||||
break;
|
||||
default:
|
||||
// @TODO: dont know what they do for the undefined case
|
||||
posX = float(x), posY = float(y), posZ = float(z);
|
||||
posX = float(x); posY = float(y); posZ = float(z);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class FireTile : public Tile
|
||||
public:
|
||||
FireTile(int ID, int texture);
|
||||
|
||||
AABB* getAABB(Level*, int x, int y, int z);
|
||||
AABB* getAABB(Level*, int x, int y, int z) override;
|
||||
int getRenderShape() override;
|
||||
bool isCubeShaped() override;
|
||||
bool isSolidRender() override;
|
||||
|
||||
@@ -19,8 +19,8 @@ public:
|
||||
bool isSolidRender() override;
|
||||
int getRenderShape() override;
|
||||
int getResourceCount(Random* random) override;
|
||||
AABB* getAABB(Level*, int x, int y, int z);
|
||||
AABB getTileAABB(Level*, int x, int y, int z);
|
||||
AABB* getAABB(Level*, int x, int y, int z) override;
|
||||
AABB getTileAABB(Level*, int x, int y, int z) override;
|
||||
void setPlacedOnFace(Level*, int x, int y, int z, int face) override;
|
||||
void neighborChanged(Level*, int, int, int, int) override;
|
||||
bool mayPlace(Level*, int, int, int) override;
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
|
||||
void updateLiquid(Level*, int x, int y, int z);
|
||||
void fizz(Level*, int x, int y, int z);
|
||||
int getColor(LevelSource*, int x, int y, int z);
|
||||
int getColor(LevelSource*, int x, int y, int z) override;
|
||||
int getDepth(Level*, int x, int y, int z);
|
||||
int getRenderedDepth(LevelSource*, int x, int y, int z);
|
||||
Vec3 getFlow(LevelSource*, int x, int y, int z);
|
||||
|
||||
@@ -28,7 +28,7 @@ int SandTile::getTickDelay()
|
||||
|
||||
void SandTile::checkSlide(Level* level, int x, int y, int z)
|
||||
{
|
||||
TileID tile = level->getTile(x, y - 1, z);
|
||||
//TileID tile = level->getTile(x, y - 1, z);
|
||||
|
||||
if (!isFree(level, x, y - 1, z))
|
||||
// standing on something, don't fall
|
||||
|
||||
@@ -138,8 +138,6 @@ void TorchTile::neighborChanged(Level* level, int x, int y, int z, int dir)
|
||||
|
||||
void TorchTile::onPlace(Level* level, int x, int y, int z)
|
||||
{
|
||||
int data = 0;
|
||||
|
||||
if (level->isSolidTile(x - 1, y, z))
|
||||
level->setData(x, y, z, 1);
|
||||
else if (level->isSolidTile(x + 1, y, z))
|
||||
|
||||
9
thirdparty/raknet/Rand.cpp
vendored
9
thirdparty/raknet/Rand.cpp
vendored
@@ -154,13 +154,13 @@ void seedMT( unsigned int seed, unsigned int *state, unsigned int *&next, int &l
|
||||
|
||||
unsigned int reloadMT( unsigned int *state, unsigned int *&next, int &left )
|
||||
{
|
||||
register unsigned int * p0 = state, *p2 = state + 2, *pM = state + M, s0, s1;
|
||||
register int j;
|
||||
unsigned int * p0 = state, *p2 = state + 2, *pM = state + M, s0, s1;
|
||||
int j;
|
||||
|
||||
if ( left < -1 )
|
||||
seedMT( 4357U );
|
||||
|
||||
left = N - 1, next = state + 1;
|
||||
left = N - 1; next = state + 1;
|
||||
|
||||
for ( s0 = state[ 0 ], s1 = state[ 1 ], j = N - M + 1; --j; s0 = s1, s1 = *p2++ )
|
||||
* p0++ = *pM++ ^ ( mixBits( s0, s1 ) >> 1 ) ^ ( loBit( s1 ) ? K : 0U );
|
||||
@@ -168,7 +168,8 @@ unsigned int reloadMT( unsigned int *state, unsigned int *&next, int &left )
|
||||
for ( pM = state, j = M; --j; s0 = s1, s1 = *p2++ )
|
||||
* p0++ = *pM++ ^ ( mixBits( s0, s1 ) >> 1 ) ^ ( loBit( s1 ) ? K : 0U );
|
||||
|
||||
s1 = state[ 0 ], *p0 = *pM ^ ( mixBits( s0, s1 ) >> 1 ) ^ ( loBit( s1 ) ? K : 0U );
|
||||
s1 = state[ 0 ];
|
||||
*p0 = *pM ^ ( mixBits( s0, s1 ) >> 1 ) ^ ( loBit( s1 ) ? K : 0U );
|
||||
|
||||
s1 ^= ( s1 >> 11 );
|
||||
|
||||
|
||||
2
tools/grabsounds.py
Normal file → Executable file
2
tools/grabsounds.py
Normal file → Executable file
@@ -1,3 +1,5 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
# Minecraft PE Reverse Engineering Project
|
||||
# Copyright (C) 2023 iProgramInCpp
|
||||
# -----------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user