here a const, there a const, everywhere a const const

git-svn-id: svn://svn.icculus.org/fs2open/trunk/fs2_open@9801 387891d4-d844-0410-90c0-e4c51a9137d3
This commit is contained in:
Goober5000 authored and niffiwan committed 2013-09-20 19:46:41 +10:00
1 parent 0dfcea3b22
commit 886018d28f
29 files changed
+133 -143

No files matched your search

+11 -13
View File
@@ -12647,8 +12647,8 @@ ADE_FUNC(drawString, l_Graphics, "string Message, [number X1, number Y1, number
}
else
{
int *linelengths = new int[MAX_TEXT_LINES];
char **linestarts = new char*[MAX_TEXT_LINES];
int linelengths[MAX_TEXT_LINES];
const char *linestarts[MAX_TEXT_LINES];
num_lines = split_str(s, x2-x, linelengths, linestarts, MAX_TEXT_LINES);
@@ -12660,26 +12660,24 @@ ADE_FUNC(drawString, l_Graphics, "string Message, [number X1, number Y1, number
y2 = y;
char rep;
char *reptr;
for(int i = 0; i < num_lines; i++)
{
//Increment line height
y2 += line_ht;
//WMC - rather than make a new string each line, set the right character to null
reptr = &linestarts[i][linelengths[i]];
rep = *reptr;
*reptr = '\0';
//Contrary to WMC's previous comment, let's make a new string each line
int len = linelengths[i];
char *buf = new char[len+1];
strncpy(buf, linestarts[i], len);
buf[len] = '\0';
//Draw the string
gr_string(x,y2,linestarts[i],false);
gr_string(x,y2,buf,false);
//Set character back
*reptr = rep;
//Free the string we made
delete[] buf;
}
delete[] linelengths;
delete[] linestarts;
NextDrawStringPos[1] = y2+gr_get_font_height();
}
return ade_set_error(L, "i", num_lines);