mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-13 06:17:13 +00:00
DWORD→uint32_t, BYTE→uint8_t, HRESULT→int32_t, HANDLE→void*, UINT→uint32_t, INT→int32_t, WORD→uint16_t, LONG→int32_t, SHORT→int16_t, LONGLONG→int64_t, ULONG_PTR→uintptr_t, PBYTE→uint8_t*, LPWSTR/PWSTR→wchar_t*, FLOAT→float, CHAR→char, boolean→bool, CONST→const, TRUE→true, FALSE→false across 176 files (excluding vendor libs and Linux stubs).
69 lines
2.4 KiB
C++
69 lines
2.4 KiB
C++
#include "../../Platform/stdafx.h"
|
|
#include "../../Headers/net.minecraft.world.level.biome.h"
|
|
#include "../../Headers/net.minecraft.world.level.newbiome.layer.h"
|
|
#include "../../Headers/net.minecraft.world.level.h"
|
|
#include "BiomeOverrideLayer.h"
|
|
|
|
BiomeOverrideLayer::BiomeOverrideLayer(int seedMixup) : Layer(seedMixup) {
|
|
m_biomeOverride = byteArray(width * height);
|
|
|
|
#if defined(_UNICODE)
|
|
std::wstring path = L"GAME:\\GameRules\\biomemap.bin";
|
|
void* file = CreateFile(path.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING,
|
|
FILE_ATTRIBUTE_NORMAL, nullptr);
|
|
#else
|
|
#if defined(_WINDOWS64)
|
|
std::string path = "GameRules\\biomemap.bin";
|
|
#else
|
|
std::string path = "GAME:\\GameRules\\biomemap.bin";
|
|
#endif
|
|
void* file = CreateFile(path.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING,
|
|
FILE_ATTRIBUTE_NORMAL, nullptr);
|
|
#endif
|
|
if (file == INVALID_HANDLE_VALUE) {
|
|
uint32_t error = GetLastError();
|
|
// assert(false);
|
|
app.DebugPrintf("Biome override not found, using plains as default\n");
|
|
|
|
memset(m_biomeOverride.data, Biome::plains->id, m_biomeOverride.length);
|
|
} else {
|
|
uint32_t bytesRead, dwFileSize = GetFileSize(file, nullptr);
|
|
if (dwFileSize > m_biomeOverride.length) {
|
|
app.DebugPrintf("Biomemap binary is too large!!\n");
|
|
__debugbreak();
|
|
}
|
|
bool bSuccess =
|
|
ReadFile(file, m_biomeOverride.data, dwFileSize, &bytesRead, nullptr);
|
|
|
|
if (bSuccess == false) {
|
|
app.FatalLoadError();
|
|
}
|
|
|
|
CloseHandle(file);
|
|
}
|
|
}
|
|
|
|
intArray BiomeOverrideLayer::getArea(int xo, int yo, int w, int h) {
|
|
intArray result{static_cast<unsigned int>(w * h)};
|
|
|
|
int xOrigin = xo + width / 2;
|
|
int yOrigin = yo + height / 2;
|
|
if (xOrigin < 0) xOrigin = 0;
|
|
if (xOrigin >= width) xOrigin = width - 1;
|
|
if (yOrigin < 0) yOrigin = 0;
|
|
if (yOrigin >= height) yOrigin = height - 1;
|
|
for (int y = 0; y < h; y++) {
|
|
for (int x = 0; x < w; x++) {
|
|
int curX = xOrigin + x;
|
|
int curY = yOrigin + y;
|
|
if (curX >= width) curX = width - 1;
|
|
if (curY >= height) curY = height - 1;
|
|
int index = curX + curY * width;
|
|
|
|
unsigned char headerValue = m_biomeOverride[index];
|
|
result[x + y * w] = headerValue;
|
|
}
|
|
}
|
|
return result;
|
|
}
|