port: ItemData, ItemManager, PythonNonPlayer + LoadLocaleData (batch 2 P3-a)

Verbatim 40250 GameLib ItemData/ItemManager and UserInterface
PythonNonPlayer(+Module) replace their pending stand-ins and the
nonplayer module stub. LoadLocaleData's body moves into the platform
CPythonApplication stand-in, so the select phase loads item_proto and
mob_proto; CPythonSkill is still pending, so it returns false after the
tables load. login_flow checks item 19 (Sword+9) and mob 101 (Wild Dog),
offline and live.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-09-24 00:36:10 +09:00
co-authored by Claude Opus 5.5
parent ce9f96398e
commit f0564a7f12
21 changed files with 1960 additions and 250 deletions
@@ -24,7 +24,6 @@
#include "UserInterface/AbstractApplication.h"
#include "UserInterface/PythonMessenger.h"
#include "UserInterface/PythonMiniMap.h"
#include "UserInterface/PythonNonPlayer.h"
#include "EterLib/Profiler.h"
#include "UserInterface/PythonQuest.h"
#include "UserInterface/PythonSafeBox.h"
@@ -393,23 +392,6 @@ void AddStubConstants_miniMap(PyObject* poModule)
PyModule_AddIntConstant(poModule, "TYPE_EMPIRE", CPythonMiniMap::TYPE_EMPIRE);
}
// 40250 UserInterface/PythonNonPlayerModule.cpp
void AddStubConstants_nonplayer(PyObject* poModule)
{
(void) poModule;
PyModule_AddIntConstant(poModule, "ON_CLICK_EVENT_NONE", CPythonNonPlayer::ON_CLICK_EVENT_NONE);
PyModule_AddIntConstant(poModule, "ON_CLICK_EVENT_BATTLE", CPythonNonPlayer::ON_CLICK_EVENT_BATTLE);
PyModule_AddIntConstant(poModule, "ON_CLICK_EVENT_SHOP", CPythonNonPlayer::ON_CLICK_EVENT_SHOP);
PyModule_AddIntConstant(poModule, "ON_CLICK_EVENT_TALK", CPythonNonPlayer::ON_CLICK_EVENT_TALK);
PyModule_AddIntConstant(poModule, "ON_CLICK_EVENT_VEHICLE", CPythonNonPlayer::ON_CLICK_EVENT_VEHICLE);
PyModule_AddIntConstant(poModule, "PAWN", 0);
PyModule_AddIntConstant(poModule, "S_PAWN", 1);
PyModule_AddIntConstant(poModule, "KNIGHT", 2);
PyModule_AddIntConstant(poModule, "S_KNIGHT", 3);
PyModule_AddIntConstant(poModule, "BOSS", 4);
PyModule_AddIntConstant(poModule, "KING", 5);
}
// 40250 UserInterface/PythonProfilerModule.cpp
void AddStubConstants_profiler(PyObject* poModule)
{
@@ -14,7 +14,6 @@ void AddStubConstants_ime(PyObject* poModule);
void AddStubConstants_item(PyObject* poModule);
void AddStubConstants_messenger(PyObject* poModule);
void AddStubConstants_miniMap(PyObject* poModule);
void AddStubConstants_nonplayer(PyObject* poModule);
void AddStubConstants_profiler(PyObject* poModule);
void AddStubConstants_quest(PyObject* poModule);
void AddStubConstants_safebox(PyObject* poModule);
@@ -519,22 +518,6 @@ PyMethodDef methods_miniMap[] = {
{ "GetGuildAreaID", stub_miniMap_GetGuildAreaID, METH_VARARGS },
{ NULL, NULL }
};
// 40250 UserInterface/PythonNonPlayerModule.cpp: nonplayer export names.
PyObject* stub_nonplayer_GetEventType(PyObject*, PyObject*) { return stub_call_named("nonplayer.GetEventType", Py_BuildValue("i", 0)); }
PyObject* stub_nonplayer_GetEventTypeByVID(PyObject*, PyObject*) { return stub_call_named("nonplayer.GetEventTypeByVID", Py_BuildValue("i", 0)); }
PyObject* stub_nonplayer_GetLevelByVID(PyObject*, PyObject*) { return stub_call_named("nonplayer.GetLevelByVID", Py_BuildValue("i", 0)); }
PyObject* stub_nonplayer_GetGradeByVID(PyObject*, PyObject*) { return stub_call_named("nonplayer.GetGradeByVID", Py_BuildValue("i", 0)); }
PyObject* stub_nonplayer_GetMonsterName(PyObject*, PyObject*) { return stub_call_named("nonplayer.GetMonsterName", Py_BuildValue("s", "")); }
PyObject* stub_nonplayer_LoadNonPlayerData(PyObject*, PyObject*) { return stub_call_named("nonplayer.LoadNonPlayerData", Py_BuildNone()); }
PyMethodDef methods_nonplayer[] = {
{ "GetEventType", stub_nonplayer_GetEventType, METH_VARARGS },
{ "GetEventTypeByVID", stub_nonplayer_GetEventTypeByVID, METH_VARARGS },
{ "GetLevelByVID", stub_nonplayer_GetLevelByVID, METH_VARARGS },
{ "GetGradeByVID", stub_nonplayer_GetGradeByVID, METH_VARARGS },
{ "GetMonsterName", stub_nonplayer_GetMonsterName, METH_VARARGS },
{ "LoadNonPlayerData", stub_nonplayer_LoadNonPlayerData, METH_VARARGS },
{ NULL, NULL }
};
// 40250 UserInterface/PythonProfilerModule.cpp: profiler export names.
PyObject* stub_profiler_Push(PyObject*, PyObject*) { return stub_call_named("profiler.Push", Py_BuildNone()); }
PyObject* stub_profiler_Pop(PyObject*, PyObject*) { return stub_call_named("profiler.Pop", Py_BuildNone()); }
@@ -922,11 +905,6 @@ void init_2v0_gameplay_stubs() {
PyModule_AddIntConstant(module, "__port_stub__", 1);
AddStubConstants_miniMap(module);
}
{
PyObject* module = Py_InitModule("nonplayer", methods_nonplayer);
PyModule_AddIntConstant(module, "__port_stub__", 1);
AddStubConstants_nonplayer(module);
}
{
PyObject* module = Py_InitModule("profiler", methods_profiler);
PyModule_AddIntConstant(module, "__port_stub__", 1);
@@ -347,6 +347,7 @@ bool run_main_script_body(const char* lpCmdLine, std::string* error)
initchr();
initchrmgr();
initPlayer();
initNonPlayer();
initChat();
initnet();
initeffect();
@@ -7,6 +7,9 @@
#include "EterLib/ResourceManager.h"
#include "UserInterface/PythonNetworkStream.h"
#include "UserInterface/AccountConnector.h"
#include "UserInterface/PythonSkill.h"
#include "UserInterface/PythonNonPlayer.h"
#include "GameLib/ItemManager.h"
#include "EterLib/NetDevice.h"
#include "../PlatformStub.h"
#include "../EterLib/UIRenderCommands.h"
@@ -311,7 +314,91 @@ BOOL PERF_CHECKER_RENDER_GAME = FALSE;
BOOL SKILL_EFFECT_UPGRADE_ENABLE = FALSE;
double g_specularSpd = 0;
bool LoadLocaleData(const char*) { MT_PLATFORM_STUB(); return false; }
// 40250 UserInterface/PythonApplication.cpp, verbatim. PORT: CPythonSkill is still a stand-in, so
// RegisterSkillDesc fails and the function returns false after the item and mob tables load.
// SUPPORT_NEW_KOREA_SERVER
bool LoadLocaleData(const char* localePath)
{
NANOBEGIN
CPythonNonPlayer& rkNPCMgr = CPythonNonPlayer::Instance();
CItemManager& rkItemMgr = CItemManager::Instance();
CPythonSkill& rkSkillMgr = CPythonSkill::Instance();
CPythonNetworkStream& rkNetStream = CPythonNetworkStream::Instance();
char szItemList[256];
char szItemProto[256];
char szItemDesc[256];
char szMobProto[256];
char szSkillDescFileName[256];
char szSkillTableFileName[256];
char szInsultList[256];
snprintf(szItemList, sizeof(szItemList) , "%s/item_list.txt", localePath);
snprintf(szItemProto, sizeof(szItemProto), "%s/item_proto", localePath);
snprintf(szItemDesc, sizeof(szItemDesc), "%s/itemdesc.txt", localePath);
snprintf(szMobProto, sizeof(szMobProto), "%s/mob_proto", localePath);
snprintf(szSkillDescFileName, sizeof(szSkillDescFileName), "%s/SkillDesc.txt", localePath);
snprintf(szSkillTableFileName, sizeof(szSkillTableFileName), "%s/SkillTable.txt", localePath);
snprintf(szInsultList, sizeof(szInsultList), "%s/insult.txt", localePath);
rkNPCMgr.Destroy();
rkItemMgr.Destroy();
rkSkillMgr.Destroy();
if (!rkItemMgr.LoadItemList(szItemList))
{
TraceError("LoadLocaleData - LoadItemList(%s) Error", szItemList);
}
if (!rkItemMgr.LoadItemTable(szItemProto))
{
TraceError("LoadLocaleData - LoadItemProto(%s) Error", szItemProto);
return false;
}
if (!rkItemMgr.LoadItemDesc(szItemDesc))
{
Tracenf("LoadLocaleData - LoadItemDesc(%s) Error", szItemDesc);
}
if (!rkNPCMgr.LoadNonPlayerData(szMobProto))
{
TraceError("LoadLocaleData - LoadMobProto(%s) Error", szMobProto);
return false;
}
if (!rkSkillMgr.RegisterSkillDesc(szSkillDescFileName))
{
TraceError("LoadLocaleData - RegisterSkillDesc(%s) Error", szMobProto);
return false;
}
if (!rkSkillMgr.RegisterSkillTable(szSkillTableFileName))
{
TraceError("LoadLocaleData - RegisterSkillTable(%s) Error", szMobProto);
return false;
}
if (!rkNetStream.LoadInsultList(szInsultList))
{
Tracenf("CPythonApplication - CPythonNetworkStream::LoadInsultList(%s)", szInsultList);
}
if (LocaleService_IsYMIR())
{
char szEmpireTextConvFile[256];
for (DWORD dwEmpireID=1; dwEmpireID<=3; ++dwEmpireID)
{
sprintf(szEmpireTextConvFile, "%s/lang%d.cvt", localePath, dwEmpireID);
if (!rkNetStream.LoadConvertTable(dwEmpireID, szEmpireTextConvFile))
{
TraceError("LoadLocaleData - CPythonNetworkStream::LoadConvertTable(%d, %s) FAILURE", dwEmpireID, szEmpireTextConvFile);
}
}
}
NANOEND
return true;
}
void TextTail_SetLivingTime(long) { MT_PLATFORM_STUB(); }
namespace {
// The supplied 40250 Client/locale.cfg selects "en" (code page 1252).
@@ -1,133 +0,0 @@
// Stand-in for the 40250 logic unit GameLib/ItemData.cpp, not ported yet: the members the ported units
// reference, as platform_stub.py stubs. Delete this file in the commit that ports the unit into port/
// (docs/PORT-PLAN.md).
#include "GameLib/StdAfx.h"
#include "GameLib/ItemData.h"
#include "../../PlatformStub.h"
auto CItemData::GetName() const -> const char *
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<const char *>();
}
auto CItemData::GetType() const -> BYTE
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<BYTE>();
}
auto CItemData::GetValue(BYTE) const -> long
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<long>();
}
auto CItemData::GetIndex() const -> DWORD
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<DWORD>();
}
auto CItemData::GetSubType() const -> BYTE
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<BYTE>();
}
auto CItemData::GetRefine() const -> UINT
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<UINT>();
}
auto CItemData::GetWeaponType() const -> DWORD
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<DWORD>();
}
auto CItemData::GetSocketCount() const -> int
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<int>();
}
auto CItemData::GetSpecularPowerf() const -> float
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<float>();
}
auto CItemData::GetModelThing() -> CGraphicThing *
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<CGraphicThing *>();
}
auto CItemData::GetSubModelThing() -> CGraphicThing *
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<CGraphicThing *>();
}
auto CItemData::GetLODModelThingCount() -> DWORD
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<DWORD>();
}
auto CItemData::GetLODModelThingPointer(DWORD, CGraphicThing **) -> BOOL
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<BOOL>();
}
auto CItemData::GetAttachingDataCount() -> DWORD
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<DWORD>();
}
auto CItemData::GetAttachingDataPointer(DWORD, const NRaceData::TAttachingData **) -> BOOL
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<BOOL>();
}
auto CItemData::IsAntiFlag(DWORD) const -> BOOL
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<BOOL>();
}
auto CItemData::IsEquipment() const -> BOOL
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<BOOL>();
}
auto CItemData::IsFlag(DWORD) const -> BOOL
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<BOOL>();
}
auto CItemData::HasNextGrade() const -> BOOL
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<BOOL>();
}
auto CItemData::GetWearFlags() const -> DWORD
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<DWORD>();
}
auto CItemData::GetISellItemPrice() const -> DWORD
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<DWORD>();
}
@@ -1,35 +0,0 @@
// Stand-in for the 40250 logic unit GameLib/ItemManager.cpp, not ported yet: the members the ported units
// reference, as platform_stub.py stubs. Delete this file in the commit that ports the unit into port/
// (docs/PORT-PLAN.md).
#include "GameLib/StdAfx.h"
#include "GameLib/ItemManager.h"
#include "../../PlatformStub.h"
CItemManager::CItemManager()
{
MT_PLATFORM_STUB();
}
CItemManager::~CItemManager()
{
MT_PLATFORM_STUB();
}
auto CItemManager::GetItemDataPointer(DWORD, CItemData **) -> BOOL
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<BOOL>();
}
auto CItemManager::SelectItemData(DWORD) -> BOOL
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<BOOL>();
}
auto CItemManager::GetSelectedItemDataPointer() -> CItemData *
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<CItemData *>();
}
@@ -1,41 +0,0 @@
// Stand-in for the 40250 logic unit UserInterface/PythonNonPlayer.cpp, not ported yet: the members the ported units
// reference, as platform_stub.py stubs. Delete this file in the commit that ports the unit into port/
// (docs/PORT-PLAN.md).
#include "UserInterface/StdAfx.h"
#include "UserInterface/PythonNonPlayer.h"
#include "../../PlatformStub.h"
CPythonNonPlayer::CPythonNonPlayer()
{
MT_PLATFORM_STUB();
}
CPythonNonPlayer::~CPythonNonPlayer()
{
MT_PLATFORM_STUB();
}
auto CPythonNonPlayer::GetName(DWORD, const char **) -> bool
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<bool>();
}
auto CPythonNonPlayer::GetInstanceType(DWORD, BYTE *) -> bool
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<bool>();
}
auto CPythonNonPlayer::GetEventType(DWORD) -> BYTE
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<BYTE>();
}
auto CPythonNonPlayer::GetMonsterColor(DWORD) -> DWORD
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<DWORD>();
}
@@ -191,3 +191,20 @@ auto CPythonSkill::SSkillData::GetType() const -> BYTE
MT_PLATFORM_STUB();
return mt_platform_stub_return<BYTE>();
}
auto CPythonSkill::Destroy() -> void
{
MT_PLATFORM_STUB();
}
auto CPythonSkill::RegisterSkillTable(const char *) -> bool
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<bool>();
}
auto CPythonSkill::RegisterSkillDesc(const char *) -> bool
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<bool>();
}