添加装备拓展功能,创建新表以管理唯一ID,并实现UUID生成逻辑;更新ItemClass和PacketClass以支持新功能
This commit is contained in:
parent
a1e5af4ef9
commit
b2e4be7d06
|
|
@ -0,0 +1,95 @@
|
||||||
|
/*
|
||||||
|
文件名:装备拓展.nut
|
||||||
|
路径:MyProject/装备拓展.nut
|
||||||
|
创建日期:2026-01-15 10:02
|
||||||
|
文件用途:
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Cb_ItemGloballyUniqueIdentifier_t_SetServerId_Enter_Func <- {};
|
||||||
|
Cb_ItemGloballyUniqueIdentifier_t_SetServerId_Leave_Func <- {};
|
||||||
|
_Hook_Register_Currency_Func_("0x08894782", ["pointer", "int", "pointer"], Cb_ItemGloballyUniqueIdentifier_t_SetServerId_Enter_Func, Cb_ItemGloballyUniqueIdentifier_t_SetServerId_Leave_Func);
|
||||||
|
|
||||||
|
// Cb_CInventory_MakeItemPacket_Enter_Func <- {};
|
||||||
|
// Cb_CInventory_MakeItemPacket_Leave_Func <- {};
|
||||||
|
// _Hook_Register_Currency_Func_("0x084FC6BC", ["pointer", "int", "int", "pointer", "int"], Cb_CInventory_MakeItemPacket_Enter_Func, Cb_CInventory_MakeItemPacket_Leave_Func);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class EquipmentExpandC {
|
||||||
|
|
||||||
|
MysqlObject = null;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
MysqlObject = Mysql(Str_Ptr("127.0.0.1"), 3306, Str_Ptr("taiwan_cain"), Str_Ptr("game"), Str_Ptr("uu5!^%jg"));
|
||||||
|
MysqlObject.Exec_Sql(format("SET NAMES %s", "latin1"));
|
||||||
|
|
||||||
|
local check_table_sql = "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'equip_only_id';"
|
||||||
|
local Ret = MysqlObject.Select(check_table_sql, ["int"]);
|
||||||
|
if (Ret.len() == 0 || Ret[0][0] == null) {
|
||||||
|
local sql = "CREATE TABLE equip_only_id (id INT(11) NOT NULL AUTO_INCREMENT COMMENT '32位自增唯一ID,初始值10000', PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '纯自增ID表' AUTO_INCREMENT=10000;";
|
||||||
|
MysqlObject.Exec_Sql(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
//HOOKServerId生成uuid
|
||||||
|
Cb_ItemGloballyUniqueIdentifier_t_SetServerId_Enter_Func["_装备拓展_"] <- function(args) {
|
||||||
|
args[1] = GenerateUUID();
|
||||||
|
print("赋予唯一id: " + args[1]);
|
||||||
|
return args;
|
||||||
|
}.bindenv(this);
|
||||||
|
|
||||||
|
// //补充数据包
|
||||||
|
// Cb_CInventory_MakeItemPacket_Leave_Func["_装备拓展_"] <- function(args) {
|
||||||
|
|
||||||
|
// // local ItemObj = Item(Sq_CallFunc(S_Ptr("0x084FC1DE"), "int", ["pointer", "int", "int", "pointer"], args[0], args[1], args[2]));
|
||||||
|
// // print("装备编号: " + ItemObj.GetIndex());
|
||||||
|
// // local Pack = Packet(args[3]);
|
||||||
|
// // local Buffer = Memory.alloc(30);
|
||||||
|
// // //无需重置为0 需要写数据的地方自己会覆写
|
||||||
|
|
||||||
|
// // Buffer.add(18).writeInt(NativePointer())
|
||||||
|
|
||||||
|
// // Pack.Put_BinaryEx(DB_JewelSocketData.C_Object, 30);
|
||||||
|
// }.bindenv(this);
|
||||||
|
|
||||||
|
// //额外数据包,发送装备数据给本地处理
|
||||||
|
// Cb_InterfacePacketBuf_put_packet_Leave_Func["_装备拓展_"] <- function(args) {
|
||||||
|
// local Inven_Item = NativePointer(args[1]);
|
||||||
|
// if (Inven_Item.add(1).readU8() == 1) {
|
||||||
|
// local Uuid = Inven_Item.add(21).readInt();
|
||||||
|
// print("uuid: " + Uuid);
|
||||||
|
// local Pack = Packet(args[0]);
|
||||||
|
// print("包位置: " + Pack.GetPos());
|
||||||
|
// // Pack.Put_BinaryEx(JewelSocketData.C_Object, 30);
|
||||||
|
// }
|
||||||
|
// }.bindenv(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
function GenerateUUID() {
|
||||||
|
MysqlObject.Exec_Sql("INSERT INTO equip_only_id VALUES ();");
|
||||||
|
local Ret = MysqlObject.Select("SELECT LAST_INSERT_ID() AS new_auto_id;", ["int"]);
|
||||||
|
return Ret[0][0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cb_CInventory_insertItemIntoInventory_Leave_Func["_装备拓展_"] <- function(args) {
|
||||||
|
// local SUser = User(NativePointer(args[0]).readPointer());
|
||||||
|
// local ItemObject = Item(NativePointer(Haker.CpuContext.ebp).add(12).C_Object);
|
||||||
|
// local ServerId = NativePointer(ItemObject.C_Object).add(21).readInt();
|
||||||
|
// //数据库主键从10000开始自增
|
||||||
|
// if (ServerId< 10000) {
|
||||||
|
// local NewUuid = GenerateUUID();
|
||||||
|
// NativePointer(ItemObject.C_Object).add(21).writeInt(NewUuid);
|
||||||
|
// }
|
||||||
|
// }.bindenv(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Timer.SetTimeOut(function() {
|
||||||
|
|
||||||
|
getroottable()._EquipmentExpand_ <- EquipmentExpandC();
|
||||||
|
|
||||||
|
print("特殊插件·装备拓展 - 已加载");
|
||||||
|
}, 1);
|
||||||
|
|
@ -146,7 +146,11 @@ class Item extends Base_C_Object {
|
||||||
this = null;
|
this = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取UUID
|
||||||
|
function GetUuid() {
|
||||||
|
Attribute.seek(21);
|
||||||
|
return Attribute.readn('i');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//是否可打包
|
//是否可打包
|
||||||
|
|
|
||||||
|
|
@ -101,9 +101,9 @@ class Packet extends Base_C_Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function GetString(a3,a4) {
|
function GetString(a3, a4) {
|
||||||
local data = Memory.alloc(a3);
|
local data = Memory.alloc(a3);
|
||||||
if (Sq_CallFunc(S_Ptr("0x858D2BC"), "int", ["pointer", "pointer","int","int","int"], this.C_Object, data.C_Object,a3,a4)) {
|
if (Sq_CallFunc(S_Ptr("0x858D2BC"), "int", ["pointer", "pointer", "int", "int", "int"], this.C_Object, data.C_Object, a3, a4)) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -114,4 +114,16 @@ class Packet extends Base_C_Object {
|
||||||
Sq_Delete_Point(this.C_Object);
|
Sq_Delete_Point(this.C_Object);
|
||||||
// Sq_Packet_Delete(this.C_Object);
|
// Sq_Packet_Delete(this.C_Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function GetPos() {
|
||||||
|
return Sq_CallFunc(S_Ptr("0x8110B4C"), "int", ["pointer"], this.C_Object);
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetPos(pos) {
|
||||||
|
Sq_CallFunc(S_Ptr("0x822B7B0"), "int", ["pointer", "int"], this.C_Object, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
function GetLength() {
|
||||||
|
return Sq_CallFunc(S_Ptr("0x848F438"), "int", ["pointer"], this.C_Object);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue