├── premake5.bat ├── premake5.exe ├── premake5.lua └── src ├── ColourSet.cpp ├── ColourSet.h ├── MemoryMgr.h ├── TimeCycle.cpp ├── TimeCycle.h ├── gta.cpp ├── gta.h └── main.cpp /premake5.bat: -------------------------------------------------------------------------------- 1 | premake5 vs2015 -------------------------------------------------------------------------------- /premake5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GTAmodding/timecycle24/7d23d11c65c64e3e182b6b957c5d8d76804d0e87/premake5.exe -------------------------------------------------------------------------------- /premake5.lua: -------------------------------------------------------------------------------- 1 | workspace "timecycle24" 2 | configurations { "Release", "Debug" } 3 | location "build" 4 | 5 | files { "src/*.*" } 6 | 7 | includedirs { "src" } 8 | includedirs { os.getenv("RWSDK36") } 9 | 10 | project "timecycle24" 11 | kind "SharedLib" 12 | language "C++" 13 | targetdir "bin/%{cfg.buildcfg}" 14 | targetextension ".asi" 15 | characterset ("MBCS") 16 | 17 | filter "configurations:Debug" 18 | defines { "DEBUG" } 19 | symbols "On" 20 | debugdir "C:/Users/aap/games/gtasa" 21 | debugcommand "C:/Users/aap/games/gtasa/gta_sa.exe" 22 | postbuildcommands "copy /y \"$(TargetPath)\" \"C:\\Users\\aap\\games\\gtasa\\scripts\\timecycle24.asi\"" 23 | 24 | 25 | filter "configurations:Release" 26 | defines { "NDEBUG" } 27 | optimize "On" 28 | flags { "StaticRuntime" } 29 | debugdir "C:/Users/aap/games/gtasa" 30 | debugcommand "C:/Users/aap/games/gtasa/gta_sa.exe" 31 | postbuildcommands "copy /y \"$(TargetPath)\" \"C:\\Users\\aap\\games\\gtasa\\scripts\\timecycle24.asi\"" 32 | -------------------------------------------------------------------------------- /src/ColourSet.cpp: -------------------------------------------------------------------------------- 1 | #include "gta.h" 2 | 3 | void 4 | CColourSet::ctor(int h, int w) 5 | { 6 | this->ambr = CTimeCycle::m_nAmbientRed[h][w]; 7 | this->ambg = CTimeCycle::m_nAmbientGreen[h][w]; 8 | this->ambb = CTimeCycle::m_nAmbientBlue[h][w]; 9 | this->ambobjr = CTimeCycle::m_nAmbientRed_Obj[h][w]; 10 | this->ambobjg = CTimeCycle::m_nAmbientGreen_Obj[h][w]; 11 | this->ambobjb = CTimeCycle::m_nAmbientBlue_Obj[h][w]; 12 | this->skytopr = CTimeCycle::m_nSkyTopRed[h][w]; 13 | this->skytopg = CTimeCycle::m_nSkyTopGreen[h][w]; 14 | this->skytopb = CTimeCycle::m_nSkyTopBlue[h][w]; 15 | this->skybotr = CTimeCycle::m_nSkyBottomRed[h][w]; 16 | this->skybotg = CTimeCycle::m_nSkyBottomGreen[h][w]; 17 | this->skybotb = CTimeCycle::m_nSkyBottomBlue[h][w]; 18 | this->suncorer = CTimeCycle::m_nSunCoreRed[h][w]; 19 | this->suncoreg = CTimeCycle::m_nSunCoreGreen[h][w]; 20 | this->suncoreb = CTimeCycle::m_nSunCoreBlue[h][w]; 21 | this->suncoronar = CTimeCycle::m_nSunCoronaRed[h][w]; 22 | this->suncoronag = CTimeCycle::m_nSunCoronaGreen[h][w]; 23 | this->suncoronab = CTimeCycle::m_nSunCoronaBlue[h][w]; 24 | this->sunsz = CTimeCycle::m_fSunSize[h][w]; 25 | this->sprsz = CTimeCycle::m_fSpriteSize[h][w]; 26 | this->sprbght = CTimeCycle::m_fSpriteBrightness[h][w]; 27 | this->shd = CTimeCycle::m_nShadowStrength[h][w]; 28 | this->lightshd = CTimeCycle::m_nLightShadowStrength[h][w]; 29 | this->poleshd = CTimeCycle::m_nPoleShadowStrength[h][w]; 30 | this->farclp = CTimeCycle::m_fFarClip[h][w]; 31 | this->fogst = CTimeCycle::m_fFogStart[h][w]; 32 | this->lightonground = CTimeCycle::m_fLightsOnGroundBrightness[h][w]; 33 | this->lowcloudr = CTimeCycle::m_nLowCloudsRed[h][w]; 34 | this->lowcloudg = CTimeCycle::m_nLowCloudsGreen[h][w]; 35 | this->lowcloudb = CTimeCycle::m_nLowCloudsBlue[h][w]; 36 | this->fluffycloudr = CTimeCycle::m_nFluffyCloudsBottomRed[h][w]; 37 | this->fluffycloudg = CTimeCycle::m_nFluffyCloudsBottomGreen[h][w]; 38 | this->fluffycloudb = CTimeCycle::m_nFluffyCloudsBottomBlue[h][w]; 39 | this->waterr = CTimeCycle::m_fWaterRed[h][w]; 40 | this->waterg = CTimeCycle::m_fWaterGreen[h][w]; 41 | this->waterb = CTimeCycle::m_fWaterBlue[h][w]; 42 | this->watera = CTimeCycle::m_fWaterAlpha[h][w]; 43 | this->postfx1r = CTimeCycle::m_fPostFx1Red[h][w]; 44 | this->postfx1g = CTimeCycle::m_fPostFx1Green[h][w]; 45 | this->postfx1b = CTimeCycle::m_fPostFx1Blue[h][w]; 46 | this->postfx1a = CTimeCycle::m_fPostFx1Alpha[h][w]; 47 | this->postfx2r = CTimeCycle::m_fPostFx2Red[h][w]; 48 | this->postfx2g = CTimeCycle::m_fPostFx2Green[h][w]; 49 | this->postfx2b = CTimeCycle::m_fPostFx2Blue[h][w]; 50 | this->postfx2a = CTimeCycle::m_fPostFx2Alpha[h][w]; 51 | this->cloudalpha = CTimeCycle::m_fCloudAlpha[h][w]; 52 | this->intensityLimit = CTimeCycle::m_nHighLightMinIntensity[h][w]; 53 | this->waterfogalpha = CTimeCycle::m_nWaterFogAlpha[h][w]; 54 | this->lodDistMult = 1.0f; 55 | this->directionalmult = CTimeCycle::m_nDirectionalMult[h][w] / 100.0f; 56 | } 57 | 58 | void 59 | CColourSet::Interpolate(CColourSet *a, CColourSet *b, float fa, float fb, bool ignoreSky) 60 | { 61 | if(!ignoreSky){ 62 | this->skytopr = a->skytopr * fa + b->skytopr * fb; 63 | this->skytopg = a->skytopg * fa + b->skytopg * fb; 64 | this->skytopb = a->skytopb * fa + b->skytopb * fb; 65 | this->skybotr = a->skybotr * fa + b->skybotr * fb; 66 | this->skybotg = a->skybotg * fa + b->skybotg * fb; 67 | this->skybotb = a->skybotb * fa + b->skybotb * fb; 68 | this->suncorer = a->suncorer * fa + b->suncorer * fb; 69 | this->suncoreg = a->suncoreg * fa + b->suncoreg * fb; 70 | this->suncoreb = a->suncoreb * fa + b->suncoreb * fb; 71 | this->suncoronar = a->suncoronar * fa + b->suncoronar * fb; 72 | this->suncoronag = a->suncoronag * fa + b->suncoronag * fb; 73 | this->suncoronab = a->suncoronab * fa + b->suncoronab * fb; 74 | this->sunsz = fa * a->sunsz + fb * b->sunsz; 75 | this->lowcloudr = a->lowcloudr * fa + b->lowcloudr * fb; 76 | this->lowcloudg = a->lowcloudg * fa + b->lowcloudg * fb; 77 | this->lowcloudb = a->lowcloudb * fa + b->lowcloudb * fb; 78 | this->fluffycloudr = a->fluffycloudr * fa + b->fluffycloudr * fb; 79 | this->fluffycloudg = a->fluffycloudg * fa + b->fluffycloudg * fb; 80 | this->fluffycloudb = a->fluffycloudb * fa + b->fluffycloudb * fb; 81 | } 82 | this->ambr = fa * a->ambr + fb * b->ambr; 83 | this->ambg = fa * a->ambg + fb * b->ambg; 84 | this->ambb = fa * a->ambb + fb * b->ambb; 85 | this->ambobjr = fa * a->ambobjr + fb * b->ambobjr; 86 | this->ambobjg = fa * a->ambobjg + fb * b->ambobjg; 87 | this->ambobjb = fa * a->ambobjb + fb * b->ambobjb; 88 | this->sprsz = fa * a->sprsz + fb * b->sprsz; 89 | this->sprbght = fa * a->sprbght + fb * b->sprbght; 90 | this->shd = a->shd * fa + b->shd * fb; 91 | this->lightshd = a->lightshd * fa + b->lightshd * fb; 92 | this->poleshd = a->poleshd * fa + b->poleshd * fb; 93 | this->farclp = fa * a->farclp + fb * b->farclp; 94 | this->fogst = fa * a->fogst + fb * b->fogst; 95 | this->postfx1r = fa * a->postfx1r + fb * b->postfx1r; 96 | this->postfx1g = fa * a->postfx1g + fb * b->postfx1g; 97 | this->postfx1b = fa * a->postfx1b + fb * b->postfx1b; 98 | this->postfx1a = fa * a->postfx1a + fb * b->postfx1a; 99 | this->postfx2r = fa * a->postfx2r + fb * b->postfx2r; 100 | this->postfx2g = fa * a->postfx2g + fb * b->postfx2g; 101 | this->postfx2b = fa * a->postfx2b + fb * b->postfx2b; 102 | this->postfx2a = fa * a->postfx2a + fb * b->postfx2a; 103 | this->lightonground = fa * a->lightonground + fb * b->lightonground; 104 | this->cloudalpha = fa * a->cloudalpha + fb * b->cloudalpha; 105 | this->intensityLimit = a->intensityLimit * fa + b->intensityLimit * fb; 106 | this->waterfogalpha = a->waterfogalpha * fa + b->waterfogalpha * fb; 107 | this->directionalmult = fa * a->directionalmult + fb * b->directionalmult; 108 | this->lodDistMult = fa * a->lodDistMult + fb * b->lodDistMult; 109 | this->waterr = fa * a->waterr + fb * b->waterr; 110 | this->waterg = fa * a->waterg + fb * b->waterg; 111 | this->waterb = fa * a->waterb + fb * b->waterb; 112 | this->watera = fa * a->watera + fb * b->watera; 113 | } 114 | -------------------------------------------------------------------------------- /src/ColourSet.h: -------------------------------------------------------------------------------- 1 | struct CColourSet 2 | { 3 | float ambr; 4 | float ambg; 5 | float ambb; 6 | float ambobjr; 7 | float ambobjg; 8 | float ambobjb; 9 | float ambBeforeBrightnessr; 10 | float ambBeforeBrightnessg; 11 | float ambBeforeBrightnessb; 12 | short skytopr; 13 | short skytopg; 14 | short skytopb; 15 | short skybotr; 16 | short skybotg; 17 | short skybotb; 18 | short suncorer; 19 | short suncoreg; 20 | short suncoreb; 21 | short suncoronar; 22 | short suncoronag; 23 | short suncoronab; 24 | float sunsz; 25 | float sprsz; 26 | float sprbght; 27 | short shd; 28 | short lightshd; 29 | short poleshd; 30 | float farclp; 31 | float fogst; 32 | float lightonground; 33 | short lowcloudr; 34 | short lowcloudg; 35 | short lowcloudb; 36 | short fluffycloudr; 37 | short fluffycloudg; 38 | short fluffycloudb; 39 | float waterr; 40 | float waterg; 41 | float waterb; 42 | float watera; 43 | float postfx1r; 44 | float postfx1g; 45 | float postfx1b; 46 | float postfx1a; 47 | float postfx2r; 48 | float postfx2g; 49 | float postfx2b; 50 | float postfx2a; 51 | float cloudalpha; 52 | int intensityLimit; 53 | short waterfogalpha; 54 | float directionalmult; 55 | float lodDistMult; 56 | 57 | void ctor(int h, int w); 58 | CColourSet(void) {} 59 | CColourSet(int h, int w) { ctor(h, w); } 60 | void Interpolate(CColourSet *a, CColourSet *b, float fa, float fb, bool ignoreSky); 61 | }; 62 | -------------------------------------------------------------------------------- /src/MemoryMgr.h: -------------------------------------------------------------------------------- 1 | #ifndef __MEMORYMGR 2 | #define __MEMORYMGR 3 | 4 | #define WRAPPER __declspec(naked) 5 | #define DEPRECATED __declspec(deprecated) 6 | #define EAXJMP(a) { _asm mov eax, a _asm jmp eax } 7 | #define VARJMP(a) { _asm jmp a } 8 | #define WRAPARG(a) UNREFERENCED_PARAMETER(a) 9 | 10 | #define NOVMT __declspec(novtable) 11 | #define SETVMT(a) *((DWORD_PTR*)this) = (DWORD_PTR)a 12 | 13 | enum 14 | { 15 | PATCH_CALL, 16 | PATCH_JUMP, 17 | PATCH_NOTHING, 18 | }; 19 | 20 | template 21 | inline AT DynBaseAddress(AT address) 22 | { 23 | return (AT)GetModuleHandle(nullptr) - 0x400000 + address; 24 | } 25 | 26 | #define PTRFROMCALL(addr) (uint32_t)(*(uint32_t*)((uint32_t)addr+1) + (uint32_t)addr + 5) 27 | #define INTERCEPT(saved, func, a) \ 28 | { \ 29 | saved = PTRFROMCALL(a); \ 30 | InjectHook(a, func); \ 31 | } 32 | 33 | template 34 | inline void Patch(AT address, T value) 35 | { 36 | DWORD dwProtect[2]; 37 | VirtualProtect((void*)address, sizeof(T), PAGE_EXECUTE_READWRITE, &dwProtect[0]); 38 | *(T*)address = value; 39 | VirtualProtect((void*)address, sizeof(T), dwProtect[0], &dwProtect[1]); 40 | } 41 | 42 | template 43 | inline void Nop(AT address, unsigned int nCount) 44 | { 45 | DWORD dwProtect[2]; 46 | VirtualProtect((void*)address, nCount, PAGE_EXECUTE_READWRITE, &dwProtect[0]); 47 | memset((void*)address, 0x90, nCount); 48 | VirtualProtect((void*)address, nCount, dwProtect[0], &dwProtect[1]); 49 | } 50 | 51 | template 52 | inline void InjectHook(AT address, HT hook, unsigned int nType=PATCH_NOTHING) 53 | { 54 | DWORD dwProtect[2]; 55 | switch ( nType ) 56 | { 57 | case PATCH_JUMP: 58 | VirtualProtect((void*)address, 5, PAGE_EXECUTE_READWRITE, &dwProtect[0]); 59 | *(BYTE*)address = 0xE9; 60 | break; 61 | case PATCH_CALL: 62 | VirtualProtect((void*)address, 5, PAGE_EXECUTE_READWRITE, &dwProtect[0]); 63 | *(BYTE*)address = 0xE8; 64 | break; 65 | default: 66 | VirtualProtect((void*)((DWORD)address + 1), 4, PAGE_EXECUTE_READWRITE, &dwProtect[0]); 67 | break; 68 | } 69 | DWORD dwHook; 70 | _asm 71 | { 72 | mov eax, hook 73 | mov dwHook, eax 74 | } 75 | 76 | *(ptrdiff_t*)((DWORD)address + 1) = (DWORD)dwHook - (DWORD)address - 5; 77 | if ( nType == PATCH_NOTHING ) 78 | VirtualProtect((void*)((DWORD)address + 1), 4, dwProtect[0], &dwProtect[1]); 79 | else 80 | VirtualProtect((void*)address, 5, dwProtect[0], &dwProtect[1]); 81 | } 82 | inline void ExtractCall(void *dst, uintptr_t a) 83 | { 84 | *(uintptr_t*)dst = (uintptr_t)(*(uintptr_t*)(a + 1) + a + 5); 85 | } 86 | template 87 | inline void InterceptCall(void *dst, T func, uintptr_t a) 88 | { 89 | ExtractCall(dst, a); 90 | InjectHook(a, func); 91 | } 92 | template 93 | inline void InterceptVmethod(void *dst, T func, uintptr_t a) 94 | { 95 | *(uintptr_t*)dst = *(uintptr_t*)a; 96 | Patch(a, func); 97 | } 98 | 99 | #endif -------------------------------------------------------------------------------- /src/TimeCycle.cpp: -------------------------------------------------------------------------------- 1 | #include "gta.h" 2 | 3 | uchar CTimeCycle::m_nDirectionalMult[NUMHOURS][NUMWEATHERS]; 4 | uchar CTimeCycle::m_nWaterFogAlpha[NUMHOURS][NUMWEATHERS]; 5 | uchar CTimeCycle::m_nHighLightMinIntensity[NUMHOURS][NUMWEATHERS]; 6 | uchar CTimeCycle::m_fCloudAlpha[NUMHOURS][NUMWEATHERS]; 7 | uchar CTimeCycle::m_fPostFx2Alpha[NUMHOURS][NUMWEATHERS]; 8 | uchar CTimeCycle::m_fPostFx2Blue[NUMHOURS][NUMWEATHERS]; 9 | uchar CTimeCycle::m_fPostFx2Green[NUMHOURS][NUMWEATHERS]; 10 | uchar CTimeCycle::m_fPostFx2Red[NUMHOURS][NUMWEATHERS]; 11 | uchar CTimeCycle::m_fPostFx1Alpha[NUMHOURS][NUMWEATHERS]; 12 | uchar CTimeCycle::m_fPostFx1Blue[NUMHOURS][NUMWEATHERS]; 13 | uchar CTimeCycle::m_fPostFx1Green[NUMHOURS][NUMWEATHERS]; 14 | uchar CTimeCycle::m_fPostFx1Red[NUMHOURS][NUMWEATHERS]; 15 | uchar CTimeCycle::m_fWaterAlpha[NUMHOURS][NUMWEATHERS]; 16 | uchar CTimeCycle::m_fWaterBlue[NUMHOURS][NUMWEATHERS]; 17 | uchar CTimeCycle::m_fWaterGreen[NUMHOURS][NUMWEATHERS]; 18 | uchar CTimeCycle::m_fWaterRed[NUMHOURS][NUMWEATHERS]; 19 | uchar CTimeCycle::m_nFluffyCloudsBottomRed[NUMHOURS][NUMWEATHERS]; 20 | uchar CTimeCycle::m_nFluffyCloudsBottomGreen[NUMHOURS][NUMWEATHERS]; 21 | uchar CTimeCycle::m_nFluffyCloudsBottomBlue[NUMHOURS][NUMWEATHERS]; 22 | uchar CTimeCycle::m_nLowCloudsBlue[NUMHOURS][NUMWEATHERS]; 23 | uchar CTimeCycle::m_nLowCloudsGreen[NUMHOURS][NUMWEATHERS]; 24 | uchar CTimeCycle::m_nLowCloudsRed[NUMHOURS][NUMWEATHERS]; 25 | uchar CTimeCycle::m_fLightsOnGroundBrightness[NUMHOURS][NUMWEATHERS]; 26 | short CTimeCycle::m_fFogStart[NUMHOURS][NUMWEATHERS]; 27 | short CTimeCycle::m_fFarClip[NUMHOURS][NUMWEATHERS]; 28 | uchar CTimeCycle::m_nPoleShadowStrength[NUMHOURS][NUMWEATHERS]; 29 | uchar CTimeCycle::m_nLightShadowStrength[NUMHOURS][NUMWEATHERS]; 30 | uchar CTimeCycle::m_nShadowStrength[NUMHOURS][NUMWEATHERS]; 31 | uchar CTimeCycle::m_fSpriteBrightness[NUMHOURS][NUMWEATHERS]; 32 | uchar CTimeCycle::m_fSpriteSize[NUMHOURS][NUMWEATHERS]; 33 | uchar CTimeCycle::m_fSunSize[NUMHOURS][NUMWEATHERS]; 34 | uchar CTimeCycle::m_nSunCoronaBlue[NUMHOURS][NUMWEATHERS]; 35 | uchar CTimeCycle::m_nSunCoronaGreen[NUMHOURS][NUMWEATHERS]; 36 | uchar CTimeCycle::m_nSunCoronaRed[NUMHOURS][NUMWEATHERS]; 37 | uchar CTimeCycle::m_nSunCoreBlue[NUMHOURS][NUMWEATHERS]; 38 | uchar CTimeCycle::m_nSunCoreGreen[NUMHOURS][NUMWEATHERS]; 39 | uchar CTimeCycle::m_nSunCoreRed[NUMHOURS][NUMWEATHERS]; 40 | uchar CTimeCycle::m_nSkyBottomBlue[NUMHOURS][NUMWEATHERS]; 41 | uchar CTimeCycle::m_nSkyBottomGreen[NUMHOURS][NUMWEATHERS]; 42 | uchar CTimeCycle::m_nSkyBottomRed[NUMHOURS][NUMWEATHERS]; 43 | uchar CTimeCycle::m_nSkyTopBlue[NUMHOURS][NUMWEATHERS]; 44 | uchar CTimeCycle::m_nSkyTopGreen[NUMHOURS][NUMWEATHERS]; 45 | uchar CTimeCycle::m_nSkyTopRed[NUMHOURS][NUMWEATHERS]; 46 | uchar CTimeCycle::m_nAmbientBlue_Obj[NUMHOURS][NUMWEATHERS]; 47 | uchar CTimeCycle::m_nAmbientGreen_Obj[NUMHOURS][NUMWEATHERS]; 48 | uchar CTimeCycle::m_nAmbientRed_Obj[NUMHOURS][NUMWEATHERS]; 49 | uchar CTimeCycle::m_nAmbientBlue[NUMHOURS][NUMWEATHERS]; 50 | uchar CTimeCycle::m_nAmbientGreen[NUMHOURS][NUMWEATHERS]; 51 | uchar CTimeCycle::m_nAmbientRed[NUMHOURS][NUMWEATHERS]; 52 | 53 | float &CTimeCycle::m_BrightnessAddedToAmbientRed = *(float*)0xB79E38; 54 | float &CTimeCycle::m_BrightnessAddedToAmbientGreen = *(float*)0xB79E34; 55 | float &CTimeCycle::m_BrightnessAddedToAmbientBlue = *(float*)0xB79E30; 56 | 57 | int &CTimeCycle::m_ExtraColourWeatherType = *(int*)0xB79E40; 58 | int &CTimeCycle::m_ExtraColour = *(int*)0xB79E44; 59 | int &CTimeCycle::m_bExtraColourOn = *(int*)0xB7C484; 60 | float &CTimeCycle::m_ExtraColourInter = *(float*)0xB79E3C; 61 | CVector &CTimeCycle::m_vecDirnLightToSun = *(CVector*)0xB7CB14; 62 | int &CTimeCycle::m_FogReduction = *(int*)0xB79E48; 63 | CVector *CTimeCycle::m_VectorToSun = (CVector*)0xB7CA50; 64 | float *CTimeCycle::m_fShadowFrontX = (float*)0xB79F90; 65 | float *CTimeCycle::m_fShadowFrontY = (float*)0xB79F50; 66 | float *CTimeCycle::m_fShadowSideX = (float*)0xB79F10; 67 | float *CTimeCycle::m_fShadowSideY = (float*)0xB79ED0; 68 | float *CTimeCycle::m_fShadowDisplacementX = (float*)0xB79E90; 69 | float *CTimeCycle::m_fShadowDisplacementY = (float*)0xB79E50; 70 | int &CTimeCycle::m_CurrentStoredValue = *(int*)0xB79FD0; 71 | RwRGBA &CTimeCycle::m_BelowHorizonGrey = *(RwRGBA*)0xB7CB10; 72 | #ifdef REPLACE 73 | CColourSet CTimeCycle::m_CurrentColours; 74 | CColourSet &CTimeCycle::m_CurrentColours_exe = *(CColourSet*)0xB7C4A0; 75 | #else 76 | CColourSet &CTimeCycle::m_CurrentColours = *(CColourSet*)0xB7C4A0; 77 | #endif 78 | 79 | void 80 | CTimeCycle::SetConstantParametersForPostFX(void) 81 | { 82 | if(!CPostEffects::IsVisionFXActive()) 83 | return; 84 | if(CPostEffects::m_bNightVision){ 85 | m_CurrentColours.shd = 0; 86 | m_CurrentColours.lightshd = 0; 87 | m_CurrentColours.poleshd = 0; 88 | m_CurrentColours.ambr = 0.0; 89 | m_CurrentColours.ambg = 0.4; 90 | m_CurrentColours.ambb = 0.0; 91 | m_CurrentColours.ambobjr = 0.0; 92 | m_CurrentColours.ambobjg = 0.4; 93 | m_CurrentColours.ambobjb = 0.0; 94 | m_CurrentColours.skytopr = 0; 95 | m_CurrentColours.skytopg = 128; 96 | m_CurrentColours.skytopb = 0; 97 | m_CurrentColours.skybotr = 0; 98 | m_CurrentColours.skybotg = 128; 99 | m_CurrentColours.skybotb = 0; 100 | } 101 | if(CPostEffects::m_bInfraredVision){ 102 | m_CurrentColours.shd = 0; 103 | m_CurrentColours.lightshd = 0; 104 | m_CurrentColours.poleshd = 0; 105 | m_CurrentColours.lightonground = 0; 106 | m_CurrentColours.intensityLimit = 0; 107 | m_CurrentColours.waterfogalpha = 0; 108 | m_CurrentColours.ambr = 0.0; 109 | m_CurrentColours.ambg = 0.0; 110 | m_CurrentColours.ambb = 1.0; 111 | m_CurrentColours.ambobjr = 0.0; 112 | m_CurrentColours.ambobjg = 0.0; 113 | m_CurrentColours.ambobjb = 1.0; 114 | m_CurrentColours.skytopr = 0; 115 | m_CurrentColours.skytopg = 0; 116 | m_CurrentColours.skytopb = 128; 117 | m_CurrentColours.skybotr = 0; 118 | m_CurrentColours.skybotg = 0; 119 | m_CurrentColours.skybotb = 128; 120 | } 121 | } 122 | 123 | void 124 | CTimeCycle::StartExtraColour(int extracolor, int keepInter) 125 | { 126 | CTimeCycle::m_ExtraColourWeatherType = extracolor / NUMHOURS + EXTRASTART; 127 | CTimeCycle::m_ExtraColour = extracolor % NUMHOURS; 128 | CTimeCycle::m_bExtraColourOn = 1; 129 | CTimeCycle::m_ExtraColourInter = 0.0f; 130 | if(!keepInter) 131 | CTimeCycle::m_ExtraColourInter = 1.0f; 132 | } 133 | 134 | void 135 | CTimeCycle::Initialise(bool unused) 136 | { 137 | int fd; 138 | int w, h; 139 | char *line; 140 | 141 | int ambr, ambg, ambb; 142 | int ambobjr, ambobjg, ambobjb; 143 | int dirr, dirg, dirb; 144 | int skytopr, skytopg, skytopb; 145 | int skybotr, skybotg, skybotb; 146 | int suncorer, suncoreg, suncoreb; 147 | int suncoronar, suncoronag, suncoronab; 148 | float sunsz, sprsz, sprbght; 149 | int shdw, lightshd, poleshd; 150 | float farclp, fogst, lightonground; 151 | int lowcloudr, lowcloudg, lowcloudb; 152 | int bottomcloudr, bottomcloudg, bottomcloudb; 153 | float waterr, waterg, waterb, watera; 154 | float postfx1a, postfx1r, postfx1g, postfx1b; 155 | float postfx2a, postfx2r, postfx2g, postfx2b; 156 | float cloudalpha; 157 | int radlimit; 158 | int waterfogalpha; 159 | float dirMult; 160 | 161 | CFileMgr::SetDir("DATA"); 162 | fd = CFileMgr::OpenFile("TIMECYC_24H.DAT", "rb"); 163 | CFileMgr::SetDir(""); 164 | 165 | for(w = 0; w < NUMWEATHERS; w++) 166 | for(h = 0; h < NUMHOURS; h++){ 167 | while(line = CFileLoader::LoadLine(fd), line) 168 | if(line[0] != '/' && line[0] != '\0') 169 | break; 170 | sscanf(line, "%d %d %d" " %d %d %d" " %d %d %d" " %d %d %d" " %d %d %d" " %d %d %d" " %d %d %d" 171 | " %f %f %f" 172 | " %d %d %d" 173 | " %f %f %f" 174 | " %d %d %d" " %d %d %d" 175 | " %f %f %f %f" 176 | " %f %f %f %f" 177 | " %f %f %f %f" 178 | " %f %d %d %f", 179 | &ambr, &ambg, &ambb, 180 | &ambobjr, &ambobjg, &ambobjb, 181 | &dirr, &dirg, &dirb, 182 | &skytopr, &skytopg, &skytopb, 183 | &skybotr, &skybotg, &skybotb, 184 | &suncorer, &suncoreg, &suncoreb, 185 | &suncoronar, &suncoronag, &suncoronab, 186 | &sunsz, &sprsz, &sprbght, 187 | &shdw, &lightshd, &poleshd, 188 | &farclp, &fogst, &lightonground, 189 | &lowcloudr, &lowcloudg, &lowcloudb, 190 | &bottomcloudr, &bottomcloudg, &bottomcloudb, 191 | &waterr, &waterg, &waterb, &watera, 192 | &postfx1a, &postfx1r, &postfx1g, &postfx1b, 193 | &postfx2a, &postfx2r, &postfx2g, &postfx2b, 194 | &cloudalpha, 195 | &radlimit, 196 | &waterfogalpha, 197 | &dirMult); 198 | m_nAmbientRed[h][w] = ambr; 199 | m_nAmbientGreen[h][w] = ambg; 200 | m_nAmbientBlue[h][w] = ambb; 201 | m_nAmbientRed_Obj[h][w] = ambobjr; 202 | m_nAmbientGreen_Obj[h][w] = ambobjg; 203 | m_nAmbientBlue_Obj[h][w] = ambobjb; 204 | m_nSkyTopRed[h][w] = skytopr; 205 | m_nSkyTopGreen[h][w] = skytopg; 206 | m_nSkyTopBlue[h][w] = skytopb; 207 | m_nSkyBottomRed[h][w] = skybotr; 208 | m_nSkyBottomGreen[h][w] = skybotg; 209 | m_nSkyBottomBlue[h][w] = skybotb; 210 | m_nSunCoreRed[h][w] = suncorer; 211 | m_nSunCoreGreen[h][w] = suncoreg; 212 | m_nSunCoreBlue[h][w] = suncoreb; 213 | m_nSunCoronaRed[h][w] = suncoronar; 214 | m_nSunCoronaGreen[h][w] = suncoronag; 215 | m_nSunCoronaBlue[h][w] = suncoronab; 216 | m_fSunSize[h][w] = sunsz*10.0f + 0.5f; 217 | m_fSpriteSize[h][w] = sprsz*10.0f + 0.5f; 218 | m_fSpriteBrightness[h][w] = sprbght*10.0f + 0.5f; 219 | m_nShadowStrength[h][w] = shdw; 220 | m_nLightShadowStrength[h][w] = lightshd; 221 | m_nPoleShadowStrength[h][w] = poleshd; 222 | m_fFarClip[h][w] = farclp; 223 | m_fFogStart[h][w] = fogst; 224 | m_fLightsOnGroundBrightness[h][w] = lightonground*10.0f + 0.5f; 225 | m_nLowCloudsRed[h][w] = lowcloudr; 226 | m_nLowCloudsGreen[h][w] = lowcloudg; 227 | m_nLowCloudsBlue[h][w] = lowcloudb; 228 | m_nFluffyCloudsBottomRed[h][w] = bottomcloudr; 229 | m_nFluffyCloudsBottomGreen[h][w] = bottomcloudg; 230 | m_nFluffyCloudsBottomBlue[h][w] = bottomcloudb; 231 | m_fWaterRed[h][w] = waterr; 232 | m_fWaterGreen[h][w] = waterg; 233 | m_fWaterBlue[h][w] = waterb; 234 | m_fWaterAlpha[h][w] = watera; 235 | m_fPostFx1Red[h][w] = postfx1r; 236 | m_fPostFx1Green[h][w] = postfx1g; 237 | m_fPostFx1Blue[h][w] = postfx1b; 238 | m_fPostFx2Red[h][w] = postfx2r; 239 | m_fPostFx2Green[h][w] = postfx2g; 240 | m_fPostFx2Blue[h][w] = postfx2b; 241 | m_fPostFx1Alpha[h][w] = postfx1a + postfx1a; 242 | m_fPostFx2Alpha[h][w] = postfx2a + postfx2a; 243 | m_fCloudAlpha[h][w] = cloudalpha; 244 | m_nHighLightMinIntensity[h][w] = radlimit; 245 | m_nWaterFogAlpha[h][w] = waterfogalpha; 246 | m_nDirectionalMult[h][w] = dirMult*100.0f; 247 | } 248 | CFileMgr::CloseFile(fd); 249 | float c = cos(0.7853981852531433); 250 | m_vecDirnLightToSun.x = cos(-2.356194496154785) * c; 251 | m_vecDirnLightToSun.y = sin(-2.356194496154785) * c; 252 | m_vecDirnLightToSun.z = sin(0.7853981852531433); 253 | m_vecDirnLightToSun.Normalise(); 254 | m_FogReduction = 0; 255 | m_bExtraColourOn = 0; 256 | } 257 | 258 | WRAPPER void CTimeCycle::FindTimeCycleBox(float x, float y, float z, CTimeCycleBox **box, float *interp, bool checkLod, bool checkFar, CTimeCycleBox *exclude) 259 | { WRAPARG(x); WRAPARG(y); WRAPARG(z); WRAPARG(box); WRAPARG(interp); WRAPARG(checkLod); WRAPARG(checkFar); WRAPARG(exclude); EAXJMP(0x55FFD0); } 260 | 261 | static uchar timecycleHours[25] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 }; 262 | static uchar timecycleHorizon[24] = { 30, 30, 30, 30, 30, 30, 30, 50, 52, 54, 56, 58, 60, 60, 60, 60, 60, 60, 60, 60, 50, 42, 35, 32 }; 263 | int &tunnelWeather = *(int*)0x8CDEE0; 264 | 265 | void 266 | CTimeCycle::CalcColoursForPoint(float x, float y, float z, CColourSet *colorset) 267 | { 268 | CTimeCycleBox *lodBox, *farBox1, *farBox2, *weatherBox, *tmpBox; 269 | float lodBoxInterp, farBox1Interp, farBox2Interp, weatherBoxInterp, tmpInterp; 270 | float time; 271 | int curHourSel, nextHourSel; 272 | int curHour, nextHour; 273 | float timeInterp, invTimeInterp, weatherInterp, invWeatherInterp; 274 | int boxWeather, boxHour; 275 | float lightMult; 276 | float sunAngle; 277 | CVector *vec; 278 | float inc; 279 | float camZ; 280 | float horiz; 281 | float brightness; 282 | float max, f; 283 | 284 | FindTimeCycleBox(x, y, z, &lodBox, &lodBoxInterp, true, false, NULL); 285 | FindTimeCycleBox(x, y, z, &farBox1, &farBox1Interp, false, true, NULL); 286 | if(farBox1){ 287 | CTimeCycle::FindTimeCycleBox(x, y, z, &farBox2, &farBox2Interp, false, true, farBox1); 288 | if(farBox2) 289 | if(farBox2->box.max.x - farBox2->box.min.x > farBox1->box.max.x - farBox1->box.min.x){ 290 | tmpBox = farBox1; 291 | farBox1 = farBox2; 292 | farBox2 = tmpBox; 293 | tmpInterp = farBox2Interp; 294 | farBox2Interp = farBox1Interp; 295 | farBox1Interp = tmpInterp; 296 | } 297 | }else 298 | farBox2 = NULL; 299 | FindTimeCycleBox(x, y, z, &weatherBox, &weatherBoxInterp, false, false, NULL); 300 | 301 | time = CClock::ms_nGameClockMinutes / 60.0f 302 | + CClock::ms_nGameClockSeconds / 3600.0f 303 | + CClock::ms_nGameClockHours; 304 | if(time >= 23.999f) 305 | time = 23.999f; 306 | 307 | for(curHourSel = 0; time >= timecycleHours[curHourSel+1]; curHourSel++); 308 | nextHourSel = (curHourSel + 1) % NUMHOURS; 309 | curHour = timecycleHours[curHourSel]; 310 | nextHour = timecycleHours[curHourSel+1]; 311 | timeInterp = (time - curHour) / (float)(nextHour - curHour); 312 | invTimeInterp = 1.0f - timeInterp; 313 | weatherInterp = CWeather::InterpolationValue; 314 | invWeatherInterp = 1.0f - weatherInterp; 315 | if(weatherBox){ 316 | boxWeather = (weatherBox->extraColor / NUMHOURS) + 21; 317 | boxHour = weatherBox->extraColor % 8; 318 | } 319 | CColourSet curold(curHourSel, CWeather::OldWeatherType); 320 | CColourSet nextold(nextHourSel, CWeather::OldWeatherType); 321 | CColourSet curnew(curHourSel, CWeather::NewWeatherType); 322 | CColourSet nextnew(nextHourSel, CWeather::NewWeatherType); 323 | 324 | if(*(CMatrix**)(0xB6F028 + 0x14)) // TheCamera coords 325 | camZ = (*(CMatrix**)(0xB6F028 + 0x14))->matrix.pos.z; 326 | else 327 | camZ = ((CVector*)(0xB6F028 + 0x4))->z; 328 | f = (camZ-20.0)/200.0; 329 | if(f < 0.0) f = 0.0; 330 | if(f > 1.0) f = 1.0; 331 | if(CWeather::OldWeatherType == EXTRASUNNY_SMOG_LA){ 332 | CColourSet set1(curHourSel, EXTRASUNNY_LA); 333 | curold.Interpolate(&curold, &set1, 1.0-f, f, false); 334 | CColourSet set2(nextHourSel, EXTRASUNNY_LA); 335 | nextold.Interpolate(&nextold, &set2, 1.0-f, f, false); 336 | }else if(CWeather::OldWeatherType == SUNNY_SMOG_LA){ 337 | CColourSet set1(curHourSel, SUNNY_LA); 338 | curold.Interpolate(&curold, &set1, 1.0-f, f, false); 339 | CColourSet set2(nextHourSel, SUNNY_LA); 340 | nextold.Interpolate(&nextold, &set2, 1.0-f, f, false); 341 | } 342 | if(CWeather::NewWeatherType == EXTRASUNNY_SMOG_LA){ 343 | CColourSet set1(curHourSel, EXTRASUNNY_LA); 344 | curnew.Interpolate(&curnew, &set1, 1.0-f, f, false); 345 | CColourSet set2(nextHourSel, EXTRASUNNY_LA); 346 | nextnew.Interpolate(&nextnew, &set2, 1.0-f, f, false); 347 | }else if(CWeather::NewWeatherType == SUNNY_SMOG_LA){ 348 | CColourSet set1(curHourSel, SUNNY_LA); 349 | curnew.Interpolate(&curnew, &set1, 1.0-f, f, false); 350 | CColourSet set2(nextHourSel, SUNNY_LA); 351 | nextnew.Interpolate(&nextnew, &set2, 1.0-f, f, false); 352 | } 353 | 354 | CColourSet oldInterp, newInterp; 355 | oldInterp.Interpolate(&curold, &nextold, invTimeInterp, timeInterp, false); 356 | newInterp.Interpolate(&curnew, &nextnew, invTimeInterp, timeInterp, false); 357 | colorset->Interpolate(&oldInterp, &newInterp, invWeatherInterp, weatherInterp, false); 358 | 359 | lightMult = (1.0f / CCoronas::LightsMult + 3.0f) * 0.25f; 360 | colorset->skytopr *= lightMult; 361 | colorset->skytopg *= lightMult; 362 | colorset->skytopb *= lightMult; 363 | colorset->skybotr *= lightMult; 364 | colorset->skybotg *= lightMult; 365 | colorset->skybotb *= lightMult; 366 | if(colorset->skytopr > 0xFF) colorset->skytopr = 0xFF; 367 | if(colorset->skytopg > 0xFF) colorset->skytopg = 0xFF; 368 | if(colorset->skytopb > 0xFF) colorset->skytopb = 0xFF; 369 | if(colorset->skybotr > 0xFF) colorset->skybotr = 0xFF; 370 | if(colorset->skybotg > 0xFF) colorset->skybotg = 0xFF; 371 | if(colorset->skybotb > 0xFF) colorset->skybotb = 0xFF; 372 | 373 | if(m_FogReduction) 374 | colorset->farclp = colorset->farclp > m_FogReduction*10.15625 ? colorset->farclp : m_FogReduction*10.15625; 375 | 376 | m_CurrentStoredValue = (m_CurrentStoredValue + 1) & 0xF; 377 | vec = &m_VectorToSun[m_CurrentStoredValue]; 378 | sunAngle = (CClock::ms_nGameClockMinutes + 60 * CClock::ms_nGameClockHours + CClock::ms_nGameClockSeconds/60.0f) * 0.0043633231; 379 | vec->x = 0.7 + sin(sunAngle); 380 | vec->y = -0.7; 381 | vec->z = 0.2 - cos(sunAngle); 382 | vec->Normalise(); 383 | 384 | if(weatherBox && weatherBox->extraColor >= 0){ 385 | float boxf = weatherBoxInterp * weatherBox->strength; 386 | float invboxf = 1.0 - boxf; 387 | 388 | colorset->skytopr = colorset->skytopr*invboxf + m_nSkyTopRed[boxHour][boxWeather]*boxf; 389 | colorset->skytopg = colorset->skytopg*invboxf + m_nSkyTopGreen[boxHour][boxWeather]*boxf; 390 | colorset->skytopb = colorset->skytopg*invboxf + m_nSkyTopBlue[boxHour][boxWeather]*boxf; 391 | 392 | colorset->skybotr = colorset->skybotr*invboxf + m_nSkyBottomRed[boxHour][boxWeather]*boxf; 393 | colorset->skybotg = colorset->skybotg*invboxf + m_nSkyBottomGreen[boxHour][boxWeather]*boxf; 394 | colorset->skybotb = colorset->skybotb*invboxf + m_nSkyBottomBlue[boxHour][boxWeather]*boxf; 395 | 396 | colorset->waterr = colorset->waterr*invboxf + m_fWaterRed[boxHour][boxWeather]*boxf; 397 | colorset->waterg = colorset->waterg*invboxf + m_fWaterGreen[boxHour][boxWeather]*boxf; 398 | colorset->waterb = colorset->waterb*invboxf + m_fWaterBlue[boxHour][boxWeather]*boxf; 399 | colorset->watera = colorset->watera*invboxf + m_fWaterAlpha[boxHour][boxWeather]*boxf; 400 | 401 | colorset->ambr = colorset->ambr*invboxf + m_nAmbientRed[boxHour][boxWeather]*boxf; 402 | colorset->ambg = colorset->ambg*invboxf + m_nAmbientGreen[boxHour][boxWeather]*boxf; 403 | colorset->ambb = colorset->ambb*invboxf + m_nAmbientBlue[boxHour][boxWeather]*boxf; 404 | 405 | colorset->ambobjr = colorset->ambobjr*invboxf + m_nAmbientRed_Obj[boxHour][boxWeather]*boxf; 406 | colorset->ambobjg = colorset->ambobjg*invboxf + m_nAmbientGreen_Obj[boxHour][boxWeather]*boxf; 407 | colorset->ambobjb = colorset->ambobjb*invboxf + m_nAmbientBlue_Obj[boxHour][boxWeather]*boxf; 408 | 409 | if(m_fFarClip[boxHour][boxWeather] < colorset->farclp) 410 | colorset->farclp = colorset->farclp*invboxf + m_fFarClip[boxHour][boxWeather]*boxf; 411 | 412 | colorset->fogst = colorset->fogst*invboxf + m_fFogStart[boxHour][boxWeather]*boxf; 413 | 414 | colorset->postfx1r = colorset->postfx1r*invboxf + m_fPostFx1Red[boxHour][boxWeather]*boxf; 415 | colorset->postfx1g = colorset->postfx1g*invboxf + m_fPostFx1Green[boxHour][boxWeather]*boxf; 416 | colorset->postfx1b = colorset->postfx1b*invboxf + m_fPostFx1Blue[boxHour][boxWeather]*boxf; 417 | colorset->postfx1a = colorset->postfx1a*invboxf + m_fPostFx1Alpha[boxHour][boxWeather]*boxf; 418 | 419 | colorset->postfx2r = colorset->postfx2r*invboxf + m_fPostFx2Red[boxHour][boxWeather]*boxf; 420 | colorset->postfx2g = colorset->postfx2g*invboxf + m_fPostFx2Green[boxHour][boxWeather]*boxf; 421 | colorset->postfx2b = colorset->postfx2b*invboxf + m_fPostFx2Blue[boxHour][boxWeather]*boxf; 422 | colorset->postfx2a = colorset->postfx2a*invboxf + m_fPostFx2Alpha[boxHour][boxWeather]*boxf; 423 | } 424 | 425 | if(lodBox) 426 | colorset->lodDistMult = colorset->lodDistMult*(1.0f-lodBoxInterp) + lodBox->lodDistMult/32.0f*lodBoxInterp; 427 | 428 | if(farBox1 && farBox1->farclp < colorset->farclp) 429 | colorset->farclp = colorset->farclp*(1.0f-farBox1Interp) + farBox1->farclp*farBox1Interp; 430 | if(farBox2 && farBox2->farclp < colorset->farclp) 431 | colorset->farclp = colorset->farclp*(1.0f-farBox2Interp) + farBox2->farclp*farBox2Interp; 432 | 433 | inc = CTimer::ms_fTimeStep/120.0f; 434 | if(m_bExtraColourOn){ 435 | m_ExtraColourInter += inc; 436 | if(m_ExtraColourInter > 1.0f) 437 | m_ExtraColourInter = 1.0f; 438 | }else{ 439 | m_ExtraColourInter -= inc; 440 | if(m_ExtraColourInter < 0.0f) 441 | m_ExtraColourInter = 0.0f; 442 | } 443 | if(m_ExtraColourInter > 0.0f){ 444 | CColourSet extraset(m_ExtraColour, m_ExtraColourWeatherType); 445 | colorset->Interpolate(colorset, &extraset, 1.0f-m_ExtraColourInter, m_ExtraColourInter, 446 | m_nSkyTopRed[m_ExtraColour][m_ExtraColourWeatherType] == 0 && 447 | m_nSkyTopGreen[m_ExtraColour][m_ExtraColourWeatherType] == 0 && 448 | m_nSkyTopBlue[m_ExtraColour][m_ExtraColourWeatherType] == 0); 449 | } 450 | 451 | if(CWeather::UnderWaterness > 0.0f){ 452 | CColourSet curuwset(curHourSel, 20); 453 | CColourSet nextuwset(nextHourSel, 20); 454 | CColourSet tmpset; 455 | tmpset.Interpolate(&curuwset, &nextuwset, invTimeInterp, timeInterp, false); 456 | colorset->Interpolate(colorset, &tmpset, 1.0f-CWeather::UnderWaterness, CWeather::UnderWaterness, false); 457 | } 458 | 459 | if(CWeather::InTunnelness > 0.0f){ 460 | CColourSet tunnelset(tunnelWeather % NUMHOURS, tunnelWeather / NUMHOURS + EXTRASTART); 461 | colorset->Interpolate(colorset, &tunnelset, 1.0f-CWeather::InTunnelness, CWeather::InTunnelness, 462 | m_nSkyTopRed[m_ExtraColour][m_ExtraColourWeatherType] == 0 && 463 | m_nSkyTopGreen[m_ExtraColour][m_ExtraColourWeatherType] == 0 && 464 | m_nSkyTopBlue[m_ExtraColour][m_ExtraColourWeatherType] == 0); 465 | } 466 | 467 | colorset->ambr /= 255; 468 | colorset->ambg /= 255; 469 | colorset->ambb /= 255; 470 | colorset->ambobjr /= 255; 471 | colorset->ambobjg /= 255; 472 | colorset->ambobjb /= 255; 473 | 474 | CShadows__CalcPedShadowValues( 475 | m_VectorToSun[m_CurrentStoredValue].x, 476 | m_VectorToSun[m_CurrentStoredValue].y, 477 | m_VectorToSun[m_CurrentStoredValue].z, 478 | &m_fShadowFrontX[m_CurrentStoredValue], 479 | &m_fShadowFrontY[m_CurrentStoredValue], 480 | &m_fShadowSideX[m_CurrentStoredValue], 481 | &m_fShadowSideY[m_CurrentStoredValue], 482 | &m_fShadowDisplacementX[m_CurrentStoredValue], 483 | &m_fShadowDisplacementY[m_CurrentStoredValue]); 484 | 485 | if(((CMatrix*)(0xB6F028 + 0x974))->matrix.up.z < -0.9 486 | || !CWeather::bScriptsForceRain 487 | && (CCullZones::PlayerNoRain() || CCullZones::CamNoRain() || CCutsceneMgr::ms_running)){ 488 | m_FogReduction++; 489 | if(m_FogReduction > 64) 490 | m_FogReduction = 64; 491 | }else{ 492 | m_FogReduction--; 493 | if(m_FogReduction < 0) 494 | m_FogReduction = 0; 495 | } 496 | 497 | if(camZ > 200.0f){ 498 | if(camZ <= 500.0f) 499 | colorset->farclp = colorset->farclp*(1.0f - (camZ-200.0f)/300.0f) + 1000.0f*(camZ-200.0f)/300.0f; 500 | else if(colorset->farclp >= 1000.0f) 501 | colorset->farclp = 1000.0f; 502 | } 503 | 504 | horiz = timecycleHorizon[curHourSel]*invTimeInterp + timecycleHorizon[nextHourSel]*timeInterp; 505 | m_BelowHorizonGrey.red = m_CurrentColours.skybotr*CWeather::UnderWaterness + horiz*(1.0f - CWeather::UnderWaterness); 506 | m_BelowHorizonGrey.green = m_CurrentColours.skybotg*CWeather::UnderWaterness + horiz*(1.0f - CWeather::UnderWaterness); 507 | m_BelowHorizonGrey.blue = m_CurrentColours.skybotb*CWeather::UnderWaterness + horiz*(1.0f - CWeather::UnderWaterness); 508 | 509 | colorset->ambBeforeBrightnessr = colorset->ambr; 510 | colorset->ambBeforeBrightnessg = colorset->ambg; 511 | colorset->ambBeforeBrightnessb = colorset->ambb; 512 | brightness = *(int*)(0xBA6748 + 0x3C); 513 | if(brightness >= 256.0f){ 514 | f = (brightness - 256.0)/128.0 + 1.0; 515 | max = colorset->ambr; 516 | if(colorset->ambg > max) 517 | max = colorset->ambg; 518 | if(colorset->ambb > max) 519 | max = colorset->ambb; 520 | max = max*f - max; 521 | colorset->ambr += max; 522 | colorset->ambg += max; 523 | colorset->ambb += max; 524 | }else{ 525 | f = brightness/256.0f * 0.8 + 0.2; 526 | colorset->ambr *= f; 527 | colorset->ambg *= f; 528 | colorset->ambb *= f; 529 | } 530 | 531 | if(f > 1.0){ 532 | float r, g, b; 533 | f = (f-1.0f)*0.06; 534 | max = colorset->ambr; 535 | if(colorset->ambg > max) 536 | max = colorset->ambg; 537 | if(colorset->ambb > max) 538 | max = colorset->ambb; 539 | r = colorset->ambr; 540 | g = colorset->ambg; 541 | b = colorset->ambb; 542 | if(max == 0.0){ 543 | colorset->ambr = 0.001; 544 | colorset->ambg = 0.001; 545 | colorset->ambb = 0.001; 546 | } 547 | if(f > max){ 548 | f /= max; 549 | colorset->ambr *= f; 550 | colorset->ambg *= f; 551 | colorset->ambb *= f; 552 | } 553 | m_BrightnessAddedToAmbientRed = colorset->ambr - r; 554 | m_BrightnessAddedToAmbientGreen = colorset->ambg - g; 555 | m_BrightnessAddedToAmbientBlue = colorset->ambb - b; 556 | } 557 | 558 | f = 0.0; 559 | if(x < -3000.0) 560 | f = -(x + 3000.0); 561 | else if(x > 3000.0) 562 | f = x - 3000.0; 563 | if(y < -3000.0) 564 | f += -(y + 3000.0); 565 | else if(y > 3000.0) 566 | f += y - 3000.0; 567 | if(f >= 1000.0) 568 | colorset->lodDistMult *= 2.0; 569 | else if(f > 0.0) 570 | colorset->lodDistMult = (f/1000.0 + 1.0) * colorset->lodDistMult; 571 | 572 | SetConstantParametersForPostFX(); 573 | } 574 | 575 | double 576 | CTimeCycle::FindFarClipForCoors(float x, float y, float z) 577 | { 578 | CColourSet s; 579 | bool extraOn; 580 | float extraInter; 581 | extraOn = CTimeCycle::m_bExtraColourOn != 0; 582 | extraInter = CTimeCycle::m_ExtraColourInter; 583 | CTimeCycle::m_bExtraColourOn = 0; 584 | CTimeCycle::m_ExtraColourInter = 0.0; 585 | CTimeCycle::CalcColoursForPoint(x, y, z, &s); 586 | CTimeCycle::m_bExtraColourOn = extraOn; 587 | CTimeCycle::m_ExtraColourInter = extraInter; 588 | return s.farclp; 589 | } 590 | 591 | void 592 | CTimeCycle::Update(void) 593 | { 594 | RwV3d *pos; 595 | if(*(CMatrix**)(0xB6F028 + 0x14)) // TheCamera coords 596 | pos = &(*(CMatrix**)(0xB6F028 + 0x14))->matrix.pos; 597 | else 598 | pos = ((RwV3d*)(0xB6F028 + 0x4)); 599 | CalcColoursForPoint(pos->x, pos->y, pos->z, &m_CurrentColours); 600 | #ifdef REPLACE 601 | memcpy(&m_CurrentColours_exe, &m_CurrentColours, 0xAC); 602 | #endif 603 | } 604 | -------------------------------------------------------------------------------- /src/TimeCycle.h: -------------------------------------------------------------------------------- 1 | struct CTimeCycleBox 2 | { 3 | CBox box; 4 | short farclp; 5 | uchar lodDistMult; 6 | int extraColor; 7 | float strength; 8 | float falloff; 9 | }; 10 | 11 | class CTimeCycle 12 | { 13 | public: 14 | enum WeatherType { 15 | EXTRASUNNY_LA = 0, 16 | SUNNY_LA = 1, 17 | EXTRASUNNY_SMOG_LA = 2, 18 | SUNNY_SMOG_LA = 3, 19 | }; 20 | static uchar m_nDirectionalMult[NUMHOURS][NUMWEATHERS]; 21 | static uchar m_nWaterFogAlpha[NUMHOURS][NUMWEATHERS]; 22 | static uchar m_nHighLightMinIntensity[NUMHOURS][NUMWEATHERS]; 23 | static uchar m_fCloudAlpha[NUMHOURS][NUMWEATHERS]; 24 | static uchar m_fPostFx2Alpha[NUMHOURS][NUMWEATHERS]; 25 | static uchar m_fPostFx2Blue[NUMHOURS][NUMWEATHERS]; 26 | static uchar m_fPostFx2Green[NUMHOURS][NUMWEATHERS]; 27 | static uchar m_fPostFx2Red[NUMHOURS][NUMWEATHERS]; 28 | static uchar m_fPostFx1Alpha[NUMHOURS][NUMWEATHERS]; 29 | static uchar m_fPostFx1Blue[NUMHOURS][NUMWEATHERS]; 30 | static uchar m_fPostFx1Green[NUMHOURS][NUMWEATHERS]; 31 | static uchar m_fPostFx1Red[NUMHOURS][NUMWEATHERS]; 32 | static uchar m_fWaterAlpha[NUMHOURS][NUMWEATHERS]; 33 | static uchar m_fWaterBlue[NUMHOURS][NUMWEATHERS]; 34 | static uchar m_fWaterGreen[NUMHOURS][NUMWEATHERS]; 35 | static uchar m_fWaterRed[NUMHOURS][NUMWEATHERS]; 36 | static uchar m_nFluffyCloudsBottomRed[NUMHOURS][NUMWEATHERS]; 37 | static uchar m_nFluffyCloudsBottomGreen[NUMHOURS][NUMWEATHERS]; 38 | static uchar m_nFluffyCloudsBottomBlue[NUMHOURS][NUMWEATHERS]; 39 | static uchar m_nLowCloudsBlue[NUMHOURS][NUMWEATHERS]; 40 | static uchar m_nLowCloudsGreen[NUMHOURS][NUMWEATHERS]; 41 | static uchar m_nLowCloudsRed[NUMHOURS][NUMWEATHERS]; 42 | static uchar m_fLightsOnGroundBrightness[NUMHOURS][NUMWEATHERS]; 43 | static short m_fFogStart[NUMHOURS][NUMWEATHERS]; 44 | static short m_fFarClip[NUMHOURS][NUMWEATHERS]; 45 | static uchar m_nPoleShadowStrength[NUMHOURS][NUMWEATHERS]; 46 | static uchar m_nLightShadowStrength[NUMHOURS][NUMWEATHERS]; 47 | static uchar m_nShadowStrength[NUMHOURS][NUMWEATHERS]; 48 | static uchar m_fSpriteBrightness[NUMHOURS][NUMWEATHERS]; 49 | static uchar m_fSpriteSize[NUMHOURS][NUMWEATHERS]; 50 | static uchar m_fSunSize[NUMHOURS][NUMWEATHERS]; 51 | static uchar m_nSunCoronaBlue[NUMHOURS][NUMWEATHERS]; 52 | static uchar m_nSunCoronaGreen[NUMHOURS][NUMWEATHERS]; 53 | static uchar m_nSunCoronaRed[NUMHOURS][NUMWEATHERS]; 54 | static uchar m_nSunCoreBlue[NUMHOURS][NUMWEATHERS]; 55 | static uchar m_nSunCoreGreen[NUMHOURS][NUMWEATHERS]; 56 | static uchar m_nSunCoreRed[NUMHOURS][NUMWEATHERS]; 57 | static uchar m_nSkyBottomBlue[NUMHOURS][NUMWEATHERS]; 58 | static uchar m_nSkyBottomGreen[NUMHOURS][NUMWEATHERS]; 59 | static uchar m_nSkyBottomRed[NUMHOURS][NUMWEATHERS]; 60 | static uchar m_nSkyTopBlue[NUMHOURS][NUMWEATHERS]; 61 | static uchar m_nSkyTopGreen[NUMHOURS][NUMWEATHERS]; 62 | static uchar m_nSkyTopRed[NUMHOURS][NUMWEATHERS]; 63 | static uchar m_nAmbientBlue_Obj[NUMHOURS][NUMWEATHERS]; 64 | static uchar m_nAmbientGreen_Obj[NUMHOURS][NUMWEATHERS]; 65 | static uchar m_nAmbientRed_Obj[NUMHOURS][NUMWEATHERS]; 66 | static uchar m_nAmbientBlue[NUMHOURS][NUMWEATHERS]; 67 | static uchar m_nAmbientGreen[NUMHOURS][NUMWEATHERS]; 68 | static uchar m_nAmbientRed[NUMHOURS][NUMWEATHERS]; 69 | 70 | static float &m_BrightnessAddedToAmbientRed; 71 | static float &m_BrightnessAddedToAmbientGreen; 72 | static float &m_BrightnessAddedToAmbientBlue; 73 | 74 | static int &m_ExtraColourWeatherType; 75 | static int &m_ExtraColour; 76 | static int &m_bExtraColourOn; 77 | static float &m_ExtraColourInter; 78 | static CVector &m_vecDirnLightToSun; 79 | static int &m_FogReduction; 80 | static CVector *m_VectorToSun; // [16] 81 | static float *m_fShadowFrontX; // [16] 82 | static float *m_fShadowFrontY; // [16] 83 | static float *m_fShadowSideX; // [16] 84 | static float *m_fShadowSideY; // [16] 85 | static float *m_fShadowDisplacementX; // [16] 86 | static float *m_fShadowDisplacementY; // [16] 87 | static int &m_CurrentStoredValue; 88 | static RwRGBA &m_BelowHorizonGrey; 89 | #ifdef REPLACE 90 | static CColourSet m_CurrentColours; 91 | static CColourSet &m_CurrentColours_exe; 92 | #else 93 | static CColourSet &m_CurrentColours; 94 | #endif 95 | 96 | static void Initialise(bool unused); 97 | static void CalcColoursForPoint(float x, float y, float z, CColourSet *colorset); 98 | static void StartExtraColour(int extracolor, int keepInter); 99 | static void FindTimeCycleBox(float x, float y, float z, CTimeCycleBox **box, float *interp, bool checkLod, bool checkFar, CTimeCycleBox *exclude); 100 | static void SetConstantParametersForPostFX(void); 101 | static double FindFarClipForCoors(float x, float y, float z); 102 | static void Update(void); 103 | }; 104 | -------------------------------------------------------------------------------- /src/gta.cpp: -------------------------------------------------------------------------------- 1 | #include "gta.h" 2 | #include "MemoryMgr.h" 3 | 4 | WRAPPER void CFileMgr::SetDir(const char *dir) { WRAPARG(dir); EAXJMP(0x5387D0); } 5 | WRAPPER int CFileMgr::OpenFile(const char *path, const char *mode) { WRAPARG(path); WRAPARG(mode); EAXJMP(0x538900); } 6 | WRAPPER void CFileMgr::CloseFile(int fd) { WRAPARG(fd); EAXJMP(0x5389D0); } 7 | 8 | WRAPPER char *CFileLoader::LoadLine(int fd) { WRAPARG(fd); EAXJMP(0x536F80); } 9 | 10 | void 11 | CVector::Normalise(void) 12 | { 13 | double dot, invlen; 14 | dot = this->x * this->x + this->y * this->y + this->z * this->z; 15 | if(dot > 0.0){ 16 | invlen = 1.0 / sqrt(dot); 17 | this->x = invlen * this->x; 18 | this->y = invlen * this->y; 19 | this->z = invlen * this->z; 20 | }else 21 | this->x = 1.0f; 22 | } 23 | 24 | float &CTimer::ms_fTimeStep = *(float*)0xB7CB5C; 25 | 26 | ushort &CClock::ms_nGameClockSeconds = *(ushort*)0xB70150; 27 | uchar &CClock::ms_nGameClockMinutes = *(uchar*)0xB70152; 28 | uchar &CClock::ms_nGameClockHours = *(uchar*)0xB70153; 29 | 30 | short &CWeather::OldWeatherType = *(short*)0xC81320; 31 | short &CWeather::NewWeatherType = *(short*)0xC8131C; 32 | float &CWeather::InterpolationValue = *(float*)0xC8130C; 33 | float &CWeather::UnderWaterness = *(float*)0xC8132C; 34 | float &CWeather::InTunnelness = *(float*)0xC81334; 35 | bool &CWeather::bScriptsForceRain = *(bool*)0xC812AC; 36 | 37 | float &CCoronas::LightsMult = *(float*)0x8D4B5C; 38 | 39 | WRAPPER bool CCullZones::PlayerNoRain(void) { EAXJMP(0x72DDC0); } 40 | WRAPPER bool CCullZones::CamNoRain(void) { EAXJMP(0x72DDB0); } 41 | 42 | bool &CCutsceneMgr::ms_running = *(bool*)0xB5F851; 43 | 44 | WRAPPER bool CPostEffects::IsVisionFXActive(void) { EAXJMP(0x7034F0); } 45 | bool &CPostEffects::m_bNightVision = *(bool*)0xC402B8; 46 | bool &CPostEffects::m_bInfraredVision = *(bool*)0xC402B9; 47 | 48 | WRAPPER void CShadows__CalcPedShadowValues(float x, float y, float z, float *sfx, float *sfy, float *ssx, float *ssy, float *sdx, float *sdy) 49 | { WRAPARG(x); WRAPARG(y); WRAPARG(z); WRAPARG(sfx); WRAPARG(sfy); WRAPARG(ssx); WRAPARG(ssy); WRAPARG(sdx); WRAPARG(sdy); EAXJMP(0x7076C0); } 50 | -------------------------------------------------------------------------------- /src/gta.h: -------------------------------------------------------------------------------- 1 | #define _CRT_SECURE_NO_WARNINGS 2 | #pragma warning(disable: 4244) // int to float 3 | #pragma warning(disable: 4800) // int to bool 4 | #pragma warning(disable: 4838) // narrowing conversion 5 | #pragma warning(disable: 4305) // truncation from 'double' to 'float' 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "MemoryMgr.h" 11 | 12 | // when this is defined, the whole TimeCycle is replaced, 13 | // not just patched to use 24 hours 14 | //#define REPLACE 15 | 16 | typedef unsigned char uchar; 17 | typedef unsigned short ushort; 18 | typedef unsigned int uint; 19 | 20 | #define NUMWEATHERS 23 21 | #define NUMHOURS 24 22 | #define EXTRASTART 21 23 | 24 | struct CVector 25 | { 26 | float x, y, z; 27 | 28 | void Normalise(void); 29 | }; 30 | 31 | struct CMatrix 32 | { 33 | RwMatrix matrix; 34 | RwMatrix *matrixPtr; 35 | int haveRwMatrix; 36 | }; 37 | 38 | struct CBox 39 | { 40 | CVector min; 41 | CVector max; 42 | }; 43 | 44 | class CFileMgr 45 | { 46 | public: 47 | static void SetDir(const char *dir); 48 | static int OpenFile(const char *path, const char *mode); 49 | static void CloseFile(int fd); 50 | }; 51 | 52 | class CFileLoader 53 | { 54 | public: 55 | static char *LoadLine(int fd); 56 | }; 57 | 58 | struct CTimer 59 | { 60 | static float &ms_fTimeStep; 61 | }; 62 | 63 | struct CClock 64 | { 65 | static ushort &ms_nGameClockSeconds; 66 | static uchar &ms_nGameClockMinutes; 67 | static uchar &ms_nGameClockHours; 68 | }; 69 | 70 | struct CWeather 71 | { 72 | static short &OldWeatherType; 73 | static short &NewWeatherType; 74 | static float &InterpolationValue; 75 | static float &UnderWaterness; 76 | static float &InTunnelness; 77 | static bool &bScriptsForceRain; 78 | }; 79 | 80 | struct CCoronas 81 | { 82 | static float &LightsMult; 83 | }; 84 | 85 | struct CCullZones 86 | { 87 | static bool PlayerNoRain(void); 88 | static bool CamNoRain(void); 89 | }; 90 | 91 | struct CCutsceneMgr 92 | { 93 | static bool &ms_running; 94 | }; 95 | 96 | struct CPostEffects 97 | { 98 | static bool IsVisionFXActive(void); 99 | static bool &m_bNightVision; 100 | static bool &m_bInfraredVision; 101 | }; 102 | 103 | void CShadows__CalcPedShadowValues(float x, float y, float z, float *sfx, float *sfy, float *ssx, float *ssy, float *sdx, float *sdy); 104 | 105 | #include "ColourSet.h" 106 | #include "TimeCycle.h" 107 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "gta.h" 2 | 3 | HMODULE dllModule; 4 | 5 | uchar timecycleHours[25] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 }; 6 | uchar timecycleHorizon[24] = { 30, 30, 30, 30, 30, 30, 30, 50, 52, 54, 56, 58, 60, 60, 60, 60, 60, 60, 60, 60, 50, 42, 35, 32 }; 7 | 8 | void __declspec(naked) 9 | mod24(void) 10 | { 11 | _asm{ 12 | // leave next hour % NUMHOURS in ebp 13 | push eax 14 | push edx 15 | push ecx 16 | 17 | mov eax, ebp 18 | cdq 19 | mov ecx,NUMHOURS 20 | idiv ecx 21 | mov ebp,edx 22 | 23 | pop ecx 24 | pop edx 25 | pop eax 26 | push 0x56056F 27 | retn 28 | } 29 | } 30 | 31 | void __declspec(naked) 32 | mod24_1(void) 33 | { 34 | _asm{ 35 | // save extra weather to stack, extra hour to eax 36 | cdq 37 | mov ecx,NUMHOURS 38 | idiv ecx // eax = weather, edx = hour 39 | mov ecx,eax 40 | add ecx,EXTRASTART 41 | mov [esp+10h],ecx 42 | mov eax,edx 43 | 44 | push 0x5605F5 45 | retn 46 | } 47 | } 48 | 49 | void __declspec(naked) 50 | mod24_2(void) 51 | { 52 | _asm{ 53 | // leave extra weather in ebx, extra hour in edi 54 | cdq 55 | mov ecx,NUMHOURS 56 | idiv ecx // eax = weather, edx = hour 57 | mov ebx,eax 58 | add ebx,EXTRASTART 59 | mov edi,ebx 60 | 61 | push 0x56116D 62 | retn 63 | } 64 | } 65 | 66 | 67 | 68 | void 69 | patch(void) 70 | { 71 | // HOODLUM 72 | if(*(uint*)0x55F4C5 == 0xFFEA63EE){ 73 | // restore movzx instruction (replace jump) 74 | struct{uchar m[3];} m = { {0x0F, 0xB6, 0xB9} }; 75 | Patch(0x55F4C2, m); 76 | } 77 | Patch(0x55F7C7, (void*)&CTimeCycle::m_nDirectionalMult); 78 | Patch(0x5BBFEC, (void*)&CTimeCycle::m_nDirectionalMult); 79 | Patch(0x55F7B8, (void*)&CTimeCycle::m_nWaterFogAlpha); 80 | Patch(0x5BBFC5, (void*)&CTimeCycle::m_nWaterFogAlpha); 81 | Patch(0x55F7A9, (void*)&CTimeCycle::m_nHighLightMinIntensity); 82 | Patch(0x5BBFBF, (void*)&CTimeCycle::m_nHighLightMinIntensity); 83 | Patch(0x55F793, (void*)&CTimeCycle::m_fCloudAlpha); 84 | Patch(0x5BBFB2, (void*)&CTimeCycle::m_fCloudAlpha); 85 | Patch(0x55F77D, (void*)&CTimeCycle::m_fPostFx2Alpha); 86 | Patch(0x560E4B, (void*)&CTimeCycle::m_fPostFx2Alpha); 87 | Patch(0x5BBF99, (void*)&CTimeCycle::m_fPostFx2Alpha); 88 | Patch(0x55F767, (void*)&CTimeCycle::m_fPostFx2Blue); 89 | Patch(0x560E2A, (void*)&CTimeCycle::m_fPostFx2Blue); 90 | Patch(0x5BBF73, (void*)&CTimeCycle::m_fPostFx2Blue); 91 | Patch(0x55F751, (void*)&CTimeCycle::m_fPostFx2Green); 92 | Patch(0x560E09, (void*)&CTimeCycle::m_fPostFx2Green); 93 | Patch(0x5BBF5F, (void*)&CTimeCycle::m_fPostFx2Green); 94 | Patch(0x55F73B, (void*)&CTimeCycle::m_fPostFx2Red); 95 | Patch(0x560DE3, (void*)&CTimeCycle::m_fPostFx2Red); 96 | Patch(0x5BBF4D, (void*)&CTimeCycle::m_fPostFx2Red); 97 | Patch(0x55F725, (void*)&CTimeCycle::m_fPostFx1Alpha); 98 | Patch(0x560DC2, (void*)&CTimeCycle::m_fPostFx1Alpha); 99 | Patch(0x5BBF87, (void*)&CTimeCycle::m_fPostFx1Alpha); 100 | Patch(0x55F70F, (void*)&CTimeCycle::m_fPostFx1Blue); 101 | Patch(0x560DA1, (void*)&CTimeCycle::m_fPostFx1Blue); 102 | Patch(0x5BBF3B, (void*)&CTimeCycle::m_fPostFx1Blue); 103 | Patch(0x55F6FC, (void*)&CTimeCycle::m_fPostFx1Green); 104 | Patch(0x560D86, (void*)&CTimeCycle::m_fPostFx1Green); 105 | Patch(0x5BBF29, (void*)&CTimeCycle::m_fPostFx1Green); 106 | Patch(0x55F6E9, (void*)&CTimeCycle::m_fPostFx1Red); 107 | Patch(0x560D66, (void*)&CTimeCycle::m_fPostFx1Red); 108 | Patch(0x5BBF17, (void*)&CTimeCycle::m_fPostFx1Red); 109 | Patch(0x55F6D6, (void*)&CTimeCycle::m_fWaterAlpha); 110 | Patch(0x560C46, (void*)&CTimeCycle::m_fWaterAlpha); 111 | Patch(0x5BBF08, (void*)&CTimeCycle::m_fWaterAlpha); 112 | Patch(0x55F6C3, (void*)&CTimeCycle::m_fWaterBlue); 113 | Patch(0x560C2B, (void*)&CTimeCycle::m_fWaterBlue); 114 | Patch(0x5BBEF9, (void*)&CTimeCycle::m_fWaterBlue); 115 | Patch(0x55F6B0, (void*)&CTimeCycle::m_fWaterGreen); 116 | Patch(0x560C10, (void*)&CTimeCycle::m_fWaterGreen); 117 | Patch(0x5BBEEA, (void*)&CTimeCycle::m_fWaterGreen); 118 | Patch(0x55F69C, (void*)&CTimeCycle::m_fWaterRed); 119 | Patch(0x560BF0, (void*)&CTimeCycle::m_fWaterRed); 120 | Patch(0x5BBEDB, (void*)&CTimeCycle::m_fWaterRed); 121 | Patch(0x55F690, (void*)&CTimeCycle::m_nFluffyCloudsBottomBlue); 122 | Patch(0x5BBECC, (void*)&CTimeCycle::m_nFluffyCloudsBottomBlue); 123 | Patch(0x55F683, (void*)&CTimeCycle::m_nFluffyCloudsBottomGreen); 124 | Patch(0x5BBEC6, (void*)&CTimeCycle::m_nFluffyCloudsBottomGreen); 125 | Patch(0x55F677, (void*)&CTimeCycle::m_nFluffyCloudsBottomRed); 126 | Patch(0x5BBEC0, (void*)&CTimeCycle::m_nFluffyCloudsBottomRed); 127 | Patch(0x55F66B, (void*)&CTimeCycle::m_nLowCloudsBlue); 128 | Patch(0x5BBEB6, (void*)&CTimeCycle::m_nLowCloudsBlue); 129 | Patch(0x55F65F, (void*)&CTimeCycle::m_nLowCloudsGreen); 130 | Patch(0x5BBEAC, (void*)&CTimeCycle::m_nLowCloudsGreen); 131 | Patch(0x55F653, (void*)&CTimeCycle::m_nLowCloudsRed); 132 | Patch(0x5BBEA2, (void*)&CTimeCycle::m_nLowCloudsRed); 133 | Patch(0x55F640, (void*)&CTimeCycle::m_fLightsOnGroundBrightness); 134 | Patch(0x5BBE98, (void*)&CTimeCycle::m_fLightsOnGroundBrightness); 135 | Patch(0x55F62E, (void*)&CTimeCycle::m_fFogStart); 136 | Patch(0x560D42, (void*)&CTimeCycle::m_fFogStart); 137 | Patch(0x5BBE7B, (void*)&CTimeCycle::m_fFogStart); 138 | Patch(0x55F61B, (void*)&CTimeCycle::m_fFarClip); 139 | Patch(0x560D0C, (void*)&CTimeCycle::m_fFarClip); 140 | Patch(0x5BBE65, (void*)&CTimeCycle::m_fFarClip); 141 | Patch(0x55F60F, (void*)&CTimeCycle::m_nPoleShadowStrength); 142 | Patch(0x5BBE52, (void*)&CTimeCycle::m_nPoleShadowStrength); 143 | Patch(0x55F603, (void*)&CTimeCycle::m_nLightShadowStrength); 144 | Patch(0x5BBE4C, (void*)&CTimeCycle::m_nLightShadowStrength); 145 | Patch(0x55F5F7, (void*)&CTimeCycle::m_nShadowStrength); 146 | Patch(0x5BBE3B, (void*)&CTimeCycle::m_nShadowStrength); 147 | Patch(0x55F5E4, (void*)&CTimeCycle::m_fSpriteBrightness); 148 | Patch(0x5BBE2E, (void*)&CTimeCycle::m_fSpriteBrightness); 149 | Patch(0x55F5D2, (void*)&CTimeCycle::m_fSpriteSize); 150 | Patch(0x5BBE19, (void*)&CTimeCycle::m_fSpriteSize); 151 | Patch(0x55F5C0, (void*)&CTimeCycle::m_fSunSize); 152 | Patch(0x5BBDFE, (void*)&CTimeCycle::m_fSunSize); 153 | Patch(0x55F5B5, (void*)&CTimeCycle::m_nSunCoronaBlue); 154 | Patch(0x5BBDE6, (void*)&CTimeCycle::m_nSunCoronaBlue); 155 | Patch(0x55F5A9, (void*)&CTimeCycle::m_nSunCoronaGreen); 156 | Patch(0x5BBDE0, (void*)&CTimeCycle::m_nSunCoronaGreen); 157 | Patch(0x55F59D, (void*)&CTimeCycle::m_nSunCoronaRed); 158 | Patch(0x5BBDDA, (void*)&CTimeCycle::m_nSunCoronaRed); 159 | Patch(0x55F591, (void*)&CTimeCycle::m_nSunCoreBlue); 160 | Patch(0x5BBDC7, (void*)&CTimeCycle::m_nSunCoreBlue); 161 | Patch(0x55F585, (void*)&CTimeCycle::m_nSunCoreGreen); 162 | Patch(0x5BBDBA, (void*)&CTimeCycle::m_nSunCoreGreen); 163 | Patch(0x55F579, (void*)&CTimeCycle::m_nSunCoreRed); 164 | Patch(0x5BBDAD, (void*)&CTimeCycle::m_nSunCoreRed); 165 | Patch(0x55F56D, (void*)&CTimeCycle::m_nSkyBottomBlue); 166 | Patch(0x560BCA, (void*)&CTimeCycle::m_nSkyBottomBlue); 167 | Patch(0x5BBDA0, (void*)&CTimeCycle::m_nSkyBottomBlue); 168 | Patch(0x55F561, (void*)&CTimeCycle::m_nSkyBottomGreen); 169 | Patch(0x560BA0, (void*)&CTimeCycle::m_nSkyBottomGreen); 170 | Patch(0x5BBD93, (void*)&CTimeCycle::m_nSkyBottomGreen); 171 | Patch(0x55F555, (void*)&CTimeCycle::m_nSkyBottomRed); 172 | Patch(0x560B6D, (void*)&CTimeCycle::m_nSkyBottomRed); 173 | Patch(0x5BBD86, (void*)&CTimeCycle::m_nSkyBottomRed); 174 | Patch(0x55F549, (void*)&CTimeCycle::m_nSkyTopBlue); 175 | Patch(0x560B47, (void*)&CTimeCycle::m_nSkyTopBlue); 176 | Patch(0x560FD8, (void*)&CTimeCycle::m_nSkyTopBlue); 177 | Patch(0x561197, (void*)&CTimeCycle::m_nSkyTopBlue); 178 | Patch(0x5BBD79, (void*)&CTimeCycle::m_nSkyTopBlue); 179 | Patch(0x55F53D, (void*)&CTimeCycle::m_nSkyTopGreen); 180 | Patch(0x560B19, (void*)&CTimeCycle::m_nSkyTopGreen); 181 | Patch(0x560FCE, (void*)&CTimeCycle::m_nSkyTopGreen); 182 | Patch(0x56118D, (void*)&CTimeCycle::m_nSkyTopGreen); 183 | Patch(0x5BBD6C, (void*)&CTimeCycle::m_nSkyTopGreen); 184 | Patch(0x55F531, (void*)&CTimeCycle::m_nSkyTopRed); 185 | Patch(0x560AEA, (void*)&CTimeCycle::m_nSkyTopRed); 186 | Patch(0x560FC4, (void*)&CTimeCycle::m_nSkyTopRed); 187 | Patch(0x561181, (void*)&CTimeCycle::m_nSkyTopRed); 188 | Patch(0x5BBD5F, (void*)&CTimeCycle::m_nSkyTopRed); 189 | Patch(0x55F51E, (void*)&CTimeCycle::m_nAmbientBlue_Obj); 190 | Patch(0x560CF0, (void*)&CTimeCycle::m_nAmbientBlue_Obj); 191 | Patch(0x5BBD52, (void*)&CTimeCycle::m_nAmbientBlue_Obj); 192 | Patch(0x55F50C, (void*)&CTimeCycle::m_nAmbientGreen_Obj); 193 | Patch(0x560CD5, (void*)&CTimeCycle::m_nAmbientGreen_Obj); 194 | Patch(0x5BBD45, (void*)&CTimeCycle::m_nAmbientGreen_Obj); 195 | Patch(0x55F4FA, (void*)&CTimeCycle::m_nAmbientRed_Obj); 196 | Patch(0x560CB5, (void*)&CTimeCycle::m_nAmbientRed_Obj); 197 | Patch(0x5BBD38, (void*)&CTimeCycle::m_nAmbientRed_Obj); 198 | Patch(0x55F4E8, (void*)&CTimeCycle::m_nAmbientBlue); 199 | Patch(0x560C9A, (void*)&CTimeCycle::m_nAmbientBlue); 200 | Patch(0x5BBD2B, (void*)&CTimeCycle::m_nAmbientBlue); 201 | Patch(0x55F4D6, (void*)&CTimeCycle::m_nAmbientGreen); 202 | Patch(0x560C7F, (void*)&CTimeCycle::m_nAmbientGreen); 203 | Patch(0x5BBD1E, (void*)&CTimeCycle::m_nAmbientGreen); 204 | Patch(0x55F4C5, (void*)&CTimeCycle::m_nAmbientRed); 205 | Patch(0x560C61, (void*)&CTimeCycle::m_nAmbientRed); 206 | Patch(0x5BBD11, (void*)&CTimeCycle::m_nAmbientRed); 207 | 208 | static char *timecycstr = "timecyc_24h.dat"; 209 | Patch(0x5BBAD9 +1, timecycstr); 210 | Patch(0x5BBB18 +1, NUMHOURS); 211 | 212 | Patch(0x560572, timecycleHours + 0x0); 213 | Patch(0x56051E, timecycleHours + 0x1); 214 | Patch(0x560579, timecycleHours + 0x1); 215 | Patch(0x560543, timecycleHours + 0x2); 216 | 217 | Patch(0x5613AD, timecycleHorizon); 218 | Patch(0x5613B8, timecycleHorizon); 219 | 220 | InjectHook(0x560562, mod24, PATCH_JUMP); 221 | InjectHook(0x5605DA, mod24_1, PATCH_JUMP); 222 | InjectHook(0x561158, mod24_2, PATCH_JUMP); 223 | InjectHook(0x55FEC0, CTimeCycle::StartExtraColour, PATCH_JUMP); 224 | 225 | #ifdef REPLACE 226 | // replace functions! 227 | InjectHook(0x5BBAC0, CTimeCycle::Initialise, PATCH_JUMP); 228 | InjectHook(0x55F4B0, &CColourSet::ctor, PATCH_JUMP); 229 | InjectHook(0x55F870, &CColourSet::Interpolate, PATCH_JUMP); 230 | InjectHook(0x5603D0, CTimeCycle::CalcColoursForPoint, PATCH_JUMP); 231 | InjectHook(0x5616E0, CTimeCycle::FindFarClipForCoors, PATCH_JUMP); 232 | InjectHook(0x561760, CTimeCycle::Update, PATCH_JUMP); 233 | #endif 234 | } 235 | 236 | BOOL WINAPI 237 | DllMain(HINSTANCE hInst, DWORD reason, LPVOID) 238 | { 239 | if(reason == DLL_PROCESS_ATTACH){ 240 | // TODO: is this correct? 241 | if(*(DWORD*)DynBaseAddress(0x82457C) != 0x94BF && 242 | *(DWORD*)DynBaseAddress(0x8245BC) == 0x94BF) 243 | return FALSE; 244 | dllModule = hInst; 245 | patch(); 246 | } 247 | return TRUE; 248 | } 249 | --------------------------------------------------------------------------------