From 65447c694c1c96a23db56cf00e220351efe7474d Mon Sep 17 00:00:00 2001 From: flowtron Date: Tue, 13 Jul 2010 18:46:26 +0000 Subject: [PATCH] avoid message spam for unloaded preview images git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5362 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/menus.cpp | 2 ++ source/src/protos.h | 1 + source/src/texture.cpp | 8 +++++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source/src/menus.cpp b/source/src/menus.cpp index 1d33b437..6e1b3a9b 100644 --- a/source/src/menus.cpp +++ b/source/src/menus.cpp @@ -390,8 +390,10 @@ struct mitemmaploadmanual : mitemmanual else formatstring(maptitle)("-n/a-:%s", filename); } defformatstring(p2p)("%s/preview/%s.jpg", cgzpath, filename); + silent_texture_load = true; image = textureload(p2p, 3); if(image==notexture) image = textureload("packages/misc/nopreview.jpg", 3); + silent_texture_load = false; } else { formatstring(maptitle)("-n/a-:%s", filename); image = textureload("packages/misc/nopreview.png", 3); } copystring(mapstats, ""); diff --git a/source/src/protos.h b/source/src/protos.h index 32b9cbdd..9c17c7db 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -256,6 +256,7 @@ struct Texture GLuint id; }; extern Texture *notexture, *noworldtexture; +extern bool silent_texture_load; extern void scaletexture(uchar *src, uint sw, uint sh, uint bpp, uchar *dst, uint dw, uint dh); extern void createtexture(int tnum, int w, int h, void *pixels, int clamp, bool mipmap, bool canreduce, GLenum format); diff --git a/source/src/texture.cpp b/source/src/texture.cpp index 76efc50f..39fc5706 100644 --- a/source/src/texture.cpp +++ b/source/src/texture.cpp @@ -239,7 +239,7 @@ int fixcl(SDL_Surface *s, bool check = true, Uint8 value = 0, Uint8 mlimit = 255 else *p >>= t; break; } - case 2: + case 2: { if (check) pixel = *(Uint16 *)p; else { p[0] >>= t; p[1] >>= t; } @@ -335,13 +335,15 @@ SDL_Surface *texdecal(SDL_Surface *s) return m; } +bool silent_texture_load = false; + GLuint loadsurface(const char *texname, int &xs, int &ys, int &bpp, int clamp = 0, bool mipmap = true, bool canreduce = false) { const char *file = texname; if(texname[0]=='<') { file = strchr(texname, '>'); - if(!file) { conoutf("could not load texture %s", texname); return 0; } + if(!file) { if(!silent_texture_load) conoutf("could not load texture %s", texname); return 0; } file++; } @@ -358,7 +360,7 @@ GLuint loadsurface(const char *texname, int &xs, int &ys, int &bpp, int clamp = delete z; } if(!s) s = IMG_Load(findfile(file, "rb")); - if(!s) { conoutf("couldn't load texture %s", texname); return 0; } + if(!s) { if(!silent_texture_load) conoutf("couldn't load texture %s", texname); return 0; } s = fixsurfaceformat(s); Uint8 x = 0; if(strstr(texname,"playermodel") && (x = fixcl(s)) > 35) { fixcl(s,false,x,35); }