(svn r10111) -Codechange: Add new vehicle hash table for collision detection and finding vehicles on a tile. The hash area scanned is far smaller than the old hash table, which is now used for viewport updates only. This should give a significant performance improvement for games with many vehicles. (Based on work by 'B. N. SmatZ!' and 'madman2003')

This commit is contained in:
peter1138
2007-06-12 11:22:32 +00:00
parent e5ea54fe22
commit ce590b59f3
4 changed files with 119 additions and 32 deletions

View File

@@ -709,7 +709,7 @@ static void RoadVehCheckTrainCrash(Vehicle *v)
if (!IsLevelCrossingTile(tile)) continue;
if (VehicleFromPos(tile, u, EnumCheckRoadVehCrashTrain) != NULL) {
if (VehicleFromPosXY(v->x_pos, v->y_pos, u, EnumCheckRoadVehCrashTrain) != NULL) {
RoadVehCrash(v);
return;
}
@@ -889,7 +889,7 @@ static Vehicle* RoadVehFindCloseTo(Vehicle* v, int x, int y, Direction dir)
rvf.y = y;
rvf.dir = dir;
rvf.veh = v;
u = (Vehicle*)VehicleFromPos(TileVirtXY(x, y), &rvf, EnumCheckRoadVehClose);
u = (Vehicle*)VehicleFromPosXY(x, y, &rvf, EnumCheckRoadVehClose);
/* This code protects a roadvehicle from being blocked for ever
* If more than 1480 / 74 days a road vehicle is blocked, it will