eliminate warnings, fix bug that locked up game when single-clicking a card
Modified: trunk/rosapps/games/solitaire/cardlib/cardbutton.cpp
Modified: trunk/rosapps/games/solitaire/cardlib/cardcolor.cpp
Modified: trunk/rosapps/games/solitaire/cardlib/cardcount.cpp
Modified: trunk/rosapps/games/solitaire/cardlib/cardlib.cpp
Modified: trunk/rosapps/games/solitaire/cardlib/cardregion.cpp
Modified: trunk/rosapps/games/solitaire/cardlib/cardregion.h
Modified: trunk/rosapps/games/solitaire/cardlib/cardrgnmouse.cpp
Modified: trunk/rosapps/games/solitaire/cardlib/cardwindow.cpp
Modified: trunk/rosapps/games/solitaire/makefile
Modified: trunk/rosapps/games/solitaire/solgame.cpp
Modified: trunk/rosapps/games/solitaire/solitaire.cpp

Modified: trunk/rosapps/games/solitaire/cardlib/cardbutton.cpp
--- trunk/rosapps/games/solitaire/cardlib/cardbutton.cpp	2005-03-10 04:10:24 UTC (rev 13906)
+++ trunk/rosapps/games/solitaire/cardlib/cardbutton.cpp	2005-03-10 04:58:40 UTC (rev 13907)
@@ -20,7 +20,7 @@
 CardButton::CardButton(CardWindow &parent, int Id, TCHAR *szText, UINT Style, bool visible,
 						int x, int y, int width, int height)
 
- : parentWnd(parent), id(Id), fVisible(visible), uStyle(Style), ButtonCallback(0)
+ : parentWnd(parent), id(Id), uStyle(Style), fVisible(visible), ButtonCallback(0)
 {
 	crText = RGB(255,255,255);
 	crBack = RGB(0, 128, 0);

Modified: trunk/rosapps/games/solitaire/cardlib/cardcolor.cpp
--- trunk/rosapps/games/solitaire/cardlib/cardcolor.cpp	2005-03-10 04:10:24 UTC (rev 13906)
+++ trunk/rosapps/games/solitaire/cardlib/cardcolor.cpp	2005-03-10 04:58:40 UTC (rev 13907)
@@ -186,28 +186,12 @@
 
 COLORREF ColorDarker(COLORREF col, double ratio)
 {
-	static double Hue, Lum, Sat;
-
-	//RGBtoHLS(col, &Hue, &Lum, &Sat);
-
-	//col = HLStoRGB(Hue, fMax(0.0,Lum-ratio), Sat);
-
 	return ColorScaleHSL(col, RGB(0,0,0), ratio);
-
-	//return col;
 }
 
 COLORREF ColorLighter(COLORREF col, double ratio)
 {
-	static double Hue, Lum, Sat;
-
-	//RGBtoHLS(col, &Hue, &Lum, &Sat);
-
-	//col = HLStoRGB(Hue, fMin(1.0,Lum+ratio), Sat);
-
 	return ColorScaleHSL(col, RGB(255,255,255), ratio);
-
-	//return col;
 }
 
 //

Modified: trunk/rosapps/games/solitaire/cardlib/cardcount.cpp
--- trunk/rosapps/games/solitaire/cardlib/cardcount.cpp	2005-03-10 04:10:24 UTC (rev 13906)
+++ trunk/rosapps/games/solitaire/cardlib/cardcount.cpp	2005-03-10 04:58:40 UTC (rev 13907)
@@ -87,4 +87,4 @@
 
 	if(count[index] > 0) 
 		count[index]--;
-}
\ No newline at end of file
+}

Modified: trunk/rosapps/games/solitaire/cardlib/cardlib.cpp
--- trunk/rosapps/games/solitaire/cardlib/cardlib.cpp	2005-03-10 04:10:24 UTC (rev 13906)
+++ trunk/rosapps/games/solitaire/cardlib/cardlib.cpp	2005-03-10 04:58:40 UTC (rev 13907)
@@ -10,7 +10,7 @@
 
 void LoadCardBitmaps(void);
 
-static bool __CARDLIB_ACES_HIGH = false;
+//static bool __CARDLIB_ACES_HIGH = false;
 extern double __CARDZOOMSPEED;
 
 //

Modified: trunk/rosapps/games/solitaire/cardlib/cardregion.cpp
--- trunk/rosapps/games/solitaire/cardlib/cardregion.cpp	2005-03-10 04:10:24 UTC (rev 13906)
+++ trunk/rosapps/games/solitaire/cardlib/cardregion.cpp	2005-03-10 04:58:40 UTC (rev 13907)
@@ -16,7 +16,7 @@
 void PaintRect(HDC hdc, RECT *rect, COLORREF colour);
 
 CardRegion::CardRegion(CardWindow &parent, int Id, bool visible, int x, int y, int xOffset, int yOffset) 
-: parentWnd(parent), id(Id), fVisible(visible), xpos(x), ypos(y), xoffset(xOffset), yoffset(yOffset)
+: id(Id), parentWnd(parent), xpos(x), ypos(y), xoffset(xOffset), yoffset(yOffset), fVisible(visible)
 {
 	width  = __cardwidth;
 	height = __cardheight;
@@ -56,7 +56,7 @@
 
 	nFlashCount		= 0;
 	fFlashVisible	= false;
-	uFlashTimer		= -1;
+	uFlashTimer		= (UINT)-1;
 
 	fMouseDragging = false;
 
@@ -331,25 +331,25 @@
 
 void CardRegion::StopFlash()
 {
-	if(uFlashTimer != -1)
+	if(uFlashTimer != (UINT)-1)
 	{
 		KillTimer((HWND)parentWnd, uFlashTimer);
 		nFlashCount		= 0;
-		uFlashTimer		= -1;
+		uFlashTimer		= (UINT)-1;
 		fFlashVisible	= true;
 	}
 }
 
 void CardRegion::DoFlash()
 {
-	if(uFlashTimer != -1)
+	if(uFlashTimer != (UINT)-1)
 	{
 		fFlashVisible = !fFlashVisible;
 
 		if(--nFlashCount == 0)
 		{
 			KillTimer((HWND)parentWnd, uFlashTimer);
-			uFlashTimer = -1;
+			uFlashTimer = (UINT)-1;
 			fFlashVisible = true;
 		}
 	
@@ -655,4 +655,4 @@
 	}
 
 	return true;
-}
\ No newline at end of file
+}

Modified: trunk/rosapps/games/solitaire/cardlib/cardregion.h
--- trunk/rosapps/games/solitaire/cardlib/cardregion.h	2005-03-10 04:10:24 UTC (rev 13906)
+++ trunk/rosapps/games/solitaire/cardlib/cardregion.h	2005-03-10 04:58:40 UTC (rev 13907)
@@ -147,12 +147,12 @@
 
 	bool	fMouseDragging;
 
-	int		xoffset;		//direction that cards take
-	int		yoffset;
-	
 	int		xpos;			//coordinates of stack
 	int		ypos;
 
+	int		xoffset;		//direction that cards take
+	int		yoffset;
+
 	int		width;			//stack-size of all cards
 	int		height;
 

Modified: trunk/rosapps/games/solitaire/cardlib/cardrgnmouse.cpp
--- trunk/rosapps/games/solitaire/cardlib/cardrgnmouse.cpp	2005-03-10 04:10:24 UTC (rev 13906)
+++ trunk/rosapps/games/solitaire/cardlib/cardrgnmouse.cpp	2005-03-10 04:58:40 UTC (rev 13907)
@@ -6,11 +6,18 @@
 //
 #include <windows.h>
 #include <math.h>
+#include <stdio.h>
 
 #include "cardlib.h"
 #include "cardwindow.h"
 #include "cardregion.h"
 
+#if 1
+#define TRACE(s)
+#else
+#define TRACE(s) printf("%s(%i): %s",__FILE__,__LINE__,s)
+#endif
+
 double __CARDZOOMSPEED = 32;
 
 int ClipCard(HDC hdc, int x, int y, int width, int height);
@@ -304,8 +311,10 @@
 	
 	// If have found a stack to drop onto
 	//
+	TRACE ( "can I drop card?\n" );
 	if(pDestStack && pDestStack->CanDropCards(dragstack)) 
 	{
+		TRACE ( "yes, dropping card\n" );
 		hdc = GetDC((HWND)parentWnd);
 		//			UseNicePalette(hdc);
 		ZoomCard(hdc, x - mousexoffset, y  - mouseyoffset, pDestStack);
@@ -332,25 +341,32 @@
 			pDestStack->AddCallback(*pDestStack, pDestStack->cardstack);//index, deststack->numcards);
 		
 		RedrawIfNotDim(pDestStack, true);
-	}	
+		TRACE ( "done dropping card\n" );
+	}
 
 	//
 	//	Otherwise, let the cards snap back onto this stack
 	//
 	else
 	{
-		
+		TRACE ( "no, putting card back\n" );
 		hdc = GetDC((HWND)parentWnd);
+		TRACE ( "calling ZoomCard()\n" );
 		ZoomCard(hdc, x - mousexoffset, y - mouseyoffset, this);
+		TRACE ( "cardstack += dragstack\n" );
 		cardstack += dragstack;
+		TRACE ( "calling ReleaseDC()\n" );
 		ReleaseDC((HWND)parentWnd, hdc);
 
+		TRACE ( "calling Update()\n" );
 		Update();		//Update this stack's card count + size
+		TRACE ( "done putting card back\n" );
 	}
 	
 	ReleaseDragBitmaps();
 	ReleaseCapture();
 	
+	TRACE ( "OnLButtonUp() done\n" );
 	return true;
 }
 
@@ -531,6 +547,7 @@
 #else
 void CardRegion::ZoomCard(HDC hdc, int xpos, int ypos, CardRegion *pDestStack)
 {
+	TRACE ( "ENTER ZoomCard()\n" );
 	double dx, dy, x ,y;
 	int apparentcards;
 	x = (double)xpos; y = (double)ypos;
@@ -552,6 +569,11 @@
 	//normalise the motion vector
 	dx = idestx - x;
 	dy = idesty - y;
+	if ( fabs(dx) + fabs(dy) < 0.001f )
+	{
+		MoveDragCardTo(hdc, idestx, idesty);
+		return;
+	}
 	double recip = 1.0 / sqrt(dx*dx + dy*dy);
 	dx *= recip * __CARDZOOMSPEED; dy *= recip * __CARDZOOMSPEED;
 
@@ -566,7 +588,8 @@
 
 		ix = (int)x;
 		iy = (int)y;
-		if(dx < 0.0 && ix < idestx) ix = idestx; 
+
+		if(dx < 0.0 && ix < idestx) ix = idestx;
 		else if(dx > 0.0 && ix > idestx) ix = idestx;
 		else attarget = false;
 
@@ -614,5 +637,6 @@
 
 		Sleep(10);
 	}
+	TRACE ( "EXIT ZoomCard()\n" );
 }
 #endif

Modified: trunk/rosapps/games/solitaire/cardlib/cardwindow.cpp
--- trunk/rosapps/games/solitaire/cardlib/cardwindow.cpp	2005-03-10 04:10:24 UTC (rev 13906)
+++ trunk/rosapps/games/solitaire/cardlib/cardwindow.cpp	2005-03-10 04:58:40 UTC (rev 13907)
@@ -282,7 +282,6 @@
 {
 	int i;
 	RECT rect;
-	int xpos = 10;
 	HPALETTE hOldPal;
 
 	hOldPal = UseNicePalette(hdc, __hPalette);

Modified: trunk/rosapps/games/solitaire/makefile
--- trunk/rosapps/games/solitaire/makefile	2005-03-10 04:10:24 UTC (rev 13906)
+++ trunk/rosapps/games/solitaire/makefile	2005-03-10 04:58:40 UTC (rev 13907)
@@ -4,6 +4,8 @@
 TARGET_TYPE = program
 
 TARGET_APPTYPE = windows
+# change to console for debugging purposes...
+#TARGET_APPTYPE = console
 
 TARGET_INSTALLDIR = system32
 

Modified: trunk/rosapps/games/solitaire/solgame.cpp
--- trunk/rosapps/games/solitaire/solgame.cpp	2005-03-10 04:10:24 UTC (rev 13906)
+++ trunk/rosapps/games/solitaire/solgame.cpp	2005-03-10 04:58:40 UTC (rev 13907)
@@ -1,16 +1,24 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <tchar.h>
+#include <stdio.h>
 #include "resource.h"
 #include "cardlib/cardlib.h"
 //#include "../catch22lib/trace.h"
 #include "solitaire.h"
 
+#if 1
+#define TRACE(s)
+#else
+#define TRACE(s) printf("%s(%i): %s",__FILE__,__LINE__,s)
+#endif
+
 CardStack activepile;
 bool fGameStarted = false;
 
 void NewGame(void)
 {
+	TRACE("ENTER NewGame()\n");
 	int i, j;
 
 	SolWnd.EmptyStacks();
@@ -44,6 +52,7 @@
 	SolWnd.Redraw();
 
 	fGameStarted = false;
+	TRACE("EXIT NewGame()\n");
 }
 
 //
@@ -56,6 +65,7 @@
 //
 bool CARDLIBPROC RowStackDragProc(CardRegion &stackobj, int iNumDragCards)
 {
+	TRACE("ENTER RowStackDragProc()\n");
 	int numfacedown;
 	int numcards;
 
@@ -63,6 +73,7 @@
 
 	numcards = stackobj.NumCards();
 
+	TRACE("EXIT RowStackDragProc()\n");
 	if(iNumDragCards <= numcards-numfacedown)
 		return true;
 	else
@@ -76,13 +87,17 @@
 //
 bool CARDLIBPROC RowStackDropProc(CardRegion &stackobj,  const CardStack &dragcards)
 {
+	TRACE("ENTER RowStackDropProc()\n");
 	Card dragcard = dragcards[dragcards.NumCards() - 1];
 
 	//if we are empty, can only drop a stack with a King at bottom
 	if(stackobj.NumCards() == 0)
 	{
 		if(dragcard.LoVal() != 13)
+		{
+			TRACE("EXIT RowStackDropProc(false)\n");
 			return false;
+		}
 	}
 	else
 	{
@@ -90,14 +105,21 @@
 		
 		//can only drop if card is 1 less
 		if(mystack[0].LoVal() != dragcard.LoVal() + 1)
+		{
+			TRACE("EXIT RowStackDropProc(false)\n");
 			return false;
+		}
 
 		//can only drop if card is different colour
 		if( mystack[0].IsBlack() && !dragcard.IsRed() ||
 		   !mystack[0].IsBlack() &&  dragcard.IsRed() )
+		{
+			TRACE("EXIT RowStackDropProc(false)\n");
 			return false;
+		}
 	}
 
+	TRACE("EXIT RowStackDropProc(true)\n");
 	return true;
 }
 
@@ -107,6 +129,7 @@
 //
 bool CanDrop(CardRegion &stackobj, Card card)
 {
+	TRACE("ENTER CanDrop()\n");
 	int topval;
 
 	const CardStack &cardstack = stackobj.GetCardStack();
@@ -115,6 +138,7 @@
 	{
 		if(card.Suit() != cardstack[0].Suit())
 		{
+			TRACE("EXIT CanDrop()\n");
 			return false;
 		}
 
@@ -127,8 +151,12 @@
 
 	//make sure 1 higher
 	if(card.LoVal() != (topval + 1))
+	{
+		TRACE("EXIT CanDrop()\n");
 		return false;
+	}
 
+	TRACE("EXIT CanDrop()\n");
 	return true;
 }
 
@@ -137,13 +165,17 @@
 //
 bool CARDLIBPROC SuitStackDropProc(CardRegion &stackobj, const CardStack &dragcards)
 {
-	int topval = 0;
-
+	TRACE("ENTER SuitStackDropProc()\n");
 	//only drop 1 card at a time
 	if(dragcards.NumCards() != 1)
+	{
+		TRACE("EXIT SuitStackDropProc()\n");
 		return false;
+	}
 
-	return CanDrop(stackobj, dragcards[0]);
+	bool b = CanDrop(stackobj, dragcards[0]);
+	TRACE("EXIT SuitStackDropProc()\n");
+	return b;
 }
 
 //
@@ -152,6 +184,7 @@
 //
 void CARDLIBPROC RowStackClickProc(CardRegion &stackobj, int iNumClicked)
 {
+	TRACE("ENTER RowStackClickProc()\n");
 	int numfacedown;
 	
 	stackobj.GetFaceDirection(&numfacedown);
@@ -163,6 +196,7 @@
 		stackobj.SetFaceDirection(CS_FACE_DOWNUP, numfacedown);
 		stackobj.Redraw();
 	}
+	TRACE("EXIT RowStackClickProc()\n");
 }
 
 //
@@ -170,12 +204,17 @@
 //
 CardRegion *FindSuitStackFromCard(Card card)
 {
+	TRACE("ENTER FindSuitStackFromCard()\n");
 	for(int i = 0; i < 4; i++)
 	{
 		if(CanDrop(*pSuitStack[i], card))
+		{
+			TRACE("EXIT FindSuitStackFromCard()\n");
 			return pSuitStack[i];
+		}
 	}
 
+	TRACE("EXIT FindSuitStackFromCard()\n");
 	return 0;
 }
 
@@ -187,6 +226,7 @@
 //
 void CARDLIBPROC SuitStackAddProc(CardRegion &stackobj, const CardStack &added)
 {
+	TRACE("ENTER SuitStackAddProc()\n");
 	bool fGameOver = true;
 
 	for(int i = 0; i < 4; i++)
@@ -207,6 +247,7 @@
 			pSuitStack[i]->Flash(11, 100);
 		}
 	}
+	TRACE("EXIT SuitStackAddProc()\n");
 }
 
 //
@@ -216,9 +257,13 @@
 //
 void CARDLIBPROC RowStackDblClickProc(CardRegion &stackobj, int iNumClicked)
 {
+	TRACE("ENTER RowStackDblClickProc()\n");
 	//can only move 1 card at a time
 	if(iNumClicked != 1)
+	{
+		TRACE("EXIT RowStackDblClickProc()\n");
 		return;
+	}
 
 	//find a suit-stack to move the card to...
 	const CardStack &cardstack = stackobj.GetCardStack();
@@ -231,6 +276,7 @@
 		//AddProc callbacks called for us on the destination stacks...
 		stackobj.SimulateDrag(pDest, 1, true);
 	}
+	TRACE("EXIT RowStackDblClickProc()\n");
 }
 
 //
@@ -238,7 +284,9 @@
 //
 void CARDLIBPROC PileDblClickProc(CardRegion &stackobj, int iNumClicked)
 {
+	TRACE("ENTER PileDblClickProc()\n");
 	RowStackDblClickProc(stackobj, iNumClicked);
+	TRACE("EXIT PileDblClickProc()\n");
 }
 
 //
@@ -246,6 +294,7 @@
 //
 void CARDLIBPROC PileRemoveProc(CardRegion &stackobj, int iItems)
 {
+	TRACE("ENTER PileRemoveProc()\n");
 	//modify our "virtual" pile by removing the same card
 	//that was removed from the physical card stack
 	activepile.Pop(iItems);
@@ -259,6 +308,7 @@
 		stackobj.SetOffsets(0,0);
 		stackobj.SetCardStack(activepile);
 	}
+	TRACE("EXIT PileRemoveProc()\n");
 }
 
 //
@@ -267,6 +317,7 @@
 //
 void CARDLIBPROC DeckClickProc(CardRegion &stackobj, int iNumClicked)
 {
+	TRACE("ENTER DeckClickProc()\n");
 	CardStack cardstack = stackobj.GetCardStack();
 	CardStack pile		 = pPile->GetCardStack();
 
@@ -305,4 +356,5 @@
 	pPile->SetCardStack(pile);
 
 	SolWnd.Redraw();
+	TRACE("EXIT DeckClickProc()\n");
 }

Modified: trunk/rosapps/games/solitaire/solitaire.cpp
--- trunk/rosapps/games/solitaire/solitaire.cpp	2005-03-10 04:10:24 UTC (rev 13906)
+++ trunk/rosapps/games/solitaire/solitaire.cpp	2005-03-10 04:58:40 UTC (rev 13907)
@@ -28,6 +28,11 @@
 	lstrcpy(ptr + 1, szExt);
 }
 
+int main ( int argc, char** argv )
+{
+	return WinMain ( NULL, NULL, NULL, SW_SHOW );
+}
+
 //
 //	Main entry point
 //