- Am I the only one who thinks that static_casts can create really clunky code? (Thanks, GCC, for your overly paranoid warning settings that necessitate such ugliness. :( )

SVN r2844 (trunk)
This commit is contained in:
Christoph Oelckers 2010-09-22 06:52:48 +00:00
parent 15d74dab56
commit 16fa8cc249
7 changed files with 18 additions and 15 deletions

View file

@ -361,7 +361,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage
} }
} }
// [BL] I have word that MSVC++ wants this static_cast ;) Shut up MSVC! // [BL] I have word that MSVC++ wants this static_cast ;) Shut up MSVC!
for(unsigned int i = 0;i < static_cast<unsigned int> (conditionAnd ? 3 : 1);i++) for(unsigned int i = 0;i < (conditionAnd ? 3u : 1u);i++)
{ {
sc.MustGetToken(','); sc.MustGetToken(',');
sc.MustGetToken(TK_StringConst); sc.MustGetToken(TK_StringConst);

View file

@ -218,7 +218,7 @@ bool DListMenu::MouseEvent(int type, int x, int y)
{ {
if (mDesc->mItems[i]->CheckCoordinate(x, y)) if (mDesc->mItems[i]->CheckCoordinate(x, y))
{ {
if (i != static_cast<unsigned int> (mDesc->mSelectedItem)) if ((int)i != mDesc->mSelectedItem)
{ {
//S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", snd_menuvolume, ATTN_NONE); //S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", snd_menuvolume, ATTN_NONE);
} }
@ -258,7 +258,7 @@ void DListMenu::Drawer ()
{ {
for(unsigned i=0;i<mDesc->mItems.Size(); i++) for(unsigned i=0;i<mDesc->mItems.Size(); i++)
{ {
if (mDesc->mItems[i]->mEnabled) mDesc->mItems[i]->Drawer(static_cast<unsigned int> (mDesc->mSelectedItem) == i); if (mDesc->mItems[i]->mEnabled) mDesc->mItems[i]->Drawer(mDesc->mSelectedItem == (int)i);
} }
if (mDesc->mSelectedItem >= 0 && mDesc->mSelectedItem < (int)mDesc->mItems.Size()) if (mDesc->mSelectedItem >= 0 && mDesc->mSelectedItem < (int)mDesc->mItems.Size())
mDesc->mItems[mDesc->mSelectedItem]->DrawSelector(mDesc->mSelectOfsX, mDesc->mSelectOfsY, mDesc->mSelector); mDesc->mItems[mDesc->mSelectedItem]->DrawSelector(mDesc->mSelectOfsX, mDesc->mSelectOfsY, mDesc->mSelector);

View file

@ -604,7 +604,7 @@ void DLoadSaveMenu::Drawer ()
{ {
color = CR_ORANGE; color = CR_ORANGE;
} }
else if (j == static_cast<unsigned int> (Selected)) else if ((int)j == Selected)
{ {
color = CR_WHITE; color = CR_WHITE;
} }
@ -612,7 +612,8 @@ void DLoadSaveMenu::Drawer ()
{ {
color = CR_TAN; color = CR_TAN;
} }
if (j == static_cast<unsigned int> (Selected))
if ((int)j == Selected)
{ {
screen->Clear (listboxLeft, listboxTop+rowHeight*i, screen->Clear (listboxLeft, listboxTop+rowHeight*i,
listboxRight, listboxTop+rowHeight*(i+1), -1, listboxRight, listboxTop+rowHeight*(i+1), -1,

View file

@ -392,13 +392,14 @@ void DOptionMenu::Drawer ()
for (i = 0; i < mDesc->mItems.Size() && y <= lastrow; i++, y += fontheight) for (i = 0; i < mDesc->mItems.Size() && y <= lastrow; i++, y += fontheight)
{ {
// Don't scroll the uppermost items // Don't scroll the uppermost items
if (i == static_cast<unsigned int> (mDesc->mScrollTop)) if ((int)i == mDesc->mScrollTop)
{ {
i += mDesc->mScrollPos; i += mDesc->mScrollPos;
if (i >= mDesc->mItems.Size()) break; // skipped beyond end of menu if (i >= mDesc->mItems.Size()) break; // skipped beyond end of menu
} }
int cur_indent = mDesc->mItems[i]->Draw(mDesc, y, indent, static_cast<unsigned int> (mDesc->mSelectedItem) == i); bool isSelected = mDesc->mSelectedItem == (int)i;
if (cur_indent >= 0 && static_cast<unsigned int> (mDesc->mSelectedItem) == i && mDesc->mItems[i]->Selectable()) int cur_indent = mDesc->mItems[i]->Draw(mDesc, y, indent, isSelected);
if (cur_indent >= 0 && isSelected && mDesc->mItems[i]->Selectable())
{ {
if (((DMenu::MenuTime%8) < 6) || DMenu::CurrentMenu != this) if (((DMenu::MenuTime%8) < 6) || DMenu::CurrentMenu != this)
{ {

View file

@ -796,13 +796,13 @@ void DPlayerMenu::UpdateSkins()
else else
{ {
PlayerSkins.Clear(); PlayerSkins.Clear();
for(unsigned i=0;i<(unsigned)numskins; i++) for(int i=0;i<(int)numskins; i++)
{ {
if (PlayerClass->CheckSkin(i)) if (PlayerClass->CheckSkin(i))
{ {
int j = PlayerSkins.Push(i); int j = PlayerSkins.Push(i);
li->SetString(j, skins[i].name); li->SetString(j, skins[i].name);
if (static_cast<unsigned int> (players[consoleplayer].userinfo.skin) == i) if (players[consoleplayer].userinfo.skin == i)
{ {
sel = j; sel = j;
} }

View file

@ -929,7 +929,7 @@ public:
void Drawer() void Drawer()
{ {
const char *speakerName; const char *speakerName;
int i, x, y, linesize; int x, y, linesize;
int width, fontheight; int width, fontheight;
int labelofs; int labelofs;
@ -973,6 +973,7 @@ public:
// Dim the screen behind the dialogue (but only if there is no backdrop). // Dim the screen behind the dialogue (but only if there is no backdrop).
if (!CurNode->Backdrop.isValid()) if (!CurNode->Backdrop.isValid())
{ {
int i;
for (i = 0; mDialogueLines[i].Width >= 0; ++i) for (i = 0; mDialogueLines[i].Width >= 0; ++i)
{ } { }
screen->Dim (0, 0.45f, 14 * screen->GetWidth() / 320, 13 * screen->GetHeight() / 200, screen->Dim (0, 0.45f, 14 * screen->GetWidth() / 320, 13 * screen->GetHeight() / 200,
@ -995,7 +996,7 @@ public:
y += linesize * 3 / 2; y += linesize * 3 / 2;
} }
x = 24 * screen->GetWidth() / 320; x = 24 * screen->GetWidth() / 320;
for (i = 0; mDialogueLines[i].Width >= 0; ++i) for (int i = 0; mDialogueLines[i].Width >= 0; ++i)
{ {
screen->DrawText (SmallFont, CR_UNTRANSLATED, x, y, mDialogueLines[i].Text, screen->DrawText (SmallFont, CR_UNTRANSLATED, x, y, mDialogueLines[i].Text,
DTA_CleanNoMove, true, TAG_DONE); DTA_CleanNoMove, true, TAG_DONE);
@ -1024,14 +1025,14 @@ public:
fontheight = OptionSettings.mLinespacing; fontheight = OptionSettings.mLinespacing;
int response = 0; int response = 0;
for (i = 0; i < (int)mResponseLines.Size(); i++, y += fontheight) for (unsigned i = 0; i < mResponseLines.Size(); i++, y += fontheight)
{ {
width = SmallFont->StringWidth(mResponseLines[i]); width = SmallFont->StringWidth(mResponseLines[i]);
x = 64; x = 64;
screen->DrawText (SmallFont, CR_GREEN, x, y, mResponseLines[i], DTA_Clean, true, TAG_DONE); screen->DrawText (SmallFont, CR_GREEN, x, y, mResponseLines[i], DTA_Clean, true, TAG_DONE);
if (static_cast<unsigned int> (i) == mResponses[response]) if (i == mResponses[response])
{ {
char tbuf[16]; char tbuf[16];

View file

@ -256,7 +256,7 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType)
// end of changed code // end of changed code
if (developer && buttonSuccess) if (developer && buttonSuccess)
{ {
Printf ("Line special %d activated on line %i\n", special, static_cast<int> (line - lines)); Printf ("Line special %d activated on line %i\n", special, int(line - lines));
} }
return true; return true;
} }