summaryrefslogtreecommitdiff
path: root/win32.c
diff options
context:
space:
mode:
authorludde <ludde@openttd.org>2005-07-19 11:42:40 +0000
committerludde <ludde@openttd.org>2005-07-19 11:42:40 +0000
commit3e97dda275f59b2bcaea44c48ceba7a0ed054d9c (patch)
tree4d3f43a36f40b9b8d244fda8f0cdb2bba4bc64ec /win32.c
parent29f6ada06a0cbf3954e9c5f61657d4ed763cee79 (diff)
downloadopenttd-3e97dda275f59b2bcaea44c48ceba7a0ed054d9c.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.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/win32.c b/win32.c
index 9fb8ca0a5..72a94b158 100644
--- a/win32.c
+++ b/win32.c
@@ -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