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

View File

@@ -34,6 +34,8 @@ import lwjake2.render.model_t;
import lwjake2.sound.S;
import lwjake2.sys.Sys;
import lwjake2.util.Lib;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.RandomAccessFile;
@@ -42,6 +44,7 @@ import java.io.RandomAccessFile;
* 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
@@ -715,7 +718,15 @@ public class CL_parse {
S.StartLocalSound("misc/talk.wav");
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;
break;

View File

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

View File

@@ -26,6 +26,8 @@ import lwjake2.qcommon.Com;
import lwjake2.qcommon.Cvar;
import lwjake2.qcommon.xcommand_t;
import lwjake2.util.Lib;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.RandomAccessFile;
@@ -35,6 +37,7 @@ import java.util.Vector;
* Key
*/
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
//
@@ -576,7 +579,7 @@ public class Key extends Globals {
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;
history_line = Globals.edit_line;
@@ -665,11 +668,16 @@ public class Key extends Globals {
}
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++) {
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() {

View File

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

View File

@@ -27,6 +27,8 @@ import lwjake2.qcommon.xcommand_t;
import lwjake2.sys.Timer;
import lwjake2.util.Math3D;
import lwjake2.util.Vargs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.nio.FloatBuffer;
@@ -35,6 +37,7 @@ import java.nio.FloatBuffer;
* V
*/
public final class V extends Globals {
private static final Logger logger = LoggerFactory.getLogger(V.class);
static cvar_t cl_testblend;
@@ -360,8 +363,7 @@ public final class V extends Globals {
re.RenderFrame(cl.refdef);
if (cl_stats.value != 0.0f)
Com.Printf("ent:%i lt:%i part:%i\n", new Vargs(3).add(
r_numentities).add(r_numdlights).add(r_numparticles));
logger.info("ent:{} lt:{} part:{}", r_numentities, r_numdlights, r_numparticles);
if (log_stats.value != 0.0f && (log_stats_file != null))
try {
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() {
public void execute() {
Com.Printf("(%i %i %i) : %i\n", new Vargs(4).add(
(int) cl.refdef.vieworg[0]).add((int) cl.refdef.vieworg[1])
.add((int) cl.refdef.vieworg[2]).add(
(int) cl.refdef.viewangles[YAW]));
logger.info("({} {} {}) : {}",
(int) cl.refdef.vieworg[0],
(int) cl.refdef.vieworg[1],
(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.sys.IN;
import lwjake2.util.Vargs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.Dimension;
import java.awt.DisplayMode;
@@ -41,6 +43,7 @@ import java.awt.DisplayMode;
* @author cwei
*/
public class VID extends Globals {
private static final Logger logger = LoggerFactory.getLogger(VID.class);
// Main windowed and fullscreen graphics interface module. This module
// is used for both the software and OpenGL rendering versions of the
// Quake refresh engine.
@@ -75,7 +78,11 @@ public class VID extends Globals {
*/
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) {
@@ -174,7 +181,8 @@ public class VID extends Globals {
FreeReflib();
}
Com.Printf( "------- Loading " + name + " -------\n");
logger.info("------- Loading {} -------", name);
boolean found = false;
@@ -187,11 +195,11 @@ public class VID extends Globals {
}
if (!found) {
Com.Printf( "LoadLibrary(\"" + name +"\") failed\n");
logger.warn("LoadLibrary(\"{}\") failed", name);
return false;
}
Com.Printf( "LoadLibrary(\"" + name +"\")\n" );
logger.info("LoadLibrary(\"{}\")", name);
Globals.re = Renderer.getDriver(name);
if (Globals.re == null)
@@ -217,7 +225,7 @@ public class VID extends Globals {
/* Init KBD */
Globals.re.getKeyboardHandler().Init();
Com.Printf( "------------------------------------\n");
logger.info("------------------------------------");
reflib_active = true;
return true;
}
@@ -263,10 +271,10 @@ public class VID extends Globals {
}
if ( vid_ref.string.equals(Renderer.getDefaultName())) {
renderer = vid_ref.string;
Com.Printf("Refresh failed\n");
logger.info("Refresh failed");
gl_mode = Cvar.Get( "gl_mode", "0", 0 );
if (gl_mode.value != 0.0f) {
Com.Printf("Trying mode 0\n");
logger.info("Trying mode 0");
Cvar.SetValue("gl_mode", 0);
if ( !LoadRefresh( vid_ref.string ) )
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.server.SV_GAME;
import lwjake2.util.Lib;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.Comparator;
@@ -40,34 +42,35 @@ import java.util.Vector;
* Cmd
*/
public final class Cmd {
private static final Logger logger = LoggerFactory.getLogger(Cmd.class);
static xcommand_t List_f = new xcommand_t() {
public void execute() {
cmd_function_t cmd = Cmd.cmd_functions;
int i = 0;
while (cmd != null) {
Com.Printf(cmd.name + '\n');
logger.info(cmd.name);
i++;
cmd = cmd.next;
}
Com.Printf(i + " commands\n");
logger.info("{} commands", i);
}
};
static xcommand_t Exec_f = new xcommand_t() {
public void execute() {
if (Cmd.Argc() != 2) {
Com.Printf("exec <filename> : execute a script file\n");
logger.info("exec <filename> : execute a script file");
return;
}
byte[] f = null;
f = FS.LoadFile(Cmd.Argv(1));
if (f == null) {
Com.Printf("couldn't exec " + Cmd.Argv(1) + "\n");
logger.info("couldn't exec {}", Cmd.Argv(1));
return;
}
Com.Printf("execing " + Cmd.Argv(1) + "\n");
logger.info("execing {}", Cmd.Argv(1));
Cbuf.InsertText(new String(f));
@@ -77,10 +80,11 @@ public final class Cmd {
static xcommand_t Echo_f = new xcommand_t() {
public void execute() {
StringBuilder sb = new StringBuilder(Cmd.Argc());
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() {
cmdalias_t a = null;
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) {
Com.Printf(a.name + " : " + a.value);
logger.info("{} : {}", a.name, a.value);
}
return;
}
String s = Cmd.Argv(1);
if (s.length() > Defines.MAX_ALIAS_NAME) {
Com.Printf("Alias name is too long\n");
logger.warn("Alias name is too long");
return;
}
@@ -191,8 +195,7 @@ public final class Cmd {
scan = text;
if (len >= Defines.MAX_STRING_CHARS) {
Com.Printf("Line exceeded " + Defines.MAX_STRING_CHARS
+ " chars, discarded.\n");
logger.info("Line exceeded {} chars, discarded.", Defines.MAX_STRING_CHARS);
return null;
}
@@ -222,8 +225,7 @@ public final class Cmd {
len += j;
if (len >= Defines.MAX_STRING_CHARS) {
Com.Printf("Expanded line exceeded " + Defines.MAX_STRING_CHARS
+ " chars, discarded.\n");
logger.warn("Expanded line exceeded {} chars, discarded.", Defines.MAX_STRING_CHARS);
return null;
}
@@ -235,13 +237,13 @@ public final class Cmd {
scan = expanded;
i--;
if (++count == 100) {
Com.Printf("Macro expansion loop, discarded.\n");
logger.info("Macro expansion loop, discarded.");
return null;
}
}
if (inquote) {
Com.Printf("Line has unmatched quote, discarded.\n");
logger.info("Line has unmatched quote, discarded.");
return null;
}
@@ -309,17 +311,14 @@ public final class Cmd {
//Com.DPrintf("Cmd_AddCommand: " + cmd_name + "\n");
// fail if the command is a variable name
if ((Cvar.VariableString(cmd_name)).length() > 0) {
Com.Printf("Cmd_AddCommand: " + cmd_name
+ " already defined as a var\n");
logger.warn("Cmd_AddCommand: {} already defined as a var", cmd_name);
return;
}
// fail if the command already exists
for (cmd = cmd_functions; cmd != null; cmd = cmd.next) {
if (cmd_name.equals(cmd.name)) {
Com
.Printf("Cmd_AddCommand: " + cmd_name
+ " already defined\n");
logger.warn("Cmd_AddCommand: {} already defined", cmd_name);
return;
}
}
@@ -343,7 +342,7 @@ public final class Cmd {
while (true) {
if (cmd == null) {
Com.Printf("Cmd_RemoveCommand: " + cmd_name + " not added\n");
logger.info("Cmd_RemoveCommand: {} not added", cmd_name);
return;
}
if (0 == Lib.strcmp(cmd_name, cmd.name)) {
@@ -421,7 +420,7 @@ public final class Cmd {
if (cmd_argv[0].equalsIgnoreCase(a.name)) {
if (++Globals.alias_count == ALIAS_LOOP_COUNT) {
Com.Printf("ALIAS_LOOP_COUNT\n");
logger.info("ALIAS_LOOP_COUNT");
return;
}
Cbuf.InsertText(a.value);
@@ -1166,7 +1165,7 @@ public final class Cmd {
cmd = Cmd.Argv(0);
if (Globals.cls.state <= Defines.ca_connected || cmd.charAt(0) == '-'
|| cmd.charAt(0) == '+') {
Com.Printf("Unknown command \"" + cmd + "\"\n");
logger.warn("Unknown command \"{}\"", cmd);
return;
}

View File

@@ -27,10 +27,13 @@ import lwjake2.server.SV;
import lwjake2.server.SV_WORLD;
import lwjake2.util.Lib;
import lwjake2.util.Math3D;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.StringTokenizer;
public class GameBase {
private static final Logger logger = LoggerFactory.getLogger(GameBase.class);
public static cplane_t dummyplane = new cplane_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];
if (targetname == null) {
gi.dprintf("G_PickTarget called with null targetname\n");
logger.info("G_PickTarget called with null targetname");
return null;
}
@@ -252,7 +255,7 @@ public class GameBase {
}
if (num_choices == 0) {
gi.dprintf("G_PickTarget: target " + targetname + " not found\n");
logger.info("G_PickTarget: target {} not found", targetname);
return null;
}
@@ -396,7 +399,7 @@ public class GameBase {
};
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.util.Lib;
import lwjake2.util.Math3D;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.StringTokenizer;
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,
.30f, .00f, Defines.ARMOR_JACKET);
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))
return it;
}
Com.Println("Item not found:" + pickup_name);
logger.info("Item not found:{}", pickup_name);
return null;
}

View File

@@ -23,8 +23,11 @@ import lwjake2.Globals;
import lwjake2.qcommon.Com;
import lwjake2.util.Lib;
import lwjake2.util.QuakeFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GameSave {
private static final Logger logger = LoggerFactory.getLogger(GameSave.class);
public static void CreateEdicts() {
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.
*/
public static void InitGame() {
GameBase.gi.dprintf("==== InitGame ====\n");
logger.info("==== InitGame ====");
// preload all classes to register the adapters
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.qcommon.Com;
import lwjake2.util.Lib;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GameSpawn {
private static final Logger logger = LoggerFactory.getLogger(GameSpawn.class);
static EntThinkAdapter SP_item_health = new EntThinkAdapter() {
public String getID(){ return "SP_item_health"; }
public boolean think(edict_t ent) {
@@ -352,7 +354,7 @@ public class GameSpawn {
static void ED_ParseField(String key, String value, edict_t ent) {
if (key.equals("nextmap"))
Com.Println("nextmap: " + value);
logger.info("nextmap: {}", value);
if (!GameBase.st.set(key, value))
if (!ent.setField(key, value))
GameBase.gi.dprintf("??? The key [" + key

View File

@@ -176,25 +176,26 @@ public class player_state_t {
}
/** Prints the player state. */
public void dump() {
pmove.dump();
Lib.printv("viewangles", viewangles);
Lib.printv("viewoffset", viewoffset);
Lib.printv("kick_angles", kick_angles);
Lib.printv("gunangles", gunangles);
Lib.printv("gunoffset", gunoffset);
Com.Println("gunindex: " + gunindex);
Com.Println("gunframe: " + gunframe);
Lib.printv("blend", blend);
Com.Println("fov: " + fov);
Com.Println("rdflags: " + rdflags);
for (int n= 0; n < Defines.MAX_STATS; n++)
System.out.println("stats[" + n + "]: " + stats[n]);
}
// метод не используется =(
// public void dump() {
// pmove.dump();
//
// Lib.printv("viewangles", viewangles);
// Lib.printv("viewoffset", viewoffset);
// Lib.printv("kick_angles", kick_angles);
// Lib.printv("gunangles", gunangles);
// Lib.printv("gunoffset", gunoffset);
//
// Com.Println("gunindex: " + gunindex);
// Com.Println("gunframe: " + gunframe);
//
// Lib.printv("blend", blend);
//
// Com.Println("fov: " + fov);
//
// Com.Println("rdflags: " + rdflags);
//
// 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.util.Math3D;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.RandomAccessFile;
public class pmove_state_t {
private final Logger logger = LoggerFactory.getLogger(pmove_state_t.class);
// this structure needs to be communicated bit-accurate
// from the server to the client to guarantee that
// prediction stays in sync, so no floats are used.
@@ -129,22 +132,22 @@ public class pmove_state_t {
}
public void dump() {
Com.Println("pm_type: " + pm_type);
logger.info("pm_type: {}", pm_type);
Com.Println("origin[0]: " + origin[0]);
Com.Println("origin[1]: " + origin[0]);
Com.Println("origin[2]: " + origin[0]);
logger.info("origin[0]: {}", origin[0]);
logger.info("origin[1]: {}", origin[1]);
logger.info("origin[2]: {}", origin[2]);
Com.Println("velocity[0]: " + velocity[0]);
Com.Println("velocity[1]: " + velocity[1]);
Com.Println("velocity[2]: " + velocity[2]);
logger.info("velocity[0]: {}", velocity[0]);
logger.info("velocity[1]: {}", velocity[1]);
logger.info("velocity[2]: {}", velocity[2]);
Com.Println("pmflags: " + pm_flags);
Com.Println("pmtime: " + pm_time);
Com.Println("gravity: " + gravity);
logger.info("pmflags: {}", pm_flags);
logger.info("pmtime: {}", pm_time);
logger.info("gravity: {}", gravity);
Com.Println("delta-angle[0]: " + delta_angles[0]);
Com.Println("delta-angle[1]: " + delta_angles[0]);
Com.Println("delta-angle[2]: " + delta_angles[0]);
logger.info("delta-angle[0]: {}", delta_angles[0]);
logger.info("delta-angle[1]: {}", delta_angles[1]);
logger.info("delta-angle[2]: {}", delta_angles[2]);
}
}

View File

@@ -22,12 +22,14 @@ import lwjake2.Defines;
import lwjake2.Globals;
import lwjake2.game.Cmd;
import lwjake2.util.Lib;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 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[] tmp = new byte[8192];
@@ -135,7 +137,7 @@ public final class Cbuf {
int l = text.length();
if (Globals.cmd_text.cursize + l >= Globals.cmd_text.maxsize) {
Com.Printf("Cbuf_AddText: overflow\n");
logger.warn("Cbuf_AddText: overflow");
return;
}
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)
{
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
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")); }
msg = msg.trim();
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)
{
String msg= "";

View File

@@ -23,6 +23,8 @@ import lwjake2.Globals;
import lwjake2.game.Cmd;
import lwjake2.game.cvar_t;
import lwjake2.sys.Sys;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileInputStream;
@@ -43,7 +45,7 @@ import java.util.List;
* @author cwei
*/
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) {
File f = new File(path.substring(0, index));
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.files = newfiles;
Com.Printf("Added packfile " + packfile + " (" + numpackfiles
+ " files)\n");
logger.info("Added packfile {} ({} files)", packfile, numpackfiles);
return pack;
}
@@ -684,7 +685,7 @@ public final class FS extends Globals {
if (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;
}
@@ -737,7 +738,7 @@ public final class FS extends Globals {
filelink_t entry = null;
if (Cmd.Argc() != 3) {
Com.Printf("USAGE: link <from> <to>\n");
logger.info("USAGE: link <from> <to>");
return;
}
@@ -805,8 +806,8 @@ public final class FS extends Globals {
if (tmp != null)
tmp.replaceAll("\\\\", "/");
Com.Printf("Directory of " + findname + '\n');
Com.Printf("----\n");
logger.info("Directory of {}", findname);
logger.info("----");
dirnames = ListFiles(findname, 0, 0);
@@ -814,15 +815,13 @@ public final class FS extends Globals {
int index = 0;
for (int i = 0; i < dirnames.length; i++) {
if ((index = dirnames[i].lastIndexOf('/')) > 0) {
Com.Printf(dirnames[i].substring(index + 1, dirnames[i]
.length()) + '\n');
logger.info(dirnames[i].substring(index + 1, dirnames[i].length()));
} 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;
filelink_t link;
Com.Printf("Current search path:\n");
logger.info("Current search path:");
for (s = fs_searchpaths; s != null; s = s.next) {
if (s == fs_base_searchpaths)
Com.Printf("----------\n");
logger.info("----------");
if (s.pack != null)
Com.Printf(s.pack.filename + " (" + s.pack.numfiles
+ " files)\n");
logger.info("{} ({} files)", s.pack.filename, s.pack.numfiles);
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();) {
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.Timer;
import lwjake2.util.Vargs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.FileWriter;
import java.io.IOException;
@@ -37,7 +39,7 @@ import java.io.IOException;
* namely initialization, shutdown and frame generation.
*/
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 CPUSTRING = System.getProperty("os.arch");
@@ -122,7 +124,7 @@ public final class Qcommon extends Globals {
SCR.EndLoadingPlaque();
}
Com.Printf("====== Quake2 Initialized ======\n\n");
logger.info("====== Quake2 Initialized ======");
// save config when configuration is completed
CL.WriteConfiguration();
@@ -184,9 +186,7 @@ public final class Qcommon extends Globals {
}
if (Globals.showtrace.value != 0.0f) {
Com.Printf("%4i traces %4i points\n",
new Vargs(2).add(Globals.c_traces)
.add(Globals.c_pointcontents));
logger.info(String.format("%4d traces %4d points", Globals.c_traces, Globals.c_pointcontents));
Globals.c_traces= 0;
@@ -223,8 +223,7 @@ public final class Qcommon extends Globals {
sv -= gm;
cl -= rf;
Com.Printf("all:%3i sv:%3i gm:%3i cl:%3i rf:%3i\n",
new Vargs(5).add(all).add(sv).add(gm).add(cl).add(rf));
logger.info(String.format("all:%3d sv:%3d gm:%3d cl:%3d rf:%3d", all, sv, gm, cl, rf));
}
} catch (longjmpException e) {

View File

@@ -32,6 +32,8 @@ import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* LWJGLBase
@@ -39,6 +41,7 @@ import org.lwjgl.opengl.GL11;
* @author dsanders/cwei
*/
public abstract class LWJGLBase {
private final Logger logger = LoggerFactory.getLogger(LWJGLBase.class);
// IMPORTED FUNCTIONS
protected DisplayMode oldDisplayMode;
@@ -207,10 +210,8 @@ public abstract class LWJGLBase {
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
*/
@@ -219,11 +220,11 @@ public abstract class LWJGLBase {
}
if (!VID.GetModeInfo(newDim, mode)) {
VID.Printf(Defines.PRINT_ALL, " invalid mode\n");
logger.warn("...setting mode {}: invalid mode", 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
GLimp_Shutdown();
@@ -254,7 +255,7 @@ public abstract class LWJGLBase {
return rserr_invalid_fullscreen;
}
VID.Printf(Defines.PRINT_ALL, "...setting fullscreen " + getModeString(displayMode) + '\n');
logger.info("...setting fullscreen {}", getModeString(displayMode));
}
else

View File

@@ -47,6 +47,8 @@ import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.ARBMultitexture;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Main
@@ -54,7 +56,7 @@ import org.lwjgl.opengl.GL13;
* @author cwei
*/
public abstract class Main extends Base {
private final Logger logger = LoggerFactory.getLogger(Main.class);
public static int[] d_8to24table = new int[256];
int c_visible_lightmaps;
@@ -1037,19 +1039,19 @@ public abstract class Main extends Base {
if (err == rserr_invalid_fullscreen) {
Cvar.SetValue("vid_fullscreen", 0);
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)
return true;
}
else if (err == rserr_invalid_mode) {
Cvar.SetValue("gl_mode", gl_state.prev_mode);
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
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;
}
}
@@ -1070,7 +1072,7 @@ public abstract class Main extends Base {
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();
@@ -1081,7 +1083,7 @@ public abstract class Main extends Base {
// create the window and set up the context
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 true;
@@ -1097,13 +1099,13 @@ public abstract class Main extends Base {
** get our various GL strings
*/
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);
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);
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);
VID.Printf(Defines.PRINT_ALL, "GL_EXTENSIONS: " + gl_config.extensions_string + '\n');
logger.info("GL_EXTENSIONS: {}", gl_config.extensions_string);
gl_config.parseOpenGLVersion();
@@ -1137,7 +1139,7 @@ public abstract class Main extends Base {
if (monolightmap.length() < 2 || monolightmap.charAt(1) != 'F') {
if (gl_config.renderer == GL_RENDERER_PERMEDIA2) {
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) {
Cvar.Set("gl_monolightmap", "0");
@@ -1172,16 +1174,16 @@ public abstract class Main extends Base {
}
if (gl_config.allow_cds)
VID.Printf(Defines.PRINT_ALL, "...allowing CDS\n");
logger.info("...allowing CDS");
else
VID.Printf(Defines.PRINT_ALL, "...disabling CDS\n");
logger.info("...disabling CDS");
/*
** grab extensions
*/
if (gl_config.extensions_string.indexOf("GL_EXT_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" );
if (gl_ext_compiled_vertex_array.value != 0.0f)
qglLockArraysEXT = true;
@@ -1191,16 +1193,16 @@ public abstract class Main extends Base {
//qglUnlockArraysEXT = true;
}
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;
}
if (gl_config.extensions_string.indexOf("WGL_EXT_swap_control") >= 0) {
qwglSwapIntervalEXT = true;
VID.Printf(Defines.PRINT_ALL, "...enabling WGL_EXT_swap_control\n");
logger.info("...enabling WGL_EXT_swap_control");
} else {
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) {
@@ -1208,14 +1210,14 @@ public abstract class Main extends Base {
// qglPointParameterfEXT = ( void (APIENTRY *)( GLenum, GLfloat ) ) qwglGetProcAddress( "glPointParameterfEXT" );
qglPointParameterfEXT = true;
// 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 {
VID.Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_point_parameters\n");
logger.info("...ignoring GL_EXT_point_parameters");
}
}
else {
VID.Printf(Defines.PRINT_ALL, "...GL_EXT_point_parameters not found\n");
logger.info("...GL_EXT_point_parameters not found");
}
// #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_shared_texture_palette") >= 0) {
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
}
else {
VID.Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_shared_texture_palette\n");
logger.info("...ignoring GL_EXT_shared_texture_palette");
qglColorTableEXT = false;
}
}
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) {
VID.Printf(Defines.PRINT_ALL, "...using GL_ARB_multitexture\n");
logger.info("...using GL_ARB_multitexture");
qglActiveTextureARB = true;
GL_TEXTURE0 = ARBMultitexture.GL_TEXTURE0_ARB;
GL_TEXTURE1 = ARBMultitexture.GL_TEXTURE1_ARB;
}
else {
VID.Printf(Defines.PRINT_ALL, "...GL_ARB_multitexture not found\n");
logger.info("...GL_ARB_multitexture not found");
}
if (!(qglActiveTextureARB))

View File

@@ -41,6 +41,8 @@ import lwjake2.sys.Sys;
import lwjake2.util.Lib;
import lwjake2.util.QuakeFile;
import lwjake2.util.Vargs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileNotFoundException;
@@ -49,7 +51,7 @@ import java.io.RandomAccessFile;
import java.util.Calendar;
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");
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");
Com.Printf("--- ----- ---- --------------- ------- --------------------- ------\n");
logger.info("num score ping name lastmsg address qport ");
logger.info("--- ----- ---- --------------- ------- --------------------- ------");
for (i = 0; i < SV_MAIN.maxclients.value; i++) {
cl = SV_INIT.svs.clients[i];
if (0 == cl.state)
continue;
Com.Printf("%3i ", new Vargs().add(i));
Com.Printf("%5i ", new Vargs().add(cl.edict.client.ps.stats[Defines.STAT_FRAGS]));
StringBuilder sb = new StringBuilder();
sb.append(String.format("%3d ", i))
.append(String.format("%5d ", cl.edict.client.ps.stats[Defines.STAT_FRAGS]));
if (cl.state == Defines.cs_connected)
Com.Printf("CNCT ");
sb.append("CNCT ");
else if (cl.state == Defines.cs_zombie)
Com.Printf("ZMBI ");
sb.append("ZMBI ");
else {
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();
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);
Com.Printf(s);
sb.append(s);
l = 22 - s.length();
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.util.Lib;
import lwjake2.util.Math3D;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.RandomAccessFile;
public class SV_INIT {
private static final Logger logger = LoggerFactory.getLogger(SV_INIT.class);
/**
* SV_FindIndex.
@@ -185,7 +188,7 @@ public class SV_INIT {
if (attractloop)
Cvar.Set("paused", "0");
Com.Printf("------- Server Initialization -------\n");
logger.info("------- Server Initialization -------");
Com.DPrintf("SpawnServer: " + server + "\n");
if (sv.demofile != null)
@@ -320,7 +323,7 @@ public class SV_INIT {
if (Cvar.VariableValue("coop") != 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
| Defines.CVAR_LATCH);
}

View File

@@ -36,10 +36,13 @@ import lwjake2.qcommon.netadr_t;
import lwjake2.sys.NET;
import lwjake2.sys.Timer;
import lwjake2.util.Lib;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
public class SV_MAIN {
private static final Logger logger = LoggerFactory.getLogger(SV_MAIN.class);
/** Address of group servers. */
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.qcommon.Com;
import lwjake2.qcommon.Cvar;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.nio.ByteBuffer;
import java.util.Vector;
@@ -30,7 +32,7 @@ import java.util.Vector;
* S
*/
public class S {
private static final Logger logger = LoggerFactory.getLogger(S.class);
static Sound impl;
static cvar_t s_impl;
@@ -93,11 +95,11 @@ public class S {
*/
public static void Init() {
Com.Printf("\n------- sound initialization -------\n");
logger.info("------- sound initialization -------");
cvar_t cv = Cvar.Get("s_initsound", "1", 0);
if (cv.value == 0.0f) {
Com.Printf("not initializing.\n");
logger.info("not initializing.");
useDriver("dummy");
return;
}
@@ -119,7 +121,7 @@ public class S {
useDriver("dummy");
}
Com.Printf("\n------- use sound driver \"" + impl.getName() + "\" -------\n");
logger.info("------- use sound driver \"{}\" -------", impl.getName());
StopAllSounds();
}

View File

@@ -21,11 +21,14 @@ package lwjake2.sound;
import lwjake2.Defines;
import lwjake2.qcommon.Com;
import lwjake2.qcommon.FS;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* SND_MEM
*/
public class WaveLoader {
private static final Logger logger = LoggerFactory.getLogger(WaveLoader.class);
/**
* The ResampleSfx can squeeze and stretch samples to a default sample rate.
@@ -227,7 +230,7 @@ public class WaveLoader {
return;
}
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;
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.EFX10;
import org.lwjgl.openal.OpenALException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* LWJGLSoundImpl
@@ -56,6 +58,7 @@ import org.lwjgl.openal.OpenALException;
* @author dsanders/cwei
*/
public final class LWJGLSoundImpl implements Sound {
private final Logger logger = LoggerFactory.getLogger(LWJGLSoundImpl.class);
static {
S.register(new LWJGLSoundImpl());
@@ -85,7 +88,7 @@ public final class LWJGLSoundImpl implements Sound {
checkError();
initOpenALExtensions();
} catch (OpenALException e) {
Com.Printf(e.getMessage() + '\n');
logger.error(e.getMessage());
return false;
} catch (Exception e) {
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);
AL10.alGenBuffers(buffers);
int count = Channel.init(buffers);
Com.Printf("... using " + count + " channels\n");
logger.info("... using {} channels", count);
AL10.alDistanceModel(AL10.AL_INVERSE_DISTANCE_CLAMPED);
Cmd.AddCommand("play", new xcommand_t() {
public void execute() {
@@ -121,10 +124,10 @@ public final class LWJGLSoundImpl implements Sound {
num_sfx = 0;
Com.Printf("sound sampling rate: 44100Hz\n");
logger.info("sound sampling rate: 44100Hz");
StopAllSounds();
Com.Printf("------------------------------------\n");
logger.info("------------------------------------");
return true;
}
@@ -141,7 +144,7 @@ public final class LWJGLSoundImpl implements Sound {
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.
if (ALC10.alcGetError(AL.getDevice()) != ALC10.ALC_NO_ERROR)
@@ -153,7 +156,7 @@ public final class LWJGLSoundImpl implements Sound {
/** Initializes OpenAL EFX effects. */
private void initOpenALExtensions()
{
Com.Printf("... using EFX effects:\n");
logger.info("... using EFX effects:");
underwaterFilter = new EFXFilterLowPass();
underwaterFilter.setGain(1.0f);
underwaterFilter.setGainHF(0.0f);
@@ -586,27 +589,26 @@ public final class LWJGLSoundImpl implements Sound {
if (sc != null) {
size = sc.length * sc.width * (sc.stereo + 1);
total += size;
if (sc.loopstart >= 0)
Com.Printf("L");
else
Com.Printf(" ");
Com.Printf("(%2db) %6i : %s\n", new Vargs(3).add(sc.width * 8).add(size).add(sfx.name));
logger.info(String.format("%s(%2db) %6d : %s",
(sc.loopstart >= 0 ? 'L' : ' '),
(sc.width * 8), size, sfx.name)
);
} else {
if (sfx.name.charAt(0) == '*')
Com.Printf(" placeholder : " + sfx.name + "\n");
logger.info(" placeholder : {}", sfx.name);
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() {
Com.Printf("%5d stereo\n", new Vargs(1).add(1));
Com.Printf("%5d samples\n", new Vargs(1).add(22050));
Com.Printf("%5d samplebits\n", new Vargs(1).add(16));
Com.Printf("%5d speed\n", new Vargs(1).add(44100));
//TODO параметры тут не нужны, сплошная статика
logger.info(String.format("%5d stereo", 1));
logger.info(String.format("%5d samples", 22050));
logger.info(String.format("%5d samplebits", 16));
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.sizebuf_t;
import lwjake2.util.Lib;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.DatagramSocket;
@@ -36,7 +38,7 @@ import java.nio.ByteBuffer;
import java.nio.channels.DatagramChannel;
public final class NET {
private static final Logger logger = LoggerFactory.getLogger(NET.class);
private final static int MAX_LOOPBACK = 4;
/** Local loopback adress. */
@@ -136,7 +138,7 @@ public final class NET {
a.port = Lib.atoi(address[1]);
return true;
} catch (Exception e) {
Com.Println(e.getMessage());
logger.error(e.getMessage());
return false;
}
}
@@ -227,7 +229,7 @@ public final class NET {
int packetLength = receiveBuffer.position();
if (packetLength > net_message.maxsize) {
Com.Println("Oversize packet from " + AdrToString(net_from));
logger.info("Oversize packet from {}", AdrToString(net_from));
return false;
}
@@ -265,7 +267,7 @@ public final class NET {
SocketAddress dstSocket = new InetSocketAddress(to.getInetAddress(), to.port);
ip_channels[sock].send(ByteBuffer.wrap(data, 0, length), dstSocket);
} 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
newsocket.setBroadcast(true);
} catch (Exception e) {
Com.Println("Error: " + e.toString());
logger.error(String.format("Error: %s", e.getMessage()), e);
newsocket = null;
}
return newsocket;

View File

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

View File

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