Skip to content
Permalink
Browse files

Remove VLAs in font structs (#1606)

  • Loading branch information...
fundies authored and JoshDreamland committed Mar 16, 2019
1 parent 5d017af commit a4216407893b2d04c55d2ee3e7557ea809514cef
@@ -26,15 +26,18 @@
\********************************************************************************/

#include "makedir.h"

#include "backend/GameData.h"
#include "compiler/compile_common.h"
#include "languages/lang_CPP.h"

#include <cstdio>
#include <fstream>
#include "backend/GameData.h"
#include <string>
using namespace std;
#include "compiler/compile_common.h"
#include <vector>

using namespace std;

#include "languages/lang_CPP.h"
int lang_CPP::compile_writeFontInfo(const GameData &game)
{
ofstream wto((codegen_directory + "Preprocessor_Environment_Editable/IDE_EDIT_fontinfo.h").c_str(),ios_base::out);
@@ -43,7 +46,7 @@ int lang_CPP::compile_writeFontInfo(const GameData &game)

int maxid = -1, rawfontcount = 0;
wto << "namespace enigma {" << endl;
wto << " rawfont rawfontdata[] = {" << endl;
wto << " std::vector<rawfont> rawfontdata = {" << endl;
for (const auto &font : game.fonts) {
wto << " {\""
<< font.name << "\", " // string name;
@@ -67,7 +67,7 @@ namespace enigma
int fontsize; bool bold, italic;
unsigned int glyphRangeCount;
};
extern rawfont rawfontdata[];
extern std::vector<rawfont> rawfontdata;
extern font **fontstructarray;

extern int rawfontcount, rawfontmaxid;
@@ -74,9 +74,9 @@ namespace enigma
// a square space based on the max height of the font.

sprite *sspr = spritestructarray[spr];
unsigned char* glyphdata[gcount]; // Raw font image data
std::vector<unsigned char*> glyphdata(gcount); // Raw font image data
std::vector<rect_packer::pvrect> glyphmetrics(gcount);
int glyphx[gcount], glyphy[gcount];
std::vector<int> glyphx(gcount), glyphy(gcount);

int gwm = sspr->width, // Glyph width max: sprite width
ghm = sspr->height, // Glyph height max: sprite height
@@ -158,7 +158,7 @@ namespace enigma
}
}

int bigtex[w*h];
std::vector<int> bigtex(w*h);
for (unsigned i = 0; i < gcount; i++)
{
fontglyph& fg = fgr.glyphs[i];
@@ -176,7 +176,7 @@ namespace enigma
fg.ty2 = (glyphmetrics[i].y + glyphmetrics[i].h) / double(h);
}

font->texture = graphics_create_texture(w,h,w,h,bigtex,false);
font->texture = graphics_create_texture(w,h,w,h,bigtex.data(),false);
font->twid = w;
font->thgt = h;
font->yoffset = 0;

0 comments on commit a421640

Please sign in to comment.
You can’t perform that action at this time.