]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
loadfont now prints a warning if it gets more than MAX_FONT_SIZES sizes and skips...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 25 Sep 2010 08:39:33 +0000 (08:39 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 25 Sep 2010 08:39:33 +0000 (08:39 +0000)
Signed-off-by: terencehill <piuntn@gmail.com>
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10493 d7cf8633-e32d-0410-b094-e92efae38249

gl_draw.c

index 6697db4263d7c1d1e096e1deebcb334fb650ad9f..dc25bd0d09acf7f1d65961270e4ebfe48b6ed4ec 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -888,10 +888,28 @@ static void LoadFont_f(void)
                                        voffset = atof(Cmd_Argv(i));
                                continue;
                        }
+
+                       if (sizes == -1)
+                               continue; // no slot for other sizes
+
                        // parse one of sizes
                        sz = atof(Cmd_Argv(i));
                        if (sz > 0.001f && sz < 1000.0f) // do not use crap sizes
                        {
+                               // search for duplicated sizes
+                               int j;
+                               for (j=0; j<sizes; j++)
+                                       if (f->req_sizes[j] == sz)
+                                               break;
+                               if (j != sizes)
+                                       continue; // sz already in req_sizes, don't add it again
+
+                               if (sizes == MAX_FONT_SIZES)
+                               {
+                                       Con_Printf("Warning: specified more than %i different font sizes, exceding ones are ignored\n", MAX_FONT_SIZES);
+                                       sizes = -1;
+                                       continue;
+                               }
                                f->req_sizes[sizes] = sz;
                                sizes++;
                        }