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
36b71d01
Commit
36b71d01
authored
Aug 22, 2022
by
AnimeGitB
Browse files
Clean up some Position usage to avoid unneccessary unpacks
parent
dbf2b91d
Changes
7
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherObject.java
View file @
36b71d01
...
...
@@ -13,7 +13,6 @@ import emu.grasscutter.net.proto.InteractTypeOuterClass.InteractType;
import
emu.grasscutter.net.proto.GadgetInteractReqOuterClass.GadgetInteractReq
;
import
emu.grasscutter.net.proto.SceneGadgetInfoOuterClass.SceneGadgetInfo
;
import
emu.grasscutter.server.packet.send.PacketGadgetInteractRsp
;
import
emu.grasscutter.utils.Position
;
import
emu.grasscutter.utils.Utils
;
public
class
GadgetGatherObject
extends
GadgetContent
{
...
...
@@ -69,11 +68,10 @@ public class GadgetGatherObject extends GadgetContent {
scene
,
player
,
GameData
.
getItemDataMap
().
get
(
itemId
),
new
Position
(
getGadget
().
getPosition
().
getX
()
+
(
float
)
Utils
.
randomRange
(
1
,
5
)
/
5
,
getGadget
().
getPosition
().
getY
()
+
2
f
,
getGadget
().
getPosition
().
getZ
()
+
(
float
)
Utils
.
randomRange
(
1
,
5
)
/
5
),
getGadget
().
getPosition
().
clone
()
.
addY
(
2
f
)
.
addX
(
Utils
.
randomFloatRange
(-
1
f
,
1
f
))
.
addZ
(
Utils
.
randomFloatRange
(-
1
f
,
1
f
)),
1
,
true
);
...
...
src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherPoint.java
View file @
36b71d01
...
...
@@ -11,7 +11,6 @@ import emu.grasscutter.game.world.Scene;
import
emu.grasscutter.net.proto.GatherGadgetInfoOuterClass.GatherGadgetInfo
;
import
emu.grasscutter.net.proto.GadgetInteractReqOuterClass.GadgetInteractReq
;
import
emu.grasscutter.net.proto.SceneGadgetInfoOuterClass.SceneGadgetInfo
;
import
emu.grasscutter.utils.Position
;
import
emu.grasscutter.utils.Utils
;
public
class
GadgetGatherPoint
extends
GadgetContent
{
...
...
@@ -64,11 +63,10 @@ public class GadgetGatherPoint extends GadgetContent {
scene
,
player
,
GameData
.
getItemDataMap
().
get
(
itemId
),
new
Position
(
getGadget
().
getPosition
().
getX
()
+
(
float
)
Utils
.
randomRange
(
1
,
5
)
/
5
,
getGadget
().
getPosition
().
getY
()
+
2
f
,
getGadget
().
getPosition
().
getZ
()
+
(
float
)
Utils
.
randomRange
(
1
,
5
)
/
5
),
getGadget
().
getPosition
().
clone
()
.
addY
(
2
f
)
.
addX
(
Utils
.
randomFloatRange
(-
1
f
,
1
f
))
.
addZ
(
Utils
.
randomFloatRange
(-
1
f
,
1
f
)),
1
,
true
);
...
...
src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java
View file @
36b71d01
...
...
@@ -25,11 +25,7 @@ public class MapMark {
public
MapMark
(
MapMarkPoint
mapMarkPoint
)
{
this
.
sceneId
=
mapMarkPoint
.
getSceneId
();
this
.
name
=
mapMarkPoint
.
getName
();
this
.
position
=
new
Position
(
mapMarkPoint
.
getPos
().
getX
(),
mapMarkPoint
.
getPos
().
getY
(),
mapMarkPoint
.
getPos
().
getZ
()
);
this
.
position
=
new
Position
(
mapMarkPoint
.
getPos
());
this
.
mapMarkPointType
=
mapMarkPoint
.
getPointType
();
this
.
monsterId
=
mapMarkPoint
.
getMonsterId
();
this
.
mapMarkFromType
=
mapMarkPoint
.
getFromType
();
...
...
src/main/java/emu/grasscutter/game/managers/stamina/StaminaManager.java
View file @
36b71d01
...
...
@@ -497,11 +497,7 @@ public class StaminaManager extends BasePlayerManager {
}
}
previousState
=
currentState
;
previousCoordinates
=
new
Position
(
currentCoordinates
.
getX
(),
currentCoordinates
.
getY
(),
currentCoordinates
.
getZ
()
);
previousCoordinates
=
currentCoordinates
.
clone
();
}
}
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerPersonalSceneJumpReq.java
View file @
36b71d01
...
...
@@ -17,19 +17,17 @@ public class HandlerPersonalSceneJumpReq extends PacketHandler {
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
PersonalSceneJumpReq
req
=
PersonalSceneJumpReq
.
parseFrom
(
payload
);
var
player
=
session
.
getPlayer
();
// get the scene point
String
code
=
session
.
getP
layer
()
.
getSceneId
()
+
"_"
+
req
.
getPointId
();
String
code
=
p
layer
.
getSceneId
()
+
"_"
+
req
.
getPointId
();
ScenePointEntry
scenePointEntry
=
GameData
.
getScenePointEntries
().
get
(
code
);
if
(
scenePointEntry
!=
null
)
{
float
x
=
scenePointEntry
.
getPointData
().
getTranPos
().
getX
();
float
y
=
scenePointEntry
.
getPointData
().
getTranPos
().
getY
();
float
z
=
scenePointEntry
.
getPointData
().
getTranPos
().
getZ
();
Position
pos
=
new
Position
(
x
,
y
,
z
);
Position
pos
=
scenePointEntry
.
getPointData
().
getTranPos
().
clone
();
// This might not need cloning
int
sceneId
=
scenePointEntry
.
getPointData
().
getTranSceneId
();
session
.
getP
layer
()
.
getWorld
().
transferPlayerToScene
(
session
.
getP
layer
()
,
sceneId
,
pos
);
p
layer
.
getWorld
().
transferPlayerToScene
(
p
layer
,
sceneId
,
pos
);
session
.
send
(
new
PacketPersonalSceneJumpRsp
(
sceneId
,
pos
));
}
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerSceneTransToPointReq.java
View file @
36b71d01
...
...
@@ -9,7 +9,6 @@ import emu.grasscutter.net.packet.PacketHandler;
import
emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketSceneTransToPointRsp
;
import
emu.grasscutter.utils.Position
;
@Opcodes
(
PacketOpcodes
.
SceneTransToPointReq
)
public
class
HandlerSceneTransToPointReq
extends
PacketHandler
{
...
...
@@ -17,21 +16,19 @@ public class HandlerSceneTransToPointReq extends PacketHandler {
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
SceneTransToPointReq
req
=
SceneTransToPointReq
.
parseFrom
(
payload
);
var
player
=
session
.
getPlayer
();
String
code
=
req
.
getSceneId
()
+
"_"
+
req
.
getPointId
();
ScenePointEntry
scenePointEntry
=
GameData
.
getScenePointEntries
().
get
(
code
);
if
(
scenePointEntry
!=
null
)
{
float
x
=
scenePointEntry
.
getPointData
().
getTranPos
().
getX
();
float
y
=
scenePointEntry
.
getPointData
().
getTranPos
().
getY
();
float
z
=
scenePointEntry
.
getPointData
().
getTranPos
().
getZ
();
if
(
session
.
getPlayer
().
getWorld
().
transferPlayerToScene
(
session
.
getPlayer
(),
req
.
getSceneId
(),
TeleportType
.
WAYPOINT
,
new
Position
(
x
,
y
,
z
)))
{
session
.
send
(
new
PacketSceneTransToPointRsp
(
session
.
getPlayer
(),
req
.
getPointId
(),
req
.
getSceneId
()));
if
(
player
.
getWorld
().
transferPlayerToScene
(
player
,
req
.
getSceneId
(),
TeleportType
.
WAYPOINT
,
scenePointEntry
.
getPointData
().
getTranPos
().
clone
()))
{
session
.
send
(
new
PacketSceneTransToPointRsp
(
player
,
req
.
getPointId
(),
req
.
getSceneId
()));
return
;
}
}
else
{
session
.
send
(
new
PacketSceneTransToPointRsp
());
}
session
.
send
(
new
PacketSceneTransToPointRsp
());
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketMarkMapRsp.java
View file @
36b71d01
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.managers.mapmark.MapMark
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.*
;
...
...
@@ -21,13 +20,7 @@ public class PacketMarkMapRsp extends BasePacket {
MapMarkPointOuterClass
.
MapMarkPoint
.
Builder
markPoint
=
MapMarkPointOuterClass
.
MapMarkPoint
.
newBuilder
();
markPoint
.
setSceneId
(
mapMark
.
getSceneId
());
markPoint
.
setName
(
mapMark
.
getName
());
VectorOuterClass
.
Vector
.
Builder
positionVector
=
VectorOuterClass
.
Vector
.
newBuilder
();
positionVector
.
setX
(
mapMark
.
getPosition
().
getX
());
positionVector
.
setY
(
mapMark
.
getPosition
().
getY
());
positionVector
.
setZ
(
mapMark
.
getPosition
().
getZ
());
markPoint
.
setPos
(
positionVector
.
build
());
markPoint
.
setPos
(
mapMark
.
getPosition
().
toProto
());
markPoint
.
setPointType
(
mapMark
.
getMapMarkPointType
());
markPoint
.
setFromType
(
mapMark
.
getMapMarkFromType
());
markPoint
.
setMonsterId
(
mapMark
.
getMonsterId
());
...
...
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