diff options
author | aap <aap@papnet.eu> | 2019-07-06 12:27:21 +0200 |
---|---|---|
committer | aap <aap@papnet.eu> | 2019-07-06 12:27:21 +0200 |
commit | 2b592605ab043be56b5bbbf1ac06f223400dd2ef (patch) | |
tree | 8abe75af453b4726fd858643c92eb160ed113610 /src/SurfaceTable.cpp | |
parent | Merge pull request #113 from erorcun/erorcun (diff) | |
download | re3-2b592605ab043be56b5bbbf1ac06f223400dd2ef.tar re3-2b592605ab043be56b5bbbf1ac06f223400dd2ef.tar.gz re3-2b592605ab043be56b5bbbf1ac06f223400dd2ef.tar.bz2 re3-2b592605ab043be56b5bbbf1ac06f223400dd2ef.tar.lz re3-2b592605ab043be56b5bbbf1ac06f223400dd2ef.tar.xz re3-2b592605ab043be56b5bbbf1ac06f223400dd2ef.tar.zst re3-2b592605ab043be56b5bbbf1ac06f223400dd2ef.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 |