Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Grasscutter
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
ziqian zhang
Grasscutter
Commits
0ea3edb7
Commit
0ea3edb7
authored
3 years ago
by
Melledy
Browse files
Options
Downloads
Patches
Plain Diff
Fix concurrency related error while spawning monsters
parent
5f4afc8e
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/emu/grasscutter/game/GenshinScene.java
+4
-4
4 additions, 4 deletions
src/main/java/emu/grasscutter/game/GenshinScene.java
with
4 additions
and
4 deletions
src/main/java/emu/grasscutter/game/GenshinScene.java
+
4
−
4
View file @
0ea3edb7
...
@@ -144,7 +144,7 @@ public class GenshinScene {
...
@@ -144,7 +144,7 @@ public class GenshinScene {
return
this
.
entities
.
containsKey
(
entity
.
getId
());
return
this
.
entities
.
containsKey
(
entity
.
getId
());
}
}
public
void
addPlayer
(
GenshinPlayer
player
)
{
public
synchronized
void
addPlayer
(
GenshinPlayer
player
)
{
// Check if player already in
// Check if player already in
if
(
getPlayers
().
contains
(
player
))
{
if
(
getPlayers
().
contains
(
player
))
{
return
;
return
;
...
@@ -163,7 +163,7 @@ public class GenshinScene {
...
@@ -163,7 +163,7 @@ public class GenshinScene {
this
.
setupPlayerAvatars
(
player
);
this
.
setupPlayerAvatars
(
player
);
}
}
public
void
removePlayer
(
GenshinPlayer
player
)
{
public
synchronized
void
removePlayer
(
GenshinPlayer
player
)
{
// Remove player from scene
// Remove player from scene
getPlayers
().
remove
(
player
);
getPlayers
().
remove
(
player
);
player
.
setScene
(
null
);
player
.
setScene
(
null
);
...
@@ -367,7 +367,6 @@ public class GenshinScene {
...
@@ -367,7 +367,6 @@ public class GenshinScene {
entity
.
setSpawnEntry
(
entry
);
entity
.
setSpawnEntry
(
entry
);
toAdd
.
add
(
entity
);
toAdd
.
add
(
entity
);
this
.
addEntityDirectly
(
entity
);
// Add to spawned list
// Add to spawned list
this
.
getSpawnedEntities
().
add
(
entry
);
this
.
getSpawnedEntities
().
add
(
entry
);
...
@@ -377,14 +376,15 @@ public class GenshinScene {
...
@@ -377,14 +376,15 @@ public class GenshinScene {
for
(
GenshinEntity
entity
:
this
.
getEntities
().
values
())
{
for
(
GenshinEntity
entity
:
this
.
getEntities
().
values
())
{
if
(
entity
.
getSpawnEntry
()
!=
null
&&
!
visible
.
contains
(
entity
.
getSpawnEntry
()))
{
if
(
entity
.
getSpawnEntry
()
!=
null
&&
!
visible
.
contains
(
entity
.
getSpawnEntry
()))
{
toRemove
.
add
(
entity
);
toRemove
.
add
(
entity
);
this
.
removeEntityDirectly
(
entity
);
}
}
}
}
if
(
toAdd
.
size
()
>
0
)
{
if
(
toAdd
.
size
()
>
0
)
{
toAdd
.
stream
().
forEach
(
this
::
addEntityDirectly
);
this
.
broadcastPacket
(
new
PacketSceneEntityAppearNotify
(
toAdd
,
VisionType
.
VisionBorn
));
this
.
broadcastPacket
(
new
PacketSceneEntityAppearNotify
(
toAdd
,
VisionType
.
VisionBorn
));
}
}
if
(
toRemove
.
size
()
>
0
)
{
if
(
toRemove
.
size
()
>
0
)
{
toRemove
.
stream
().
forEach
(
this
::
removeEntityDirectly
);
this
.
broadcastPacket
(
new
PacketSceneEntityDisappearNotify
(
toRemove
,
VisionType
.
VisionRemove
));
this
.
broadcastPacket
(
new
PacketSceneEntityDisappearNotify
(
toRemove
,
VisionType
.
VisionRemove
));
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment