Files
@ r25014:e1f1bf3a062e
Branch filter:
Location: cpp/openttd-patchpack/source/src/tunnel_map.h - annotation
r25014:e1f1bf3a062e
2.6 KiB
text/x-c
Add: [Video] move GameLoop into its own thread
This allows drawing to happen while the GameLoop is doing an
iteration too.
Sadly, not much drawing currently can be done while the GameLoop
is running, as for example PollEvent() or UpdateWindows() can
influence the game-state. As such, they first need to acquire a
lock on the game-state before they can be called.
Currently, the main advantage is the time spend in Paint(), which
for non-OpenGL drivers can be a few milliseconds. For OpenGL this
is more like 0.05 milliseconds; in these instances this change
doesn't add any benefits for now.
This is an alternative to the former "draw-thread", which moved
the drawing in a thread for some OSes. It has similar performance
gain as this does, although this implementation allows for more
finer control over what suffers when the GameLoop takes too
long: drawing or the next GameLoop. For now they both suffer
equally.
This allows drawing to happen while the GameLoop is doing an
iteration too.
Sadly, not much drawing currently can be done while the GameLoop
is running, as for example PollEvent() or UpdateWindows() can
influence the game-state. As such, they first need to acquire a
lock on the game-state before they can be called.
Currently, the main advantage is the time spend in Paint(), which
for non-OpenGL drivers can be a few milliseconds. For OpenGL this
is more like 0.05 milliseconds; in these instances this change
doesn't add any benefits for now.
This is an alternative to the former "draw-thread", which moved
the drawing in a thread for some OSes. It has similar performance
gain as this does, although this implementation allows for more
finer control over what suffers when the GameLoop takes too
long: drawing or the next GameLoop. For now they both suffer
equally.
r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r9111:983de9c5a848 r6422:5983361e241a r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r24323:0772be16e3f4 r11247:c15ef8b37f5e r5475:3f5cd13d1b63 r8083:8cd2123a0c7c r6540:ee437874694d r6540:ee437874694d r6540:ee437874694d r6540:ee437874694d r6540:ee437874694d r6540:ee437874694d r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r7928:a80e7e05d6c5 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6540:ee437874694d r6540:ee437874694d r6540:ee437874694d r6540:ee437874694d r6540:ee437874694d r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r18321:8dc1c147192c r18321:8dc1c147192c r5475:3f5cd13d1b63 r6540:ee437874694d r6540:ee437874694d r6540:ee437874694d r6540:ee437874694d r6540:ee437874694d r6661:a60bd28b4b57 r6540:ee437874694d r23698:1872cc5b7dd7 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r11247:c15ef8b37f5e r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r21735:dc929fbec3dd r11289:7e06e1b4e52d r22972:1584085035e8 r23698:1872cc5b7dd7 r23698:1872cc5b7dd7 r23698:1872cc5b7dd7 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6540:ee437874694d r6540:ee437874694d r6540:ee437874694d r6540:ee437874694d r6540:ee437874694d r6540:ee437874694d r6540:ee437874694d r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r22972:1584085035e8 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r21735:dc929fbec3dd r11289:7e06e1b4e52d r24323:0772be16e3f4 r24323:0772be16e3f4 r24323:0772be16e3f4 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 | /*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file tunnel_map.h Map accessors for tunnels. */
#ifndef TUNNEL_MAP_H
#define TUNNEL_MAP_H
#include "rail_map.h"
#include "road_map.h"
/**
* Is this a tunnel (entrance)?
* @param t the tile that might be a tunnel
* @pre IsTileType(t, MP_TUNNELBRIDGE)
* @return true if and only if this tile is a tunnel (entrance)
*/
static inline bool IsTunnel(TileIndex t)
{
assert(IsTileType(t, MP_TUNNELBRIDGE));
return !HasBit(_m[t].m5, 7);
}
/**
* Is this a tunnel (entrance)?
* @param t the tile that might be a tunnel
* @return true if and only if this tile is a tunnel (entrance)
*/
static inline bool IsTunnelTile(TileIndex t)
{
return IsTileType(t, MP_TUNNELBRIDGE) && IsTunnel(t);
}
TileIndex GetOtherTunnelEnd(TileIndex);
bool IsTunnelInWay(TileIndex, int z);
bool IsTunnelInWayDir(TileIndex tile, int z, DiagDirection dir);
/**
* Makes a road tunnel entrance
* @param t the entrance of the tunnel
* @param o the owner of the entrance
* @param d the direction facing out of the tunnel
* @param r the road type used in the tunnel
*/
static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadType road_rt, RoadType tram_rt)
{
SetTileType(t, MP_TUNNELBRIDGE);
SetTileOwner(t, o);
_m[t].m2 = 0;
_m[t].m3 = 0;
_m[t].m4 = 0;
_m[t].m5 = TRANSPORT_ROAD << 2 | d;
SB(_me[t].m6, 2, 4, 0);
_me[t].m7 = 0;
_me[t].m8 = 0;
SetRoadOwner(t, RTT_ROAD, o);
if (o != OWNER_TOWN) SetRoadOwner(t, RTT_TRAM, o);
SetRoadTypes(t, road_rt, tram_rt);
}
/**
* Makes a rail tunnel entrance
* @param t the entrance of the tunnel
* @param o the owner of the entrance
* @param d the direction facing out of the tunnel
* @param r the rail type used in the tunnel
*/
static inline void MakeRailTunnel(TileIndex t, Owner o, DiagDirection d, RailType r)
{
SetTileType(t, MP_TUNNELBRIDGE);
SetTileOwner(t, o);
_m[t].m2 = 0;
_m[t].m3 = 0;
_m[t].m4 = 0;
_m[t].m5 = TRANSPORT_RAIL << 2 | d;
SB(_me[t].m6, 2, 4, 0);
_me[t].m7 = 0;
_me[t].m8 = 0;
SetRailType(t, r);
SetRoadTypes(t, INVALID_ROADTYPE, INVALID_ROADTYPE);
}
#endif /* TUNNEL_MAP_H */
|