From bec0d3438f77db99ebd39334ffd341ca3d5ff478 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 8 Jan 2008 01:48:33 +0000 Subject: [PATCH] GCC fixes. SVN r677 (trunk) --- src/am_map.cpp | 2 +- src/f_wipe.cpp | 4 ++-- src/m_menu.cpp | 4 ++-- src/r_data.cpp | 6 +++--- src/r_translate.cpp | 4 ++-- src/r_translate.h | 8 ++++---- src/tarray.h | 14 +++++++++++--- src/wi_stuff.cpp | 8 ++++---- src/win32/fb_d3d9_wipe.cpp | 2 +- 9 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index 06af6ddc3f..a9d2cf534c 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -1821,4 +1821,4 @@ void AM_SerializeMarkers(FArchive &arc) { arc << markpoints[i].x << markpoints[i].y; } -} \ No newline at end of file +} diff --git a/src/f_wipe.cpp b/src/f_wipe.cpp index e203f4a6fb..7d3fb84cd1 100644 --- a/src/f_wipe.cpp +++ b/src/f_wipe.cpp @@ -104,7 +104,7 @@ bool wipe_doMelt (int ticks) int i, j, dy, x; const short *s; short *d; - bool done; + bool done = true; while (ticks--) { @@ -437,4 +437,4 @@ void wipe_Cleanup() { (*wipes[(CurrentWipeType-1)*3+2])(0); } -} \ No newline at end of file +} diff --git a/src/m_menu.cpp b/src/m_menu.cpp index c5d30d18bd..6a9927e0fe 100644 --- a/src/m_menu.cpp +++ b/src/m_menu.cpp @@ -2166,7 +2166,7 @@ static void M_PlayerSetupDrawer () (PSetupDef.y + LINEHEIGHT*3 + 57 - 104)*CleanYfac + (SCREENHEIGHT/2), DTA_DestWidth, MulScale16 (tex->GetWidth() * CleanXfac, Scale), DTA_DestHeight, MulScale16 (tex->GetHeight() * CleanYfac, Scale), - DTA_Translation, translationtables[TRANSLATION_Players][MAXPLAYERS], + DTA_Translation, translationtables[TRANSLATION_Players](MAXPLAYERS), TAG_DONE); } } @@ -2596,7 +2596,7 @@ static void M_ChangePlayerTeam (int choice) } else { - if (team == teams.Size () - 1) + if (team == int(teams.Size () - 1)) { team = TEAM_None; } diff --git a/src/r_data.cpp b/src/r_data.cpp index b6c15754e3..8eed975673 100644 --- a/src/r_data.cpp +++ b/src/r_data.cpp @@ -173,7 +173,7 @@ int FTextureManager::ListTextures (const char *name, TArray &list) // NULL textures must be ignored. if (tex->UseType!=FTexture::TEX_Null) { - int j; + unsigned int j; for(j = 0; j < list.Size(); j++) { // Check for overriding definitions from newer WADs @@ -383,7 +383,7 @@ void FTextureManager::AddHiresTextures () } else { - for(int i = 0; i < tlist.Size(); i++) + for(unsigned int i = 0; i < tlist.Size(); i++) { FTexture * newtex = FTexture::CreateTexture (firsttx, FTexture::TEX_Any); if (newtex != NULL) @@ -460,7 +460,7 @@ void FTextureManager::LoadHiresTex() } else { - for(int i = 0; i < tlist.Size(); i++) + for(unsigned int i = 0; i < tlist.Size(); i++) { FTexture * oldtex = Textures[tlist[i]].Texture; int sl; diff --git a/src/r_translate.cpp b/src/r_translate.cpp index 6d16869034..ddd6906b31 100644 --- a/src/r_translate.cpp +++ b/src/r_translate.cpp @@ -44,7 +44,7 @@ #include "gi.h" #include "stats.h" -TAutoGrowArray translationtables[NUM_TRANSLATION_TABLES]; +TAutoGrowArray translationtables[NUM_TRANSLATION_TABLES]; /****************************************************/ /****************************************************/ @@ -281,7 +281,7 @@ FRemapTable *TranslationToTable(int translation) { unsigned int type = GetTranslationType(translation); unsigned int index = GetTranslationIndex(translation); - TAutoGrowArray *slots; + TAutoGrowArray *slots; if (type <= 0 || type >= NUM_TRANSLATION_TABLES) { diff --git a/src/r_translate.h b/src/r_translate.h index 24b231b5ed..fe9e7b49be 100644 --- a/src/r_translate.h +++ b/src/r_translate.h @@ -56,7 +56,7 @@ class FRemapTablePtr public: FRemapTablePtr() throw() : Ptr(0) {} FRemapTablePtr(FRemapTable *p) throw() : Ptr(p) {} - FRemapTablePtr(FRemapTablePtr &p) throw() : Ptr(p.Ptr) {} + FRemapTablePtr(const FRemapTablePtr &p) throw() : Ptr(p.Ptr) {} operator FRemapTable *() const throw() { return Ptr; } FRemapTablePtr &operator= (FRemapTable *p) throw() { Ptr = p; return *this; } FRemapTablePtr &operator= (FRemapTablePtr &p) throw() { Ptr = p.Ptr; return *this; } @@ -66,7 +66,7 @@ private: FRemapTable *Ptr; }; -extern TAutoGrowArray translationtables[NUM_TRANSLATION_TABLES]; +extern TAutoGrowArray translationtables[NUM_TRANSLATION_TABLES]; #define TRANSLATION_SHIFT 16 #define TRANSLATION_MASK ((1< +// T is the type stored in the array. +// TT is the type returned by operator(). +template class TArray { public: @@ -107,10 +109,16 @@ public: Most = 0; } } + // Return a reference to an element T &operator[] (unsigned int index) const { return Array[index]; } + // Returns the value of an element + TT operator() (unsigned int index) const + { + return Array[index]; + } unsigned int Push (const T &item) { Grow (1); @@ -283,8 +291,8 @@ private: // It can still be used as a normal TArray if needed. ACS uses this for // world and global arrays. -template -class TAutoGrowArray : public TArray +template +class TAutoGrowArray : public TArray { public: T GetVal (unsigned int index) diff --git a/src/wi_stuff.cpp b/src/wi_stuff.cpp index fe8ba3fdfa..8538c423a7 100644 --- a/src/wi_stuff.cpp +++ b/src/wi_stuff.cpp @@ -1584,13 +1584,13 @@ void WI_drawNetgameStats () x = NG_STATSX; // [RH] Only use one graphic for the face backgrounds screen->DrawTexture (p, x - p->GetWidth(), y, - DTA_Translation, translationtables[TRANSLATION_Players][i], + DTA_Translation, translationtables[TRANSLATION_Players](i), DTA_Clean, true, TAG_DONE); if (i == me) screen->DrawTexture (star, x - p->GetWidth(), y, - DTA_Translation, translationtables[TRANSLATION_Players][i], + DTA_Translation, translationtables[TRANSLATION_Players](i), DTA_Clean, true, TAG_DONE); @@ -1634,13 +1634,13 @@ void WI_drawNetgameStats () if (gameinfo.gametype == GAME_Heretic) { screen->DrawTexture (star, 25, y, - DTA_Translation, translationtables[TRANSLATION_Players][i], + DTA_Translation, translationtables[TRANSLATION_Players](i), DTA_Clean, true, TAG_DONE); } else // Hexen and Strife don't have a face graphic for this. { - char pstr[3]={'P', '1'+i}; + char pstr[3]={'P', '1'+i, 0}; screen->SetFont (BigFont); screen->DrawText(CR_UNTRANSLATED, 25, y+10, pstr, DTA_Clean, true, TAG_DONE); } diff --git a/src/win32/fb_d3d9_wipe.cpp b/src/win32/fb_d3d9_wipe.cpp index db0d4b7f6f..290a75f59b 100644 --- a/src/win32/fb_d3d9_wipe.cpp +++ b/src/win32/fb_d3d9_wipe.cpp @@ -530,7 +530,7 @@ bool D3DFB::Wiper_Melt::Run(int ticks, D3DFB *fb) fb->D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(FBVERTEX)); int i, dy; - bool done; + bool done = true; // Copy the old screen in vertical strips on top of the new one. while (ticks--)