blob: b1bcceb61e534a63a273241f7ad64179cbc03d32 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
#include "common.h"
#include "main.h"
#include "FileMgr.h"
#include "Weather.h"
#include "Collision.h"
#include "SurfaceTable.h"
float CSurfaceTable::ms_aAdhesiveLimitTable[NUMADHESIVEGROUPS][NUMADHESIVEGROUPS];
void
CSurfaceTable::Initialise(Const char *filename)
{
int lineno, fieldno;
char *line;
char surfname[256];
float adhesiveLimit;
CFileMgr::SetDir("");
CFileMgr::LoadFile(filename, work_buff, sizeof(work_buff), "r");
line = (char*)work_buff;
for(lineno = 0; lineno < NUMADHESIVEGROUPS; lineno++){
// skip white space and comments
while(*line == ' ' || *line == '\t' || *line == '\n' || *line == '\r' || *line == ';'){
if(*line == ';'){
while(*line != '\n' && *line != '\r')
line++;
}else
line++;
}
sscanf(line, "%s", surfname);
// skip what we just read
while(!(*line == ' ' || *line == '\t' || *line == ','))
line++;
for(fieldno = 0; fieldno <= lineno; fieldno++){
// skip white space
while(*line == ' ' || *line == '\t' || *line == ',')
line++;
adhesiveLimit = 0.0f;
if(*line != '-')
sscanf(line, "%f", &adhesiveLimit);
// skip what we just read
while(!(*line == ' ' || *line == '\t' || *line == ',' || *line == '\n'))
line++;
ms_aAdhesiveLimitTable[lineno][fieldno] = adhesiveLimit;
ms_aAdhesiveLimitTable[fieldno][lineno] = adhesiveLimit;
}
}
}
int
CSurfaceTable::GetAdhesionGroup(uint8 surfaceType)
{
switch(surfaceType){
case SURFACE_DEFAULT: return ADHESIVE_ROAD;
case SURFACE_TARMAC: return ADHESIVE_ROAD;
case SURFACE_GRASS: return ADHESIVE_LOOSE;
case SURFACE_GRAVEL: return ADHESIVE_LOOSE;
case SURFACE_MUD_DRY: return ADHESIVE_HARD;
case SURFACE_PAVEMENT: return ADHESIVE_ROAD;
case SURFACE_CAR: return ADHESIVE_HARD;
case SURFACE_GLASS: return ADHESIVE_HARD;
case SURFACE_TRANSPARENT_CLOTH: return ADHESIVE_HARD;
case SURFACE_GARAGE_DOOR: return ADHESIVE_HARD;
case SURFACE_CAR_PANEL: return ADHESIVE_HARD;
case SURFACE_THICK_METAL_PLATE: return ADHESIVE_HARD;
case SURFACE_SCAFFOLD_POLE: return ADHESIVE_HARD;
case SURFACE_LAMP_POST: return ADHESIVE_HARD;
case SURFACE_FIRE_HYDRANT: return ADHESIVE_HARD;
case SURFACE_GIRDER: return ADHESIVE_HARD;
case SURFACE_METAL_CHAIN_FENCE: return ADHESIVE_HARD;
case SURFACE_PED: return ADHESIVE_RUBBER;
case SURFACE_SAND: return ADHESIVE_LOOSE;
case SURFACE_WATER: return ADHESIVE_WET;
case SURFACE_WOOD_CRATES: return ADHESIVE_ROAD;
case SURFACE_WOOD_BENCH: return ADHESIVE_ROAD;
case SURFACE_WOOD_SOLID: return ADHESIVE_ROAD;
case SURFACE_RUBBER: return ADHESIVE_RUBBER;
case SURFACE_PLASTIC: return ADHESIVE_HARD;
case SURFACE_HEDGE: return ADHESIVE_LOOSE;
case SURFACE_STEEP_CLIFF: return ADHESIVE_LOOSE;
case SURFACE_CONTAINER: return ADHESIVE_HARD;
case SURFACE_NEWS_VENDOR: return ADHESIVE_HARD;
case SURFACE_WHEELBASE: return ADHESIVE_RUBBER;
case SURFACE_CARDBOARDBOX: return ADHESIVE_LOOSE;
case SURFACE_TRANSPARENT_STONE: return ADHESIVE_HARD;
case SURFACE_METAL_GATE: return ADHESIVE_HARD;
default: return ADHESIVE_ROAD;
}
}
float
CSurfaceTable::GetWetMultiplier(uint8 surfaceType)
{
switch(surfaceType){
case SURFACE_DEFAULT:
case SURFACE_TARMAC:
case SURFACE_MUD_DRY:
case SURFACE_PAVEMENT:
case SURFACE_TRANSPARENT_CLOTH:
case SURFACE_WOOD_CRATES:
case SURFACE_WOOD_BENCH:
case SURFACE_WOOD_SOLID:
case SURFACE_HEDGE:
case SURFACE_CARDBOARDBOX:
case SURFACE_TRANSPARENT_STONE:
return 1.0f - CWeather::WetRoads*0.25f;
case SURFACE_GRASS:
case SURFACE_CAR:
case SURFACE_GLASS:
case SURFACE_GARAGE_DOOR:
case SURFACE_CAR_PANEL:
case SURFACE_THICK_METAL_PLATE:
case SURFACE_SCAFFOLD_POLE:
case SURFACE_LAMP_POST:
case SURFACE_FIRE_HYDRANT:
case SURFACE_GIRDER:
case SURFACE_METAL_CHAIN_FENCE:
case SURFACE_PED:
case SURFACE_RUBBER:
case SURFACE_PLASTIC:
case SURFACE_STEEP_CLIFF:
case SURFACE_CONTAINER:
case SURFACE_NEWS_VENDOR:
case SURFACE_WHEELBASE:
case SURFACE_METAL_GATE:
return 1.0f - CWeather::WetRoads*0.4f;
default:
return 1.0f;
}
}
float
CSurfaceTable::GetAdhesiveLimit(CColPoint &colpoint)
{
return ms_aAdhesiveLimitTable[GetAdhesionGroup(colpoint.surfaceB)][GetAdhesionGroup(colpoint.surfaceA)];
}
|