(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.
This commit is contained in:
ludde
2005-07-19 11:42:40 +00:00
parent 857a3a1ffc
commit 08725cd6df
13 changed files with 340 additions and 286 deletions

43
win32.c
View File

@@ -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);
}