Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
77fcce65
Commit
77fcce65
authored
Apr 21, 2022
by
Benjamin Elsdon
Browse files
Fixed null pointer exception in game only mode
PacketPlayerLoginRsp now creates the required QuerryCurrRegionHttpRsp itself.
parent
12755927
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/server/packet/send/PacketPlayerLoginRsp.java
View file @
77fcce65
package
emu.grasscutter.server.packet.send
;
package
emu.grasscutter.server.packet.send
;
import
com.google.protobuf.ByteString
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.PlayerLoginRspOuterClass.PlayerLoginRsp
;
import
emu.grasscutter.net.proto.PlayerLoginRspOuterClass.PlayerLoginRsp
;
import
emu.grasscutter.net.proto.QueryCurrRegionHttpRspOuterClass
;
import
emu.grasscutter.net.proto.RegionInfoOuterClass.RegionInfo
;
import
emu.grasscutter.net.proto.RegionInfoOuterClass.RegionInfo
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.utils.FileUtils
;
import
java.io.File
;
import
java.net.URL
;
import
java.util.Base64
;
public
class
PacketPlayerLoginRsp
extends
GenshinPacket
{
public
class
PacketPlayerLoginRsp
extends
GenshinPacket
{
private
static
QueryCurrRegionHttpRspOuterClass
.
QueryCurrRegionHttpRsp
regionCache
;
public
PacketPlayerLoginRsp
(
GameSession
session
)
{
public
PacketPlayerLoginRsp
(
GameSession
session
)
{
super
(
PacketOpcodes
.
PlayerLoginRsp
,
1
);
super
(
PacketOpcodes
.
PlayerLoginRsp
,
1
);
this
.
setUseDispatchKey
(
true
);
this
.
setUseDispatchKey
(
true
);
RegionInfo
info
=
Grasscutter
.
getDispatchServer
().
getCurrRegion
().
getRegionInfo
();
RegionInfo
info
;
if
(
Grasscutter
.
getConfig
().
RunMode
.
equalsIgnoreCase
(
"GAME_ONLY"
))
{
if
(
regionCache
==
null
)
{
try
{
File
file
=
new
File
(
Grasscutter
.
getConfig
().
DATA_FOLDER
+
"query_cur_region.txt"
);
String
query_cur_region
=
""
;
if
(
file
.
exists
())
{
query_cur_region
=
new
String
(
FileUtils
.
read
(
file
));
}
else
{
Grasscutter
.
getLogger
().
warn
(
"query_cur_region not found! Using default current region."
);
}
byte
[]
decodedCurRegion
=
Base64
.
getDecoder
().
decode
(
query_cur_region
);
QueryCurrRegionHttpRspOuterClass
.
QueryCurrRegionHttpRsp
regionQuery
=
QueryCurrRegionHttpRspOuterClass
.
QueryCurrRegionHttpRsp
.
parseFrom
(
decodedCurRegion
);
RegionInfo
serverRegion
=
regionQuery
.
getRegionInfo
().
toBuilder
()
.
setIp
((
Grasscutter
.
getConfig
().
getGameServerOptions
().
PublicIp
.
isEmpty
()
?
Grasscutter
.
getConfig
().
getGameServerOptions
().
Ip
:
Grasscutter
.
getConfig
().
getGameServerOptions
().
PublicIp
))
.
setPort
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
Port
)
.
setSecretKey
(
ByteString
.
copyFrom
(
FileUtils
.
read
(
Grasscutter
.
getConfig
().
KEY_FOLDER
+
"dispatchSeed.bin"
)))
.
build
();
regionCache
=
regionQuery
.
toBuilder
().
setRegionInfo
(
serverRegion
).
build
();
}
catch
(
Exception
e
)
{
Grasscutter
.
getLogger
().
error
(
"Error while initializing region cache!"
,
e
);
}
}
info
=
regionCache
.
getRegionInfo
();
}
else
{
info
=
Grasscutter
.
getDispatchServer
().
getCurrRegion
().
getRegionInfo
();
}
PlayerLoginRsp
p
=
PlayerLoginRsp
.
newBuilder
()
PlayerLoginRsp
p
=
PlayerLoginRsp
.
newBuilder
()
.
setIsUseAbilityHash
(
true
)
// true
.
setIsUseAbilityHash
(
true
)
// true
.
setAbilityHashCode
(
1844674
)
// 1844674
.
setAbilityHashCode
(
1844674
)
// 1844674
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment