Admin player team switch + more trace info

This commit is contained in:
Anuken
2023-06-11 23:18:04 -04:00
parent 0ec59691bf
commit 4b0824a20c
10 changed files with 180 additions and 68 deletions

View File

@@ -835,13 +835,40 @@ public class TypeIO{
write.b(trace.mobile ? (byte)1 : 0);
write.i(trace.timesJoined);
write.i(trace.timesKicked);
//there is a cap to prevent TCP packet size overrun
writeStrings(write, trace.ips, 12);
writeStrings(write, trace.names, 12);
}
public static TraceInfo readTraceInfo(Reads read){
return new TraceInfo(readString(read), readString(read), read.b() == 1, read.b() == 1, read.i(), read.i());
return new TraceInfo(readString(read), readString(read), read.b() == 1, read.b() == 1, read.i(), read.i(), readStrings(read), readStrings(read));
}
public static void writeStrings(Writes write, String[][] strings){
public static void writeStrings(Writes write, String[] strings, int maxLen){
write.b(Math.min(strings.length, maxLen));
for(int i = 0; i < Math.min(strings.length, maxLen); i++){
writeString(write, strings[i]);
}
}
public static void writeStrings(Writes write, String[] strings){
write.b(strings.length);
for(String s : strings){
writeString(write, s);
}
}
public static String[] readStrings(Reads read){
int length = read.ub();
var result = new String[length];
for(int j = 0; j < length; j++){
result[j] = readString(read);
}
return result;
}
public static void writeStringArray(Writes write, String[][] strings){
write.b(strings.length);
for(String[] string : strings){
write.b(string.length);
@@ -851,7 +878,7 @@ public class TypeIO{
}
}
public static String[][] readStrings(Reads read){
public static String[][] readStringArray(Reads read){
int rows = read.ub();
String[][] strings = new String[rows][];