port 2A step 4: platform skeleton + rest of the 2V3 header closure

- Mirror the remaining non-Python 2V3 closure headers (98 more, 173 total): EffectLib,
  EterGrnLib, SpeedTreeLib, SphereLib, PRTerrainLib, EterImageLib, EterBase/Poly, cipher/tea,
  EterLib Grp*/IME/Input/MSWindow/StateManager, GameLib actor/map/race headers, EterPack.
- SDK shims: granny.h, SpeedTreeRT.h, imm.h, Dimm.h (the SDK MIDL header, not mirrored),
  dinput/d3dx8 additions; D3D8 render-state enums, FVF macros and the COM resource hierarchy;
  more Win32 GDI/handle types with layout static_asserts.
- PORT edits for MSVC-permissive code (typename, friend visibility, <algorithm>, pointer→uintptr_t)
  and PRTerrainLib/StdAfx.h dropping the ScriptLib/Python include.
- port_logic links the vendored cryptopp/minilzo.
- extension/src/platform: port_platform target with 103 generated stub files (1917 function
  stubs, 146 static members) from the new platform_stub.py (clang -ast-dump-filter);
  MT_PLATFORM_STUB() marks every unimplemented body. libmtgodot links port_platform and
  port_gate.sh builds it.

Gate: macOS, Android, iOS, Windows (mingw) PASS; Linux BLOCKED (no toolchain).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-09-22 21:46:24 +09:00
co-authored by Claude Opus 5
parent fc47582017
commit 9a8e11f3dd
220 changed files with 24287 additions and 25 deletions
+32
View File
@@ -0,0 +1,32 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__EECC0C4D_07A5_4D9E_B40F_767A80FD6DE6__INCLUDED_)
#define AFX_STDAFX_H__EECC0C4D_07A5_4D9E_B40F_767A80FD6DE6__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// TODO: reference additional headers your program requires here
#pragma warning(disable:4702)
//#include <crtdbg.h>
#include "../EterLib/StdAfx.h"
#include "../EterGrnLib/StdAfx.h"
// PORT: dropped #include "../ScriptLib/StdAfx.h": no PRTerrainLib file uses Python, and it would pull
// CPython headers into every terrain translation unit.
/* Fast Float<->Integer conversion */
extern float PR_FCNV;
extern long PR_ICNV;
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__EECC0C4D_07A5_4D9E_B40F_767A80FD6DE6__INCLUDED_)
+156
View File
@@ -0,0 +1,156 @@
// Terrain.h: interface for the CTerrainImpl class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_TERRAIN_H__1C9108E1_69A7_4392_9B68_0E6CD4E1BFBA__INCLUDED_)
#define AFX_TERRAIN_H__1C9108E1_69A7_4392_9B68_0E6CD4E1BFBA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "../EterImageLib/TGAImage.h"
#include "TextureSet.h"
#include "TerrainType.h"
class CTerrainImpl
{
public:
enum
{
XSIZE = TERRAIN_SIZE,
YSIZE = TERRAIN_SIZE,
HEIGHTMAP_XSIZE = XSIZE+1,
HEIGHTMAP_YSIZE = YSIZE+1,
HEIGHTMAP_RAW_XSIZE = XSIZE+3,
HEIGHTMAP_RAW_YSIZE = YSIZE+3,
ATTRMAP_XSIZE = XSIZE*2,
ATTRMAP_YSIZE = YSIZE*2,
ATTRMAP_ZCOUNT = 8,
TILEMAP_XSIZE = XSIZE*2,
TILEMAP_YSIZE = YSIZE*2,
TILEMAP_RAW_XSIZE = XSIZE*2+2,
TILEMAP_RAW_YSIZE = YSIZE*2+2,
WATERMAP_XSIZE = XSIZE,
WATERMAP_YSIZE = YSIZE,
NORMALMAP_XSIZE = XSIZE+1,
NORMALMAP_YSIZE = YSIZE+1,
SHADOWMAP_XSIZE = XSIZE*2,
SHADOWMAP_YSIZE = YSIZE*2,
SPLATALPHA_RAW_XSIZE = XSIZE*2+2,
SPLATALPHA_RAW_YSIZE = YSIZE*2+2,
SPLATALPHA_ZCOUNT = 7,
HEIGHT_TILE_XRATIO = TILEMAP_XSIZE / XSIZE,
HEIGHT_TILE_YRATIO = TILEMAP_XSIZE / XSIZE,
PATCH_XSIZE = TERRAIN_PATCHSIZE,
PATCH_YSIZE = TERRAIN_PATCHSIZE,
PATCH_TILE_XSIZE = PATCH_XSIZE * HEIGHT_TILE_XRATIO,
PATCH_TILE_YSIZE = PATCH_YSIZE * HEIGHT_TILE_YRATIO,
PATCH_XCOUNT = TERRAIN_PATCHCOUNT,
PATCH_YCOUNT = TERRAIN_PATCHCOUNT,
CELLSCALE = 200,
CELLSCALE_IN_METER = CELLSCALE / 100,
HALF_CELLSCALE = CELLSCALE / 2,
HALF_CELLSCALE_IN_METER = HALF_CELLSCALE / 100,
TERRAIN_XSIZE = XSIZE * CELLSCALE,
TERRAIN_YSIZE = YSIZE * CELLSCALE,
};
enum
{
MAX_ATTRIBUTE_NUM = 8,
MAX_WATER_NUM = 255,
};
enum
{
ATTRIBUTE_BLOCK = (1 << 0),
ATTRIBUTE_WATER = (1 << 1),
ATTRIBUTE_BANPK = (1 << 2),
};
public:
static void SetTextureSet(CTextureSet * pTextureSet);
static CTextureSet * GetTextureSet(); // 무조건 성공해야 함
protected:
static CTextureSet * ms_pTextureSet;
public:
CTerrainImpl();
virtual ~CTerrainImpl();
TTerrainSplatPatch & GetTerrainSplatPatch() {return m_TerrainSplatPatch;}
DWORD GetNumTextures() { return ms_pTextureSet->GetTextureCount(); }
TTerrainTexture & GetTexture(const long & c_rlTextureNum) { return ms_pTextureSet->GetTexture(c_rlTextureNum); }
// int GetHeightTileMapRatio() { return m_iHeightTileRatio; }
bool LoadWaterMap(const char * c_szWaterMapName);
bool LoadWaterMapFile(const char * c_szWaterMapName);
LPDIRECT3DTEXTURE8 GetShadowTexture() { return m_lpShadowTexture; }
DWORD GetShadowMapColor(float fx, float fy);
protected:
void Initialize();
virtual void Clear();
void LoadTextures();
bool LoadHeightMap(const char *c_szFileName);
bool RAW_LoadTileMap(const char * c_szFileName);
bool LoadAttrMap(const char *c_pszFileName);
#ifdef WORLD_EDITOR
public:
#endif
__forceinline WORD GetHeightMapValue(short sx, short sy);
protected:
LPDIRECT3DTEXTURE8 m_lpAlphaTexture[MAXTERRAINTEXTURES];
WORD m_awRawHeightMap[HEIGHTMAP_RAW_YSIZE*HEIGHTMAP_RAW_XSIZE];
BYTE m_abyTileMap[TILEMAP_RAW_YSIZE*TILEMAP_RAW_XSIZE];
BYTE m_abyAttrMap[ATTRMAP_YSIZE*ATTRMAP_XSIZE];
BYTE m_abyWaterMap[WATERMAP_YSIZE*WATERMAP_XSIZE];
CHAR m_acNormalMap[NORMALMAP_YSIZE*NORMALMAP_XSIZE*3];
TGA_HEADER m_HeightMapHeader;
WORD m_wTileMapVersion;
long m_lViewRadius;
float m_fHeightScale;
TTerrainSplatPatch m_TerrainSplatPatch;
//////////////////////////////////////////////////////////////////////////
//Water Map
BYTE m_byNumWater;
long m_lWaterHeight[MAX_WATER_NUM + 1];
//Water Map
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// TileMap과 HeightMap 비율
// int m_iHeightTileRatio;
//////////////////////////////////////////////////////////////////////////
// Shadow Map
LPDIRECT3DTEXTURE8 m_lpShadowTexture;
WORD m_awShadowMap[SHADOWMAP_YSIZE*SHADOWMAP_XSIZE]; // 16bit R5 G6 B5
protected:
long m_lSplatTilesX;
long m_lSplatTilesY;
};
__forceinline WORD CTerrainImpl::GetHeightMapValue(short sx, short sy)
{
return m_awRawHeightMap[(sy+1) * HEIGHTMAP_RAW_XSIZE + sx+1];
}
#endif // !defined(AFX_TERRAIN_H__1C9108E1_69A7_4392_9B68_0E6CD4E1BFBA__INCLUDED_)
@@ -0,0 +1,95 @@
#ifndef __TERRAIn_TYPES__
#define __TERRAIn_TYPES__
#include "../EterLib/GrpVertexBuffer.h"
#include "../EterLib/GrpIndexBuffer.h"
#define TERRAIN_PATCHSIZE 16
#define TERRAIN_SIZE 128
#define TERRAIN_PATCHCOUNT TERRAIN_SIZE/TERRAIN_PATCHSIZE
#define MAXTERRAINTEXTURES 256
typedef struct
{
long Active;
long NeedsUpdate;
LPDIRECT3DTEXTURE8 pd3dTexture;
} TTerainSplat;
typedef struct
{
DWORD TileCount[MAXTERRAINTEXTURES];
DWORD PatchTileCount[TERRAIN_PATCHCOUNT*TERRAIN_PATCHCOUNT][MAXTERRAINTEXTURES];
TTerainSplat Splats[MAXTERRAINTEXTURES];
bool m_bNeedsUpdate;
} TTerrainSplatPatch;
typedef struct
{
char used;
short mat;
CGraphicVertexBuffer vb;
CGraphicIndexBuffer ib;
long VertexSize;
short NumIndices;
float minx, maxx;
float miny, maxy;
float minz, maxz;
} TERRAIN_VBUFFER;
typedef struct
{
char name[19];
float ambi_r, ambi_g, ambi_b, ambi_a; /* Ambient Color */
float diff_r, diff_g, diff_b, diff_a; /* Diffuse Color */
float spec_r, spec_g, spec_b, spec_a; /* Specular Color */
float spec_power; /* Specular power */
} PR_MATERIAL;
typedef struct
{
/* Public Settings */
float PageUVLength;
long SquaresPerTexture; /* Heightfield squares per texture (128 texels) */
long SplatTilesX; /* Number of splat textures across map */
long SplatTilesY; /* Number of splat textures down map */
long DisableWrapping;
long DisableShadow;
long ShadowMode;
long OutsideVisible;
D3DXVECTOR3 SunLocation;
} TTerrainGlobals;
/* Converts a floating point number to an integer by truncation, using
the FISTP instruction */
#define PR_FLOAT_TO_INTASM __asm \
{ \
__asm fld PR_FCNV \
__asm fistp PR_ICNV \
}
#define PR_FLOAT_TO_FIXED(inreal, outint) \
{ \
PR_FCNV = (inreal) * 65536.0f; \
PR_FLOAT_TO_INTASM; \
(outint) = PR_ICNV; \
}
#define PR_FLOAT_TO_INT(inreal, outint) \
{ \
PR_FCNV = (inreal); \
PR_FLOAT_TO_INTASM; \
(outint) = PR_ICNV > PR_FCNV ? PR_ICNV - 1 : PR_ICNV; \
}
#define PR_FLOAT_ADD_TO_INT(inreal, outint) \
{ \
PR_FCNV = (inreal); \
PR_FLOAT_TO_INTASM; \
(outint) += PR_ICNV; \
}
#endif //__TERRAIn_TYPES__
@@ -0,0 +1,90 @@
#ifndef __INC_TERRAINLIB_TEXTURESET_H__
#define __INC_TERRAINLIB_TEXTURESET_H__
#include "../EterLib/GrpImageInstance.h"
typedef struct STerrainTexture
{
STerrainTexture() : pd3dTexture(NULL),
UScale(4.0f),
VScale(4.0f),
UOffset(0.0f),
VOffset(0.0f),
bSplat(true),
Begin(0),
End(0)
{
}
~STerrainTexture()
{
}
std::string stFilename;
LPDIRECT3DTEXTURE8 pd3dTexture;
CGraphicImageInstance ImageInstance;
float UScale;
float VScale;
float UOffset;
float VOffset;
bool bSplat;
unsigned short Begin, End; // 0 ~ 65535 의 16bit heightfield 높이값.
D3DXMATRIX m_matTransform;
} TTerrainTexture;
class CTextureSet
{
public:
typedef std::vector<TTerrainTexture> TTextureVector;
CTextureSet();
virtual ~CTextureSet();
void Initialize();
void Clear();
void Create();
bool Load(const char * c_pszFileName, float fTerrainTexCoordBase);
bool Save(const char * c_pszFileName);
unsigned long GetTextureCount();
TTerrainTexture & GetTexture(unsigned long ulIndex);
bool RemoveTexture(unsigned long ulIndex);
bool SetTexture(unsigned long ulIndex,
const char * c_szFileName,
float fuScale,
float fvScale,
float fuOffset,
float fvOffset,
bool bSplat,
unsigned short usBegin,
unsigned short usEnd,
float fTerrainTexCoordBase);
void Reload(float fTerrainTexCoordBase);
bool AddTexture(const char * c_szFileName,
float fuScale,
float fvScale,
float fuOffset,
float fvOffset,
bool bSplat,
unsigned short usBegin,
unsigned short usEnd,
float fTerrainTexCoordBase);
const char * GetFileName() { return m_stFileName.c_str(); }
protected:
void AddEmptyTexture();
protected:
TTextureVector m_Textures;
TTerrainTexture m_ErrorTexture;
std::string m_stFileName;
};
#endif