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
66c2743d
Commit
66c2743d
authored
Apr 29, 2022
by
Melledy
Browse files
Update how scene/dungeon map points are handled
parent
c2b8a20e
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/Grasscutter.java
View file @
66c2743d
...
...
@@ -6,6 +6,7 @@ import java.io.FileReader;
import
java.io.FileWriter
;
import
java.io.InputStreamReader
;
import
java.net.InetSocketAddress
;
import
java.util.Calendar
;
import
emu.grasscutter.command.CommandMap
;
import
emu.grasscutter.plugin.PluginManager
;
...
...
@@ -32,6 +33,8 @@ public final class Grasscutter {
private
static
final
Gson
gson
=
new
GsonBuilder
().
setPrettyPrinting
().
create
();
private
static
final
File
configFile
=
new
File
(
"./config.json"
);
private
static
int
day
;
// Current day of week
public
static
RunMode
MODE
=
RunMode
.
BOTH
;
private
static
DispatchServer
dispatchServer
;
private
static
GameServer
gameServer
;
...
...
@@ -67,8 +70,10 @@ public final class Grasscutter {
Grasscutter
.
getLogger
().
info
(
"Starting Grasscutter..."
);
// Load all resources.
Grasscutter
.
updateDayOfWeek
();
ResourceLoader
.
loadAll
();
ScriptLoader
.
init
();
// Database
DatabaseManager
.
initialize
();
...
...
@@ -179,4 +184,13 @@ public final class Grasscutter {
public
static
PluginManager
getPluginManager
()
{
return
pluginManager
;
}
public
static
void
updateDayOfWeek
()
{
Calendar
calendar
=
Calendar
.
getInstance
();
day
=
calendar
.
get
(
Calendar
.
DAY_OF_WEEK
);
}
public
static
int
getCurrentDayOfWeek
()
{
return
day
;
}
}
src/main/java/emu/grasscutter/data/GameData.java
View file @
66c2743d
...
...
@@ -15,6 +15,8 @@ import emu.grasscutter.data.def.*;
import
it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.IntArrayList
;
import
it.unimi.dsi.fastutil.ints.IntList
;
public
class
GameData
{
// BinOutputs
...
...
@@ -61,12 +63,14 @@ public class GameData {
private
static
final
Int2ObjectMap
<
FetterCharacterCardData
>
fetterCharacterCardDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
RewardData
>
rewardDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
WorldLevelData
>
worldLevelDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
DailyDungeonData
>
dailyDungeonDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
DungeonData
>
dungeonDataMap
=
new
Int2ObjectOpenHashMap
<>();
private
static
final
Int2ObjectMap
<
ShopGoodsData
>
shopGoodsDataMap
=
new
Int2ObjectOpenHashMap
<>();
// Cache
private
static
Map
<
Integer
,
List
<
Integer
>>
fetters
=
new
HashMap
<>();
private
static
Map
<
Integer
,
List
<
ShopGoodsData
>>
shopGoods
=
new
HashMap
<>();
private
static
final
IntList
scenePointIdList
=
new
IntArrayList
();
public
static
char
EJWOA
=
's'
;
...
...
@@ -280,6 +284,10 @@ public class GameData {
return
dungeonDataMap
;
}
public
static
Int2ObjectMap
<
DailyDungeonData
>
getDailyDungeonDataMap
()
{
return
dailyDungeonDataMap
;
}
public
static
Map
<
Integer
,
List
<
ShopGoodsData
>>
getShopGoodsDataEntries
()
{
if
(
shopGoods
.
isEmpty
())
{
shopGoodsDataMap
.
forEach
((
k
,
v
)
->
{
...
...
@@ -291,4 +299,8 @@ public class GameData {
return
shopGoods
;
}
public
static
IntList
getScenePointIdList
()
{
return
scenePointIdList
;
}
}
src/main/java/emu/grasscutter/data/ResourceLoader.java
View file @
66c2743d
...
...
@@ -48,11 +48,12 @@ public class ResourceLoader {
loadOpenConfig
();
// Load resources
loadResources
();
loadScenePoints
();
// Process into depots
GameDepot
.
load
();
// Load spawn data
loadSpawnData
();
// Load scene points - must be done AFTER resources are loaded
loadScenePoints
();
// Custom - TODO move this somewhere else
try
{
GameData
.
getAvatarSkillDepotDataMap
().
get
(
504
).
setAbilities
(
...
...
@@ -168,6 +169,9 @@ public class ResourceLoader {
ScenePointEntry
sl
=
new
ScenePointEntry
(
sceneId
+
"_"
+
entry
.
getKey
(),
pointData
);
scenePointList
.
add
(
sl
);
GameData
.
getScenePointIdList
().
add
(
pointData
.
getId
());
pointData
.
updateDailyDungeon
();
}
for
(
ScenePointEntry
entry
:
scenePointList
)
{
...
...
src/main/java/emu/grasscutter/data/common/PointData.java
View file @
66c2743d
package
emu.grasscutter.data.common
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.def.DailyDungeonData
;
import
emu.grasscutter.utils.Position
;
import
it.unimi.dsi.fastutil.ints.IntArrayList
;
import
it.unimi.dsi.fastutil.ints.IntList
;
public
class
PointData
{
private
int
id
;
private
String
$type
;
private
Position
tranPos
;
private
int
[]
dungeonIds
;
private
int
[]
dungeonRandomList
;
public
int
getId
()
{
return
id
;
...
...
@@ -27,4 +33,31 @@ public class PointData {
public
int
[]
getDungeonIds
()
{
return
dungeonIds
;
}
public
int
[]
getDungeonRandomList
()
{
return
dungeonRandomList
;
}
public
void
updateDailyDungeon
()
{
if
(
getDungeonRandomList
()
==
null
)
{
return
;
}
IntList
newDungeons
=
new
IntArrayList
();
int
day
=
Grasscutter
.
getCurrentDayOfWeek
();
for
(
int
randomId
:
getDungeonRandomList
())
{
DailyDungeonData
data
=
GameData
.
getDailyDungeonDataMap
().
get
(
randomId
);
if
(
data
!=
null
)
{
int
[]
addDungeons
=
data
.
getDungeonsByDay
(
day
);
for
(
int
d
:
addDungeons
)
{
newDungeons
.
add
(
d
);
}
}
}
this
.
dungeonIds
=
newDungeons
.
toIntArray
();
}
}
src/main/java/emu/grasscutter/data/def/DailyDungeonData.java
0 → 100644
View file @
66c2743d
package
emu.grasscutter.data.def
;
import
java.util.Calendar
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.GameResource
;
import
emu.grasscutter.data.ResourceType
;
import
emu.grasscutter.game.props.SceneType
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
@ResourceType
(
name
=
"DailyDungeonConfigData.json"
)
public
class
DailyDungeonData
extends
GameResource
{
private
int
Id
;
private
int
[]
Monday
;
private
int
[]
Tuesday
;
private
int
[]
Wednesday
;
private
int
[]
Thursday
;
private
int
[]
Friday
;
private
int
[]
Saturday
;
private
int
[]
Sunday
;
private
static
final
int
[]
empty
=
new
int
[
0
];
private
final
Int2ObjectMap
<
int
[]>
map
;
public
DailyDungeonData
()
{
this
.
map
=
new
Int2ObjectOpenHashMap
<>();
}
@Override
public
int
getId
()
{
return
this
.
Id
;
}
public
int
[]
getDungeonsByDay
(
int
day
)
{
return
map
.
getOrDefault
(
day
,
empty
);
}
@Override
public
void
onLoad
()
{
map
.
put
(
Calendar
.
MONDAY
,
Monday
);
map
.
put
(
Calendar
.
TUESDAY
,
Tuesday
);
map
.
put
(
Calendar
.
WEDNESDAY
,
Wednesday
);
map
.
put
(
Calendar
.
THURSDAY
,
Thursday
);
map
.
put
(
Calendar
.
FRIDAY
,
Friday
);
map
.
put
(
Calendar
.
SATURDAY
,
Saturday
);
map
.
put
(
Calendar
.
SUNDAY
,
Sunday
);
}
}
src/main/java/emu/grasscutter/game/dungeons/DungeonManager.java
View file @
66c2743d
...
...
@@ -28,7 +28,7 @@ public class DungeonManager {
public
void
getEntryInfo
(
Player
player
,
int
pointId
)
{
ScenePointEntry
entry
=
GameData
.
getScenePointEntryById
(
player
.
getScene
().
getId
(),
pointId
);
if
(
entry
==
null
||
entry
.
getPointData
().
getDungeonIds
()
==
null
)
{
if
(
entry
==
null
)
{
// Error
player
.
sendPacket
(
new
PacketDungeonEntryInfoRsp
());
return
;
...
...
@@ -79,4 +79,10 @@ public class DungeonManager {
player
.
getWorld
().
transferPlayerToScene
(
player
,
prevScene
,
prevPos
);
player
.
sendPacket
(
new
BasePacket
(
PacketOpcodes
.
PlayerQuitDungeonRsp
));
}
public
void
updateDailyDungeons
()
{
for
(
ScenePointEntry
entry
:
GameData
.
getScenePointEntries
().
values
())
{
entry
.
getPointData
().
updateDailyDungeon
();
}
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketDungeonEntryInfoRsp.java
View file @
66c2743d
...
...
@@ -17,11 +17,13 @@ public class PacketDungeonEntryInfoRsp extends BasePacket {
DungeonEntryInfoRsp
.
Builder
proto
=
DungeonEntryInfoRsp
.
newBuilder
()
.
setPointId
(
pointData
.
getId
());
for
(
int
dungeonId
:
pointData
.
getDungeonIds
())
{
DungeonEntryInfo
info
=
DungeonEntryInfo
.
newBuilder
().
setDungeonId
(
dungeonId
).
build
();
proto
.
addDungeonEntryList
(
info
);
if
(
pointData
.
getDungeonIds
()
!=
null
)
{
for
(
int
dungeonId
:
pointData
.
getDungeonIds
())
{
DungeonEntryInfo
info
=
DungeonEntryInfo
.
newBuilder
().
setDungeonId
(
dungeonId
).
build
();
proto
.
addDungeonEntryList
(
info
);
}
}
this
.
setData
(
proto
);
}
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketGetScenePointRsp.java
View file @
66c2743d
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.GetScenePointRspOuterClass.GetScenePointRsp
;
...
...
@@ -12,8 +13,12 @@ public class PacketGetScenePointRsp extends BasePacket {
GetScenePointRsp
.
Builder
p
=
GetScenePointRsp
.
newBuilder
()
.
setSceneId
(
sceneId
);
for
(
int
i
=
1
;
i
<
1000
;
i
++)
{
p
.
addUnlockedPointList
(
i
);
if
(
GameData
.
getScenePointIdList
().
size
()
==
0
)
{
for
(
int
i
=
1
;
i
<
1000
;
i
++)
{
p
.
addUnlockedPointList
(
i
);
}
}
else
{
p
.
addAllUnlockedPointList
(
GameData
.
getScenePointIdList
());
}
for
(
int
i
=
1
;
i
<
9
;
i
++)
{
...
...
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