Commit 7356e583270cfda8e46be6118b508ed261de745d
1 parent
344d2df3
feat: 增加角色注销协议
Showing
4 changed files
with
26 additions
and
2 deletions
Show diff stats
src/ProtocolCode.lua
... | ... | @@ -65,6 +65,7 @@ actionCodes = { |
65 | 65 | Role_worldLineRouletteRpc = 146, --世界线抽轮盘 |
66 | 66 | Role_worldLineRewardRpc = 147, -- 世界线一键领取奖励 |
67 | 67 | Role_itemConvertDevilTicketRpc = 148, -- 兑换魔鬼训练营门票 |
68 | + Role_unRegisterRpc = 149, --注销账号 | |
68 | 69 | |
69 | 70 | Adv_startAdvRpc = 151, |
70 | 71 | Adv_startHangRpc = 152, | ... | ... |
src/actions/RoleAction.lua
... | ... | @@ -506,6 +506,20 @@ function _M.createRpc(agent, data) |
506 | 506 | return true |
507 | 507 | end |
508 | 508 | |
509 | +function _M.unRegisterRpc(agent, data) | |
510 | + local role = agent.role | |
511 | + local roleId = role:getProperty("id") | |
512 | + local msg = MsgPack.unpack(data) | |
513 | + local id = msg.roleId | |
514 | + if id ~= roleId then | |
515 | + return 0 | |
516 | + end | |
517 | + | |
518 | + if not roleUnRegister(roleId) then return 1 end | |
519 | + SendPacket(actionCodes.Role_unRegisterRpc, MsgPack.pack({})) | |
520 | + return true | |
521 | +end | |
522 | + | |
509 | 523 | function _M.changeNameRpc(agent, data) |
510 | 524 | local role = agent.role |
511 | 525 | local roleId = role:getProperty("id") | ... | ... |
src/models/Role.lua
src/utils/MysqlUtil.lua
... | ... | @@ -51,7 +51,7 @@ function delFriend(roleId, friendId) |
51 | 51 | end |
52 | 52 | |
53 | 53 | function roleExists(roleId) |
54 | - local res = mysqlproxy:query(string.format("SELECT `id` FROM `Role` WHERE `id` = %s", roleId)) | |
54 | + local res = mysqlproxy:query(string.format("SELECT `id` FROM `Role` WHERE `del` = 0 and `id` = %s", roleId)) | |
55 | 55 | if res["errno"] or not next(res) then |
56 | 56 | return false |
57 | 57 | end |
... | ... | @@ -60,10 +60,18 @@ function roleExists(roleId) |
60 | 60 | end |
61 | 61 | |
62 | 62 | function roleUidExists(uid) |
63 | - local res = mysqlproxy:query(string.format("SELECT `name` FROM `Role` WHERE `uid` = '%s'", uid)) | |
63 | + local res = mysqlproxy:query(string.format("SELECT `name` FROM `Role` WHERE `del` = 0 and `uid` = '%s'", uid)) | |
64 | 64 | if res["errno"] or not next(res) then |
65 | 65 | return false |
66 | 66 | end |
67 | 67 | |
68 | 68 | return true, res[1]["name"] |
69 | +end | |
70 | + | |
71 | +function roleUnRegister(roleId) | |
72 | + local res = mysqlproxy:query(string.format("UPDATE`Role` SET `del` = 1 WHERE `id` = %s", roleId)) | |
73 | + if res["errno"] or not next(res) then | |
74 | + return false | |
75 | + end | |
76 | + return true | |
69 | 77 | end |
70 | 78 | \ No newline at end of file | ... | ... |