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
3ea9e157
Commit
3ea9e157
authored
Apr 18, 2022
by
Melledy
Browse files
Make co-op players spawn into the host's scene too
parent
dd8d1752
Changes
1
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/managers/MultiplayerManager.java
View file @
3ea9e157
...
@@ -58,25 +58,25 @@ public class MultiplayerManager {
...
@@ -58,25 +58,25 @@ public class MultiplayerManager {
target
.
sendPacket
(
new
PacketPlayerApplyEnterMpNotify
(
player
));
target
.
sendPacket
(
new
PacketPlayerApplyEnterMpNotify
(
player
));
}
}
public
void
applyEnterMpReply
(
GenshinPlayer
p
layer
,
int
applyUid
,
boolean
isAgreed
)
{
public
void
applyEnterMpReply
(
GenshinPlayer
hostP
layer
,
int
applyUid
,
boolean
isAgreed
)
{
// Checks
// Checks
CoopRequest
request
=
p
layer
.
getCoopRequests
().
get
(
applyUid
);
CoopRequest
request
=
hostP
layer
.
getCoopRequests
().
get
(
applyUid
);
if
(
request
==
null
||
request
.
isExpired
())
{
if
(
request
==
null
||
request
.
isExpired
())
{
return
;
return
;
}
}
// Remove now that we are handling it
// Remove now that we are handling it
GenshinPlayer
requester
=
request
.
getRequester
();
GenshinPlayer
requester
=
request
.
getRequester
();
p
layer
.
getCoopRequests
().
remove
(
applyUid
);
hostP
layer
.
getCoopRequests
().
remove
(
applyUid
);
// Sanity checks - Dont let player join if already in multiplayer
// Sanity checks - Dont let
the requesting
player join if
they are
already in multiplayer
if
(
requester
.
getWorld
().
isMultiplayer
())
{
if
(
requester
.
getWorld
().
isMultiplayer
())
{
request
.
getRequester
().
sendPacket
(
new
PacketPlayerApplyEnterMpResultNotify
(
p
layer
,
false
,
PlayerApplyEnterMpReason
.
PlayerCannotEnterMp
));
request
.
getRequester
().
sendPacket
(
new
PacketPlayerApplyEnterMpResultNotify
(
hostP
layer
,
false
,
PlayerApplyEnterMpReason
.
PlayerCannotEnterMp
));
return
;
return
;
}
}
// Response packet
// Response packet
request
.
getRequester
().
sendPacket
(
new
PacketPlayerApplyEnterMpResultNotify
(
p
layer
,
isAgreed
,
PlayerApplyEnterMpReason
.
PlayerJudge
));
request
.
getRequester
().
sendPacket
(
new
PacketPlayerApplyEnterMpResultNotify
(
hostP
layer
,
isAgreed
,
PlayerApplyEnterMpReason
.
PlayerJudge
));
// Declined
// Declined
if
(!
isAgreed
)
{
if
(!
isAgreed
)
{
...
@@ -84,24 +84,27 @@ public class MultiplayerManager {
...
@@ -84,24 +84,27 @@ public class MultiplayerManager {
}
}
// Success
// Success
if
(!
p
layer
.
getWorld
().
isMultiplayer
())
{
if
(!
hostP
layer
.
getWorld
().
isMultiplayer
())
{
// Player not in multiplayer, create multiplayer world
// Player not in multiplayer, create multiplayer world
World
world
=
new
World
(
p
layer
,
true
);
World
world
=
new
World
(
hostP
layer
,
true
);
// Add
// Add
world
.
addPlayer
(
p
layer
);
world
.
addPlayer
(
hostP
layer
);
// Rejoin packet
// Rejoin packet
p
layer
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
p
layer
,
p
layer
,
EnterType
.
EnterSelf
,
EnterReason
.
HostFromSingleToMp
,
p
layer
.
getScene
().
getId
(),
p
layer
.
getPos
()));
hostP
layer
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
hostP
layer
,
hostP
layer
,
EnterType
.
EnterSelf
,
EnterReason
.
HostFromSingleToMp
,
hostP
layer
.
getScene
().
getId
(),
hostP
layer
.
getPos
()));
}
}
// Make requester join
// Make requester join
player
.
getWorld
().
addPlayer
(
requester
);
hostPlayer
.
getWorld
().
addPlayer
(
requester
);
// Set scene pos and id of requester to the host player's
requester
.
getPos
().
set
(
hostPlayer
.
getPos
());
requester
.
getRotation
().
set
(
hostPlayer
.
getRotation
());
requester
.
setSceneId
(
hostPlayer
.
getSceneId
());
// Packet
// Packet
requester
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
requester
,
player
,
EnterType
.
EnterOther
,
EnterReason
.
TeamJoin
,
player
.
getScene
().
getId
(),
player
.
getPos
()));
requester
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
requester
,
hostPlayer
,
EnterType
.
EnterOther
,
EnterReason
.
TeamJoin
,
hostPlayer
.
getScene
().
getId
(),
hostPlayer
.
getPos
()));
requester
.
getPos
().
set
(
player
.
getPos
());
requester
.
getRotation
().
set
(
player
.
getRotation
());
}
}
public
boolean
leaveCoop
(
GenshinPlayer
player
)
{
public
boolean
leaveCoop
(
GenshinPlayer
player
)
{
...
...
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