Compare commits
6
Commits
f9cd63713f
...
8ec8f1a445
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ec8f1a445 | ||
|
|
3aa4c482e9 | ||
|
|
f9be09d2c2 | ||
|
|
5c8d583b31 | ||
|
|
78d14776b8 | ||
|
|
58a3d01027 |
@@ -640,3 +640,5 @@
|
||||
{"date": "2026-09-30", "unit": "EterLib/GrpDevice.cpp", "action": "port", "evidence": "verbatim except Create (recording device in place of Direct3DCreate8/detector/CreateDevice, EL3D_ConfirmDevice on its caps); RecordingDevice decodes declaration-only vertex shaders to stream-0 FVFs; GrpScreen Show uses the GrpDevice browser globals; port.app_loop (PT/PNT/PNT2 FVFs, max texture 4096), full ctest, live-client screenshot matches"}
|
||||
{"date": "2026-09-30", "unit": "EterLib/GrpDetector.cpp", "action": "port", "evidence": "verbatim; IDirect3D8 shim completed (adapter count/caps/format checks/CreateDevice) and implemented once as the host adapter behind Direct3DCreate8 (RecordingDevice.cpp), which CPythonGraphic::GetD3D also returns; GrpDevice::Create now verbatim but for the D3DX debug meshes; port.app_loop (800x600x32 HWVP D16 mode, ms_lpd3d, GetString), full ctest, live-client screenshot matches"}
|
||||
{"date": "2026-09-30", "unit": "UserInterface/UserInterface.cpp", "action": "port", "evidence": "ApplicationSetErrorString/ApplicationStringTable_Initialize verbatim + port.app_loop; Main ADAPTED to PythonBoot; Win32 entry/launcher options N_A"}
|
||||
{"date": "2026-09-30", "unit": "ScriptLib/PythonUtils.cpp", "action": "port", "evidence": "already verbatim (udiff: MSVC cast + perf counters); mapped"}
|
||||
{"date": "2026-09-30", "unit": "ScriptLib/Resource.cpp", "action": "port", "evidence": "verbatim 40250 (was a rewrite that also registered .png); ctest 29/29, screenshot unchanged"}
|
||||
|
||||
@@ -684,6 +684,14 @@
|
||||
"tests": [
|
||||
"project/app_flow_lifecycle_test.gd"
|
||||
]
|
||||
},
|
||||
{
|
||||
"reference": "CPythonApplication::Process on the 60 Hz s_uiNextFrameTime update clock; a late frame skips only the render (s_bFrameSkip), so CPythonNetworkStream::Process runs every 16/17 ms",
|
||||
"implementation": "src/platform/UserInterface/PythonApplication.cpp CPythonApplication::Process: one host frame polls the stream once per elapsed 60 Hz tick (catch-up capped at 500 ms)",
|
||||
"invariant": "GamePhase packet budget (3 packets a poll below 8 KB pending) must be 180/s regardless of render rate; at 30 fps idle it was 90/s and mob move packets queued behind character add/del bursts",
|
||||
"tests": [
|
||||
"real server 192.168.21.203 chase probe A/B 2026-09-30: GC_MOVE push gap p50 138-178 -> 70-92 ms, p90 580-785 -> 358-403 ms"
|
||||
]
|
||||
}
|
||||
],
|
||||
"evidence": {
|
||||
|
||||
@@ -5,61 +5,122 @@
|
||||
"contracts": [],
|
||||
"functions": {
|
||||
"Py_BadArgument": {
|
||||
"status": "TODO"
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/ScriptLib/PythonUtils.cpp:Py_BadArgument"
|
||||
]
|
||||
},
|
||||
"Py_BuildException": {
|
||||
"status": "TODO"
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/ScriptLib/PythonUtils.cpp:Py_BuildException"
|
||||
]
|
||||
},
|
||||
"Py_BuildNone": {
|
||||
"status": "TODO"
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/ScriptLib/PythonUtils.cpp:Py_BuildNone"
|
||||
]
|
||||
},
|
||||
"Py_ReleaseNone": {
|
||||
"status": "TODO"
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/ScriptLib/PythonUtils.cpp:Py_ReleaseNone"
|
||||
]
|
||||
},
|
||||
"PyTuple_GetObject": {
|
||||
"status": "TODO"
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/ScriptLib/PythonUtils.cpp:PyTuple_GetObject"
|
||||
]
|
||||
},
|
||||
"PyTuple_GetLong": {
|
||||
"status": "TODO"
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/ScriptLib/PythonUtils.cpp:PyTuple_GetLong"
|
||||
]
|
||||
},
|
||||
"PyTuple_GetDouble": {
|
||||
"status": "TODO"
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/ScriptLib/PythonUtils.cpp:PyTuple_GetDouble"
|
||||
]
|
||||
},
|
||||
"PyTuple_GetFloat": {
|
||||
"status": "TODO"
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/ScriptLib/PythonUtils.cpp:PyTuple_GetFloat"
|
||||
]
|
||||
},
|
||||
"PyTuple_GetByte": {
|
||||
"status": "TODO"
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/ScriptLib/PythonUtils.cpp:PyTuple_GetByte"
|
||||
],
|
||||
"note": "verbatim except `unsigned char(val)` (MSVC-only cast) written as `(unsigned char) val`."
|
||||
},
|
||||
"PyTuple_GetInteger": {
|
||||
"status": "TODO"
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/ScriptLib/PythonUtils.cpp:PyTuple_GetInteger"
|
||||
]
|
||||
},
|
||||
"PyTuple_GetUnsignedLong": {
|
||||
"status": "TODO"
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/ScriptLib/PythonUtils.cpp:PyTuple_GetUnsignedLong"
|
||||
]
|
||||
},
|
||||
"PyTuple_GetUnsignedInteger": {
|
||||
"status": "TODO"
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/ScriptLib/PythonUtils.cpp:PyTuple_GetUnsignedInteger"
|
||||
]
|
||||
},
|
||||
"PyTuple_GetString": {
|
||||
"status": "TODO"
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/ScriptLib/PythonUtils.cpp:PyTuple_GetString"
|
||||
]
|
||||
},
|
||||
"PyTuple_GetBoolean": {
|
||||
"status": "TODO"
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/ScriptLib/PythonUtils.cpp:PyTuple_GetBoolean"
|
||||
]
|
||||
},
|
||||
"PyCallClassMemberFunc": {
|
||||
"status": "TODO"
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/ScriptLib/PythonUtils.cpp:PyCallClassMemberFunc"
|
||||
]
|
||||
},
|
||||
"PyCallClassMemberFunc_ByPyString": {
|
||||
"status": "TODO"
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/ScriptLib/PythonUtils.cpp:PyCallClassMemberFunc_ByPyString"
|
||||
]
|
||||
},
|
||||
"__PyCallClassMemberFunc_ByCString": {
|
||||
"status": "TODO"
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/ScriptLib/PythonUtils.cpp:__PyCallClassMemberFunc_ByCString"
|
||||
],
|
||||
"note": "verbatim plus the MtPerf::CPythonScope / CountPythonMissing perf counters (no behaviour change)."
|
||||
},
|
||||
"__PyCallClassMemberFunc_ByPyString": {
|
||||
"status": "TODO"
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/ScriptLib/PythonUtils.cpp:__PyCallClassMemberFunc_ByPyString"
|
||||
],
|
||||
"note": "verbatim plus the MtPerf::CPythonScope / CountPythonMissing perf counters (no behaviour change)."
|
||||
},
|
||||
"__PyCallClassMemberFunc": {
|
||||
"status": "TODO"
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/ScriptLib/PythonUtils.cpp:__PyCallClassMemberFunc"
|
||||
],
|
||||
"note": "verbatim plus the MtPerf::CPythonScope / CountPythonMissing perf counters (no behaviour change)."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"reference": "ScriptLib/Resource.cpp",
|
||||
"reference_sha256": "559339874da495b2e5fbeb78256a6ea9dfde2ea11f838d55c4f01b918a052c7f",
|
||||
"priority": "P4",
|
||||
"contracts": [],
|
||||
"functions": {
|
||||
"NewImage": {
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/platform/ScriptLib/Resource.cpp:NewImage"
|
||||
]
|
||||
},
|
||||
"NewSubImage": {
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/platform/ScriptLib/Resource.cpp:NewSubImage"
|
||||
]
|
||||
},
|
||||
"NewText": {
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/platform/ScriptLib/Resource.cpp:NewText"
|
||||
]
|
||||
},
|
||||
"NewThing": {
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/platform/ScriptLib/Resource.cpp:NewThing"
|
||||
]
|
||||
},
|
||||
"NewEffectMesh": {
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/platform/ScriptLib/Resource.cpp:NewEffectMesh"
|
||||
]
|
||||
},
|
||||
"NewAttributeData": {
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/platform/ScriptLib/Resource.cpp:NewAttributeData"
|
||||
]
|
||||
},
|
||||
"CPythonResource::DumpFileList": {
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/platform/ScriptLib/Resource.cpp:CPythonResource::DumpFileList"
|
||||
]
|
||||
},
|
||||
"CPythonResource::Destroy": {
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/platform/ScriptLib/Resource.cpp:CPythonResource::Destroy"
|
||||
],
|
||||
"note": "verbatim; like 40250 only CPythonApplication::Destroy calls it, which is DIVERGENT (host tears down via PythonBoot::Stop resets), so it does not run at shutdown yet."
|
||||
},
|
||||
"CPythonResource::CPythonResource": {
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/platform/ScriptLib/Resource.cpp:CPythonResource::CPythonResource"
|
||||
]
|
||||
},
|
||||
"CPythonResource::~CPythonResource": {
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/platform/ScriptLib/Resource.cpp:CPythonResource::~CPythonResource"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"reference": "UserInterface/PythonNetworkDatagramModule.cpp",
|
||||
"reference_sha256": "fc49120f237cee410aeb9d8d18dcda0eeeb8a244f541af878b8ebaf08858e9de",
|
||||
"priority": "P4",
|
||||
"contracts": [],
|
||||
"functions": {
|
||||
"initudp": {
|
||||
"status": "TODO"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"reference": "UserInterface/PythonProfilerModule.cpp",
|
||||
"reference_sha256": "6afa0c492e2ad88eea775c55ff3f6bd9c490abe91408772dae461e40a207b96c",
|
||||
"priority": "P4",
|
||||
"contracts": [],
|
||||
"functions": {
|
||||
"profilerPush": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"profilerPop": {
|
||||
"status": "TODO"
|
||||
},
|
||||
"initProfiler": {
|
||||
"status": "TODO"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -588,7 +588,7 @@ public:
|
||||
private:
|
||||
bool gameplay_controls_visible() const {
|
||||
#ifdef MT_NATIVE_HAS_LIVE_CLIENT
|
||||
return !PythonBoot::CurrentMapName().empty();
|
||||
return PythonBoot::InGamePhase() && !PythonBoot::CurrentMapName().empty();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
||||
@@ -277,6 +277,11 @@ std::string CurrentMapName()
|
||||
return CPythonBackground::Instance().GetWarpMapName();
|
||||
}
|
||||
|
||||
bool InGamePhase()
|
||||
{
|
||||
return g_network_stream && g_network_stream->PORT_IsGamePhase();
|
||||
}
|
||||
|
||||
bool IsRunning()
|
||||
{
|
||||
return g_launcher != nullptr;
|
||||
@@ -612,7 +617,16 @@ bool IsPointInsideFocusedWindow(int x, int y)
|
||||
{
|
||||
if (!g_window_manager) return false;
|
||||
UI::CWindow* pWin = g_window_manager->GetActivateWindow();
|
||||
return pWin && pWin->IsShow() && pWin->IsIn(x - g_window_manager->GetScreenOffsetX(), y);
|
||||
if (!pWin || !pWin->IsRendering())
|
||||
return false;
|
||||
// The focus can outlive the EditLine's use: UnlockWindow after an NPC dialog and DeactivateWindow
|
||||
// hand it back to a chat line whose board is hidden (capture on again), and the full-screen
|
||||
// GameWindow can hold it. Only a tap that picks the focused window itself (or its child) is one on it.
|
||||
for (UI::CWindow* pPicked = g_window_manager->PickWindow(x - g_window_manager->GetScreenOffsetX(), y);
|
||||
pPicked; pPicked = pPicked->GetParent())
|
||||
if (pPicked == pWin)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsPointInsideActiveUI(int x, int y)
|
||||
|
||||
@@ -46,6 +46,8 @@ int ScriptThreadId();
|
||||
bool AppFrame();
|
||||
// Native CPythonBackground map selection, in the local coordinate frame of RenderGame.
|
||||
std::string CurrentMapName();
|
||||
// CPythonNetworkStream is in the game phase (SetGamePhase opened game.GameWindow); false while loading.
|
||||
bool InGamePhase();
|
||||
|
||||
// Used by the platform CPythonApplication: Loop() calls AppLoopWait() before each Process() and stops
|
||||
// when it returns false; Exit()/Abort() call AppRequestQuit() (40250: PostQuitMessage).
|
||||
@@ -101,7 +103,7 @@ void SetTouchInput(bool touch);
|
||||
bool TouchInput();
|
||||
// An EditLine has focus (40250 ui.EditLine.OnSetFocus -> ime.EnableCaptureInput).
|
||||
bool TextInputFocused();
|
||||
// (x, y) hits the focused window, i.e. the tap landed on the focused EditLine.
|
||||
// (x, y) picks the focused window, shown with all its parents: the tap landed on the focused EditLine.
|
||||
bool IsPointInsideFocusedWindow(int x, int y);
|
||||
|
||||
struct PlayerStatusInfo {
|
||||
|
||||
@@ -1,31 +1,106 @@
|
||||
// 40250 ScriptLib/Resource.cpp, verbatim.
|
||||
#include "ScriptLib/StdAfx.h"
|
||||
#include "ScriptLib/Resource.h"
|
||||
#include "EterLib/GrpImage.h"
|
||||
#include "EterLib/GrpExpandedImageInstance.h"
|
||||
#include "EterLib/GrpTextInstance.h"
|
||||
#include "EterLib/GrpMarkInstance.h"
|
||||
#include "EterLib/GrpSubImage.h"
|
||||
#include "EterLib/GrpText.h"
|
||||
#include "EterLib/AttributeData.h"
|
||||
#include "EterGrnLib/Thing.h"
|
||||
#include "EterGrnLib/ThingInstance.h"
|
||||
#include "EffectLib/EffectMesh.h"
|
||||
#include "EffectLib/EffectInstance.h"
|
||||
#include "GameLib/WeaponTrace.h"
|
||||
#include "GameLib/MapType.h"
|
||||
#include "GameLib/GameType.h"
|
||||
#include "GameLib/RaceData.h"
|
||||
#include "GameLib/RaceMotionData.h"
|
||||
#include "GameLib/ActorInstance.h"
|
||||
#include "GameLib/Area.h"
|
||||
#include "GameLib/ItemData.h"
|
||||
#include "GameLib/FlyingData.h"
|
||||
#include "GameLib/FlyTrace.h"
|
||||
#include "GameLib/FlyingInstance.h"
|
||||
#include "GameLib/FlyingData.h"
|
||||
|
||||
namespace {
|
||||
CResource* NewUIImage(const char* name) { return new CGraphicImage(name); }
|
||||
CResource* NewUISubImage(const char* name) { return new CGraphicSubImage(name); }
|
||||
// 40250 UserInterface/PythonApplication.cpp NewText: a "<face>:<size>[i].fnt" name is a CGraphicText.
|
||||
CResource* NewText(const char* name) { return new CGraphicText(name); }
|
||||
CResource* NewThing(const char* name) { return new CGraphicThing(name); }
|
||||
CResource* NewEffectMesh(const char* name) { return new CEffectMesh(name); }
|
||||
CResource* NewAttributeData(const char* name) { return new CAttributeData(name); }
|
||||
#include "ScriptLib/Resource.h"
|
||||
|
||||
CResource * NewImage(const char* c_szFileName)
|
||||
{
|
||||
return new CGraphicImage(c_szFileName);
|
||||
}
|
||||
|
||||
CPythonResource::CPythonResource() {
|
||||
for (const char* ext : {"tga", "dds", "png", "jpg", "bmp"})
|
||||
m_resManager.RegisterResourceNewFunctionPointer(ext, NewUIImage);
|
||||
m_resManager.RegisterResourceNewFunctionPointer("sub", NewUISubImage);
|
||||
m_resManager.RegisterResourceNewFunctionPointer("fnt", NewText);
|
||||
m_resManager.RegisterResourceNewFunctionPointer("gr2", NewThing);
|
||||
m_resManager.RegisterResourceNewFunctionPointer("mde", NewEffectMesh);
|
||||
m_resManager.RegisterResourceNewFunctionPointer("mdatr", NewAttributeData);
|
||||
CResource * NewSubImage(const char* c_szFileName)
|
||||
{
|
||||
return new CGraphicSubImage(c_szFileName);
|
||||
}
|
||||
|
||||
CResource * NewText(const char* c_szFileName)
|
||||
{
|
||||
return new CGraphicText(c_szFileName);
|
||||
}
|
||||
|
||||
CResource * NewThing(const char* c_szFileName)
|
||||
{
|
||||
return new CGraphicThing(c_szFileName);
|
||||
}
|
||||
|
||||
CResource * NewEffectMesh(const char* c_szFileName)
|
||||
{
|
||||
return new CEffectMesh(c_szFileName);
|
||||
}
|
||||
|
||||
CResource * NewAttributeData(const char* c_szFileName)
|
||||
{
|
||||
return new CAttributeData(c_szFileName);
|
||||
}
|
||||
|
||||
void CPythonResource::DumpFileList(const char * c_szFileName)
|
||||
{
|
||||
m_resManager.DumpFileListToTextFile(c_szFileName);
|
||||
}
|
||||
|
||||
void CPythonResource::Destroy()
|
||||
{
|
||||
CFlyingInstance::DestroySystem();
|
||||
CActorInstance::DestroySystem();
|
||||
CArea::DestroySystem();
|
||||
CGraphicExpandedImageInstance::DestroySystem();
|
||||
CGraphicImageInstance::DestroySystem();
|
||||
CGraphicMarkInstance::DestroySystem();
|
||||
CGraphicThingInstance::DestroySystem();
|
||||
CGrannyModelInstance::DestroySystem();
|
||||
CGraphicTextInstance::DestroySystem();
|
||||
CEffectInstance::DestroySystem();
|
||||
CWeaponTrace::DestroySystem();
|
||||
CFlyTrace::DestroySystem();
|
||||
|
||||
m_resManager.DestroyDeletingList();
|
||||
|
||||
CFlyingData::DestroySystem();
|
||||
CItemData::DestroySystem();
|
||||
CEffectData::DestroySystem();
|
||||
CEffectMesh::SEffectMeshData::DestroySystem();
|
||||
CRaceData::DestroySystem();
|
||||
NRaceData::DestroySystem();
|
||||
CRaceMotionData::DestroySystem();
|
||||
|
||||
m_resManager.Destroy();
|
||||
}
|
||||
|
||||
CPythonResource::CPythonResource()
|
||||
{
|
||||
m_resManager.RegisterResourceNewFunctionPointer("sub", NewSubImage);
|
||||
m_resManager.RegisterResourceNewFunctionPointer("dds", NewImage);
|
||||
m_resManager.RegisterResourceNewFunctionPointer("jpg", NewImage);
|
||||
m_resManager.RegisterResourceNewFunctionPointer("tga", NewImage);
|
||||
m_resManager.RegisterResourceNewFunctionPointer("bmp", NewImage);
|
||||
m_resManager.RegisterResourceNewFunctionPointer("fnt", NewText);
|
||||
m_resManager.RegisterResourceNewFunctionPointer("gr2", NewThing);
|
||||
m_resManager.RegisterResourceNewFunctionPointer("mde", NewEffectMesh);
|
||||
m_resManager.RegisterResourceNewFunctionPointer("mdatr", NewAttributeData);
|
||||
}
|
||||
|
||||
CPythonResource::~CPythonResource()
|
||||
{
|
||||
}
|
||||
CPythonResource::~CPythonResource() { m_resManager.DestroyDeletingList(); }
|
||||
void CPythonResource::Destroy() { m_resManager.DestroyDeletingList(); m_resManager.Destroy(); }
|
||||
void CPythonResource::DumpFileList(const char* name) { m_resManager.DumpFileListToTextFile(name); }
|
||||
|
||||
@@ -330,7 +330,23 @@ bool CPythonApplication::Process()
|
||||
// Network I/O
|
||||
{
|
||||
MtPerf::CScope kPerf(MtPerf::SECTION_NETWORK);
|
||||
CPythonNetworkStream::Instance().Process();
|
||||
// PORT: 40250 runs Process() on its 60 Hz update clock and only skips the render pass when late
|
||||
// (s_bFrameSkip), so the stream is polled every 16 ms whatever the render rate, and GamePhase
|
||||
// handles three packets a poll while less than 8 KB is pending. The host runs one Process() per
|
||||
// rendered frame (30 fps when idle, less on a busy phone), which halves that budget or worse: the
|
||||
// character add/del bursts of a mob field hold the move packets back for up to a second and the
|
||||
// mobs stop, then jump. Poll once per elapsed 60 Hz tick, as 40250 does.
|
||||
{
|
||||
static DWORD s_dwNextNetworkPoll = 0;
|
||||
const DWORD dwNow = ELTimer_GetMSec();
|
||||
if (!s_dwNextNetworkPoll || int(dwNow - s_dwNextNetworkPoll) > 500)
|
||||
s_dwNextNetworkPoll = dwNow;
|
||||
do
|
||||
{
|
||||
CPythonNetworkStream::Instance().Process();
|
||||
s_dwNextNetworkPoll += 16 + (s_dwNextNetworkPoll & 1);
|
||||
} while (int(dwNow - s_dwNextNetworkPoll) >= 0);
|
||||
}
|
||||
// PORT: m_kGuildMarkUploader/m_kGuildMarkDownloader.Process() follow here in 40250; the guild mark
|
||||
// transfer is not ported yet (GuildMarkDownloader.cpp/GuildMarkUploader.cpp).
|
||||
CAccountConnector::Instance().Process();
|
||||
|
||||
@@ -62,6 +62,7 @@ struct HFONT__ : GdiObject
|
||||
int descent = 0;
|
||||
bool italic = false;
|
||||
bool antialiased = false;
|
||||
BYTE charset = ANSI_CHARSET;
|
||||
};
|
||||
|
||||
struct HDC__
|
||||
@@ -293,6 +294,7 @@ HFONT CreateFontIndirect(const LOGFONT* lplf)
|
||||
for (const char* name : kLinked)
|
||||
if (FT_Face linked = open_named(name); linked && linked != face) font->fallbacks.push_back(linked);
|
||||
font->italic = lplf->lfItalic != 0;
|
||||
font->charset = lplf->lfCharSet;
|
||||
font->antialiased = lplf->lfQuality == ANTIALIASED_QUALITY;
|
||||
|
||||
const TT_OS2* os2 = static_cast<const TT_OS2*>(FT_Get_Sfnt_Table(face, FT_SFNT_OS2));
|
||||
@@ -447,24 +449,48 @@ BOOL TextOutW(HDC hdc, int x, int y, LPCWSTR lpString, int c)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// The ANSI GDI calls decode the bytes with the code page of the selected font's charset (CTextBar selects
|
||||
// GetCharsetFromCodePage of the locale, e.g. GB2312_CHARSET for a 936 locale); ANSI/DEFAULT fall back to CP_ACP.
|
||||
static UINT dc_code_page(HDC hdc)
|
||||
{
|
||||
switch (dc_font(hdc)->charset) {
|
||||
case SHIFTJIS_CHARSET: return 932;
|
||||
case HANGUL_CHARSET: return 949;
|
||||
case GB2312_CHARSET: return 936;
|
||||
case CHINESEBIG5_CHARSET: return 950;
|
||||
case GREEK_CHARSET: return 1253;
|
||||
case TURKISH_CHARSET: return 1254;
|
||||
case VIETNAMESE_CHARSET: return 1258;
|
||||
case HEBREW_CHARSET: return 1255;
|
||||
case ARABIC_CHARSET: return 1256;
|
||||
case BALTIC_CHARSET: return 1257;
|
||||
case RUSSIAN_CHARSET: return 1251;
|
||||
case THAI_CHARSET: return 874;
|
||||
case EASTEUROPE_CHARSET: return 1250;
|
||||
default: return CP_ACP;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL TextOutA(HDC hdc, int x, int y, LPCSTR lpString, int c)
|
||||
{
|
||||
const int n = MultiByteToWideChar(CP_ACP, 0, lpString, c, nullptr, 0);
|
||||
const UINT cp = dc_code_page(hdc);
|
||||
const int n = MultiByteToWideChar(cp, 0, lpString, c, nullptr, 0);
|
||||
if (n <= 0) return c == 0;
|
||||
std::vector<WCHAR> wide(static_cast<size_t>(n));
|
||||
MultiByteToWideChar(CP_ACP, 0, lpString, c, wide.data(), n);
|
||||
MultiByteToWideChar(cp, 0, lpString, c, wide.data(), n);
|
||||
return TextOutW(hdc, x, y, wide.data(), n);
|
||||
}
|
||||
|
||||
BOOL GetTextExtentPoint32A(HDC hdc, LPCSTR lpString, int c, LPSIZE psizl)
|
||||
{
|
||||
const int n = MultiByteToWideChar(CP_ACP, 0, lpString, c, nullptr, 0);
|
||||
const UINT cp = dc_code_page(hdc);
|
||||
const int n = MultiByteToWideChar(cp, 0, lpString, c, nullptr, 0);
|
||||
if (n <= 0)
|
||||
{
|
||||
if (c != 0 || !psizl) return FALSE;
|
||||
return GetTextExtentPoint32W(hdc, nullptr, 0, psizl);
|
||||
}
|
||||
std::vector<WCHAR> wide(static_cast<size_t>(n));
|
||||
MultiByteToWideChar(CP_ACP, 0, lpString, c, wide.data(), n);
|
||||
MultiByteToWideChar(cp, 0, lpString, c, wide.data(), n);
|
||||
return GetTextExtentPoint32W(hdc, wide.data(), n, psizl);
|
||||
}
|
||||
|
||||
@@ -118,6 +118,8 @@ class CPythonNetworkStream : public CNetworkStream, public CSingleton<CPythonNet
|
||||
// END_OF_SUPPORT_BGM
|
||||
|
||||
bool IsSelectedEmpire();
|
||||
// PORT: the touch host shows its joystick and skill buttons only in the game phase.
|
||||
bool PORT_IsGamePhase() const { return m_strPhase == "Game"; }
|
||||
|
||||
void ToggleGameDebugInfo();
|
||||
|
||||
|
||||
@@ -306,6 +306,7 @@ int main(int argc, char** argv)
|
||||
py_true("isinstance(_stream.curPhaseWindow, introSelect.SelectCharacterWindow)"));
|
||||
});
|
||||
CHECK(selecting && !failed());
|
||||
CHECK(!PythonBoot::InGamePhase());
|
||||
if (!selecting)
|
||||
{
|
||||
// The login window reports failures in its popup (LOGIN_FAILURE, connect errors).
|
||||
@@ -392,6 +393,9 @@ int main(int argc, char** argv)
|
||||
});
|
||||
CHECK(loading && !failed());
|
||||
CHECK(py_true(loaded));
|
||||
// The loading window already warped the map; the touch host's joystick and skill buttons wait for
|
||||
// the game phase.
|
||||
CHECK(!PythonBoot::InGamePhase() && !PythonBoot::CurrentMapName().empty());
|
||||
|
||||
// 6. introLoading's update steps end in net.StartGame(); the next CPythonNetworkStream::Process calls
|
||||
// networkModule's SetGamePhase, which builds game.GameWindow (interfaceModule.MakeInterface) and
|
||||
@@ -402,6 +406,8 @@ int main(int argc, char** argv)
|
||||
return failed() || (py_true(gaming) && (!server || server->Has("game2:entergame")));
|
||||
});
|
||||
CHECK(entered && !failed());
|
||||
// CG_ENTERGAME's PHASE_GAME answer switches the stream to "Game" a round trip after the window opens.
|
||||
CHECK(pump_until(5, [] { return PythonBoot::InGamePhase(); }) && !PythonBoot::CurrentMapName().empty());
|
||||
|
||||
// 7. (批次 2V2-b) The server answers CG_ENTERGAME with the character's own insert packets and
|
||||
// PHASE_GAME, then the Entergame burst (PVP/land list, time, channel, greet chat, ...). GamePhase
|
||||
@@ -683,6 +689,27 @@ int main(int argc, char** argv)
|
||||
CHECK(pump_until(2, [&] { return server->Has("game2:chat 0 hello"); }));
|
||||
// uichat.__SendTalkingChatPacket only resets the line; a Return on the empty line closes it (eventReturn).
|
||||
CHECK(py_true("_stream.curPhaseWindow.interface.IsOpenChat() and __import__('ime').GetText(0) == ''"));
|
||||
// Touch hosts raise the system keyboard only for a tap on the focused, visible EditLine. A chat line
|
||||
// that keeps the focus under a hidden board (interfacemodule.__HideWindows for an NPC dialog, then the
|
||||
// focus handed back by UnlockWindow/DeactivateWindow) must not, wherever the tap lands.
|
||||
{
|
||||
std::string xywh;
|
||||
CHECK(py("_line = _stream.curPhaseWindow.interface.wndChat.chatInputSet.chatLine"));
|
||||
CHECK(PythonBoot::Evaluate("'%d %d %d %d' % (_line.GetGlobalPosition() + (_line.GetWidth(), _line.GetHeight()))",
|
||||
&xywh, nullptr));
|
||||
int x = 0, y = 0, w = 0, h = 0;
|
||||
std::sscanf(xywh.c_str(), "%d %d %d %d", &x, &y, &w, &h);
|
||||
const int cx = x + w / 2, cy = y + h / 2;
|
||||
CHECK(w > 0 && h > 0);
|
||||
CHECK(PythonBoot::TextInputFocused());
|
||||
CHECK(PythonBoot::IsPointInsideFocusedWindow(cx, cy));
|
||||
CHECK(!PythonBoot::IsPointInsideFocusedWindow(790, 10));
|
||||
CHECK(py("_stream.curPhaseWindow.interface.wndChat.Hide()"));
|
||||
CHECK(PythonBoot::TextInputFocused());
|
||||
CHECK(!PythonBoot::IsPointInsideFocusedWindow(cx, cy));
|
||||
CHECK(py("_stream.curPhaseWindow.interface.wndChat.Show()"));
|
||||
CHECK(PythonBoot::IsPointInsideFocusedWindow(cx, cy));
|
||||
}
|
||||
PythonBoot::UIChar(VK_RETURN);
|
||||
CHECK(pump_until(1, [] { return py_true("not _stream.curPhaseWindow.interface.IsOpenChat()"); }));
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cwchar>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -60,6 +62,39 @@ static int opaque_pixels(const std::string& name, std::uint32_t* sample)
|
||||
return count;
|
||||
}
|
||||
|
||||
// Renders text into a 64 x 20 DIB with a 12 px font of the given charset (A or W call); returns the bits.
|
||||
static std::vector<std::uint32_t> gdi_text(BYTE charset, const char* ansi, const wchar_t* wide)
|
||||
{
|
||||
BITMAPINFO info = {};
|
||||
info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
info.bmiHeader.biWidth = 64;
|
||||
info.bmiHeader.biHeight = -20;
|
||||
info.bmiHeader.biPlanes = 1;
|
||||
info.bmiHeader.biBitCount = 32;
|
||||
void* bits = NULL;
|
||||
HDC dc = CreateCompatibleDC(NULL);
|
||||
HBITMAP bmp = CreateDIBSection(dc, &info, DIB_RGB_COLORS, &bits, NULL, 0);
|
||||
SelectObject(dc, bmp);
|
||||
LOGFONT lf = {};
|
||||
lf.lfHeight = 12;
|
||||
lf.lfCharSet = charset;
|
||||
lf.lfQuality = ANTIALIASED_QUALITY;
|
||||
std::strcpy(lf.lfFaceName, "Arial");
|
||||
HFONT font = CreateFontIndirect(&lf);
|
||||
SelectObject(dc, font);
|
||||
SetBkMode(dc, TRANSPARENT);
|
||||
SetTextColor(dc, RGB(255, 255, 255));
|
||||
if (ansi)
|
||||
TextOutA(dc, 0, 0, ansi, int(std::strlen(ansi)));
|
||||
else
|
||||
TextOutW(dc, 0, 0, wide, int(std::wcslen(wide)));
|
||||
std::vector<std::uint32_t> out(static_cast<std::uint32_t*>(bits), static_cast<std::uint32_t*>(bits) + 64 * 20);
|
||||
DeleteObject(font);
|
||||
DeleteDC(dc);
|
||||
DeleteObject(bmp);
|
||||
return out;
|
||||
}
|
||||
|
||||
static bool near(float a, float b)
|
||||
{
|
||||
return std::fabs(a - b) < 1e-3f;
|
||||
@@ -162,6 +197,28 @@ int main()
|
||||
CHECK(images().size() == 1); // 64 x 64 fits in one block (count 0, rest 64)
|
||||
}
|
||||
|
||||
{
|
||||
// GDI's ANSI calls decode with the selected font's charset (CTextBar: GetCharsetFromCodePage of the
|
||||
// locale), so a 936 server notice in GBK draws as the CJK text, not as its bytes read as CP 1252.
|
||||
const char gbk[] = "\xB9\xAB\xB8\xE6"; // "公告"
|
||||
const std::vector<std::uint32_t> wide = gdi_text(GB2312_CHARSET, NULL, L"\u516C\u544A");
|
||||
int lit = 0;
|
||||
for (std::uint32_t px : wide)
|
||||
lit += px != 0;
|
||||
CHECK(lit > 20);
|
||||
CHECK(gdi_text(GB2312_CHARSET, gbk, NULL) == wide);
|
||||
CHECK(gdi_text(ANSI_CHARSET, gbk, NULL) != wide);
|
||||
SIZE size = {};
|
||||
SetDefaultCodePage(936);
|
||||
CTextBar bar(12, false);
|
||||
CHECK(bar.Create(NULL, 64, 20));
|
||||
bar.GetTextExtent(gbk, &size);
|
||||
SIZE one = {};
|
||||
bar.GetTextExtent("\xB9\xAB", &one);
|
||||
CHECK(one.cx > 0 && size.cx == 2 * one.cx); // two full-width glyphs, not four Latin-1 ones
|
||||
SetDefaultCodePage(1252);
|
||||
}
|
||||
|
||||
DeviceAccess::Set(NULL);
|
||||
device->Release();
|
||||
if (!g_failures)
|
||||
|
||||
@@ -11,12 +11,13 @@
|
||||
# Patches, in order (each is a patch -p1 against /usr/metin2/src, saved byte-exact):
|
||||
# inventory-5-pages 5-page inventory; needs its DB migration once (inventory-5-pages/README.md)
|
||||
# hunt-set quest item.set_attribute, free items in extended shops
|
||||
# shop-item-time NPC shop items carry a new item's time sockets (tooltip shows the duration)
|
||||
set -eu
|
||||
|
||||
SRC=${SRC:-/usr/metin2/src}
|
||||
SERVER=${SERVER:-/usr/metin2/server}
|
||||
HERE=$(cd "$(dirname "$0")" && pwd)
|
||||
PATCHES="inventory-5-pages hunt-set"
|
||||
PATCHES="inventory-5-pages hunt-set shop-item-time"
|
||||
TS=$(date +%Y%m%d-%H%M%S)
|
||||
|
||||
patch_state() {
|
||||
@@ -90,7 +91,7 @@ data)
|
||||
start_server
|
||||
;;
|
||||
*)
|
||||
sed -n '2,15p' "$0" >&2
|
||||
sed -n '2,16p' "$0" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# NPC 商店物品显示剩余时间(203 服务端)
|
||||
|
||||
40250 服务端发商店物品列表时,NPC 商店(`shop.cpp` 的 `StartShop`/`UpdateItem`)和扩展多页商店
|
||||
(`shopEx.cpp`,如百店老板娘 9010)把物品的 socket 全部清零。客户端 `uitooltip.py` 用 socket 算剩余时间
|
||||
(UNIQUE 取 `socket[2]` 分钟数,LIMIT_REAL_TIME 取 `socket[0]` 到期时间戳),于是坐骑、百货店的限时物品
|
||||
在商店里都显示「剩余时间 : 0分」,买下后才正常。
|
||||
|
||||
`server.patch` 在 `shop.cpp` 加 `MT_GetNewItemSockets(vnum, alSockets)`:按 `ITEM_MANAGER::CreateItem`
|
||||
给新物品设 socket 的同一套规则(UNIQUE 剩余时间、自动药水、LIMIT_REAL_TIME、LIMIT_TIMER_BASED_ON_WEAR)
|
||||
填商店包里的 socket。玩家个人商店(有实际物品)不变,仍发物品自身的 socket。只影响显示,买到的物品照旧由
|
||||
`CreateItem` 生成。
|
||||
|
||||
在 hunt-set 之后打(`shopEx.cpp` 上下文依赖它)。`sh rebuild.sh build` 自动打补丁并编译。
|
||||
@@ -0,0 +1,96 @@
|
||||
--- a/server/game/src/shop.cpp
|
||||
+++ b/server/game/src/shop.cpp
|
||||
@@ -18,7 +18,55 @@
|
||||
#include "monarch.h"
|
||||
#include "mob_manager.h"
|
||||
#include "locale_service.h"
|
||||
+#include "unique_item.h"
|
||||
+
|
||||
+// MT: the sockets ITEM_MANAGER::CreateItem gives a new item of this vnum (its remaining time), sent
|
||||
+// with an NPC shop's items so the client tooltip shows how long a bought one lasts instead of 0.
|
||||
+void MT_GetNewItemSockets(DWORD dwVnum, long* alSockets)
|
||||
+{
|
||||
+ memset(alSockets, 0, sizeof(long) * ITEM_SOCKET_MAX_NUM);
|
||||
+
|
||||
+ const TItemTable* table = ITEM_MANAGER::instance().GetTable(dwVnum);
|
||||
+ if (!table)
|
||||
+ return;
|
||||
+
|
||||
+ if (table->bType == ITEM_UNIQUE)
|
||||
+ {
|
||||
+ if (table->alValues[2] == 0)
|
||||
+ alSockets[ITEM_SOCKET_UNIQUE_REMAIN_TIME] = table->alValues[0];
|
||||
+ else
|
||||
+ alSockets[ITEM_SOCKET_UNIQUE_REMAIN_TIME] = get_global_time() + table->alValues[0];
|
||||
+ }
|
||||
+
|
||||
+ switch (dwVnum)
|
||||
+ {
|
||||
+ case ITEM_AUTO_HP_RECOVERY_S:
|
||||
+ case ITEM_AUTO_HP_RECOVERY_M:
|
||||
+ case ITEM_AUTO_HP_RECOVERY_L:
|
||||
+ case ITEM_AUTO_HP_RECOVERY_X:
|
||||
+ case ITEM_AUTO_SP_RECOVERY_S:
|
||||
+ case ITEM_AUTO_SP_RECOVERY_M:
|
||||
+ case ITEM_AUTO_SP_RECOVERY_L:
|
||||
+ case ITEM_AUTO_SP_RECOVERY_X:
|
||||
+ case REWARD_BOX_ITEM_AUTO_SP_RECOVERY_XS:
|
||||
+ case REWARD_BOX_ITEM_AUTO_SP_RECOVERY_S:
|
||||
+ case REWARD_BOX_ITEM_AUTO_HP_RECOVERY_XS:
|
||||
+ case REWARD_BOX_ITEM_AUTO_HP_RECOVERY_S:
|
||||
+ case FUCKING_BRAZIL_ITEM_AUTO_SP_RECOVERY_S:
|
||||
+ case FUCKING_BRAZIL_ITEM_AUTO_HP_RECOVERY_S:
|
||||
+ alSockets[2] = table->alValues[0];
|
||||
+ break;
|
||||
+ }
|
||||
|
||||
+ for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
|
||||
+ {
|
||||
+ if (LIMIT_REAL_TIME == table->aLimits[i].bType)
|
||||
+ alSockets[0] = time(0) + (table->aLimits[i].lValue ? table->aLimits[i].lValue : 60*60*24*7);
|
||||
+ else if (LIMIT_TIMER_BASED_ON_WEAR == table->aLimits[i].bType)
|
||||
+ alSockets[0] = table->aLimits[i].lValue ? table->aLimits[i].lValue : 60 * 60 * 10;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
/* ------------------------------------------------------------------------------------ */
|
||||
CShop::CShop()
|
||||
: m_dwVnum(0), m_dwNPCVnum(0), m_pkPC(NULL)
|
||||
@@ -467,6 +515,8 @@
|
||||
thecore_memcpy(pack2.items[i].alSockets, item.pkItem->GetSockets(), sizeof(pack2.items[i].alSockets));
|
||||
thecore_memcpy(pack2.items[i].aAttr, item.pkItem->GetAttributes(), sizeof(pack2.items[i].aAttr));
|
||||
}
|
||||
+ else
|
||||
+ MT_GetNewItemSockets(item.vnum, pack2.items[i].alSockets);
|
||||
}
|
||||
|
||||
pack.size = sizeof(pack) + sizeof(pack2);
|
||||
@@ -537,7 +587,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
- memset(pack2.item.alSockets, 0, sizeof(pack2.item.alSockets));
|
||||
+ MT_GetNewItemSockets(m_itemVector[pos].vnum, pack2.item.alSockets);
|
||||
memset(pack2.item.aAttr, 0, sizeof(pack2.item.aAttr));
|
||||
}
|
||||
}
|
||||
--- a/server/game/src/shopEx.cpp
|
||||
+++ b/server/game/src/shopEx.cpp
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "monarch.h"
|
||||
#include "mob_manager.h"
|
||||
#include "locale_service.h"
|
||||
+
|
||||
+void MT_GetNewItemSockets(DWORD dwVnum, long* alSockets);
|
||||
#include "desc_client.h"
|
||||
#include "shopEx.h"
|
||||
#include "group_text_parse_tree.h"
|
||||
@@ -96,7 +98,7 @@
|
||||
break;
|
||||
}
|
||||
memset(pack_tab.items[i].aAttr, 0, sizeof(pack_tab.items[i].aAttr));
|
||||
- memset(pack_tab.items[i].alSockets, 0, sizeof(pack_tab.items[i].alSockets));
|
||||
+ MT_GetNewItemSockets(shop_tab.items[i].vnum, pack_tab.items[i].alSockets);
|
||||
}
|
||||
|
||||
memcpy(buf, &pack_tab, sizeof(pack_tab));
|
||||
Reference in New Issue
Block a user