diff --git a/Dps_A/BaseClass/GameManagerClass/GameManagerClass.nut b/Dps_A/BaseClass/GameManagerClass/GameManagerClass.nut index 2220095..b61a5f1 100644 --- a/Dps_A/BaseClass/GameManagerClass/GameManagerClass.nut +++ b/Dps_A/BaseClass/GameManagerClass/GameManagerClass.nut @@ -15,4 +15,39 @@ class GameManager extends Base_C_Object { local C_Party = Sq_GameManager_GetParty(C_Object); return Party(C_Party); } + + //设置游戏最大等级 + function SetGameMaxLevel(MaxLevel) { + NativePointer("0x8360C38").add(3).writeU8(MaxLevel); + NativePointer("0x8360C76").add(3).writeU8(MaxLevel); + NativePointer("0x8360CC1").add(3).writeU8(MaxLevel); + NativePointer("0x84EF802").add(3).writeU8(MaxLevel); + NativePointer("0x858F002").add(3).writeU8(MaxLevel); + NativePointer("0x865A5C0").add(1).writeU8(MaxLevel); + NativePointer("0x865B091").add(4).writeU8(MaxLevel); + NativePointer("0x865B757").add(4).writeU8(MaxLevel); + NativePointer("0x8662F53").add(2).writeU8(MaxLevel); + NativePointer("0x86630F0").add(3).writeU8(MaxLevel); + NativePointer("0x86638F4").add(2).writeU8(MaxLevel); + NativePointer("0x8665D24").add(4).writeU8(MaxLevel); + NativePointer("0x8666E9A").add(2).writeU8(MaxLevel); + NativePointer("0x866A4A6").add(2).writeU8(MaxLevel); + NativePointer("0x866A657").add(2).writeU8(MaxLevel); + NativePointer("0x866A926").add(3).writeU8(MaxLevel); + NativePointer("0x866A93F").add(2).writeU8(MaxLevel); + NativePointer("0x867AEC0").add(2).writeU8(MaxLevel); + NativePointer("0x8689D48").add(3).writeU8(MaxLevel); + NativePointer("0x868fecb").add(3).writeU8(MaxLevel); + NativePointer("0x868fed4").add(6).writeU8(MaxLevel); + } + + //设置装备解锁需要时间 + function SetItemLockTime(time) { + NativePointer("0x8402D29").writeInt(time); + NativePointer("0x854242F").writeInt(time); + NativePointer("0x854274D").writeInt(time); + NativePointer("0x854296F").writeInt(time); + NativePointer("0x8542AD9").writeInt(time); + NativePointer("0x8542BDE").writeInt(time); + } } \ No newline at end of file diff --git a/Dps_A/BaseClass/IOClass/IOClass.nut b/Dps_A/BaseClass/IOClass/IOClass.nut new file mode 100644 index 0000000..5512347 --- /dev/null +++ b/Dps_A/BaseClass/IOClass/IOClass.nut @@ -0,0 +1,76 @@ +/* +文件名:IOClass.nut +路径:Dps_A/BaseClass/IOClass/IOClass.nut +创建日期:2024-09-19 14:13 +文件用途:IO流类 +*/ +class IO extends Base_C_Object { + _Fopen_Address = Module.getExportByName(null, "fopen"); + _Fgetc_Address = Module.getExportByName(null, "fgetc"); + _Fputc_Address = Module.getExportByName(null, "fputc"); + _Fgets_Address = Module.getExportByName(null, "fgets"); + _Fputs_Address = Module.getExportByName(null, "fputs"); + _Fread_Address = Module.getExportByName(null, "fread"); + _Fwrite_Address = Module.getExportByName(null, "fwrite"); + _Fclose_Address = Module.getExportByName(null, "fclose"); + _Fseek_Address = Module.getExportByName(null, "fseek"); + _Ftell_Address = Module.getExportByName(null, "ftell"); + _Rewind_Address = Module.getExportByName(null, "rewind"); + + + + Pos = 0; + + constructor(FileName, Modes) { + local FileObj = Sq_CallFunc(_Fopen_Address, "pointer", ["pointer", "pointer"], Str_Ptr(FileName), Str_Ptr(Modes)); + if (FileObj) { + base.constructor(FileObj); + } else error("文件打开错误! FileName: " + FileName); + } + + //读取一行 + function ReadLine() { + local Buffer = Memory.alloc(256); + local RetFlag = Sq_CallFunc(_Fgets_Address, "pointer", ["pointer", "int", "pointer"], Buffer.C_Object, 256, this.C_Object); + if (RetFlag) + return Buffer.readUtf8String(); + } + + //读取一个 + function Read() { + local RetFlag = Sq_CallFunc(_Fgetc_Address, "char", ["pointer"], this.C_Object); + if (RetFlag) { + return RetFlag; + } + } + + //读取指定大小 + function ReadBuffer(size) { + local Buffer = Memory.alloc(size); + local RetFlag = Sq_CallFunc(_Fread_Address, "int", ["pointer", "int", "int", "pointer"], Buffer.C_Object, 1, size, this.C_Object); + if (RetFlag > 0) { + return { + count = RetFlag, + str = Buffer.readUtf8String(RetFlag) + }; + } else { + return { + count = 0, + str = "" + } + } + } + + + //写入字符串 + function Write(Str) { + local Buffer = Memory.allocUtf8String(Str); + Sq_CallFunc(_Fputs_Address, "int", ["pointer", "pointer"], Buffer.C_Object, this.C_Object); + } + + + //关闭文件 + function Close() { + Sq_CallFunc(_Fclose_Address, "pointer", ["pointer"], this.C_Object); + } +} \ No newline at end of file diff --git a/Dps_A/BaseClass/MD5Class/MD5Class.nut b/Dps_A/BaseClass/MD5Class/MD5Class.nut new file mode 100644 index 0000000..c57277f --- /dev/null +++ b/Dps_A/BaseClass/MD5Class/MD5Class.nut @@ -0,0 +1,42 @@ +/* +文件名:MD5Class.nut +路径:Dps_A/BaseClass/MD5Class/MD5Class.nut +创建日期:2024-09-20 00:06 +文件用途:MD5类 +*/ +class MD5 { + MD5_Init_ptr = Module.getExportByName(null, "MD5_Init"); + MD5_Update_ptr = Module.getExportByName(null, "MD5_Update"); + MD5_Final_ptr = Module.getExportByName(null, "MD5_Final"); + + function MD5_Init(Ctx) { + Sq_CallFunc(MD5_Init_ptr, "void", ["pointer"], Ctx); + } + + function MD5_Update(Ctx, Buffer, Size) { + Sq_CallFunc(MD5_Update_ptr, "void", ["pointer", "pointer", "int"], Ctx, Buffer, Size); + } + + function MD5_Final(Ctx, Result) { + Sq_CallFunc(MD5_Final_ptr, "void", ["pointer", "pointer"], Ctx, Result); + } + + function GetFile(FileName) { + local Io = IO(FileName, "r+"); + + local Ctx = Memory.alloc(0x100); + MD5.MD5_Init(Ctx.C_Object); + + while (true) { + local Buffer = Memory.alloc(0x1000); + local Res = Io.ReadBuffer(0x1000); + if (Res.count == 0) break; + MD5.MD5_Update(Ctx.C_Object, Memory.allocUtf8String(Res.str).C_Object, Res.count); + } + + local Result = Memory.alloc(16); + MD5.MD5_Final(Result.C_Object, Ctx.C_Object); + Io.Close(); + return Result.readUtf8String(16); + } +} \ No newline at end of file diff --git a/Dps_A/BaseClass/MemoryClass/MemoryClass.nut b/Dps_A/BaseClass/MemoryClass/MemoryClass.nut new file mode 100644 index 0000000..4a496d9 --- /dev/null +++ b/Dps_A/BaseClass/MemoryClass/MemoryClass.nut @@ -0,0 +1,183 @@ +/* +文件名:MemoryClass.nut +路径:Dps_A/BaseClass/MemoryClass/MemoryClass.nut +创建日期:2024-09-17 08:23 +文件用途:内存类 +*/ +class Memory { + + function alloc(Size) { + return NativePointer(Size); + } + + function allocUtf8String(Str) { + return NativePointer(Str_Ptr(Str)); + } +} + +class NativePointer extends Base_C_Object { + + constructor(T) { + if (typeof T == "integer") { + base.constructor(Sq_New_Point(T)); + //注册销毁伪析构 + Register_Destruction(C_Object, this); + } else if (typeof T == "userdata") { + base.constructor(T); + } else if (typeof T == "string") { + base.constructor(S_Ptr(T)); + } + } + + function add(intoffset) { + this.C_Object = Sq_PointerOperation(this.C_Object, intoffset, "+"); + return this; + } + + function sub(intoffset) { + this.C_Object = Sq_PointerOperation(this.C_Object, intoffset, "-"); + return this; + } + + function writeByteArray(arr) { + Sq_Memory_WriteByteArr(this.C_Object, arr); + } + + function readByteArray(size) { + local PointB = Sq_Point2Blob(this.C_Object, size); + local arr = []; + foreach(value in PointB) { + arr.append(value); + } + return arr; + } + + + function write(value, type) { + local Buf = blob(0); + Buf.writen(value, type); + local arr = []; + foreach(value in Buf) { + arr.append(value); + } + writeByteArray(arr); + } + + function writeS8(value) { + write(value, 'c'); + } + + function writeU8(value) { + write(value, 'b'); + } + + function writeS16(value) { + write(value, 's'); + } + + function writeU16(value) { + write(value, 'w'); + } + + function writeS32(value) { + write(value, 'i'); + } + + function writeU32(value) { + write(value, 'i'); + } + + function writeShort(value) { + write(value, 's'); + } + + function writeUShort(value) { + write(value, 'w'); + } + + function writeInt(value) { + write(value, 'i'); + } + + function writeUInt(value) { + write(value, 'i'); + } + + function writeFloat(value) { + write(value, 'f'); + } + + function writeDouble(value) { + write(value, 'd'); + } + + + function read(type) { + local Buf = Sq_Point2Blob(this.C_Object, 4); + return Buf.readn(type); + } + + function readS8() { + return read('c'); + } + + function readU8() { + return read('b'); + } + + function readS16() { + return read('s'); + } + + function readU16() { + return read('w'); + } + + function readS32() { + return read('i'); + } + + function readU32() { + return read('i'); + } + + function readShort() { + return read('s'); + } + + function readUShort() { + return read('w'); + } + + function readInt() { + return read('i'); + } + + function readUInt() { + return read('i'); + } + + function readFloat() { + return read('f'); + } + + function readDouble() { + return read('d'); + } + + function readUtf8String(...) { + if (vargv.len() > 0) { + return Sq_Memory_ReadString(this.C_Object, vargv[0]); + } else { + return Sq_Memory_ReadString(this.C_Object); + } + } + + function readPointer() { + return Sq_ReadPoint(this.C_Object); + } + + function tostring() { + return this.C_Object.tostring(); + } +} \ No newline at end of file diff --git a/Dps_A/BaseClass/MoudleClass/MoudleClass.nut b/Dps_A/BaseClass/MoudleClass/MoudleClass.nut new file mode 100644 index 0000000..3e7932c --- /dev/null +++ b/Dps_A/BaseClass/MoudleClass/MoudleClass.nut @@ -0,0 +1,16 @@ +/* +文件名:MoudleClass.nut +路径:Dps_A/BaseClass/MoudleClass/MoudleClass.nut +创建日期:2024-09-17 09:48 +文件用途:模块类 +*/ +class Module { + + function getExportByName(ModuleName, FunctionName) { + return Sq_getExportByName(ModuleName, FunctionName); + } + + function load() { + + } +} \ No newline at end of file diff --git a/Dps_A/BaseClass/MysqlClass/MysqlClass.nut b/Dps_A/BaseClass/MysqlClass/MysqlClass.nut new file mode 100644 index 0000000..554f336 --- /dev/null +++ b/Dps_A/BaseClass/MysqlClass/MysqlClass.nut @@ -0,0 +1,272 @@ +/* +文件名:MysqlClass.nut +路径:Dps_A/BaseClass/MysqlClass/MysqlClass.nut +创建日期:2024-09-16 21:23 +文件用途:数据库类 +*/ +class Mysql extends Base_C_Object { + + // 0空闲 1任务中 2死亡 + State = 0; + + constructor(Ip, Port, Name, Account, Password) { + if (!Open(Ip, Port, Name, Account, Password)) error("数据库连接失败"); + } + + /* + * 读取mysql返回的数据,读取binary类型的字段 + * @param this.C_Object mysql数据库句柄 + * @param columnIndex 要读取的字段的位置 + */ + function Open(db_ip, db_port, db_name, db_username, db_password) { + base.constructor(Sq_New_Point(0x80000)); + Sq_CallFunc(S_Ptr("0x83F3AC8"), "pointer", ["pointer"], this.C_Object); + Sq_CallFunc(S_Ptr("0x83F3CE4"), "int", ["pointer"], this.C_Object); + //打开数据库句柄 + if (Sq_CallFunc(S_Ptr("0x83F4024"), "int", ["pointer", "pointer", "int", "pointer", "pointer", "pointer"], + this.C_Object, db_ip, db_port, db_name, db_username, db_password)) { + return true; + } + return false; + } + + function Fetch() { + Sq_CallFunc(S_Ptr("0x83F44BC"), "int", ["pointer"], this.C_Object); + } + + function Close() { + Sq_CallFunc(S_Ptr("0x83F3E74"), "int", ["pointer"], this.C_Object); + Sq_Delete_Point(this.C_Object); + State = 2; + } + + + /* + * 读取mysql返回的数据,读取string类型的字段 + * @param this.C_Object mysql数据库句柄 + * @param columnIndex 要读取的字段的位置 + */ + function ReadStringColumn(columnIndex) { + //MySQL_get_binary_length + local binary_length = Sq_CallFunc(S_Ptr("0x81253DE"), "int", ["pointer", "int"], this.C_Object, columnIndex); + local binary_length_point = Sq_New_Point(binary_length); + //MySQL_get_binary + if (1 == Sq_CallFunc(S_Ptr("0x812531A"), "int", ["pointer", "int", "pointer", "int"], this.C_Object, columnIndex, binary_length_point, binary_length)) { + //读取string类型的数据 + local result = Sq_ReadAddressString(binary_length_point, binary_length); + Sq_Delete_Point(binary_length_point); + return result; + } + Sq_Delete_Point(binary_length_point); + return null; + } + + /* + * 读取mysql返回的数据,读取有符号int类型的字段 + * @param this.C_Object mysql数据库句柄 + * @param columnIndex 要读取的字段的位置 + */ + function ReadIntColumn(columnIndex) { + local intSizePoint = Sq_New_Point(4); + //MySQL_get_int + if (1 == Sq_CallFunc(S_Ptr("0x811692C"), "int", ["pointer", "int", "pointer"], this.C_Object, columnIndex, intSizePoint)) { + //转为blob + local blob = Sq_Point2Blob(intSizePoint, 4); + //读取8位有符号整数 + local result = blob.readn('c'); + Sq_Delete_Point(intSizePoint); + return result; + } + Sq_Delete_Point(intSizePoint); + return null; + } + + + /* + * 读取mysql返回的数据,读取无符号int类型的字段 + * @param this.C_Object mysql数据库句柄 + * @param columnIndex 要读取的字段的位置 + */ + function ReadUIntColumn(columnIndex) { + local intSizePoint = Sq_New_Point(4); + //MySQL_get_uint + if (1 == Sq_CallFunc(S_Ptr("0x80E22F2"), "int", ["pointer", "int", "pointer"], this.C_Object, columnIndex, intSizePoint)) { + //转为blob + local blob = Sq_Point2Blob(intSizePoint, 4); + //读取8位无符号整数 + local result = blob.readn('b'); + Sq_Delete_Point(intSizePoint); + return result; + } + Sq_Delete_Point(intSizePoint); + return null; + } + + /* + * 读取mysql返回的数据,读取float类型的字段 + * @param this.C_Object mysql数据库句柄 + * @param columnIndex 要读取的字段的位置 + */ + function ReadFloatColumn(columnIndex) { + local intSizePoint = Sq_New_Point(4); + //MySQL_get_float + if (1 == Sq_CallFunc(S_Ptr("0x844D6D0"), "int", ["pointer", "int", "pointer"], this.C_Object, columnIndex, intSizePoint)) { + //转为blob + local blob = Sq_Point2Blob(intSizePoint, 4); + //读取32位浮点数 + local result = blob.readn('f'); + Sq_Delete_Point(intSizePoint); + return result; + } + Sq_Delete_Point(intSizePoint); + return null; + } + + /* + * 读取mysql返回的数据,读取binary类型的字段 + * @param this.C_Object mysql数据库句柄 + * @param columnIndex 要读取的字段的位置 + */ + function ReadBinaryColumn(columnIndex) { + //MySQL_get_binary_length + local binary_length = Sq_CallFunc(S_Ptr("0x81253DE"), "int", ["pointer", "int"], this.C_Object, columnIndex); + if (binary_length > 0) { + local binary_length_point = Sq_New_Point(binary_length); + //MySQL_get_binary + if (1 == Sq_CallFunc(S_Ptr("0x812531A"), "int", ["pointer", "int", "pointer", "int"], this.C_Object, columnIndex, binary_length_point, binary_length)) { + //转为blob + local blob = Sq_Point2Blob(binary_length_point, binary_length); + Sq_Delete_Point(intSizePoint); + return blob; + } + } + Sq_Delete_Point(intSizePoint); + return null; + } + + /** + * mysql查询,带返回结果,返回一个二维数组 + * @param {*} db_pointer 数据库句柄 + * @param {*} select_sql 要执行的查询语句 + * @param {*} column_type_list 返回结果的类型list,按select的column顺序,int,string,unit,float,binary + * @returns + */ + function Select(select_sql, column_type_list) { + local result_list = []; + if (Exec_Sql(select_sql)) { + //获取查询到的数据总数 + local row_count = Sq_CallFunc(S_Ptr("0x80E236C"), "int", ["pointer"], this.C_Object); + if (row_count > 0) { + for (local i = 0; i< row_count; i++) { + Fetch(); + local row = []; + for (local j = 0; j< column_type_list.len(); j++) { + if (column_type_list[j] == "int") { + row.push(ReadIntColumn(j)); + } + if (column_type_list[j] == "string") { + row.push(ReadStringColumn(j)); + } + if (column_type_list[j] == "uint") { + row.push(ReadUIntColumn(j)); + } + if (column_type_list[j] == "float") { + row.push(ReadFloatColumn(j)); + } + if (column_type_list[j] == "binary") { + row.push(ReadBinaryColumn(j)); + } + } + result_list.push(row); + } + } + } + return result_list; + } + + //执行查询返回执行是否成功 + function Exec_Sql(sql) { + local sql_ptr = Str_Ptr(sql); + //set query + local set_query = Sq_CallFunc(S_Ptr("0x83F41C0"), "int", ["pointer", "pointer"], this.C_Object, sql_ptr); + //执行sql + local sql_exec_result = Sq_CallFunc(S_Ptr("0x83F4326"), "int", ["pointer", "int"], this.C_Object, 1); + return sql_exec_result; + } + + + //获取服务端版本 + function GetServerVersion() { + return Sq_CallFunc(S_Ptr("0x83F460C"), "int", ["pointer"], this.C_Object); + } + //获取客户端版本 + function GetClientVersion() { + return Sq_CallFunc(S_Ptr("0x83F4622"), "int", ["pointer"], this.C_Object); + } +} + +class MysqlPool { + + // 用于存储数据库的 IP 地址 + db_ip = null; + // 用于存储数据库的端口号 + db_port = null; + // 用于存储数据库的名称 + db_name = null; + // 用于存储数据库的用户名 + db_username = null; + // 用于存储数据库的密码 + db_password = null; + + //连接池大小 + PoolSize = 10; + //连接编码 + Charset = "latin1"; + //连接池 + PoolList = null; + + constructor() { + PoolList = []; + getroottable()._MysqlPoolObject <- this; + } + + function GetInstance() { + // if (!(getroottable().rawin("_MysqlPoolObject"))) MysqlPool(); + MysqlPool(); + return getroottable()._MysqlPoolObject; + } + + //设置基础配置 + function SetBaseConfiguration(Ip, Port, Account, Password) { + db_ip = Str_Ptr(Ip); + db_port = Port; + db_name = Str_Ptr("taiwan_cain"); + db_username = Str_Ptr(Account); + db_password = Str_Ptr(Password); + } + + //初始化连接池 + function Init() { + for (local i = 0; i< PoolSize; i++) { + local Buffer = Mysql(db_ip, db_port, db_name, db_username, db_password); + Buffer.Exec_Sql(format("SET NAMES %s", Charset)); + PoolList.append(Buffer); + // print("创建了一条连接,编号: " + i + ",地址: " + Buffer + ", 指针地址: " + Buffer.C_Object); + } + } + + function GetConnect() { + local _Connect = PoolList.pop(); + if (_Connect.State == 0) { + _Connect.State = 1; + return _Connect; + } + } + + function PutConnect(_Connect) { + if (_Connect.State == 1) { + _Connect.State = 0; + PoolList.append(_Connect); + } + } +} \ No newline at end of file diff --git a/Dps_A/BaseClass/PvfClass/PvfItemClass.nut b/Dps_A/BaseClass/PvfClass/PvfItemClass.nut index e513d73..2700d3c 100644 --- a/Dps_A/BaseClass/PvfClass/PvfItemClass.nut +++ b/Dps_A/BaseClass/PvfClass/PvfItemClass.nut @@ -55,4 +55,9 @@ class PvfItem extends Base_C_Object { return PvfItem(Ret); } else return null; } + //Public + function GetPvfData(Idx) { + local Ret = Sq_CallFunc(S_Ptr("0x835FA32"), "pointer", ["pointer", "int"], Sq_CallFunc(S_Ptr("0x80CC19B"), "pointer", []), Idx); + return NativePointer(Ret); + } } \ No newline at end of file diff --git a/Dps_A/BaseClass/RedBlackTreeClass/RedBlackTreeClass.nut b/Dps_A/BaseClass/RedBlackTreeClass/RedBlackTreeClass.nut new file mode 100644 index 0000000..4f15f52 --- /dev/null +++ b/Dps_A/BaseClass/RedBlackTreeClass/RedBlackTreeClass.nut @@ -0,0 +1,280 @@ +/* +文件名:RedBlackTreeClass.nut +路径:Dps_A/BaseClass/RedBlackTreeClass/RedBlackTreeClass.nut +创建日期:2024-09-19 12:42 +文件用途:红黑树类 +*/ +// 红黑树节点类 +class RBTreeNode { + key = null; + time = null; + left = null; + right = null; + parent = null; + color = null; + Info = null; + constructor(key, func_info) { + this.key = key; + this.time = key; + this.Info = func_info; + this.left = null; + this.right = null; + this.parent = null; + this.color = "red"; + } + + function _tyoeof() { + return "RBTreeNode"; + } +} + +// 红黑树类 +class RedBlackTree { + nil = null; + root = null; + size = 0; + + function _tyoeof() { + return "RedBlackTree"; + } + + constructor() { + this.nil = RBTreeNode(null, null); + this.root = this.nil; + } + + function insert(key, func_info) { + local z = RBTreeNode(key, func_info); + local y = this.nil; + local x = this.root; + while (x != this.nil) { + y = x; + if (z.key< x.key) { + x = x.left; + } else { + x = x.right; + } + } + z.parent = y; + if (y == this.nil) { + this.root = z; + } else if (z.key< y.key) { + y.left = z; + } else { + y.right = z; + } + z.left = this.nil; + z.right = this.nil; + z.color = "red"; + this.insertFixup(z); + this.size++; + } + + function insertFixup(z) { + while (z.parent.color == "red") { + if (z.parent.parent && z.parent == z.parent.parent.left) { + local y = z.parent.parent.right; + if (y.color == "red") { + z.parent.color = "black"; + y.color = "black"; + z.parent.parent.color = "red"; + z = z.parent.parent; + } else { + if (z == z.parent.right) { + z = z.parent; + this.leftRotate(z); + } + z.parent.color = "black"; + z.parent.parent.color = "red"; + this.rightRotate(z.parent.parent); + } + } else { + if (z.parent.parent && z.parent.parent.left.color == "red") { + z.parent.color = "black"; + z.parent.parent.left.color = "black"; + z.parent.parent.color = "red"; + z = z.parent.parent; + } else { + if (z == z.parent.left) { + z = z.parent; + this.rightRotate(z); + } + z.parent.color = "black"; + if (z.parent.parent) z.parent.parent.color = "red"; + this.leftRotate(z.parent.parent); + } + } + } + this.root.color = "black"; + } + + function leftRotate(x) { + if (!x) return; + local y = x.right; + x.right = y.left; + if (y.left != this.nil) { + y.left.parent = x; + } + y.parent = x.parent; + if (x.parent == this.nil) { + this.root = y; + } else if (x == x.parent.left) { + x.parent.left = y; + } else { + x.parent.right = y; + } + y.left = x; + x.parent = y; + } + + function rightRotate(x) { + local y = x.left; + x.left = y.right; + if (y.right != this.nil) { + y.right.parent = x; + } + y.parent = x.parent; + if (x.parent == this.nil) { + this.root = y; + } else if (x == x.parent.left) { + x.parent.left = y; + } else { + x.parent.right = y; + } + y.right = x; + x.parent = y; + } + + + function minimum(...) { + local node = this.root; + if (vargv.len() > 0) node = vargv[0]; + while (node.left != this.nil) { + node = node.left; + } + return node; + } + + function transplant(u, v) { + if (u.parent == this.nil) { + this.root = v; + } else if (u == u.parent.left) { + u.parent.left = v; + } else { + u.parent.right = v; + } + v.parent = u.parent; + } + + function deleteFixup(x) { + while (x != this.root && x.color == "black") { + if (x == x.parent.left) { + local w = x.parent.right; + if (w.color == "red") { + w.color = "black"; + x.parent.color = "red"; + this.leftRotate(x.parent); + w = x.parent.right; + } + if (w.left.color == "black" && w.right.color == "black") { + w.color = "red"; + x = x.parent; + } else { + if (w.right.color == "black") { + w.left.color = "black"; + w.color = "red"; + this.rightRotate(w); + w = x.parent.right; + } + w.color = x.parent.color; + x.parent.color = "black"; + w.right.color = "black"; + this.leftRotate(x.parent); + x = this.root; + } + } else { + local w = x.parent.left; + if (w.color == "red") { + w.color = "black"; + x.parent.color = "red"; + this.rightRotate(x.parent); + w = x.parent.left; + } + if (w.right.color == "black" && w.left.color == "black") { + w.color = "red"; + x = x.parent; + } else { + if (w.left.color == "black") { + w.right.color = "black"; + w.color = "red"; + this.leftRotate(w); + w = x.parent.left; + } + w.color = x.parent.color; + x.parent.color = "black"; + w.left.color = "black"; + this.rightRotate(x.parent); + x = this.root; + } + } + } + x.color = "black"; + } + + function deleteNode(z) { + local y = z; + local yOriginalColor = y.color; + local x; + if (z.left == this.nil) { + x = z.right; + this.transplant(z, z.right); + } else if (z.right == this.nil) { + x = z.left; + this.transplant(z, z.left); + } else { + y = this.minimum(z.right); + yOriginalColor = y.color; + x = y.right; + if (y.parent == z) { + x.parent = y; + } else { + this.transplant(y, y.right); + y.right = z.right; + y.right.parent = y; + } + this.transplant(z, y); + y.left = z.left; + y.left.parent = y; + y.color = z.color; + } + if (yOriginalColor == "black") { + this.deleteFixup(x); + } + this.size--; + } + + function inorderTraversal(...) { + local node = this.root; + if (vargv.len() > 0) node = vargv[0]; + if (node == this.nil) { + return; + } + this.inorderTraversal(node.left); + print(node.key + "(" + node.color + ") "); + this.inorderTraversal(node.right); + } + + function getSize() { + return this.size; + } + + function pop() { + if (this.size <= 0) return null; + local z = this.minimum(); + if (z != this.nil) { + this.deleteNode(z); + return z; + } + return null; + } +} \ No newline at end of file diff --git a/Dps_A/BaseClass/TimerClass/TimerClass.nut b/Dps_A/BaseClass/TimerClass/TimerClass.nut new file mode 100644 index 0000000..b72a60b --- /dev/null +++ b/Dps_A/BaseClass/TimerClass/TimerClass.nut @@ -0,0 +1,58 @@ +/* +文件名:TimerClass.nut +路径:Dps_A/BaseClass/TimerClass/TimerClass.nut +创建日期:2024-09-19 12:39 +文件用途:定时器类 +*/ +class Timer { + //执行任务队列树 + Wait_Exec_Tree = null; + + constructor() { + Wait_Exec_Tree = RedBlackTree(); + + Cb_timer_dispatch_Func.rawset("__System__Timer__Event", Update.bindenv(this)); + } + + function Update() { + local Node = Wait_Exec_Tree.pop(); + if (!Node) { + return; + } + //取得函数体 + local Info = Node.Info; + //执行时间 + local exec_time = Node.time; + //如果没到执行时间,放回去,等待下次扫描 + if (time() <= exec_time) { + Wait_Exec_Tree.insert(exec_time, Node.Info); + return; + } + //函数 + local func = Info[0]; + //参数 + local func_args = Info[1]; + //执行函数 + func.acall(func_args); + } + + function SetTimeOut(target_func, delay_time, ...) { + local target_arg_list = []; + target_arg_list.push(getroottable()); + for (local i = 0; i< vargv.len(); i++) { + target_arg_list.push(vargv[i]); + } + //当前时间戳,单位:s + local time_sec = time(); + //计算下一次执行的时间 + local exec_time_sec = time_sec + (delay_time - 1); + + //设置下一次执行 + local func_info = []; + + func_info.push(target_func); + func_info.push(target_arg_list); + + _Timer_Object.Wait_Exec_Tree.insert(exec_time_sec, func_info); + } +} \ No newline at end of file diff --git a/Dps_A/BaseClass/AccountCargoClass/AccountCargoClass.nut b/Dps_A/BaseClass/UserAccountCargoClass/AccountCargoClass.nut similarity index 100% rename from Dps_A/BaseClass/AccountCargoClass/AccountCargoClass.nut rename to Dps_A/BaseClass/UserAccountCargoClass/AccountCargoClass.nut diff --git a/Dps_A/BaseClass/UserClass/UserClass.nut b/Dps_A/BaseClass/UserClass/UserClass.nut index 74fb8e4..e8c18d7 100644 --- a/Dps_A/BaseClass/UserClass/UserClass.nut +++ b/Dps_A/BaseClass/UserClass/UserClass.nut @@ -215,6 +215,19 @@ class User extends Base_C_Object { Sq_Packet_Send(this.C_Object, SPacket.C_Object); } + //发送弹窗公告包(可自定义文字需要客户端修复233dll搭配) + function SendNotiBox(Msg, Type) { + local Pack = Packet(); + Pack.Put_Header(0, 233); + Pack.Put_Byte(1); + Pack.Put_Byte(5); + Pack.Put_Int(Msg.len()); + Pack.Put_BinaryEx(Str_Ptr(Msg), Msg.len()); + Pack.Finalize(true); + Sq_CallFunc(S_Ptr("0x867B8FE"), "int", ["pointer", "int", "pointer"], this.C_Object, Type, Pack.C_Object); + Pack.Delete(); + } + //发送自定义包 function SendJso(Jso) { local Str = Json.Encode(Jso); diff --git a/Dps_A/BaseClass/WorldClass/WorldClass.nut b/Dps_A/BaseClass/WorldClass/WorldClass.nut index a51b668..f5c251d 100644 --- a/Dps_A/BaseClass/WorldClass/WorldClass.nut +++ b/Dps_A/BaseClass/WorldClass/WorldClass.nut @@ -204,4 +204,64 @@ class World { function SendPartyInfoToAll(Party) { Sq_GameWorld_SendPartyInfoToAll(Sq_Get_GameWorld(), Party.C_Object); } + + + + + + + + + + + //获取在线玩家列表表头 + function api_gameworld_user_map_begin() { + local Begin = Sq_New_Point(4); + Sq_CallFunc(S_Ptr("0x80F78A6"), "int", ["pointer", "pointer"], Begin, Ptr_Operation_A2S(Sq_Get_GameWorld(), 308)); + return Begin; + } + + //获取在线玩家列表表尾 + function api_gameworld_user_map_end() { + local End = Sq_New_Point(4); + Sq_CallFunc(S_Ptr("0x80F78CC"), "int", ["pointer", "pointer"], End, Ptr_Operation_A2S(Sq_Get_GameWorld(), 308)); + return End; + } + + //获取当前正在遍历的玩家 + function api_gameworld_user_map_get(it) { + local Buf = Sq_CallFunc(S_Ptr("0x80F7944"), "pointer", ["pointer"], it); + local Buf2 = Ptr_Operation_A2S(Buf, 4); + local Buf3 = Sq_ReadPoint(Buf2); + return Buf3; + } + + //迭代器指针自增 + function api_gameworld_user_map_next(it) { + local Next = Sq_New_Point(4); + Sq_CallFunc(S_Ptr("0x80F7906"), "pointer", ["pointer", "pointer"], Next, it); + Sq_Delete_Point(Next); + return Next; + } + //获取在线玩家列表 + function GetOnlinePlayer() { + local PlayerArr = []; + //遍历在线玩家列表 + local it = api_gameworld_user_map_begin(); + local end = api_gameworld_user_map_end(); + + //判断在线玩家列表遍历是否已结束 + while (Sq_CallFunc(S_Ptr("0x80F78F2"), "bool", ["pointer", "pointer"], it, end)) { + //当前被遍历到的玩家 + local user = api_gameworld_user_map_get(it); + local SUser = User(user); + if (SUser) PlayerArr.append(SUser); + //继续遍历下一个玩家 + api_gameworld_user_map_next(it); + } + + Sq_Delete_Point(it); + Sq_Delete_Point(end); + return PlayerArr; + } } \ No newline at end of file diff --git a/Dps_A/CallBack/Gm_Input.nut b/Dps_A/CallBack/Gm_Input.nut index b2fa8d8..510e7e6 100644 --- a/Dps_A/CallBack/Gm_Input.nut +++ b/Dps_A/CallBack/Gm_Input.nut @@ -153,13 +153,19 @@ Gm_InputFunc_Handle.Q <- function(SUser, CmdString) { }; Gm_InputFunc_Handle.FI <- function(SUser, CmdString) { - local PartyObj = SUser.GetParty(); - if (PartyObj) { - local Bfobj = PartyObj.GetBattleField(); - print(Bfobj.GetHellDifficulty()); - // print(n); - } + // local PartyObj = SUser.GetParty(); + // if (PartyObj) { + // local Bfobj = PartyObj.GetBattleField(); + // print(Bfobj.GetHellDifficulty()); + // // print(n); + // } + + SUser.SendNotiForColorAIdPacketMessage([ + [" → ", 0, [0xff, 0xff, 0xff]], + ["无色", 1, [255, 215, 0], 3037], + [" x" + (1).tostring(), 0, [0xff, 0xff, 0xff]] + ], 6); }; Gm_InputFunc_Handle.UINJ <- function(SUser, CmdString) { @@ -173,7 +179,7 @@ Gm_InputFunc_Handle.UINJ <- function(SUser, CmdString) { Pack.Put_Binary(Str); Pack.Finalize(true); SUser.Send(Pack); - Pack.Delete(); + Pack.Delocale(); }; Gm_InputFunc_Handle.T <- function(SUser, CmdString) { @@ -212,4 +218,137 @@ function Cb_gm_input(C_User, CmdString) { if (Str in Gm_InputFunc_Handle) { Gm_InputFunc_Handle[Str](SUser, CmdString); } -} \ No newline at end of file +} + +function TestIoP() { + local ret = suspend("no"); + local Io = IO("/dp_s/a.txt", "w+"); + for (local i = 0; i< 500000; i++) { + Io.Write("写入测试文本: " + i + "\n"); + if ((i % 5000) == 0) ret = suspend("no"); + } + Io.Close(); + + return "yes"; +} + +function TestThread(coro) { + local susparam = "noq"; + if (coro.getstatus() == "idle") susparam = coro.call(); + else if (coro.getstatus() == "suspended") susparam = coro.wakeup(); + + if (susparam == "no") { + Timer.SetTimeOut(TestThread, 0, coro); + } else { + print("文件书写完成"); + } +} + + +function TestL() { + print("注册 1 秒后执行") + Timer.SetTimeOut(TestL, 1); +} + +Gm_InputFunc_Handle.TTT <- function(SUser, CmdString) { + + + local md5 = MD5.GetFile("/dp_s/a.txt"); + print("Md5文本值: " + md5); + local Arr = []; + foreach(char in md5) { + Arr.append(char.tointeger()); + } + print("Md5字符值>>>"); + printT(Arr); + + + // local Io = IO("/dp_s/a.txt", "r+"); + // local Ret = Io.ReadBuffer(256); + // printT(Ret); + // Io.Close(); + + // local coro = newthread(TestIoP); + // Timer.SetTimeOut(TestThread, 0, coro); + // Timer.SetTimeOut(TestL, 1); + + // local FileObj = file("/dp_s/a.txt", "r+"); + + // local Arr = [0, 1]; + // local T = { + // TestWn = 666 + // }; + // // Arr.insert(0,getroottable()); + // Arr.insert(0, T); + // TestWn.acall(Arr); + + // sq_RunScript("测试加密脚本.sut"); + // local Opendir = Module.getExportByName(null, "opendir"); + // local Readdir = Module.getExportByName(null, "readdir"); + // local Closedir = Module.getExportByName(null, "closedir"); + // print("Opendir: " + Opendir); + // print("Readdir: " + Readdir); + // print("Closedir: " + Closedir); + + // local UserList = World.GetOnlinePlayer(); + + // foreach (SUserObj in UserList) { + // print(SUserObj.GetCharacLevel()); + // } + + // api_exec_delay_function(function() { + // print("先注册") + // }, 2); + + // api_exec_delay_function(function() { + // print("后注册") + // }, 5); + + + // local rbTree = RedBlackTree(); + // // rbTree.insert(10); + // // rbTree.insert(40); + // // rbTree.insert(20); + // // rbTree.insert(50); + // // rbTree.insert(30); + // // rbTree.insert(752); + // // rbTree.insert(54); + // // rbTree.insert(12); + // // rbTree.insert(787); + // // rbTree.insert(26); + // // rbTree.insert(278); + + // rbTree.inorderTraversal(); + + // local l = rbTree.pop(); + // print(">>>"); + // print("弹出值: " + l); + // print(">>>"); + // rbTree.inorderTraversal(); + + + // Timer.SetTimeOut(function() { + // print("注册 5 秒后执行") + // }, 5); + // Timer.SetTimeOut(function() { + // print("注册 3 秒后执行") + // }, 3); + // Timer.SetTimeOut(function() { + // print("注册 2 秒后执行") + // }, 2); +}; + +Gm_InputFunc_Handle.AAA <- function(SUser, CmdString) { + + //查询的sql语句 + local sql = "SELECT m_id,charac_name,lev,village,job,exp,Hp FROM charac_info WHERE charac_no = 1;"; + //查询的元素类型,按sql中的顺序 + local column_type_list = ["int", "string", "int", "int", "int", "int", "int"]; + local SqlObj = MysqlPool.GetInstance().GetConnect(); + local result = SqlObj.Select(sql, column_type_list); + + printT(result); + + MysqlPool.GetInstance().PutConnect(SqlObj); + +}; \ No newline at end of file diff --git a/Dps_A/CallBack/History_Log.nut b/Dps_A/CallBack/History_Log.nut index 06e931e..3577310 100644 --- a/Dps_A/CallBack/History_Log.nut +++ b/Dps_A/CallBack/History_Log.nut @@ -98,4 +98,11 @@ Cb_History_Log_Func["PCoin-"] <- function(SUser, Data) { foreach(_Index, Func in Cb_History_PCoinDown_Func) { Func(SUser, Data); } +} +//使用复活币事件 +if (!("Cb_History_ItemLock_Func" in getroottable())) Cb_History_ItemLock_Func <- {}; +Cb_History_Log_Func["ItemLock"] <- function(SUser, Data) { + foreach(_Index, Func in Cb_History_ItemLock_Func) { + Func(SUser, Data); + } } \ No newline at end of file diff --git a/Dps_A/Interface.nut b/Dps_A/Interface.nut deleted file mode 100644 index d176191..0000000 --- a/Dps_A/Interface.nut +++ /dev/null @@ -1,5 +0,0 @@ -try { - dofile("/dp_s/Main.nut"); -} catch (exception){ - -} \ No newline at end of file diff --git a/Dps_A/enum.nut b/Dps_A/enum.nut index a2c79ed..de4bd0c 100644 --- a/Dps_A/enum.nut +++ b/Dps_A/enum.nut @@ -27,7 +27,8 @@ enum RETTYPE { POINTER } -function sq_RunScript(Path) + +function printT(T) { - return dofile("/dp_s/" + Path); + Sq_OutPutTable(Json.Encode(T)); } \ No newline at end of file diff --git a/Dps_A/main.nut b/Dps_A/main.nut index 2a1305b..3193bb5 100644 --- a/Dps_A/main.nut +++ b/Dps_A/main.nut @@ -1,7 +1,17 @@ getroottable().DebugModelFlag <- false; //初始化插件 function InitPluginInfo() { - Sq_CreatCConnectPool(2, 4, "127.0.0.1", 3306, "game", "uu5!^%jg"); + //初始化定时器 + _Timer_Object <- Timer(); + + local PoolObj = MysqlPool.GetInstance(); + PoolObj.SetBaseConfiguration("127.0.0.1", 3306, "game", "uu5!^%jg"); + //连接池大小 + PoolObj.PoolSize = 10; + //初始化 + PoolObj.Init(); + + // Sq_CreatCConnectPool(2, 4, "127.0.0.1", 3306, "game", "uu5!^%jg"); Sq_CreatSocketConnect("192.168.200.24", "65109"); } @@ -17,6 +27,8 @@ function main() { PrintTag(); + GameManager.SetGameMaxLevel(95); + } diff --git a/a.txt b/a.txt new file mode 100644 index 0000000..b15f8f9 --- /dev/null +++ b/a.txt @@ -0,0 +1,3 @@ +abcdef +1561561561563156156adaa +asndKasdakdn阿基德拿手机卡迪那啊睡你的觉卡死 \ No newline at end of file diff --git a/folder-alias.json b/folder-alias.json index 196311c..7a7d74b 100644 --- a/folder-alias.json +++ b/folder-alias.json @@ -106,5 +106,26 @@ }, "Dps_A/CallBack/UserPartyGiveKick.nut": { "description": "踢出队伍" + }, + "Dps_A/BaseClass/MysqlClass": { + "description": "数据库类" + }, + "Dps_A/BaseClass/MemoryClass": { + "description": "内存类" + }, + "Dps_A/BaseClass/MoudleClass": { + "description": "模块类" + }, + "Dps_A/BaseClass/RedBlackTreeClass": { + "description": "红黑树类" + }, + "Dps_A/BaseClass/TimerClass": { + "description": "定时器类" + }, + "Dps_A/BaseClass/IOClass": { + "description": "Io类" + }, + "Dps_A/BaseClass/MD5Class": { + "description": "MD5类" } } \ No newline at end of file diff --git a/lib/libAurora.so b/lib/libAurora.so old mode 100644 new mode 100755 index e4bac10..139416e Binary files a/lib/libAurora.so and b/lib/libAurora.so differ diff --git a/测试加密脚本.sut b/测试加密脚本.sut new file mode 100644 index 0000000..c75194f Binary files /dev/null and b/测试加密脚本.sut differ