Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/unstable' into unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
KingRainbow44 committed Nov 30, 2024
2 parents 5ad5bd3 + b087e1f commit e6895ca
Show file tree
Hide file tree
Showing 24 changed files with 53 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,9 @@ public enum Type {
public String overrideMapKey;

public int paramNum;
public DynamicFloat
param1 = DynamicFloat.ZERO,
param2 = DynamicFloat.ZERO,
param3 = DynamicFloat.ZERO;
public DynamicFloat param1 = DynamicFloat.ZERO,
param2 = DynamicFloat.ZERO,
param3 = DynamicFloat.ZERO;

public String funcName;
public LuaCallType luaCallType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@Data
public class ConfigGlobalCombat {
private DefaultAbilities defaultAbilities;

// TODO: Add more indices

@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class RoutePoint {
private float waitTime; // optional
private float targetVelocity; // optional
private boolean hasReachEvent; // optional

// rotRoundReachDir //optional Pos with optional values
// rotRoundLeaveDir //optional Pos with optional values

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
public class BlossomRefreshExcelConfigData extends GameResource {
@Getter(onMethod_ = @Override)
private int id;

// Map details
private long nameTextMapHash;
private long descTextMapHash;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class CoopChapterData extends GameResource {
// int avatarSortId;
// String chapterIcon;
List<CoopCondition> unlockCond;

// int [] unlockCondTips;
// int openMaterialId;
// int openMaterialNum;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/emu/grasscutter/game/ability/Ability.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ public Ability(AbilityData data, GameEntity owner, Player playerOwner) {
data.modifiers.values().stream()
.map(
m ->
m.onAdded == null ? Collections.<AbilityModifierAction>emptyList() : Arrays.asList(m.onAdded))
m.onAdded == null
? Collections.<AbilityModifierAction>emptyList()
: Arrays.asList(m.onAdded))
.flatMap(List::stream)
.filter(action -> action.type == AbilityModifierAction.Type.AvatarSkillStart)
.map(action -> action.skillID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ public boolean execute(
var param2 = action.param2.getInt(ability);
var param3 = action.param3.getInt(ability);

owner
.getEntityController()
.onClientExecuteRequest(owner, param1, param2, param3);
owner.getEntityController().onClientExecuteRequest(owner, param1, param2, param3);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ public boolean execute(
* @return Whether the function was called successfully.
*/
private static boolean callFunction(
Bindings bindings, String functionName,
Ability ability, AbilityModifierAction action
) {
Bindings bindings, String functionName, Ability ability, AbilityModifierAction action) {
try {
// Resolve the function from the script.
var function = bindings.get(functionName);
Expand All @@ -86,10 +84,10 @@ private static boolean callFunction(

// Invoke the function with the parameters.
switch (action.paramNum) {
case 1 -> luaFunction.invoke(new LuaValue[] { lParam1 });
case 2 -> luaFunction.invoke(new LuaValue[] { lParam1, lParam2 });
case 3 -> luaFunction.invoke(new LuaValue[] { lParam1, lParam2, lParam3 });
default -> luaFunction.invoke(new LuaValue[] { ScriptLoader.getScriptLibLua() });
case 1 -> luaFunction.invoke(new LuaValue[] {lParam1});
case 2 -> luaFunction.invoke(new LuaValue[] {lParam1, lParam2});
case 3 -> luaFunction.invoke(new LuaValue[] {lParam1, lParam2, lParam3});
default -> luaFunction.invoke(new LuaValue[] {ScriptLoader.getScriptLibLua()});
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class PlayerActivityData {
int uid;
int activityId;
Map<Integer, WatcherInfo> watcherInfoMap;

/** the detail data of each type of activity (Json format) */
String detail;

Expand Down
1 change: 1 addition & 0 deletions src/main/java/emu/grasscutter/game/avatar/Avatar.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public class Avatar {

// trial avatar property
@Getter @Setter private int trialAvatarId = 0;

// cannot store to db if grant reason is not integer
@Getter @Setter
private int grantReason = TrialAvatarGrantRecord.GrantReason.GRANT_REASON_INVALID.getNumber();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/emu/grasscutter/game/gacha/GachaBanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class GachaBanner {
@Getter private int[] rateUpItems5 = {};
// This now handles default values for the fields below
@Getter private BannerType bannerType = BannerType.STANDARD;

// These don't change between banner types (apart from Standard having three extra 4star avatars)
@Getter
private int[] fallbackItems3 = {
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/emu/grasscutter/game/gacha/GachaSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@
import java.nio.file.*;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;

import lombok.Getter;
import org.greenrobot.eventbus.Subscribe;

public class GachaSystem extends BaseGameSystem {
private static final int starglitterId = 221;
private static final int stardustId = 222;
@Getter
private final Int2ObjectMap<GachaBanner> gachaBanners;
@Getter private final Int2ObjectMap<GachaBanner> gachaBanners;
private WatchService watchService;

public GachaSystem(GameServer server) {
Expand Down Expand Up @@ -422,8 +420,7 @@ private synchronized void startWatcher(GameServer server) {
if (this.watchService == null) {
try {
this.watchService = FileSystems.getDefault().newWatchService();
FileUtils.getDataUserPath("")
.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY);
FileUtils.getDataUserPath("").register(watchService, StandardWatchEventKinds.ENTRY_MODIFY);
} catch (Exception e) {
Grasscutter.getLogger()
.error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public void finish() {
// .forEach(getQuestManager()::startMainQuest);
// }
}

// TODO
public void fail() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
public class TowerLevelRecord {
/** floorId in config */
private int floorId;

/** LevelId - Stars */
private Map<Integer, Integer> passedLevelMap;

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/emu/grasscutter/scripts/SceneScriptManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class SceneScriptManager {
private final Map<Integer, SceneGroupInstance> cachedSceneGroupsInstances;
private ScriptMonsterTideService scriptMonsterTideService;
private ScriptMonsterSpawnService scriptMonsterSpawnService;

/** blockid - loaded groupSet */
private final Map<Integer, Set<SceneGroup>> loadedGroupSetPerBlock;

Expand Down Expand Up @@ -846,6 +847,7 @@ public void spawnMonstersByConfigId(SceneGroup group, int configId, int delayTim
.warn("failed to create entity with group {} and config {}", group.id, configId);
}
}

// Events
public Future<?> callEvent(int groupId, int eventType) {
return callEvent(new ScriptArgs(groupId, eventType));
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/emu/grasscutter/scripts/ScriptLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ public class ScriptLoader {
@Getter private static Serializer serializer;
@Getter private static ScriptLib scriptLib;
@Getter private static LuaValue scriptLibLua;

/** suggest GC to remove it if the memory is less */
private static Map<String, SoftReference<String>> scriptSources = new ConcurrentHashMap<>();

private static Map<String, SoftReference<CompiledScript>> scriptsCache =
new ConcurrentHashMap<>();

/** sceneId - SceneMeta */
private static Map<Integer, SoftReference<SceneMeta>> sceneMetaCache = new ConcurrentHashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

public class EventType {
public static final int EVENT_NONE = 0;

/** param1: monster.configId */
public static final int EVENT_ANY_MONSTER_DIE = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class SceneGadget extends SceneObject {
public int owner;
public SceneBossChest boss_chest;
public int interact_id;

/**
* Note: this field indicates whether the gadget should disappear permanently. For example, if
* isOneOff=true, like most chests, it will disappear permanently after interacted. If
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public abstract class SceneObject {

public Position pos;
public Position rot;

/** not set by lua */
public transient SceneGroup group;
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public int onClientExecuteRequest(GameEntity entity, int param1, int param2, int
}

/**
* Invoked from {@link emu.grasscutter.game.ability.actions.ActionServerLuaCall} to call an entity controller function.
* Invoked from {@link emu.grasscutter.game.ability.actions.ActionServerLuaCall} to call an entity
* controller function.
*
* @param entity The entity which called the function.
* @param funcName The name of the function to call.
Expand All @@ -70,8 +71,7 @@ public int onClientExecuteRequest(GameEntity entity, int param1, int param2, int
* @return The return value of the function.
*/
public LuaValue callControllerScriptFunc(
GameEntity entity, String funcName,
Ability ability, AbilityModifierAction action) {
GameEntity entity, String funcName, Ability ability, AbilityModifierAction action) {
var lParam1 = LuaValue.valueOf(action.param1.getInt(ability));
var lParam2 = LuaValue.valueOf(action.param2.getInt(ability));
var lParam3 = LuaValue.valueOf(action.param3.getInt(ability));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import org.slf4j.Logger;

/**
* This is a simple implementation of a server-to-server IPC client.
* It is implemented over WebSockets, and supports all Grasscutter versions past 1.6.0
* This is a simple implementation of a server-to-server IPC client. It is implemented over
* WebSockets, and supports all Grasscutter versions past 1.6.0
*/
@Getter
public final class DispatchClient extends WebSocketClient implements IDispatcher {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ public void handle(GameSession session, byte[] header, byte[] payload) throws Ex
// These are bundled into a list of items.
for (var item : req.getItemParamListList()) {
session
.getServer()
.getInventorySystem()
.upgradeAvatar(session.getPlayer(), req.getAvatarGuid(), item.getItemId(), item.getCount());
.getServer()
.getInventorySystem()
.upgradeAvatar(
session.getPlayer(), req.getAvatarGuid(), item.getItemId(), item.getCount());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ public PacketPlayerEnterSceneNotify(Player player) {
.setTargetUid(player.getUid())
.setEnterSceneToken(player.getEnterSceneToken())
.setWorldLevel(player.getWorldLevel())
// .setEnterReason(EnterReason.Login.getValue()) // Removed in 5.0; we don't know what it is
// .setIsFirstLoginEnterScene(player.isFirstLoginEnterScene()) // Removed in 5.0; we don't know what it is
// .setEnterReason(EnterReason.Login.getValue()) // Removed in 5.0; we don't know what
// it is
// .setIsFirstLoginEnterScene(player.isFirstLoginEnterScene()) // Removed in 5.0; we
// don't know what it is
// .setWorldType(1) // Removed in 5.0; we don't know what it is
.setSceneTransaction(
"3-"
Expand Down Expand Up @@ -80,15 +82,17 @@ public PacketPlayerEnterSceneNotify(
var proto =
PlayerEnterSceneNotify.newBuilder()
// .setPrevSceneId(player.getSceneId()) // Removed in 5.0; we don't know what it is
// .setPrevPos(player.getPosition().toProto()) // Removed in 5.0; we don't know what it is
// .setPrevPos(player.getPosition().toProto()) // Removed in 5.0; we don't know what it
// is
.setSceneId(teleportProperties.getSceneId())
.setPos(teleportProperties.getTeleportTo().toProto())
.setSceneBeginTime(System.currentTimeMillis())
.setType(teleportProperties.getEnterType())
.setTargetUid(target.getUid())
.setEnterSceneToken(player.getEnterSceneToken())
.setWorldLevel(target.getWorld().getWorldLevel())
// .setEnterReason(teleportProperties.getEnterReason().getValue()) // Removed in 5.0; we don't know what it is
// .setEnterReason(teleportProperties.getEnterReason().getValue()) // Removed in 5.0; we
// don't know what it is
// .setWorldType(1) // Removed in 5.0; we don't know what it is
.setSceneTransaction(
teleportProperties.getSceneId()
Expand Down Expand Up @@ -118,14 +122,16 @@ public PacketPlayerEnterSceneNotify(
var proto =
PlayerEnterSceneNotify.newBuilder()
// .setPrevSceneId(player.getSceneId()) // Removed in 5.0; we don't know what it is
// .setPrevPos(player.getPosition().toProto()) // Removed in 5.0; we don't know what it is
// .setPrevPos(player.getPosition().toProto()) // Removed in 5.0; we don't know what it
// is
.setSceneId(teleportProperties.getSceneId())
.setPos(teleportProperties.getTeleportTo().toProto())
.setSceneBeginTime(System.currentTimeMillis())
.setType(other ? EnterType.ENTER_TYPE_OTHER_HOME : EnterType.ENTER_TYPE_SELF_HOME)
.setTargetUid(targetUid)
.setEnterSceneToken(player.getEnterSceneToken())
// .setEnterReason(teleportProperties.getEnterReason().getValue()) // Removed in 5.0; we don't know what it is
// .setEnterReason(teleportProperties.getEnterReason().getValue()) // Removed in 5.0; we
// don't know what it is
// .setWorldType(64) // Removed in 5.0; we don't know what it is
.setSceneTransaction(
teleportProperties.getSceneId()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public PacketPlayerLoginRsp(GameSession session) {
.setClientDataVersion(info.getClientDataVersion())
.setClientSilenceDataVersion(info.getClientSilenceDataVersion())
// .setClientMd5(info.getClientDataMd5()) // Removed in 5.0; we don't know what it is
// .setClientSilenceMd5(info.getClientSilenceDataMd5()) // Removed in 5.0; we don't know what it is
// .setClientSilenceMd5(info.getClientSilenceDataMd5()) // Removed in 5.0; we don't know
// what it is
.setResVersionConfig(info.getResVersionConfig())
.setClientVersionSuffix(info.getClientVersionSuffix())
.setClientSilenceVersionSuffix(info.getClientSilenceVersionSuffix())
Expand Down

0 comments on commit e6895ca

Please sign in to comment.