Skip to content

Commit

Permalink
Rename 'Utils' to 'LoadUtils'
Browse files Browse the repository at this point in the history
  • Loading branch information
Garanas committed May 11, 2024
1 parent 07bee25 commit 020955d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.faforever.commons.replay.body;

import com.faforever.commons.replay.shared.LuaData;
import com.faforever.commons.replay.shared.Utils;
import com.faforever.commons.replay.shared.LoadUtils;
import com.google.common.io.LittleEndianDataInputStream;
import org.jetbrains.annotations.Contract;

Expand Down Expand Up @@ -89,10 +89,10 @@ private static Event.CommandData parseCommandData(LittleEndianDataInputStream st

Event.CommandFormation commandFormation = parseCommandFormation(stream);

String blueprintId = Utils.readString(stream);
String blueprintId = LoadUtils.readString(stream);
byte[] arg4 = stream.readNBytes(12);

LuaData parametersLua = Utils.parseLua(stream);
LuaData parametersLua = LoadUtils.parseLua(stream);
boolean addToQueue = stream.readByte() > 0;

return new Event.CommandData(
Expand Down Expand Up @@ -131,7 +131,7 @@ private static Event parseToken(ReplayBodyToken token) throws IOException {

case CMDST_CREATE_UNIT -> {
int playerIndex = stream.readByte();
String blueprintId = Utils.readString(stream);
String blueprintId = LoadUtils.readString(stream);
float px = stream.readFloat();
float pz = stream.readFloat();
float heading = stream.readFloat();
Expand All @@ -140,7 +140,7 @@ private static Event parseToken(ReplayBodyToken token) throws IOException {
}

case CMDST_CREATE_PROP -> {
String blueprintId = Utils.readString(stream);
String blueprintId = LoadUtils.readString(stream);
float px = stream.readFloat();
float pz = stream.readFloat();
float heading = stream.readFloat();
Expand All @@ -163,8 +163,8 @@ private static Event parseToken(ReplayBodyToken token) throws IOException {

case CMDST_PROCESS_INFO_PAIR -> {
int entityId = stream.readInt();
String arg1 = Utils.readString(stream);
String arg2 = Utils.readString(stream);
String arg1 = LoadUtils.readString(stream);
String arg2 = LoadUtils.readString(stream);
yield new Event.ProcessInfoPair(entityId, arg1, arg2);
}

Expand Down Expand Up @@ -208,7 +208,7 @@ private static Event parseToken(ReplayBodyToken token) throws IOException {

case CMDST_SET_COMMAND_CELLS -> {
int commandId = stream.readInt();
LuaData parametersLua = Utils.parseLua(stream);
LuaData parametersLua = LoadUtils.parseLua(stream);
if (!(parametersLua instanceof LuaData.Nil)) {
stream.readNBytes(1);
}
Expand All @@ -227,7 +227,7 @@ private static Event parseToken(ReplayBodyToken token) throws IOException {
}

case CMDST_DEBUG_COMMAND -> {
String command = Utils.readString(stream);
String command = LoadUtils.readString(stream);
float px = stream.readFloat();
float py = stream.readFloat();
float pz = stream.readFloat();
Expand All @@ -238,13 +238,13 @@ private static Event parseToken(ReplayBodyToken token) throws IOException {
}

case CMDST_EXECUTE_LUA_IN_SIM -> {
String luaCode = Utils.readString(stream);
String luaCode = LoadUtils.readString(stream);
yield new Event.ExecuteLuaInSim(luaCode);
}

case CMDST_LUA_SIM_CALLBACK -> {
String func = Utils.readString(stream);
LuaData args = Utils.parseLua(stream);
String func = LoadUtils.readString(stream);
LuaData args = LoadUtils.parseLua(stream);
Event.CommandUnits commandUnits = null;

// suspicion that this is just flat out wrong! Whether there's a selection in the data is not related to whether there are Lua arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.List;
import java.util.Objects;

import static com.faforever.commons.replay.shared.Utils.parseLua;
import static com.faforever.commons.replay.shared.LoadUtils.parseLua;

public class ReplayHeaderParser {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.faforever.commons.replay.header;

import com.faforever.commons.replay.shared.Utils;
import com.faforever.commons.replay.shared.LoadUtils;
import com.google.common.io.LittleEndianDataInputStream;
import org.jetbrains.annotations.Contract;

Expand All @@ -13,13 +13,13 @@ public class ReplayHeaderTokenizer {
@Contract(pure = true)
public static ReplayHeaderToken tokenize(LittleEndianDataInputStream dataStream) throws IOException {

String gameVersion = Utils.readString(dataStream);
String arg1 = Utils.readString(dataStream); // Always \r\n
String gameVersion = LoadUtils.readString(dataStream);
String arg1 = LoadUtils.readString(dataStream); // Always \r\n

String[] replayAndScenario = Utils.readString(dataStream).split("\\r\\n");
String[] replayAndScenario = LoadUtils.readString(dataStream).split("\\r\\n");
String replayVersion = replayAndScenario[0];
String pathToScenario = replayAndScenario[1];
String arg2 = Utils.readString(dataStream); // always \r\n and some unknown character
String arg2 = LoadUtils.readString(dataStream); // always \r\n and some unknown character

int sizeModsInBytes = dataStream.readInt();
byte[] mods = dataStream.readNBytes(sizeModsInBytes);
Expand All @@ -30,7 +30,7 @@ public static ReplayHeaderToken tokenize(LittleEndianDataInputStream dataStream)
int numberOfClients = dataStream.readUnsignedByte();
List<Source> clients = new ArrayList<>(numberOfClients);
for (int i = 0; i < numberOfClients; i++) {
String playerName = Utils.readString(dataStream);
String playerName = LoadUtils.readString(dataStream);
int playerId = dataStream.readInt();
Source source = new Source(i, playerId, playerName);
clients.add(source);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.HashMap;
import java.util.Map;

public class Utils {
public class LoadUtils {

@Contract(pure = true)
private static int peek(LittleEndianDataInputStream dataStream) throws IOException {
Expand Down

0 comments on commit 020955d

Please sign in to comment.