mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-14 07:55:33 +01:00
handle alliance kicking
This commit is contained in:
@@ -3,9 +3,9 @@ package mhfpacket
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"erupe-ce/network/clientctx"
|
|
||||||
"erupe-ce/network"
|
|
||||||
"erupe-ce/common/byteframe"
|
"erupe-ce/common/byteframe"
|
||||||
|
"erupe-ce/network"
|
||||||
|
"erupe-ce/network/clientctx"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OperateJointAction uint8
|
type OperateJointAction uint8
|
||||||
@@ -22,7 +22,7 @@ type MsgMhfOperateJoint struct {
|
|||||||
AllianceID uint32
|
AllianceID uint32
|
||||||
GuildID uint32
|
GuildID uint32
|
||||||
Action OperateJointAction
|
Action OperateJointAction
|
||||||
UnkData []byte
|
UnkData *byteframe.ByteFrame
|
||||||
}
|
}
|
||||||
|
|
||||||
// Opcode returns the ID associated with this packet type.
|
// Opcode returns the ID associated with this packet type.
|
||||||
@@ -36,8 +36,8 @@ func (m *MsgMhfOperateJoint) Parse(bf *byteframe.ByteFrame, ctx *clientctx.Clien
|
|||||||
m.AllianceID = bf.ReadUint32()
|
m.AllianceID = bf.ReadUint32()
|
||||||
m.GuildID = bf.ReadUint32()
|
m.GuildID = bf.ReadUint32()
|
||||||
m.Action = OperateJointAction(bf.ReadUint8())
|
m.Action = OperateJointAction(bf.ReadUint8())
|
||||||
m.UnkData = bf.DataFromCurrent()
|
m.UnkData = byteframe.NewByteFrameFromBytes(bf.DataFromCurrent())
|
||||||
bf.Seek(int64(len(bf.Data()) - 2), 0)
|
bf.Seek(int64(len(bf.Data())-2), 0)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -157,6 +157,26 @@ func handleMsgMhfOperateJoint(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
)
|
)
|
||||||
doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4))
|
doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4))
|
||||||
}
|
}
|
||||||
|
case mhfpacket.OPERATE_JOINT_KICK:
|
||||||
|
if alliance.ParentGuild.LeaderCharID == s.charID {
|
||||||
|
_ = pkt.UnkData.ReadUint8()
|
||||||
|
kickedGuildID := pkt.UnkData.ReadUint32()
|
||||||
|
if kickedGuildID == alliance.SubGuild1ID && alliance.SubGuild2ID > 0 {
|
||||||
|
s.server.db.Exec(`UPDATE guild_alliances SET sub1_id = sub2_id, sub2_id = NULL WHERE id = $1`, alliance.ID)
|
||||||
|
} else if kickedGuildID == alliance.SubGuild1ID && alliance.SubGuild2ID == 0 {
|
||||||
|
s.server.db.Exec(`UPDATE guild_alliances SET sub1_id = NULL WHERE id = $1`, alliance.ID)
|
||||||
|
} else {
|
||||||
|
s.server.db.Exec(`UPDATE guild_alliances SET sub2_id = NULL WHERE id = $1`, alliance.ID)
|
||||||
|
}
|
||||||
|
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
||||||
|
} else {
|
||||||
|
s.logger.Warn(
|
||||||
|
"Non-owner of alliance attempted kick",
|
||||||
|
zap.Uint32("CharID", s.charID),
|
||||||
|
zap.Uint32("AllyID", alliance.ID),
|
||||||
|
)
|
||||||
|
doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4))
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
||||||
panic(fmt.Sprintf("Unhandled operate joint action '%d'", pkt.Action))
|
panic(fmt.Sprintf("Unhandled operate joint action '%d'", pkt.Action))
|
||||||
|
|||||||
Reference in New Issue
Block a user