0

продолжаем мигрировать из *.Printf в log.*

This commit is contained in:
2018-03-09 00:02:16 +03:00
parent ab553cb877
commit 30646b7557
4 changed files with 77 additions and 71 deletions

View File

@@ -73,7 +73,7 @@ public class CL_parse {
String name; String name;
if (filename.indexOf("..") != -1) { if (filename.indexOf("..") != -1) {
Com.Printf("Refusing to download a path with ..\n"); log.info("Refusing to download a path with ..");
return true; return true;
} }
@@ -113,12 +113,12 @@ public class CL_parse {
Globals.cls.download = fp; Globals.cls.download = fp;
// give the server an offset to start the download // give the server an offset to start the download
Com.Printf("Resuming " + Globals.cls.downloadname + "\n"); log.info("Resuming {}", Globals.cls.downloadname);
MSG.WriteByte(Globals.cls.netchan.message, Defines.clc_stringcmd); MSG.WriteByte(Globals.cls.netchan.message, Defines.clc_stringcmd);
MSG.WriteString(Globals.cls.netchan.message, "download " MSG.WriteString(Globals.cls.netchan.message, "download "
+ Globals.cls.downloadname + " " + len); + Globals.cls.downloadname + " " + len);
} else { } else {
Com.Printf("Downloading " + Globals.cls.downloadname + "\n"); log.info("Downloading {}", Globals.cls.downloadname);
MSG.WriteByte(Globals.cls.netchan.message, Defines.clc_stringcmd); MSG.WriteByte(Globals.cls.netchan.message, Defines.clc_stringcmd);
MSG.WriteString(Globals.cls.netchan.message, "download " MSG.WriteString(Globals.cls.netchan.message, "download "
+ Globals.cls.downloadname); + Globals.cls.downloadname);
@@ -138,25 +138,25 @@ public class CL_parse {
String filename; String filename;
if (Cmd.Argc() != 2) { if (Cmd.Argc() != 2) {
Com.Printf("Usage: download <filename>\n"); log.info("Usage: download <filename>");
return; return;
} }
filename = Cmd.Argv(1); filename = Cmd.Argv(1);
if (filename.indexOf("..") != -1) { if (filename.indexOf("..") != -1) {
Com.Printf("Refusing to download a path with ..\n"); log.info("Refusing to download a path with ..");
return; return;
} }
if (fileSystem.loadFile(filename) != null) { // it exists, no need to if (fileSystem.loadFile(filename) != null) { // it exists, no need to
// download // download
Com.Printf("File already exists.\n"); log.info("File already exists.");
return; return;
} }
Globals.cls.downloadname = filename; Globals.cls.downloadname = filename;
Com.Printf("Downloading " + Globals.cls.downloadname + "\n"); log.info("Downloading {}", Globals.cls.downloadname);
// download to a temp name, and only rename // download to a temp name, and only rename
// to the real name when done, so if interrupted // to the real name when done, so if interrupted
@@ -205,7 +205,7 @@ public class CL_parse {
int size = MSG.ReadShort(Globals.net_message); int size = MSG.ReadShort(Globals.net_message);
int percent = MSG.ReadByte(Globals.net_message); int percent = MSG.ReadByte(Globals.net_message);
if (size == -1) { if (size == -1) {
Com.Printf("Server does not have this file.\n"); log.info("Server does not have this file.");
if (Globals.cls.download != null) { if (Globals.cls.download != null) {
// if here, we tried to resume a file but the server said no // if here, we tried to resume a file but the server said no
try { try {
@@ -227,8 +227,7 @@ public class CL_parse {
Globals.cls.download = Lib.fopen(name, "rw"); Globals.cls.download = Lib.fopen(name, "rw");
if (Globals.cls.download == null) { if (Globals.cls.download == null) {
Globals.net_message.readcount += size; Globals.net_message.readcount += size;
Com.Printf("Failed to open " + Globals.cls.downloadtempname log.info("Failed to open {}", Globals.cls.downloadtempname);
+ "\n");
CL.RequestNextDownload(); CL.RequestNextDownload();
return; return;
} }
@@ -266,7 +265,7 @@ public class CL_parse {
newn = DownloadFileName(Globals.cls.downloadname); newn = DownloadFileName(Globals.cls.downloadname);
int r = Lib.rename(oldn, newn); int r = Lib.rename(oldn, newn);
if (r != 0) if (r != 0)
Com.Printf("failed to rename.\n"); log.info("failed to rename.");
Globals.cls.download = null; Globals.cls.download = null;
Globals.cls.downloadpercent = 0; Globals.cls.downloadpercent = 0;
@@ -343,7 +342,7 @@ public class CL_parse {
// Com.Printf( // Com.Printf(
// "\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n"); // "\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n");
// Com.Printf('\02' + str + "\n"); // Com.Printf('\02' + str + "\n");
Com.Printf("Levelname:" + str + "\n"); log.info("Levelname:{}", str);
// need to prep refresh at next oportunity // need to prep refresh at next oportunity
Globals.cl.refresh_prepped = false; Globals.cl.refresh_prepped = false;
} }
@@ -636,7 +635,7 @@ public class CL_parse {
public static void SHOWNET(String s) { public static void SHOWNET(String s) {
if (Globals.cl_shownet.value >= 2) if (Globals.cl_shownet.value >= 2)
Com.Printf(Globals.net_message.readcount - 1 + ":" + s + "\n"); log.info("{}:{}", Globals.net_message.readcount - 1, s);
} }
/* /*
@@ -674,8 +673,7 @@ public class CL_parse {
if (Globals.cl_shownet.value >= 2) { if (Globals.cl_shownet.value >= 2) {
if (null == svc_strings[cmd]) if (null == svc_strings[cmd])
Com.Printf(Globals.net_message.readcount - 1 + ":BAD CMD " log.info("{}:BAD CMD {}", Globals.net_message.readcount - 1, cmd);
+ cmd + "\n");
else else
SHOWNET(svc_strings[cmd]); SHOWNET(svc_strings[cmd]);
} }
@@ -696,7 +694,7 @@ public class CL_parse {
break; break;
case Defines.svc_reconnect: case Defines.svc_reconnect:
Com.Printf("Server disconnected, reconnecting\n"); log.info("Server disconnected, reconnecting");
if (Globals.cls.download != null) { if (Globals.cls.download != null) {
//ZOID, close download //ZOID, close download
try { try {

View File

@@ -18,6 +18,7 @@
package lwjake2.client; package lwjake2.client;
import lombok.extern.slf4j.Slf4j;
import lwjake2.Defines; import lwjake2.Defines;
import lwjake2.Globals; import lwjake2.Globals;
import lwjake2.qcommon.CM; import lwjake2.qcommon.CM;
@@ -26,6 +27,7 @@ import lwjake2.sys.Sys;
import java.util.StringTokenizer; import java.util.StringTokenizer;
@Slf4j
public class CL_view { public class CL_view {
static int num_cl_weaponmodels; static int num_cl_weaponmodels;
@@ -59,16 +61,14 @@ public class CL_view {
// cut off ".bsp" // cut off ".bsp"
// register models, pics, and skins // register models, pics, and skins
Com.Printf("Map: " + mapname + "\r"); log.info("Map: {}", mapname);
SCR.UpdateScreen(); SCR.UpdateScreen();
Globals.re.BeginRegistration(mapname); Globals.re.BeginRegistration(mapname);
Com.Printf(" \r");
// precache status bar pics // precache status bar pics
Com.Printf("pics\r"); log.info("pics");
SCR.UpdateScreen(); SCR.UpdateScreen();
SCR.TouchPics(); SCR.TouchPics();
Com.Printf(" \r");
CL_tent.RegisterTEntModels(); CL_tent.RegisterTEntModels();
@@ -77,12 +77,10 @@ public class CL_view {
for (i = 1; i < Defines.MAX_MODELS for (i = 1; i < Defines.MAX_MODELS
&& Globals.cl.configstrings[Defines.CS_MODELS + i].length() != 0; i++) { && Globals.cl.configstrings[Defines.CS_MODELS + i].length() != 0; i++) {
name = new String(Globals.cl.configstrings[Defines.CS_MODELS + i]); name = Globals.cl.configstrings[Defines.CS_MODELS + i];
if (name.length() > 37)
name = name.substring(0, 36);
if (name.charAt(0) != '*') if (name.charAt(0) != '*')
Com.Printf(name + "\r"); log.info(name);
SCR.UpdateScreen(); SCR.UpdateScreen();
Sys.SendKeyEvents(); // pump message loop Sys.SendKeyEvents(); // pump message loop
@@ -104,11 +102,9 @@ public class CL_view {
else else
Globals.cl.model_clip[i] = null; Globals.cl.model_clip[i] = null;
} }
if (name.charAt(0) != '*')
Com.Printf(" \r");
} }
Com.Printf("images\r"); log.info("images");
SCR.UpdateScreen(); SCR.UpdateScreen();
for (i = 1; i < Defines.MAX_IMAGES for (i = 1; i < Defines.MAX_IMAGES
&& Globals.cl.configstrings[Defines.CS_IMAGES + i].length() > 0; i++) { && Globals.cl.configstrings[Defines.CS_IMAGES + i].length() > 0; i++) {
@@ -117,22 +113,20 @@ public class CL_view {
Sys.SendKeyEvents(); // pump message loop Sys.SendKeyEvents(); // pump message loop
} }
Com.Printf(" \r");
for (i = 0; i < Defines.MAX_CLIENTS; i++) { for (i = 0; i < Defines.MAX_CLIENTS; i++) {
if (Globals.cl.configstrings[Defines.CS_PLAYERSKINS + i].length() == 0) if (Globals.cl.configstrings[Defines.CS_PLAYERSKINS + i].length() == 0)
continue; continue;
Com.Printf("client " + i + '\r'); log.info("client {}", i);
SCR.UpdateScreen(); SCR.UpdateScreen();
Sys.SendKeyEvents(); // pump message loop Sys.SendKeyEvents(); // pump message loop
CL_parse.ParseClientinfo(i); CL_parse.ParseClientinfo(i);
Com.Printf(" \r");
} }
CL_parse.LoadClientinfo(Globals.cl.baseclientinfo, CL_parse.LoadClientinfo(Globals.cl.baseclientinfo,
"unnamed\\male/grunt"); "unnamed\\male/grunt");
// set sky textures and speed // set sky textures and speed
Com.Printf("sky\r"); log.info("sky");
SCR.UpdateScreen(); SCR.UpdateScreen();
rotate = Float rotate = Float
.parseFloat(Globals.cl.configstrings[Defines.CS_SKYROTATE]); .parseFloat(Globals.cl.configstrings[Defines.CS_SKYROTATE]);
@@ -143,7 +137,6 @@ public class CL_view {
axis[2] = Float.parseFloat(st.nextToken()); axis[2] = Float.parseFloat(st.nextToken());
Globals.re.SetSky(Globals.cl.configstrings[Defines.CS_SKY], rotate, Globals.re.SetSky(Globals.cl.configstrings[Defines.CS_SKY], rotate,
axis); axis);
Com.Printf(" \r");
// the renderer can now free unneeded stuff // the renderer can now free unneeded stuff
Globals.re.EndRegistration(); Globals.re.EndRegistration();

View File

@@ -18,6 +18,7 @@
package lwjake2.qcommon; package lwjake2.qcommon;
import lombok.extern.slf4j.Slf4j;
import lwjake2.Defines; import lwjake2.Defines;
import lwjake2.Globals; import lwjake2.Globals;
import lwjake2.game.Cmd; import lwjake2.game.Cmd;
@@ -32,6 +33,7 @@ import java.util.Vector;
/** /**
* Cvar implements console variables. The original code is located in cvar.c * Cvar implements console variables. The original code is located in cvar.c
*/ */
@Slf4j
public class Cvar extends Globals { public class Cvar extends Globals {
private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance();
@@ -46,7 +48,7 @@ public class Cvar extends Globals {
if ((flags & (CVAR_USERINFO | CVAR_SERVERINFO)) != 0) { if ((flags & (CVAR_USERINFO | CVAR_SERVERINFO)) != 0) {
if (!InfoValidate(var_name)) { if (!InfoValidate(var_name)) {
Com.Printf("invalid info cvar name\n"); log.info("invalid info cvar name");
return null; return null;
} }
} }
@@ -62,7 +64,7 @@ public class Cvar extends Globals {
if ((flags & (CVAR_USERINFO | CVAR_SERVERINFO)) != 0) { if ((flags & (CVAR_USERINFO | CVAR_SERVERINFO)) != 0) {
if (!InfoValidate(var_value)) { if (!InfoValidate(var_value)) {
Com.Printf("invalid info cvar value\n"); log.info("invalid info cvar value");
return null; return null;
} }
} }
@@ -163,14 +165,14 @@ public class Cvar extends Globals {
if ((var.flags & (CVAR_USERINFO | CVAR_SERVERINFO)) != 0) { if ((var.flags & (CVAR_USERINFO | CVAR_SERVERINFO)) != 0) {
if (!InfoValidate(value)) { if (!InfoValidate(value)) {
Com.Printf("invalid info cvar value\n"); log.info("invalid info cvar value");
return var; return var;
} }
} }
if (!force) { if (!force) {
if ((var.flags & CVAR_NOSET) != 0) { if ((var.flags & CVAR_NOSET) != 0) {
Com.Printf(var_name + " is write protected.\n"); log.info("{} is write protected.", var_name);
return var; return var;
} }
@@ -185,7 +187,7 @@ public class Cvar extends Globals {
} }
if (Globals.server_state != 0) { if (Globals.server_state != 0) {
Com.Printf(var_name + " will be changed for next game.\n"); log.info("{} will be changed for next game.", var_name);
var.latched_string = value; var.latched_string = value;
} else { } else {
var.string = value; var.string = value;
@@ -235,7 +237,7 @@ public class Cvar extends Globals {
c = Cmd.Argc(); c = Cmd.Argc();
if (c != 3 && c != 4) { if (c != 3 && c != 4) {
Com.Printf("usage: set <variable> <value> [u / s]\n"); log.info("usage: set <variable> <value> [u / s]");
return; return;
} }
@@ -245,7 +247,7 @@ public class Cvar extends Globals {
else if (Cmd.Argv(3).equals("s")) else if (Cmd.Argv(3).equals("s"))
flags = CVAR_SERVERINFO; flags = CVAR_SERVERINFO;
else { else {
Com.Printf("flags can only be 'u' or 's'\n"); log.info("flags can only be 'u' or 's'");
return; return;
} }
Cvar.FullSet(Cmd.Argv(1), Cmd.Argv(2), flags); Cvar.FullSet(Cmd.Argv(1), Cmd.Argv(2), flags);
@@ -263,27 +265,34 @@ public class Cvar extends Globals {
i = 0; i = 0;
for (var = Globals.cvar_vars; var != null; var = var.next, i++) { for (var = Globals.cvar_vars; var != null; var = var.next, i++) {
StringBuilder sb = new StringBuilder();
if ((var.flags & CVAR_ARCHIVE) != 0) if ((var.flags & CVAR_ARCHIVE) != 0)
Com.Printf("*"); sb.append('*');
else else
Com.Printf(" "); sb.append(' ');
if ((var.flags & CVAR_USERINFO) != 0) if ((var.flags & CVAR_USERINFO) != 0)
Com.Printf("U"); sb.append('U');
else else
Com.Printf(" "); sb.append(' ');
if ((var.flags & CVAR_SERVERINFO) != 0) if ((var.flags & CVAR_SERVERINFO) != 0)
Com.Printf("S"); sb.append('S');
else else
Com.Printf(" "); sb.append(' ');
if ((var.flags & CVAR_NOSET) != 0) if ((var.flags & CVAR_NOSET) != 0)
Com.Printf("-"); sb.append('-');
else if ((var.flags & CVAR_LATCH) != 0) else if ((var.flags & CVAR_LATCH) != 0)
Com.Printf("L"); sb.append('L');
else else
Com.Printf(" "); sb.append(' ');
Com.Printf(" " + var.name + " \"" + var.string + "\"\n");
sb.append(" {} \"{}\"");
log.info(sb.toString(), var.name, var.string);
} }
Com.Printf(i + " cvars\n"); log.info("{} cvars", i);
}; };
@@ -334,7 +343,7 @@ public class Cvar extends Globals {
// perform a variable print or set // perform a variable print or set
if (Cmd.Argc() == 1) { if (Cmd.Argc() == 1) {
Com.Printf("\"" + v.name + "\" is \"" + v.string + "\"\n"); log.info("\"{}\" is \"{}\"", v.name, v.string);
return true; return true;
} }

View File

@@ -18,6 +18,7 @@
package lwjake2.render.lwjgl; package lwjake2.render.lwjgl;
import lombok.extern.slf4j.Slf4j;
import lwjake2.Defines; import lwjake2.Defines;
import lwjake2.client.VID; import lwjake2.client.VID;
import lwjake2.client.particle_t; import lwjake2.client.particle_t;
@@ -47,6 +48,7 @@ import org.lwjgl.opengl.GL11;
* *
* @author cwei * @author cwei
*/ */
@Slf4j
public abstract class Image extends Main { public abstract class Image extends Main {
private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance();
@@ -247,7 +249,7 @@ public abstract class Image extends Main {
} }
if (i == NUM_GL_MODES) { if (i == NUM_GL_MODES) {
VID.Printf(Defines.PRINT_ALL, "bad filter name: [" + string + "]\n"); log.warn("bad filter name: [{}]", string);
return; return;
} }
@@ -281,7 +283,7 @@ public abstract class Image extends Main {
} }
if (i == NUM_GL_ALPHA_MODES) { if (i == NUM_GL_ALPHA_MODES) {
VID.Printf(Defines.PRINT_ALL, "bad alpha texture mode name: [" + string + "]\n"); log.warn("bad alpha texture mode name: [{}]", string);
return; return;
} }
@@ -301,7 +303,7 @@ public abstract class Image extends Main {
} }
if (i == NUM_GL_SOLID_MODES) { if (i == NUM_GL_SOLID_MODES) {
VID.Printf(Defines.PRINT_ALL, "bad solid texture mode name: [" + string + "]\n"); log.warn("bad solid texture mode name: [{}]", string);
return; return;
} }
@@ -319,7 +321,7 @@ public abstract class Image extends Main {
int texels; int texels;
final String[] palstrings = { "RGB", "PAL" }; final String[] palstrings = { "RGB", "PAL" };
VID.Printf(Defines.PRINT_ALL, "------------------\n"); log.info("------------------");
texels = 0; texels = 0;
for (int i = 0; i < numgltextures; i++) { for (int i = 0; i < numgltextures; i++) {
@@ -327,32 +329,35 @@ public abstract class Image extends Main {
if (image.texnum <= 0) if (image.texnum <= 0)
continue; continue;
StringBuilder sb = new StringBuilder();
texels += image.upload_width * image.upload_height; texels += image.upload_width * image.upload_height;
switch (image.type) { switch (image.type) {
case it_skin : case it_skin :
VID.Printf(Defines.PRINT_ALL, "M"); sb.append("M");
break; break;
case it_sprite : case it_sprite :
VID.Printf(Defines.PRINT_ALL, "S"); sb.append("S");
break; break;
case it_wall : case it_wall :
VID.Printf(Defines.PRINT_ALL, "W"); sb.append("W");
break; break;
case it_pic : case it_pic :
VID.Printf(Defines.PRINT_ALL, "P"); sb.append("P");
break; break;
default : default :
VID.Printf(Defines.PRINT_ALL, " "); sb.append(" ");
break; break;
} }
VID.Printf( sb.append(" {} {} {}: {}");
Defines.PRINT_ALL, log.info(sb.toString(),
" %3i %3i %s: %s\n", image.upload_width,
new Vargs(4).add(image.upload_width).add(image.upload_height).add(palstrings[(image.paletted) ? 1 : 0]).add( image.upload_height,
image.name)); (image.paletted ? 1 : 0),
image.name
);
} }
VID.Printf(Defines.PRINT_ALL, "Total texel count (not counting mipmaps): " + texels + '\n'); log.info("Total texel count (not counting mipmaps): {}", texels);
} }
/* /*
@@ -451,7 +456,7 @@ public abstract class Image extends Main {
byte[] raw = fileSystem.loadFile(filename); byte[] raw = fileSystem.loadFile(filename);
if (raw == null) { if (raw == null) {
VID.Printf(Defines.PRINT_DEVELOPER, "Bad pcx file " + filename + '\n'); log.debug(/*Defines.PRINT_DEVELOPER*/"Bad pcx file {}", filename);
return null; return null;
} }
@@ -467,7 +472,7 @@ public abstract class Image extends Main {
|| pcx.xmax >= 640 || pcx.xmax >= 640
|| pcx.ymax >= 480) { || pcx.ymax >= 480) {
VID.Printf(Defines.PRINT_ALL, "Bad pcx file " + filename + '\n'); log.warn("Bad pcx file {}", filename);
return null; return null;
} }
@@ -549,7 +554,7 @@ public abstract class Image extends Main {
if (raw == null) if (raw == null)
{ {
VID.Printf(Defines.PRINT_DEVELOPER, "Bad tga file "+ name +'\n'); log.debug(/*Defines.PRINT_DEVELOPER*/"Bad tga file {}", name);
return null; return null;
} }
@@ -558,6 +563,7 @@ public abstract class Image extends Main {
if (targa_header.image_type != 2 && targa_header.image_type != 10) if (targa_header.image_type != 2 && targa_header.image_type != 10)
Com.Error(Defines.ERR_DROP, "LoadTGA: Only type 2 and 10 targa RGB images supported\n"); Com.Error(Defines.ERR_DROP, "LoadTGA: Only type 2 and 10 targa RGB images supported\n");
if (targa_header.colormap_type != 0 || (targa_header.pixel_size != 32 && targa_header.pixel_size != 24)) if (targa_header.colormap_type != 0 || (targa_header.pixel_size != 32 && targa_header.pixel_size != 24))
Com.Error (Defines.ERR_DROP, "LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n"); Com.Error (Defines.ERR_DROP, "LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n");
@@ -1113,7 +1119,7 @@ public abstract class Image extends Main {
else if (samples == gl_alpha_format) else if (samples == gl_alpha_format)
comp = gl_tex_alpha_format; comp = gl_tex_alpha_format;
else { else {
VID.Printf(Defines.PRINT_ALL, "Unknown number of texture components " + samples + '\n'); log.info("Unknown number of texture components {}", samples);
comp = samples; comp = samples;
} }
@@ -1432,7 +1438,7 @@ public abstract class Image extends Main {
byte[] raw = fileSystem.loadFile(name); byte[] raw = fileSystem.loadFile(name);
if (raw == null) { if (raw == null) {
VID.Printf(Defines.PRINT_ALL, "GL_FindImage: can't load " + name + '\n'); log.info("GL_FindImage: can't load {}", name);
return r_notexture; return r_notexture;
} }