Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 5.1 Hotfix #18

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void execute(Player sender, Player targetPlayer, List<String> args) {
translate(
sender, "commands.trialAvatarActivity.success_dungeon", Integer.parseInt(param)));
} else {
if (!"all".equals(param)) {
if (!"all".equals(param)) {
CommandHandler.sendMessage(
sender, translate(sender, "commands.trialAvatarActivity.invalid_param"));
return;
Expand Down Expand Up @@ -131,7 +131,7 @@ public void execute(Player sender, Player targetPlayer, List<String> args) {
translate(
sender, "commands.trialAvatarActivity.success_reward", Integer.parseInt(param)));
} else {
if (!"all".equals(param.toLowerCase())) {
if (!"all".equals(param.toLowerCase())) {
CommandHandler.sendMessage(
sender, translate(sender, "commands.trialAvatarActivity.invalid_param"));
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.server.packet.send.PacketWindSeedClientNotify;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
Expand All @@ -30,5 +29,4 @@ public void execute(Player sender, Player targetPlayer, List<String> args) {
CommandHandler.sendMessage(sender, "Error reading Lua script: " + e.getMessage());
}
}

}
23 changes: 11 additions & 12 deletions src/main/java/emu/grasscutter/game/ability/AbilityManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import emu.grasscutter.net.proto.AbilityMetaModifierChangeOuterClass.AbilityMetaModifierChange;
import emu.grasscutter.net.proto.AbilityMetaReInitOverrideMapOuterClass.AbilityMetaReInitOverrideMap;
import emu.grasscutter.net.proto.AbilityMetaSetKilledStateOuterClass.AbilityMetaSetKilledState;
import emu.grasscutter.net.proto.AbilityScalarTypeOuterClass.AbilityScalarType;
import emu.grasscutter.net.proto.AbilityScalarValueEntryOuterClass.AbilityScalarValueEntry;
import emu.grasscutter.net.proto.ModifierActionOuterClass.ModifierAction;
import emu.grasscutter.server.event.player.PlayerUseSkillEvent;
Expand Down Expand Up @@ -95,17 +94,17 @@ private void onPossibleElementalBurst(Ability ability, AbilityModifier modifier,

// TODO: fix the check
// if (this.burstCasterId == entityId
// && (ability.getAvatarSkillStartIds().contains(this.burstSkillId) || skillInvincibility)) {
Grasscutter.getLogger()
.trace(
"Caster ID's {} burst successful, clearing energy and setting invulnerability",
entityId);
this.abilityInvulnerable = true;
this.player
.getEnergyManager()
.handleEvtDoSkillSuccNotify(
this.player.getSession(), this.burstSkillId, this.burstCasterId);
this.removePendingEnergyClear();
// && (ability.getAvatarSkillStartIds().contains(this.burstSkillId) || skillInvincibility)) {
Grasscutter.getLogger()
.trace(
"Caster ID's {} burst successful, clearing energy and setting invulnerability",
entityId);
this.abilityInvulnerable = true;
this.player
.getEnergyManager()
.handleEvtDoSkillSuccNotify(
this.player.getSession(), this.burstSkillId, this.burstCasterId);
this.removePendingEnergyClear();
// }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@ public class ActionExecuteGadgetLua extends AbilityActionHandler {
@Override
public boolean execute(
Ability ability, AbilityModifierAction action, ByteString abilityData, GameEntity target) {
// GameEntity owner = ability.getOwner();
//
// // Investigate if we need to use target
//
// if (owner.getEntityController() != null) {
// owner
// .getEntityController()
// .onClientExecuteRequest(owner, action.param1, action.param2, action.param3);
// return true;
// }
//
// return false;
// GameEntity owner = ability.getOwner();
//
// // Investigate if we need to use target
//
// if (owner.getEntityController() != null) {
// owner
// .getEntityController()
// .onClientExecuteRequest(owner, action.param1, action.param2,
// action.param3);
// return true;
// }
//
// return false;

return true;
}
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/emu/grasscutter/game/gacha/GachaSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static emu.grasscutter.config.Configuration.GAME_OPTIONS;

import com.sun.nio.file.SensitivityWatchEventModifier;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.*;
import emu.grasscutter.data.common.ItemParamData;
Expand Down Expand Up @@ -425,9 +424,7 @@ private synchronized void startWatcher(GameServer server) {
try {
this.watchService = FileSystems.getDefault().newWatchService();
FileUtils.getDataUserPath("")
.register(
watchService,
new WatchEvent.Kind[]{StandardWatchEventKinds.ENTRY_MODIFY});
.register(watchService, new WatchEvent.Kind[] {StandardWatchEventKinds.ENTRY_MODIFY});
} catch (Exception e) {
Grasscutter.getLogger()
.error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import emu.grasscutter.data.excels.ItemData;
import emu.grasscutter.data.excels.avatar.AvatarSkillDepotData;
import emu.grasscutter.data.excels.monster.MonsterData.HpDrops;
import emu.grasscutter.game.ability.Ability;
import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.entity.*;
import emu.grasscutter.game.player.*;
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/emu/grasscutter/net/packet/PacketOpcodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public class PacketOpcodes {
public static final int GetAllUnlockNameCardReq = 1;
public static final int GetAllUnlockNameCardRsp = 1;
public static final int SetPlayerBirthdayReq = 1;
public static final int SetPlayerBirthdayRsp = 1;
public static final int SetPlayerBirthdayRsp = 1;
public static final int GalleryWillStartCountdownNotify = 1;
public static final int GetWidgetSlotRsp = 1;
public static final int AvatarExpeditionDataNotify = 1;
Expand Down Expand Up @@ -2458,8 +2458,9 @@ public class PacketOpcodes {
public static final int WorldOwnerDailyTaskNotify = 1;

// Unknown
public static final HashSet<Integer> BANNED_PACKETS = new HashSet<>() {
{
}
};
public static final HashSet<Integer> BANNED_PACKETS =
new HashSet<>() {
{
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
public class PacketOpcodesUtils {
public static final Set<Integer> LOOP_PACKETS =
Set.of(
PacketOpcodes.PingReq,
PacketOpcodes.PingRsp,
PacketOpcodes.WorldPlayerRTTNotify
PacketOpcodes.PingReq, PacketOpcodes.PingRsp, PacketOpcodes.WorldPlayerRTTNotify
// PacketOpcodes.UnionCmdNotify,
// PacketOpcodes.SceneTimeNotify,
// PacketOpcodes.QueryPathReq,
Expand All @@ -27,7 +25,7 @@ public class PacketOpcodesUtils {
// PacketOpcodes.PlayerGameTimeNotify,
// PacketOpcodes.AvatarPropNotify,
// PacketOpcodes.AvatarSatiationDataNotify
);
);
private static final Int2ObjectMap<String> opcodeMap;

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void handle(GameSession session, int opcode, byte[] header, byte[] payloa

// Log unhandled packets
if (GAME_INFO.logPackets == ServerDebugMode.MISSING
/* || GAME_INFO.logPackets == ServerDebugMode.ALL */) {
/* || GAME_INFO.logPackets == ServerDebugMode.ALL */ ) {
Grasscutter.getLogger()
.info(
"Unhandled packet ("
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/emu/grasscutter/server/game/GameSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
import java.io.File;
import java.net.InetSocketAddress;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;

import lombok.*;

public class GameSession implements GameSessionManager.KcpChannel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,15 @@ private static void queryCurrentRegion(Context ctx) {
if (!Grasscutter.getConfig().server.game.useXorEncryption) {
if (versionName != null) {
if (versionName.startsWith("CN")) {
ctx.result("{\"content\":\"v4ODcIe6c8I+UGyDOIzudWuTk+DcH4znJAdvK7oksJg77KetHm9hbFXmUc5mDUy72ovfOCNoW+Ln8GRwitL/6fliDFSP/6P92wv+5b+/u2Yk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3fY13NfgFFfd9rQ3vuY3QuH8J+XsKBkicFrpyqd9QvtxiQe3GHqIW7AobARmIYzdhuBG5fFtxe/scKUxTh1UUtbT8BTpUO7VcaXFBxXqva5ghUiKa1a7QoEMVL232D8t6nz74KOeZKZCcn8bGbO4PzkbcfkDmGL0fuEbhgh5e2+w+NQpAsX5TdO7NCYR8dKP+alTHnaeCdqXPkcauAAg==\"}");
ctx.result(
"{\"content\":\"Gw9hSPdjoJe34l9OC58Q+/qfzt5R8DkJYkg1plgG0ZAGUkrZbJhnPD9htFxBTR0tXSQJA3chVLsIgr55GY+J27k8P3HKkj6sQsZ2isRTqqQnLZKruHCLZmrWmbhmx3ioh3mbo7OHJd1V+s7W/HSHe7mknUC9xKKqYHBnpYKBE5m5afUc3mlUqxFbwfZpOIItlnBWqxiXJqI3M7ux1Go4Fs0ZSvstvxw4lGTYUyLtBG1b/tMpahUAazG0G+WJbU22JOY7JRGlXXU+LaJPTqAHksFF7Hj1tOdQnw0clNbe62nyjObdixJxkRhKsxBory1OJQqZVA8z5ZeZn7hXzzkeRQ==\",\"sign\":\"AW6F2n8+EobiwQ3ZHeW3xHR9krFDpseGewxTA9yfreWLCmoXG5bXRDp60oO464VSeEFT885yOqwidLeE2umA4TGXcRu0aJBGT/7Olse6l5M4LyltuL/xIlPMUC/pq0dMmG3fY13NfgFFfd9rQ3vuY3QuH8J+XsKBkicFrpyqd9QvtxiQe3GHqIW7AobARmIYzdhuBG5fFtxe/scKUxTh1UUtbT8BTpUO7VcaXFBxXqva5ghUiKa1a7QoEMVL232D8t6nz74KOeZKZCcn8bGbO4PzkbcfkDmGL0fuEbhgh5e2+w+NQpAsX5TdO7NCYR8dKP+alTHnaeCdqXPkcauAAg==\"}");
}
} else {
String regionName = ctx.pathParam("region");
Expand All @@ -283,46 +286,47 @@ private static void queryCurrentRegion(Context ctx) {
var versionFix = Integer.parseInt(versionCode[2]);

if (versionMajor >= 3
|| (versionMajor == 2 && versionMinor == 7 && versionFix >= 50)
|| (versionMajor == 2 && versionMinor == 8)) {
|| (versionMajor == 2 && versionMinor == 7 && versionFix >= 50)
|| (versionMajor == 2 && versionMinor == 8)) {
try {
QueryCurrentRegionEvent event = new QueryCurrentRegionEvent(regionData);
event.call();

String key_id = ctx.queryParam("key_id");

if (versionMajor != GameConstants.VERSION_PARTS[0]
|| versionMinor != GameConstants.VERSION_PARTS[1]
// The 'fix' or 'patch' version is not checked because it is only used
// when miHoYo is desperate and fucks up big time.
|| versionMinor != GameConstants.VERSION_PARTS[1]
// The 'fix' or 'patch' version is not checked because it is only used
// when miHoYo is desperate and fucks up big time.
) { // Reject clients when there is a version mismatch

boolean updateClient = GameConstants.VERSION.compareTo(clientVersion) > 0;

QueryCurrRegionHttpRsp rsp =
QueryCurrRegionHttpRsp.newBuilder()
.setRetcode(Retcode.RET_STOP_SERVER_VALUE)
.setMsg("Connection Failed!")
.setRegionInfo(RegionInfo.newBuilder())
.setStopServer(
StopServerInfo.newBuilder()
.setUrl("https://discord.gg/T5vZU6UyeG")
.setStopBeginTime((int) Instant.now().getEpochSecond())
.setStopEndTime((int) Instant.now().getEpochSecond() + 1)
.setContentMsg(
updateClient
? "\nVersion mismatch outdated client! \n\nServer version: %s\nClient version: %s"
.formatted(GameConstants.VERSION, clientVersion)
: "\nVersion mismatch outdated server! \n\nServer version: %s\nClient version: %s"
.formatted(GameConstants.VERSION, clientVersion))
.build())
.buildPartial();
QueryCurrRegionHttpRsp.newBuilder()
.setRetcode(Retcode.RET_STOP_SERVER_VALUE)
.setMsg("Connection Failed!")
.setRegionInfo(RegionInfo.newBuilder())
.setStopServer(
StopServerInfo.newBuilder()
.setUrl("https://discord.gg/T5vZU6UyeG")
.setStopBeginTime((int) Instant.now().getEpochSecond())
.setStopEndTime((int) Instant.now().getEpochSecond() + 1)
.setContentMsg(
updateClient
? "\nVersion mismatch outdated client! \n\nServer version: %s\nClient version: %s"
.formatted(GameConstants.VERSION, clientVersion)
: "\nVersion mismatch outdated server! \n\nServer version: %s\nClient version: %s"
.formatted(GameConstants.VERSION, clientVersion))
.build())
.buildPartial();

Grasscutter.getLogger()
.debug(
String.format(
"Connection denied for %s due to %s.",
Utils.address(ctx), updateClient ? "outdated client!" : "outdated server!"));
.debug(
String.format(
"Connection denied for %s due to %s.",
Utils.address(ctx),
updateClient ? "outdated client!" : "outdated server!"));

ctx.json(Crypto.encryptAndSignRegionData(rsp.toByteArray(), key_id));
return;
Expand Down Expand Up @@ -354,9 +358,7 @@ private static void queryCurrentRegion(Context ctx) {
}
}
Grasscutter.getLogger()
.info(
String.format(
"Client %s request: query_cur_region/%s", Utils.address(ctx), ""));
.info(String.format("Client %s request: query_cur_region/%s", Utils.address(ctx), ""));
}

/** Region data container. */
Expand Down
Loading
Loading