Add mobile touch UI and AVA2 biology system with server tools

This commit is contained in:
shen
2026-10-14 19:12:38 -07:00
parent e7f2202a94
commit 6472d17306
68 changed files with 4447 additions and 197 deletions
+32 -5
View File
@@ -2,7 +2,7 @@
// Runtime loading remains the original 40250 path and binary format.
// An optional item limits table (vnum, limit type 0, value 0, limit type 1, value 1) mirrors the few
// item_proto.txt limit changes made on our server (tools/server/*), so the tooltip states what the
// server enforces; only aLimits of the listed items may change.
// server enforces. An optional 14-row stone overlay restores extracted +6 stone data.
#include "GameLib/StdAfx.h"
#include "GameLib/ItemData.h"
#include "UserInterface/StdAfx.h"
@@ -16,6 +16,7 @@
#include <fstream>
#include <iostream>
#include <map>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>
@@ -23,6 +24,7 @@
namespace {
using Item = CItemData::TItemTable;
using Mob = CPythonNonPlayer::TMobTable;
std::map<DWORD, std::array<long, 11>> stones;
constexpr std::array<DWORD, 4> item_key{{173217, 72619434, 408587239, 27973291}};
constexpr std::array<DWORD, 4> mob_key{{4813894, 18955, 552631, 6822045}};
@@ -99,6 +101,14 @@ void apply_limits(Record&, const std::map<DWORD, Limits>&, std::size_t&) {}
template <>
void apply_limits<Item>(Item& record, const std::map<DWORD, Limits>& limits, std::size_t& changed) {
const auto stone = stones.find(record.dwVnum);
if (stone != stones.end()) {
const auto& s = stone->second;
record.bType = s[0]; record.bSubType = s[1]; record.dwWearFlags = s[2];
std::memset(record.aApplies, 0, sizeof(record.aApplies));
record.aApplies[0].bType = s[3]; record.aApplies[0].lValue = s[4];
for (int i = 0; i < 6; ++i) record.alValues[i] = s[5+i];
}
const auto found = limits.find(record.dwVnum);
if (found == limits.end()) return;
std::memcpy(record.aLimits, found->second.data(), sizeof(record.aLimits));
@@ -110,6 +120,10 @@ bool limits_field(std::size_t, DWORD, const std::map<DWORD, Limits>&) { return f
template <>
bool limits_field<Item>(std::size_t offset, DWORD vnum, const std::map<DWORD, Limits>& limits) {
if (stones.count(vnum) && (offset == offsetof(Item, bType) || offset == offsetof(Item, bSubType) ||
(offset >= offsetof(Item, dwWearFlags) && offset < offsetof(Item, dwWearFlags)+sizeof(Item::dwWearFlags)) ||
(offset >= offsetof(Item, aApplies) && offset < offsetof(Item, aApplies)+sizeof(Item::aApplies)) ||
(offset >= offsetof(Item, alValues) && offset < offsetof(Item, alValues)+sizeof(Item::alValues)))) return true;
return limits.count(vnum) && offset >= offsetof(Item, aLimits) &&
offset < offsetof(Item, aLimits) + sizeof(Item::aLimits);
}
@@ -151,7 +165,7 @@ std::vector<BYTE> patch(const char* source, const char* names_path,
std::memcpy(plain.data() + std::size_t(i) * sizeof(Record), &record, sizeof(Record));
++translated;
}
// No item stats, VNUM, canonical name, or mob gameplay fields may change (but the listed item limits).
// Only locale names, listed limits and explicit stone overlay fields may change.
for (DWORD i = 0; i < count; ++i) {
const std::size_t start = std::size_t(i) * sizeof(Record);
const std::size_t name_start = start + offsetof(Record, szLocaleName);
@@ -185,14 +199,27 @@ std::vector<BYTE> patch(const char* source, const char* names_path,
} // namespace
int main(int argc, char** argv) {
if (argc != 7 && argc != 8) {
if (argc != 7 && argc != 8 && argc != 9) {
std::cerr << "usage: locale_proto_patch item_proto mob_proto item_names_gbk mob_names_gbk out_item out_mob"
" [item_limits]\n";
" [item_limits [item_stones]]\n";
return 2;
}
try {
static CLZO lzo;
const auto item = patch<Item>(argv[1], argv[3], item_key, "MIPX", true, read_limits(argc == 8 ? argv[7] : nullptr));
if (argc == 9) {
std::ifstream stream(argv[8]);
if (!stream) throw std::runtime_error("cannot read stone overlay");
std::string line;
while (std::getline(stream, line)) {
if (line.empty() || line[0] == '#') continue;
std::istringstream row(line); DWORD vnum; std::array<long,11> values{};
if (!(row >> vnum) || vnum < 28700 || vnum > 28713) throw std::runtime_error("bad stone vnum");
for (auto& value : values) if (!(row >> value)) throw std::runtime_error("bad stone row");
if (values[0] != 10 || !stones.emplace(vnum, values).second) throw std::runtime_error("bad stone type/duplicate");
}
if (stones.size() != 14) throw std::runtime_error("stone overlay must contain all 14 stones");
}
const auto item = patch<Item>(argv[1], argv[3], item_key, "MIPX", true, read_limits(argc >= 8 ? argv[7] : nullptr));
const auto mob = patch<Mob>(argv[2], argv[4], mob_key, "MMPT", false);
write_file(argv[5], item);
write_file(argv[6], mob);