Skip to content
Snippets Groups Projects
Commit 1886c637 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Clean-up the hex and decimal value parsing of "extra attribute codes"

Eliminate the unnecessary calls to snprintf() and atoi()/ahtoul() since these
are simple fixed-length parses. No change in behavior, just a minor
optimization.
parent 0e4a4995
Branches
No related tags found
No related merge requests found
Pipeline #8707 failed
...@@ -239,8 +239,7 @@ char sbbs_t::putmsgfrag(const char* buf, int& mode, int org_cols, JSObject* obj) ...@@ -239,8 +239,7 @@ char sbbs_t::putmsgfrag(const char* buf, int& mode, int org_cols, JSObject* obj)
else if (!(mode & P_NOXATTRS) else if (!(mode & P_NOXATTRS)
&& (cfg.sys_misc & SM_PCBOARD) && str[l] == '@' && str[l + 1] == 'X' && (cfg.sys_misc & SM_PCBOARD) && str[l] == '@' && str[l + 1] == 'X'
&& IS_HEXDIGIT(str[l + 2]) && IS_HEXDIGIT(str[l + 3])) { && IS_HEXDIGIT(str[l + 2]) && IS_HEXDIGIT(str[l + 3])) {
snprintf(tmp2, sizeof tmp2, "%.2s", str + l + 2); uint val = (HEX_CHAR_TO_INT(str[l + 2]) << 4) + HEX_CHAR_TO_INT(str[l + 3]);
uint val = ahtoul(tmp2);
// @X00 saves the current color and @XFF restores that saved color // @X00 saves the current color and @XFF restores that saved color
static uchar save_attr; static uchar save_attr;
switch (val) { switch (val) {
...@@ -260,16 +259,14 @@ char sbbs_t::putmsgfrag(const char* buf, int& mode, int org_cols, JSObject* obj) ...@@ -260,16 +259,14 @@ char sbbs_t::putmsgfrag(const char* buf, int& mode, int org_cols, JSObject* obj)
else if (!(mode & P_NOXATTRS) else if (!(mode & P_NOXATTRS)
&& (cfg.sys_misc & SM_WILDCAT) && str[l] == '@' && str[l + 3] == '@' && (cfg.sys_misc & SM_WILDCAT) && str[l] == '@' && str[l + 3] == '@'
&& IS_HEXDIGIT(str[l + 1]) && IS_HEXDIGIT(str[l + 2])) { && IS_HEXDIGIT(str[l + 1]) && IS_HEXDIGIT(str[l + 2])) {
snprintf(tmp2, sizeof tmp2, "%.2s", str + l + 1); attr((HEX_CHAR_TO_INT(str[l + 1]) << 4) + HEX_CHAR_TO_INT(str[l + 2]));
attr(ahtoul(tmp2));
// exatr=1; // exatr=1;
l += 4; l += 4;
} }
else if (!(mode & P_NOXATTRS) else if (!(mode & P_NOXATTRS)
&& (cfg.sys_misc & SM_RENEGADE) && str[l] == '|' && IS_DIGIT(str[l + 1]) && (cfg.sys_misc & SM_RENEGADE) && str[l] == '|' && IS_DIGIT(str[l + 1])
&& IS_DIGIT(str[l + 2]) && !(useron.misc & RIP)) { && IS_DIGIT(str[l + 2]) && !(useron.misc & RIP)) {
snprintf(tmp2, sizeof tmp2, "%.2s", str + l + 1); i = (DEC_CHAR_TO_INT(str[l + 1]) * 10) + DEC_CHAR_TO_INT(str[l + 2]);
i = atoi(tmp2);
if (i >= 16) { /* setting background */ if (i >= 16) { /* setting background */
i -= 16; i -= 16;
i <<= 4; i <<= 4;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment