diff options
author | ludde <ludde@openttd.org> | 2005-07-19 11:42:40 +0000 |
---|---|---|
committer | ludde <ludde@openttd.org> | 2005-07-19 11:42:40 +0000 |
commit | 08725cd6dfa1bc06adf3f3909e811e7abef64538 (patch) | |
tree | 4d3f43a36f40b9b8d244fda8f0cdb2bba4bc64ec /win32.c | |
parent | 857a3a1ffce4ac4a150a042e45af9513d516adaf (diff) | |
download | openttd-08725cd6dfa1bc06adf3f3909e811e7abef64538.tar.xz |
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
- Benchmark shows that NTP is now around 10x faster than NPF.
- Made IsTunnelTile macro to determine if a tile is a tunnel.
- Added some useful debugging functions for making tiles red / getting accurate timestamps.
- Remove old depot finding algorithm.
- Disable warning for signed/unsigned comparisons.
Diffstat (limited to 'win32.c')
-rw-r--r-- | win32.c | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -181,6 +181,34 @@ static void ClientSizeChanged(int w, int h) extern void DoExitSave(void); +#ifdef _DEBUG +// Keep this function here.. +// It allows you to redraw the screen from within the MSVC debugger +int RedrawScreenDebug() +{ + HDC dc,dc2; + static int _fooctr; + HBITMAP old_bmp; + HPALETTE old_palette; + + _screen.dst_ptr = _wnd.buffer_bits; + UpdateWindows(); + + dc = GetDC(_wnd.main_wnd); + dc2 = CreateCompatibleDC(dc); + + old_bmp = SelectObject(dc2, _wnd.dib_sect); + old_palette = SelectPalette(dc, _wnd.gdi_palette, FALSE); + BitBlt(dc, 0, 0, _wnd.width, _wnd.height, dc2, 0, 0, SRCCOPY); + SelectPalette(dc, old_palette, TRUE); + SelectObject(dc2, old_bmp); + DeleteDC(dc2); + ReleaseDC(_wnd.main_wnd, dc); + + return _fooctr++; +} +#endif + static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { @@ -2267,3 +2295,18 @@ void CSleep(int milliseconds) { Sleep(milliseconds); } + + +// Utility function to get the current timestamp in milliseconds +// Useful for profiling +int64 GetTS() +{ + static double freq; + __int64 value; + if (!freq) { + QueryPerformanceFrequency((LARGE_INTEGER*)&value); + freq = (double)1000000 / value; + } + QueryPerformanceCounter((LARGE_INTEGER*)&value); + return (__int64)(value * freq); +}
\ No newline at end of file |