From bec0d3438f77db99ebd39334ffd341ca3d5ff478 Mon Sep 17 00:00:00 2001
From: Randy Heit <rheit@zdoom.fake>
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 06af6ddc3..a9d2cf534 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 e203f4a6f..7d3fb84cd 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 c5d30d18b..6a9927e0f 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 b6c15754e..8eed97567 100644
--- a/src/r_data.cpp
+++ b/src/r_data.cpp
@@ -173,7 +173,7 @@ int FTextureManager::ListTextures (const char *name, TArray<int> &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 6d1686903..ddd6906b3 100644
--- a/src/r_translate.cpp
+++ b/src/r_translate.cpp
@@ -44,7 +44,7 @@
 #include "gi.h"
 #include "stats.h"
 
-TAutoGrowArray<FRemapTablePtr> translationtables[NUM_TRANSLATION_TABLES];
+TAutoGrowArray<FRemapTablePtr, FRemapTable *> translationtables[NUM_TRANSLATION_TABLES];
 
 /****************************************************/
 /****************************************************/
@@ -281,7 +281,7 @@ FRemapTable *TranslationToTable(int translation)
 {
 	unsigned int type = GetTranslationType(translation);
 	unsigned int index = GetTranslationIndex(translation);
-	TAutoGrowArray<FRemapTablePtr> *slots;
+	TAutoGrowArray<FRemapTablePtr, FRemapTable *> *slots;
 
 	if (type <= 0 || type >= NUM_TRANSLATION_TABLES)
 	{
diff --git a/src/r_translate.h b/src/r_translate.h
index 24b231b5e..fe9e7b49b 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<FRemapTablePtr> translationtables[NUM_TRANSLATION_TABLES];
+extern TAutoGrowArray<FRemapTablePtr, FRemapTable *> translationtables[NUM_TRANSLATION_TABLES];
 
 #define TRANSLATION_SHIFT 16
 #define TRANSLATION_MASK ((1<<TRANSLATION_SHIFT)-1)
@@ -87,8 +87,8 @@ inline int GetTranslationIndex(DWORD trans)
 // Retrieve the FRemapTable that an actor's translation value maps to.
 FRemapTable *TranslationToTable(int translation);
 
-const int MAX_ACS_TRANSLATIONS = 65535;
-const int MAX_DECORATE_TRANSLATIONS = 65535;
+#define MAX_ACS_TRANSLATIONS		65535
+#define MAX_DECORATE_TRANSLATIONS	65535
 
 // Initialize color translation tables, for player rendering etc.
 void R_InitTranslationTables (void);
diff --git a/src/tarray.h b/src/tarray.h
index 2a9447ae4..a66369f62 100644
--- a/src/tarray.h
+++ b/src/tarray.h
@@ -43,7 +43,9 @@
 
 // TArray -------------------------------------------------------------------
 
-template <class T>
+// T is the type stored in the array.
+// TT is the type returned by operator().
+template <class T, class TT=T>
 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 T>
-class TAutoGrowArray : public TArray<T>
+template <class T, class TT=T>
+class TAutoGrowArray : public TArray<T, TT>
 {
 public:
 	T GetVal (unsigned int index)
diff --git a/src/wi_stuff.cpp b/src/wi_stuff.cpp
index fe8ba3fdf..8538c423a 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 db0d4b7f6..290a75f59 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--)