diff --git a/src/api_s2c/user/ApiLogin.ts b/src/api_s2c/user/ApiLogin.ts index 33ef532..6b54a15 100644 --- a/src/api_s2c/user/ApiLogin.ts +++ b/src/api_s2c/user/ApiLogin.ts @@ -132,6 +132,9 @@ async function doLogin(call: ApiCall) { //await G.redis.set('user', gud.uid, gud); await initGud(gud.uid, gud); + // 修复公会id + await fixUnionData(gud); + //记录玩家所在的进程,change: 更换到处理完踢线操作在写入。 // setUidProcessId(gud.uid); @@ -278,4 +281,19 @@ async function LoginFun(call: ApiCall) { // // G.mongodb.collection("hero").findOneAndUpdate({_id: i._id}, {$set: {shiwu: shiwuChange}}) // }) -// } \ No newline at end of file +// } + +// 修复玩家退出公会 但是gud中残留公会id +async function fixUnionData(gud: ResLogin["gud"]) { + if (gud.ghId) { + let ghdata = await G.mongodb.collection("gonghui").findOne( + {_id: G.mongodb.conversionId(gud.ghId), 'players.uid': gud.uid} + ) + if (!ghdata) { + gud.ghId = ""; + gud.ghName = ""; + gud.ghLevel = 0; + PlayerFun.changeAttr(gud.uid, {ghId: '', ghLevel: 0}) + } + } +} \ No newline at end of file