mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-14 16:04:38 +01:00
partial courses rework
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
package channelserver
|
package channelserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"erupe-ce/common/stringsupport"
|
"erupe-ce/common/stringsupport"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"math"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -14,9 +14,6 @@ import (
|
|||||||
"erupe-ce/common/byteframe"
|
"erupe-ce/common/byteframe"
|
||||||
"erupe-ce/network/mhfpacket"
|
"erupe-ce/network/mhfpacket"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"golang.org/x/text/encoding/japanese"
|
|
||||||
"golang.org/x/text/transform"
|
|
||||||
"io/ioutil"
|
|
||||||
"math/bits"
|
"math/bits"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
)
|
)
|
||||||
@@ -77,40 +74,32 @@ func doAckSimpleFail(s *Session, ackHandle uint32, data []byte) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func updateRights(s *Session) {
|
func updateRights(s *Session) {
|
||||||
|
s.rights = uint32(0x0E)
|
||||||
|
s.server.db.QueryRow("SELECT rights FROM users u INNER JOIN characters c ON u.id = c.user_id WHERE c.id = $1", s.charID).Scan(&s.rights)
|
||||||
|
|
||||||
|
rights := make([]mhfpacket.ClientRight, 0)
|
||||||
|
tempRights := s.rights
|
||||||
|
for i := 30; i > 0; i-- {
|
||||||
|
right := uint32(math.Pow(2, float64(i)))
|
||||||
|
if tempRights-right < 0x80000000 {
|
||||||
|
if i == 1 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
rights = append(rights, mhfpacket.ClientRight{ID: uint16(i), Timestamp: 0x70DB59F0})
|
||||||
|
tempRights -= right
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rights = append(rights, mhfpacket.ClientRight{ID: 1, Timestamp: 0})
|
||||||
|
|
||||||
update := &mhfpacket.MsgSysUpdateRight{
|
update := &mhfpacket.MsgSysUpdateRight{
|
||||||
ClientRespAckHandle: 0,
|
ClientRespAckHandle: 0,
|
||||||
Bitfield: s.rights,
|
Bitfield: s.rights,
|
||||||
Rights: []mhfpacket.ClientRight{
|
Rights: rights,
|
||||||
{
|
|
||||||
ID: 1,
|
|
||||||
Timestamp: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ID: 2,
|
|
||||||
Timestamp: 0x5FEA1781,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ID: 3,
|
|
||||||
Timestamp: 0x5FEA1781,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UnkSize: 0,
|
UnkSize: 0,
|
||||||
}
|
}
|
||||||
s.QueueSendMHF(update)
|
s.QueueSendMHF(update)
|
||||||
}
|
}
|
||||||
|
|
||||||
func fixedSizeShiftJIS(text string, size int) []byte {
|
|
||||||
r := bytes.NewBuffer([]byte(text))
|
|
||||||
encoded, err := ioutil.ReadAll(transform.NewReader(r, japanese.ShiftJIS.NewEncoder()))
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
out := make([]byte, size)
|
|
||||||
copy(out, encoded)
|
|
||||||
out[len(out)-1] = 0
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
func handleMsgHead(s *Session, p mhfpacket.MHFPacket) {}
|
func handleMsgHead(s *Session, p mhfpacket.MHFPacket) {}
|
||||||
|
|
||||||
func handleMsgSysExtendThreshold(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgSysExtendThreshold(s *Session, p mhfpacket.MHFPacket) {
|
||||||
@@ -148,14 +137,11 @@ func handleMsgSysLogin(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rights := uint32(0x0E)
|
|
||||||
s.server.db.QueryRow("SELECT rights FROM users u INNER JOIN characters c ON u.id = c.user_id WHERE c.id = $1", pkt.CharID0).Scan(&rights)
|
|
||||||
|
|
||||||
s.Lock()
|
s.Lock()
|
||||||
s.charID = pkt.CharID0
|
s.charID = pkt.CharID0
|
||||||
s.rights = rights
|
|
||||||
s.token = pkt.LoginTokenString
|
s.token = pkt.LoginTokenString
|
||||||
s.Unlock()
|
s.Unlock()
|
||||||
|
updateRights(s)
|
||||||
bf := byteframe.NewByteFrame()
|
bf := byteframe.NewByteFrame()
|
||||||
bf.WriteUint32(uint32(Time_Current_Adjusted().Unix())) // Unix timestamp
|
bf.WriteUint32(uint32(Time_Current_Adjusted().Unix())) // Unix timestamp
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user