mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-29 19:00:33 +02:00
regexless getText
This commit is contained in:
@@ -31,25 +31,38 @@ std::string sign::getText(Simulation *sim)
|
|||||||
else
|
else
|
||||||
sprintf(buff, "Temp: 0.00"); //...temperature
|
sprintf(buff, "Temp: 0.00"); //...temperature
|
||||||
}
|
}
|
||||||
else if (sregexp(signText, "^{[ct]:[0-9]*|.*}$")==0)
|
|
||||||
{
|
|
||||||
int sldr, startm;
|
|
||||||
memset(buff, 0, sizeof(buff));
|
|
||||||
for (sldr=3; signText[sldr-1] != '|'; sldr++)
|
|
||||||
startm = sldr + 1;
|
|
||||||
sldr = startm;
|
|
||||||
while (signText[sldr] != '}')
|
|
||||||
{
|
|
||||||
buff[sldr - startm] = signText[sldr];
|
|
||||||
sldr++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(buff, "%s", signText);
|
int match=0;
|
||||||
|
const char* r;
|
||||||
|
const char* e;
|
||||||
|
if (signText[0]=='{' && (signText[1]=='c' || signText[1]=='t') && signText[2]==':' && signText[3]>='0' && signText[3]<='9')
|
||||||
|
{
|
||||||
|
const char* p=signText+4;
|
||||||
|
while (*p>='0' && *p<='9')
|
||||||
|
p++;
|
||||||
|
if (*p=='|')
|
||||||
|
{
|
||||||
|
r=p+1;
|
||||||
|
while (*p)
|
||||||
|
p++;
|
||||||
|
if (p[-1]=='}')
|
||||||
|
{
|
||||||
|
match=1;
|
||||||
|
e=p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (match)
|
||||||
|
{
|
||||||
|
strcpy(buff, r);
|
||||||
|
buff[e-r-1]=0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strcpy(buff, signText);
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::string(buff,256);
|
return std::string(buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sign::pos(std::string signText, int & x0, int & y0, int & w, int & h)
|
void sign::pos(std::string signText, int & x0, int & y0, int & w, int & h)
|
||||||
|
Reference in New Issue
Block a user