2019-05-15 14:52:37 +00:00
|
|
|
#include "common.h"
|
2020-04-17 13:31:11 +00:00
|
|
|
|
2019-07-06 10:27:21 +00:00
|
|
|
#include "main.h"
|
|
|
|
#include "FileMgr.h"
|
2019-05-18 10:39:39 +00:00
|
|
|
#include "Weather.h"
|
|
|
|
#include "Collision.h"
|
2019-05-15 14:52:37 +00:00
|
|
|
#include "SurfaceTable.h"
|
|
|
|
|
2020-04-17 05:54:14 +00:00
|
|
|
float CSurfaceTable::ms_aAdhesiveLimitTable[NUMADHESIVEGROUPS][NUMADHESIVEGROUPS];
|
2019-05-18 10:39:39 +00:00
|
|
|
|
2019-07-06 10:27:21 +00:00
|
|
|
void
|
2020-05-11 23:24:57 +00:00
|
|
|
CSurfaceTable::Initialise(Const char *filename)
|
2019-07-06 10:27:21 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-15 14:52:37 +00:00
|
|
|
int
|
|
|
|
CSurfaceTable::GetAdhesionGroup(uint8 surfaceType)
|
|
|
|
{
|
|
|
|
switch(surfaceType){
|
2020-05-22 12:27:16 +00:00
|
|
|
case SURFACE_DEFAULT: return ADHESIVE_ROAD;
|
|
|
|
case SURFACE_TARMAC: return ADHESIVE_ROAD;
|
|
|
|
case SURFACE_GRASS: return ADHESIVE_LOOSE;
|
2020-05-26 09:34:20 +00:00
|
|
|
case SURFACE_GRAVEL: return ADHESIVE_LOOSE;
|
|
|
|
case SURFACE_MUD_DRY: return ADHESIVE_HARD;
|
2020-05-22 12:27:16 +00:00
|
|
|
case SURFACE_PAVEMENT: return ADHESIVE_ROAD;
|
2020-05-26 09:34:20 +00:00
|
|
|
case SURFACE_CAR: return ADHESIVE_HARD;
|
2020-05-22 12:27:16 +00:00
|
|
|
case SURFACE_GLASS: return ADHESIVE_HARD;
|
2020-05-26 09:34:20 +00:00
|
|
|
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;
|
2020-05-22 12:27:16 +00:00
|
|
|
case SURFACE_SAND: return ADHESIVE_SAND;
|
2020-05-26 09:34:20 +00:00
|
|
|
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;
|
2020-05-22 12:27:16 +00:00
|
|
|
case SURFACE_HEDGE: return ADHESIVE_LOOSE;
|
2020-05-26 09:34:20 +00:00
|
|
|
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;
|
|
|
|
case SURFACE_SAND_BEACH: return ADHESIVE_SAND;
|
|
|
|
case SURFACE_CONCRETE_BEACH: return ADHESIVE_ROAD;
|
2020-05-22 12:27:16 +00:00
|
|
|
default: return ADHESIVE_ROAD;
|
2019-05-15 14:52:37 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-18 10:39:39 +00:00
|
|
|
|
|
|
|
float
|
|
|
|
CSurfaceTable::GetWetMultiplier(uint8 surfaceType)
|
|
|
|
{
|
|
|
|
switch(surfaceType){
|
2020-05-22 12:27:16 +00:00
|
|
|
case SURFACE_DEFAULT:
|
|
|
|
case SURFACE_TARMAC:
|
2020-05-26 09:34:20 +00:00
|
|
|
case SURFACE_MUD_DRY:
|
2020-05-22 12:27:16 +00:00
|
|
|
case SURFACE_PAVEMENT:
|
2020-05-26 09:34:20 +00:00
|
|
|
case SURFACE_TRANSPARENT_CLOTH:
|
|
|
|
case SURFACE_WOOD_CRATES:
|
|
|
|
case SURFACE_WOOD_BENCH:
|
|
|
|
case SURFACE_WOOD_SOLID:
|
2020-05-22 12:27:16 +00:00
|
|
|
case SURFACE_HEDGE:
|
2020-05-26 09:34:20 +00:00
|
|
|
case SURFACE_CARDBOARDBOX:
|
|
|
|
case SURFACE_TRANSPARENT_STONE:
|
|
|
|
case SURFACE_CONCRETE_BEACH:
|
2019-05-18 10:39:39 +00:00
|
|
|
return 1.0f - CWeather::WetRoads*0.25f;
|
|
|
|
|
2020-05-22 12:27:16 +00:00
|
|
|
case SURFACE_GRASS:
|
2020-05-26 09:34:20 +00:00
|
|
|
case SURFACE_CAR:
|
2020-05-22 12:27:16 +00:00
|
|
|
case SURFACE_GLASS:
|
2020-05-26 09:34:20 +00:00
|
|
|
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:
|
2019-05-18 10:39:39 +00:00
|
|
|
return 1.0f - CWeather::WetRoads*0.4f;
|
|
|
|
|
2020-05-22 12:27:16 +00:00
|
|
|
case SURFACE_SAND:
|
2020-05-26 09:34:20 +00:00
|
|
|
case SURFACE_SAND_BEACH:
|
2021-01-05 15:53:00 +00:00
|
|
|
return 1.0f + CWeather::WetRoads*0.5f;
|
2020-05-22 12:27:16 +00:00
|
|
|
|
2019-05-18 10:39:39 +00:00
|
|
|
default:
|
|
|
|
return 1.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
float
|
|
|
|
CSurfaceTable::GetAdhesiveLimit(CColPoint &colpoint)
|
|
|
|
{
|
|
|
|
return ms_aAdhesiveLimitTable[GetAdhesionGroup(colpoint.surfaceB)][GetAdhesionGroup(colpoint.surfaceA)];
|
|
|
|
}
|
2020-08-19 19:58:00 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
CSurfaceTable::IsSoftLanding(uint8 surf)
|
|
|
|
{
|
|
|
|
return surf == SURFACE_GRASS || surf == SURFACE_SAND || surf == SURFACE_SAND_BEACH;
|
|
|
|
}
|