diff --git a/CLEOPlus/CLEOPlus.cpp b/CLEOPlus/CLEOPlus.cpp index dc51ea5..d8150bf 100644 --- a/CLEOPlus/CLEOPlus.cpp +++ b/CLEOPlus/CLEOPlus.cpp @@ -18,7 +18,7 @@ #include "rw/rpworld.h" #include -constexpr uint32_t CLEOPLUS_VERSION_INT = 0x01000800; +constexpr uint32_t CLEOPLUS_VERSION_INT = 0x01000900; using namespace plugin; using namespace std; @@ -224,8 +224,8 @@ OpcodeResult WINAPI SET_CAR_MODEL_ALPHA(CScriptThread* thread); OpcodeResult WINAPI SET_CHAR_MODEL_ALPHA(CScriptThread* thread); OpcodeResult WINAPI SET_OBJECT_MODEL_ALPHA(CScriptThread* thread); OpcodeResult WINAPI GET_LOCAL_TIME(CScriptThread* thread); -OpcodeResult WINAPI SET_THREAD_VAR(CScriptThread* thread); -OpcodeResult WINAPI GET_THREAD_VAR(CScriptThread* thread); +OpcodeResult WINAPI SET_SCRIPT_VAR(CScriptThread* thread); +OpcodeResult WINAPI GET_SCRIPT_VAR(CScriptThread* thread); OpcodeResult WINAPI SET_CAR_DOOR_WINDOW_STATE(CScriptThread* thread); OpcodeResult WINAPI GET_OBJECT_CENTRE_OF_MASS_TO_BASE_OF_MODEL(CScriptThread* thread); OpcodeResult WINAPI GET_MODEL_TYPE(CScriptThread* thread); @@ -723,8 +723,8 @@ class CLEOPlus CLEO_RegisterOpcode(0xD10, SET_CHAR_MODEL_ALPHA); // 0xD10=2,set_char_model_alpha %1d% alpha %2d% CLEO_RegisterOpcode(0xD11, SET_OBJECT_MODEL_ALPHA); // 0xD11=2,set_object_model_alpha %1d% alpha %2d% CLEO_RegisterOpcode(0xD2D, GET_LOCAL_TIME); // 0D2D=8,get_local_time_year_to %1d% month_to %2d% day_of_week_to %3d% day_to %4d% hour_to %5d% minute_to %6d% second_to %7d% milliseconds_to %8d% - CLEO_RegisterOpcode(0xD2E, SET_THREAD_VAR); // 0D2E=3,set_thread %1d% var %2d% value %3d% - CLEO_RegisterOpcode(0xD2F, GET_THREAD_VAR); // 0D2F=3,%3d% = get_thread %1d% var %2d% // keep NewOpcodes order + CLEO_RegisterOpcode(0xD2E, SET_SCRIPT_VAR); // 0D2E=3,set_script %1d% var %2d% value %3d% + CLEO_RegisterOpcode(0xD2F, GET_SCRIPT_VAR); // 0D2F=3,%3d% = get_script %1d% var %2d% // keep NewOpcodes order CLEO_RegisterOpcode(0xD33, SET_CAR_DOOR_WINDOW_STATE); // 0D33=3,set_car %1d% door %2d% window_state %3d% } @@ -832,8 +832,8 @@ class CLEOPlus { CLEO_RegisterOpcode(0xD3A, GET_COLLISION_BETWEEN_POINTS); // 0D3A=20,get_collision_between_points %1d% %2d% %3d% and %4d% %5d% %6d% flags %7d% %8d% %9d% %10d% %11d% %12d% %13d% %14d% ignore_entity %15d% store_point_to %17d% %18d% %19d% entity_to %20d% colpoint_data_to %16d% // keep NewOpcodes order CLEO_RegisterOpcode(0xD3B, GET_COLPOINT_NORMAL_VECTOR); // 0D3B=4,get_colpoint_normal_vector %1d% store_to %2d% %3d% %4d% - CLEO_RegisterOpcode(0xD3C, GET_COLPOINT_SURFACE); // 0D3D=2,get_colpoint_surface %1d% store_to %2d% - CLEO_RegisterOpcode(0xD3E, GET_COLPOINT_DEPTH); // 0D3C=2,get_colpoint_depth %1d% store_to %2d% + CLEO_RegisterOpcode(0xD3C, GET_COLPOINT_SURFACE); // 0D3C=2,get_colpoint_surface %1d% store_to %2d% + CLEO_RegisterOpcode(0xD3E, GET_COLPOINT_DEPTH); // 0D3E=2,get_colpoint_depth %1d% store_to %2d% } CLEO_RegisterOpcode(0xE6B, GET_COLPOINT_LIGHTING); // 0xE6B=2,get_colpoint_lighting %1d% from_night %2d% store_to %3d% CLEO_RegisterOpcode(0xEE1, GET_COLPOINT_COORDINATES); // 0xEE1=4,get_colpoint_coordinates %1d% store_to %2d% %3d% %4d% @@ -1225,7 +1225,7 @@ class CLEOPlus Events::objectDtorEvent.before += [](CObject *object) { int ref = CPools::GetObjectRef(object); - if (scriptEvents[ScriptEvent::List::ObjectCreate].size() > 0) { + if (scriptEvents[ScriptEvent::List::ObjectDelete].size() > 0) { for (auto scriptEvent : scriptEvents[ScriptEvent::List::ObjectDelete]) scriptEvent->RunScriptEvent(ref); } for (int i = 0; i < sizeScriptConnectLodsObjects; ++i) diff --git a/CLEOPlus/CLEOPlus.vcxproj b/CLEOPlus/CLEOPlus.vcxproj index 2bf619a..3518db5 100644 --- a/CLEOPlus/CLEOPlus.vcxproj +++ b/CLEOPlus/CLEOPlus.vcxproj @@ -96,14 +96,14 @@ - G:\GTA San Andreas Remaster\cleo\ + G:\GTA SA The Modded Edition\CLEO\ $(ProjectDir).obj\GTASA\Release\ CLEO+ .cleo $(VC_IncludePath);$(WindowsSDK_IncludePath);E:\Documents\Para GTA\plugin-sdk-2020\shared;E:\Documents\Para GTA\plugin-sdk-2020\plugin_sa\game_sa - G:\GTA San Andreas Remaster\cleo\ + G:\GTA SA The Modded Edition\CLEO\ $(ProjectDir).obj\GTASA\Debug\ CLEO+ .cleo diff --git a/CLEOPlus/Colpoint.cpp b/CLEOPlus/Colpoint.cpp index 2593d39..d40ddde 100644 --- a/CLEOPlus/Colpoint.cpp +++ b/CLEOPlus/Colpoint.cpp @@ -78,8 +78,10 @@ OpcodeResult WINAPI GET_COLPOINT_NORMAL_VECTOR(CScriptThread* thread) // SCR: GET_COL_DATA_DEPTH OpcodeResult WINAPI GET_COLPOINT_DEPTH(CScriptThread* thread) { - CColPoint *colPoint = (CColPoint*)CLEO_GetIntOpcodeParam(thread); - CLEO_SetFloatOpcodeParam(thread, colPoint->m_fDepth); + //CColPoint *colPoint = (CColPoint*)CLEO_GetIntOpcodeParam(thread); + //CLEO_SetFloatOpcodeParam(thread, colPoint->m_fDepth); + uint32_t colPoint = CLEO_GetIntOpcodeParam(thread); + CLEO_SetFloatOpcodeParam(thread, *(float*)(colPoint + 0x28)); return OR_CONTINUE; } @@ -88,8 +90,10 @@ OpcodeResult WINAPI GET_COLPOINT_DEPTH(CScriptThread* thread) // SCR: GET_COL_DATA_SURFACE OpcodeResult WINAPI GET_COLPOINT_SURFACE(CScriptThread* thread) { - CColPoint *colPoint = (CColPoint*)CLEO_GetIntOpcodeParam(thread); - CLEO_SetIntOpcodeParam(thread, colPoint->m_nSurfaceTypeB); + //CColPoint *colPoint = (CColPoint*)CLEO_GetIntOpcodeParam(thread); + //CLEO_SetIntOpcodeParam(thread, colPoint->m_nSurfaceTypeB); + uint32_t colPoint = CLEO_GetIntOpcodeParam(thread); + CLEO_SetIntOpcodeParam(thread, *(uint8_t*)(colPoint+0x23)); return OR_CONTINUE; } diff --git a/CLEOPlus/MathRelated.cpp b/CLEOPlus/MathRelated.cpp index 0419ad0..9a6c5c7 100644 --- a/CLEOPlus/MathRelated.cpp +++ b/CLEOPlus/MathRelated.cpp @@ -32,6 +32,9 @@ OpcodeResult WINAPI GET_ANGLE_FROM_TWO_COORDS(CScriptThread* thread) while (result < 0.0) { result += 360.0; } + if (_isnan(result)) { + result = 0.0f; + } CLEO_SetFloatOpcodeParam(thread, result); return OR_CONTINUE; @@ -423,7 +426,11 @@ OpcodeResult WINAPI CLAMP_FLOAT(CScriptThread* thread) float f = CLEO_GetFloatOpcodeParam(thread); float min = CLEO_GetFloatOpcodeParam(thread); float max = CLEO_GetFloatOpcodeParam(thread); - CLEO_SetFloatOpcodeParam(thread, clamp(f, min, max)); + float result = 0.0f; + if (!_isnan(f)) { + result = clamp(f, min, max); + } + CLEO_SetFloatOpcodeParam(thread, result); return OR_CONTINUE; } diff --git a/CLEOPlus/Misc.cpp b/CLEOPlus/Misc.cpp index 287f561..691ef00 100644 --- a/CLEOPlus/Misc.cpp +++ b/CLEOPlus/Misc.cpp @@ -505,8 +505,8 @@ OpcodeResult WINAPI GET_LOCAL_TIME(CScriptThread* thread) // 0D2E=3,set_thread %1d% var %2d% to %3d% // 0D2E: set_thread 0@ var 10 to 10.0 -// SCR: SET_THREAD_VAR -OpcodeResult WINAPI SET_THREAD_VAR(CScriptThread* thread) +// SCR: SET_SCRIPT_VAR +OpcodeResult WINAPI SET_SCRIPT_VAR(CScriptThread* thread) { void *t, *value; unsigned int var; SCRIPT_VAR scrVal; t = (void *)CLEO_GetIntOpcodeParam(thread); @@ -519,8 +519,8 @@ OpcodeResult WINAPI SET_THREAD_VAR(CScriptThread* thread) // 0D2F=3,%3d% = get_thread %1d% var %2d% // 0D2F: 1@ = get_thread 0@ var 10 -// SCR: GET_THREAD_VAR -OpcodeResult WINAPI GET_THREAD_VAR(CScriptThread* thread) +// SCR: GET_SCRIPT_VAR +OpcodeResult WINAPI GET_SCRIPT_VAR(CScriptThread* thread) { void *t; unsigned int var; t = (void *)CLEO_GetIntOpcodeParam(thread); @@ -1472,15 +1472,15 @@ OpcodeResult WINAPI STRING_FIND(CScriptThread* thread) std::string str = CLEO_ReadStringPointerOpcodeParam(thread, bufferA, 128); std::string strFind = CLEO_ReadStringPointerOpcodeParam(thread, bufferB, 128); - size_t found = 0; + size_t found = string::npos; if (mode == 0) { - found = str.find_first_of(strFind); + found = str.find(strFind); } else if (mode == 1) { - found = str.find_last_of(strFind); + found = str.rfind(strFind); } if (found != string::npos) diff --git a/CLEOPlus/RenderObjectOnChar.cpp b/CLEOPlus/RenderObjectOnChar.cpp index 7d65101..f33a8f8 100644 --- a/CLEOPlus/RenderObjectOnChar.cpp +++ b/CLEOPlus/RenderObjectOnChar.cpp @@ -107,9 +107,11 @@ OpcodeResult WINAPI DELETE_RENDER_OBJECT(CScriptThread* thread) OpcodeResult WINAPI SET_RENDER_OBJECT_AUTO_HIDE(CScriptThread* thread) { RenderObject *renderObject = (RenderObject *)CLEO_GetIntOpcodeParam(thread); - renderObject->hideIfDead = CLEO_GetIntOpcodeParam(thread); - renderObject->hideIfWeapon = CLEO_GetIntOpcodeParam(thread); - renderObject->hideIfCar = CLEO_GetIntOpcodeParam(thread); + if (renderObject) { + renderObject->hideIfDead = CLEO_GetIntOpcodeParam(thread); + renderObject->hideIfWeapon = CLEO_GetIntOpcodeParam(thread); + renderObject->hideIfCar = CLEO_GetIntOpcodeParam(thread); + } return OR_CONTINUE; } @@ -128,9 +130,11 @@ OpcodeResult WINAPI SET_RENDER_OBJECT_VISIBLE(CScriptThread* thread) OpcodeResult WINAPI SET_RENDER_OBJECT_POSITION(CScriptThread* thread) { RenderObject *renderObject = (RenderObject *)CLEO_GetIntOpcodeParam(thread); - renderObject->offset.x = CLEO_GetFloatOpcodeParam(thread); - renderObject->offset.y = CLEO_GetFloatOpcodeParam(thread); - renderObject->offset.z = CLEO_GetFloatOpcodeParam(thread); + if (renderObject) { + renderObject->offset.x = CLEO_GetFloatOpcodeParam(thread); + renderObject->offset.y = CLEO_GetFloatOpcodeParam(thread); + renderObject->offset.z = CLEO_GetFloatOpcodeParam(thread); + } return OR_CONTINUE; } @@ -139,9 +143,11 @@ OpcodeResult WINAPI SET_RENDER_OBJECT_POSITION(CScriptThread* thread) OpcodeResult WINAPI SET_RENDER_OBJECT_ROTATION(CScriptThread* thread) { RenderObject *renderObject = (RenderObject *)CLEO_GetIntOpcodeParam(thread); - renderObject->rot.x = CLEO_GetFloatOpcodeParam(thread); - renderObject->rot.y = CLEO_GetFloatOpcodeParam(thread); - renderObject->rot.z = CLEO_GetFloatOpcodeParam(thread); + if (renderObject) { + renderObject->rot.x = CLEO_GetFloatOpcodeParam(thread); + renderObject->rot.y = CLEO_GetFloatOpcodeParam(thread); + renderObject->rot.z = CLEO_GetFloatOpcodeParam(thread); + } return OR_CONTINUE; } @@ -150,9 +156,11 @@ OpcodeResult WINAPI SET_RENDER_OBJECT_ROTATION(CScriptThread* thread) OpcodeResult WINAPI SET_RENDER_OBJECT_SCALE(CScriptThread* thread) { RenderObject *renderObject = (RenderObject *)CLEO_GetIntOpcodeParam(thread); - renderObject->scale.x = CLEO_GetFloatOpcodeParam(thread); - renderObject->scale.y = CLEO_GetFloatOpcodeParam(thread); - renderObject->scale.z = CLEO_GetFloatOpcodeParam(thread); + if (renderObject) { + renderObject->scale.x = CLEO_GetFloatOpcodeParam(thread); + renderObject->scale.y = CLEO_GetFloatOpcodeParam(thread); + renderObject->scale.z = CLEO_GetFloatOpcodeParam(thread); + } return OR_CONTINUE; } @@ -161,9 +169,11 @@ OpcodeResult WINAPI SET_RENDER_OBJECT_SCALE(CScriptThread* thread) OpcodeResult WINAPI SET_RENDER_OBJECT_DISTORTION(CScriptThread* thread) { RenderObject *renderObject = (RenderObject *)CLEO_GetIntOpcodeParam(thread); - renderObject->dist.x = CLEO_GetFloatOpcodeParam(thread); - renderObject->dist.y = CLEO_GetFloatOpcodeParam(thread); - renderObject->dist.z = CLEO_GetFloatOpcodeParam(thread); - renderObject->dist.w = CLEO_GetFloatOpcodeParam(thread); + if (renderObject) { + renderObject->dist.x = CLEO_GetFloatOpcodeParam(thread); + renderObject->dist.y = CLEO_GetFloatOpcodeParam(thread); + renderObject->dist.z = CLEO_GetFloatOpcodeParam(thread); + renderObject->dist.w = CLEO_GetFloatOpcodeParam(thread); + } return OR_CONTINUE; } diff --git a/CLEOPlus/TextDrawer/TextDrawer.cpp b/CLEOPlus/TextDrawer/TextDrawer.cpp index 5df114a..7032950 100644 --- a/CLEOPlus/TextDrawer/TextDrawer.cpp +++ b/CLEOPlus/TextDrawer/TextDrawer.cpp @@ -1,3 +1,4 @@ +#include "CMessages.h" #include "TextDrawer.h" #include "../Screen.h" @@ -5,6 +6,7 @@ TextDrawer textDrawer[DrawEvent::TOTAL_DRAW_EVENT]; void TextDrawer::DrawPrints() { + char finalString[400]; for (auto print : m_aPrints) { float sizX = print->m_fWidth; @@ -52,7 +54,9 @@ void TextDrawer::DrawPrints() case ALIGN_RIGHT: CFont::SetRightJustifyWrap(print->m_fWrap * magicResolutionWidth); break; } - CFont::PrintString(print->m_fX * magicResolutionWidth, print->m_fY * magicResolutionHeight, print->m_text); + CMessages::InsertNumberInString(print->m_text, -1, -1, -1, -1, -1, -1, finalString); // this is required to use InsertPlayerControlKeysInString, idkw + CMessages::InsertPlayerControlKeysInString(finalString); + CFont::PrintString(print->m_fX * magicResolutionWidth, print->m_fY * magicResolutionHeight, finalString); } // clear all