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
Hide 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;
...
@@ -13,7 +13,6 @@ import emu.grasscutter.net.proto.InteractTypeOuterClass.InteractType;
import
emu.grasscutter.net.proto.GadgetInteractReqOuterClass.GadgetInteractReq
;
import
emu.grasscutter.net.proto.GadgetInteractReqOuterClass.GadgetInteractReq
;
import
emu.grasscutter.net.proto.SceneGadgetInfoOuterClass.SceneGadgetInfo
;
import
emu.grasscutter.net.proto.SceneGadgetInfoOuterClass.SceneGadgetInfo
;
import
emu.grasscutter.server.packet.send.PacketGadgetInteractRsp
;
import
emu.grasscutter.server.packet.send.PacketGadgetInteractRsp
;
import
emu.grasscutter.utils.Position
;
import
emu.grasscutter.utils.Utils
;
import
emu.grasscutter.utils.Utils
;
public
class
GadgetGatherObject
extends
GadgetContent
{
public
class
GadgetGatherObject
extends
GadgetContent
{
...
@@ -69,11 +68,10 @@ public class GadgetGatherObject extends GadgetContent {
...
@@ -69,11 +68,10 @@ public class GadgetGatherObject extends GadgetContent {
scene
,
scene
,
player
,
player
,
GameData
.
getItemDataMap
().
get
(
itemId
),
GameData
.
getItemDataMap
().
get
(
itemId
),
new
Position
(
getGadget
().
getPosition
().
clone
()
getGadget
().
getPosition
().
getX
()
+
(
float
)
Utils
.
randomRange
(
1
,
5
)
/
5
,
.
addY
(
2
f
)
getGadget
().
getPosition
().
getY
()
+
2
f
,
.
addX
(
Utils
.
randomFloatRange
(-
1
f
,
1
f
))
getGadget
().
getPosition
().
getZ
()
+
(
float
)
Utils
.
randomRange
(
1
,
5
)
/
5
.
addZ
(
Utils
.
randomFloatRange
(-
1
f
,
1
f
)),
),
1
,
1
,
true
);
true
);
...
...
src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherPoint.java
View file @
36b71d01
...
@@ -11,7 +11,6 @@ import emu.grasscutter.game.world.Scene;
...
@@ -11,7 +11,6 @@ import emu.grasscutter.game.world.Scene;
import
emu.grasscutter.net.proto.GatherGadgetInfoOuterClass.GatherGadgetInfo
;
import
emu.grasscutter.net.proto.GatherGadgetInfoOuterClass.GatherGadgetInfo
;
import
emu.grasscutter.net.proto.GadgetInteractReqOuterClass.GadgetInteractReq
;
import
emu.grasscutter.net.proto.GadgetInteractReqOuterClass.GadgetInteractReq
;
import
emu.grasscutter.net.proto.SceneGadgetInfoOuterClass.SceneGadgetInfo
;
import
emu.grasscutter.net.proto.SceneGadgetInfoOuterClass.SceneGadgetInfo
;
import
emu.grasscutter.utils.Position
;
import
emu.grasscutter.utils.Utils
;
import
emu.grasscutter.utils.Utils
;
public
class
GadgetGatherPoint
extends
GadgetContent
{
public
class
GadgetGatherPoint
extends
GadgetContent
{
...
@@ -61,14 +60,13 @@ public class GadgetGatherPoint extends GadgetContent {
...
@@ -61,14 +60,13 @@ public class GadgetGatherPoint extends GadgetContent {
for
(
int
i
=
0
;
i
<
times
;
i
++)
{
for
(
int
i
=
0
;
i
<
times
;
i
++)
{
EntityItem
item
=
new
EntityItem
(
EntityItem
item
=
new
EntityItem
(
scene
,
scene
,
player
,
player
,
GameData
.
getItemDataMap
().
get
(
itemId
),
GameData
.
getItemDataMap
().
get
(
itemId
),
new
Position
(
getGadget
().
getPosition
().
clone
()
getGadget
().
getPosition
().
getX
()
+
(
float
)
Utils
.
randomRange
(
1
,
5
)
/
5
,
.
addY
(
2
f
)
getGadget
().
getPosition
().
getY
()
+
2
f
,
.
addX
(
Utils
.
randomFloatRange
(-
1
f
,
1
f
))
getGadget
().
getPosition
().
getZ
()
+
(
float
)
Utils
.
randomRange
(
1
,
5
)
/
5
.
addZ
(
Utils
.
randomFloatRange
(-
1
f
,
1
f
)),
),
1
,
1
,
true
);
true
);
...
...
src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java
View file @
36b71d01
...
@@ -25,11 +25,7 @@ public class MapMark {
...
@@ -25,11 +25,7 @@ public class MapMark {
public
MapMark
(
MapMarkPoint
mapMarkPoint
)
{
public
MapMark
(
MapMarkPoint
mapMarkPoint
)
{
this
.
sceneId
=
mapMarkPoint
.
getSceneId
();
this
.
sceneId
=
mapMarkPoint
.
getSceneId
();
this
.
name
=
mapMarkPoint
.
getName
();
this
.
name
=
mapMarkPoint
.
getName
();
this
.
position
=
new
Position
(
this
.
position
=
new
Position
(
mapMarkPoint
.
getPos
());
mapMarkPoint
.
getPos
().
getX
(),
mapMarkPoint
.
getPos
().
getY
(),
mapMarkPoint
.
getPos
().
getZ
()
);
this
.
mapMarkPointType
=
mapMarkPoint
.
getPointType
();
this
.
mapMarkPointType
=
mapMarkPoint
.
getPointType
();
this
.
monsterId
=
mapMarkPoint
.
getMonsterId
();
this
.
monsterId
=
mapMarkPoint
.
getMonsterId
();
this
.
mapMarkFromType
=
mapMarkPoint
.
getFromType
();
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 {
...
@@ -497,11 +497,7 @@ public class StaminaManager extends BasePlayerManager {
}
}
}
}
previousState
=
currentState
;
previousState
=
currentState
;
previousCoordinates
=
new
Position
(
previousCoordinates
=
currentCoordinates
.
clone
();
currentCoordinates
.
getX
(),
currentCoordinates
.
getY
(),
currentCoordinates
.
getZ
()
);
}
}
}
}
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerPersonalSceneJumpReq.java
View file @
36b71d01
...
@@ -17,19 +17,17 @@ public class HandlerPersonalSceneJumpReq extends PacketHandler {
...
@@ -17,19 +17,17 @@ public class HandlerPersonalSceneJumpReq extends PacketHandler {
@Override
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
PersonalSceneJumpReq
req
=
PersonalSceneJumpReq
.
parseFrom
(
payload
);
PersonalSceneJumpReq
req
=
PersonalSceneJumpReq
.
parseFrom
(
payload
);
var
player
=
session
.
getPlayer
();
// get the scene point
// 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
);
ScenePointEntry
scenePointEntry
=
GameData
.
getScenePointEntries
().
get
(
code
);
if
(
scenePointEntry
!=
null
)
{
if
(
scenePointEntry
!=
null
)
{
float
x
=
scenePointEntry
.
getPointData
().
getTranPos
().
getX
();
Position
pos
=
scenePointEntry
.
getPointData
().
getTranPos
().
clone
();
// This might not need cloning
float
y
=
scenePointEntry
.
getPointData
().
getTranPos
().
getY
();
float
z
=
scenePointEntry
.
getPointData
().
getTranPos
().
getZ
();
Position
pos
=
new
Position
(
x
,
y
,
z
);
int
sceneId
=
scenePointEntry
.
getPointData
().
getTranSceneId
();
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
));
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;
...
@@ -9,7 +9,6 @@ import emu.grasscutter.net.packet.PacketHandler;
import
emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType
;
import
emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketSceneTransToPointRsp
;
import
emu.grasscutter.server.packet.send.PacketSceneTransToPointRsp
;
import
emu.grasscutter.utils.Position
;
@Opcodes
(
PacketOpcodes
.
SceneTransToPointReq
)
@Opcodes
(
PacketOpcodes
.
SceneTransToPointReq
)
public
class
HandlerSceneTransToPointReq
extends
PacketHandler
{
public
class
HandlerSceneTransToPointReq
extends
PacketHandler
{
...
@@ -17,21 +16,19 @@ public class HandlerSceneTransToPointReq extends PacketHandler {
...
@@ -17,21 +16,19 @@ public class HandlerSceneTransToPointReq extends PacketHandler {
@Override
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
SceneTransToPointReq
req
=
SceneTransToPointReq
.
parseFrom
(
payload
);
SceneTransToPointReq
req
=
SceneTransToPointReq
.
parseFrom
(
payload
);
var
player
=
session
.
getPlayer
();
String
code
=
req
.
getSceneId
()
+
"_"
+
req
.
getPointId
();
String
code
=
req
.
getSceneId
()
+
"_"
+
req
.
getPointId
();
ScenePointEntry
scenePointEntry
=
GameData
.
getScenePointEntries
().
get
(
code
);
ScenePointEntry
scenePointEntry
=
GameData
.
getScenePointEntries
().
get
(
code
);
if
(
scenePointEntry
!=
null
)
{
if
(
scenePointEntry
!=
null
)
{
float
x
=
scenePointEntry
.
getPointData
().
getTranPos
().
getX
();
if
(
player
.
getWorld
().
transferPlayerToScene
(
player
,
req
.
getSceneId
(),
TeleportType
.
WAYPOINT
,
scenePointEntry
.
getPointData
().
getTranPos
().
clone
()))
{
float
y
=
scenePointEntry
.
getPointData
().
getTranPos
().
getY
();
session
.
send
(
new
PacketSceneTransToPointRsp
(
player
,
req
.
getPointId
(),
req
.
getSceneId
()));
float
z
=
scenePointEntry
.
getPointData
().
getTranPos
().
getZ
();
return
;
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
()));
}
}
}
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
;
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.managers.mapmark.MapMark
;
import
emu.grasscutter.game.managers.mapmark.MapMark
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.*
;
import
emu.grasscutter.net.proto.*
;
...
@@ -21,13 +20,7 @@ public class PacketMarkMapRsp extends BasePacket {
...
@@ -21,13 +20,7 @@ public class PacketMarkMapRsp extends BasePacket {
MapMarkPointOuterClass
.
MapMarkPoint
.
Builder
markPoint
=
MapMarkPointOuterClass
.
MapMarkPoint
.
newBuilder
();
MapMarkPointOuterClass
.
MapMarkPoint
.
Builder
markPoint
=
MapMarkPointOuterClass
.
MapMarkPoint
.
newBuilder
();
markPoint
.
setSceneId
(
mapMark
.
getSceneId
());
markPoint
.
setSceneId
(
mapMark
.
getSceneId
());
markPoint
.
setName
(
mapMark
.
getName
());
markPoint
.
setName
(
mapMark
.
getName
());
markPoint
.
setPos
(
mapMark
.
getPosition
().
toProto
());
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
.
setPointType
(
mapMark
.
getMapMarkPointType
());
markPoint
.
setPointType
(
mapMark
.
getMapMarkPointType
());
markPoint
.
setFromType
(
mapMark
.
getMapMarkFromType
());
markPoint
.
setFromType
(
mapMark
.
getMapMarkFromType
());
markPoint
.
setMonsterId
(
mapMark
.
getMonsterId
());
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