AVA2 client Windows parity passes (gr2 BitKnit2/64-bit, GamePhase handlers, python modules)
- gr2: BitKnit2 decompression, 64-bit LE files, compressed curves - net: remaining GamePhase handlers, generated GC packet table - python: event/chat/chr/minimap/guild/quest/messenger/shop-search and other native modules ported against the AVA2 Windows client - render: D3D8 fixed-function lighting in Gr2ModelRenderer, terrain without baked shade; cape/NPC equipment attachment - tests + audits updated; docs/PORT-PLAN.md and WINDOWS-PARITY.md Batch 4 (render pipeline: background.*, app.RenderGame/UpdateGame, camera bindings, main.cpp fake-content removal) is still in progress. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9f748eb05a
commit
9077aa389a
+172
-11
@@ -1,11 +1,28 @@
|
||||
#include "player_settings.h"
|
||||
#include "python_app.h"
|
||||
#include "server_clock.h"
|
||||
#include "generated_app_constants.h"
|
||||
#include "../upstream/ava2-client/UserInterface/Locale_inc.h"
|
||||
#include "src/eter_image/MarkManager.h"
|
||||
#include "nonplayer_data.h"
|
||||
#include "eter_net/NetworkActorManager.h"
|
||||
#include "eter_render/RaceData.h"
|
||||
#include "pet_skill_state.h"
|
||||
#include "python_gameplay_modules.h"
|
||||
#include "python_native_modules.h"
|
||||
#include "python_net.h"
|
||||
#include "python_runtime.h"
|
||||
#include "ava2_text_file.h"
|
||||
#include "python_wiki.h"
|
||||
#include "shared/common/PythonUtils.h"
|
||||
#include "eter_base/Random.h"
|
||||
#include <iostream>
|
||||
#include <Python.h>
|
||||
#include <chrono>
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace ava2 {
|
||||
namespace {
|
||||
@@ -13,6 +30,8 @@ namespace {
|
||||
std::uint32_t local_milliseconds() { return static_cast<std::uint32_t>(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count()); }
|
||||
std::int64_t unix_seconds() { return std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count(); }
|
||||
ServerClock server_clock(local_milliseconds());
|
||||
// EterBase Timer.cpp gs_dwServerTime / gs_dwClientTime (ELTimer_*ServerMSec), separate from app.GetGlobalTime.
|
||||
std::uint32_t elt_server_time=0,elt_client_time=0;
|
||||
auto app_start=std::chrono::steady_clock::now();
|
||||
float s_camera_distance = 1500.0f;
|
||||
float s_camera_pitch = 30.0f;
|
||||
@@ -49,12 +68,26 @@ PyObject* app_set_camera(PyObject*, PyObject* args) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyObject* app_set_hair_color_enable(PyObject*, PyObject* args) { int f = 0; if(!PyArg_ParseTuple(args, "i", &f)) return nullptr; Py_RETURN_NONE; }
|
||||
PyObject* app_set_armor_specular_enable(PyObject*, PyObject* args) { int f = 0; if(!PyArg_ParseTuple(args, "i", &f)) return nullptr; s_armor_specular = (f != 0); Py_RETURN_NONE; }
|
||||
PyObject* app_set_hair_color_enable(PyObject*, PyObject* args) { int f = 0; if(!PyArg_ParseTuple(args, "i", &f)) return nullptr; NetworkActorManager::SetHairColorEnable(f != 0); Py_RETURN_NONE; }
|
||||
PyObject* app_set_armor_specular_enable(PyObject*, PyObject* args) { int f = 0; if(!PyArg_ParseTuple(args, "i", &f)) return nullptr; s_armor_specular = (f != 0); NetworkActorManager::SetArmorSpecularEnable(f != 0); Py_RETURN_NONE; }
|
||||
PyObject* app_set_weapon_specular_enable(PyObject*, PyObject* args) { int f = 0; if(!PyArg_ParseTuple(args, "i", &f)) return nullptr; s_weapon_specular = (f != 0); Py_RETURN_NONE; }
|
||||
|
||||
PyObject* app_set_mouse_handler(PyObject*, PyObject* args) { Py_RETURN_NONE; }
|
||||
PyObject* app_create(PyObject*, PyObject* args) { Py_RETURN_NONE; }
|
||||
// appCreate: after the window, LoadPythonPlayerSettingsModuleLibrary registers the
|
||||
// PythonPlayerSettingsModule tables and CPythonPlayerSettingsModule::Load runs
|
||||
// introLoading.__main__ (name/title colours, title names, emotion icons, dungeon names),
|
||||
// then __LoadGameNPC("npclist.txt") and the player race table (CRaceManager / .msm).
|
||||
PyObject* app_create(PyObject*, PyObject* args) {
|
||||
ava2::LoadPlayerSettings();
|
||||
PyObject* module = PyImport_ImportModule("introLoading");
|
||||
PyObject* main = module ? PyObject_GetAttrString(module, "__main__") : nullptr;
|
||||
PyObject* result = main ? PyObject_CallObject(main, nullptr) : nullptr;
|
||||
if (!result) PyErr_Print();
|
||||
Py_XDECREF(result); Py_XDECREF(main); Py_XDECREF(module);
|
||||
RaceManager::Instance().LoadGameNPC("npclist.txt");
|
||||
RaceManager::Instance().LoadPlayerRaces();
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
PyObject* app_loop(PyObject*, PyObject*) { Py_RETURN_NONE; }
|
||||
PyObject* app_exit(PyObject*, PyObject*) { Py_RETURN_NONE; }
|
||||
PyObject* app_abort(PyObject*, PyObject*) { Py_RETURN_NONE; }
|
||||
@@ -72,11 +105,32 @@ PyObject* app_get_locale_path(PyObject*, PyObject*) {
|
||||
return PyString_FromString(s_locale_path.c_str());
|
||||
}
|
||||
|
||||
// appLoadLocaleData (AVA2 PythonApplicationModule.cpp).
|
||||
PyObject* app_load_locale_data(PyObject*, PyObject* args) {
|
||||
char* localePath;
|
||||
if (!PyTuple_GetString(args, 0, &localePath))
|
||||
return Py_BuildException();
|
||||
return Py_BuildValue("i", LoadLocaleData(localePath));
|
||||
}
|
||||
|
||||
PyObject* app_get_default_codepage(PyObject*, PyObject*) {
|
||||
return PyInt_FromLong(1252);
|
||||
return PyInt_FromLong(GetDefaultCodePage());
|
||||
}
|
||||
|
||||
PyObject* app_dummy_none(PyObject*, PyObject*) { Py_RETURN_NONE; }
|
||||
|
||||
// appGetRandom: EterBase random_range over the swapped bounds.
|
||||
PyObject* app_get_random(PyObject*, PyObject* poArgs) {
|
||||
int from;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &from))
|
||||
return Py_BuildException();
|
||||
int to;
|
||||
if (!PyTuple_GetInteger(poArgs, 1, &to))
|
||||
return Py_BuildException();
|
||||
if (from > to)
|
||||
std::swap(from, to);
|
||||
return Py_BuildValue("i", eter::random_range(from, to));
|
||||
}
|
||||
PyObject* app_dummy_zero(PyObject*, PyObject*) { return PyInt_FromLong(0); }
|
||||
PyObject* app_dummy_one(PyObject*, PyObject*) { return PyInt_FromLong(1); }
|
||||
PyObject* app_dummy_float_zero(PyObject*, PyObject*) { return PyFloat_FromDouble(0.0); }
|
||||
@@ -84,6 +138,43 @@ PyObject* app_dummy_str(PyObject*, PyObject*) { return PyString_FromString("");
|
||||
PyObject* app_dummy_tuple2(PyObject*, PyObject*) { return Py_BuildValue("ii", 0, 0); }
|
||||
PyObject* app_dummy_tuple3(PyObject*, PyObject*) { return Py_BuildValue("iii", 0, 0, 0); }
|
||||
|
||||
// CTextLineLoader / appOpenTextFile..appGetTextFileLine (PythonApplicationModule.cpp).
|
||||
// Windows hands Python the heap pointer as an int; 64-bit hosts get an index instead.
|
||||
std::unordered_map<int, std::vector<std::string>> s_textLineLoaders;
|
||||
int s_nextTextLineLoader = 1;
|
||||
|
||||
PyObject* app_open_text_file(PyObject*, PyObject* args) {
|
||||
const char* fileName = nullptr;
|
||||
if (!PyArg_ParseTuple(args, "s", &fileName)) return nullptr;
|
||||
std::vector<std::string> lines;
|
||||
try { lines = ava2::ava2TextLines(ReadPackedText(fileName)); } catch (const std::exception&) {}
|
||||
const int handle = s_nextTextLineLoader++;
|
||||
s_textLineLoaders[handle] = std::move(lines);
|
||||
return PyInt_FromLong(handle);
|
||||
}
|
||||
|
||||
PyObject* app_close_text_file(PyObject*, PyObject* args) {
|
||||
int handle = 0;
|
||||
if (!PyArg_ParseTuple(args, "i", &handle)) return nullptr;
|
||||
s_textLineLoaders.erase(handle);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyObject* app_get_text_file_line_count(PyObject*, PyObject* args) {
|
||||
int handle = 0;
|
||||
if (!PyArg_ParseTuple(args, "i", &handle)) return nullptr;
|
||||
auto it = s_textLineLoaders.find(handle);
|
||||
return PyInt_FromLong(it == s_textLineLoaders.end() ? 0 : long(it->second.size()));
|
||||
}
|
||||
|
||||
PyObject* app_get_text_file_line(PyObject*, PyObject* args) {
|
||||
int handle = 0, index = 0;
|
||||
if (!PyArg_ParseTuple(args, "ii", &handle, &index)) return nullptr;
|
||||
auto it = s_textLineLoaders.find(handle);
|
||||
if (it == s_textLineLoaders.end() || index < 0 || size_t(index) >= it->second.size()) return PyString_FromString("");
|
||||
return PyString_FromStringAndSize(it->second[index].data(), Py_ssize_t(it->second[index].size()));
|
||||
}
|
||||
|
||||
PyObject* app_set_guild_mark_path(PyObject*, PyObject* args) {
|
||||
const char* path = nullptr;
|
||||
if (PyArg_ParseTuple(args, "s", &path) && path) {
|
||||
@@ -99,12 +190,18 @@ PyObject* app_set_guild_mark_path(PyObject*, PyObject* args) {
|
||||
|
||||
std::int32_t GetServerTimeStamp() { return server_clock.timestamp(unix_seconds()); }
|
||||
void SetServerTime(std::int32_t time) { server_clock.set(time,local_milliseconds(),unix_seconds()); }
|
||||
void ResetPythonAppState() { server_clock=ServerClock(local_milliseconds());app_start=std::chrono::steady_clock::now();s_test_server_flag=false;twoHandedAttackSpeedDecrease=0; }
|
||||
std::uint32_t GetLocalMSec() { return local_milliseconds(); }
|
||||
std::int32_t GetApplicationSeconds() { return static_cast<std::int32_t>(std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now()-app_start).count()); }
|
||||
void SetServerMSec(std::uint32_t time) { if(time==0) return;elt_server_time=time;elt_client_time=local_milliseconds(); }
|
||||
std::uint32_t GetServerMSec() { return local_milliseconds()-elt_client_time+elt_server_time; }
|
||||
void ResetPythonAppState() { elt_server_time=elt_client_time=0;server_clock=ServerClock(local_milliseconds());app_start=std::chrono::steady_clock::now();s_test_server_flag=false;twoHandedAttackSpeedDecrease=0; }
|
||||
std::uint8_t GetEnterGameLanguage() {
|
||||
const char* locales[]={"ymir","en","de","tr","pt","es","fr","ro","pl","it","cz","hu"};
|
||||
for(std::uint8_t i=1;i<12;++i) if(s_locale_name==locales[i]) return i;
|
||||
return 1;
|
||||
}
|
||||
// The port serves the AVA2 Latin-1 locales only (en/de/es/...), so the ANSI code page is 1252.
|
||||
unsigned GetDefaultCodePage() { return 1252; }
|
||||
|
||||
int GetTwoHandedAttackSpeedDecrease(){return twoHandedAttackSpeedDecrease;}
|
||||
bool IsYmirLocale() { return s_locale_name=="ymir"; }
|
||||
@@ -163,7 +260,7 @@ void initapp() {
|
||||
{"SetGlobalCenterPosition", app_dummy_none, METH_VARARGS, nullptr},
|
||||
{"SetCenterPosition", app_dummy_none, METH_VARARGS, nullptr},
|
||||
{"GetCursorPosition", app_dummy_tuple2, METH_VARARGS, nullptr},
|
||||
{"GetRandom", app_dummy_zero, METH_VARARGS, nullptr},
|
||||
{"GetRandom", app_get_random, METH_VARARGS, nullptr},
|
||||
{"RunPythonFile", app_dummy_none, METH_VARARGS, nullptr},
|
||||
{"IsWebPageMode", app_dummy_zero, METH_VARARGS, nullptr},
|
||||
{"ShowWebPage", app_dummy_none, METH_VARARGS, nullptr},
|
||||
@@ -193,16 +290,16 @@ void initapp() {
|
||||
{"SetCameraSetting", app_dummy_none, METH_VARARGS, nullptr},
|
||||
{"SetSightRange", app_dummy_none, METH_VARARGS, nullptr},
|
||||
{"IsFileExist", app_dummy_zero, METH_VARARGS, nullptr},
|
||||
{"OpenTextFile", app_dummy_none, METH_VARARGS, nullptr},
|
||||
{"CloseTextFile", app_dummy_none, METH_VARARGS, nullptr},
|
||||
{"GetTextFileLineCount", app_dummy_str, METH_VARARGS, nullptr},
|
||||
{"GetTextFileLine", app_dummy_str, METH_VARARGS, nullptr},
|
||||
{"OpenTextFile", app_open_text_file, METH_VARARGS, nullptr},
|
||||
{"CloseTextFile", app_close_text_file, METH_VARARGS, nullptr},
|
||||
{"GetTextFileLineCount", app_get_text_file_line_count, METH_VARARGS, nullptr},
|
||||
{"GetTextFileLine", app_get_text_file_line, METH_VARARGS, nullptr},
|
||||
{"GetLocaleServiceName", app_get_locale_service_name, METH_VARARGS, nullptr},
|
||||
{"GetLocaleName", app_get_locale_name, METH_VARARGS, nullptr},
|
||||
{"GetLocalePath", app_get_locale_path, METH_VARARGS, nullptr},
|
||||
{"ForceSetLocale", app_dummy_none, METH_VARARGS, nullptr},
|
||||
{"LoadLocaleAddr", app_dummy_none, METH_VARARGS, nullptr},
|
||||
{"LoadLocaleData", app_dummy_none, METH_VARARGS, nullptr},
|
||||
{"LoadLocaleData", app_load_locale_data, METH_VARARGS, nullptr},
|
||||
{"SetCHEONMA", app_dummy_none, METH_VARARGS, nullptr},
|
||||
{"IsCHEONMA", app_dummy_zero, METH_VARARGS, nullptr},
|
||||
{"GetDefaultCodePage", app_get_default_codepage, METH_VARARGS, nullptr},
|
||||
@@ -295,4 +392,68 @@ void initapp() {
|
||||
PyModule_AddIntConstant(module, "INFO_TEXTTAIL", 3);
|
||||
}
|
||||
|
||||
namespace {
|
||||
void locale_trace_error(const std::string& text) { std::cerr << "[AVA2 TraceError] " << text << std::endl; }
|
||||
bool load_text(const std::string& path, std::string* text) {
|
||||
try { *text = ReadPackedText(path); return true; } catch (const std::exception&) { return false; }
|
||||
}
|
||||
}
|
||||
|
||||
// Same order, Destroy() calls and early-return points as the Windows coordinator.
|
||||
// Not ported: YMIR lang%d.cvt (AVA2 runs EUROPE) - see docs/WINDOWS-PARITY.md.
|
||||
bool LoadLocaleData(const std::string& localePath) {
|
||||
const std::string szItemList = localePath + "/item_list.txt";
|
||||
const std::string szItemProto = localePath + "/item_proto";
|
||||
const std::string szItemDesc = localePath + "/itemdesc.txt";
|
||||
const std::string szMobProto = localePath + "/mob_proto";
|
||||
const std::string szSkillDescFileName = localePath + "/SkillDesc.txt";
|
||||
const std::string szSkillTableFileName = localePath + "/SkillTable.txt";
|
||||
const std::string szInsultList = localePath + "/insult.txt";
|
||||
const std::string szSkillPetFileName = localePath + "/pet_skill.txt";
|
||||
const std::string szMobScale = localePath + "/mob_scale.txt";
|
||||
|
||||
NonPlayerData& rkNPCMgr = NonPlayerData::Instance();
|
||||
rkNPCMgr.clear();
|
||||
ResetItemDatabase();
|
||||
ResetSkillDescriptions();
|
||||
GetPetSkillState().Clear();
|
||||
|
||||
if (!LoadItemList(szItemList))
|
||||
locale_trace_error("LoadLocaleData - LoadItemList(" + szItemList + ") Error");
|
||||
if (!LoadItemTable(szItemProto)) {
|
||||
locale_trace_error("LoadLocaleData - LoadItemProto(" + szItemProto + ") Error");
|
||||
return false;
|
||||
}
|
||||
LoadItemDescriptions(szItemDesc); // Tracenf only
|
||||
std::string text;
|
||||
if (!load_text(szMobProto, &text) || !rkNPCMgr.load(text)) {
|
||||
locale_trace_error("LoadLocaleData - LoadMobProto(" + szMobProto + ") Error");
|
||||
return false;
|
||||
}
|
||||
// The original passes szMobProto to the two skill messages.
|
||||
if (!LoadSkillDescriptions(szSkillDescFileName)) {
|
||||
locale_trace_error("LoadLocaleData - RegisterSkillDesc(" + szMobProto + ") Error");
|
||||
return false;
|
||||
}
|
||||
if (!LoadSkillTable(szSkillTableFileName)) {
|
||||
locale_trace_error("LoadLocaleData - RegisterSkillTable(" + szMobProto + ") Error");
|
||||
return false;
|
||||
}
|
||||
if (!LoadPetSkills(szSkillPetFileName)) {
|
||||
locale_trace_error("LoadLocaleData - RegisterSkillPet(" + szSkillPetFileName + ") Error");
|
||||
return false;
|
||||
}
|
||||
LoadInsultList(szInsultList); // Tracenf only
|
||||
rkNPCMgr.clearNPCWear();
|
||||
if (load_text("locale/common/npc_wear.txt", &text))
|
||||
rkNPCMgr.loadNPCWear(text);
|
||||
if (!load_text(szMobScale, &text) || !rkNPCMgr.loadMobScale(text, szMobScale)) {
|
||||
locale_trace_error("LoadMobScale Error(" + szMobScale + ")");
|
||||
return false;
|
||||
}
|
||||
LoadItemScale(localePath + "/item_scale.txt"); // Tracenf only
|
||||
WikiReadData(localePath); // ENABLE_WIKI
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace ava2
|
||||
|
||||
Reference in New Issue
Block a user