station_map.c
author bjarni
Thu, 05 Oct 2006 12:59:28 +0000
changeset 4739 e626ef1b522e
parent 3882 c2e3e12e71d6
permissions -rw-r--r--
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
This gives the ability to invalidate some window data and recalculate as needed instead of doing it for each WE_PAINT

This event is called right away when using InvalidateWindowData(), so it may be a good idea to set a bool or similar in the window
or similar and then act on that bool in WE_PAINT instead of doing a lot of stuff in WE_INVALIDATE_DATA as it might be called more than once before WE_PAINT is called

InvalidateWindowData() will not automatically repaint the window, so if you want to repaint it as well, you need to mark it dirty as well.

Made the depot windows use WE_INVALIDATE_DATA to set when to generate the engine and wagon lists instead of at each redraw
It makes no sense to regenerate the list when say using the scrollbar if we know that no vehicle have entered or left the list

NOTE: currently there is a piece of code to generate the list when it's not needed and compare it to the stored list and assert if they mismatch
This check is somewhat slow and kills the whole idea of WE_INVALIDATE_DATA, so it's a short lived one to verify that InvalidateWindowData() is used everywhere where it's needed
3334
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents:
diff changeset
     1
/* $Id$ */
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents:
diff changeset
     2
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents:
diff changeset
     3
#include "stdafx.h"
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents:
diff changeset
     4
#include "openttd.h"
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents:
diff changeset
     5
#include "station_map.h"
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents:
diff changeset
     6
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents:
diff changeset
     7
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents:
diff changeset
     8
StationType GetStationType(TileIndex t)
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents:
diff changeset
     9
{
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents:
diff changeset
    10
	assert(IsTileType(t, MP_STATION));
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents:
diff changeset
    11
	if (IsRailwayStation(t)) return STATION_RAIL;
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents:
diff changeset
    12
	if (IsAirport(t)) return STATION_AIRPORT;
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents:
diff changeset
    13
	if (IsTruckStop(t)) return STATION_TRUCK;
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents:
diff changeset
    14
	if (IsBusStop(t)) return STATION_BUS;
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents:
diff changeset
    15
	if (IsOilRig(t)) return STATION_OILRIG;
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents:
diff changeset
    16
	if (IsDock(t)) return STATION_DOCK;
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents:
diff changeset
    17
	assert(IsBuoy_(t));
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents:
diff changeset
    18
	return STATION_BUOY;
2999d2ddc0f9 (svn r4113) Moved all relevant map functions for stations to station_map.[ch]
celestar
parents:
diff changeset
    19
}