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
0ea3edb7
Commit
0ea3edb7
authored
Apr 25, 2022
by
Melledy
Browse files
Fix concurrency related error while spawning monsters
parent
5f4afc8e
Changes
1
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/GenshinScene.java
View file @
0ea3edb7
...
...
@@ -144,7 +144,7 @@ public class GenshinScene {
return
this
.
entities
.
containsKey
(
entity
.
getId
());
}
public
void
addPlayer
(
GenshinPlayer
player
)
{
public
synchronized
void
addPlayer
(
GenshinPlayer
player
)
{
// Check if player already in
if
(
getPlayers
().
contains
(
player
))
{
return
;
...
...
@@ -163,7 +163,7 @@ public class GenshinScene {
this
.
setupPlayerAvatars
(
player
);
}
public
void
removePlayer
(
GenshinPlayer
player
)
{
public
synchronized
void
removePlayer
(
GenshinPlayer
player
)
{
// Remove player from scene
getPlayers
().
remove
(
player
);
player
.
setScene
(
null
);
...
...
@@ -367,7 +367,6 @@ public class GenshinScene {
entity
.
setSpawnEntry
(
entry
);
toAdd
.
add
(
entity
);
this
.
addEntityDirectly
(
entity
);
// Add to spawned list
this
.
getSpawnedEntities
().
add
(
entry
);
...
...
@@ -377,14 +376,15 @@ public class GenshinScene {
for
(
GenshinEntity
entity
:
this
.
getEntities
().
values
())
{
if
(
entity
.
getSpawnEntry
()
!=
null
&&
!
visible
.
contains
(
entity
.
getSpawnEntry
()))
{
toRemove
.
add
(
entity
);
this
.
removeEntityDirectly
(
entity
);
}
}
if
(
toAdd
.
size
()
>
0
)
{
toAdd
.
stream
().
forEach
(
this
::
addEntityDirectly
);
this
.
broadcastPacket
(
new
PacketSceneEntityAppearNotify
(
toAdd
,
VisionType
.
VisionBorn
));
}
if
(
toRemove
.
size
()
>
0
)
{
toRemove
.
stream
().
forEach
(
this
::
removeEntityDirectly
);
this
.
broadcastPacket
(
new
PacketSceneEntityDisappearNotify
(
toRemove
,
VisionType
.
VisionRemove
));
}
}
...
...
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