diff options
author | eray orçunus <erayorcunus@gmail.com> | 2019-07-07 00:36:39 +0200 |
---|---|---|
committer | eray orçunus <erayorcunus@gmail.com> | 2019-07-07 00:39:58 +0200 |
commit | ee8e16376b4d0fcb199762274946c16b8f42c04f (patch) | |
tree | 0aec680fb9460225c18231d26d78b75f522c2592 /src/SurfaceTable.cpp | |
parent | General fixes (diff) | |
parent | some work on vehicles (diff) | |
download | re3-ee8e16376b4d0fcb199762274946c16b8f42c04f.tar re3-ee8e16376b4d0fcb199762274946c16b8f42c04f.tar.gz re3-ee8e16376b4d0fcb199762274946c16b8f42c04f.tar.bz2 re3-ee8e16376b4d0fcb199762274946c16b8f42c04f.tar.lz re3-ee8e16376b4d0fcb199762274946c16b8f42c04f.tar.xz re3-ee8e16376b4d0fcb199762274946c16b8f42c04f.tar.zst re3-ee8e16376b4d0fcb199762274946c16b8f42c04f.zip |
Diffstat (limited to 'src/SurfaceTable.cpp')
-rw-r--r-- | src/SurfaceTable.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/SurfaceTable.cpp b/src/SurfaceTable.cpp index 107734e4..2ba884b1 100644 --- a/src/SurfaceTable.cpp +++ b/src/SurfaceTable.cpp @@ -1,11 +1,57 @@ #include "common.h" #include "patcher.h" +#include "main.h" +#include "FileMgr.h" #include "Weather.h" #include "Collision.h" #include "SurfaceTable.h" float (*CSurfaceTable::ms_aAdhesiveLimitTable)[NUMADHESIVEGROUPS] = (float (*)[NUMADHESIVEGROUPS])0x8E29D4; +void +CSurfaceTable::Initialise(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) { @@ -95,3 +141,10 @@ CSurfaceTable::GetAdhesiveLimit(CColPoint &colpoint) { return ms_aAdhesiveLimitTable[GetAdhesionGroup(colpoint.surfaceB)][GetAdhesionGroup(colpoint.surfaceA)]; } + +STARTPATCHES + InjectHook(0x4AB8F0, CSurfaceTable::Initialise, PATCH_JUMP); + InjectHook(0x4ABA60, CSurfaceTable::GetAdhesionGroup, PATCH_JUMP); + InjectHook(0x4ABAA0, CSurfaceTable::GetWetMultiplier, PATCH_JUMP); + InjectHook(0x4ABA30, CSurfaceTable::GetAdhesiveLimit, PATCH_JUMP); +ENDPATCHES |