Author SHA1 Message Date
Tropical 0dd1654dec docs: undo accidental comment replacement 2026-03-06 05:13:40 -06:00
Tropical b8c4e96409 fix: more replacement mistakes 2026-03-06 05:09:17 -06:00
Tropical 6c56d884e5 fix: undo some mistakes 2026-03-06 05:06:27 -06:00
Tropical 15af35eef2 fix: remove byte type alias 2026-03-06 05:03:37 -06:00
2575 changed files with 778 additions and 8859 deletions
-36
View File
@@ -1,36 +0,0 @@
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04
ENV DEBIAN_FRONTEND=noninteractive
# Dependencies
RUN apt-get update \
&& apt-get install -y software-properties-common \
&& add-apt-repository -y ppa:ubuntu-toolchain-r/test \
&& apt-get update \
&& apt-get install -y \
build-essential \
cmake \
libglfw3-dev \
libgl-dev \
libglu1-mesa-dev \
libopenal-dev \
libvorbis-dev \
libpng-dev \
libpthread-stubs0-dev \
lld \
meson \
ninja-build \
gcc-15 \
g++-15 \
# Clean up lol
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# Set GCC 15 as default
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-15 100 \
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-15 100 \
&& update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 100 \
&& update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 100
ENV DEBIAN_FRONTEND=dialog
-17
View File
@@ -1,17 +0,0 @@
{
"name": "4JCraft Dev Container",
"build": {
"dockerfile": "Dockerfile"
},
"customizations": {
"vscode": {
"settings": {},
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cpptools-extension-pack",
"mesonbuild.mesonbuild"
]
}
},
"remoteUser": "vscode"
}
+3 -1
View File
@@ -33,7 +33,9 @@ meson-logs/
*.d
compile_commands.json
# ----- Runtime-created symlinks / scratch -----
# Asset symlink created at runtime for working directory resolution
Common
# ----- Scratch / legacy -----
oldimpl/
+75 -34
View File
@@ -11,9 +11,6 @@
#include <cmath>
#include <pthread.h>
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
C4JRender RenderManager;
static GLFWwindow *s_window = nullptr;
@@ -498,62 +495,106 @@ void C4JRender::TextureDynamicUpdateEnd() {}
void C4JRender::Tick() {}
void C4JRender::UpdateGamma(unsigned short) {}
// really don't know if this is nessesary but didn't find any other functions to load images properly as a png..
// im sorry.
#ifdef __linux__
#include <png.h>
#include <stdio.h>
#include <string.h>
// This sucks, but at least better than libpng
static HRESULT LoadFromSTB(unsigned char* data, int width, int height, D3DXIMAGE_INFO* pSrcInfo, int** ppDataOut)
static HRESULT LoadPNGFromRows(png_structp png, png_infop info, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut)
{
int pixelCount = width * height;
int* pixels = new int[pixelCount];
int width = png_get_image_width(png, info);
int height = png_get_image_height(png, info);
png_byte color_type = png_get_color_type(png, info);
png_byte bit_depth = png_get_bit_depth(png, info);
for (int i = 0; i < pixelCount; i++)
if (bit_depth == 16) png_set_strip_16(png);
if (color_type == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb(png);
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png);
if (png_get_valid(png, info, PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png);
if (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_PALETTE)
png_set_filler(png, 0xFF, PNG_FILLER_AFTER);
if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png);
png_read_update_info(png, info);
unsigned char *buf = new unsigned char[width * height * 4];
png_bytep *rows = new png_bytep[height];
for (int y = 0; y < height; y++)
rows[y] = buf + y * width * 4;
png_read_image(png, rows);
delete[] rows;
// considering i worked on previous projects with raw pngs,,,,,
int *pixels = new int[width * height];
for (int i = 0; i < width * height; i++)
{
unsigned char r = data[i * 4 + 0];
unsigned char g = data[i * 4 + 1];
unsigned char b = data[i * 4 + 2];
unsigned char a = data[i * 4 + 3];
//pixels[i] = (a << 24) | (b << 16) | (g << 8) | r;
unsigned char r = buf[i * 4 + 0];
unsigned char g = buf[i * 4 + 1];
unsigned char b = buf[i * 4 + 2];
unsigned char a = buf[i * 4 + 3];
pixels[i] = (a << 24) | (r << 16) | (g << 8) | b;
}
delete[] buf;
if (pSrcInfo)
{
pSrcInfo->Width = width;
pSrcInfo->Height = height;
}
pSrcInfo->Width = width;
pSrcInfo->Height = height;
*ppDataOut = pixels;
return S_OK;
}
HRESULT C4JRender::LoadTextureData(const char* szFilename, D3DXIMAGE_INFO* pSrcInfo, int** ppDataOut)
HRESULT C4JRender::LoadTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut)
{
int width, height, channels;
FILE *fp = fopen(szFilename, "rb");
if (!fp) return E_FAIL;
unsigned char* data = stbi_load(szFilename, &width, &height, &channels, 4);
if (!data)
return E_FAIL;
png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png) { fclose(fp); return E_FAIL; }
png_infop info = png_create_info_struct(png);
if (!info) { png_destroy_read_struct(&png, NULL, NULL); fclose(fp); return E_FAIL; }
if (setjmp(png_jmpbuf(png))) { png_destroy_read_struct(&png, &info, NULL); fclose(fp); return E_FAIL; }
HRESULT hr = LoadFromSTB(data, width, height, pSrcInfo, ppDataOut);
png_init_io(png, fp);
png_read_info(png, info);
stbi_image_free(data);
HRESULT hr = LoadPNGFromRows(png, info, pSrcInfo, ppDataOut);
png_destroy_read_struct(&png, &info, NULL);
fclose(fp);
return hr;
}
HRESULT C4JRender::LoadTextureData(BYTE* pbData, DWORD dwBytes, D3DXIMAGE_INFO* pSrcInfo, int** ppDataOut)
struct PNGMemReader { const unsigned char *data; png_size_t pos; png_size_t size; };
static void png_mem_read(png_structp png, png_bytep out, png_size_t len)
{
int width, height, channels;
PNGMemReader *r = (PNGMemReader *)png_get_io_ptr(png);
if (r->pos + len > r->size) len = r->size - r->pos;
memcpy(out, r->data + r->pos, len);
r->pos += len;
}
unsigned char* data = stbi_load_from_memory(pbData, dwBytes, &width, &height, &channels, 4);
if (!data)
return E_FAIL;
HRESULT C4JRender::LoadTextureData(BYTE *pbData, DWORD dwBytes, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut)
{
png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png) return E_FAIL;
png_infop info = png_create_info_struct(png);
if (!info) { png_destroy_read_struct(&png, NULL, NULL); return E_FAIL; }
if (setjmp(png_jmpbuf(png))) { png_destroy_read_struct(&png, &info, NULL); return E_FAIL; }
HRESULT hr = LoadFromSTB(data, width, height, pSrcInfo, ppDataOut);
PNGMemReader reader = { pbData, 0, dwBytes };
png_set_read_fn(png, &reader, png_mem_read);
png_read_info(png, info);
stbi_image_free(data);
HRESULT hr = LoadPNGFromRows(png, info, pSrcInfo, ppDataOut);
png_destroy_read_struct(&png, &info, NULL);
return hr;
}
#else
HRESULT C4JRender::LoadTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut) { return S_OK; }
HRESULT C4JRender::LoadTextureData(BYTE *pbData, DWORD dwBytes, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut) { return S_OK; }
#endif
HRESULT C4JRender::SaveTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int *ppDataOut) { return S_OK; }
HRESULT C4JRender::SaveTextureDataToMemory(void *pOutput, int outputCapacity, int *outputLength, int width, int height, int *ppDataIn) { return S_OK; }
void C4JRender::TextureGetStats() {}
File diff suppressed because it is too large Load Diff
@@ -104,7 +104,7 @@ void GameRuleManager::loadGameRules(DLCPack *pack)
{
DLCGameRulesHeader *dlcHeader = (DLCGameRulesHeader *)pack->getFile(DLCManager::e_DLCType_GameRulesHeader, i);
DWORD dSize;
byte *dData = dlcHeader->getData(dSize);
uint8_t *dData = dlcHeader->getData(dSize);
LevelGenerationOptions *createdLevelGenerationOptions = new LevelGenerationOptions();
// = loadGameRules(dData, dSize); //, strings);
@@ -126,7 +126,7 @@ void GameRuleManager::loadGameRules(DLCPack *pack)
DLCGameRulesFile *dlcFile = (DLCGameRulesFile *)pack->getFile(DLCManager::e_DLCType_GameRules, i);
DWORD dSize;
byte *dData = dlcFile->getData(dSize);
uint8_t *dData = dlcFile->getData(dSize);
LevelGenerationOptions *createdLevelGenerationOptions = new LevelGenerationOptions();
// = loadGameRules(dData, dSize); //, strings);
@@ -142,7 +142,7 @@ void GameRuleManager::loadGameRules(DLCPack *pack)
}
}
LevelGenerationOptions *GameRuleManager::loadGameRules(byte *dIn, UINT dSize)
LevelGenerationOptions *GameRuleManager::loadGameRules(uint8_t *dIn, UINT dSize)
{
LevelGenerationOptions *lgo = new LevelGenerationOptions();
lgo->setGrSource( new JustGrSource() );
@@ -153,7 +153,7 @@ LevelGenerationOptions *GameRuleManager::loadGameRules(byte *dIn, UINT dSize)
}
// 4J-JEV: Reverse of saveGameRules.
void GameRuleManager::loadGameRules(LevelGenerationOptions *lgo, byte *dIn, UINT dSize)
void GameRuleManager::loadGameRules(LevelGenerationOptions *lgo, uint8_t *dIn, UINT dSize)
{
app.DebugPrintf("GameRuleManager::LoadingGameRules:\n");
@@ -240,7 +240,7 @@ void GameRuleManager::loadGameRules(LevelGenerationOptions *lgo, byte *dIn, UINT
}
// 4J-JEV: Reverse of loadGameRules.
void GameRuleManager::saveGameRules(byte **dOut, UINT *dSize)
void GameRuleManager::saveGameRules(uint8_t **dOut, UINT *dSize)
{
if (m_currentGameRuleDefinitions == NULL &&
m_currentLevelGenerationOptions == NULL)
@@ -373,7 +373,7 @@ void GameRuleManager::writeRuleFile(DataOutputStream *dos)
m_currentGameRuleDefinitions->write(dos);
}
bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, byte *dIn, UINT dSize, StringTable *strings) //(DLCGameRulesFile *dlcFile, StringTable *strings)
bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, uint8_t *dIn, UINT dSize, StringTable *strings) //(DLCGameRulesFile *dlcFile, StringTable *strings)
{
bool levelGenAdded = false;
bool gameRulesAdded = false;
@@ -40,10 +40,10 @@ public:
void loadGameRules(DLCPack *);
LevelGenerationOptions *loadGameRules(byte *dIn, UINT dSize);
void loadGameRules(LevelGenerationOptions *lgo, byte *dIn, UINT dSize);
LevelGenerationOptions *loadGameRules(uint8_t *dIn, UINT dSize);
void loadGameRules(LevelGenerationOptions *lgo, uint8_t *dIn, UINT dSize);
void saveGameRules(byte **dOut, UINT *dSize);
void saveGameRules(uint8_t **dOut, UINT *dSize);
private:
LevelGenerationOptions *readHeader(DLCGameRulesHeader *grh);
@@ -51,7 +51,7 @@ private:
void writeRuleFile(DataOutputStream *dos);
public:
bool readRuleFile(LevelGenerationOptions *lgo, byte *dIn, UINT dSize, StringTable *strings); //(DLCGameRulesFile *dlcFile, StringTable *strings);
bool readRuleFile(LevelGenerationOptions *lgo, uint8_t *dIn, UINT dSize, StringTable *strings); //(DLCGameRulesFile *dlcFile, StringTable *strings);
private:
void readAttributes(DataInputStream *dis, vector<wstring> *tagsAndAtts, GameRuleDefinition *rule);

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