]> 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)
committerRudolf Polzer <divverent@alientrap.org>
Sat, 25 Sep 2010 19:49:13 +0000 (21:49 +0200)
Signed-off-by: terencehill <piuntn@gmail.com>
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10493 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=df715e90671b3ea25ce8e79ebb9f7afc86b42bd0

gl_draw.c

index 6821819cdfd58a30e7d2d93ff30974f60f930d01..212d4ef145ffcd55d41ed68694af27ea70bdc311 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++;
                        }