增加部分CG配置文件
修改README 增加部分CG加密函数翻译工作 增加MAIN函数
This commit is contained in:
parent
b0eaff1999
commit
e622f2904a
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,3 +3,5 @@ Tests/Network_test/debug
|
||||
/Tests/Network_test/log
|
||||
/test/Network_test/log
|
||||
/test/Network_test/debug
|
||||
/logs
|
||||
debug
|
||||
|
@ -1,3 +0,0 @@
|
||||
// 2017-07-23
|
||||
// cg 加解密函数
|
||||
package CGCrypt
|
7
Config/Conf.go
Normal file
7
Config/Conf.go
Normal file
@ -0,0 +1,7 @@
|
||||
// CrossGate配置文件快速解析
|
||||
// 依赖Ini
|
||||
// version 1.0 beta
|
||||
// by koangel
|
||||
// email: jackliu100@gmail.com
|
||||
// 2017/7/26
|
||||
package CGConfig
|
339
Crypt/CGCrypt.go
Normal file
339
Crypt/CGCrypt.go
Normal file
@ -0,0 +1,339 @@
|
||||
// CrossGate加解密库,用于游戏加解密
|
||||
// C语言翻译为GO语言
|
||||
// version 1.0 beta
|
||||
// by koangel
|
||||
// email: jackliu100@gmail.com
|
||||
// 2017/7/23
|
||||
package CGCrypt
|
||||
|
||||
import (
|
||||
"math"
|
||||
)
|
||||
|
||||
/*
|
||||
* used by bitstream routines
|
||||
*/
|
||||
var bitstream_maxbyte int
|
||||
var bitstream_bitaddr int
|
||||
var bitstream_buf []byte
|
||||
|
||||
/* initialize bitstream for output */
|
||||
func initOutputBitStream(buf []byte, buflen int) {
|
||||
bitstream_bitaddr = 0
|
||||
bitstream_maxbyte = buflen
|
||||
bitstream_buf = buf
|
||||
}
|
||||
|
||||
/* initialize bitstream for input */
|
||||
func initInputBitStream(buf []byte, buflen int) {
|
||||
bitstream_bitaddr = 0
|
||||
bitstream_maxbyte = buflen
|
||||
bitstream_buf = buf
|
||||
}
|
||||
|
||||
/*
|
||||
* read from bit stream. used only from 1 bit to 8 bits
|
||||
* this is a base routine
|
||||
*/
|
||||
func readInputBitStreamBody(bwidth int) uint32 {
|
||||
mod := bitstream_bitaddr % 8
|
||||
byteaddr := bitstream_bitaddr / 8
|
||||
/* return if excess */
|
||||
if byteaddr >= bitstream_maxbyte {
|
||||
return 0
|
||||
}
|
||||
|
||||
if bwidth >= 1 && bwidth <= 8 {
|
||||
b1 := uint((uint(bitstream_buf[byteaddr]) & uint(saacproto_modifymask_first[mod][bwidth])) >> uint(mod))
|
||||
b2 := uint((uint(bitstream_buf[byteaddr+1]) & uint(saacproto_modifymask_second[mod][bwidth])) << uint(8-mod))
|
||||
bitstream_bitaddr += bwidth
|
||||
return uint32(b1 | b2)
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* read from bit stream. used from 1 bit to 32 bits
|
||||
*
|
||||
*/
|
||||
func readInputBitStream(bwidth int) uint32 {
|
||||
if bwidth <= 0 {
|
||||
return 0
|
||||
} else if bwidth >= 1 && bwidth <= 8 {
|
||||
return readInputBitStreamBody(bwidth)
|
||||
} else if bwidth >= 9 && bwidth <= 16 {
|
||||
first := readInputBitStreamBody(8)
|
||||
second := readInputBitStreamBody(bwidth - 8)
|
||||
return first + (second << 8)
|
||||
} else if bwidth >= 17 && bwidth <= 24 {
|
||||
first := readInputBitStreamBody(8)
|
||||
second := readInputBitStreamBody(8)
|
||||
third := readInputBitStreamBody(bwidth - 8)
|
||||
return first + (second << 8) + (third << 16)
|
||||
} else if bwidth >= 25 && bwidth <= 32 {
|
||||
first := readInputBitStreamBody(8)
|
||||
second := readInputBitStreamBody(8)
|
||||
third := readInputBitStreamBody(8)
|
||||
forth := readInputBitStreamBody(bwidth - 8)
|
||||
return first + (second << 8) + (third << 16) + (forth << 24)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
/*
|
||||
* write to a bitstream. only used from 1 bit to 8 bits
|
||||
* this is a base routine.
|
||||
*/
|
||||
func writeOutputBitStreamBody(bwidth int, b byte) int {
|
||||
mod := bitstream_bitaddr % 8
|
||||
byteaddr := bitstream_bitaddr / 8
|
||||
/* return error if excess */
|
||||
if bitstream_maxbyte <= (byteaddr + 1) {
|
||||
return -1
|
||||
}
|
||||
bitstream_buf[byteaddr] &= byte(saacproto_modifymask_first[mod][bwidth])
|
||||
bitstream_buf[byteaddr] |= byte((int(b) << uint(mod)) & saacproto_modifymask_first[mod][bwidth])
|
||||
bitstream_buf[byteaddr+1] &= byte(saacproto_modifymask_second[mod][bwidth])
|
||||
bitstream_buf[byteaddr+1] |= byte((int(b) >> uint(8-mod)) & saacproto_modifymask_second[mod][bwidth])
|
||||
bitstream_bitaddr += bwidth
|
||||
return byteaddr + 1
|
||||
}
|
||||
|
||||
/*
|
||||
* write to a bitstream. used from 1 bits to 32 bits
|
||||
* returns -1 if error or buffer excession
|
||||
*/
|
||||
func writeOutputBitStream(bwidth int, dat uint) int {
|
||||
var ret int = 0
|
||||
if bwidth <= 0 {
|
||||
return -1
|
||||
} else if bwidth >= 1 && bwidth <= 8 {
|
||||
if writeOutputBitStreamBody(bwidth, byte(dat)) < 0 {
|
||||
return -1
|
||||
}
|
||||
} else if bwidth > 8 && bwidth <= 16 {
|
||||
if writeOutputBitStreamBody(8, byte(dat&0xff)) < 0 {
|
||||
return -1
|
||||
}
|
||||
if writeOutputBitStreamBody(bwidth-8, byte((dat>>8)&0xff)) < 0 {
|
||||
return -1
|
||||
}
|
||||
} else if bwidth > 16 && bwidth <= 24 {
|
||||
if writeOutputBitStreamBody(8, byte(dat&0xff)) < 0 {
|
||||
return -1
|
||||
}
|
||||
if writeOutputBitStreamBody(8, byte((dat>>8)&0xff)) < 0 {
|
||||
return -1
|
||||
}
|
||||
if writeOutputBitStreamBody(bwidth-16, byte((dat>>16)&0xff)) < 0 {
|
||||
return -1
|
||||
}
|
||||
} else if bwidth > 24 && bwidth <= 32 {
|
||||
if writeOutputBitStreamBody(8, byte(dat&0xff)) < 0 {
|
||||
return -1
|
||||
}
|
||||
if writeOutputBitStreamBody(8, byte((dat>>8)&0xff)) < 0 {
|
||||
return -1
|
||||
}
|
||||
if writeOutputBitStreamBody(8, byte((dat>>16)&0xff)) < 0 {
|
||||
return -1
|
||||
}
|
||||
if writeOutputBitStreamBody(bwidth-24, byte((dat>>24)&0xff)) < 0 {
|
||||
return -1
|
||||
}
|
||||
} else {
|
||||
return -1
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func Encode64(in []byte) []byte {
|
||||
var i int
|
||||
var use_bytes int
|
||||
var address int = 0
|
||||
len := len(in)
|
||||
out := make([]byte, len)
|
||||
out[0] = 0
|
||||
for i = 0; ; i += 3 {
|
||||
var in1 byte
|
||||
var in2 byte
|
||||
var in3 byte
|
||||
var out1 byte
|
||||
var out2 byte
|
||||
var out3 byte
|
||||
var out4 byte
|
||||
if i >= len {
|
||||
break
|
||||
}
|
||||
|
||||
if i >= (len - 1) { /* the last letter ( to be thrown away ) */
|
||||
in1 = in[i] & 0xff
|
||||
in2 = 0
|
||||
in3 = 0
|
||||
use_bytes = 2
|
||||
} else if i >= (len - 2) { /* the last 2 letters ( process only 1 byte)*/
|
||||
in1 = in[i] & 0xff
|
||||
in2 = in[i+1] & 0xff
|
||||
in3 = 0
|
||||
use_bytes = 3
|
||||
} else { /* there are more or equal than 3 letters */
|
||||
in1 = in[i] & 0xff
|
||||
in2 = in[i+1] & 0xff
|
||||
in3 = in[i+2] & 0xff
|
||||
use_bytes = 4
|
||||
}
|
||||
out1 = ((in1 & 0xfc) >> 2) & 0x3f
|
||||
out2 = ((in1 & 0x03) << 4) | (((in2 & 0xf0) >> 4) & 0x0f)
|
||||
out3 = ((in2 & 0x0f) << 2) | (((in3 & 0xc0) >> 6) & 0x03)
|
||||
out4 = (in3 & 0x3f)
|
||||
if use_bytes >= 2 {
|
||||
out[address] = base64_charset[out1]
|
||||
address++
|
||||
out[address] = base64_charset[out2]
|
||||
address++
|
||||
out[address] = 0
|
||||
}
|
||||
if use_bytes >= 3 {
|
||||
out[address] = base64_charset[out3]
|
||||
address++
|
||||
out[address] = 0
|
||||
}
|
||||
if use_bytes >= 4 {
|
||||
out[address] = base64_charset[out4]
|
||||
address++
|
||||
out[address] = 0
|
||||
}
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
func Decode64(in []byte) []byte {
|
||||
var in1 byte
|
||||
var in2 byte
|
||||
var in3 byte
|
||||
var in4 byte
|
||||
var out1 byte
|
||||
var out2 byte
|
||||
var out3 byte
|
||||
var use_bytes int
|
||||
var address int = 0
|
||||
|
||||
len := len(in)
|
||||
out := make([]byte, len)
|
||||
var i int
|
||||
for i = 0; ; i += 4 {
|
||||
if in[i] == 0 {
|
||||
break
|
||||
} else if in[i+1] == 0 { /* the last letter */
|
||||
break
|
||||
} else if in[i+2] == 0 { /* the last 2 letters */
|
||||
in1 = base64_reversecharset[in[i]]
|
||||
in2 = base64_reversecharset[in[i+1]]
|
||||
in3 = 0
|
||||
in4 = 0
|
||||
use_bytes = 1
|
||||
} else if in[i+3] == 0 { /* the last 3 letters */
|
||||
in1 = base64_reversecharset[in[i]]
|
||||
in2 = base64_reversecharset[in[i+1]]
|
||||
in3 = base64_reversecharset[in[i+2]]
|
||||
in4 = 0
|
||||
use_bytes = 2
|
||||
} else { /* process 4 letters */
|
||||
in1 = base64_reversecharset[in[i]]
|
||||
in2 = base64_reversecharset[in[i+1]]
|
||||
in3 = base64_reversecharset[in[i+2]]
|
||||
in4 = base64_reversecharset[in[i+3]]
|
||||
use_bytes = 3
|
||||
}
|
||||
out1 = (in1 << 2) | (((in2 & 0x30) >> 4) & 0x0f)
|
||||
out2 = ((in2 & 0x0f) << 4) | (((in3 & 0x3c) >> 2) & 0x0f)
|
||||
out3 = ((in3 & 0x03) << 6) | (in4 & 0x3f)
|
||||
if use_bytes >= 1 {
|
||||
out[address] = out1
|
||||
address++
|
||||
}
|
||||
if use_bytes >= 2 {
|
||||
out[address] = out2
|
||||
address++
|
||||
}
|
||||
if use_bytes >= 3 {
|
||||
out[address] = out3
|
||||
address++
|
||||
}
|
||||
if use_bytes != 3 {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
func abs(val int) int {
|
||||
return int(math.Abs(float64(val)))
|
||||
}
|
||||
|
||||
func jDecode(src []byte, key int) (decoded []byte, decodedlen int) {
|
||||
decoded = make([]byte, len(src))
|
||||
var sum byte = 0
|
||||
var i int
|
||||
var srclen = len(src)
|
||||
decodedlen = srclen - 1
|
||||
if decodedlen == 0 {
|
||||
return /* return error if length is 0 */
|
||||
}
|
||||
sum = src[abs(key%(decodedlen))]
|
||||
for i = 0; i < srclen; i++ {
|
||||
if abs((key % (decodedlen))) > i {
|
||||
decoded[i] = src[i] - byte(int(sum)*int((i*i)%3))
|
||||
}
|
||||
if abs((key % (decodedlen))) < i {
|
||||
decoded[i-1] = src[i] - byte(int(sum)*int((i*i)%7))
|
||||
}
|
||||
}
|
||||
for i = 0; i < decodedlen; i++ {
|
||||
if ((key % 7) == (i % 5)) || ((key % 2) == (i % 2)) {
|
||||
decoded[i] = ^decoded[i]
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func jEncode(src []byte, key int, maxencodedlen int) (encoded []byte, encodedlen int) {
|
||||
var sum byte = 0
|
||||
var i int
|
||||
srclen := len(src)
|
||||
encoded = make([]byte, srclen)
|
||||
encodedlen = srclen
|
||||
if srclen+1 > maxencodedlen {
|
||||
encodedlen = maxencodedlen
|
||||
for i = 0; i < encodedlen; i++ {
|
||||
encoded[i] = src[i]
|
||||
}
|
||||
}
|
||||
if srclen+1 <= maxencodedlen {
|
||||
encodedlen = srclen + 1
|
||||
for i = 0; i < srclen; i++ {
|
||||
sum = sum + src[i]
|
||||
if ((key % 7) == (i % 5)) || ((key % 2) == (i % 2)) {
|
||||
src[i] = ^src[i]
|
||||
}
|
||||
}
|
||||
for i = 0; i < encodedlen; i++ {
|
||||
if abs((key % srclen)) > i {
|
||||
encoded[i] = src[i] + byte(int(sum)*int((i*i)%3))
|
||||
}
|
||||
|
||||
if abs((key % srclen)) == i {
|
||||
encoded[i] = sum
|
||||
}
|
||||
if abs((key % srclen)) < i {
|
||||
encoded[i] = src[i-1] + byte(int(sum)*int((i*i)%7))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
342
Crypt/ConstData.go
Normal file
342
Crypt/ConstData.go
Normal file
@ -0,0 +1,342 @@
|
||||
// CrossGate静态数据
|
||||
// version 1.0 beta
|
||||
// by koangel
|
||||
// email: jackliu100@gmail.com
|
||||
// 2017/7/26
|
||||
package CGCrypt
|
||||
|
||||
var base64_reversecharset = []byte{
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 62, 0, 63, 0, 0,
|
||||
52, 53, 54, 55, 56, 57, 58, 59,
|
||||
60, 61, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 1, 2, 3, 4, 5, 6,
|
||||
7, 8, 9, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 21, 22,
|
||||
23, 24, 25, 0, 0, 0, 0, 0,
|
||||
0, 26, 27, 28, 29, 30, 31, 32,
|
||||
33, 34, 35, 36, 37, 38, 39, 40,
|
||||
41, 42, 43, 44, 45, 46, 47, 48,
|
||||
49, 50, 51, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
}
|
||||
|
||||
var base64_charset = []byte{
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
||||
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
|
||||
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
|
||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
||||
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
||||
'w', 'x', 'y', 'z', '0', '1', '2', '3',
|
||||
'4', '5', '6', '7', '8', '9', '+', '-',
|
||||
}
|
||||
|
||||
const (
|
||||
B00000000 = 0
|
||||
B00000001 = 1
|
||||
B00000010 = 2
|
||||
B00000011 = 3
|
||||
B00000100 = 4
|
||||
B00000101 = 5
|
||||
B00000110 = 6
|
||||
B00000111 = 7
|
||||
B00001000 = 8
|
||||
B00001001 = 9
|
||||
B00001010 = 10
|
||||
B00001011 = 11
|
||||
B00001100 = 12
|
||||
B00001101 = 13
|
||||
B00001110 = 14
|
||||
B00001111 = 15
|
||||
B00010000 = 16
|
||||
B00010001 = 17
|
||||
B00010010 = 18
|
||||
B00010011 = 19
|
||||
B00010100 = 20
|
||||
B00010101 = 21
|
||||
B00010110 = 22
|
||||
B00010111 = 23
|
||||
B00011000 = 24
|
||||
B00011001 = 25
|
||||
B00011010 = 26
|
||||
B00011011 = 27
|
||||
B00011100 = 28
|
||||
B00011101 = 29
|
||||
B00011110 = 30
|
||||
B00011111 = 31
|
||||
B00100000 = 32
|
||||
B00100001 = 33
|
||||
B00100010 = 34
|
||||
B00100011 = 35
|
||||
B00100100 = 36
|
||||
B00100101 = 37
|
||||
B00100110 = 38
|
||||
B00100111 = 39
|
||||
B00101000 = 40
|
||||
B00101001 = 41
|
||||
B00101010 = 42
|
||||
B00101011 = 43
|
||||
B00101100 = 44
|
||||
B00101101 = 45
|
||||
B00101110 = 46
|
||||
B00101111 = 47
|
||||
B00110000 = 48
|
||||
B00110001 = 49
|
||||
B00110010 = 50
|
||||
B00110011 = 51
|
||||
B00110100 = 52
|
||||
B00110101 = 53
|
||||
B00110110 = 54
|
||||
B00110111 = 55
|
||||
B00111000 = 56
|
||||
B00111001 = 57
|
||||
B00111010 = 58
|
||||
B00111011 = 59
|
||||
B00111100 = 60
|
||||
B00111101 = 61
|
||||
B00111110 = 62
|
||||
B00111111 = 63
|
||||
B01000000 = 64
|
||||
B01000001 = 65
|
||||
B01000010 = 66
|
||||
B01000011 = 67
|
||||
B01000100 = 68
|
||||
B01000101 = 69
|
||||
B01000110 = 70
|
||||
B01000111 = 71
|
||||
B01001000 = 72
|
||||
B01001001 = 73
|
||||
B01001010 = 74
|
||||
B01001011 = 75
|
||||
B01001100 = 76
|
||||
B01001101 = 77
|
||||
B01001110 = 78
|
||||
B01001111 = 79
|
||||
B01010000 = 80
|
||||
B01010001 = 81
|
||||
B01010010 = 82
|
||||
B01010011 = 83
|
||||
B01010100 = 84
|
||||
B01010101 = 85
|
||||
B01010110 = 86
|
||||
B01010111 = 87
|
||||
B01011000 = 88
|
||||
B01011001 = 89
|
||||
B01011010 = 90
|
||||
B01011011 = 91
|
||||
B01011100 = 92
|
||||
B01011101 = 93
|
||||
B01011110 = 94
|
||||
B01011111 = 95
|
||||
B01100000 = 96
|
||||
B01100001 = 97
|
||||
B01100010 = 98
|
||||
B01100011 = 99
|
||||
B01100100 = 100
|
||||
B01100101 = 101
|
||||
B01100110 = 102
|
||||
B01100111 = 103
|
||||
B01101000 = 104
|
||||
B01101001 = 105
|
||||
B01101010 = 106
|
||||
B01101011 = 107
|
||||
B01101100 = 108
|
||||
B01101101 = 109
|
||||
B01101110 = 110
|
||||
B01101111 = 111
|
||||
B01110000 = 112
|
||||
B01110001 = 113
|
||||
B01110010 = 114
|
||||
B01110011 = 115
|
||||
B01110100 = 116
|
||||
B01110101 = 117
|
||||
B01110110 = 118
|
||||
B01110111 = 119
|
||||
B01111000 = 120
|
||||
B01111001 = 121
|
||||
B01111010 = 122
|
||||
B01111011 = 123
|
||||
B01111100 = 124
|
||||
B01111101 = 125
|
||||
B01111110 = 126
|
||||
B01111111 = 127
|
||||
B10000000 = 128
|
||||
B10000001 = 129
|
||||
B10000010 = 130
|
||||
B10000011 = 131
|
||||
B10000100 = 132
|
||||
B10000101 = 133
|
||||
B10000110 = 134
|
||||
B10000111 = 135
|
||||
B10001000 = 136
|
||||
B10001001 = 137
|
||||
B10001010 = 138
|
||||
B10001011 = 139
|
||||
B10001100 = 140
|
||||
B10001101 = 141
|
||||
B10001110 = 142
|
||||
B10001111 = 143
|
||||
B10010000 = 144
|
||||
B10010001 = 145
|
||||
B10010010 = 146
|
||||
B10010011 = 147
|
||||
B10010100 = 148
|
||||
B10010101 = 149
|
||||
B10010110 = 150
|
||||
B10010111 = 151
|
||||
B10011000 = 152
|
||||
B10011001 = 153
|
||||
B10011010 = 154
|
||||
B10011011 = 155
|
||||
B10011100 = 156
|
||||
B10011101 = 157
|
||||
B10011110 = 158
|
||||
B10011111 = 159
|
||||
B10100000 = 160
|
||||
B10100001 = 161
|
||||
B10100010 = 162
|
||||
B10100011 = 163
|
||||
B10100100 = 164
|
||||
B10100101 = 165
|
||||
B10100110 = 166
|
||||
B10100111 = 167
|
||||
B10101000 = 168
|
||||
B10101001 = 169
|
||||
B10101010 = 170
|
||||
B10101011 = 171
|
||||
B10101100 = 172
|
||||
B10101101 = 173
|
||||
B10101110 = 174
|
||||
B10101111 = 175
|
||||
B10110000 = 176
|
||||
B10110001 = 177
|
||||
B10110010 = 178
|
||||
B10110011 = 179
|
||||
B10110100 = 180
|
||||
B10110101 = 181
|
||||
B10110110 = 182
|
||||
B10110111 = 183
|
||||
B10111000 = 184
|
||||
B10111001 = 185
|
||||
B10111010 = 186
|
||||
B10111011 = 187
|
||||
B10111100 = 188
|
||||
B10111101 = 189
|
||||
B10111110 = 190
|
||||
B10111111 = 191
|
||||
B11000000 = 192
|
||||
B11000001 = 193
|
||||
B11000010 = 194
|
||||
B11000011 = 195
|
||||
B11000100 = 196
|
||||
B11000101 = 197
|
||||
B11000110 = 198
|
||||
B11000111 = 199
|
||||
B11001000 = 200
|
||||
B11001001 = 201
|
||||
B11001010 = 202
|
||||
B11001011 = 203
|
||||
B11001100 = 204
|
||||
B11001101 = 205
|
||||
B11001110 = 206
|
||||
B11001111 = 207
|
||||
B11010000 = 208
|
||||
B11010001 = 209
|
||||
B11010010 = 210
|
||||
B11010011 = 211
|
||||
B11010100 = 212
|
||||
B11010101 = 213
|
||||
B11010110 = 214
|
||||
B11010111 = 215
|
||||
B11011000 = 216
|
||||
B11011001 = 217
|
||||
B11011010 = 218
|
||||
B11011011 = 219
|
||||
B11011100 = 220
|
||||
B11011101 = 221
|
||||
B11011110 = 222
|
||||
B11011111 = 223
|
||||
B11100000 = 224
|
||||
B11100001 = 225
|
||||
B11100010 = 226
|
||||
B11100011 = 227
|
||||
B11100100 = 228
|
||||
B11100101 = 229
|
||||
B11100110 = 230
|
||||
B11100111 = 231
|
||||
B11101000 = 232
|
||||
B11101001 = 233
|
||||
B11101010 = 234
|
||||
B11101011 = 235
|
||||
B11101100 = 236
|
||||
B11101101 = 237
|
||||
B11101110 = 238
|
||||
B11101111 = 239
|
||||
B11110000 = 240
|
||||
B11110001 = 241
|
||||
B11110010 = 242
|
||||
B11110011 = 243
|
||||
B11110100 = 244
|
||||
B11110101 = 245
|
||||
B11110110 = 246
|
||||
B11110111 = 247
|
||||
B11111000 = 248
|
||||
B11111001 = 249
|
||||
B11111010 = 250
|
||||
B11111011 = 251
|
||||
B11111100 = 252
|
||||
B11111101 = 253
|
||||
B11111110 = 254
|
||||
B11111111 = 255
|
||||
)
|
||||
|
||||
/* masks for first byte ( write )*/
|
||||
var saacproto_modifymask_first = [8][9]int{
|
||||
{0, B00000001, B00000011, B00000111, B00001111, B00011111, B00111111, B01111111, B11111111}, /* mod 0*/
|
||||
{0, B00000011, B00000111, B00001111, B00011111, B00111111, B01111111, B11111111, B11111111}, /* mod 1*/
|
||||
{0, B00000111, B00001111, B00011111, B00111111, B01111111, B11111111, B11111111, B11111111}, /* mod 2*/
|
||||
{0, B00001111, B00011111, B00111111, B01111111, B11111111, B11111111, B11111111, B11111111}, /* mod 3*/
|
||||
{0, B00011111, B00111111, B01111111, B11111111, B11111111, B11111111, B11111111, B11111111}, /* mod 4*/
|
||||
{0, B00111111, B01111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111}, /* mod 5*/
|
||||
{0, B01111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111}, /* mod 6*/
|
||||
{0, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111, B11111111}, /* mod 7*/
|
||||
}
|
||||
|
||||
/* masks for second byte ( write ) */
|
||||
var saacproto_modifymask_second = [8][9]int{
|
||||
{0, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000}, /* mod 0 */
|
||||
{0, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000001}, /* mod 1 */
|
||||
{0, B00000000, B00000000, B00000000, B00000000, B00000000, B00000000, B00000001, B00000011}, /* mod 2 */
|
||||
{0, B00000000, B00000000, B00000000, B00000000, B00000000, B00000001, B00000011, B00000111}, /* mod 3 */
|
||||
{0, B00000000, B00000000, B00000000, B00000000, B00000001, B00000011, B00000111, B00001111}, /* mod 4 */
|
||||
{0, B00000000, B00000000, B00000000, B00000001, B00000011, B00000111, B00001111, B00011111}, /* mod 5 */
|
||||
{0, B00000000, B00000000, B00000001, B00000011, B00000111, B00001111, B00011111, B00111111}, /* mod 6 */
|
||||
{0, B00000000, B00000001, B00000011, B00000111, B00001111, B00011111, B00111111, B01111111}, /* mod 7 */
|
||||
}
|
||||
|
||||
const (
|
||||
CHAR_SIZE = 256
|
||||
NODE_SIZE = 512
|
||||
JCODE_KEY = 4595
|
||||
BITS_LEN = 9 /* 9 bit lzw compression */
|
||||
)
|
17
README.md
17
README.md
@ -10,9 +10,26 @@ grapeCG is CrossGate Emulator for golang
|
||||
|
||||
发起本项目并不是为了盈利纯粹就是个人爱好,我比较喜欢这个游戏就深入研究了这个游戏在韩国地区泄露的服务端的协议,并模拟了基本的框架和加解密,目的是为了借CG这款游戏来完善在GO语言方面的游戏服务端框架编写。
|
||||
|
||||
本人曾经在2016年写过一个C#版本,暂不开源了,但是基本上是基于C++的,由于代码过多依赖C++而且未设计跨平台代码,感觉有点恶心,后来改为使用GO编写,所有算法纯GO,不依赖任何C/C++库。
|
||||
|
||||
当然主要目的是为了学习并深入研究GO语言可以实现多么轻量级的高并发模型。
|
||||
|
||||
|
||||
# 目前可以做什么
|
||||
|
||||
> 但是介于游戏版权方,本模拟器不会做任何实际战斗代码,只会逛地图,如果你自己愿意承担任何法律责任可以FORK过去自己添加代码,与本人无关。
|
||||
|
||||
目前本模拟器刚刚起步,应该只可以做到基本的逛地图,而本人并不是特别有空,所以也就是学习之用,慢慢完善吧。
|
||||
|
||||
如果框架编写差不多了,基本上也就不会再去维护和更新了。
|
||||
|
||||
# Res/Data缺少数据
|
||||
|
||||
由于数据文件过于庞大,建议自行找CrossGate泄漏服务端的DATA目录进去即可
|
||||
|
||||
# 依赖项目
|
||||
|
||||
* grapeNet (https://github.com/koangel/grapeNet)
|
||||
* seelog (https://github.com/cihub/seelog)
|
||||
* mysql (https://github.com/go-sql-driver/mysql)
|
||||
* macaron (https://github.com/go-macaron/macaron)
|
224
Res/setup.cf
Normal file
224
Res/setup.cf
Normal file
@ -0,0 +1,224 @@
|
||||
#blserv服务器地址
|
||||
blserv=127.0.0.1
|
||||
|
||||
#blserv服务器端口
|
||||
blservport=1072
|
||||
|
||||
battledebugmsg=0
|
||||
battlenum=1000
|
||||
CAinterval=500
|
||||
petmailmistakefile=data/petmailmistake.txt
|
||||
titleconfigfile=data/titleconfig.txt
|
||||
skillfile=data/skill.txt
|
||||
itemboxfile=store/itembox.txt
|
||||
protocolreadfrequency=200
|
||||
addressbookoffmesgnum=10000
|
||||
itemrecipefile=data/itemrecipe.txt
|
||||
activedungeonfile=store/activedungeon.txt
|
||||
|
||||
#数据库最大查询数
|
||||
dbquenum=1000
|
||||
|
||||
enemyfile=data/enemy.txt
|
||||
Itemdeletetime=2160
|
||||
netiointerval=200
|
||||
autodungeonmapdir=store/dungeon/
|
||||
quizfile=data/question.txt
|
||||
maketimefile=data/maketime.txt
|
||||
logdir=./log
|
||||
|
||||
#GMSV端口
|
||||
port=8030
|
||||
|
||||
tobossnpcfile=data/tobossnpc.txt
|
||||
timeoutsafetime=600
|
||||
timeoutchecktime=600
|
||||
effectfile=data/effect.txt
|
||||
itematomfile=data/itematom.txt
|
||||
logconfname=log.cf
|
||||
groupfile=data/group.txt
|
||||
guildmonstertextfile=data/guildmonstertext.txt
|
||||
|
||||
#GM密码设置
|
||||
chatmagicpasswd=nr
|
||||
|
||||
#物品数量
|
||||
objnum=50000
|
||||
|
||||
battlerebirthfile=data/battlerebirth.txt
|
||||
ridepetfile=data/ridepet.txt
|
||||
magicfile=data/magic.txt
|
||||
boltacnum=10
|
||||
|
||||
#允许上线人数
|
||||
fdnum=800
|
||||
|
||||
nocompress=1
|
||||
titlenamefile=data/titlename.txt
|
||||
servernumber=3
|
||||
#encountmemorynum=3000
|
||||
encountmemorynum=5000
|
||||
isaotrialcheck=1
|
||||
warpfile=data/warp.txt
|
||||
guisefile=data/guise.txt
|
||||
fctime=60
|
||||
loghour=0
|
||||
harborfile=data/harbor.txt
|
||||
endofgmsvfile=gmsv.end
|
||||
|
||||
#数据库用户名
|
||||
dbusername=newcg
|
||||
|
||||
#mapjobnum=1000
|
||||
mapjobnum=5000
|
||||
encountfile=data/encount.txt
|
||||
itemboxentrynum=1000
|
||||
#npccreatenum=6000
|
||||
npccreatenum=10000
|
||||
npcfile=data/npc.txt
|
||||
shipadjust=0
|
||||
fccount=5
|
||||
Onelooptime=100
|
||||
guildmonsteritemfile=data/guildmonsteritem.txt
|
||||
#acpasswd=love.java
|
||||
acpasswd=aho.java
|
||||
dungeonconffile=data/dungeonconf.txt
|
||||
isaocheck=1
|
||||
battlemapfile=data/map/battlemap.txt
|
||||
morphfile=data/morph.txt
|
||||
guildnum=50
|
||||
betaserver=0
|
||||
techareafile=data/techarea.txt
|
||||
|
||||
#GMSV服务器名字
|
||||
gameservname=Arzes
|
||||
#autodungeonnum=2500
|
||||
autodungeonnum=5000
|
||||
getSkillPopulationtime=9
|
||||
usememoryunitnum=1600000
|
||||
skillexpfile=data/skillexp.txt
|
||||
enemybasefile=data/enemybase.txt
|
||||
albumversion=4
|
||||
nologinrankdown=604800
|
||||
enemymsgfile=data/enemytalk.txt
|
||||
nodelay=1
|
||||
tech_areafile=store/dungeontech_area.txt
|
||||
techareamemorynum=1024
|
||||
filesearchnum=5000
|
||||
mlservport=9650
|
||||
golddeletetime=3600
|
||||
CharSaveinterval=1800
|
||||
checksyslogfile=log/syscheck.log
|
||||
itemingredientfile=data/itemingredient.txt
|
||||
acserv=gmsv
|
||||
saacreadnum=16
|
||||
macrouserdown=1
|
||||
chatmagiccdkeycheck=1
|
||||
mapjobfile=store/mapjob.txt
|
||||
guildmonsterfile=data/guildmonster.txt
|
||||
dungeonnpcfile=store/dungeonnpc.txt
|
||||
housetime=120
|
||||
mouselist=60
|
||||
reuseaddr=0
|
||||
mapdir=data/map/
|
||||
|
||||
#数据库服务器地址
|
||||
dbservname=127.0.0.1
|
||||
|
||||
fishfile=data/fish.txt
|
||||
#othercharnum=9000
|
||||
othercharnum=15000
|
||||
skilllvfile=data/skilllv.txt
|
||||
boxcontainsfile=data/boxcontains.txt
|
||||
badmsgtxtfile=data/badmsg.txt
|
||||
|
||||
#最大宠物数量
|
||||
petnum=10000
|
||||
|
||||
jobs_ancestryfile=data/jobsancestry.txt
|
||||
makeseqfile=store/makeseq.txt
|
||||
rssfile=data/rss.txt
|
||||
walkinterval=250
|
||||
itemautofile=data/itemauto.txt
|
||||
housenum=3000
|
||||
boltaclistnum=1000
|
||||
storedir=./store
|
||||
time_free=0
|
||||
petmailimpossiblefile=data/petmailimpossible.txt
|
||||
saacwritenum=2
|
||||
level_limit=120
|
||||
CDinterval=500
|
||||
lsgenlogfilename=
|
||||
authquenum=1000
|
||||
mlserv=127.0.0.1
|
||||
housecontractserver=1
|
||||
morphpuk2file=data/morphpuk2.txt
|
||||
msgtxtfile=data/msg.txt
|
||||
adjusttime=0
|
||||
dungeonencountfile=store/dungeonencount.txt
|
||||
enemyaifile=data/enemyai.txt
|
||||
itemmaterialfile=data/itemmaterial.txt
|
||||
materialmapdir=data/material_map/
|
||||
injuryfile=data/injury.txt
|
||||
rebirthfile=data/rebirth.txt
|
||||
guildmonsterrankfile=data/guildmonsterrank.txt
|
||||
mousecount=50
|
||||
allowerrornum=20
|
||||
acservport=9600
|
||||
maplogfile=log/mapid.log
|
||||
guildSaveInterval=60
|
||||
unfairuserdown=1
|
||||
fcwait=300
|
||||
shipfile=data/ship.txt
|
||||
guildmonsterfavoritefile=data/guildmonsterfavor.txt
|
||||
|
||||
#最大物品数量
|
||||
itemnum=60000
|
||||
|
||||
topdir=.
|
||||
jobsfile=data/jobs.txt
|
||||
itemfile=data/itemset.txt
|
||||
geneboxratefile=data/geneboxrate.txt
|
||||
|
||||
#数据库服务器密码
|
||||
dbpassword=woaini@65206973
|
||||
|
||||
#宠物删除时间
|
||||
Petdeletetime=3600
|
||||
|
||||
techfile=data/tech.txt
|
||||
usememoryunit=128
|
||||
|
||||
#调试等级
|
||||
debuglevel=3
|
||||
|
||||
petskillfile=data/petskill.txt
|
||||
houseroomfile=data/houseroom.txt
|
||||
borderfile=data/border.txt
|
||||
maptilefile=data/map/newmapset.txt
|
||||
breedingRoomSaveInterval=60
|
||||
debuggerfile=data/debugger.txt
|
||||
socketreuse=OFF
|
||||
extraipaddress=218.102.156.94
|
||||
|
||||
#数据库名字
|
||||
dbdatabasename=newcg-link1
|
||||
|
||||
housemapdir=store/house/
|
||||
|
||||
#游戏版本号
|
||||
version_conf=./version.conf
|
||||
|
||||
daychargetouse=10
|
||||
paymoneytoonce=100
|
||||
beforemoney=300
|
||||
beforehandgivemoney=1000000
|
||||
guildItemBoxSaveInterval=60
|
||||
profilelist=data/profile.txt
|
||||
profileversion=3
|
||||
aboutlist=data/aboutfile.txt
|
||||
aboutversion=2
|
||||
mailcharge=100
|
||||
|
||||
# http监听端口
|
||||
httpServerPort=1930
|
34
main.go
Normal file
34
main.go
Normal file
@ -0,0 +1,34 @@
|
||||
// CrossGeta主执行类
|
||||
// version 1.0 beta
|
||||
// by koangel
|
||||
// email: jackliu100@gmail.com
|
||||
// 2017/7/26
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/fatih/color"
|
||||
logger "github.com/koangel/grapeNet/Logger"
|
||||
)
|
||||
|
||||
func main() {
|
||||
color.Blue(`
|
||||
_______ _______ _______ ___ ___
|
||||
| __| | | __| | |
|
||||
| | | |__ | | |
|
||||
|_______|__|_|__|_______|\_____/
|
||||
`)
|
||||
|
||||
color.Green("==================================================")
|
||||
color.Green(" grapeCG Gmsv 1.0 beta")
|
||||
color.Green(" CrossGate Emulator for Golang")
|
||||
color.Green(" Author:Koangel")
|
||||
color.Green(" github - github.com/koangel/grapeCG")
|
||||
color.Green("==================================================")
|
||||
|
||||
RunDir := logger.GetCurrentDirectory()
|
||||
logger.BuildLogger(RunDir+"/logs", "main.log")
|
||||
|
||||
logger.INFO("============ CG System Init ============")
|
||||
logger.INFO("start load conf,wait...")
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user