mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-06-22 11:05:32 +00:00
restructure codebase according to vcproj filters
This commit is contained in:
262
Minecraft.Client/Source Files/BufferedImage.cpp
Normal file
262
Minecraft.Client/Source Files/BufferedImage.cpp
Normal file
@@ -0,0 +1,262 @@
|
||||
#include "../../Minecraft.World/Header Files/stdafx.h"
|
||||
#include "../../Minecraft.World/ConsoleHelpers/StringHelpers.h"
|
||||
#include "../net/minecraft/client/renderer/Textures.h"
|
||||
#include "../../Minecraft.World/Header Files/PathHelper.h"
|
||||
#include "../../Minecraft.World/ConsoleHelpers/ArrayWithLength.h"
|
||||
#include "../Header Files/BufferedImage.h"
|
||||
#if defined(__linux__)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
BufferedImage::BufferedImage(int width, int height, int type) {
|
||||
data[0] = new int[width * height];
|
||||
|
||||
for (int i = 1; i < 10; i++) {
|
||||
data[i] = nullptr;
|
||||
}
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
}
|
||||
|
||||
void BufferedImage::ByteFlip4(unsigned int& data) {
|
||||
data = (data >> 24) | ((data >> 8) & 0x0000ff00) |
|
||||
((data << 8) & 0x00ff0000) | (data << 24);
|
||||
}
|
||||
// Loads a bitmap into a buffered image - only currently supports the 2 types of
|
||||
// 32-bit image that we've made so far and determines which of these is which by
|
||||
// the compression method. Compression method 3 is a 32-bit image with only
|
||||
// 24-bits used (ie no alpha channel) whereas method 0 is a full 32-bit image
|
||||
// with a valid alpha channel.
|
||||
|
||||
// 4jcraft: mostly rewrote this function
|
||||
BufferedImage::BufferedImage(const std::wstring& File,
|
||||
bool filenameHasExtension,
|
||||
bool bTitleUpdateTexture,
|
||||
const std::wstring& drive) {
|
||||
int32_t hr = -1;
|
||||
std::wstring filePath = File;
|
||||
|
||||
for (size_t i = 0; i < filePath.length(); ++i) {
|
||||
if (filePath[i] == L'\\') filePath[i] = L'/';
|
||||
}
|
||||
for (int l = 0; l < 10; l++) data[l] = nullptr;
|
||||
|
||||
std::wstring baseName = filePath;
|
||||
if (!filenameHasExtension) {
|
||||
if (baseName.size() > 4 &&
|
||||
baseName.substr(baseName.size() - 4) == L".png") {
|
||||
baseName = baseName.substr(0, baseName.size() - 4);
|
||||
}
|
||||
}
|
||||
|
||||
while (!baseName.empty() && (baseName[0] == L'/' || baseName[0] == L'\\'))
|
||||
baseName = baseName.substr(1);
|
||||
if (baseName.find(L"res/") == 0) baseName = baseName.substr(4);
|
||||
|
||||
std::wstring exeDir = PathHelper::GetExecutableDirW();
|
||||
|
||||
for (int l = 0; l < 10; l++) {
|
||||
std::wstring mipSuffix =
|
||||
(l != 0) ? L"MipMapLevel" + _toString<int>(l + 1) : L"";
|
||||
std::wstring fileName = baseName + mipSuffix + L".png";
|
||||
std::wstring finalPath;
|
||||
bool foundOnDisk = false;
|
||||
|
||||
std::vector<std::wstring> searchPaths = {
|
||||
exeDir + L"/Common/res/TitleUpdate/res/" + fileName,
|
||||
exeDir + L"/Common/res/" + fileName,
|
||||
exeDir + L"/Common/Media/Graphics/" + fileName,
|
||||
exeDir + L"/Common/Media/font/" + fileName,
|
||||
exeDir + L"/Common/res/font/" + fileName,
|
||||
exeDir + L"/Common/Media/" + fileName};
|
||||
|
||||
for (auto& attempt : searchPaths) {
|
||||
size_t p;
|
||||
while ((p = attempt.find(L"//")) != std::wstring::npos)
|
||||
attempt.replace(p, 2, L"/");
|
||||
if (access(wstringtofilename(attempt), F_OK) != -1) {
|
||||
finalPath = attempt;
|
||||
foundOnDisk = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
D3DXIMAGE_INFO ImageInfo;
|
||||
ZeroMemory(&ImageInfo, sizeof(D3DXIMAGE_INFO));
|
||||
|
||||
if (foundOnDisk) {
|
||||
hr = RenderManager.LoadTextureData(wstringtofilename(finalPath),
|
||||
&ImageInfo, &data[l]);
|
||||
} else {
|
||||
std::wstring archiveKey = L"res/" + fileName;
|
||||
if (app.hasArchiveFile(archiveKey)) {
|
||||
byteArray ba = app.getArchiveFile(archiveKey);
|
||||
hr = RenderManager.LoadTextureData(ba.data, ba.length,
|
||||
&ImageInfo, &data[l]);
|
||||
}
|
||||
}
|
||||
|
||||
if (hr == ERROR_SUCCESS) {
|
||||
if (l == 0) {
|
||||
width = ImageInfo.Width;
|
||||
height = ImageInfo.Height;
|
||||
}
|
||||
} else {
|
||||
if (l == 0) {
|
||||
// safety dummy to prevent crash
|
||||
width = 1;
|
||||
height = 1;
|
||||
data[0] = new int[1];
|
||||
data[0][0] = 0xFFFF00FF;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
BufferedImage::BufferedImage(DLCPack* dlcPack, const std::wstring& File,
|
||||
bool filenameHasExtension) {
|
||||
int32_t hr;
|
||||
std::wstring filePath = File;
|
||||
std::uint8_t* pbData = nullptr;
|
||||
std::uint32_t dataBytes = 0;
|
||||
for (int l = 0; l < 10; l++) data[l] = nullptr;
|
||||
|
||||
for (int l = 0; l < 10; l++) {
|
||||
std::wstring name;
|
||||
std::wstring mipMapPath =
|
||||
(l != 0) ? L"MipMapLevel" + _toString<int>(l + 1) : L"";
|
||||
name = L"res" + (filenameHasExtension
|
||||
? filePath
|
||||
: filePath.substr(0, filePath.length() - 4) +
|
||||
mipMapPath + L".png");
|
||||
|
||||
if (!dlcPack->doesPackContainFile(DLCManager::e_DLCType_All, name)) {
|
||||
if (l == 0) app.FatalLoadError();
|
||||
return;
|
||||
}
|
||||
|
||||
DLCFile* dlcFile = dlcPack->getFile(DLCManager::e_DLCType_All, name);
|
||||
pbData = dlcFile->getData(dataBytes);
|
||||
if (pbData == nullptr || dataBytes == 0) {
|
||||
if (l == 0) app.FatalLoadError();
|
||||
return;
|
||||
}
|
||||
|
||||
D3DXIMAGE_INFO ImageInfo;
|
||||
hr = RenderManager.LoadTextureData(pbData, dataBytes, &ImageInfo,
|
||||
&data[l]);
|
||||
if (hr == ERROR_SUCCESS && l == 0) {
|
||||
width = ImageInfo.Width;
|
||||
height = ImageInfo.Height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BufferedImage::BufferedImage(std::uint8_t* pbData, std::uint32_t dataBytes) {
|
||||
for (int l = 0; l < 10; l++) {
|
||||
data[l] = nullptr;
|
||||
}
|
||||
|
||||
D3DXIMAGE_INFO ImageInfo;
|
||||
ZeroMemory(&ImageInfo, sizeof(D3DXIMAGE_INFO));
|
||||
int32_t hr =
|
||||
RenderManager.LoadTextureData(pbData, dataBytes, &ImageInfo, &data[0]);
|
||||
|
||||
if (hr == ERROR_SUCCESS) {
|
||||
width = ImageInfo.Width;
|
||||
height = ImageInfo.Height;
|
||||
} else {
|
||||
app.FatalLoadError();
|
||||
}
|
||||
}
|
||||
|
||||
BufferedImage::~BufferedImage() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
delete[] data[i];
|
||||
}
|
||||
}
|
||||
|
||||
int BufferedImage::getWidth() { return width; }
|
||||
|
||||
int BufferedImage::getHeight() { return height; }
|
||||
|
||||
void BufferedImage::getRGB(int startX, int startY, int w, int h, intArray out,
|
||||
int offset, int scansize, int level) {
|
||||
int ww = width >> level;
|
||||
for (int y = 0; y < h; y++) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
out[y * scansize + offset + x] =
|
||||
data[level][startX + x + ww * (startY + y)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int* BufferedImage::getData() { return data[0]; }
|
||||
|
||||
int* BufferedImage::getData(int level) { return data[level]; }
|
||||
|
||||
Graphics* BufferedImage::getGraphics() { return nullptr; }
|
||||
|
||||
// Returns the transparency. Returns either OPAQUE, BITMASK, or TRANSLUCENT.
|
||||
// Specified by:
|
||||
// getTransparency in interface Transparency
|
||||
// Returns:
|
||||
// the transparency of this BufferedImage.
|
||||
int BufferedImage::getTransparency() {
|
||||
// TODO - 4J Implement?
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Returns a subimage defined by a specified rectangular region. The returned
|
||||
// BufferedImage shares the same data array as the original image. Parameters:
|
||||
// x, y - the coordinates of the upper-left corner of the specified rectangular
|
||||
// region w - the width of the specified rectangular region h - the height of
|
||||
// the specified rectangular region Returns: a BufferedImage that is the
|
||||
// subimage of this BufferedImage.
|
||||
BufferedImage* BufferedImage::getSubimage(int x, int y, int w, int h) {
|
||||
// TODO - 4J Implement
|
||||
|
||||
BufferedImage* img = new BufferedImage(w, h, 0);
|
||||
intArray arrayWrapper(img->data[0], w * h);
|
||||
this->getRGB(x, y, w, h, arrayWrapper, 0, w);
|
||||
|
||||
int level = 1;
|
||||
// prevent overflow
|
||||
while (level < 10 && getData(level) != nullptr) {
|
||||
int ww = w >> level;
|
||||
int hh = h >> level;
|
||||
int xx = x >> level;
|
||||
int yy = y >> level;
|
||||
img->data[level] = new int[ww * hh];
|
||||
intArray levelWrapper(img->data[level], ww * hh);
|
||||
this->getRGB(xx, yy, ww, hh, levelWrapper, 0, ww, level);
|
||||
|
||||
++level;
|
||||
}
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
void BufferedImage::preMultiplyAlpha() {
|
||||
int* curData = data[0];
|
||||
|
||||
int cur = 0;
|
||||
int alpha = 0;
|
||||
int r = 0;
|
||||
int g = 0;
|
||||
int b = 0;
|
||||
|
||||
int total = width * height;
|
||||
// why was it unsigned??
|
||||
for (int i = 0; i < total; ++i) {
|
||||
cur = curData[i];
|
||||
alpha = (cur >> 24) & 0xff;
|
||||
r = ((cur >> 16) & 0xff) * (float)alpha / 255;
|
||||
g = ((cur >> 8) & 0xff) * (float)alpha / 255;
|
||||
b = (cur & 0xff) * (float)alpha / 255;
|
||||
|
||||
curData[i] = (r << 16) | (g << 8) | (b) | (alpha << 24);
|
||||
}
|
||||
}
|
||||
814
Minecraft.Client/Source Files/Extrax64Stubs.cpp
Normal file
814
Minecraft.Client/Source Files/Extrax64Stubs.cpp
Normal file
@@ -0,0 +1,814 @@
|
||||
#include "../../Minecraft.World/Header Files/stdafx.h"
|
||||
// #include <compressapi.h>
|
||||
|
||||
#if defined(_WINDOWS64)
|
||||
#include "../Windows64/Source Files/Sentient/SentientManager.h"
|
||||
#include "../net/minecraft/stats/StatsCounter.h"
|
||||
#include "../Windows64/Source Files/Social/SocialManager.h"
|
||||
#include "../Windows64/Source Files/Sentient/DynamicConfigurations.h"
|
||||
#elif defined(__linux__)
|
||||
// On Linux, stdafx.h already provides Orbis-compatible Sentient/Dynamic headers
|
||||
// via #pragma once. Pull in SentientManager for CSentientManager class
|
||||
// declaration and StatsCounter; CSocialManager is provided as inline stubs via
|
||||
// Linux/Social/SocialManager.h.
|
||||
#include "../Windows64/Source Files/Sentient/SentientManager.h"
|
||||
#include "../net/minecraft/stats/StatsCounter.h"
|
||||
#else
|
||||
#include "../net/minecraft/stats/StatsCounter.h"
|
||||
#endif
|
||||
|
||||
#if defined(_WINDOWS64)
|
||||
// C4JStorage StorageManager;
|
||||
C_4JProfile ProfileManager;
|
||||
#endif
|
||||
CSentientManager SentientManager;
|
||||
#if !defined(__linux__)
|
||||
// On Linux this global shadows the project's StringTable class name in unity
|
||||
// builds
|
||||
CXuiStringTable StringTable;
|
||||
#endif
|
||||
|
||||
#if !defined(__linux__)
|
||||
ATG::XMLParser::XMLParser() {}
|
||||
ATG::XMLParser::~XMLParser() {}
|
||||
int32_t ATG::XMLParser::ParseXMLBuffer(const char* strBuffer,
|
||||
uint32_t uBufferSize) {
|
||||
return S_OK;
|
||||
}
|
||||
void ATG::XMLParser::RegisterSAXCallbackInterface(ISAXCallback* pISAXCallback) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(__linux__)
|
||||
bool CSocialManager::IsTitleAllowedToPostAnything() { return false; }
|
||||
bool CSocialManager::AreAllUsersAllowedToPostImages() { return false; }
|
||||
bool CSocialManager::IsTitleAllowedToPostImages() { return false; }
|
||||
|
||||
bool CSocialManager::PostLinkToSocialNetwork(ESocialNetwork eSocialNetwork,
|
||||
uint32_t dwUserIndex,
|
||||
bool bUsingKinect) {
|
||||
return false;
|
||||
}
|
||||
bool CSocialManager::PostImageToSocialNetwork(ESocialNetwork eSocialNetwork,
|
||||
uint32_t dwUserIndex,
|
||||
bool bUsingKinect) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CSocialManager* CSocialManager::Instance() { return nullptr; }
|
||||
void CSocialManager::SetSocialPostText(const wchar_t* Title,
|
||||
const wchar_t* Caption,
|
||||
const wchar_t* Desc) {};
|
||||
#endif
|
||||
|
||||
uint32_t XShowPartyUI(uint32_t dwUserIndex) { return 0; }
|
||||
uint32_t XShowFriendsUI(uint32_t dwUserIndex) { return 0; }
|
||||
int32_t XPartyGetUserList(XPARTY_USER_LIST* pUserList) { return S_OK; }
|
||||
uint32_t XContentGetThumbnail(uint32_t dwUserIndex,
|
||||
const XCONTENT_DATA* pContentData,
|
||||
uint8_t* pbThumbnail, uint32_t* pcbThumbnail,
|
||||
PXOVERLAPPED* pOverlapped) {
|
||||
return 0;
|
||||
}
|
||||
void XShowAchievementsUI(int i) {}
|
||||
uint32_t XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE Mode) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PIXAddNamedCounter(int a, const char* b, ...) {}
|
||||
// #define PS3_USE_PIX_EVENTS
|
||||
// #define PS4_USE_PIX_EVENTS
|
||||
void PIXBeginNamedEvent(int a, const char* b, ...) {
|
||||
#if defined(PS4_USE_PIX_EVENTS)
|
||||
char buf[512];
|
||||
va_list args;
|
||||
va_start(args, b);
|
||||
vsprintf(buf, b, args);
|
||||
sceRazorCpuPushMarker(buf, 0xffffffff, SCE_RAZOR_MARKER_ENABLE_HUD);
|
||||
|
||||
#endif
|
||||
#if defined(PS3_USE_PIX_EVENTS)
|
||||
char buf[256];
|
||||
wchar_t wbuf[256];
|
||||
va_list args;
|
||||
va_start(args, b);
|
||||
vsprintf(buf, b, args);
|
||||
snPushMarker(buf);
|
||||
|
||||
// mbstowcs(wbuf,buf,256);
|
||||
// RenderManager.BeginEvent(wbuf);
|
||||
va_end(args);
|
||||
#endif
|
||||
}
|
||||
|
||||
void PIXEndNamedEvent() {
|
||||
#if defined(PS4_USE_PIX_EVENTS)
|
||||
sceRazorCpuPopMarker();
|
||||
#endif
|
||||
#if defined(PS3_USE_PIX_EVENTS)
|
||||
snPopMarker();
|
||||
// RenderManager.EndEvent();
|
||||
#endif
|
||||
}
|
||||
void PIXSetMarkerDeprecated(int a, char* b, ...) {}
|
||||
|
||||
// void *D3DXBUFFER::GetBufferPointer() { return nullptr; }
|
||||
// int D3DXBUFFER::GetBufferSize() { return 0; }
|
||||
// void D3DXBUFFER::Release() {}
|
||||
|
||||
// #if 0
|
||||
// void GetLocalTime(SYSTEMTIME *time) {}
|
||||
// #endif
|
||||
|
||||
bool IsEqualXUID(PlayerUID a, PlayerUID b) { return false; }
|
||||
|
||||
void XMemCpy(void* a, const void* b, size_t s) { memcpy(a, b, s); }
|
||||
void XMemSet(void* a, int t, size_t s) { memset(a, t, s); }
|
||||
void XMemSet128(void* a, int t, size_t s) { memset(a, t, s); }
|
||||
void* XPhysicalAlloc(size_t a, uintptr_t b, uintptr_t c, uint32_t d) {
|
||||
return malloc(a);
|
||||
}
|
||||
void XPhysicalFree(void* a) { free(a); }
|
||||
|
||||
D3DXVECTOR3::D3DXVECTOR3() {}
|
||||
D3DXVECTOR3::D3DXVECTOR3(float x, float y, float z) : x(x), y(y), z(z) {}
|
||||
D3DXVECTOR3& D3DXVECTOR3::operator+=(const D3DXVECTOR3& add) {
|
||||
x += add.x;
|
||||
y += add.y;
|
||||
z += add.z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
uint8_t IQNetPlayer::GetSmallId() { return 0; }
|
||||
void IQNetPlayer::SendData(IQNetPlayer* player, const void* pvData,
|
||||
uint32_t dwDataSize, uint32_t dwFlags) {
|
||||
#if !defined(__linux__)
|
||||
app.DebugPrintf("Sending from 0x%x to 0x%x %d bytes\n", this, player,
|
||||
dwDataSize);
|
||||
#endif
|
||||
}
|
||||
bool IQNetPlayer::IsSameSystem(IQNetPlayer* player) { return true; }
|
||||
uint32_t IQNetPlayer::GetSendQueueSize(IQNetPlayer* player, uint32_t dwFlags) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t IQNetPlayer::GetCurrentRtt() { return 0; }
|
||||
bool IQNetPlayer::IsHost() { return this == &IQNet::m_player[0]; }
|
||||
bool IQNetPlayer::IsGuest() { return false; }
|
||||
bool IQNetPlayer::IsLocal() { return true; }
|
||||
PlayerUID IQNetPlayer::GetXuid() { return INVALID_XUID; }
|
||||
const wchar_t* IQNetPlayer::GetGamertag() {
|
||||
static const wchar_t* test = L"stub";
|
||||
return test;
|
||||
}
|
||||
int IQNetPlayer::GetSessionIndex() { return 0; }
|
||||
bool IQNetPlayer::IsTalking() { return false; }
|
||||
bool IQNetPlayer::IsMutedByLocalUser(uint32_t dwUserIndex) { return false; }
|
||||
bool IQNetPlayer::HasVoice() { return false; }
|
||||
bool IQNetPlayer::HasCamera() { return false; }
|
||||
int IQNetPlayer::GetUserIndex() { return this - &IQNet::m_player[0]; }
|
||||
void IQNetPlayer::SetCustomDataValue(uintptr_t ulpCustomDataValue) {
|
||||
m_customData = ulpCustomDataValue;
|
||||
}
|
||||
uintptr_t IQNetPlayer::GetCustomDataValue() { return m_customData; }
|
||||
|
||||
IQNetPlayer IQNet::m_player[4];
|
||||
|
||||
bool _bQNetStubGameRunning = false;
|
||||
|
||||
int32_t IQNet::AddLocalPlayerByUserIndex(uint32_t dwUserIndex) { return S_OK; }
|
||||
IQNetPlayer* IQNet::GetHostPlayer() { return &m_player[0]; }
|
||||
IQNetPlayer* IQNet::GetLocalPlayerByUserIndex(uint32_t dwUserIndex) {
|
||||
return &m_player[dwUserIndex];
|
||||
}
|
||||
IQNetPlayer* IQNet::GetPlayerByIndex(uint32_t dwPlayerIndex) {
|
||||
return &m_player[0];
|
||||
}
|
||||
IQNetPlayer* IQNet::GetPlayerBySmallId(uint8_t SmallId) { return &m_player[0]; }
|
||||
IQNetPlayer* IQNet::GetPlayerByXuid(PlayerUID xuid) { return &m_player[0]; }
|
||||
uint32_t IQNet::GetPlayerCount() { return 1; }
|
||||
QNET_STATE IQNet::GetState() {
|
||||
return _bQNetStubGameRunning ? QNET_STATE_GAME_PLAY : QNET_STATE_IDLE;
|
||||
}
|
||||
bool IQNet::IsHost() { return true; }
|
||||
int32_t IQNet::JoinGameFromInviteInfo(uint32_t dwUserIndex, uint32_t dwUserMask,
|
||||
const INVITE_INFO* pInviteInfo) {
|
||||
return S_OK;
|
||||
}
|
||||
void IQNet::HostGame() { _bQNetStubGameRunning = true; }
|
||||
void IQNet::EndGame() { _bQNetStubGameRunning = false; }
|
||||
|
||||
uint32_t MinecraftDynamicConfigurations::GetTrialTime() {
|
||||
return DYNAMIC_CONFIG_DEFAULT_TRIAL_TIME;
|
||||
}
|
||||
|
||||
void XSetThreadProcessor(void* a, int b) {}
|
||||
// #if !(0) && !(0)
|
||||
// bool XCloseHandle(void* a) { return CloseHandle(a); }
|
||||
// #endif // 0
|
||||
|
||||
uint32_t XUserGetSigninInfo(uint32_t dwUserIndex, uint32_t dwFlags,
|
||||
PXUSER_SIGNIN_INFO pSigninInfo) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const wchar_t* CXuiStringTable::Lookup(const wchar_t* szId) { return szId; }
|
||||
const wchar_t* CXuiStringTable::Lookup(uint32_t nIndex) { return L"String"; }
|
||||
void CXuiStringTable::Clear() {}
|
||||
int32_t CXuiStringTable::Load(const wchar_t* szId) { return S_OK; }
|
||||
|
||||
uint32_t XUserAreUsersFriends(uint32_t dwUserIndex, PPlayerUID pXuids,
|
||||
uint32_t dwXuidCount, bool* pfResult,
|
||||
void* pOverlapped) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t XMemDecompress(XMEMDECOMPRESSION_CONTEXT Context, void* pDestination,
|
||||
size_t* pDestSize, void* pSource, size_t SrcSize) {
|
||||
memcpy(pDestination, pSource, SrcSize);
|
||||
*pDestSize = SrcSize;
|
||||
return S_OK;
|
||||
|
||||
/*
|
||||
DECOMPRESSOR_HANDLE Decompressor = (DECOMPRESSOR_HANDLE)Context;
|
||||
if( Decompress(
|
||||
Decompressor, // Decompressor handle
|
||||
(void *)pSource, // Compressed data
|
||||
SrcSize, // Compressed data size
|
||||
pDestination, // Decompressed buffer
|
||||
*pDestSize, // Decompressed buffer size
|
||||
pDestSize) ) // Decompressed data size
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t XMemCompress(XMEMCOMPRESSION_CONTEXT Context, void* pDestination,
|
||||
size_t* pDestSize, void* pSource, size_t SrcSize) {
|
||||
memcpy(pDestination, pSource, SrcSize);
|
||||
*pDestSize = SrcSize;
|
||||
return S_OK;
|
||||
|
||||
/*
|
||||
COMPRESSOR_HANDLE Compressor = (COMPRESSOR_HANDLE)Context;
|
||||
if( Compress(
|
||||
Compressor, // Compressor Handle
|
||||
(void *)pSource, // Input buffer, Uncompressed
|
||||
data SrcSize, // Uncompressed data
|
||||
size pDestination, // Compressed Buffer *pDestSize, //
|
||||
Compressed Buffer size pDestSize) ) //
|
||||
Compressed Data size
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t XMemCreateCompressionContext(XMEMCODEC_TYPE CodecType,
|
||||
const void* pCodecParams, uint32_t Flags,
|
||||
XMEMCOMPRESSION_CONTEXT* pContext) {
|
||||
/*
|
||||
COMPRESSOR_HANDLE Compressor = nullptr;
|
||||
|
||||
int32_t hr = CreateCompressor(
|
||||
COMPRESS_ALGORITHM_XPRESS_HUFF, // Compression Algorithm
|
||||
nullptr, // Optional allocation routine
|
||||
&Compressor); // Handle
|
||||
|
||||
pContext = (XMEMDECOMPRESSION_CONTEXT *)Compressor;
|
||||
return hr;
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t XMemCreateDecompressionContext(XMEMCODEC_TYPE CodecType,
|
||||
const void* pCodecParams, uint32_t Flags,
|
||||
XMEMDECOMPRESSION_CONTEXT* pContext) {
|
||||
/*
|
||||
DECOMPRESSOR_HANDLE Decompressor = nullptr;
|
||||
|
||||
int32_t hr = CreateDecompressor(
|
||||
COMPRESS_ALGORITHM_XPRESS_HUFF, // Compression Algorithm
|
||||
nullptr, // Optional allocation routine
|
||||
&Decompressor); // Handle
|
||||
|
||||
pContext = (XMEMDECOMPRESSION_CONTEXT *)Decompressor;
|
||||
return hr;
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
void XMemDestroyCompressionContext(XMEMCOMPRESSION_CONTEXT Context) {
|
||||
// COMPRESSOR_HANDLE Compressor = (COMPRESSOR_HANDLE)Context;
|
||||
// CloseCompressor(Compressor);
|
||||
}
|
||||
|
||||
void XMemDestroyDecompressionContext(XMEMDECOMPRESSION_CONTEXT Context) {
|
||||
// DECOMPRESSOR_HANDLE Decompressor = (DECOMPRESSOR_HANDLE)Context;
|
||||
// CloseDecompressor(Decompressor);
|
||||
}
|
||||
|
||||
// #if 1
|
||||
uint32_t XGetLanguage() { return 1; }
|
||||
uint32_t XGetLocale() { return 0; }
|
||||
uint32_t XEnableGuestSignin(bool fEnable) { return 0; }
|
||||
|
||||
/////////////////////////////////////////////// Profile library
|
||||
#if defined(_WINDOWS64)
|
||||
static void* profileData[4];
|
||||
static bool s_bProfileIsFullVersion;
|
||||
void C_4JProfile::Initialise(std::uint32_t dwTitleID, std::uint32_t dwOfferID,
|
||||
unsigned short usProfileVersion,
|
||||
unsigned int uiProfileValuesC,
|
||||
unsigned int uiProfileSettingsC,
|
||||
std::uint32_t* pdwProfileSettingsA,
|
||||
int iGameDefinedDataSizeX4,
|
||||
unsigned int* puiGameDefinedDataChangedBitmask) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
profileData[i] = new uint8_t[iGameDefinedDataSizeX4 / 4];
|
||||
ZeroMemory(profileData[i],
|
||||
sizeof(uint8_t) * iGameDefinedDataSizeX4 / 4);
|
||||
|
||||
// Set some sane initial values!
|
||||
GAME_SETTINGS* pGameSettings = (GAME_SETTINGS*)profileData[i];
|
||||
pGameSettings->ucMenuSensitivity =
|
||||
100; // eGameSetting_Sensitivity_InMenu
|
||||
pGameSettings->ucInterfaceOpacity =
|
||||
80; // eGameSetting_Sensitivity_InMenu
|
||||
pGameSettings->usBitmaskValues |=
|
||||
0x0200; // eGameSetting_DisplaySplitscreenGamertags - on
|
||||
pGameSettings->usBitmaskValues |= 0x0400; // eGameSetting_Hints - on
|
||||
pGameSettings->usBitmaskValues |= 0x1000; // eGameSetting_Autosave - 2
|
||||
pGameSettings->usBitmaskValues |= 0x8000; // eGameSetting_Tooltips - on
|
||||
pGameSettings->uiBitmaskValues = 0L; // reset
|
||||
pGameSettings->uiBitmaskValues |=
|
||||
GAMESETTING_CLOUDS; // eGameSetting_Clouds - on
|
||||
pGameSettings->uiBitmaskValues |=
|
||||
GAMESETTING_ONLINE; // eGameSetting_GameSetting_Online - on
|
||||
pGameSettings->uiBitmaskValues |=
|
||||
GAMESETTING_FRIENDSOFFRIENDS; // eGameSetting_GameSetting_FriendsOfFriends
|
||||
// - on
|
||||
pGameSettings->uiBitmaskValues |=
|
||||
GAMESETTING_DISPLAYUPDATEMSG; // eGameSetting_DisplayUpdateMessage
|
||||
// (counter)
|
||||
pGameSettings->uiBitmaskValues &=
|
||||
~GAMESETTING_BEDROCKFOG; // eGameSetting_BedrockFog - off
|
||||
pGameSettings->uiBitmaskValues |=
|
||||
GAMESETTING_DISPLAYHUD; // eGameSetting_DisplayHUD - on
|
||||
pGameSettings->uiBitmaskValues |=
|
||||
GAMESETTING_DISPLAYHAND; // eGameSetting_DisplayHand - on
|
||||
pGameSettings->uiBitmaskValues |=
|
||||
GAMESETTING_CUSTOMSKINANIM; // eGameSetting_CustomSkinAnim - on
|
||||
pGameSettings->uiBitmaskValues |=
|
||||
GAMESETTING_DEATHMESSAGES; // eGameSetting_DeathMessages - on
|
||||
pGameSettings->uiBitmaskValues |=
|
||||
(GAMESETTING_UISIZE & 0x00000800); // uisize 2
|
||||
pGameSettings->uiBitmaskValues |=
|
||||
(GAMESETTING_UISIZE_SPLITSCREEN &
|
||||
0x00004000); // splitscreen ui size 3
|
||||
pGameSettings->uiBitmaskValues |=
|
||||
GAMESETTING_ANIMATEDCHARACTER; // eGameSetting_AnimatedCharacter -
|
||||
// on
|
||||
|
||||
// TU12
|
||||
// favorite skins added, but only set in TU12 - set to FFs
|
||||
for (int i = 0; i < MAX_FAVORITE_SKINS; i++) {
|
||||
pGameSettings->uiFavoriteSkinA[i] = 0xFFFFFFFF;
|
||||
}
|
||||
pGameSettings->ucCurrentFavoriteSkinPos = 0;
|
||||
// Added a bitmask in TU13 to enable/disable display of the Mash-up pack
|
||||
// worlds in the saves list
|
||||
pGameSettings->uiMashUpPackWorldsDisplay = 0xFFFFFFFF;
|
||||
|
||||
// PS3DEC13
|
||||
pGameSettings->uiBitmaskValues &=
|
||||
~GAMESETTING_PS3EULAREAD; // eGameSetting_PS3_EULA_Read - off
|
||||
|
||||
// PS3 1.05 - added Greek
|
||||
pGameSettings->ucLanguage =
|
||||
MINECRAFT_LANGUAGE_DEFAULT; // use the system language
|
||||
|
||||
// PS Vita - network mode added
|
||||
pGameSettings->uiBitmaskValues &=
|
||||
~GAMESETTING_PSVITANETWORKMODEADHOC; // eGameSetting_PSVita_NetworkModeAdhoc
|
||||
// - off
|
||||
|
||||
// Tutorials for most menus, and a few other things
|
||||
pGameSettings->ucTutorialCompletion[0] = 0xFF;
|
||||
pGameSettings->ucTutorialCompletion[1] = 0xFF;
|
||||
pGameSettings->ucTutorialCompletion[2] = 0xF;
|
||||
|
||||
// Has gone halfway through the tutorial
|
||||
pGameSettings->ucTutorialCompletion[28] |= 1 << 0;
|
||||
}
|
||||
}
|
||||
void C_4JProfile::SetTrialTextStringTable(CXuiStringTable* pStringTable,
|
||||
int iAccept, int iReject) {}
|
||||
void C_4JProfile::SetTrialAwardText(eAwardType AwardType, int iTitle,
|
||||
int iText) {}
|
||||
int C_4JProfile::GetLockedProfile() { return 0; }
|
||||
void C_4JProfile::SetLockedProfile(int iProf) {}
|
||||
bool C_4JProfile::IsSignedIn(int iQuadrant) { return (iQuadrant == 0); }
|
||||
bool C_4JProfile::IsSignedInLive(int iProf) { return true; }
|
||||
bool C_4JProfile::IsGuest(int iQuadrant) { return false; }
|
||||
unsigned int C_4JProfile::RequestSignInUI(
|
||||
bool bFromInvite, bool bLocalGame, bool bNoGuestsAllowed,
|
||||
bool bMultiplayerSignIn, bool bAddUser,
|
||||
int (*Func)(void*, const bool, const int iPad), void* lpParam,
|
||||
int iQuadrant) {
|
||||
return 0;
|
||||
}
|
||||
unsigned int C_4JProfile::DisplayOfflineProfile(int (*Func)(void*, const bool,
|
||||
const int iPad),
|
||||
void* lpParam, int iQuadrant) {
|
||||
return 0;
|
||||
}
|
||||
unsigned int C_4JProfile::RequestConvertOfflineToGuestUI(
|
||||
int (*Func)(void*, const bool, const int iPad), void* lpParam,
|
||||
int iQuadrant) {
|
||||
return 0;
|
||||
}
|
||||
void C_4JProfile::SetPrimaryPlayerChanged(bool bVal) {}
|
||||
bool C_4JProfile::QuerySigninStatus(void) { return true; }
|
||||
void C_4JProfile::GetXUID(int iPad, PlayerUID* pXuid, bool bOnlineXuid) {
|
||||
*pXuid = 0xe000d45248242f2e;
|
||||
}
|
||||
bool C_4JProfile::AreXUIDSEqual(PlayerUID xuid1, PlayerUID xuid2) {
|
||||
return false;
|
||||
}
|
||||
bool C_4JProfile::XUIDIsGuest(PlayerUID xuid) { return false; }
|
||||
bool C_4JProfile::AllowedToPlayMultiplayer(int iProf) { return true; }
|
||||
|
||||
void C_4JProfile::StartTrialGame() {}
|
||||
void C_4JProfile::AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly,
|
||||
bool* allAllowed,
|
||||
bool* friendsAllowed) {}
|
||||
bool C_4JProfile::CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly,
|
||||
PPlayerUID pXuids,
|
||||
unsigned int xuidCount) {
|
||||
return true;
|
||||
}
|
||||
bool C_4JProfile::GetProfileAvatar(int iPad,
|
||||
int (*Func)(void* lpParam,
|
||||
std::uint8_t* thumbnailData,
|
||||
unsigned int thumbnailBytes),
|
||||
void* lpParam) {
|
||||
return false;
|
||||
}
|
||||
void C_4JProfile::CancelProfileAvatarRequest() {}
|
||||
int C_4JProfile::GetPrimaryPad() { return 0; }
|
||||
void C_4JProfile::SetPrimaryPad(int iPad) {}
|
||||
char* C_4JProfile::GetGamertag(int iPad) { return "PlayerName"; }
|
||||
std::wstring C_4JProfile::GetDisplayName(int iPad) { return L"PlayerName"; }
|
||||
bool C_4JProfile::IsFullVersion() { return s_bProfileIsFullVersion; }
|
||||
void C_4JProfile::SetSignInChangeCallback(void (*Func)(void*, bool,
|
||||
unsigned int),
|
||||
void* lpParam) {}
|
||||
void C_4JProfile::SetNotificationsCallback(void (*Func)(void*, std::uint32_t,
|
||||
unsigned int),
|
||||
void* lpParam) {}
|
||||
bool C_4JProfile::RegionIsNorthAmerica(void) { return false; }
|
||||
bool C_4JProfile::LocaleIsUSorCanada(void) { return false; }
|
||||
int32_t C_4JProfile::GetLiveConnectionStatus() { return S_OK; }
|
||||
bool C_4JProfile::IsSystemUIDisplayed() { return false; }
|
||||
void C_4JProfile::SetProfileReadErrorCallback(void (*Func)(void*),
|
||||
void* lpParam) {}
|
||||
int (*defaultOptionsCallback)(void*, C_4JProfile::PROFILESETTINGS*,
|
||||
const int iPad) = nullptr;
|
||||
void* lpProfileParam = nullptr;
|
||||
int C_4JProfile::SetDefaultOptionsCallback(int (*Func)(void*, PROFILESETTINGS*,
|
||||
const int iPad),
|
||||
void* lpParam) {
|
||||
defaultOptionsCallback = Func;
|
||||
lpProfileParam = lpParam;
|
||||
return 0;
|
||||
}
|
||||
int C_4JProfile::SetOldProfileVersionCallback(int (*Func)(void*, unsigned char*,
|
||||
const unsigned short,
|
||||
const int),
|
||||
void* lpParam) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// To store the dashboard preferences for controller flipped, etc.
|
||||
C_4JProfile::PROFILESETTINGS ProfileSettingsA[XUSER_MAX_COUNT];
|
||||
|
||||
C_4JProfile::PROFILESETTINGS* C_4JProfile::GetDashboardProfileSettings(
|
||||
int iPad) {
|
||||
return &ProfileSettingsA[iPad];
|
||||
}
|
||||
void C_4JProfile::WriteToProfile(int iQuadrant, bool bGameDefinedDataChanged,
|
||||
bool bOverride5MinuteLimitOnProfileWrites) {}
|
||||
void C_4JProfile::ForceQueuedProfileWrites(int iPad) {}
|
||||
void* C_4JProfile::GetGameDefinedProfileData(int iQuadrant) {
|
||||
// 4J Stu - Don't reset the options when we call this!!
|
||||
// defaultOptionsCallback(lpProfileParam, (C_4JProfile::PROFILESETTINGS
|
||||
// *)profileData[iQuadrant], iQuadrant);
|
||||
// pApp->SetDefaultOptions(pSettings,iPad);
|
||||
|
||||
return profileData[iQuadrant];
|
||||
}
|
||||
void C_4JProfile::ResetProfileProcessState() {}
|
||||
void C_4JProfile::Tick(void) {}
|
||||
void C_4JProfile::RegisterAward(int iAwardNumber, int iGamerconfigID,
|
||||
eAwardType eType, bool bLeaderboardAffected,
|
||||
CXuiStringTable* pStringTable, int iTitleStr,
|
||||
int iTextStr, int iAcceptStr,
|
||||
char* pszThemeName, unsigned int ulThemeSize) {}
|
||||
int C_4JProfile::GetAwardId(int iAwardNumber) { return 0; }
|
||||
eAwardType C_4JProfile::GetAwardType(int iAwardNumber) {
|
||||
return eAwardType_Achievement;
|
||||
}
|
||||
bool C_4JProfile::CanBeAwarded(int iQuadrant, int iAwardNumber) {
|
||||
return false;
|
||||
}
|
||||
void C_4JProfile::Award(int iQuadrant, int iAwardNumber, bool bForce) {}
|
||||
bool C_4JProfile::IsAwardsFlagSet(int iQuadrant, int iAward) { return false; }
|
||||
void C_4JProfile::RichPresenceInit(int iPresenceCount, int iContextCount) {}
|
||||
void C_4JProfile::RegisterRichPresenceContext(int iGameConfigContextID) {}
|
||||
void C_4JProfile::SetRichPresenceContextValue(int iPad, int iContextID,
|
||||
int iVal) {}
|
||||
void C_4JProfile::SetCurrentGameActivity(int iPad, int iNewPresence,
|
||||
bool bSetOthersToIdle) {}
|
||||
void C_4JProfile::DisplayFullVersionPurchase(bool bRequired, int iQuadrant,
|
||||
int iUpsellParam) {}
|
||||
void C_4JProfile::SetUpsellCallback(void (*Func)(void* lpParam,
|
||||
eUpsellType type,
|
||||
eUpsellResponse response,
|
||||
int iUserData),
|
||||
void* lpParam) {}
|
||||
void C_4JProfile::SetDebugFullOverride(bool bVal) {
|
||||
s_bProfileIsFullVersion = bVal;
|
||||
}
|
||||
void C_4JProfile::ShowProfileCard(int iPad, PlayerUID targetUid) {}
|
||||
|
||||
/////////////////////////////////////////////// Storage library
|
||||
// #ifdef _WINDOWS64
|
||||
// TODO???
|
||||
#if defined(__linux__)
|
||||
C4JStorage::C4JStorage() {}
|
||||
void C4JStorage::Tick() {}
|
||||
C4JStorage::EMessageResult C4JStorage::RequestMessageBox(
|
||||
unsigned int uiTitle, unsigned int uiText, unsigned int* uiOptionA,
|
||||
unsigned int uiOptionC, unsigned int pad,
|
||||
int (*Func)(void*, int, const C4JStorage::EMessageResult), void* lpParam,
|
||||
C4JStringTable* pStringTable, wchar_t* pwchFormatString,
|
||||
unsigned int focusButton) {
|
||||
return C4JStorage::EMessage_Undefined;
|
||||
}
|
||||
C4JStorage::EMessageResult C4JStorage::GetMessageBoxResult() {
|
||||
return C4JStorage::EMessage_Undefined;
|
||||
}
|
||||
bool C4JStorage::SetSaveDevice(int (*Func)(void*, const bool), void* lpParam,
|
||||
bool bForceResetOfSaveDevice) {
|
||||
return true;
|
||||
}
|
||||
void C4JStorage::Init(const wchar_t* pwchDefaultSaveName, char* pszSavePackName,
|
||||
int iMinimumSaveSize,
|
||||
int (*Func)(void*, const ESavingMessage, int),
|
||||
void* lpParam) {}
|
||||
void C4JStorage::ResetSaveData() {}
|
||||
void C4JStorage::SetDefaultSaveNameForKeyboardDisplay(
|
||||
const wchar_t* pwchDefaultSaveName) {}
|
||||
void C4JStorage::SetSaveTitle(const wchar_t* pwchDefaultSaveName) {}
|
||||
const wchar_t* C4JStorage::GetSaveTitle() { return L""; }
|
||||
bool C4JStorage::GetSaveUniqueNumber(int32_t* piVal) { return true; }
|
||||
bool C4JStorage::GetSaveUniqueFilename(char* pszName) { return true; }
|
||||
void C4JStorage::SetSaveUniqueFilename(char* szFilename) {}
|
||||
void C4JStorage::SetState(ESaveGameControlState eControlState,
|
||||
int (*Func)(void*, const bool), void* lpParam) {}
|
||||
void C4JStorage::SetSaveDisabled(bool bDisable) {}
|
||||
bool C4JStorage::GetSaveDisabled(void) { return false; }
|
||||
unsigned int C4JStorage::GetSaveSize() { return 0; }
|
||||
void C4JStorage::GetSaveData(void* pvData, unsigned int* pulBytes) {}
|
||||
void* C4JStorage::AllocateSaveData(unsigned int ulBytes) {
|
||||
return new char[ulBytes];
|
||||
}
|
||||
void C4JStorage::SaveSaveData(unsigned int ulBytes, uint8_t* pbThumbnail,
|
||||
uint32_t cbThumbnail, uint8_t* pbTextData,
|
||||
uint32_t dwTextLen) {}
|
||||
void C4JStorage::CopySaveDataToNewSave(std::uint8_t* pbThumbnail,
|
||||
unsigned int cbThumbnail,
|
||||
wchar_t* wchNewName,
|
||||
int (*Func)(void* lpParam, bool),
|
||||
void* lpParam) {}
|
||||
void C4JStorage::SetSaveDeviceSelected(unsigned int uiPad, bool bSelected) {}
|
||||
bool C4JStorage::GetSaveDeviceSelected(unsigned int iPad) { return true; }
|
||||
C4JStorage::ELoadGameStatus C4JStorage::DoesSaveExist(bool* pbExists) {
|
||||
return C4JStorage::ELoadGame_Idle;
|
||||
}
|
||||
bool C4JStorage::EnoughSpaceForAMinSaveGame() { return true; }
|
||||
void C4JStorage::SetSaveMessageVPosition(float fY) {}
|
||||
// C4JStorage::ESGIStatus
|
||||
// C4JStorage::GetSavesInfo(int iPad,bool ( *Func)(void*, int, CACHEINFOSTRUCT
|
||||
// *, int, int32_t),void* lpParam,char *pszSavePackName) { return
|
||||
// C4JStorage::ESGIStatus_Idle; }
|
||||
C4JStorage::ESaveGameState C4JStorage::GetSavesInfo(
|
||||
int iPad,
|
||||
int (*Func)(void* lpParam, SAVE_DETAILS* pSaveDetails, const bool),
|
||||
void* lpParam, char* pszSavePackName) {
|
||||
return C4JStorage::ESaveGame_Idle;
|
||||
}
|
||||
|
||||
void C4JStorage::GetSaveCacheFileInfo(unsigned int fileIndex,
|
||||
XCONTENT_DATA& xContentData) {}
|
||||
void C4JStorage::GetSaveCacheFileInfo(unsigned int fileIndex,
|
||||
std::uint8_t** ppbImageData,
|
||||
unsigned int* pImageBytes) {}
|
||||
C4JStorage::ESaveGameState C4JStorage::LoadSaveData(
|
||||
PSAVE_INFO pSaveInfo, int (*Func)(void* lpParam, const bool, const bool),
|
||||
void* lpParam) {
|
||||
return C4JStorage::ESaveGame_Idle;
|
||||
}
|
||||
C4JStorage::EDeleteGameStatus C4JStorage::DeleteSaveData(
|
||||
PSAVE_INFO pSaveInfo, int (*Func)(void* lpParam, const bool),
|
||||
void* lpParam) {
|
||||
return C4JStorage::EDeleteGame_Idle;
|
||||
}
|
||||
PSAVE_DETAILS C4JStorage::ReturnSavesInfo() { return nullptr; }
|
||||
|
||||
void C4JStorage::RegisterMarketplaceCountsCallback(
|
||||
int (*Func)(void* lpParam, C4JStorage::DLC_TMS_DETAILS*, int),
|
||||
void* lpParam) {}
|
||||
void C4JStorage::SetDLCPackageRoot(char* pszDLCRoot) {}
|
||||
C4JStorage::EDLCStatus C4JStorage::GetDLCOffers(
|
||||
int iPad, int (*Func)(void*, int, std::uint32_t, int), void* lpParam,
|
||||
std::uint32_t dwOfferTypesBitmaskT) {
|
||||
return C4JStorage::EDLC_Idle;
|
||||
}
|
||||
unsigned int C4JStorage::CancelGetDLCOffers() { return 0; }
|
||||
void C4JStorage::ClearDLCOffers() {}
|
||||
XMARKETPLACE_CONTENTOFFER_INFO& C4JStorage::GetOffer(unsigned int dw) {
|
||||
static XMARKETPLACE_CONTENTOFFER_INFO retval = {0};
|
||||
return retval;
|
||||
}
|
||||
int C4JStorage::GetOfferCount() { return 0; }
|
||||
unsigned int C4JStorage::InstallOffer(int iOfferIDC, uint64_t* ullOfferIDA,
|
||||
int (*Func)(void*, int, int),
|
||||
void* lpParam, bool bTrial) {
|
||||
return 0;
|
||||
}
|
||||
unsigned int C4JStorage::GetAvailableDLCCount(int iPad) { return 0; }
|
||||
XCONTENT_DATA& C4JStorage::GetDLC(unsigned int dw) {
|
||||
static XCONTENT_DATA retval = {0};
|
||||
return retval;
|
||||
}
|
||||
C4JStorage::EDLCStatus C4JStorage::GetInstalledDLC(int iPad,
|
||||
int (*Func)(void*, int, int),
|
||||
void* lpParam) {
|
||||
return C4JStorage::EDLC_Idle;
|
||||
}
|
||||
std::uint32_t C4JStorage::MountInstalledDLC(
|
||||
int iPad, std::uint32_t dwDLC,
|
||||
int (*Func)(void*, int, std::uint32_t, std::uint32_t), void* lpParam,
|
||||
const char* szMountDrive) {
|
||||
return 0;
|
||||
}
|
||||
unsigned int C4JStorage::UnmountInstalledDLC(const char* szMountDrive) {
|
||||
return 0;
|
||||
}
|
||||
C4JStorage::ETMSStatus C4JStorage::ReadTMSFile(
|
||||
int iQuadrant, eGlobalStorage eStorageFacility,
|
||||
C4JStorage::eTMS_FileType eFileType, wchar_t* pwchFilename,
|
||||
std::uint8_t** ppBuffer, unsigned int* pBufferSize,
|
||||
int (*Func)(void*, wchar_t*, int, bool, int), void* lpParam, int iAction) {
|
||||
return C4JStorage::ETMSStatus_Idle;
|
||||
}
|
||||
bool C4JStorage::WriteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility,
|
||||
wchar_t* pwchFilename, std::uint8_t* pBuffer,
|
||||
unsigned int bufferSize) {
|
||||
return true;
|
||||
}
|
||||
bool C4JStorage::DeleteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility,
|
||||
wchar_t* pwchFilename) {
|
||||
return true;
|
||||
}
|
||||
void C4JStorage::StoreTMSPathName(wchar_t* pwchName) {}
|
||||
unsigned int C4JStorage::CRC(unsigned char* buf, int len) { return 0; }
|
||||
|
||||
struct PTMSPP_FILEDATA;
|
||||
C4JStorage::ETMSStatus C4JStorage::TMSPP_ReadFile(
|
||||
int iPad, C4JStorage::eGlobalStorage eStorageFacility,
|
||||
C4JStorage::eTMS_FILETYPEVAL eFileTypeVal, const char* szFilename,
|
||||
int (*Func)(void*, int, int, PTMSPP_FILEDATA, const char*) /*=nullptr*/,
|
||||
void* lpParam /*=nullptr*/, int iUserData /*=0*/) {
|
||||
return C4JStorage::ETMSStatus_Idle;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////// Sentient manager
|
||||
|
||||
int32_t CSentientManager::Init() { return S_OK; }
|
||||
int32_t CSentientManager::Tick() { return S_OK; }
|
||||
int32_t CSentientManager::Flush() { return S_OK; }
|
||||
bool CSentientManager::RecordPlayerSessionStart(uint32_t dwUserId) {
|
||||
return true;
|
||||
}
|
||||
bool CSentientManager::RecordPlayerSessionExit(uint32_t dwUserId,
|
||||
int exitStatus) {
|
||||
return true;
|
||||
}
|
||||
bool CSentientManager::RecordHeartBeat(uint32_t dwUserId) { return true; }
|
||||
bool CSentientManager::RecordLevelStart(uint32_t dwUserId,
|
||||
ESen_FriendOrMatch friendsOrMatch,
|
||||
ESen_CompeteOrCoop competeOrCoop,
|
||||
int difficulty,
|
||||
uint32_t numberOfLocalPlayers,
|
||||
uint32_t numberOfOnlinePlayers) {
|
||||
return true;
|
||||
}
|
||||
bool CSentientManager::RecordLevelExit(uint32_t dwUserId,
|
||||
ESen_LevelExitStatus levelExitStatus) {
|
||||
return true;
|
||||
}
|
||||
bool CSentientManager::RecordLevelSaveOrCheckpoint(uint32_t dwUserId,
|
||||
int32_t saveOrCheckPointID,
|
||||
int32_t saveSizeInBytes) {
|
||||
return true;
|
||||
}
|
||||
bool CSentientManager::RecordLevelResume(uint32_t dwUserId,
|
||||
ESen_FriendOrMatch friendsOrMatch,
|
||||
ESen_CompeteOrCoop competeOrCoop,
|
||||
int difficulty,
|
||||
uint32_t numberOfLocalPlayers,
|
||||
uint32_t numberOfOnlinePlayers,
|
||||
int32_t saveOrCheckPointID) {
|
||||
return true;
|
||||
}
|
||||
bool CSentientManager::RecordPauseOrInactive(uint32_t dwUserId) { return true; }
|
||||
bool CSentientManager::RecordUnpauseOrActive(uint32_t dwUserId) { return true; }
|
||||
bool CSentientManager::RecordMenuShown(uint32_t dwUserId, int32_t menuID,
|
||||
int32_t optionalMenuSubID) {
|
||||
return true;
|
||||
}
|
||||
bool CSentientManager::RecordAchievementUnlocked(
|
||||
uint32_t dwUserId, int32_t achievementID, int32_t achievementGamerscore) {
|
||||
return true;
|
||||
}
|
||||
bool CSentientManager::RecordMediaShareUpload(
|
||||
uint32_t dwUserId, ESen_MediaDestination mediaDestination,
|
||||
ESen_MediaType mediaType) {
|
||||
return true;
|
||||
}
|
||||
bool CSentientManager::RecordUpsellPresented(uint32_t dwUserId,
|
||||
ESen_UpsellID upsellId,
|
||||
int32_t marketplaceOfferID) {
|
||||
return true;
|
||||
}
|
||||
bool CSentientManager::RecordUpsellResponded(uint32_t dwUserId,
|
||||
ESen_UpsellID upsellId,
|
||||
int32_t marketplaceOfferID,
|
||||
ESen_UpsellOutcome upsellOutcome) {
|
||||
return true;
|
||||
}
|
||||
bool CSentientManager::RecordPlayerDiedOrFailed(
|
||||
uint32_t dwUserId, int32_t lowResMapX, int32_t lowResMapY,
|
||||
int32_t lowResMapZ, int32_t mapID, int32_t playerWeaponID,
|
||||
int32_t enemyWeaponID, ETelemetryChallenges enemyTypeID) {
|
||||
return true;
|
||||
}
|
||||
bool CSentientManager::RecordEnemyKilledOrOvercome(
|
||||
uint32_t dwUserId, int32_t lowResMapX, int32_t lowResMapY,
|
||||
int32_t lowResMapZ, int32_t mapID, int32_t playerWeaponID,
|
||||
int32_t enemyWeaponID, ETelemetryChallenges enemyTypeID) {
|
||||
return true;
|
||||
}
|
||||
bool CSentientManager::RecordSkinChanged(uint32_t dwUserId, uint32_t dwSkinId) {
|
||||
return true;
|
||||
}
|
||||
bool CSentientManager::RecordBanLevel(uint32_t dwUserId) { return true; }
|
||||
bool CSentientManager::RecordUnBanLevel(uint32_t dwUserId) { return true; }
|
||||
int32_t CSentientManager::GetMultiplayerInstanceID() { return 0; }
|
||||
int32_t CSentientManager::GenerateMultiplayerInstanceId() { return 0; }
|
||||
void CSentientManager::SetMultiplayerInstanceId(int32_t value) {}
|
||||
|
||||
//////////////////////////////////////////////////////// Stats counter
|
||||
|
||||
/*
|
||||
StatsCounter::StatsCounter() {}
|
||||
void StatsCounter::award(Stat *stat, unsigned int difficulty, unsigned int
|
||||
count) {} bool StatsCounter::hasTaken(Achievement *ach) { return true; } bool
|
||||
StatsCounter::canTake(Achievement *ach) { return true; } unsigned int
|
||||
StatsCounter::getValue(Stat *stat, unsigned int difficulty) { return 0; }
|
||||
unsigned int StatsCounter::getTotalValue(Stat *stat) { return 0; }
|
||||
void StatsCounter::tick(int player) {}
|
||||
void StatsCounter::parse(void* data) {}
|
||||
void StatsCounter::clear() {}
|
||||
void StatsCounter::save(int player, bool force) {}
|
||||
void StatsCounter::flushLeaderboards() {}
|
||||
void StatsCounter::saveLeaderboards() {}
|
||||
void StatsCounter::setupStatBoards() {}
|
||||
#if defined(_DEBUG)
|
||||
void StatsCounter::WipeLeaderboards() {}
|
||||
#endif
|
||||
*/
|
||||
273
Minecraft.Client/Source Files/FrameProfiler.cpp
Normal file
273
Minecraft.Client/Source Files/FrameProfiler.cpp
Normal file
@@ -0,0 +1,273 @@
|
||||
#include "../../Minecraft.World/Header Files/stdafx.h"
|
||||
#include "../Header Files/FrameProfiler.h"
|
||||
|
||||
#ifdef ENABLE_FRAME_PROFILER
|
||||
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <string_view>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define FRAME_PROFILER_NOINLINE __declspec(noinline)
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
#define FRAME_PROFILER_NOINLINE __attribute__((noinline))
|
||||
#else
|
||||
#define FRAME_PROFILER_NOINLINE
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
using FrameProfilerClock = std::chrono::steady_clock;
|
||||
using Bucket = FrameProfiler::Bucket;
|
||||
constexpr std::uint64_t kNsPerMs = 1000ULL * 1000ULL;
|
||||
constexpr std::uint64_t kReportIntervalNs = 1000ULL * 1000ULL * 1000ULL;
|
||||
constexpr std::size_t kBucketCount = FrameProfiler::BucketCount();
|
||||
constexpr auto kFalseTokens = std::to_array<std::string_view>({
|
||||
"0",
|
||||
"false",
|
||||
"False",
|
||||
"false",
|
||||
"no",
|
||||
"No",
|
||||
"NO",
|
||||
"off",
|
||||
"Off",
|
||||
"OFF",
|
||||
});
|
||||
constexpr std::array<FrameProfiler::BucketDescriptor, kBucketCount>
|
||||
kBucketDescriptors = {{
|
||||
{Bucket::Frame, "frame"},
|
||||
{Bucket::World, "world"},
|
||||
{Bucket::Terrain, "terrain"},
|
||||
{Bucket::ChunkCull, "chunkCull"},
|
||||
{Bucket::ChunkCollect, "chunkCollect"},
|
||||
{Bucket::ChunkPlayback, "chunkPlayback"},
|
||||
{Bucket::ChunkDirtyScan, "chunkDirtyScan"},
|
||||
{Bucket::ChunkRebuildSchedule, "chunkRebuildSchedule"},
|
||||
{Bucket::ChunkRebuildBody, "chunkRebuildBody"},
|
||||
{Bucket::ChunkPrepass, "chunkPrepass"},
|
||||
{Bucket::ChunkBlockShape, "chunkBlockShape"},
|
||||
{Bucket::ChunkBlockFaceCull, "chunkBlockFaceCull"},
|
||||
{Bucket::ChunkBlockLighting, "chunkBlockLighting"},
|
||||
{Bucket::ChunkBlockEmit, "chunkBlockEmit"},
|
||||
{Bucket::RenderableTileEntityCleanup, "renderableTileEntityCleanup"},
|
||||
{Bucket::TileEntityUnloadCleanup, "tileEntityUnloadCleanup"},
|
||||
{Bucket::Entity, "entities"},
|
||||
{Bucket::Particle, "particles"},
|
||||
{Bucket::WeatherSky, "weather"},
|
||||
{Bucket::UIHud, "ui"},
|
||||
{Bucket::Lightmap, "lightmap"},
|
||||
}};
|
||||
|
||||
struct BucketTotals {
|
||||
std::uint64_t totalNs{};
|
||||
std::uint64_t maxNs{};
|
||||
std::uint64_t calls{};
|
||||
|
||||
void Record(std::uint64_t elapsedNs) noexcept {
|
||||
totalNs += elapsedNs;
|
||||
++calls;
|
||||
if (elapsedNs > maxNs) maxNs = elapsedNs;
|
||||
}
|
||||
|
||||
void Merge(const BucketTotals& other) noexcept {
|
||||
totalNs += other.totalNs;
|
||||
calls += other.calls;
|
||||
if (other.maxNs > maxNs) maxNs = other.maxNs;
|
||||
}
|
||||
};
|
||||
|
||||
struct AtomicBucketTotals {
|
||||
std::atomic<std::uint64_t> totalNs{0};
|
||||
std::atomic<std::uint64_t> maxNs{0};
|
||||
std::atomic<std::uint64_t> calls{0};
|
||||
};
|
||||
|
||||
struct ProfilerState {
|
||||
std::array<AtomicBucketTotals, kBucketCount> workerBuckets{};
|
||||
};
|
||||
|
||||
struct ThreadState {
|
||||
std::uint32_t frameScopeDepth{};
|
||||
std::uint64_t windowStartNs{};
|
||||
std::array<BucketTotals, kBucketCount> localBuckets{};
|
||||
};
|
||||
|
||||
constinit ProfilerState g_profilerState{};
|
||||
constinit thread_local ThreadState t_threadState{};
|
||||
|
||||
static_assert(kBucketDescriptors.size() == kBucketCount);
|
||||
|
||||
[[nodiscard]] inline std::uint64_t nowNs() noexcept {
|
||||
return static_cast<std::uint64_t>(
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
FrameProfilerClock::now().time_since_epoch())
|
||||
.count());
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr double nsToMs(std::uint64_t ns) noexcept {
|
||||
return static_cast<double>(ns) / static_cast<double>(kNsPerMs);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool envSaysDisabled(std::string_view value) noexcept {
|
||||
if (value.empty()) return false;
|
||||
|
||||
for (std::string_view falseToken : kFalseTokens) {
|
||||
if (value == falseToken) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline void updateAtomicMax(std::atomic<std::uint64_t>& value,
|
||||
std::uint64_t candidate) noexcept {
|
||||
std::uint64_t current = value.load(std::memory_order_relaxed);
|
||||
while (current < candidate &&
|
||||
!value.compare_exchange_weak(current, candidate,
|
||||
std::memory_order_relaxed,
|
||||
std::memory_order_relaxed)) {
|
||||
}
|
||||
}
|
||||
|
||||
inline void recordWorkerBucket(Bucket bucket,
|
||||
std::uint64_t elapsedNs) noexcept {
|
||||
AtomicBucketTotals& state =
|
||||
g_profilerState.workerBuckets[FrameProfiler::BucketIndex(bucket)];
|
||||
state.totalNs.fetch_add(elapsedNs, std::memory_order_relaxed);
|
||||
state.calls.fetch_add(1, std::memory_order_relaxed);
|
||||
updateAtomicMax(state.maxNs, elapsedNs);
|
||||
}
|
||||
|
||||
[[nodiscard]] inline bool isFrameThread() noexcept {
|
||||
return t_threadState.frameScopeDepth != 0;
|
||||
}
|
||||
|
||||
FRAME_PROFILER_NOINLINE bool computeEnabled() noexcept {
|
||||
const char* const envValue = std::getenv("C4J_FRAME_PROFILER");
|
||||
if (envValue == nullptr) return true;
|
||||
return !envSaysDisabled(envValue);
|
||||
}
|
||||
|
||||
FRAME_PROFILER_NOINLINE void emitWindowReport(
|
||||
const std::array<BucketTotals, kBucketCount>& buckets) noexcept {
|
||||
const std::uint64_t frames =
|
||||
buckets[FrameProfiler::BucketIndex(Bucket::Frame)].calls;
|
||||
if (frames == 0) return;
|
||||
|
||||
std::fprintf(stderr, "[frame-prof] avg/frame(ms) frames=%llu",
|
||||
static_cast<unsigned long long>(frames));
|
||||
for (const auto& descriptor : kBucketDescriptors) {
|
||||
const BucketTotals& bucket =
|
||||
buckets[FrameProfiler::BucketIndex(descriptor.bucket)];
|
||||
const std::string_view label = descriptor.label;
|
||||
std::fprintf(stderr, " %.*s=%.2f", static_cast<int>(label.size()),
|
||||
label.data(), nsToMs(bucket.totalNs) / frames);
|
||||
}
|
||||
std::fputc('\n', stderr);
|
||||
|
||||
std::fputs("[frame-prof] max(ms)/calls", stderr);
|
||||
for (const auto& descriptor : kBucketDescriptors) {
|
||||
const BucketTotals& bucket =
|
||||
buckets[FrameProfiler::BucketIndex(descriptor.bucket)];
|
||||
const std::string_view label = descriptor.label;
|
||||
std::fprintf(stderr, " %.*s=%.2f/%llu", static_cast<int>(label.size()),
|
||||
label.data(), nsToMs(bucket.maxNs),
|
||||
static_cast<unsigned long long>(bucket.calls));
|
||||
}
|
||||
std::fputc('\n', stderr);
|
||||
std::fflush(stderr);
|
||||
}
|
||||
|
||||
[[nodiscard]] std::array<BucketTotals, kBucketCount>
|
||||
snapshotAndResetWorkerBuckets() noexcept {
|
||||
std::array<BucketTotals, kBucketCount> snapshot = {};
|
||||
for (std::size_t i = 0; i < kBucketCount; ++i) {
|
||||
AtomicBucketTotals& workerBucket = g_profilerState.workerBuckets[i];
|
||||
snapshot[i].totalNs =
|
||||
workerBucket.totalNs.exchange(0, std::memory_order_relaxed);
|
||||
snapshot[i].maxNs =
|
||||
workerBucket.maxNs.exchange(0, std::memory_order_relaxed);
|
||||
snapshot[i].calls =
|
||||
workerBucket.calls.exchange(0, std::memory_order_relaxed);
|
||||
}
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool FrameProfiler::IsEnabled() noexcept {
|
||||
static const bool enabled = computeEnabled();
|
||||
return enabled;
|
||||
}
|
||||
|
||||
void FrameProfiler::Record(Bucket bucket, std::uint64_t elapsedNs) noexcept {
|
||||
if (isFrameThread()) {
|
||||
t_threadState.localBuckets[BucketIndex(bucket)].Record(elapsedNs);
|
||||
return;
|
||||
}
|
||||
|
||||
recordWorkerBucket(bucket, elapsedNs);
|
||||
}
|
||||
|
||||
void FrameProfiler::EndFrame(std::uint64_t elapsedNs) noexcept {
|
||||
Record(Bucket::Frame, elapsedNs);
|
||||
|
||||
ThreadState& threadState = t_threadState;
|
||||
const std::uint64_t now = nowNs();
|
||||
|
||||
if (threadState.windowStartNs == 0) {
|
||||
threadState.windowStartNs = now;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((now - threadState.windowStartNs) < kReportIntervalNs) return;
|
||||
|
||||
std::array<BucketTotals, kBucketCount> combined = threadState.localBuckets;
|
||||
const auto workerSnapshot = snapshotAndResetWorkerBuckets();
|
||||
|
||||
for (std::size_t i = 0; i < kBucketCount; ++i) {
|
||||
combined[i].Merge(workerSnapshot[i]);
|
||||
}
|
||||
|
||||
emitWindowReport(combined);
|
||||
|
||||
threadState.windowStartNs = now;
|
||||
threadState.localBuckets = {};
|
||||
}
|
||||
|
||||
FrameProfiler::Scope::Scope(Bucket bucket) noexcept
|
||||
: m_startNs(0), m_bucket(bucket), m_enabled(FrameProfiler::IsEnabled()) {
|
||||
if (m_enabled) m_startNs = nowNs();
|
||||
}
|
||||
|
||||
FrameProfiler::Scope::~Scope() noexcept {
|
||||
if (!m_enabled) return;
|
||||
FrameProfiler::Record(m_bucket, nowNs() - m_startNs);
|
||||
}
|
||||
|
||||
FrameProfiler::FrameScope::FrameScope() noexcept
|
||||
: m_startNs(0), m_enabled(false) {
|
||||
if (!FrameProfiler::IsEnabled()) return;
|
||||
|
||||
m_enabled = (t_threadState.frameScopeDepth++ == 0);
|
||||
if (m_enabled) m_startNs = nowNs();
|
||||
}
|
||||
|
||||
FrameProfiler::FrameScope::~FrameScope() noexcept {
|
||||
if (!m_enabled) {
|
||||
if (t_threadState.frameScopeDepth > 0) {
|
||||
--t_threadState.frameScopeDepth;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
FrameProfiler::EndFrame(nowNs() - m_startNs);
|
||||
|
||||
if (t_threadState.frameScopeDepth > 0) {
|
||||
--t_threadState.frameScopeDepth;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
284
Minecraft.Client/Source Files/glWrapper.cpp
Normal file
284
Minecraft.Client/Source Files/glWrapper.cpp
Normal file
@@ -0,0 +1,284 @@
|
||||
#include "../../Minecraft.World/Header Files/stdafx.h"
|
||||
|
||||
#if !defined(__linux__)
|
||||
|
||||
#include "../../Minecraft.World/ConsoleJavaLibs/FloatBuffer.h"
|
||||
#include "../../Minecraft.World/ConsoleJavaLibs/IntBuffer.h"
|
||||
#include "../../Minecraft.World/ConsoleJavaLibs/ByteBuffer.h"
|
||||
|
||||
void glViewport(int x, int y, int w, int h) {
|
||||
// We don't really need anything here because minecraft doesn't current do
|
||||
// anything other than the default viewport
|
||||
}
|
||||
|
||||
void glTranslatef(float x, float y, float z) {
|
||||
RenderManager.MatrixTranslate(x, y, z);
|
||||
}
|
||||
|
||||
void glRotatef(float angle, float x, float y, float z) {
|
||||
RenderManager.MatrixRotate(angle * (PI / 180.0f), x, y, z);
|
||||
}
|
||||
|
||||
void glPopMatrix() { RenderManager.MatrixPop(); }
|
||||
|
||||
void glPushMatrix() { RenderManager.MatrixPush(); }
|
||||
|
||||
void glScalef(float x, float y, float z) { RenderManager.MatrixScale(x, y, z); }
|
||||
|
||||
void glMultMatrixf(float* m) { RenderManager.MatrixMult(m); }
|
||||
|
||||
void glMatrixMode(int type) { RenderManager.MatrixMode(type); }
|
||||
|
||||
void glLoadIdentity() { RenderManager.MatrixSetIdentity(); }
|
||||
|
||||
void gluPerspective(float fovy, float aspect, float zNear, float zFar) {
|
||||
RenderManager.MatrixPerspective(fovy, aspect, zNear, zFar);
|
||||
}
|
||||
|
||||
void glOrtho(float left, float right, float bottom, float top, float zNear,
|
||||
float zFar) {
|
||||
RenderManager.MatrixOrthogonal(left, right, bottom, top, zNear, zFar);
|
||||
}
|
||||
|
||||
void glScaled(double x, double y, double z) {
|
||||
RenderManager.MatrixScale((float)x, (float)y, (float)z);
|
||||
}
|
||||
|
||||
void glGetFloat(int type, FloatBuffer* buff) {
|
||||
memcpy(buff->_getDataPointer(), RenderManager.MatrixGet(type), 64);
|
||||
}
|
||||
|
||||
void glDeleteLists(int first, int count) {
|
||||
RenderManager.CBuffDelete(first, count);
|
||||
}
|
||||
|
||||
int glGenLists(int count) { return RenderManager.CBuffCreate(count); }
|
||||
|
||||
void glNewList(int index, int mode) { RenderManager.CBuffStart(index); }
|
||||
|
||||
void glEndList(int vertexCount) { RenderManager.CBuffEnd(); }
|
||||
|
||||
void glCallList(int index) { RenderManager.CBuffCall(index); }
|
||||
|
||||
void glCallLists(IntBuffer* ib) {
|
||||
for (unsigned int i = 0; i < ib->limit(); i++) {
|
||||
RenderManager.CBuffCall(ib->get(i));
|
||||
}
|
||||
}
|
||||
|
||||
void glClear(int flags) { RenderManager.Clear(flags); }
|
||||
|
||||
void glClearColor(float r, float g, float b, float a) {
|
||||
float rgba[4] = {r, g, b, a};
|
||||
RenderManager.SetClearColour(rgba);
|
||||
}
|
||||
|
||||
void Display::update() {}
|
||||
|
||||
void Display::swapBuffers() {}
|
||||
|
||||
void glBindTexture(int target, int texture) {
|
||||
RenderManager.TextureBind(texture);
|
||||
}
|
||||
|
||||
void glTexImage2D(int target, int level, int internalformat, int width,
|
||||
int height, int border, int format, int type,
|
||||
ByteBuffer* data) {
|
||||
RenderManager.TextureData(width, height, data->getBuffer(), level);
|
||||
}
|
||||
|
||||
void glDeleteTextures(IntBuffer* ib) {
|
||||
for (unsigned int i = 0; i < ib->limit(); i++) {
|
||||
RenderManager.TextureFree(ib->get(i));
|
||||
}
|
||||
}
|
||||
|
||||
// 4J Stu - I'm pretty sure this is what it should do
|
||||
void glDeleteTextures(int id) { RenderManager.TextureFree(id); }
|
||||
|
||||
void glGenTextures(IntBuffer* ib) {
|
||||
for (unsigned int i = 0; i < ib->limit(); i++) {
|
||||
ib->put(RenderManager.TextureCreate());
|
||||
}
|
||||
}
|
||||
|
||||
// 4J Stu - I'm pretty sure this is what it should do
|
||||
int glGenTextures() { return RenderManager.TextureCreate(); }
|
||||
|
||||
void glColor3f(float r, float g, float b) {
|
||||
RenderManager.StateSetColour(r, g, b, 1.0f);
|
||||
}
|
||||
|
||||
void glColor4f(float r, float g, float b, float a) {
|
||||
RenderManager.StateSetColour(r, g, b, a);
|
||||
}
|
||||
|
||||
void glDisable(int state) {
|
||||
switch (state) {
|
||||
case GL_TEXTURE_2D:
|
||||
RenderManager.TextureBind(-1);
|
||||
break;
|
||||
case GL_BLEND:
|
||||
RenderManager.StateSetBlendEnable(false);
|
||||
break;
|
||||
case GL_CULL_FACE:
|
||||
RenderManager.StateSetFaceCull(false);
|
||||
break;
|
||||
case GL_DEPTH_TEST:
|
||||
RenderManager.StateSetDepthTestEnable(false);
|
||||
break;
|
||||
case GL_ALPHA_TEST:
|
||||
RenderManager.StateSetAlphaTestEnable(false);
|
||||
break;
|
||||
case GL_FOG:
|
||||
RenderManager.StateSetFogEnable(false);
|
||||
break;
|
||||
case GL_LIGHTING:
|
||||
RenderManager.StateSetLightingEnable(false);
|
||||
break;
|
||||
case GL_LIGHT0:
|
||||
RenderManager.StateSetLightEnable(0, false);
|
||||
break;
|
||||
case GL_LIGHT1:
|
||||
RenderManager.StateSetLightEnable(1, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void glEnable(int state) {
|
||||
switch (state) {
|
||||
case GL_BLEND:
|
||||
RenderManager.StateSetBlendEnable(true);
|
||||
break;
|
||||
case GL_CULL_FACE:
|
||||
RenderManager.StateSetFaceCull(true);
|
||||
break;
|
||||
case GL_DEPTH_TEST:
|
||||
RenderManager.StateSetDepthTestEnable(true);
|
||||
break;
|
||||
case GL_ALPHA_TEST:
|
||||
RenderManager.StateSetAlphaTestEnable(true);
|
||||
break;
|
||||
case GL_FOG:
|
||||
RenderManager.StateSetFogEnable(true);
|
||||
break;
|
||||
case GL_LIGHTING:
|
||||
RenderManager.StateSetLightingEnable(true);
|
||||
break;
|
||||
case GL_LIGHT0:
|
||||
RenderManager.StateSetLightEnable(0, true);
|
||||
break;
|
||||
case GL_LIGHT1:
|
||||
RenderManager.StateSetLightEnable(1, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void glDepthMask(bool enable) { RenderManager.StateSetDepthMask(enable); }
|
||||
|
||||
void glBlendFunc(int src, int dst) {
|
||||
RenderManager.StateSetBlendFunc(src, dst);
|
||||
}
|
||||
|
||||
void glAlphaFunc(int func, float param) {
|
||||
RenderManager.StateSetAlphaFunc(func, param);
|
||||
}
|
||||
|
||||
void glDepthFunc(int func) { RenderManager.StateSetDepthFunc(func); }
|
||||
|
||||
void glTexParameteri(int target, int param, int value) {
|
||||
RenderManager.TextureSetParam(param, value);
|
||||
}
|
||||
|
||||
void glPolygonOffset(float factor, float units) {
|
||||
// DirectX specifies these offsets in z buffer 0 to 1 sort of range, whereas
|
||||
// opengl seems to be in a 0 -> depth buffer size sort of range. The slope
|
||||
// factor is quite possibly different too. Magic factor for now anyway.
|
||||
const float magicFactor = 65536.0f;
|
||||
RenderManager.StateSetDepthSlopeAndBias(factor / magicFactor,
|
||||
units / magicFactor);
|
||||
}
|
||||
|
||||
void glFogi(int param, int value) {
|
||||
if (param == GL_FOG_MODE) {
|
||||
RenderManager.StateSetFogMode(value);
|
||||
}
|
||||
}
|
||||
|
||||
void glFogf(int param, float value) {
|
||||
switch (param) {
|
||||
case GL_FOG_START:
|
||||
RenderManager.StateSetFogNearDistance(value);
|
||||
break;
|
||||
case GL_FOG_END:
|
||||
RenderManager.StateSetFogFarDistance(value);
|
||||
break;
|
||||
case GL_FOG_DENSITY:
|
||||
RenderManager.StateSetFogDensity(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void glFog(int param, FloatBuffer* values) {
|
||||
if (param == GL_FOG_COLOR) {
|
||||
float* data = values->_getDataPointer();
|
||||
RenderManager.StateSetFogColour(data[0], data[1], data[2]);
|
||||
}
|
||||
}
|
||||
|
||||
void glLight(int light, int mode, FloatBuffer* values) {
|
||||
int idx;
|
||||
if (light == GL_LIGHT0) {
|
||||
idx = 0;
|
||||
} else if (light == GL_LIGHT1) {
|
||||
idx = 1;
|
||||
} else
|
||||
return;
|
||||
float* data = values->_getDataPointer();
|
||||
switch (mode) {
|
||||
case GL_POSITION:
|
||||
RenderManager.StateSetLightDirection(idx, data[0], data[1],
|
||||
data[2]);
|
||||
break;
|
||||
case GL_DIFFUSE:
|
||||
RenderManager.StateSetLightColour(idx, data[0], data[1], data[2]);
|
||||
break;
|
||||
case GL_AMBIENT:
|
||||
break;
|
||||
case GL_SPECULAR:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void glLightModel(int mode, FloatBuffer* values) {
|
||||
float* data = values->_getDataPointer();
|
||||
if (mode == GL_LIGHT_MODEL_AMBIENT) {
|
||||
RenderManager.StateSetLightAmbientColour(data[0], data[1], data[2]);
|
||||
}
|
||||
}
|
||||
|
||||
void glLineWidth(float width) { RenderManager.StateSetLineWidth(width); }
|
||||
|
||||
void glColorMask(bool red, bool green, bool blue, bool alpha) {
|
||||
RenderManager.StateSetWriteEnable(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
void glMultiTexCoord2f(int, float u, float v) {
|
||||
// Clamp these values just to be safe - the lighting code can get broken if
|
||||
// we pass things to StateSetVertexTextureUV that are >= 1
|
||||
if (u > 255.0f) u = 255.0f;
|
||||
if (v > 255.0f) v = 255.0f;
|
||||
|
||||
RenderManager.StateSetVertexTextureUV(u / 256.0f, v / 256.0f);
|
||||
}
|
||||
|
||||
void glTexGen(int coord, int mode, FloatBuffer* vec) {
|
||||
float* data = vec->_getDataPointer();
|
||||
|
||||
RenderManager.StateSetTexGenCol(coord, data[0], data[1], data[2], data[3],
|
||||
mode == GL_EYE_PLANE);
|
||||
}
|
||||
|
||||
void glCullFace(int dir) { RenderManager.StateSetFaceCullCW(dir == GL_BACK); }
|
||||
|
||||
#endif
|
||||
8
Minecraft.Client/Source Files/stdafx.cpp
Normal file
8
Minecraft.Client/Source Files/stdafx.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// Minecraft.Client.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "../../Minecraft.World/Header Files/stdafx.h"
|
||||
|
||||
// TODO: reference any additional headers you need in STDAFX.H
|
||||
// and not in this file
|
||||
66
Minecraft.Client/Source Files/stubs.cpp
Normal file
66
Minecraft.Client/Source Files/stubs.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include "../../Minecraft.World/Header Files/stdafx.h"
|
||||
|
||||
#if defined(__linux__)
|
||||
|
||||
void LinuxLogStubLightmapProbe() {
|
||||
static bool logged = false;
|
||||
if (logged) return;
|
||||
|
||||
logged = true;
|
||||
app.DebugPrintf(
|
||||
"[linux-lightmap] stubs.cpp: Linux excludes the no-op multitexture "
|
||||
"stubs in this file; the runtime uses libGL/4jlibs symbols.\n");
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void glReadPixels(int, int, int, int, int, int, ByteBuffer*) {}
|
||||
|
||||
void glClearDepth(double) {}
|
||||
|
||||
void glVertexPointer(int, int, int, int) {}
|
||||
|
||||
void glVertexPointer(int, int, FloatBuffer*) {}
|
||||
|
||||
void glTexCoordPointer(int, int, int, int) {}
|
||||
|
||||
void glTexCoordPointer(int, int, FloatBuffer*) {}
|
||||
|
||||
void glNormalPointer(int, int, int) {}
|
||||
|
||||
void glNormalPointer(int, ByteBuffer*) {}
|
||||
|
||||
void glEnableClientState(int) {}
|
||||
|
||||
void glDisableClientState(int) {}
|
||||
|
||||
void glColorPointer(int, int, int, int) {}
|
||||
|
||||
void glColorPointer(int, bool, int, ByteBuffer*) {}
|
||||
|
||||
void glDrawArrays(int, int, int) {}
|
||||
|
||||
void glNormal3f(float, float, float) {}
|
||||
|
||||
void glGenQueriesARB(IntBuffer*) {}
|
||||
|
||||
void glBeginQueryARB(int, int) {}
|
||||
|
||||
void glEndQueryARB(int) {}
|
||||
|
||||
void glGetQueryObjectuARB(int, int, IntBuffer*) {}
|
||||
|
||||
void glShadeModel(int) {}
|
||||
|
||||
void glColorMaterial(int, int) {}
|
||||
|
||||
// 1.8.2
|
||||
void glClientActiveTexture(int) {}
|
||||
|
||||
void glActiveTexture(int) {}
|
||||
|
||||
void glFlush() {}
|
||||
|
||||
void glTexGeni(int, int, int) {}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user