Am Dienstag, 27. Februar 2007 schrieb Per Inge Mathisen:
> On 2/27/07, Dennis Schridde <[EMAIL PROTECTED]> wrote:
> > Now the fog is gone entirely... Even in campaign I don't get any fog
> > anymore. (SVN-trunk)
>
> Since you say SVN-trunk, I must ask, is this with or without the patch
> attached in the first post in this thread?
With an without.
I attached the patch again, since the trunk changed a bit, so the patch didn't 
apply cleanly.

--Dennis
Index: src/scriptfuncs.c
===================================================================
--- src/scriptfuncs.c	(revision 824)
+++ src/scriptfuncs.c	(working copy)
@@ -3818,18 +3818,23 @@
 		return FALSE;
 	}
 
-	//jps 17 feb 99 just set the status let other code worry about fogEnable/reveal
-	if (bState)//true, so go to false
+	if (bState)
 	{
 		//restart fog if it was off
-		if ((fogStatus == 0) && war_GetFog() && !(bMultiPlayer && game.fog))
+		// The check below used to check if (fogStatus == 0) too, making it impossible
+		// to use both background and distance fog at the same time. I removed it. - Per
+		if (war_GetVisualFog())
 		{
+			debug(LOG_FOG, "Script sets background fog on");
 			pie_EnableFog(TRUE);
+		} else if (!war_GetVisualFog()) {
+			debug(LOG_FOG, "Script would set background fog on but war_GetVisualFog is FALSE");
 		}
 		fogStatus |= FOG_BACKGROUND;//set lowest bit of 3
 	}
 	else
 	{
+		debug(LOG_FOG, "Script turns background fog off");
 		fogStatus &= FOG_FLAGS-FOG_BACKGROUND;//clear middle bit of 3
 		//disable fog if it longer used
 		if (fogStatus == 0)
@@ -3839,42 +3844,6 @@
 		}
 	}
 
-/* jps 17 feb 99
-	if(getRevealStatus())		// fog'o war enabled
-	{
-		pie_SetFogStatus(FALSE);
-		pie_EnableFog(FALSE);
-//		fogStatus = 0;
-		return TRUE;
-	}
-
-	if (bState)//true, so go to false
-	{
-		if (war_GetFog())
-		{
-			//restart fog if it was off
-			if (fogStatus == 0)
-			{
-				pie_EnableFog(TRUE);
-			}
-			fogStatus |= FOG_BACKGROUND;//set lowest bit of 3
-		}
-	}
-	else
-	{
-		if (war_GetFog())
-		{
-			fogStatus &= FOG_FLAGS-FOG_BACKGROUND;//clear middle bit of 3
-			//disable fog if it longer used
-			if (fogStatus == 0)
-			{
-				pie_SetFogStatus(FALSE);
-				pie_EnableFog(FALSE);
-			}
-		}
-	}
-*/
-
 	return TRUE;
 }
 
@@ -3888,19 +3857,24 @@
 	{
 		return FALSE;
 	}
-	// ffs am
-//jps 17 feb 99 just set the status let other code worry about fogEnable/reveal
-	if (bState)//true, so go to false
+
+	if (bState)
 	{
 		//restart fog if it was off
-		if ((fogStatus == 0) && war_GetFog() )
+		// The check below used to check if (fogStatus == 0) too, making it impossible
+		// to use both background and distance fog at the same time. I removed it. - Per
+		if (war_GetVisualFog())
 		{
+			debug(LOG_FOG, "Script sets distance fog on");
 			pie_EnableFog(TRUE);
+		} else if (!war_GetVisualFog()) {
+			debug(LOG_FOG, "Script would set distance fog on but war_GetVisualFog is FALSE");
 		}
 		fogStatus |= FOG_DISTANCE;//set lowest bit of 3
 	}
 	else
 	{
+		debug(LOG_FOG, "Script turns distance fog off");
 		fogStatus &= FOG_FLAGS-FOG_DISTANCE;//clear middle bit of 3
 		//disable fog if it longer used
 		if (fogStatus == 0)
@@ -3910,41 +3884,6 @@
 		}
 	}
 
-/* jps 17 feb 99	if(getRevealStatus())		// fog'o war enabled
-	{
-		pie_SetFogStatus(FALSE);
-		pie_EnableFog(FALSE);
-//		fogStatus = 0;
-		return TRUE;
-	}
-
-	if (bState)//true, so go to false
-	{
-		if (war_GetFog())
-		{
-			//restart fog if it was off
-			if (fogStatus == 0)
-			{
-				pie_EnableFog(TRUE);
-			}
-			fogStatus |= FOG_DISTANCE;//set lowest bit of 3
-		}
-	}
-	else
-	{
-		if (war_GetFog())
-		{
-			fogStatus &= FOG_FLAGS-FOG_DISTANCE;//clear middle bit of 3
-			//disable fog if it longer used
-			if (fogStatus == 0)
-			{
-				pie_SetFogStatus(FALSE);
-				pie_EnableFog(FALSE);
-			}
-		}
-	}
-*/
-
 	return TRUE;
 }
 
Index: src/levels.c
===================================================================
--- src/levels.c	(revision 824)
+++ src/levels.c	(working copy)
@@ -668,8 +668,6 @@
 
 	debug(LOG_WZ, "Loading level %s", pName);
 	// reset fog
-//	fogStatus = 0;
-//	pie_EnableFog(FALSE);//removed, always set by script or save game
 
 	levelLoadType = saveType;
 
Index: src/warzoneconfig.c
===================================================================
--- src/warzoneconfig.c	(revision 824)
+++ src/warzoneconfig.c	(working copy)
@@ -79,7 +79,6 @@
 {
 	//set those here and reset in clParse or loadConfig
 	pie_SetFogCap(FOG_CAP_UNDEFINED);
-	war_SetFog(FALSE);
 	war_SetTranslucent(TRUE);	// SHURCOOL: These two should be true (ie. enabled) by default; not false
 
 	war_SetPlayAudioCDs(TRUE);
@@ -112,26 +111,23 @@
 }
 
 /***************************************************************************/
+/*  Set or unset visual fog. Whenever visual fog is set, fog of war is     */
+/*  unset, and vica versa.                                                 */
 /***************************************************************************/
-void war_SetFog(BOOL val)
+void war_SetVisualFog(BOOL val)
 {
-	debug(LOG_FOG, "Fog of war turned %s", val ? "ON" : "OFF");
-	if (warGlobs.bFog != val)
+	debug(LOG_FOG, "war_SetFog: Visual fog turned %s", val ? "ON" : "OFF");
+	warGlobs.bFog = val;
+	setRevealStatus(!val);
+
+	/* FIXME: Why the below? - Per */
+	if (warGlobs.bFog == FALSE)
 	{
-		warGlobs.bFog = val;
-	}
-	if (warGlobs.bFog == TRUE)
-	{
-		setRevealStatus(FALSE);
-	}
-	else
-	{
-		setRevealStatus(TRUE);
 		pie_SetFogColour(0);
 	}
 }
 
-BOOL war_GetFog(void)
+BOOL war_GetVisualFog(void)
 {
 	return  warGlobs.bFog;
 }
Index: src/warzoneconfig.h
===================================================================
--- src/warzoneconfig.h	(revision 824)
+++ src/warzoneconfig.h	(working copy)
@@ -50,8 +50,8 @@
  */
 /***************************************************************************/
 extern void	war_SetDefaultStates(void);
-extern void war_SetFog(BOOL val);
-extern BOOL war_GetFog(void);
+extern void war_SetVisualFog(BOOL val);
+extern BOOL war_GetVisualFog(void);
 extern void war_SetTranslucent(BOOL val);
 extern BOOL war_GetTranslucent(void);
 extern void war_SetSeqMode(SEQ_MODE mode);
Index: src/game.c
===================================================================
--- src/game.c	(revision 824)
+++ src/game.c	(working copy)
@@ -1655,7 +1655,7 @@
 			}
 			else if (saveGameData.fogState == 1)//fog using old code assume background and depth
 			{
-				if (war_GetFog())
+				if (war_GetVisualFog())
 				{
 					pie_EnableFog(TRUE);
 				}
@@ -1667,7 +1667,7 @@
 			}
 			else//version 18+ fog
 			{
-				if (war_GetFog())
+				if (war_GetVisualFog())
 				{
 					pie_EnableFog(TRUE);
 				}
@@ -3854,7 +3854,7 @@
 		}
 		else if (psSaveGame->fogState == 1)//fog using old code assume background and depth
 		{
-			if (war_GetFog())
+			if (war_GetVisualFog())
 			{
 				pie_EnableFog(TRUE);
 			}
@@ -3866,7 +3866,7 @@
 		}
 		else//version 18+ fog
 		{
-			if (war_GetFog())
+			if (war_GetVisualFog())
 			{
 				pie_EnableFog(TRUE);
 			}
Index: src/multiplay.h
===================================================================
--- src/multiplay.h	(revision 824)
+++ src/multiplay.h	(working copy)
@@ -101,7 +101,6 @@
 	UBYTE		maxPlayers;					// max players to allow
 	char		name[128];					// game name   (to be used)
 	BOOL		bComputerPlayers;			// Allow computer players
-	BOOL		fog;
 	UDWORD		power;						// power level for arena game
 //	UDWORD		techLevel;					// tech levels to use . 0= all levels.
 	UBYTE		base;						// clean/base/base&defence
Index: src/init.c
===================================================================
--- src/init.c	(revision 824)
+++ src/init.c	(working copy)
@@ -972,7 +972,6 @@
 	//loadLevels(DIR_CAMPAIGN);
 
 	// Initialize render engine
-	war_SetFog(FALSE);
 	if (!pie_Initialise()) {
 		debug(LOG_ERROR, "Unable to initialise renderer");
 		return FALSE;
Index: src/multiint.c
===================================================================
--- src/multiint.c	(revision 824)
+++ src/multiint.c	(working copy)
@@ -45,6 +45,7 @@
 #include "objects.h"
 #include "display.h"// pal stuff
 #include "display3d.h"
+#include "warzoneconfig.h"
 
 /* Includes direct access to render library */
 #include "lib/ivis_common/piedef.h"
@@ -903,13 +904,13 @@
 
 	addMultiBut(psWScreen,MULTIOP_FOG,MULTIOP_FOG_ON ,MCOL1,2,MULTIOP_BUTW,MULTIOP_BUTH,STR_MUL_FOG_ON, IMAGE_FOG_OFF, IMAGE_FOG_OFF_HI,TRUE);//black stuff
 	addMultiBut(psWScreen,MULTIOP_FOG,MULTIOP_FOG_OFF,MCOL2,2,MULTIOP_BUTW,MULTIOP_BUTH,STR_MUL_FOG_OFF,IMAGE_FOG_ON,IMAGE_FOG_ON_HI,TRUE);
-	if(game.fog)
+	if (!war_GetVisualFog())
 	{
-		widgSetButtonState(psWScreen, MULTIOP_FOG_ON,WBUT_LOCK);
+		widgSetButtonState(psWScreen, MULTIOP_FOG_ON, WBUT_LOCK);
 	}
 	else
 	{
-		widgSetButtonState(psWScreen, MULTIOP_FOG_OFF,WBUT_LOCK);
+		widgSetButtonState(psWScreen, MULTIOP_FOG_OFF, WBUT_LOCK);
 	}
 
 
@@ -1700,8 +1701,12 @@
 
 	if(! NetPlay.bHost)
 	{
-		if( game.fog) widgSetButtonState(psWScreen,MULTIOP_FOG_OFF ,WBUT_DISABLE);		//fog
-		if(!game.fog) widgSetButtonState(psWScreen,MULTIOP_FOG_ON ,WBUT_DISABLE);
+		if (!war_GetVisualFog()) 
+		{
+			widgSetButtonState(psWScreen, MULTIOP_FOG_OFF, WBUT_DISABLE);
+		} else {
+			widgSetButtonState(psWScreen, MULTIOP_FOG_ON, WBUT_DISABLE);
+		}
 
 //		if(  game.type == DMATCH )
 //		{
@@ -1974,7 +1979,7 @@
 		case MULTIOP_FOG_ON:
 			widgSetButtonState(psWScreen, MULTIOP_FOG_ON,WBUT_LOCK);
 			widgSetButtonState(psWScreen, MULTIOP_FOG_OFF,0);
-			game.fog = TRUE;
+			war_SetVisualFog(FALSE);
 			if(bHosted)
 			{
 				sendOptions(0,0);
@@ -1984,7 +1989,7 @@
 		case MULTIOP_FOG_OFF:
 			widgSetButtonState(psWScreen, MULTIOP_FOG_ON,0);
 			widgSetButtonState(psWScreen, MULTIOP_FOG_OFF,WBUT_LOCK);
-			game.fog = FALSE;
+			war_SetVisualFog(TRUE);
 			if(bHosted)
 			{
 				sendOptions(0,0);
@@ -2310,14 +2315,11 @@
 			SendFireUp();								//bcast a fireup message
 		}
 
-		// set the fog correctly..
-		setRevealStatus(game.fog);
+		if(bWhiteBoardUp)
+		{
+			removeWhiteBoard();
+		}
 
-	if(bWhiteBoardUp)
-	{
-		removeWhiteBoard();
-	}
-
 		changeTitleMode(STARTGAME);
 
 		bHosted = FALSE;
@@ -2544,14 +2546,10 @@
 					removeWildcards(sForceName);
 				}
 
-
-				// set the fog correctly..
-				setRevealStatus(game.fog);
-
 				bMultiPlayer = TRUE;
 				if(bWhiteBoardUp)
 				{
-				removeWhiteBoard();
+					removeWhiteBoard();
 				}
 				changeTitleMode(STARTGAME);
 				bHosted = FALSE;
Index: src/frontend.c
===================================================================
--- src/frontend.c	(revision 824)
+++ src/frontend.c	(working copy)
@@ -784,7 +784,7 @@
 	////////////
 	// fog
 	addTextButton(FRONTEND_FOGTYPE,	 FRONTEND_POS4X-35,   FRONTEND_POS4Y, strresGetString(psStringRes,STR_FE_FOG),TRUE,FALSE);
-	if(war_GetFog())
+	if (war_GetVisualFog())
 	{
 		addTextButton(FRONTEND_FOGTYPE_R,FRONTEND_POS4M-55,FRONTEND_POS4Y, strresGetString(psStringRes,STR_FE_CRAPFOG),TRUE,FALSE);
 	}
@@ -882,20 +882,18 @@
 
 	case FRONTEND_FOGTYPE:
 	case FRONTEND_FOGTYPE_R:
-	if (war_GetFog())
-	{	// turn off crap fog, turn on vis fog.
-		debug(LOG_FOG, "runGameOptions2Menu: Fog of war ON, visual fog OFF");
-		war_SetFog(FALSE);
-		avSetStatus(TRUE);
-		widgSetString(psWScreen,FRONTEND_FOGTYPE_R, strresGetString(psStringRes,STR_FE_GOODFOG));
-	}
-	else
-	{	// turn off vis fog, turn on normal crap fog.
+	if (!war_GetVisualFog())
+	{
 		debug(LOG_FOG, "runGameOptions2Menu: Fog of war OFF, visual fog ON");
-		avSetStatus(FALSE);
-		war_SetFog(TRUE);
+		war_SetVisualFog(TRUE);
 		widgSetString(psWScreen,FRONTEND_FOGTYPE_R, strresGetString(psStringRes,STR_FE_CRAPFOG));
 	}
+	else
+	{
+		debug(LOG_FOG, "runGameOptions2Menu: Fog of war ON, visual fog OFF");
+		war_SetVisualFog(FALSE);
+		widgSetString(psWScreen,FRONTEND_FOGTYPE_R, strresGetString(psStringRes,STR_FE_GOODFOG));
+	}
 	break;
 
 	case FRONTEND_QUIT:
@@ -1100,28 +1098,10 @@
 	switch(id)
 	{
 
-//	case FRONTEND_GAMMA:
 	case FRONTEND_SCROLLSPEED:
 		SetMousePos(FRONTEND_BOTFORMX + FRONTEND_POS1M + 5, mouseY() - 3);	// move mouse
 		break;
 
-/*	case FRONTEND_FOGTYPE:
-	case FRONTEND_FOGTYPE_R:
-	if( war_GetFog()	)
-	{	// turn off crap fog, turn on vis fog.
-		war_SetFog(FALSE);
-		avSetStatus(TRUE);
-		widgSetString(psWScreen,FRONTEND_FOGTYPE_R, strresGetString(psStringRes,STR_FE_GOODFOG));
-	}
-	else
-	{	// turn off vis fog, turn on normal crap fog.
-		avSetStatus(FALSE);
-		war_SetFog(TRUE);
-		widgSetString(psWScreen,FRONTEND_FOGTYPE_R, strresGetString(psStringRes,STR_FE_CRAPFOG));
-	}
-	break;
-*/
-
 	case FRONTEND_DIFFICULTY:
 	case FRONTEND_DIFFICULTY_R:
 		switch( getDifficultyLevel() )
Index: src/keybind.c
===================================================================
--- src/keybind.c	(revision 824)
+++ src/keybind.c	(working copy)
@@ -545,31 +545,32 @@
 
 }
 
+/* FIXME: Does not seem to do anything. - Per */
 void	kf_ToggleMistFog( void )
 {
-
 	static BOOL bEnabled  = TRUE;//start in nicks mode
 
-		if (bEnabled)//true, so go to false
+	if (bEnabled)//true, so go to false
+	{
+		debug(LOG_FOG, "kf_ToggleMistFog: Setting mist to false");
+		bEnabled = FALSE;
+		fogStatus &= FOG_FLAGS - FOG_GROUND; //clear highest bit of 3
+		if (fogStatus == 0)
 		{
-			bEnabled = FALSE;
-			fogStatus &= FOG_FLAGS-FOG_GROUND;//clear highest bit of 3
-			if (fogStatus == 0)
-			{
-				pie_SetFogStatus(FALSE);
-				pie_EnableFog(FALSE);
-			}
+			pie_SetFogStatus(FALSE);
+			pie_EnableFog(FALSE);
 		}
-		else
+	}
+	else
+	{
+		debug(LOG_FOG, "kf_ToggleMistFog: Setting mist to true");
+		bEnabled = TRUE;
+		if (fogStatus == 0)
 		{
-			bEnabled = TRUE;
-			if (fogStatus == 0)
-			{
-				pie_EnableFog(TRUE);
-			}
-			fogStatus |= FOG_GROUND;//set highest bit of 3
+			pie_EnableFog(TRUE);
 		}
-
+		fogStatus |= FOG_GROUND; //set highest bit of 3
+	}
 }
 
 void	kf_ToggleFogColour( void )
Index: src/configuration.c
===================================================================
--- src/configuration.c	(revision 824)
+++ src/configuration.c	(working copy)
@@ -244,28 +244,6 @@
 
 
 	// //////////////////////////
-	// use vis fog
-	if(getWarzoneKeyNumeric("visfog", &val))
-	{
-		if(val)
-		{
-			war_SetFog(FALSE);
-			avSetStatus(TRUE);
-		}
-		else
-		{
-			avSetStatus(FALSE);
-			war_SetFog(TRUE);
-		}
-	}
-	else
-	{
-		avSetStatus(FALSE);
-		war_SetFog(TRUE);
-		setWarzoneKeyNumeric("visfog", 0);
-	}
-
-	// //////////////////////////
 	// favourite colour
 	if(!bMultiPlayer)
 	{
@@ -357,16 +335,14 @@
 		setWarzoneKeyNumeric("power", game.power);
 	}
 
-	// fog
-	if(getWarzoneKeyNumeric("fog", &val))
+	// visual fog
+	if (!getWarzoneKeyNumeric("fog", &val))
 	{
-		game.fog= val;
+		debug(LOG_FOG, "No fog information in config file");
+		val = TRUE;
+		setWarzoneKeyNumeric("fog", val);
 	}
-	else
-	{
-		game.fog= TRUE;
-		setWarzoneKeyNumeric("fog", game.fog);
-	}
+	war_SetVisualFog(val);
 
 	//type
 	if(getWarzoneKeyNumeric("type", &val))
@@ -547,7 +523,6 @@
 	setWarzoneKeyNumeric("scroll",(SDWORD)scroll_speed_accel);		// scroll
 	setWarzoneKeyNumeric("difficulty", getDifficultyLevel());		// level
 	setWarzoneKeyNumeric("barmode",(SDWORD)barMode);			//energybars
-	setWarzoneKeyNumeric("visfog",(SDWORD)(!war_GetFog()));			// fogtype
 	setWarzoneKeyNumeric("shake",(SDWORD)(getShakeStatus()));		// screenshake
 	setWarzoneKeyNumeric("mouseflip",(SDWORD)(getInvertMouseStatus()));	// flipmouse
 	setWarzoneKeyNumeric("shadows",(SDWORD)(getDrawShadows()));	// shadows
@@ -560,6 +535,9 @@
 	setWarzoneKeyNumeric("radarObjectMode",(SDWORD)bEnemyAllyRadarColor);    // enemy/allies radar view
 	setWarzoneKeyNumeric("radarTerrainMode",(SDWORD)radarDrawMode);
 
+	debug(LOG_FOG, "Writing fog info to config file...");
+	setWarzoneKeyNumeric("fog", war_GetVisualFog());
+
 	if(!bMultiPlayer)
 	{
 		setWarzoneKeyNumeric("colour",(SDWORD)getPlayerColour(0));			// favourite colour.
@@ -575,7 +553,6 @@
 		setWarzoneKeyNumeric("power", game.power);			// power
 		setWarzoneKeyNumeric("type", game.type);				// game type
 		setWarzoneKeyNumeric("base", game.base);				// size of base
-		setWarzoneKeyNumeric("fog", game.fog);				// fog 'o war
 		setWarzoneKeyNumeric("limit", game.limit);			// limits
 		setWarzoneKeyNumeric("maxPlay", game.maxPlayers);		// max no of players
 		setWarzoneKeyNumeric("compPlay", game.bComputerPlayers);	// allow pc players
Index: src/main.c
===================================================================
--- src/main.c	(revision 824)
+++ src/main.c	(working copy)
@@ -825,6 +825,7 @@
 			case GS_NORMAL:
 				if (loopStatus != GAMECODE_NEWLEVEL)
 				{
+					debug(LOG_FOG, "main: Resetting fogStatus");
 					initLoadingScreen(TRUE);	// returning to f.e. do a loader.render not active
 					pie_EnableFog(FALSE);//dont let the normal loop code set status on
 					fogStatus = 0;
Index: src/advvis.c
===================================================================
--- src/advvis.c	(revision 824)
+++ src/advvis.c	(working copy)
@@ -42,13 +42,6 @@
 static BOOL bRevealActive = FALSE;
 
 
-// ------------------------------------------------------------------------------------
-void	avSetStatus(BOOL var)
-{
-	debug(LOG_FOG, "avSetStatus: Setting visual fog %s", var ? "ON" : "OFF");
-	bRevealActive = var;
-}
-
 void	avInformOfChange(SDWORD x, SDWORD y)
 {
 MAPTILE	*psTile;
Index: src/advvis.h
===================================================================
--- src/advvis.h	(revision 824)
+++ src/advvis.h	(working copy)
@@ -30,6 +30,5 @@
 extern void	setRevealStatus( BOOL val );
 extern BOOL	getRevealStatus( void );
 extern void	preProcessVisibility( void );
-extern void	avSetStatus(BOOL var);
 
 #endif

Attachment: pgptpqH2VYcDq.pgp
Description: PGP signature

_______________________________________________
Warzone-dev mailing list
[email protected]
https://mail.gna.org/listinfo/warzone-dev

Reply via email to