寒服更新
This commit is contained in:
parent
c9d989f8b8
commit
b5fba5bed3
|
|
@ -0,0 +1,94 @@
|
||||||
|
/*
|
||||||
|
文件名:装备拓展.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] == 0) {
|
||||||
|
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();
|
||||||
|
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_Enter_Func["_装备拓展_"] <- function(args) {
|
||||||
|
local Inven_Item = NativePointer(args[1]);
|
||||||
|
if (Inven_Item.add(1).readU8() == 1) {
|
||||||
|
local Uuid = Inven_Item.add(21).readInt();
|
||||||
|
if (Uuid< 10000) {
|
||||||
|
local uuid = GenerateUUID();
|
||||||
|
Inven_Item.add(21).writeInt(uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.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);
|
||||||
|
|
@ -88,8 +88,9 @@ class NewTitleC {
|
||||||
//查询自身称号簿数据
|
//查询自身称号簿数据
|
||||||
ClientSocketPackFuncMap.rawset(21012001, function(SUser, Jso) {
|
ClientSocketPackFuncMap.rawset(21012001, function(SUser, Jso) {
|
||||||
local SendInfo = {};
|
local SendInfo = {};
|
||||||
if (data.rawin(SUser.GetCID())) {
|
local Cid = SUser.GetCID().tostring();
|
||||||
SendInfo = data.rawget(SUser.GetCID());
|
if (data.rawin(Cid)) {
|
||||||
|
SendInfo = data.rawget(Cid);
|
||||||
}
|
}
|
||||||
SUser.SendJso({
|
SUser.SendJso({
|
||||||
op = 21012002,
|
op = 21012002,
|
||||||
|
|
@ -101,7 +102,7 @@ class NewTitleC {
|
||||||
ClientSocketPackFuncMap.rawset(21012003, function(SUser, Jso) {
|
ClientSocketPackFuncMap.rawset(21012003, function(SUser, Jso) {
|
||||||
local SaveInfo = Jso.SendInfo;
|
local SaveInfo = Jso.SendInfo;
|
||||||
local SaveId = Jso.Id;
|
local SaveId = Jso.Id;
|
||||||
local Cid = SUser.GetCID();
|
local Cid = SUser.GetCID().tostring();
|
||||||
//因为json传输过程会导致INT key变成string 所以这里的缓存里一律要使用string 的编号
|
//因为json传输过程会导致INT key变成string 所以这里的缓存里一律要使用string 的编号
|
||||||
data[Cid].rawset(SaveId.tostring(), SaveInfo);
|
data[Cid].rawset(SaveId.tostring(), SaveInfo);
|
||||||
RefreshAreaDrawInfo(SUser);
|
RefreshAreaDrawInfo(SUser);
|
||||||
|
|
@ -111,7 +112,7 @@ class NewTitleC {
|
||||||
|
|
||||||
//给玩家添加称号
|
//给玩家添加称号
|
||||||
function AddTitle(SUser, TitleId) {
|
function AddTitle(SUser, TitleId) {
|
||||||
local Cid = SUser.GetCID();
|
local Cid = SUser.GetCID().tostring();
|
||||||
if (!data.rawin(Cid)) {
|
if (!data.rawin(Cid)) {
|
||||||
data.rawset(Cid, {});
|
data.rawset(Cid, {});
|
||||||
}
|
}
|
||||||
|
|
@ -126,7 +127,7 @@ class NewTitleC {
|
||||||
|
|
||||||
//给玩家移除称号
|
//给玩家移除称号
|
||||||
function RemoveTitle(SUser, TitleId) {
|
function RemoveTitle(SUser, TitleId) {
|
||||||
local Cid = SUser.GetCID();
|
local Cid = SUser.GetCID().tostring();
|
||||||
if (!data.rawin(Cid)) {
|
if (!data.rawin(Cid)) {
|
||||||
data.rawset(Cid, {});
|
data.rawset(Cid, {});
|
||||||
}
|
}
|
||||||
|
|
@ -153,7 +154,7 @@ class NewTitleC {
|
||||||
function GenerateDrawInfo(ShowCidList) {
|
function GenerateDrawInfo(ShowCidList) {
|
||||||
local ShowList = {};
|
local ShowList = {};
|
||||||
foreach(SUserObj in ShowCidList) {
|
foreach(SUserObj in ShowCidList) {
|
||||||
local Cid = SUserObj.GetCID();
|
local Cid = SUserObj.GetCID().tostring();
|
||||||
local ShowData = null;
|
local ShowData = null;
|
||||||
if (data.rawin(Cid)) {
|
if (data.rawin(Cid)) {
|
||||||
ShowData = data.rawget(Cid);
|
ShowData = data.rawget(Cid);
|
||||||
|
|
@ -191,7 +192,7 @@ class NewTitleC {
|
||||||
Timer.SetCronTask(function() {
|
Timer.SetCronTask(function() {
|
||||||
local DataList = [];
|
local DataList = [];
|
||||||
foreach(cid, value in data) {
|
foreach(cid, value in data) {
|
||||||
local str = format("(%d,'%s'),", cid, Json.Encode(value));
|
local str = format("(%s,'%s'),", cid.tostring(), Json.Encode(value));
|
||||||
DataList.push(str);
|
DataList.push(str);
|
||||||
}
|
}
|
||||||
local sql = "REPLACE INTO newtitle (cid, data) VALUES";
|
local sql = "REPLACE INTO newtitle (cid, data) VALUES";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue