Remove duplicated code from FOptiAttr::changeAttribute

This commit is contained in:
Markus Gans 2017-11-23 00:59:58 +01:00
parent 051fbab046
commit 3ced63510c
3 changed files with 94 additions and 118 deletions

View File

@ -1,3 +1,6 @@
2017-11-23 Markus Gans <guru.mail@muenster.de>
* Remove duplicated code from FOptiAttr::changeAttribute
2017-11-22 Markus Gans <guru.mail@muenster.de>
* Remove duplicated code in FVTerm::print

View File

@ -218,6 +218,8 @@ class FOptiAttr
bool setTermPCcharset (char_data*&);
bool unsetTermPCcharset (char_data*&);
bool setTermDefaultColor (char_data*&);
void setAttributesOn (char_data*&);
void setAttributesOff (char_data*&);
// Inquiries
static bool hasColor (char_data*&);

View File

@ -566,46 +566,7 @@ char* FOptiAttr::changeAttribute (char_data*& term, char_data*& next)
unsetTermAltCharset(term);
}
else
{
if ( off.attr.bit.pc_charset )
unsetTermPCcharset(term);
if ( off.attr.bit.alt_charset )
unsetTermAltCharset(term);
if ( off.attr.bit.bold )
unsetTermBold(term);
if ( off.attr.bit.dim )
unsetTermDim(term);
if ( off.attr.bit.italic )
unsetTermItalic(term);
if ( off.attr.bit.underline )
unsetTermUnderline(term);
if ( off.attr.bit.blink )
unsetTermBlink(term);
if ( off.attr.bit.reverse )
unsetTermReverse(term);
if ( off.attr.bit.standout )
unsetTermStandout(term);
if ( off.attr.bit.invisible )
unsetTermInvisible(term);
if ( off.attr.bit.protect )
unsetTermProtected(term);
if ( off.attr.bit.crossed_out )
unsetTermCrossedOut(term);
if ( off.attr.bit.dbl_underline )
unsetTermDoubleUnderline(term);
}
setAttributesOff(term);
}
if ( colorChange(term, next) )
@ -659,45 +620,7 @@ char* FOptiAttr::changeAttribute (char_data*& term, char_data*& next)
}
else
{
if ( off.attr.bit.pc_charset )
unsetTermPCcharset(term);
if ( off.attr.bit.alt_charset )
unsetTermAltCharset(term);
if ( off.attr.bit.bold )
unsetTermBold(term);
if ( off.attr.bit.dim )
unsetTermDim(term);
if ( off.attr.bit.italic )
unsetTermItalic(term);
if ( off.attr.bit.underline )
unsetTermUnderline(term);
if ( off.attr.bit.blink )
unsetTermBlink(term);
if ( off.attr.bit.reverse )
unsetTermReverse(term);
if ( off.attr.bit.standout )
unsetTermStandout(term);
if ( off.attr.bit.invisible )
unsetTermInvisible(term);
if ( off.attr.bit.protect )
unsetTermProtected(term);
if ( off.attr.bit.crossed_out )
unsetTermCrossedOut(term);
if ( off.attr.bit.dbl_underline )
unsetTermDoubleUnderline(term);
setAttributesOff(term);
detectSwitchOff (term, next);
if ( switchOff() )
@ -707,45 +630,7 @@ char* FOptiAttr::changeAttribute (char_data*& term, char_data*& next)
change_color (term, next);
detectSwitchOn (term, next);
if ( on.attr.bit.alt_charset )
setTermAltCharset(term);
if ( on.attr.bit.pc_charset )
setTermPCcharset(term);
if ( on.attr.bit.bold )
setTermBold(term);
if ( on.attr.bit.dim )
setTermDim(term);
if ( on.attr.bit.italic )
setTermItalic(term);
if ( on.attr.bit.underline )
setTermUnderline(term);
if ( on.attr.bit.blink )
setTermBlink(term);
if ( on.attr.bit.reverse )
setTermReverse(term);
if ( on.attr.bit.standout )
setTermStandout(term);
if ( on.attr.bit.invisible )
setTermInvisible(term);
if ( on.attr.bit.protect )
setTermProtected(term);
if ( on.attr.bit.crossed_out )
setTermCrossedOut(term);
if ( on.attr.bit.dbl_underline )
setTermDoubleUnderline(term);
setAttributesOn(term);
}
if ( term && fake_reverse )
@ -1171,6 +1056,92 @@ bool FOptiAttr::setTermDefaultColor (char_data*& term)
return false;
}
//----------------------------------------------------------------------
void FOptiAttr::setAttributesOn (char_data*& term)
{
if ( on.attr.bit.alt_charset )
setTermAltCharset(term);
if ( on.attr.bit.pc_charset )
setTermPCcharset(term);
if ( on.attr.bit.bold )
setTermBold(term);
if ( on.attr.bit.dim )
setTermDim(term);
if ( on.attr.bit.italic )
setTermItalic(term);
if ( on.attr.bit.underline )
setTermUnderline(term);
if ( on.attr.bit.blink )
setTermBlink(term);
if ( on.attr.bit.reverse )
setTermReverse(term);
if ( on.attr.bit.standout )
setTermStandout(term);
if ( on.attr.bit.invisible )
setTermInvisible(term);
if ( on.attr.bit.protect )
setTermProtected(term);
if ( on.attr.bit.crossed_out )
setTermCrossedOut(term);
if ( on.attr.bit.dbl_underline )
setTermDoubleUnderline(term);
}
//----------------------------------------------------------------------
void FOptiAttr::setAttributesOff (char_data*& term)
{
if ( off.attr.bit.pc_charset )
unsetTermPCcharset(term);
if ( off.attr.bit.alt_charset )
unsetTermAltCharset(term);
if ( off.attr.bit.bold )
unsetTermBold(term);
if ( off.attr.bit.dim )
unsetTermDim(term);
if ( off.attr.bit.italic )
unsetTermItalic(term);
if ( off.attr.bit.underline )
unsetTermUnderline(term);
if ( off.attr.bit.blink )
unsetTermBlink(term);
if ( off.attr.bit.reverse )
unsetTermReverse(term);
if ( off.attr.bit.standout )
unsetTermStandout(term);
if ( off.attr.bit.invisible )
unsetTermInvisible(term);
if ( off.attr.bit.protect )
unsetTermProtected(term);
if ( off.attr.bit.crossed_out )
unsetTermCrossedOut(term);
if ( off.attr.bit.dbl_underline )
unsetTermDoubleUnderline(term);
}
//----------------------------------------------------------------------
bool FOptiAttr::hasColor (char_data*& attr)
{