mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-23 20:09:46 +03:00
C++03 Support & Partial Xbox 360 Support (#37)
* WIP C++03 + Xbox 360 Support * math.h & _USE_MATH_DEFINES on Level.hpp Updated Xenon vcxproj file for new file structure. * * Fix bad GUI scale setup. * * Gui: Use ratios instead of hardcoded sub-1 floating point values, to make the mechanism more clear. * Add Direct Connect Button and Screen (#30) * Add Direct Connect Button and Screen * Remove accidental extra build directories for wasm * Add DirectConnectScreen.cpp to the CMake * Use Hungarian coding style notation * * Fix errors caused by #30 * * Improve the Chat Screen * * Improve the DirectConnectScreen, among other things. * * Update the game title once again. * * Add build-wasm.bat. * * Add info about compiling for wasm * * Fix send to specific GUID actually broadcasting to everyone * * Add command manager. * * Add writeable configuration. * * Allow dynamic screen size change on windows * * Allow the same thing on the emscripten version. * WIP C++03 + Xbox 360 Support * Fixed a possible merging issue that broke RakNet? * Additional Xbox 360 compatability fixes --------- Co-authored-by: Brent Da Mage <BrentDaMage@users.noreply.github.com> Co-authored-by: iProgramInCpp <iprogramincpp@gmail.com> Co-authored-by: ts <124226059+uniformization@users.noreply.github.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
@@ -9,7 +9,9 @@
|
||||
#include "CThread.hpp"
|
||||
#include "client/common/Utils.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_XBOX)
|
||||
|
||||
#elif defined(_WIN32)
|
||||
#include <Windows.h> // for Sleep()
|
||||
#else
|
||||
#include <unistd.h>
|
||||
@@ -24,17 +26,26 @@ void CThread::sleep(uint32_t ms)
|
||||
#endif
|
||||
}
|
||||
|
||||
CThread::CThread(CThreadFunction func, void* parm)
|
||||
CThread::CThread(CThreadFunction func, void* param)
|
||||
{
|
||||
m_func = func;
|
||||
|
||||
|
||||
#ifdef USE_CPP11_THREADS
|
||||
std::thread thr(func, parm);
|
||||
std::thread thr(func, param);
|
||||
m_thrd.swap(thr);
|
||||
#elif defined(_XBOX)
|
||||
m_thrd = CreateThread(
|
||||
NULL, // not used
|
||||
0, // initial stack size
|
||||
func, // thread function
|
||||
param, // thread argument
|
||||
0, // creation option
|
||||
LPDWORD(1) // thread identifier (but does it really matter if I'm the one managing them...?)
|
||||
);
|
||||
#else
|
||||
pthread_attr_init(&m_thrd_attr);
|
||||
pthread_attr_setdetachstate(&m_thrd_attr, 1);
|
||||
pthread_create(&m_thrd, &m_thrd_attr, m_func, parm);
|
||||
pthread_create(&m_thrd, &m_thrd_attr, m_func, param);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -42,6 +53,8 @@ CThread::~CThread()
|
||||
{
|
||||
#ifdef USE_CPP11_THREADS
|
||||
m_thrd.join();
|
||||
#elif defined(_XBOX)
|
||||
|
||||
#else
|
||||
pthread_join(m_thrd, 0);
|
||||
pthread_attr_destroy(&m_thrd_attr);
|
||||
|
||||
@@ -1,29 +1,38 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(_XBOX)
|
||||
// CThread - Object oriented pthread wrapper
|
||||
#define USE_CPP11_THREADS
|
||||
#define USE_CPP11_THREADS //__cplusplus >= 201103L
|
||||
#endif
|
||||
|
||||
// USE_CPP11_THREADS - Use a C++11 implementation of threads instead of using pthread
|
||||
#ifdef USE_CPP11_THREADS
|
||||
#include <thread>
|
||||
#elif defined(_XBOX)
|
||||
#include <stdint.h>
|
||||
#include <xtl.h>
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifdef _XBOX
|
||||
typedef LPTHREAD_START_ROUTINE CThreadFunction;
|
||||
#else
|
||||
typedef void* (*CThreadFunction)(void*);
|
||||
#endif
|
||||
|
||||
class CThread
|
||||
{
|
||||
public:
|
||||
CThread(CThreadFunction, void* parm);
|
||||
CThread(CThreadFunction, void* param);
|
||||
~CThread();
|
||||
|
||||
static void sleep(uint32_t ms);
|
||||
@@ -33,6 +42,8 @@ private:
|
||||
|
||||
#ifdef USE_CPP11_THREADS
|
||||
std::thread m_thrd;
|
||||
#elif defined(_XBOX)
|
||||
HANDLE m_thrd;
|
||||
#else
|
||||
pthread_t m_thrd;
|
||||
pthread_attr_t m_thrd_attr;
|
||||
|
||||
@@ -8,10 +8,24 @@
|
||||
|
||||
#include "HitResult.hpp"
|
||||
|
||||
HitResult::HitResult() {}
|
||||
void HitResult::_init()
|
||||
{
|
||||
m_hitType = NONE;
|
||||
// block coords?
|
||||
m_tileX = 0;
|
||||
m_tileY = 0;
|
||||
m_tileZ = 0;
|
||||
|
||||
m_hitSide = MINY;
|
||||
|
||||
m_pEnt = nullptr;
|
||||
m_bUnk24 = 0;
|
||||
}
|
||||
|
||||
HitResult::HitResult(int x, int y, int z, eHitSide hitSide, const Vec3& vec)
|
||||
{
|
||||
_init();
|
||||
|
||||
m_hitType = AABB;
|
||||
m_hitSide = hitSide;
|
||||
m_tileX = x;
|
||||
@@ -23,6 +37,8 @@ HitResult::HitResult(int x, int y, int z, eHitSide hitSide, const Vec3& vec)
|
||||
|
||||
HitResult::HitResult(Entity* pEnt)
|
||||
{
|
||||
_init();
|
||||
|
||||
m_hitType = ENTITY;
|
||||
m_pEnt = pEnt;
|
||||
}
|
||||
|
||||
@@ -34,24 +34,26 @@ public:
|
||||
MAXX, // 5
|
||||
};
|
||||
|
||||
private:
|
||||
void _init();
|
||||
public:
|
||||
HitResult();
|
||||
HitResult() { _init(); }
|
||||
HitResult(Entity*);
|
||||
HitResult(int x, int y, int z, eHitSide hitSide, const Vec3&);
|
||||
|
||||
public:
|
||||
eHitResultType m_hitType = NONE;
|
||||
eHitResultType m_hitType;
|
||||
// block coords?
|
||||
int m_tileX = 0;
|
||||
int m_tileY = 0;
|
||||
int m_tileZ = 0;
|
||||
int m_tileX;
|
||||
int m_tileY;
|
||||
int m_tileZ;
|
||||
|
||||
eHitSide m_hitSide = MINY;
|
||||
eHitSide m_hitSide;
|
||||
|
||||
// hit position
|
||||
Vec3 m_hitPos;
|
||||
|
||||
Entity* m_pEnt = nullptr;
|
||||
bool m_bUnk24 = 0;
|
||||
Entity* m_pEnt;
|
||||
bool m_bUnk24;
|
||||
};
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
Matrix::Matrix()
|
||||
{
|
||||
c[0] = 0.0f;
|
||||
|
||||
memset(c, 0, sizeof c);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
friend Matrix operator*(const Matrix& a, const Matrix& b);
|
||||
|
||||
public:
|
||||
float c[16] = { 0.0f };
|
||||
float c[16];
|
||||
};
|
||||
|
||||
Matrix operator*(const Matrix& a, const Matrix& b);
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -81,5 +81,20 @@ void Timer::advanceTime()
|
||||
|
||||
Timer::Timer()
|
||||
{
|
||||
field_0 = 0;
|
||||
#ifndef USE_ACCURATE_TIMER
|
||||
field_4 = 0;
|
||||
field_8 = 0;
|
||||
#else
|
||||
field_4 = 0;
|
||||
field_8 = 0;
|
||||
#endif
|
||||
field_C = 1.0f;
|
||||
field_10 = 20.0f;
|
||||
field_14 = 0;
|
||||
field_18 = 0;
|
||||
field_1C = 1.0f;
|
||||
field_20 = 0;
|
||||
|
||||
field_4 = field_8 = getTimeMs();
|
||||
}
|
||||
|
||||
@@ -20,19 +20,19 @@ public:
|
||||
void advanceTime();
|
||||
|
||||
public:
|
||||
float field_0 = 0;
|
||||
float field_0;
|
||||
#ifndef USE_ACCURATE_TIMER
|
||||
int field_4 = 0;
|
||||
int field_8 = 0;
|
||||
int field_4;
|
||||
int field_8;
|
||||
#else
|
||||
double field_4 = 0;
|
||||
double field_8 = 0;
|
||||
double field_4;
|
||||
double field_8;
|
||||
#endif
|
||||
float field_C = 1.0f;
|
||||
float field_10 = 20.0f;
|
||||
int field_14 = 0;
|
||||
float field_18 = 0;
|
||||
float field_1C = 1.0f;
|
||||
float field_20 = 0;
|
||||
float field_C;
|
||||
float field_10;
|
||||
int field_14;
|
||||
float field_18;
|
||||
float field_1C;
|
||||
float field_20;
|
||||
};
|
||||
|
||||
|
||||
@@ -36,8 +36,10 @@ public:
|
||||
{
|
||||
int removed = 0;
|
||||
|
||||
for (auto rem : toRemove)
|
||||
for (auto it = toRemove.begin(); it != toRemove.end(); it++)
|
||||
{
|
||||
T rem = *it;
|
||||
|
||||
if (remove(vec, rem))
|
||||
removed++;
|
||||
}
|
||||
@@ -63,11 +65,13 @@ public:
|
||||
{
|
||||
TLong result = 0;
|
||||
|
||||
for (auto chr : str)
|
||||
const size_t size = str.size();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
result = result * 31 + chr;
|
||||
result = result * 31 + str.at(i);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "client/common/Utils.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
|
||||
#include <Windows.h>
|
||||
#include <io.h>
|
||||
@@ -19,6 +19,8 @@
|
||||
// Why are we not using GetTickCount64()? It's simple -- getTimeMs has the exact same problem as using regular old GetTickCount.
|
||||
#pragma warning(disable : 28159)
|
||||
|
||||
#elif defined(_XBOX)
|
||||
|
||||
#else
|
||||
|
||||
#include <sys/time.h>
|
||||
@@ -120,8 +122,6 @@ bool DeleteDirectory(const std::string& name, bool unused)
|
||||
if (!dir)
|
||||
return false;
|
||||
|
||||
char buffer[1024];
|
||||
|
||||
while (true)
|
||||
{
|
||||
dirent* de = readdir(dir);
|
||||
@@ -131,8 +131,8 @@ bool DeleteDirectory(const std::string& name, bool unused)
|
||||
if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
|
||||
continue;
|
||||
|
||||
snprintf(buffer, sizeof buffer, "%s/%s", name.c_str(), de->d_name);
|
||||
remove(buffer);
|
||||
const std::string dirPath = name + de->d_name;
|
||||
remove(dirPath.c_str());
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
@@ -17,14 +17,26 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
|
||||
#ifndef _XBOX // assume we're on a normal Windows device
|
||||
// @HACK: Include WinSock2.h also
|
||||
#include <WinSock2.h>
|
||||
#include <Windows.h>
|
||||
#include <WS2tcpip.h>
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#elif defined(_XBOX)
|
||||
|
||||
#include <xtl.h>
|
||||
#include <winsockx.h>
|
||||
|
||||
//#if __cplusplus < 201103L
|
||||
// We're < C++11
|
||||
//!defined(__cpp_constexpr)
|
||||
#define constexpr const
|
||||
//#endif
|
||||
#endif
|
||||
|
||||
// XPL means "Cross PLatform"
|
||||
#define XPL_ACCESS _access
|
||||
@@ -478,8 +490,12 @@ enum eDirection
|
||||
|
||||
struct ChunkPos
|
||||
{
|
||||
int x = 0, z = 0;
|
||||
ChunkPos() {}
|
||||
int x, z;
|
||||
ChunkPos()
|
||||
{
|
||||
x = 0;
|
||||
z = 0;
|
||||
}
|
||||
ChunkPos(int _x, int _z) : x(_x), z(_z) {}
|
||||
|
||||
bool operator<(const ChunkPos& b) const
|
||||
@@ -493,17 +509,20 @@ struct ChunkPos
|
||||
|
||||
struct Pos
|
||||
{
|
||||
int x = 0, y = 0, z = 0;
|
||||
Pos() {}
|
||||
int x, y, z;
|
||||
Pos()
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
}
|
||||
Pos(int _x, int _y, int _z) : x(_x), y(_y), z(_z) {}
|
||||
};
|
||||
|
||||
// @NOTE: Duplicate?
|
||||
struct TilePos
|
||||
struct TilePos : Pos
|
||||
{
|
||||
int x = 0, y = 0, z = 0;
|
||||
TilePos() {}
|
||||
TilePos(int _x, int _y, int _z) : x(_x), y(_y), z(_z) {}
|
||||
TilePos() : Pos() {}
|
||||
TilePos(int _x, int _y, int _z) : Pos(_x, _y, _z) {}
|
||||
|
||||
bool operator<(const TilePos& b) const
|
||||
{
|
||||
|
||||
@@ -8,7 +8,12 @@
|
||||
|
||||
#include "Vec3.hpp"
|
||||
|
||||
Vec3::Vec3() {}
|
||||
Vec3::Vec3()
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
}
|
||||
|
||||
Vec3::Vec3(float x, float y, float z)
|
||||
{
|
||||
|
||||
@@ -13,9 +13,7 @@
|
||||
class Vec3
|
||||
{
|
||||
public:
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
float z = 0;
|
||||
float x, y, z;
|
||||
|
||||
public:
|
||||
bool clipX(const Vec3& a2, float a3, Vec3& a4) const;
|
||||
|
||||
Reference in New Issue
Block a user