Giel van Schijndel schreef:
> Giel van Schijndel schreef:
>   
>> This patch implements it as a configfile setting.
>>     
> That patch seems to also modify an assert (just to clarify what it
> means). If however you don't want that modification, then this one
> *only* applies the required changes for the addition of an fps config
> setting.
This is (I hope) the final patch for the addition of this config setting.

Difference with last one is that it prevents a call to setFPSlimit() to
modify the FPS-limit when it is only intended to set a default or
initial value. See (the modified) frame.h for the function prototypes
(plus doxygen style comments on it).

-- 
Giel
Index: lib/framework/frame.c
===================================================================
--- lib/framework/frame.c       (revision 586)
+++ lib/framework/frame.c       (working copy)
@@ -234,6 +234,22 @@
        }
 }
 
+void setFPSlimit(int newfps, BOOL initCall = FALSE)
+{
+       static BOOL firstCall = TRUE;
+       if (initCall && !firstCall)     // If the call is ment as 
initialization when
+               return;                 // this isn't the first call to this 
function, abort.
+
+       firstCall = FALSE;
+
+       SDL_setFramerate( &wzFPSmanager, newfps );
+}
+
+int getFPSlimit()
+{
+       return SDL_getFramerate( &wzFPSmanager );
+}
+
 /*
  * frameInitialise
  *
@@ -279,7 +295,7 @@
        InitFrameStuff();
 
        SDL_initFramerate( &wzFPSmanager );
-       SDL_setFramerate( &wzFPSmanager, 60 );
+       setFPSlimit(60, TRUE);
 
        // Initialise the resource stuff
        if (!resInitialise())
Index: lib/framework/frame.h
===================================================================
--- lib/framework/frame.h       (revision 586)
+++ lib/framework/frame.h       (working copy)
@@ -67,7 +67,17 @@
  */
 extern UDWORD frameGetAverageRate(void);
 
+/** sets the used framerate limit
+ * \param newfps new framerate limit
+ * \param initCall indicates wether this call is only meant to set an 
initial/default value for the framerate
+ */
+extern void setFPSlimit(int newfps, BOOL initCall = FALSE);
 
+/** returns the used framerate limit
+ * \return currently used framerate limit
+ */
+extern int getFPSlimit();
+
 /* Load the file with name pointed to by pFileName into a memory buffer. */
 BOOL loadFile(const char *pFileName,           // The filename
               char **ppFileData,       // A buffer containing the file contents
Index: src/configuration.c
===================================================================
--- src/configuration.c (revision 586)
+++ src/configuration.c (working copy)
@@ -480,6 +480,15 @@
                setWarzoneKeyNumeric("radarTerrainMode", radarDrawMode);
        }
 
+       // fps limit
+       if(getWarzoneKeyNumeric("fps", &val))
+       {
+               setFPSlimit(val);
+       } else {
+               setFPSlimit(60, TRUE);
+               setWarzoneKeyNumeric("fps", 60);
+       }
+
        return closeWarzoneKey();
 }
 
@@ -552,6 +561,7 @@
 
        setWarzoneKeyNumeric("radarObjectMode",(SDWORD)bEnemyAllyRadarColor);   
 // enemy/allies radar view
        setWarzoneKeyNumeric("radarTerrainMode",(SDWORD)radarDrawMode);
+       setWarzoneKeyNumeric("fps", getFPSlimit());
 
        if(!bMultiPlayer)
        {
Index: src/keybind.c
===================================================================
--- src/keybind.c       (revision 586)
+++ src/keybind.c       (working copy)
@@ -295,7 +295,7 @@
 /* Writes out the frame rate */
 void   kf_FrameRate( void )
 {
-       CONPRINTF(ConsoleString,(ConsoleString,"FPS %d; PIEs %d; polys %d; 
Terr. polys %d; States %d", frameGetAverageRate(), loopPieCount, loopPolyCount, 
loopTileCount, loopStateChanges));
+       CONPRINTF(ConsoleString,(ConsoleString,"FPS %d; Target-FPS: %d; PIEs 
%d; polys %d; Terr. polys %d; States %d", frameGetAverageRate(), getFPSlimit(), 
loopPieCount, loopPolyCount, loopTileCount, loopStateChanges));
        if (bMultiPlayer) {
                        CONPRINTF(ConsoleString,(ConsoleString,
                                                "NETWORK:  Bytes: s-%d r-%d  
Packets: s-%d r-%d",

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Warzone-dev mailing list
Warzone-dev@gna.org
https://mail.gna.org/listinfo/warzone-dev

Reply via email to