port: CMapOutdoor + PythonBackground + minimap (1:1 40250)

GameLib map/area/terrain units, PRTerrainLib Terrain/TextureSet,
PythonBackground(+Module) and ColorTransitionHelper ported verbatim;
pending stand-ins and background module stubs removed. Hand edits:
BeginEnvironment's pointer tag via uintptr_t, LoadWaterMap reads the
file's 32-bit longs. Terrain draw passes stay platform no-ops (Godot
draws the terrain). RecordingDevice gains textures, buffers and render
targets; orthographic draws become UI commands so CPythonMiniMap's
masked tiles show through minimap_image_filter in python_ui_surface.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-09-24 03:50:09 +09:00
co-authored by Claude Opus 5.5
parent b69116992c
commit 2ead95756e
100 changed files with 17679 additions and 1514 deletions
+74 -4
View File
@@ -662,10 +662,71 @@ typedef struct _D3DCAPS8
// upcasts 40250 relies on (texture -> base texture) compile; of the resources only the buffers carry
// methods (Lock/Unlock, platform/EterLib/CpuBuffer.h).
struct IDirect3D8;
struct IDirect3DResource8 {};
struct IDirect3DBaseTexture8 : IDirect3DResource8 {};
struct IDirect3DTexture8 : IDirect3DBaseTexture8 {};
struct IDirect3DSurface8 : IDirect3DResource8 {};
typedef enum _D3DRESOURCETYPE
{
D3DRTYPE_SURFACE = 1,
D3DRTYPE_VOLUME = 2,
D3DRTYPE_TEXTURE = 3,
D3DRTYPE_VOLUMETEXTURE = 4,
D3DRTYPE_CUBETEXTURE = 5,
D3DRTYPE_VERTEXBUFFER = 6,
D3DRTYPE_INDEXBUFFER = 7,
D3DRTYPE_FORCE_DWORD = 0x7fffffff
} D3DRESOURCETYPE;
typedef struct _D3DLOCKED_RECT
{
INT Pitch;
void* pBits;
} D3DLOCKED_RECT;
typedef struct _D3DSURFACE_DESC
{
D3DFORMAT Format;
D3DRESOURCETYPE Type;
DWORD Usage;
D3DPOOL Pool;
UINT Size;
D3DMULTISAMPLE_TYPE MultiSampleType;
UINT Width;
UINT Height;
} D3DSURFACE_DESC;
typedef struct _D3DRECT
{
LONG x1, y1, x2, y2;
} D3DRECT;
#define D3DCLEAR_TARGET 0x00000001l
#define D3DCLEAR_ZBUFFER 0x00000002l
#define D3DCLEAR_STENCIL 0x00000004l
// PORT: the resource interfaces carry virtual defaults so the platform's texture handles
// (GrpImageTexture's MemoryTexture/FileTexture, owned by their own registries) need not implement
// them; device-created resources (RecordingDevice CreateTexture/...) override AddRef/Release.
struct IDirect3DResource8
{
virtual ~IDirect3DResource8() = default;
virtual ULONG AddRef() { return 1; }
virtual ULONG Release() { return 1; }
};
struct IDirect3DSurface8 : IDirect3DResource8
{
virtual HRESULT GetDesc(D3DSURFACE_DESC* pDesc) { return E_FAIL; }
virtual HRESULT LockRect(D3DLOCKED_RECT* pLockedRect, const RECT* pRect, DWORD Flags) { return E_FAIL; }
virtual HRESULT UnlockRect() { return E_FAIL; }
};
struct IDirect3DBaseTexture8 : IDirect3DResource8
{
virtual DWORD GetLevelCount() { return 1; }
};
struct IDirect3DTexture8 : IDirect3DBaseTexture8
{
virtual HRESULT GetLevelDesc(UINT Level, D3DSURFACE_DESC* pDesc) { return E_FAIL; }
virtual HRESULT GetSurfaceLevel(UINT Level, IDirect3DSurface8** ppSurfaceLevel) { return E_FAIL; }
virtual HRESULT LockRect(UINT Level, D3DLOCKED_RECT* pLockedRect, const RECT* pRect, DWORD Flags) { return E_FAIL; }
virtual HRESULT UnlockRect(UINT Level) { return E_FAIL; }
};
struct IDirect3DVertexBuffer8 : IDirect3DResource8
{
virtual ~IDirect3DVertexBuffer8() = default;
@@ -695,6 +756,15 @@ struct IDirect3DDevice8
virtual HRESULT GetTransform(D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix) = 0;
virtual HRESULT SetMaterial(const D3DMATERIAL8* pMaterial) = 0;
virtual HRESULT SetLight(DWORD Index, const D3DLIGHT8* pLight) = 0;
virtual HRESULT LightEnable(DWORD Index, BOOL Enable) = 0;
virtual HRESULT CreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture8** ppTexture) = 0;
virtual HRESULT CreateVertexBuffer(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer8** ppVertexBuffer) = 0;
virtual HRESULT CreateIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer8** ppIndexBuffer) = 0;
virtual HRESULT CreateDepthStencilSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, IDirect3DSurface8** ppSurface) = 0;
virtual HRESULT GetRenderTarget(IDirect3DSurface8** ppRenderTarget) = 0;
virtual HRESULT GetDepthStencilSurface(IDirect3DSurface8** ppZStencilSurface) = 0;
virtual HRESULT SetRenderTarget(IDirect3DSurface8* pRenderTarget, IDirect3DSurface8* pNewZStencil) = 0;
virtual HRESULT Clear(DWORD Count, const D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil) = 0;
virtual HRESULT SetRenderState(D3DRENDERSTATETYPE State, DWORD Value) = 0;
virtual HRESULT SetTexture(DWORD Stage, IDirect3DBaseTexture8* pTexture) = 0;
virtual HRESULT SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) = 0;
+10
View File
@@ -411,6 +411,16 @@ inline FLOAT D3DXPlaneDotCoord(const D3DXPLANE* pP, const D3DXVECTOR3* pV)
{
return pP->a * pV->x + pP->b * pV->y + pP->c * pV->z + pP->d;
}
inline D3DXPLANE* D3DXPlaneNormalize(D3DXPLANE* pOut, const D3DXPLANE* pP)
{
const FLOAT length = sqrtf(pP->a * pP->a + pP->b * pP->b + pP->c * pP->c);
const FLOAT inv = length > 0.0f ? 1.0f / length : 0.0f;
pOut->a = pP->a * inv;
pOut->b = pP->b * inv;
pOut->c = pP->c * inv;
pOut->d = pP->d * inv;
return pOut;
}
// --- ID3DXMatrixStack --- (the D3DX8 interface, as a plain class: the Local variants pre-multiply)
struct ID3DXMatrixStack
+28
View File
@@ -65,9 +65,37 @@ void fill_find_data(const std::string& path, WIN32_FIND_DATA* data)
const size_t slash = path.find_last_of('/');
const std::string name = path.substr(slash == std::string::npos ? 0 : slash + 1);
std::snprintf(data->cFileName, sizeof(data->cFileName), "%s", name.c_str());
struct stat st{};
data->dwFileAttributes = stat(path.c_str(), &st) == 0 && S_ISDIR(st.st_mode) ? FILE_ATTRIBUTE_DIRECTORY
: FILE_ATTRIBUTE_NORMAL;
}
}
BOOL CopyFile(LPCSTR existing_path, LPCSTR new_path, BOOL fail_if_exists)
{
if (!existing_path || !new_path)
return FALSE;
if (fail_if_exists && _access(new_path, 0) == 0)
return FALSE;
FILE* in = std::fopen(existing_path, "rb");
if (!in)
return FALSE;
FILE* out = std::fopen(new_path, "wb");
if (!out)
{
std::fclose(in);
return FALSE;
}
char buffer[65536];
size_t n;
bool ok = true;
while ((n = std::fread(buffer, 1, sizeof(buffer), in)) > 0)
ok = ok && std::fwrite(buffer, 1, n, out) == n;
std::fclose(in);
ok = std::fclose(out) == 0 && ok;
return ok ? TRUE : FALSE;
}
HANDLE FindFirstFile(const char* pattern, WIN32_FIND_DATA* data)
{
if (!pattern || !data)
+6 -1
View File
@@ -61,8 +61,11 @@ int _snprintf(char* buf, size_t count, const char* fmt, ...)
// the MSVC modes 0 (exists), 2 (write), 4 (read), 6 (read/write).
BOOL CreateDirectory(LPCSTR path, void* security_attributes);
BOOL DeleteFile(LPCSTR path);
BOOL CopyFile(LPCSTR existing_path, LPCSTR new_path, BOOL fail_if_exists);
int _access(const char* path, int mode);
struct WIN32_FIND_DATA { char cFileName[MAX_PATH]; };
#define FILE_ATTRIBUTE_DIRECTORY 0x00000010
#define FILE_ATTRIBUTE_NORMAL 0x00000080
struct WIN32_FIND_DATA { DWORD dwFileAttributes; char cFileName[MAX_PATH]; };
#define INVALID_HANDLE_VALUE (reinterpret_cast<HANDLE>(static_cast<intptr_t>(-1)))
HANDLE FindFirstFile(const char* pattern, WIN32_FIND_DATA* data);
BOOL FindNextFile(HANDLE handle, WIN32_FIND_DATA* data);
@@ -72,6 +75,8 @@ void Sleep(DWORD milliseconds);
// winmm `timeGetTime`: milliseconds since system start, wrapping at 2^32.
DWORD timeGetTime();
DWORD GetTickCount();
// winbase.h: #define GetCurrentTime() GetTickCount()
#define GetCurrentTime() GetTickCount()
// Recursive, like the Win32 critical section. Storage holds a std::recursive_mutex.
struct CRITICAL_SECTION