0

Первый этап замены встроенного логгера на SLF4j

This commit is contained in:
2017-05-12 16:23:45 +03:00
parent 03461857de
commit 7c91ddbe7b
29 changed files with 315 additions and 261 deletions

View File

@@ -112,7 +112,7 @@ public final class CL {
int len; int len;
if (!Globals.cls.demorecording) { if (!Globals.cls.demorecording) {
Com.Printf("Not recording a demo.\n"); logger.info("Not recording a demo.");
return; return;
} }
@@ -122,7 +122,7 @@ public final class CL {
Globals.cls.demofile.close(); Globals.cls.demofile.close();
Globals.cls.demofile = null; Globals.cls.demofile = null;
Globals.cls.demorecording = false; Globals.cls.demorecording = false;
Com.Printf("Stopped demo.\n"); logger.info("Stopped demo.");
} catch (IOException e) { } catch (IOException e) {
} }
} }
@@ -146,17 +146,17 @@ public final class CL {
entity_state_t ent; entity_state_t ent;
if (Cmd.Argc() != 2) { if (Cmd.Argc() != 2) {
Com.Printf("record <demoname>\n"); logger.info("record <demoname>");
return; return;
} }
if (Globals.cls.demorecording) { if (Globals.cls.demorecording) {
Com.Printf("Already recording.\n"); logger.info("Already recording.");
return; return;
} }
if (Globals.cls.state != Defines.ca_active) { if (Globals.cls.state != Defines.ca_active) {
Com.Printf("You must be in a level to record.\n"); logger.info("You must be in a level to record.");
return; return;
} }
@@ -165,11 +165,11 @@ public final class CL {
// //
name = FS.Gamedir() + "/demos/" + Cmd.Argv(1) + ".dm2"; name = FS.Gamedir() + "/demos/" + Cmd.Argv(1) + ".dm2";
Com.Printf("recording to " + name + ".\n"); logger.info("recording to {}", name);
FS.CreatePath(name); FS.CreatePath(name);
Globals.cls.demofile = new RandomAccessFile(name, "rw"); Globals.cls.demofile = new RandomAccessFile(name, "rw");
if (Globals.cls.demofile == null) { if (Globals.cls.demofile == null) {
Com.Printf("ERROR: couldn't open.\n"); logger.error("ERROR: couldn't open.");
return; return;
} }
Globals.cls.demorecording = true; Globals.cls.demorecording = true;
@@ -250,7 +250,7 @@ public final class CL {
public void execute() { public void execute() {
if (Globals.cls.state != Defines.ca_connected if (Globals.cls.state != Defines.ca_connected
&& Globals.cls.state != Defines.ca_active) { && Globals.cls.state != Defines.ca_active) {
Com.Printf("Can't \"" + Cmd.Argv(0) + "\", not connected\n"); logger.warn("Can't \"{}\", not connected", Cmd.Argv(0));
return; return;
} }
@@ -298,7 +298,7 @@ public final class CL {
String server; String server;
if (Cmd.Argc() != 2) { if (Cmd.Argc() != 2) {
Com.Printf("usage: connect <server>\n"); logger.info("usage: connect <server>");
return; return;
} }
@@ -332,7 +332,7 @@ public final class CL {
public void execute() { public void execute() {
if (Globals.rcon_client_password.string.length() == 0) { if (Globals.rcon_client_password.string.length() == 0) {
Com.Printf("You must set 'rcon_password' before\nissuing an rcon command.\n"); logger.warn("You must set 'rcon_password' before\nissuing an rcon command.");
return; return;
} }
@@ -362,7 +362,7 @@ public final class CL {
to = Globals.cls.netchan.remote_address; to = Globals.cls.netchan.remote_address;
else { else {
if (Globals.rcon_address.string.length() == 0) { if (Globals.rcon_address.string.length() == 0) {
Com.Printf("You must either be connected,\nor set the 'rcon_address' cvar\nto issue rcon commands\n"); logger.warn("You must either be connected,\nor set the 'rcon_address' cvar\nto issue rcon commands");
return; return;
} }
NET.StringToAdr(Globals.rcon_address.string, to); NET.StringToAdr(Globals.rcon_address.string, to);
@@ -397,7 +397,7 @@ public final class CL {
SCR.BeginLoadingPlaque(); SCR.BeginLoadingPlaque();
Globals.cls.state = Defines.ca_connected; // not active anymore, but Globals.cls.state = Defines.ca_connected; // not active anymore, but
// not disconnected // not disconnected
Com.Printf("\nChanging map...\n"); logger.info("Changing map...");
} }
}; };
@@ -416,7 +416,7 @@ public final class CL {
S.StopAllSounds(); S.StopAllSounds();
if (Globals.cls.state == Defines.ca_connected) { if (Globals.cls.state == Defines.ca_connected) {
Com.Printf("reconnecting...\n"); logger.info("reconnecting...");
Globals.cls.state = Defines.ca_connected; Globals.cls.state = Defines.ca_connected;
MSG.WriteChar(Globals.cls.netchan.message, MSG.WriteChar(Globals.cls.netchan.message,
Defines.clc_stringcmd); Defines.clc_stringcmd);
@@ -432,7 +432,7 @@ public final class CL {
Globals.cls.connect_time = -99999; // fire immediately Globals.cls.connect_time = -99999; // fire immediately
Globals.cls.state = Defines.ca_connecting; Globals.cls.state = Defines.ca_connecting;
Com.Printf("reconnecting...\n"); logger.info("reconnecting...");
} }
} }
}; };
@@ -453,7 +453,7 @@ public final class CL {
NET.Config(true); // allow remote NET.Config(true); // allow remote
// send a broadcast packet // send a broadcast packet
Com.Printf("pinging broadcast...\n"); logger.info("pinging broadcast...");
noudp = Cvar.Get("noudp", "0", Defines.CVAR_NOSET); noudp = Cvar.Get("noudp", "0", Defines.CVAR_NOSET);
if (noudp.value == 0.0f) { if (noudp.value == 0.0f) {
@@ -482,9 +482,9 @@ public final class CL {
if (adrstring == null || adrstring.length() == 0) if (adrstring == null || adrstring.length() == 0)
continue; continue;
Com.Printf("pinging " + adrstring + "...\n"); logger.info("pinging {} ...", adrstring);
if (!NET.StringToAdr(adrstring, adr)) { if (!NET.StringToAdr(adrstring, adr)) {
Com.Printf("Bad address: " + adrstring + "\n"); logger.warn("Bad address: {}", adrstring);
continue; continue;
} }
if (adr.port == 0) if (adr.port == 0)
@@ -508,9 +508,7 @@ public final class CL {
for (i = 0; i < Defines.MAX_CLIENTS; i++) { for (i = 0; i < Defines.MAX_CLIENTS; i++) {
if (Globals.cl.configstrings[Defines.CS_PLAYERSKINS + i] == null) if (Globals.cl.configstrings[Defines.CS_PLAYERSKINS + i] == null)
continue; continue;
Com.Printf("client " + i + ": " logger.info("client {}: {}", i, Globals.cl.configstrings[Defines.CS_PLAYERSKINS + i]);
+ Globals.cl.configstrings[Defines.CS_PLAYERSKINS + i]
+ "\n");
SCR.UpdateScreen(); SCR.UpdateScreen();
Sys.SendKeyEvents(); // pump message loop Sys.SendKeyEvents(); // pump message loop
CL_parse.ParseClientinfo(i); CL_parse.ParseClientinfo(i);
@@ -523,7 +521,7 @@ public final class CL {
*/ */
static xcommand_t Userinfo_f = new xcommand_t() { static xcommand_t Userinfo_f = new xcommand_t() {
public void execute() { public void execute() {
Com.Printf("User info settings:\n"); logger.info("User info settings:");
Info.Print(Cvar.Userinfo()); Info.Print(Cvar.Userinfo());
} }
}; };
@@ -619,7 +617,7 @@ public final class CL {
int port; int port;
if (!NET.StringToAdr(Globals.cls.servername, adr)) { if (!NET.StringToAdr(Globals.cls.servername, adr)) {
Com.Printf("Bad server address\n"); logger.warn("Bad server address");
Globals.cls.connect_time = 0; Globals.cls.connect_time = 0;
return; return;
} }
@@ -662,7 +660,7 @@ public final class CL {
return; return;
if (!NET.StringToAdr(Globals.cls.servername, adr)) { if (!NET.StringToAdr(Globals.cls.servername, adr)) {
Com.Printf("Bad server address\n"); logger.warn("Bad server address");
Globals.cls.state = Defines.ca_disconnected; Globals.cls.state = Defines.ca_disconnected;
return; return;
} }
@@ -672,7 +670,7 @@ public final class CL {
// for retransmit requests // for retransmit requests
Globals.cls.connect_time = Globals.cls.realtime; Globals.cls.connect_time = Globals.cls.realtime;
Com.Printf("Connecting to " + Globals.cls.servername + "...\n"); logger.info("Connecting to {}...", Globals.cls.servername);
Netchan.OutOfBandPrint(Defines.NS_CLIENT, adr, "getchallenge\n"); Netchan.OutOfBandPrint(Defines.NS_CLIENT, adr, "getchallenge\n");
} }
@@ -715,10 +713,11 @@ public final class CL {
time = (int) (Timer.Milliseconds() - Globals.cl.timedemo_start); time = (int) (Timer.Milliseconds() - Globals.cl.timedemo_start);
if (time > 0) if (time > 0)
Com.Printf("%i frames, %3.1f seconds: %3.1f fps\n", logger.info(String.format("%d frames, %3.1f seconds: %3.1f fps",
new Vargs(3).add(Globals.cl.timedemo_frames).add( Globals.cl.timedemo_frames,
time / 1000.0).add( (time / 1000.0f),
Globals.cl.timedemo_frames * 1000.0 / time)); (Globals.cl.timedemo_frames * 1000.0f / time)
));
} }
Math3D.VectorClear(Globals.cl.refdef.blend); Math3D.VectorClear(Globals.cl.refdef.blend);
@@ -761,7 +760,7 @@ public final class CL {
s = MSG.ReadString(Globals.net_message); s = MSG.ReadString(Globals.net_message);
Com.Printf(s + "\n"); logger.info(s);
Menu.AddToServerList(Globals.net_from, s); Menu.AddToServerList(Globals.net_from, s);
} }
@@ -783,12 +782,12 @@ public final class CL {
c = Cmd.Argv(0); c = Cmd.Argv(0);
Com.Println(Globals.net_from.toString() + ": " + c); logger.info("{}: {}", Globals.net_from.toString(), c);
// server connection // server connection
if (c.equals("client_connect")) { if (c.equals("client_connect")) {
if (Globals.cls.state == Defines.ca_connected) { if (Globals.cls.state == Defines.ca_connected) {
Com.Printf("Dup connect received. Ignored.\n"); logger.info("Dup connect received. Ignored.");
return; return;
} }
Netchan.Setup(Defines.NS_CLIENT, Globals.cls.netchan, Netchan.Setup(Defines.NS_CLIENT, Globals.cls.netchan,
@@ -808,7 +807,7 @@ public final class CL {
// remote command from gui front end // remote command from gui front end
if (c.equals("cmd")) { if (c.equals("cmd")) {
if (!NET.IsLocalAddress(Globals.net_from)) { if (!NET.IsLocalAddress(Globals.net_from)) {
Com.Printf("Command packet from remote host. Ignored.\n"); logger.info("Command packet from remote host. Ignored.");
return; return;
} }
s = MSG.ReadString(Globals.net_message); s = MSG.ReadString(Globals.net_message);
@@ -820,7 +819,7 @@ public final class CL {
if (c.equals("print")) { if (c.equals("print")) {
s = MSG.ReadString(Globals.net_message); s = MSG.ReadString(Globals.net_message);
if (s.length() > 0) if (s.length() > 0)
Com.Printf(s); logger.info(s);
return; return;
} }
@@ -844,7 +843,7 @@ public final class CL {
return; return;
} }
Com.Printf("Unknown command.\n"); logger.warn("Unknown command.");
} }
@@ -872,8 +871,7 @@ public final class CL {
continue; // dump it if not connected continue; // dump it if not connected
if (Globals.net_message.cursize < 8) { if (Globals.net_message.cursize < 8) {
Com.Printf(NET.AdrToString(Globals.net_from) logger.info("{}: Runt packet", NET.AdrToString(Globals.net_from));
+ ": Runt packet\n");
continue; continue;
} }
@@ -898,7 +896,7 @@ public final class CL {
&& Globals.cls.realtime - Globals.cls.netchan.last_received > Globals.cl_timeout.value * 1000) { && Globals.cls.realtime - Globals.cls.netchan.last_received > Globals.cl_timeout.value * 1000) {
if (++Globals.cl.timeoutcount > 5) // timeoutcount saves debugger if (++Globals.cl.timeoutcount > 5) // timeoutcount saves debugger
{ {
Com.Printf("\nServer connection timed out.\n"); logger.info("Server connection timed out.");
Disconnect(); Disconnect();
return; return;
} }
@@ -1417,7 +1415,7 @@ public final class CL {
path = FS.Gamedir() + "/config.cfg"; path = FS.Gamedir() + "/config.cfg";
f = Lib.fopen(path, "rw"); f = Lib.fopen(path, "rw");
if (f == null) { if (f == null) {
Com.Printf("Couldn't write config.cfg.\n"); logger.warn("Couldn't write config.cfg.");
return; return;
} }
try { try {

View File

@@ -34,6 +34,8 @@ import lwjake2.render.model_t;
import lwjake2.sound.S; import lwjake2.sound.S;
import lwjake2.sys.Sys; import lwjake2.sys.Sys;
import lwjake2.util.Lib; import lwjake2.util.Lib;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
@@ -42,6 +44,7 @@ import java.io.RandomAccessFile;
* CL_parse * CL_parse
*/ */
public class CL_parse { public class CL_parse {
private static final Logger logger = LoggerFactory.getLogger(CL_parse.class);
//// cl_parse.c -- parse a message received from the server //// cl_parse.c -- parse a message received from the server
@@ -715,7 +718,15 @@ public class CL_parse {
S.StartLocalSound("misc/talk.wav"); S.StartLocalSound("misc/talk.wav");
Globals.con.ormask = 128; Globals.con.ormask = 128;
} }
Com.Printf(MSG.ReadString(Globals.net_message)); //TODO потом уброать
String msg = MSG.ReadString(Globals.net_message);
while (msg.startsWith("\n")) { msg = msg.substring(1); }
while (msg.endsWith("\n")) { msg = msg.substring(0, msg.lastIndexOf("\n")); }
while (msg.endsWith("\r")) { msg = msg.substring(0, msg.lastIndexOf("\r")); }
msg = msg.trim();
if (!msg.isEmpty()) {
logger.info(msg);
}
Globals.con.ormask = 0; Globals.con.ormask = 0;
break; break;

View File

@@ -28,6 +28,8 @@ import lwjake2.qcommon.FS;
import lwjake2.qcommon.xcommand_t; import lwjake2.qcommon.xcommand_t;
import lwjake2.util.Lib; import lwjake2.util.Lib;
import lwjake2.util.Vargs; import lwjake2.util.Vargs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
@@ -37,7 +39,7 @@ import java.util.Arrays;
* Console * Console
*/ */
public final class Console extends Globals { public final class Console extends Globals {
private static final Logger logger = LoggerFactory.getLogger(Console.class);
public static xcommand_t ToggleConsole_f = new xcommand_t() { public static xcommand_t ToggleConsole_f = new xcommand_t() {
public void execute() { public void execute() {
SCR.EndLoadingPlaque(); // get rid of loading plaque SCR.EndLoadingPlaque(); // get rid of loading plaque
@@ -86,7 +88,8 @@ public final class Console extends Globals {
String name; String name;
if (Cmd.Argc() != 2) { if (Cmd.Argc() != 2) {
Com.Printf("usage: condump <filename>\n"); logger.info("usage: condump <filename>");
return; return;
} }
@@ -94,11 +97,11 @@ public final class Console extends Globals {
// Cmd_Argv(1)); // Cmd_Argv(1));
name = FS.Gamedir() + "/" + Cmd.Argv(1) + ".txt"; name = FS.Gamedir() + "/" + Cmd.Argv(1) + ".txt";
Com.Printf("Dumped console text to " + name + ".\n"); logger.info("Dumped console text to {}", name);
FS.CreatePath(name); FS.CreatePath(name);
f = Lib.fopen(name, "rw"); f = Lib.fopen(name, "rw");
if (f == null) { if (f == null) {
Com.Printf("ERROR: couldn't open.\n"); logger.error("ERROR: couldn't open.");
return; return;
} }
@@ -148,7 +151,7 @@ public final class Console extends Globals {
CheckResize(); CheckResize();
Com.Printf("Console initialized.\n"); logger.info("Console initialized.");
// //
// register our commands // register our commands

View File

@@ -26,6 +26,8 @@ import lwjake2.qcommon.Com;
import lwjake2.qcommon.Cvar; import lwjake2.qcommon.Cvar;
import lwjake2.qcommon.xcommand_t; import lwjake2.qcommon.xcommand_t;
import lwjake2.util.Lib; import lwjake2.util.Lib;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
@@ -35,6 +37,7 @@ import java.util.Vector;
* Key * Key
*/ */
public class Key extends Globals { public class Key extends Globals {
private static final Logger logger = LoggerFactory.getLogger(Key.class);
// //
// these are the key numbers that should be passed to Key_Event // these are the key numbers that should be passed to Key_Event
// //
@@ -576,7 +579,7 @@ public class Key extends Globals {
Cbuf.AddText("\n"); Cbuf.AddText("\n");
Com.Printf(new String(Globals.key_lines[Globals.edit_line], 0, Lib.strlen(Globals.key_lines[Globals.edit_line])) + "\n"); logger.info(new String(Globals.key_lines[Globals.edit_line], 0, Lib.strlen(Globals.key_lines[Globals.edit_line])));
Globals.edit_line = (Globals.edit_line + 1) & 31; Globals.edit_line = (Globals.edit_line + 1) & 31;
history_line = Globals.edit_line; history_line = Globals.edit_line;
@@ -665,11 +668,16 @@ public class Key extends Globals {
} }
private static void printCompletions(String type, Vector<String> compl) { private static void printCompletions(String type, Vector<String> compl) {
Com.Printf(type); StringBuilder sb = new StringBuilder(compl.size());
for (int i = 0; i < compl.size(); i++) { for (int i = 0; i < compl.size(); i++) {
Com.Printf((String)compl.get(i) + " "); sb.append(compl.get(i)).append(' ');
} }
Com.Printf("\n"); //TODO потом убрать
while (type.startsWith("\n")) { type = type.substring(1); }
while (type.endsWith("\n")) { type = type.substring(0, type.lastIndexOf("\n")); }
while (type.endsWith("\r")) { type = type.substring(0, type.lastIndexOf("\r")); }
type = type.trim();
logger.info("{} {}", type, sb.toString());
} }
static void CompleteCommand() { static void CompleteCommand() {

View File

@@ -33,6 +33,8 @@ import lwjake2.sound.S;
import lwjake2.sys.Timer; import lwjake2.sys.Timer;
import lwjake2.util.Lib; import lwjake2.util.Lib;
import lwjake2.util.Vargs; import lwjake2.util.Vargs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.Dimension; import java.awt.Dimension;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@@ -43,6 +45,7 @@ import java.util.Arrays;
* SCR * SCR
*/ */
public final class SCR extends Globals { public final class SCR extends Globals {
private static final Logger logger = LoggerFactory.getLogger(SCR.class);
// cl_scrn.c -- master for refresh, status bar, console, chat, notify, etc // cl_scrn.c -- master for refresh, status bar, console, chat, notify, etc
@@ -637,8 +640,7 @@ public final class SCR extends Globals {
stop = Timer.Milliseconds(); stop = Timer.Milliseconds();
time = (stop - start) / 1000.0f; time = (stop - start) / 1000.0f;
Com.Printf("%f seconds (%f fps)\n", new Vargs(2).add(time).add( logger.info(String.format("%f seconds (%f fps)", time, (128.0f / time)));
128.0f / time));
} }
static void DirtyScreen() { static void DirtyScreen() {
@@ -1758,8 +1760,7 @@ public final class SCR extends Globals {
return; return;
if (frame > cl.cinematicframe + 1) { if (frame > cl.cinematicframe + 1) {
Com.Println("Dropped frame: " + frame + " > " logger.info("Dropped frame: {} > {}", frame, (cl.cinematicframe + 1));
+ (cl.cinematicframe + 1));
cl.cinematictime = cls.realtime - cl.cinematicframe * 1000 / 14; cl.cinematictime = cls.realtime - cl.cinematicframe * 1000 / 14;
} }
@@ -1826,7 +1827,7 @@ public final class SCR extends Globals {
EndLoadingPlaque(); EndLoadingPlaque();
cls.state = ca_active; cls.state = ca_active;
if (size == 0 || cin.pic == null) { if (size == 0 || cin.pic == null) {
Com.Println(name + " not found."); logger.info("{} not found.", name);
cl.cinematictime = 0; cl.cinematictime = 0;
} }
return; return;

View File

@@ -27,6 +27,8 @@ import lwjake2.qcommon.xcommand_t;
import lwjake2.sys.Timer; import lwjake2.sys.Timer;
import lwjake2.util.Math3D; import lwjake2.util.Math3D;
import lwjake2.util.Vargs; import lwjake2.util.Vargs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
@@ -35,6 +37,7 @@ import java.nio.FloatBuffer;
* V * V
*/ */
public final class V extends Globals { public final class V extends Globals {
private static final Logger logger = LoggerFactory.getLogger(V.class);
static cvar_t cl_testblend; static cvar_t cl_testblend;
@@ -360,8 +363,7 @@ public final class V extends Globals {
re.RenderFrame(cl.refdef); re.RenderFrame(cl.refdef);
if (cl_stats.value != 0.0f) if (cl_stats.value != 0.0f)
Com.Printf("ent:%i lt:%i part:%i\n", new Vargs(3).add( logger.info("ent:{} lt:{} part:{}", r_numentities, r_numdlights, r_numparticles);
r_numentities).add(r_numdlights).add(r_numparticles));
if (log_stats.value != 0.0f && (log_stats_file != null)) if (log_stats.value != 0.0f && (log_stats_file != null))
try { try {
log_stats_file.write(r_numentities + "," + r_numdlights + "," log_stats_file.write(r_numentities + "," + r_numdlights + ","
@@ -381,10 +383,12 @@ public final class V extends Globals {
*/ */
static xcommand_t Viewpos_f = new xcommand_t() { static xcommand_t Viewpos_f = new xcommand_t() {
public void execute() { public void execute() {
Com.Printf("(%i %i %i) : %i\n", new Vargs(4).add( logger.info("({} {} {}) : {}",
(int) cl.refdef.vieworg[0]).add((int) cl.refdef.vieworg[1]) (int) cl.refdef.vieworg[0],
.add((int) cl.refdef.vieworg[2]).add( (int) cl.refdef.vieworg[1],
(int) cl.refdef.viewangles[YAW])); (int) cl.refdef.vieworg[2],
(int) cl.refdef.viewangles[YAW]
);
} }
}; };

View File

@@ -29,6 +29,8 @@ import lwjake2.render.Renderer;
import lwjake2.sound.S; import lwjake2.sound.S;
import lwjake2.sys.IN; import lwjake2.sys.IN;
import lwjake2.util.Vargs; import lwjake2.util.Vargs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.DisplayMode; import java.awt.DisplayMode;
@@ -41,6 +43,7 @@ import java.awt.DisplayMode;
* @author cwei * @author cwei
*/ */
public class VID extends Globals { public class VID extends Globals {
private static final Logger logger = LoggerFactory.getLogger(VID.class);
// Main windowed and fullscreen graphics interface module. This module // Main windowed and fullscreen graphics interface module. This module
// is used for both the software and OpenGL rendering versions of the // is used for both the software and OpenGL rendering versions of the
// Quake refresh engine. // Quake refresh engine.
@@ -75,7 +78,11 @@ public class VID extends Globals {
*/ */
public static void Printf(int print_level, String fmt) { public static void Printf(int print_level, String fmt) {
Printf(print_level, fmt, null); while (fmt.startsWith("\n")) { fmt = fmt.substring(1); }
while (fmt.endsWith("\n")) { fmt = fmt.substring(0, fmt.lastIndexOf("\n")); }
while (fmt.endsWith("\r")) { fmt = fmt.substring(0, fmt.lastIndexOf("\r")); }
fmt = fmt.trim();
logger.warn("{}", fmt);
} }
public static void Printf(int print_level, String fmt, Vargs vargs) { public static void Printf(int print_level, String fmt, Vargs vargs) {
@@ -174,7 +181,8 @@ public class VID extends Globals {
FreeReflib(); FreeReflib();
} }
Com.Printf( "------- Loading " + name + " -------\n"); logger.info("------- Loading {} -------", name);
boolean found = false; boolean found = false;
@@ -187,11 +195,11 @@ public class VID extends Globals {
} }
if (!found) { if (!found) {
Com.Printf( "LoadLibrary(\"" + name +"\") failed\n"); logger.warn("LoadLibrary(\"{}\") failed", name);
return false; return false;
} }
Com.Printf( "LoadLibrary(\"" + name +"\")\n" ); logger.info("LoadLibrary(\"{}\")", name);
Globals.re = Renderer.getDriver(name); Globals.re = Renderer.getDriver(name);
if (Globals.re == null) if (Globals.re == null)
@@ -217,7 +225,7 @@ public class VID extends Globals {
/* Init KBD */ /* Init KBD */
Globals.re.getKeyboardHandler().Init(); Globals.re.getKeyboardHandler().Init();
Com.Printf( "------------------------------------\n"); logger.info("------------------------------------");
reflib_active = true; reflib_active = true;
return true; return true;
} }
@@ -263,10 +271,10 @@ public class VID extends Globals {
} }
if ( vid_ref.string.equals(Renderer.getDefaultName())) { if ( vid_ref.string.equals(Renderer.getDefaultName())) {
renderer = vid_ref.string; renderer = vid_ref.string;
Com.Printf("Refresh failed\n"); logger.info("Refresh failed");
gl_mode = Cvar.Get( "gl_mode", "0", 0 ); gl_mode = Cvar.Get( "gl_mode", "0", 0 );
if (gl_mode.value != 0.0f) { if (gl_mode.value != 0.0f) {
Com.Printf("Trying mode 0\n"); logger.info("Trying mode 0");
Cvar.SetValue("gl_mode", 0); Cvar.SetValue("gl_mode", 0);
if ( !LoadRefresh( vid_ref.string ) ) if ( !LoadRefresh( vid_ref.string ) )
Com.Error(Defines.ERR_FATAL, "Couldn't fall back to " + renderer +" refresh!"); Com.Error(Defines.ERR_FATAL, "Couldn't fall back to " + renderer +" refresh!");

View File

@@ -31,6 +31,8 @@ import lwjake2.qcommon.cmd_function_t;
import lwjake2.qcommon.xcommand_t; import lwjake2.qcommon.xcommand_t;
import lwjake2.server.SV_GAME; import lwjake2.server.SV_GAME;
import lwjake2.util.Lib; import lwjake2.util.Lib;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
@@ -40,34 +42,35 @@ import java.util.Vector;
* Cmd * Cmd
*/ */
public final class Cmd { public final class Cmd {
private static final Logger logger = LoggerFactory.getLogger(Cmd.class);
static xcommand_t List_f = new xcommand_t() { static xcommand_t List_f = new xcommand_t() {
public void execute() { public void execute() {
cmd_function_t cmd = Cmd.cmd_functions; cmd_function_t cmd = Cmd.cmd_functions;
int i = 0; int i = 0;
while (cmd != null) { while (cmd != null) {
Com.Printf(cmd.name + '\n'); logger.info(cmd.name);
i++; i++;
cmd = cmd.next; cmd = cmd.next;
} }
Com.Printf(i + " commands\n"); logger.info("{} commands", i);
} }
}; };
static xcommand_t Exec_f = new xcommand_t() { static xcommand_t Exec_f = new xcommand_t() {
public void execute() { public void execute() {
if (Cmd.Argc() != 2) { if (Cmd.Argc() != 2) {
Com.Printf("exec <filename> : execute a script file\n"); logger.info("exec <filename> : execute a script file");
return; return;
} }
byte[] f = null; byte[] f = null;
f = FS.LoadFile(Cmd.Argv(1)); f = FS.LoadFile(Cmd.Argv(1));
if (f == null) { if (f == null) {
Com.Printf("couldn't exec " + Cmd.Argv(1) + "\n"); logger.info("couldn't exec {}", Cmd.Argv(1));
return; return;
} }
Com.Printf("execing " + Cmd.Argv(1) + "\n"); logger.info("execing {}", Cmd.Argv(1));
Cbuf.InsertText(new String(f)); Cbuf.InsertText(new String(f));
@@ -77,10 +80,11 @@ public final class Cmd {
static xcommand_t Echo_f = new xcommand_t() { static xcommand_t Echo_f = new xcommand_t() {
public void execute() { public void execute() {
StringBuilder sb = new StringBuilder(Cmd.Argc());
for (int i = 1; i < Cmd.Argc(); i++) { for (int i = 1; i < Cmd.Argc(); i++) {
Com.Printf(Cmd.Argv(i) + " "); sb.append(Cmd.Argv(i)).append(' ');
} }
Com.Printf("'\n"); logger.info(sb.toString());
} }
}; };
@@ -88,16 +92,16 @@ public final class Cmd {
public void execute() { public void execute() {
cmdalias_t a = null; cmdalias_t a = null;
if (Cmd.Argc() == 1) { if (Cmd.Argc() == 1) {
Com.Printf("Current alias commands:\n"); logger.info("Current alias commands:");
for (a = Globals.cmd_alias; a != null; a = a.next) { for (a = Globals.cmd_alias; a != null; a = a.next) {
Com.Printf(a.name + " : " + a.value); logger.info("{} : {}", a.name, a.value);
} }
return; return;
} }
String s = Cmd.Argv(1); String s = Cmd.Argv(1);
if (s.length() > Defines.MAX_ALIAS_NAME) { if (s.length() > Defines.MAX_ALIAS_NAME) {
Com.Printf("Alias name is too long\n"); logger.warn("Alias name is too long");
return; return;
} }
@@ -191,8 +195,7 @@ public final class Cmd {
scan = text; scan = text;
if (len >= Defines.MAX_STRING_CHARS) { if (len >= Defines.MAX_STRING_CHARS) {
Com.Printf("Line exceeded " + Defines.MAX_STRING_CHARS logger.info("Line exceeded {} chars, discarded.", Defines.MAX_STRING_CHARS);
+ " chars, discarded.\n");
return null; return null;
} }
@@ -222,8 +225,7 @@ public final class Cmd {
len += j; len += j;
if (len >= Defines.MAX_STRING_CHARS) { if (len >= Defines.MAX_STRING_CHARS) {
Com.Printf("Expanded line exceeded " + Defines.MAX_STRING_CHARS logger.warn("Expanded line exceeded {} chars, discarded.", Defines.MAX_STRING_CHARS);
+ " chars, discarded.\n");
return null; return null;
} }
@@ -235,13 +237,13 @@ public final class Cmd {
scan = expanded; scan = expanded;
i--; i--;
if (++count == 100) { if (++count == 100) {
Com.Printf("Macro expansion loop, discarded.\n"); logger.info("Macro expansion loop, discarded.");
return null; return null;
} }
} }
if (inquote) { if (inquote) {
Com.Printf("Line has unmatched quote, discarded.\n"); logger.info("Line has unmatched quote, discarded.");
return null; return null;
} }
@@ -309,17 +311,14 @@ public final class Cmd {
//Com.DPrintf("Cmd_AddCommand: " + cmd_name + "\n"); //Com.DPrintf("Cmd_AddCommand: " + cmd_name + "\n");
// fail if the command is a variable name // fail if the command is a variable name
if ((Cvar.VariableString(cmd_name)).length() > 0) { if ((Cvar.VariableString(cmd_name)).length() > 0) {
Com.Printf("Cmd_AddCommand: " + cmd_name logger.warn("Cmd_AddCommand: {} already defined as a var", cmd_name);
+ " already defined as a var\n");
return; return;
} }
// fail if the command already exists // fail if the command already exists
for (cmd = cmd_functions; cmd != null; cmd = cmd.next) { for (cmd = cmd_functions; cmd != null; cmd = cmd.next) {
if (cmd_name.equals(cmd.name)) { if (cmd_name.equals(cmd.name)) {
Com logger.warn("Cmd_AddCommand: {} already defined", cmd_name);
.Printf("Cmd_AddCommand: " + cmd_name
+ " already defined\n");
return; return;
} }
} }
@@ -343,7 +342,7 @@ public final class Cmd {
while (true) { while (true) {
if (cmd == null) { if (cmd == null) {
Com.Printf("Cmd_RemoveCommand: " + cmd_name + " not added\n"); logger.info("Cmd_RemoveCommand: {} not added", cmd_name);
return; return;
} }
if (0 == Lib.strcmp(cmd_name, cmd.name)) { if (0 == Lib.strcmp(cmd_name, cmd.name)) {
@@ -421,7 +420,7 @@ public final class Cmd {
if (cmd_argv[0].equalsIgnoreCase(a.name)) { if (cmd_argv[0].equalsIgnoreCase(a.name)) {
if (++Globals.alias_count == ALIAS_LOOP_COUNT) { if (++Globals.alias_count == ALIAS_LOOP_COUNT) {
Com.Printf("ALIAS_LOOP_COUNT\n"); logger.info("ALIAS_LOOP_COUNT");
return; return;
} }
Cbuf.InsertText(a.value); Cbuf.InsertText(a.value);
@@ -1166,7 +1165,7 @@ public final class Cmd {
cmd = Cmd.Argv(0); cmd = Cmd.Argv(0);
if (Globals.cls.state <= Defines.ca_connected || cmd.charAt(0) == '-' if (Globals.cls.state <= Defines.ca_connected || cmd.charAt(0) == '-'
|| cmd.charAt(0) == '+') { || cmd.charAt(0) == '+') {
Com.Printf("Unknown command \"" + cmd + "\"\n"); logger.warn("Unknown command \"{}\"", cmd);
return; return;
} }

View File

@@ -27,10 +27,13 @@ import lwjake2.server.SV;
import lwjake2.server.SV_WORLD; import lwjake2.server.SV_WORLD;
import lwjake2.util.Lib; import lwjake2.util.Lib;
import lwjake2.util.Math3D; import lwjake2.util.Math3D;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.StringTokenizer; import java.util.StringTokenizer;
public class GameBase { public class GameBase {
private static final Logger logger = LoggerFactory.getLogger(GameBase.class);
public static cplane_t dummyplane = new cplane_t(); public static cplane_t dummyplane = new cplane_t();
public static game_locals_t game = new game_locals_t(); public static game_locals_t game = new game_locals_t();
@@ -239,7 +242,7 @@ public class GameBase {
edict_t choice[] = new edict_t[MAXCHOICES]; edict_t choice[] = new edict_t[MAXCHOICES];
if (targetname == null) { if (targetname == null) {
gi.dprintf("G_PickTarget called with null targetname\n"); logger.info("G_PickTarget called with null targetname");
return null; return null;
} }
@@ -252,7 +255,7 @@ public class GameBase {
} }
if (num_choices == 0) { if (num_choices == 0) {
gi.dprintf("G_PickTarget: target " + targetname + " not found\n"); logger.info("G_PickTarget: target {} not found", targetname);
return null; return null;
} }
@@ -396,7 +399,7 @@ public class GameBase {
}; };
public static void ShutdownGame() { public static void ShutdownGame() {
gi.dprintf("==== ShutdownGame ====\n"); logger.info("==== ShutdownGame ====");
} }
/** /**

View File

@@ -23,12 +23,14 @@ import lwjake2.Defines;
import lwjake2.qcommon.Com; import lwjake2.qcommon.Com;
import lwjake2.util.Lib; import lwjake2.util.Lib;
import lwjake2.util.Math3D; import lwjake2.util.Math3D;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.StringTokenizer; import java.util.StringTokenizer;
public class GameItems { public class GameItems {
private static final Logger logger = LoggerFactory.getLogger(GameItems.class);
public static gitem_armor_t jacketarmor_info = new gitem_armor_t(25, 50, public static gitem_armor_t jacketarmor_info = new gitem_armor_t(25, 50,
.30f, .00f, Defines.ARMOR_JACKET); .30f, .00f, Defines.ARMOR_JACKET);
public static gitem_armor_t combatarmor_info = new gitem_armor_t(50, 100, public static gitem_armor_t combatarmor_info = new gitem_armor_t(50, 100,
@@ -815,7 +817,7 @@ public class GameItems {
if (it.pickup_name.equalsIgnoreCase(pickup_name)) if (it.pickup_name.equalsIgnoreCase(pickup_name))
return it; return it;
} }
Com.Println("Item not found:" + pickup_name); logger.info("Item not found:{}", pickup_name);
return null; return null;
} }

View File

@@ -23,8 +23,11 @@ import lwjake2.Globals;
import lwjake2.qcommon.Com; import lwjake2.qcommon.Com;
import lwjake2.util.Lib; import lwjake2.util.Lib;
import lwjake2.util.QuakeFile; import lwjake2.util.QuakeFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GameSave { public class GameSave {
private static final Logger logger = LoggerFactory.getLogger(GameSave.class);
public static void CreateEdicts() { public static void CreateEdicts() {
GameBase.g_edicts = new edict_t[GameBase.game.maxentities]; GameBase.g_edicts = new edict_t[GameBase.game.maxentities];
@@ -114,7 +117,7 @@ public class GameSave {
* a new game is started or a save game is loaded. * a new game is started or a save game is loaded.
*/ */
public static void InitGame() { public static void InitGame() {
GameBase.gi.dprintf("==== InitGame ====\n"); logger.info("==== InitGame ====");
// preload all classes to register the adapters // preload all classes to register the adapters
for ( int n=0; n < preloadclasslist.length; n++) for ( int n=0; n < preloadclasslist.length; n++)

View File

@@ -42,9 +42,11 @@ import lwjake2.game.monsters.M_Supertank;
import lwjake2.game.monsters.M_Tank; import lwjake2.game.monsters.M_Tank;
import lwjake2.qcommon.Com; import lwjake2.qcommon.Com;
import lwjake2.util.Lib; import lwjake2.util.Lib;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GameSpawn { public class GameSpawn {
private static final Logger logger = LoggerFactory.getLogger(GameSpawn.class);
static EntThinkAdapter SP_item_health = new EntThinkAdapter() { static EntThinkAdapter SP_item_health = new EntThinkAdapter() {
public String getID(){ return "SP_item_health"; } public String getID(){ return "SP_item_health"; }
public boolean think(edict_t ent) { public boolean think(edict_t ent) {
@@ -352,7 +354,7 @@ public class GameSpawn {
static void ED_ParseField(String key, String value, edict_t ent) { static void ED_ParseField(String key, String value, edict_t ent) {
if (key.equals("nextmap")) if (key.equals("nextmap"))
Com.Println("nextmap: " + value); logger.info("nextmap: {}", value);
if (!GameBase.st.set(key, value)) if (!GameBase.st.set(key, value))
if (!ent.setField(key, value)) if (!ent.setField(key, value))
GameBase.gi.dprintf("??? The key [" + key GameBase.gi.dprintf("??? The key [" + key

View File

@@ -176,25 +176,26 @@ public class player_state_t {
} }
/** Prints the player state. */ /** Prints the player state. */
public void dump() { // метод не используется =(
pmove.dump(); // public void dump() {
// pmove.dump();
Lib.printv("viewangles", viewangles); //
Lib.printv("viewoffset", viewoffset); // Lib.printv("viewangles", viewangles);
Lib.printv("kick_angles", kick_angles); // Lib.printv("viewoffset", viewoffset);
Lib.printv("gunangles", gunangles); // Lib.printv("kick_angles", kick_angles);
Lib.printv("gunoffset", gunoffset); // Lib.printv("gunangles", gunangles);
// Lib.printv("gunoffset", gunoffset);
Com.Println("gunindex: " + gunindex); //
Com.Println("gunframe: " + gunframe); // Com.Println("gunindex: " + gunindex);
// Com.Println("gunframe: " + gunframe);
Lib.printv("blend", blend); //
// Lib.printv("blend", blend);
Com.Println("fov: " + fov); //
// Com.Println("fov: " + fov);
Com.Println("rdflags: " + rdflags); //
// Com.Println("rdflags: " + rdflags);
for (int n= 0; n < Defines.MAX_STATS; n++) //
System.out.println("stats[" + n + "]: " + stats[n]); // for (int n= 0; n < Defines.MAX_STATS; n++)
} // System.out.println("stats[" + n + "]: " + stats[n]);
// }
} }

View File

@@ -20,11 +20,14 @@ package lwjake2.game;
import lwjake2.qcommon.Com; import lwjake2.qcommon.Com;
import lwjake2.util.Math3D; import lwjake2.util.Math3D;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
public class pmove_state_t { public class pmove_state_t {
private final Logger logger = LoggerFactory.getLogger(pmove_state_t.class);
// this structure needs to be communicated bit-accurate // this structure needs to be communicated bit-accurate
// from the server to the client to guarantee that // from the server to the client to guarantee that
// prediction stays in sync, so no floats are used. // prediction stays in sync, so no floats are used.
@@ -129,22 +132,22 @@ public class pmove_state_t {
} }
public void dump() { public void dump() {
Com.Println("pm_type: " + pm_type); logger.info("pm_type: {}", pm_type);
Com.Println("origin[0]: " + origin[0]); logger.info("origin[0]: {}", origin[0]);
Com.Println("origin[1]: " + origin[0]); logger.info("origin[1]: {}", origin[1]);
Com.Println("origin[2]: " + origin[0]); logger.info("origin[2]: {}", origin[2]);
Com.Println("velocity[0]: " + velocity[0]); logger.info("velocity[0]: {}", velocity[0]);
Com.Println("velocity[1]: " + velocity[1]); logger.info("velocity[1]: {}", velocity[1]);
Com.Println("velocity[2]: " + velocity[2]); logger.info("velocity[2]: {}", velocity[2]);
Com.Println("pmflags: " + pm_flags); logger.info("pmflags: {}", pm_flags);
Com.Println("pmtime: " + pm_time); logger.info("pmtime: {}", pm_time);
Com.Println("gravity: " + gravity); logger.info("gravity: {}", gravity);
Com.Println("delta-angle[0]: " + delta_angles[0]); logger.info("delta-angle[0]: {}", delta_angles[0]);
Com.Println("delta-angle[1]: " + delta_angles[0]); logger.info("delta-angle[1]: {}", delta_angles[1]);
Com.Println("delta-angle[2]: " + delta_angles[0]); logger.info("delta-angle[2]: {}", delta_angles[2]);
} }
} }

View File

@@ -22,12 +22,14 @@ import lwjake2.Defines;
import lwjake2.Globals; import lwjake2.Globals;
import lwjake2.game.Cmd; import lwjake2.game.Cmd;
import lwjake2.util.Lib; import lwjake2.util.Lib;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Cbuf * Cbuf
*/ */
public final class Cbuf { public final class Cbuf {
private static final Logger logger = LoggerFactory.getLogger(Cbuf.class);
private static final byte[] line = new byte[1024]; private static final byte[] line = new byte[1024];
private static final byte[] tmp = new byte[8192]; private static final byte[] tmp = new byte[8192];
@@ -135,7 +137,7 @@ public final class Cbuf {
int l = text.length(); int l = text.length();
if (Globals.cmd_text.cursize + l >= Globals.cmd_text.maxsize) { if (Globals.cmd_text.cursize + l >= Globals.cmd_text.maxsize) {
Com.Printf("Cbuf_AddText: overflow\n"); logger.warn("Cbuf_AddText: overflow");
return; return;
} }
SZ.Write(Globals.cmd_text, Lib.stringToBytes(text), l); SZ.Write(Globals.cmd_text, Lib.stringToBytes(text), l);

View File

@@ -342,18 +342,6 @@ public final class Com
public static void Printf(String fmt, Vargs vargs) public static void Printf(String fmt, Vargs vargs)
{ {
String msg= sprintf(_debugContext + fmt, vargs); String msg= sprintf(_debugContext + fmt, vargs);
if (rd_target != 0)
{
if ((msg.length() + rd_buffer.length()) > (rd_buffersize - 1))
{
rd_flusher.rd_flush(rd_target, rd_buffer);
rd_buffer.setLength(0);
}
rd_buffer.append(msg);
return;
}
Console.Print(msg);
// also echo to debugging console // also echo to debugging console
while (msg.startsWith("\n")) { msg = msg.substring(1); } while (msg.startsWith("\n")) { msg = msg.substring(1); }
@@ -361,15 +349,10 @@ public final class Com
while (msg.endsWith("\r")) { msg = msg.substring(0, msg.lastIndexOf("\r")); } while (msg.endsWith("\r")) { msg = msg.substring(0, msg.lastIndexOf("\r")); }
msg = msg.trim(); msg = msg.trim();
if (!msg.isEmpty()) { if (!msg.isEmpty()) {
logger.info(msg); logger.warn(msg);
} }
} }
public static void Println(String fmt)
{
Printf(_debugContext + fmt + "\n");
}
public static String sprintf(String fmt, Vargs vargs) public static String sprintf(String fmt, Vargs vargs)
{ {
String msg= ""; String msg= "";

View File

@@ -23,6 +23,8 @@ import lwjake2.Globals;
import lwjake2.game.Cmd; import lwjake2.game.Cmd;
import lwjake2.game.cvar_t; import lwjake2.game.cvar_t;
import lwjake2.sys.Sys; import lwjake2.sys.Sys;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@@ -43,7 +45,7 @@ import java.util.List;
* @author cwei * @author cwei
*/ */
public final class FS extends Globals { public final class FS extends Globals {
private static final Logger logger = LoggerFactory.getLogger(FS.class);
/* /*
* ================================================== * ==================================================
* *
@@ -143,7 +145,7 @@ public final class FS extends Globals {
if (index > 0) { if (index > 0) {
File f = new File(path.substring(0, index)); File f = new File(path.substring(0, index));
if (!f.mkdirs() && !f.isDirectory()) { if (!f.mkdirs() && !f.isDirectory()) {
Com.Printf("can't create path \"" + path + '"' + "\n"); logger.warn("can't create path \"{}\"", path);
} }
} }
} }
@@ -581,8 +583,7 @@ public final class FS extends Globals {
pack.numfiles = numpackfiles; pack.numfiles = numpackfiles;
pack.files = newfiles; pack.files = newfiles;
Com.Printf("Added packfile " + packfile + " (" + numpackfiles logger.info("Added packfile {} ({} files)", packfile, numpackfiles);
+ " files)\n");
return pack; return pack;
} }
@@ -684,7 +685,7 @@ public final class FS extends Globals {
if (dir.indexOf("..") != -1 || dir.indexOf("/") != -1 if (dir.indexOf("..") != -1 || dir.indexOf("/") != -1
|| dir.indexOf("\\") != -1 || dir.indexOf(":") != -1) { || dir.indexOf("\\") != -1 || dir.indexOf(":") != -1) {
Com.Printf("Gamedir should be a single filename, not a path\n"); logger.warn("Gamedir should be a single filename, not a path");
return; return;
} }
@@ -737,7 +738,7 @@ public final class FS extends Globals {
filelink_t entry = null; filelink_t entry = null;
if (Cmd.Argc() != 3) { if (Cmd.Argc() != 3) {
Com.Printf("USAGE: link <from> <to>\n"); logger.info("USAGE: link <from> <to>");
return; return;
} }
@@ -805,8 +806,8 @@ public final class FS extends Globals {
if (tmp != null) if (tmp != null)
tmp.replaceAll("\\\\", "/"); tmp.replaceAll("\\\\", "/");
Com.Printf("Directory of " + findname + '\n'); logger.info("Directory of {}", findname);
Com.Printf("----\n"); logger.info("----");
dirnames = ListFiles(findname, 0, 0); dirnames = ListFiles(findname, 0, 0);
@@ -814,15 +815,13 @@ public final class FS extends Globals {
int index = 0; int index = 0;
for (int i = 0; i < dirnames.length; i++) { for (int i = 0; i < dirnames.length; i++) {
if ((index = dirnames[i].lastIndexOf('/')) > 0) { if ((index = dirnames[i].lastIndexOf('/')) > 0) {
Com.Printf(dirnames[i].substring(index + 1, dirnames[i] logger.info(dirnames[i].substring(index + 1, dirnames[i].length()));
.length()) + '\n');
} else { } else {
Com.Printf(dirnames[i] + '\n'); logger.info(dirnames[i]);
} }
} }
} }
Com.Printf("\n");
} }
} }
@@ -834,21 +833,20 @@ public final class FS extends Globals {
searchpath_t s; searchpath_t s;
filelink_t link; filelink_t link;
Com.Printf("Current search path:\n"); logger.info("Current search path:");
for (s = fs_searchpaths; s != null; s = s.next) { for (s = fs_searchpaths; s != null; s = s.next) {
if (s == fs_base_searchpaths) if (s == fs_base_searchpaths)
Com.Printf("----------\n"); logger.info("----------");
if (s.pack != null) if (s.pack != null)
Com.Printf(s.pack.filename + " (" + s.pack.numfiles logger.info("{} ({} files)", s.pack.filename, s.pack.numfiles);
+ " files)\n");
else else
Com.Printf(s.filename + '\n'); logger.info(s.filename);
} }
Com.Printf("\nLinks:\n"); logger.info("Links:");
for (Iterator<filelink_t> it = fs_links.iterator(); it.hasNext();) { for (Iterator<filelink_t> it = fs_links.iterator(); it.hasNext();) {
link = it.next(); link = it.next();
Com.Printf(link.from + " : " + link.to + '\n'); logger.info("{} : {}", link.from, link.to);
} }
} }

View File

@@ -28,6 +28,8 @@ import lwjake2.sys.NET;
import lwjake2.sys.Sys; import lwjake2.sys.Sys;
import lwjake2.sys.Timer; import lwjake2.sys.Timer;
import lwjake2.util.Vargs; import lwjake2.util.Vargs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
@@ -37,7 +39,7 @@ import java.io.IOException;
* namely initialization, shutdown and frame generation. * namely initialization, shutdown and frame generation.
*/ */
public final class Qcommon extends Globals { public final class Qcommon extends Globals {
private static final Logger logger = LoggerFactory.getLogger(Qcommon.class);
public static final String BUILDSTRING = "Java " + System.getProperty("java.version");; public static final String BUILDSTRING = "Java " + System.getProperty("java.version");;
public static final String CPUSTRING = System.getProperty("os.arch"); public static final String CPUSTRING = System.getProperty("os.arch");
@@ -122,7 +124,7 @@ public final class Qcommon extends Globals {
SCR.EndLoadingPlaque(); SCR.EndLoadingPlaque();
} }
Com.Printf("====== Quake2 Initialized ======\n\n"); logger.info("====== Quake2 Initialized ======");
// save config when configuration is completed // save config when configuration is completed
CL.WriteConfiguration(); CL.WriteConfiguration();
@@ -184,9 +186,7 @@ public final class Qcommon extends Globals {
} }
if (Globals.showtrace.value != 0.0f) { if (Globals.showtrace.value != 0.0f) {
Com.Printf("%4i traces %4i points\n", logger.info(String.format("%4d traces %4d points", Globals.c_traces, Globals.c_pointcontents));
new Vargs(2).add(Globals.c_traces)
.add(Globals.c_pointcontents));
Globals.c_traces= 0; Globals.c_traces= 0;
@@ -223,8 +223,7 @@ public final class Qcommon extends Globals {
sv -= gm; sv -= gm;
cl -= rf; cl -= rf;
Com.Printf("all:%3i sv:%3i gm:%3i cl:%3i rf:%3i\n", logger.info(String.format("all:%3d sv:%3d gm:%3d cl:%3d rf:%3d", all, sv, gm, cl, rf));
new Vargs(5).add(all).add(sv).add(gm).add(cl).add(rf));
} }
} catch (longjmpException e) { } catch (longjmpException e) {

View File

@@ -32,6 +32,8 @@ import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display; import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode; import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* LWJGLBase * LWJGLBase
@@ -39,6 +41,7 @@ import org.lwjgl.opengl.GL11;
* @author dsanders/cwei * @author dsanders/cwei
*/ */
public abstract class LWJGLBase { public abstract class LWJGLBase {
private final Logger logger = LoggerFactory.getLogger(LWJGLBase.class);
// IMPORTED FUNCTIONS // IMPORTED FUNCTIONS
protected DisplayMode oldDisplayMode; protected DisplayMode oldDisplayMode;
@@ -207,9 +210,7 @@ public abstract class LWJGLBase {
Dimension newDim = new Dimension(); Dimension newDim = new Dimension();
VID.Printf(Defines.PRINT_ALL, "Initializing OpenGL display\n"); logger.info("Initializing OpenGL display");
VID.Printf(Defines.PRINT_ALL, "...setting mode " + mode + ":");
/* /*
* fullscreen handling * fullscreen handling
@@ -219,11 +220,11 @@ public abstract class LWJGLBase {
} }
if (!VID.GetModeInfo(newDim, mode)) { if (!VID.GetModeInfo(newDim, mode)) {
VID.Printf(Defines.PRINT_ALL, " invalid mode\n"); logger.warn("...setting mode {}: invalid mode", mode);
return rserr_invalid_mode; return rserr_invalid_mode;
} }
VID.Printf(Defines.PRINT_ALL, " " + newDim.width + " " + newDim.height + '\n'); logger.info("...setting mode {}: {} {}", mode, newDim.width, newDim.height);
// destroy the existing window // destroy the existing window
GLimp_Shutdown(); GLimp_Shutdown();
@@ -254,7 +255,7 @@ public abstract class LWJGLBase {
return rserr_invalid_fullscreen; return rserr_invalid_fullscreen;
} }
VID.Printf(Defines.PRINT_ALL, "...setting fullscreen " + getModeString(displayMode) + '\n'); logger.info("...setting fullscreen {}", getModeString(displayMode));
} }
else else

View File

@@ -47,6 +47,8 @@ import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.ARBMultitexture; import org.lwjgl.opengl.ARBMultitexture;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13; import org.lwjgl.opengl.GL13;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Main * Main
@@ -54,7 +56,7 @@ import org.lwjgl.opengl.GL13;
* @author cwei * @author cwei
*/ */
public abstract class Main extends Base { public abstract class Main extends Base {
private final Logger logger = LoggerFactory.getLogger(Main.class);
public static int[] d_8to24table = new int[256]; public static int[] d_8to24table = new int[256];
int c_visible_lightmaps; int c_visible_lightmaps;
@@ -1037,19 +1039,19 @@ public abstract class Main extends Base {
if (err == rserr_invalid_fullscreen) { if (err == rserr_invalid_fullscreen) {
Cvar.SetValue("vid_fullscreen", 0); Cvar.SetValue("vid_fullscreen", 0);
vid_fullscreen.modified = false; vid_fullscreen.modified = false;
VID.Printf(Defines.PRINT_ALL, "ref_gl::R_SetMode() - fullscreen unavailable in this mode\n"); logger.warn("ref_gl::R_SetMode() - fullscreen unavailable in this mode");
if ((err = GLimp_SetMode(dim, (int) gl_mode.value, false)) == rserr_ok) if ((err = GLimp_SetMode(dim, (int) gl_mode.value, false)) == rserr_ok)
return true; return true;
} }
else if (err == rserr_invalid_mode) { else if (err == rserr_invalid_mode) {
Cvar.SetValue("gl_mode", gl_state.prev_mode); Cvar.SetValue("gl_mode", gl_state.prev_mode);
gl_mode.modified = false; gl_mode.modified = false;
VID.Printf(Defines.PRINT_ALL, "ref_gl::R_SetMode() - invalid mode\n"); logger.warn("ref_gl::R_SetMode() - invalid mode");
} }
// try setting it back to something safe // try setting it back to something safe
if ((err = GLimp_SetMode(dim, gl_state.prev_mode, false)) != rserr_ok) { if ((err = GLimp_SetMode(dim, gl_state.prev_mode, false)) != rserr_ok) {
VID.Printf(Defines.PRINT_ALL, "ref_gl::R_SetMode() - could not revert to safe mode\n"); logger.warn("ref_gl::R_SetMode() - could not revert to safe mode");
return false; return false;
} }
} }
@@ -1070,7 +1072,7 @@ public abstract class Main extends Base {
r_turbsin[j] = Warp.SIN[j] * 0.5f; r_turbsin[j] = Warp.SIN[j] * 0.5f;
} }
VID.Printf(Defines.PRINT_ALL, "ref_gl version: " + REF_VERSION + '\n'); logger.info("ref_gl version: {}", REF_VERSION);
Draw_GetPalette(); Draw_GetPalette();
@@ -1081,7 +1083,7 @@ public abstract class Main extends Base {
// create the window and set up the context // create the window and set up the context
if (!R_SetMode()) { if (!R_SetMode()) {
VID.Printf(Defines.PRINT_ALL, "ref_gl::R_Init() - could not R_SetMode()\n"); logger.info("ref_gl::R_Init() - could not R_SetMode()");
return false; return false;
} }
return true; return true;
@@ -1097,13 +1099,13 @@ public abstract class Main extends Base {
** get our various GL strings ** get our various GL strings
*/ */
gl_config.vendor_string = GL11.glGetString(GL11.GL_VENDOR); gl_config.vendor_string = GL11.glGetString(GL11.GL_VENDOR);
VID.Printf(Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\n'); logger.info("GL_VENDOR: {}", gl_config.vendor_string);
gl_config.renderer_string = GL11.glGetString(GL11.GL_RENDERER); gl_config.renderer_string = GL11.glGetString(GL11.GL_RENDERER);
VID.Printf(Defines.PRINT_ALL, "GL_RENDERER: " + gl_config.renderer_string + '\n'); logger.info("GL_RENDERER: {}", gl_config.renderer_string);
gl_config.version_string = GL11.glGetString(GL11.GL_VERSION); gl_config.version_string = GL11.glGetString(GL11.GL_VERSION);
VID.Printf(Defines.PRINT_ALL, "GL_VERSION: " + gl_config.version_string + '\n'); logger.info("GL_VERSION: {}", gl_config.version_string);
gl_config.extensions_string = GL11.glGetString(GL11.GL_EXTENSIONS); gl_config.extensions_string = GL11.glGetString(GL11.GL_EXTENSIONS);
VID.Printf(Defines.PRINT_ALL, "GL_EXTENSIONS: " + gl_config.extensions_string + '\n'); logger.info("GL_EXTENSIONS: {}", gl_config.extensions_string);
gl_config.parseOpenGLVersion(); gl_config.parseOpenGLVersion();
@@ -1137,7 +1139,7 @@ public abstract class Main extends Base {
if (monolightmap.length() < 2 || monolightmap.charAt(1) != 'F') { if (monolightmap.length() < 2 || monolightmap.charAt(1) != 'F') {
if (gl_config.renderer == GL_RENDERER_PERMEDIA2) { if (gl_config.renderer == GL_RENDERER_PERMEDIA2) {
Cvar.Set("gl_monolightmap", "A"); Cvar.Set("gl_monolightmap", "A");
VID.Printf(Defines.PRINT_ALL, "...using gl_monolightmap 'a'\n"); logger.info("...using gl_monolightmap 'a'");
} }
else if ((gl_config.renderer & GL_RENDERER_POWERVR) != 0) { else if ((gl_config.renderer & GL_RENDERER_POWERVR) != 0) {
Cvar.Set("gl_monolightmap", "0"); Cvar.Set("gl_monolightmap", "0");
@@ -1172,16 +1174,16 @@ public abstract class Main extends Base {
} }
if (gl_config.allow_cds) if (gl_config.allow_cds)
VID.Printf(Defines.PRINT_ALL, "...allowing CDS\n"); logger.info("...allowing CDS");
else else
VID.Printf(Defines.PRINT_ALL, "...disabling CDS\n"); logger.info("...disabling CDS");
/* /*
** grab extensions ** grab extensions
*/ */
if (gl_config.extensions_string.indexOf("GL_EXT_compiled_vertex_array") >= 0 if (gl_config.extensions_string.indexOf("GL_EXT_compiled_vertex_array") >= 0
|| gl_config.extensions_string.indexOf("GL_SGI_compiled_vertex_array") >= 0) { || gl_config.extensions_string.indexOf("GL_SGI_compiled_vertex_array") >= 0) {
VID.Printf(Defines.PRINT_ALL, "...enabling GL_EXT_compiled_vertex_array\n"); logger.info("...enabling GL_EXT_compiled_vertex_array");
// qglLockArraysEXT = ( void * ) qwglGetProcAddress( "glLockArraysEXT" ); // qglLockArraysEXT = ( void * ) qwglGetProcAddress( "glLockArraysEXT" );
if (gl_ext_compiled_vertex_array.value != 0.0f) if (gl_ext_compiled_vertex_array.value != 0.0f)
qglLockArraysEXT = true; qglLockArraysEXT = true;
@@ -1191,16 +1193,16 @@ public abstract class Main extends Base {
//qglUnlockArraysEXT = true; //qglUnlockArraysEXT = true;
} }
else { else {
VID.Printf(Defines.PRINT_ALL, "...GL_EXT_compiled_vertex_array not found\n"); logger.info("...GL_EXT_compiled_vertex_array not found");
qglLockArraysEXT = false; qglLockArraysEXT = false;
} }
if (gl_config.extensions_string.indexOf("WGL_EXT_swap_control") >= 0) { if (gl_config.extensions_string.indexOf("WGL_EXT_swap_control") >= 0) {
qwglSwapIntervalEXT = true; qwglSwapIntervalEXT = true;
VID.Printf(Defines.PRINT_ALL, "...enabling WGL_EXT_swap_control\n"); logger.info("...enabling WGL_EXT_swap_control");
} else { } else {
qwglSwapIntervalEXT = false; qwglSwapIntervalEXT = false;
VID.Printf(Defines.PRINT_ALL, "...WGL_EXT_swap_control not found\n"); logger.info("...WGL_EXT_swap_control not found");
} }
if (gl_config.extensions_string.indexOf("GL_EXT_point_parameters") >= 0) { if (gl_config.extensions_string.indexOf("GL_EXT_point_parameters") >= 0) {
@@ -1208,14 +1210,14 @@ public abstract class Main extends Base {
// qglPointParameterfEXT = ( void (APIENTRY *)( GLenum, GLfloat ) ) qwglGetProcAddress( "glPointParameterfEXT" ); // qglPointParameterfEXT = ( void (APIENTRY *)( GLenum, GLfloat ) ) qwglGetProcAddress( "glPointParameterfEXT" );
qglPointParameterfEXT = true; qglPointParameterfEXT = true;
// qglPointParameterfvEXT = ( void (APIENTRY *)( GLenum, const GLfloat * ) ) qwglGetProcAddress( "glPointParameterfvEXT" ); // qglPointParameterfvEXT = ( void (APIENTRY *)( GLenum, const GLfloat * ) ) qwglGetProcAddress( "glPointParameterfvEXT" );
VID.Printf(Defines.PRINT_ALL, "...using GL_EXT_point_parameters\n"); logger.info("...using GL_EXT_point_parameters");
} }
else { else {
VID.Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_point_parameters\n"); logger.info("...ignoring GL_EXT_point_parameters");
} }
} }
else { else {
VID.Printf(Defines.PRINT_ALL, "...GL_EXT_point_parameters not found\n"); logger.info("...GL_EXT_point_parameters not found");
} }
// #ifdef __linux__ // #ifdef __linux__
@@ -1242,26 +1244,26 @@ public abstract class Main extends Base {
&& gl_config.extensions_string.indexOf("GL_EXT_paletted_texture") >= 0 && gl_config.extensions_string.indexOf("GL_EXT_paletted_texture") >= 0
&& gl_config.extensions_string.indexOf("GL_EXT_shared_texture_palette") >= 0) { && gl_config.extensions_string.indexOf("GL_EXT_shared_texture_palette") >= 0) {
if (gl_ext_palettedtexture.value != 0.0f) { if (gl_ext_palettedtexture.value != 0.0f) {
VID.Printf(Defines.PRINT_ALL, "...using GL_EXT_shared_texture_palette\n"); logger.info("...using GL_EXT_shared_texture_palette");
qglColorTableEXT = false; // true; TODO jogl bug qglColorTableEXT = false; // true; TODO jogl bug
} }
else { else {
VID.Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_shared_texture_palette\n"); logger.info("...ignoring GL_EXT_shared_texture_palette");
qglColorTableEXT = false; qglColorTableEXT = false;
} }
} }
else { else {
VID.Printf(Defines.PRINT_ALL, "...GL_EXT_shared_texture_palette not found\n"); logger.info("...GL_EXT_shared_texture_palette not found");
} }
if (gl_config.extensions_string.indexOf("GL_ARB_multitexture") >= 0) { if (gl_config.extensions_string.indexOf("GL_ARB_multitexture") >= 0) {
VID.Printf(Defines.PRINT_ALL, "...using GL_ARB_multitexture\n"); logger.info("...using GL_ARB_multitexture");
qglActiveTextureARB = true; qglActiveTextureARB = true;
GL_TEXTURE0 = ARBMultitexture.GL_TEXTURE0_ARB; GL_TEXTURE0 = ARBMultitexture.GL_TEXTURE0_ARB;
GL_TEXTURE1 = ARBMultitexture.GL_TEXTURE1_ARB; GL_TEXTURE1 = ARBMultitexture.GL_TEXTURE1_ARB;
} }
else { else {
VID.Printf(Defines.PRINT_ALL, "...GL_ARB_multitexture not found\n"); logger.info("...GL_ARB_multitexture not found");
} }
if (!(qglActiveTextureARB)) if (!(qglActiveTextureARB))

View File

@@ -41,6 +41,8 @@ import lwjake2.sys.Sys;
import lwjake2.util.Lib; import lwjake2.util.Lib;
import lwjake2.util.QuakeFile; import lwjake2.util.QuakeFile;
import lwjake2.util.Vargs; import lwjake2.util.Vargs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@@ -49,7 +51,7 @@ import java.io.RandomAccessFile;
import java.util.Calendar; import java.util.Calendar;
public class SV_CCMDS { public class SV_CCMDS {
private static final Logger logger = LoggerFactory.getLogger(SV_CCMDS.class);
/* /*
=============================================================================== ===============================================================================
@@ -768,45 +770,46 @@ public class SV_CCMDS {
Com.Printf("No server running.\n"); Com.Printf("No server running.\n");
return; return;
} }
Com.Printf("map : " + SV_INIT.sv.name + "\n"); logger.info("map : {}", SV_INIT.sv.name);
Com.Printf("num score ping name lastmsg address qport \n"); logger.info("num score ping name lastmsg address qport ");
Com.Printf("--- ----- ---- --------------- ------- --------------------- ------\n"); logger.info("--- ----- ---- --------------- ------- --------------------- ------");
for (i = 0; i < SV_MAIN.maxclients.value; i++) { for (i = 0; i < SV_MAIN.maxclients.value; i++) {
cl = SV_INIT.svs.clients[i]; cl = SV_INIT.svs.clients[i];
if (0 == cl.state) if (0 == cl.state)
continue; continue;
Com.Printf("%3i ", new Vargs().add(i)); StringBuilder sb = new StringBuilder();
Com.Printf("%5i ", new Vargs().add(cl.edict.client.ps.stats[Defines.STAT_FRAGS])); sb.append(String.format("%3d ", i))
.append(String.format("%5d ", cl.edict.client.ps.stats[Defines.STAT_FRAGS]));
if (cl.state == Defines.cs_connected) if (cl.state == Defines.cs_connected)
Com.Printf("CNCT "); sb.append("CNCT ");
else if (cl.state == Defines.cs_zombie) else if (cl.state == Defines.cs_zombie)
Com.Printf("ZMBI "); sb.append("ZMBI ");
else { else {
ping = cl.ping < 9999 ? cl.ping : 9999; ping = cl.ping < 9999 ? cl.ping : 9999;
Com.Printf("%4i ", new Vargs().add(ping)); sb.append(String.format("%4d ", ping));
} }
Com.Printf("%s", new Vargs().add(cl.name)); sb.append(cl.name);
l = 16 - cl.name.length(); l = 16 - cl.name.length();
for (j = 0; j < l; j++) for (j = 0; j < l; j++)
Com.Printf(" "); sb.append(' ');
Com.Printf("%7i ", new Vargs().add(SV_INIT.svs.realtime - cl.lastmessage)); sb.append(String.format("%7d ", (SV_INIT.svs.realtime - cl.lastmessage)));
s = NET.AdrToString(cl.netchan.remote_address); s = NET.AdrToString(cl.netchan.remote_address);
Com.Printf(s); sb.append(s);
l = 22 - s.length(); l = 22 - s.length();
for (j = 0; j < l; j++) for (j = 0; j < l; j++)
Com.Printf(" "); sb.append(' ');
Com.Printf("%5i", new Vargs().add(cl.netchan.qport)); sb.append(String.format("%5d", cl.netchan.qport));
Com.Printf("\n"); logger.info(sb.toString());
} }
Com.Printf("\n"); logger.info("");
} }
/* /*
================== ==================

View File

@@ -38,11 +38,14 @@ import lwjake2.qcommon.SZ;
import lwjake2.sys.NET; import lwjake2.sys.NET;
import lwjake2.util.Lib; import lwjake2.util.Lib;
import lwjake2.util.Math3D; import lwjake2.util.Math3D;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
public class SV_INIT { public class SV_INIT {
private static final Logger logger = LoggerFactory.getLogger(SV_INIT.class);
/** /**
* SV_FindIndex. * SV_FindIndex.
@@ -185,7 +188,7 @@ public class SV_INIT {
if (attractloop) if (attractloop)
Cvar.Set("paused", "0"); Cvar.Set("paused", "0");
Com.Printf("------- Server Initialization -------\n"); logger.info("------- Server Initialization -------");
Com.DPrintf("SpawnServer: " + server + "\n"); Com.DPrintf("SpawnServer: " + server + "\n");
if (sv.demofile != null) if (sv.demofile != null)
@@ -320,7 +323,7 @@ public class SV_INIT {
if (Cvar.VariableValue("coop") != 0 if (Cvar.VariableValue("coop") != 0
&& Cvar.VariableValue("deathmatch") != 0) { && Cvar.VariableValue("deathmatch") != 0) {
Com.Printf("Deathmatch and Coop both set, disabling Coop\n"); logger.info("Deathmatch and Coop both set, disabling Coop");
Cvar.FullSet("coop", "0", Defines.CVAR_SERVERINFO Cvar.FullSet("coop", "0", Defines.CVAR_SERVERINFO
| Defines.CVAR_LATCH); | Defines.CVAR_LATCH);
} }

View File

@@ -36,10 +36,13 @@ import lwjake2.qcommon.netadr_t;
import lwjake2.sys.NET; import lwjake2.sys.NET;
import lwjake2.sys.Timer; import lwjake2.sys.Timer;
import lwjake2.util.Lib; import lwjake2.util.Lib;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
public class SV_MAIN { public class SV_MAIN {
private static final Logger logger = LoggerFactory.getLogger(SV_MAIN.class);
/** Address of group servers. */ /** Address of group servers. */
public static netadr_t master_adr[] = new netadr_t[Defines.MAX_MASTERS]; public static netadr_t master_adr[] = new netadr_t[Defines.MAX_MASTERS];

View File

@@ -22,6 +22,8 @@ import lwjake2.Defines;
import lwjake2.game.cvar_t; import lwjake2.game.cvar_t;
import lwjake2.qcommon.Com; import lwjake2.qcommon.Com;
import lwjake2.qcommon.Cvar; import lwjake2.qcommon.Cvar;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.Vector; import java.util.Vector;
@@ -30,7 +32,7 @@ import java.util.Vector;
* S * S
*/ */
public class S { public class S {
private static final Logger logger = LoggerFactory.getLogger(S.class);
static Sound impl; static Sound impl;
static cvar_t s_impl; static cvar_t s_impl;
@@ -93,11 +95,11 @@ public class S {
*/ */
public static void Init() { public static void Init() {
Com.Printf("\n------- sound initialization -------\n"); logger.info("------- sound initialization -------");
cvar_t cv = Cvar.Get("s_initsound", "1", 0); cvar_t cv = Cvar.Get("s_initsound", "1", 0);
if (cv.value == 0.0f) { if (cv.value == 0.0f) {
Com.Printf("not initializing.\n"); logger.info("not initializing.");
useDriver("dummy"); useDriver("dummy");
return; return;
} }
@@ -119,7 +121,7 @@ public class S {
useDriver("dummy"); useDriver("dummy");
} }
Com.Printf("\n------- use sound driver \"" + impl.getName() + "\" -------\n"); logger.info("------- use sound driver \"{}\" -------", impl.getName());
StopAllSounds(); StopAllSounds();
} }

View File

@@ -21,11 +21,14 @@ package lwjake2.sound;
import lwjake2.Defines; import lwjake2.Defines;
import lwjake2.qcommon.Com; import lwjake2.qcommon.Com;
import lwjake2.qcommon.FS; import lwjake2.qcommon.FS;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* SND_MEM * SND_MEM
*/ */
public class WaveLoader { public class WaveLoader {
private static final Logger logger = LoggerFactory.getLogger(WaveLoader.class);
/** /**
* The ResampleSfx can squeeze and stretch samples to a default sample rate. * The ResampleSfx can squeeze and stretch samples to a default sample rate.
@@ -227,7 +230,7 @@ public class WaveLoader {
return; return;
} }
if (iff_chunk_len > 1024*1024) { if (iff_chunk_len > 1024*1024) {
Com.Println(" Warning: FindNextChunk: length is past the 1 meg sanity limit"); logger.warn("Warning: FindNextChunk: length is past the 1 meg sanity limit");
} }
data_p -= 8; data_p -= 8;
last_chunk = data_p + 8 + ((iff_chunk_len + 1) & ~1); last_chunk = data_p + 8 + ((iff_chunk_len + 1) & ~1);

View File

@@ -49,6 +49,8 @@ import org.lwjgl.openal.AL10;
import org.lwjgl.openal.ALC10; import org.lwjgl.openal.ALC10;
import org.lwjgl.openal.EFX10; import org.lwjgl.openal.EFX10;
import org.lwjgl.openal.OpenALException; import org.lwjgl.openal.OpenALException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* LWJGLSoundImpl * LWJGLSoundImpl
@@ -56,6 +58,7 @@ import org.lwjgl.openal.OpenALException;
* @author dsanders/cwei * @author dsanders/cwei
*/ */
public final class LWJGLSoundImpl implements Sound { public final class LWJGLSoundImpl implements Sound {
private final Logger logger = LoggerFactory.getLogger(LWJGLSoundImpl.class);
static { static {
S.register(new LWJGLSoundImpl()); S.register(new LWJGLSoundImpl());
@@ -85,7 +88,7 @@ public final class LWJGLSoundImpl implements Sound {
checkError(); checkError();
initOpenALExtensions(); initOpenALExtensions();
} catch (OpenALException e) { } catch (OpenALException e) {
Com.Printf(e.getMessage() + '\n'); logger.error(e.getMessage());
return false; return false;
} catch (Exception e) { } catch (Exception e) {
Com.DPrintf(e.getMessage() + '\n'); Com.DPrintf(e.getMessage() + '\n');
@@ -96,7 +99,7 @@ public final class LWJGLSoundImpl implements Sound {
s_volume = Cvar.Get("s_volume", "0.7", Defines.CVAR_ARCHIVE); s_volume = Cvar.Get("s_volume", "0.7", Defines.CVAR_ARCHIVE);
AL10.alGenBuffers(buffers); AL10.alGenBuffers(buffers);
int count = Channel.init(buffers); int count = Channel.init(buffers);
Com.Printf("... using " + count + " channels\n"); logger.info("... using {} channels", count);
AL10.alDistanceModel(AL10.AL_INVERSE_DISTANCE_CLAMPED); AL10.alDistanceModel(AL10.AL_INVERSE_DISTANCE_CLAMPED);
Cmd.AddCommand("play", new xcommand_t() { Cmd.AddCommand("play", new xcommand_t() {
public void execute() { public void execute() {
@@ -121,10 +124,10 @@ public final class LWJGLSoundImpl implements Sound {
num_sfx = 0; num_sfx = 0;
Com.Printf("sound sampling rate: 44100Hz\n"); logger.info("sound sampling rate: 44100Hz");
StopAllSounds(); StopAllSounds();
Com.Printf("------------------------------------\n"); logger.info("------------------------------------");
return true; return true;
} }
@@ -141,7 +144,7 @@ public final class LWJGLSoundImpl implements Sound {
String defaultSpecifier = ALC10.alcGetString(AL.getDevice(), ALC10.ALC_DEFAULT_DEVICE_SPECIFIER); String defaultSpecifier = ALC10.alcGetString(AL.getDevice(), ALC10.ALC_DEFAULT_DEVICE_SPECIFIER);
Com.Printf(os + " using " + ((deviceName == null) ? defaultSpecifier : deviceName) + '\n'); logger.info("{} using {}", os, ((deviceName == null) ? defaultSpecifier : deviceName));
// Check for an error. // Check for an error.
if (ALC10.alcGetError(AL.getDevice()) != ALC10.ALC_NO_ERROR) if (ALC10.alcGetError(AL.getDevice()) != ALC10.ALC_NO_ERROR)
@@ -153,7 +156,7 @@ public final class LWJGLSoundImpl implements Sound {
/** Initializes OpenAL EFX effects. */ /** Initializes OpenAL EFX effects. */
private void initOpenALExtensions() private void initOpenALExtensions()
{ {
Com.Printf("... using EFX effects:\n"); logger.info("... using EFX effects:");
underwaterFilter = new EFXFilterLowPass(); underwaterFilter = new EFXFilterLowPass();
underwaterFilter.setGain(1.0f); underwaterFilter.setGain(1.0f);
underwaterFilter.setGainHF(0.0f); underwaterFilter.setGainHF(0.0f);
@@ -586,27 +589,26 @@ public final class LWJGLSoundImpl implements Sound {
if (sc != null) { if (sc != null) {
size = sc.length * sc.width * (sc.stereo + 1); size = sc.length * sc.width * (sc.stereo + 1);
total += size; total += size;
if (sc.loopstart >= 0) logger.info(String.format("%s(%2db) %6d : %s",
Com.Printf("L"); (sc.loopstart >= 0 ? 'L' : ' '),
else (sc.width * 8), size, sfx.name)
Com.Printf(" "); );
Com.Printf("(%2db) %6i : %s\n", new Vargs(3).add(sc.width * 8).add(size).add(sfx.name));
} else { } else {
if (sfx.name.charAt(0) == '*') if (sfx.name.charAt(0) == '*')
Com.Printf(" placeholder : " + sfx.name + "\n"); logger.info(" placeholder : {}", sfx.name);
else else
Com.Printf(" not loaded : " + sfx.name + "\n"); logger.info(" not loaded : {}", sfx.name);
} }
} }
Com.Printf("Total resident: " + total + "\n"); logger.info("Total resident: {}", total);
} }
void SoundInfo_f() { void SoundInfo_f() {
//TODO параметры тут не нужны, сплошная статика
Com.Printf("%5d stereo\n", new Vargs(1).add(1)); logger.info(String.format("%5d stereo", 1));
Com.Printf("%5d samples\n", new Vargs(1).add(22050)); logger.info(String.format("%5d samples", 22050));
Com.Printf("%5d samplebits\n", new Vargs(1).add(16)); logger.info(String.format("%5d samplebits", 16));
Com.Printf("%5d speed\n", new Vargs(1).add(44100)); logger.info(String.format("%5d speed", 44100));
} }
} }

View File

@@ -26,6 +26,8 @@ import lwjake2.qcommon.Cvar;
import lwjake2.qcommon.netadr_t; import lwjake2.qcommon.netadr_t;
import lwjake2.qcommon.sizebuf_t; import lwjake2.qcommon.sizebuf_t;
import lwjake2.util.Lib; import lwjake2.util.Lib;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.net.DatagramSocket; import java.net.DatagramSocket;
@@ -36,7 +38,7 @@ import java.nio.ByteBuffer;
import java.nio.channels.DatagramChannel; import java.nio.channels.DatagramChannel;
public final class NET { public final class NET {
private static final Logger logger = LoggerFactory.getLogger(NET.class);
private final static int MAX_LOOPBACK = 4; private final static int MAX_LOOPBACK = 4;
/** Local loopback adress. */ /** Local loopback adress. */
@@ -136,7 +138,7 @@ public final class NET {
a.port = Lib.atoi(address[1]); a.port = Lib.atoi(address[1]);
return true; return true;
} catch (Exception e) { } catch (Exception e) {
Com.Println(e.getMessage()); logger.error(e.getMessage());
return false; return false;
} }
} }
@@ -227,7 +229,7 @@ public final class NET {
int packetLength = receiveBuffer.position(); int packetLength = receiveBuffer.position();
if (packetLength > net_message.maxsize) { if (packetLength > net_message.maxsize) {
Com.Println("Oversize packet from " + AdrToString(net_from)); logger.info("Oversize packet from {}", AdrToString(net_from));
return false; return false;
} }
@@ -265,7 +267,7 @@ public final class NET {
SocketAddress dstSocket = new InetSocketAddress(to.getInetAddress(), to.port); SocketAddress dstSocket = new InetSocketAddress(to.getInetAddress(), to.port);
ip_channels[sock].send(ByteBuffer.wrap(data, 0, length), dstSocket); ip_channels[sock].send(ByteBuffer.wrap(data, 0, length), dstSocket);
} catch (Exception e) { } catch (Exception e) {
Com.Println("NET_SendPacket ERROR: " + e + " to " + AdrToString(to)); logger.error(String.format("NET_SendPacket: %s to %s", e.getMessage(), AdrToString(to)), e);
} }
} }
@@ -345,7 +347,7 @@ public final class NET {
// the socket have to be broadcastable // the socket have to be broadcastable
newsocket.setBroadcast(true); newsocket.setBroadcast(true);
} catch (Exception e) { } catch (Exception e) {
Com.Println("Error: " + e.toString()); logger.error(String.format("Error: %s", e.getMessage()), e);
newsocket = null; newsocket = null;
} }
return newsocket; return newsocket;

View File

@@ -20,8 +20,11 @@ package lwjake2.sys;
import lwjake2.Globals; import lwjake2.Globals;
import lwjake2.qcommon.Com; import lwjake2.qcommon.Com;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class Timer { public abstract class Timer {
private static final Logger logger = LoggerFactory.getLogger(Timer.class);
abstract public long currentTimeMillis(); abstract public long currentTimeMillis();
@@ -33,7 +36,7 @@ public abstract class Timer {
} catch (Throwable e) { } catch (Throwable e) {
t = new StandardTimer(); t = new StandardTimer();
} }
Com.Println("using " + t.getClass().getName()); logger.info("using {}", t.getClass().getName());
} }
public static int Milliseconds() { public static int Milliseconds() {

View File

@@ -21,6 +21,8 @@ package lwjake2.util;
import lwjake2.Globals; import lwjake2.Globals;
import lwjake2.qcommon.Com; import lwjake2.qcommon.Com;
import lwjake2.qcommon.FS; import lwjake2.qcommon.FS;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@@ -32,7 +34,7 @@ import java.nio.FloatBuffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
public class Lib { public class Lib {
private static final Logger logger = LoggerFactory.getLogger(Lib.class);
/** Converts a vector to a string. */ /** Converts a vector to a string. */
public static String vtos(float[] v) { public static String vtos(float[] v) {
@@ -197,7 +199,7 @@ public class Lib {
/** Prints a vector to the quake console. */ /** Prints a vector to the quake console. */
public static void printv(String in, float arr[]) { public static void printv(String in, float arr[]) {
for (int n = 0; n < arr.length; n++) { for (int n = 0; n < arr.length; n++) {
Com.Println(in + "[" + n + "]: " + arr[n]); logger.info("{}[{}]: {}", in, n, arr[n]);
} }
} }