diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2019-03-30 01:25:23 +0100 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2019-03-30 01:25:23 +0100 |
commit | 5e84e122eaddd118a1f6be2e6af282eb797ac8a1 (patch) | |
tree | 4703d43315798a5db3eecc6fec40e76a18b24b43 /src | |
parent | 7faa7890ec6e899158962506ad17b75bb92ebb16 (diff) | |
parent | 4bebc71c013b4874c699f987e42098e9c0450990 (diff) | |
download | termgl-5e84e122eaddd118a1f6be2e6af282eb797ac8a1.tar.gz |
Merge branch 'master' of github.com:kompetenzbolzen/enginev1.0
Diffstat (limited to 'src')
-rw-r--r-- | src/cRender.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/cRender.cpp b/src/cRender.cpp index 2035b21..5e7677f 100644 --- a/src/cRender.cpp +++ b/src/cRender.cpp @@ -213,31 +213,34 @@ int cRender::render(void) #elif __linux__ - char buffer[40]; - char colorstr[30]; + const unsigned int buffer_len = 40; + const unsigned int colorstr_len = 30; + + char buffer[ buffer_len ]; + char colorstr[ colorstr_len ]; + uint8_t color[3] = {(uint8_t) (0x0000ff & wColor[o][i]), //Color (uint8_t)((0x00ff00 & wColor[o][i]) >> 8), //Background (uint8_t)((0xff0000 & wColor[o][i]) >> 16)};//Modifier {//// int cc = 0; - cc = cc + sprintf(&colorstr[cc], "%u", color[0]); + cc = cc + snprintf(&colorstr[cc], colorstr_len - cc - 1, "%u", color[0]); if(color[1]) { colorstr[cc] = ';'; colorstr[cc + 1] = color[1]; - cc += 1 + sprintf(&colorstr[cc + 1], "%u", color[1]); + cc += 1 + snprintf(&colorstr[cc + 1],colorstr_len - cc - 1, "%u", color[1]); } if(color[2]) { colorstr[cc] = ';'; - cc += 1 + sprintf(&colorstr[cc + 1], "%u", color[2]); + cc += 1 + snprintf(&colorstr[cc + 1], colorstr_len - cc - 1, "%u", color[2]); } }//// - int cbuf = sprintf(buffer,"\e[%u;%uH\e[%sm%c\e[0m", i + 1, o + 1, colorstr, cScreen[o][i]); + int cbuf = snprintf(buffer, buffer_len - 1,"\e[%u;%uH\e[%sm%c\e[0m", i + 1, o + 1, colorstr, cScreen[o][i]); // Position Color Origin is at 1,1 - //int cbuf = sprintf(buffer,"\e[%u;%uH%c", i + 1, o + 1, cScreen[o][i]); if(!bMute) write (STDOUT_FILENO, buffer, cbuf); @@ -447,12 +450,13 @@ void cRender::printDebugInfo() if(!bPrintDebugInfo) return; - char dbgtxt[30]; + const unsigned int dbgtxt_len = 30; + char dbgtxt[ dbgtxt_len ]; double lrt = (double)lastFrameTime / CLOCKS_PER_SEC; double fps = getFrametime() ? 1/getFrametime() : 0; - sprintf(dbgtxt, "R: %f F: %f ", lrt, fps); + snprintf(dbgtxt, dbgtxt_len - 1, "R: %f F: %f ", lrt, fps); drawText(dbgtxt, {0,0}, _COL_BLACK | _COL_WHITE_BG); } |