-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


EA , 12-

, 19 2017 . 13:21 +
. , - , . , . , . , float, .

image

.


Need for Speed: Most Wanted. -, . , . .

. . , - NFS. Ewil.

? - , , . , , , ( ), , . , timebug, IGT . Ewil . , . IGT RTA. , , (!).

. IGT. , - . , - , - . , , No TimeBug.

SpeedyHeart, , float. , !

.


Cheat Engine, OllyDbg, DxWND NFS: MostWanted 1.3, . ( ):


. IGT . float ! Float, , , .
, int ( 2 , ). , , . , , IGT RTA, , , .

, . , .. . , Global IGT Race IGT, . Global IGT , Race IGT . IGT Global IGT, - . - .

:
  1. , ? , IGT ,
  2. ? , .

1 . Global IGT 300000.0 , . (!), . , , -, . , , . . .

2. Global IGT 524288 . , . , , ( Alt+F4). / . , .

Float .


, . , .

, . , 120 ( , SpeedyHeart ). vsync , 60 . , float- 1/60 . , , . . 2 (33) , .

#include 
#include 
#include 
#include 
#include 

#define REPEATS 1000       //  
#define ESCAPE 27          //   ESCAPE
#define TEST_TIME 2        // ,   
#define START_TIME 0       //    

void main( )
{
	time_t t;
	srand( time( &t ) );
	while ( true )
	{
		float diffs[ REPEATS ];
		int   frame_diffs[ REPEATS ];   //  
		for ( int i = 0; i < REPEATS; i++ )
		{
			int limit = rand( ) % TEST_TIME + 1;//   - ,
							 // +1     0
			limit *= 60;			//   
			limit += (START_TIME * 60);	   //   
			float t = 0.0f + (START_TIME*60); //   
			float step = 1.0f / 60.0f;      	   //     60 
			int steps = 0;
			while ( t < limit )
			{
				steps++;
				t += step;
			}

			//       
			double expectation = (double)(limit - START_TIME*60)/ ( 1.0 / 60.0 );
			printf("%f\n", t );
			printf("Difference = %f; steps = %d\n", t - limit, steps );
			printf( "Expected steps = %f; frames dropped = %d\n", 
					expectation, (int)expectation - (int)steps );

			diffs[i] =  fabs( t - limit );
			frame_diffs[ i ] = (int)expectation - (int)steps;
		}

		//    
		float sum = 0;
		int frame_sum = 0;
		for ( int j = 0; j < REPEATS; j++ )
		{
			sum += diffs[ j ];
			frame_sum += frame_diffs[ j ];
		}

		printf( "Avg. time difference = %f, avg. frame difference = %d\n", 
			     sum / REPEATS, frame_sum / REPEATS  );
		//   "any key" ,   "ESCAPE" 
		printf( "Press any key to continue, press esc to quit\n" );
		if ( getch() == ESCAPE )
			break;
	}
}


START_TIME TEST_TIME . , START_TIME 15 , 2- . , 1-2 :
image

16 , :
image

, START_TIME . , , :
image

, , . , 15 . START_TIME 300000 , . START_TIME, 524288 . , .
, 60 . 120 7 . . , , .


.


, , . Global IGT , . Race IGT. .

: NFS: Most Wanted NFS: Most Wanted Black Edition. , 69- . , , ! . , 1.3 . 4 , . . -, , 4 , , , . C#.

image

. GameProcess , - . GameHolder . GameProcess, Game. , .

? . ImageSize. , enum:
enum ProcessSizes
{
    MW13 = 0x00678e4e
}


.

isUnknown , . Refresh, :
        public void Refresh()
        {
            if(!process.IsOpen)
            {
                // In cases when the process is not open, but the game exists
                // The process had either crashed, either was exited on purpose
                if(game != null)
                    Console.WriteLine("Process lost (quit?)");
                game = null;
                return;
            }
            if(isUnknown) // If we couldn't determine game version, do nothing
            {
                return;
            }
            // If process is opened, but the game doesn't exist, we need to create it
            if(process.IsOpen && game == null)
            {
                Console.WriteLine("Opened process, size = 0x{0:X}", process.ImageSize);
                switch((ProcessSizes)process.ImageSize)              // Guessing version
                {
                    case ProcessSizes.MW13:
                        game = new MW.MW13(process);
                        break;
                    default:
                        Console.WriteLine("Unknown game type");
                        isUnknown = false;
                        break;
                }
            }
            // At last, update game
            game.Update();
        }


:
    public abstract class Game
    {
        private float lastTime;
        private GameProcess game;

        /// 
        /// Synch-timer's address
        /// 
        protected int raceIgtAddress;               
        
        /// 
        /// Timer-to-sync address
        /// 
        protected int globalIgtAddress;

        private void ResetTime()
        {
            byte[] data = { 0, 0, 0, 0 };
            game.WriteMemory(globalIgtAddress, data);
        }

        public void Update()
        {
            float tmp = game.ReadFloat(raceIgtAddress);
            if (tmp < lastTime)
            {
                ResetTime();
                Console.WriteLine("Timer reset");
            }
            lastTime = tmp;
        }

        public Game(GameProcess proc)
        {
            game = proc;
            lastTime = -2; // Why not anyway
        }
    }


: , protected-. . , - Nvidia NFS , .
    class Program
    {
        static void Run(object proc)
        {
            GameHolder holder = new GameHolder((string)proc);
            while (true)
            {
                Thread.Sleep(100);
                holder.Refresh();
            }
        }
        static void Main(string[] args)
        {
            Thread t = new Thread(new ParameterizedThreadStart(Run));
            t.Start(args[0]);
            Console.WriteLine("Press any key at any time to close");
            Console.ReadKey();
            t.Abort();
        }
    }


. , , yay! ^_^ .


, . 15 , . , .
.

Summary.


. , Black Box double, . , , / . Timebug Black Box ever since. Carbon, ProStreet Undercover. IGT, , . SpeedyHeart - , -.

? . , float . , . , , .

, ( IGT) : timestamp , . , . 1/60 16,(6) , 0,(6) , .

. , .
Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/333676/

:  

: [1] []
 

:
: 

: ( )

:

  URL