Improved network stability and other related fixes:

* server: fixed that a critical errors ignored in user commands threads (now it will be added to the logs);
* network: fixed frozen user responses in some use cases;
* network: fixed accidental and incorrect user responses (only latest response will be used now);
* network: improved freeze logs, added problem method name and code's line number;
* cheats: removed outdated deck and card load logic (only init.txt commands supports now);
* cheats: fixed wrong priority after add card dialog (closes #11437);
* cheats: improved stability and random errors on cheat executes (related to #11437);
* docs: added details on network and thread logic, human feedback life cycle, etc (see HumanPlayer, ThreadExecutorImpl);
This commit is contained in:
Oleg Agafonov 2023-11-24 21:22:16 +04:00
parent 4ba3e1fec5
commit 53add71826
33 changed files with 476 additions and 273 deletions

View file

@ -1,5 +1,7 @@
package mage.util;
import java.lang.reflect.Method;
/**
* Devs only: enable or disable debug features
* <p>
@ -28,4 +30,47 @@ public class DebugUtil {
public static boolean GUI_GAME_DRAW_BATTLEFIELD_BORDER = false;
public static boolean GUI_GAME_DRAW_HAND_AND_STACK_BORDER = false;
public static boolean GUI_GAME_DIALOGS_DRAW_CARDS_AREA_BORDER = false;
public static String getMethodNameWithSource(final int depth) {
return TraceHelper.getMethodNameWithSource(depth);
}
}
/**
* Debug: allows to find a caller's method name
* <a href="https://stackoverflow.com/a/11726687/1276632">Original code</a>
*/
class TraceHelper {
private static Method m;
static {
try {
m = Throwable.class.getDeclaredMethod("getStackTraceElement", int.class);
m.setAccessible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
public static String getMethodName(final int depth) {
try {
StackTraceElement element = (StackTraceElement) m.invoke(new Throwable(), depth + 1);
return element.getMethodName();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static String getMethodNameWithSource(final int depth) {
try {
StackTraceElement element = (StackTraceElement) m.invoke(new Throwable(), depth + 1);
return String.format("%s - %s:%d", element.getMethodName(), element.getFileName(), element.getLineNumber());
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}