Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed problems with ModLoader support. #65

Merged
merged 8 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ jobs:
@REM copy files
copy source\cleo_config.ini .output\Release\cleo\.cleo_config.ini
copy cleo_plugins\.output\*.cleo .output\Release\cleo\cleo_plugins
copy cleo_plugins\.output\*.cleo5 .output\Release\cleo\cleo_plugins
copy cleo_plugins\.output\*.ini .output\Release\cleo\cleo_plugins
copy cleo_plugins\Audio\bass\bass.dll .output\Release\bass.dll
xcopy /E /I tests\ .output\cleo
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ CLEO requires an 'ASI Loader' installed to run which is provided with the releas
No additional files are replaced, however the following files and folders are added:

- cleo\ (CLEO script directory)
- cleo\cleo_plugins\DebugUtils.cleo (script debug utilities plugin)
- cleo\cleo_plugins\FileSystemOperations.cleo (file system plugin)
- cleo\cleo_plugins\IniFiles.cleo (INI config plugin)
- cleo\cleo_plugins\IntOperations.cleo (INT operations plugin)
- cleo\cleo_plugins\SA.Audio.cleo (audio playback utilities powered by BASS.dll library)
- cleo\cleo_plugins\SA.DebugUtils.cleo (script debugging utilities plugin)
- cleo\cleo_plugins\SA.FileSystemOperations.cleo (disk drive files related operations plugin)
- cleo\cleo_plugins\SA.IniFiles.cleo (.ini config files handling plugin)
- cleo\cleo_plugins\SA.IntOperations.cleo (additional math operations plugin)
- cleo\cleo_plugins\SA.MemoryOperations (memory and .dll libraries utilities plugin)
- cleo\cleo_saves\ (CLEO save directory)
- cleo\cleo_text\ (CLEO text directory)
- cleo.asi (core library)
- bass.dll (audio engine library)
- vorbisHooked.dll (Silent's ASI Loader)
- vorbisFile.dll (Silent's ASI Loader)
- vorbisHooked.dll (original vorbisFile.dll file)

All plugins are optional, however they may be required by various CLEO scripts.

Expand Down
10 changes: 5 additions & 5 deletions cleo_plugins/DebugUtils/DebugUtils.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir).output\</OutDir>
<IntDir>$(ProjectDir).obj\$(Configuration)\</IntDir>
<TargetName>DebugUtils</TargetName>
<TargetExt>.cleo5</TargetExt>
<TargetName>SA.DebugUtils</TargetName>
<TargetExt>.cleo</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir).output\</OutDir>
<IntDir>$(ProjectDir).obj\$(Configuration)\</IntDir>
<TargetName>DebugUtils</TargetName>
<TargetExt>.cleo5</TargetExt>
<TargetName>SA.DebugUtils</TargetName>
<TargetExt>.cleo</TargetExt>
</PropertyGroup>
<PropertyGroup>
<LocalDebuggerCommand>$(GTA_SA_DIR)\gta_sa.exe</LocalDebuggerCommand>
Expand Down Expand Up @@ -132,7 +132,7 @@ xcopy /Y "$(OutDir)$(TargetName).*" "$(GTA_SA_DIR)\cleo\cleo_plugins\"
<ClInclude Include="ScreenLog.h" />
</ItemGroup>
<ItemGroup>
<None Include="DebugUtils.ini" />
<None Include="SA.DebugUtils.ini" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
2 changes: 1 addition & 1 deletion cleo_plugins/DebugUtils/DebugUtils.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="DebugUtils.ini" />
<None Include="SA.DebugUtils.ini" />
</ItemGroup>
</Project>
16 changes: 10 additions & 6 deletions cleo_plugins/FileSystemOperations/FileSystemOperations.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir).output\</OutDir>
<IntDir>$(ProjectDir).obj\$(Configuration)\</IntDir>
<TargetName>FileSystemOperations</TargetName>
<TargetExt>.cleo5</TargetExt>
<TargetName>SA.FileSystemOperations</TargetName>
<TargetExt>.cleo</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir).output\</OutDir>
<IntDir>$(ProjectDir).obj\$(Configuration)\</IntDir>
<TargetName>FileSystemOperations</TargetName>
<TargetExt>.cleo5</TargetExt>
<TargetName>SA.FileSystemOperations</TargetName>
<TargetExt>.cleo</TargetExt>
</PropertyGroup>
<PropertyGroup>
<LocalDebuggerCommand>$(GTA_SA_DIR)\gta_sa.exe</LocalDebuggerCommand>
Expand Down Expand Up @@ -83,7 +83,9 @@
</Link>
<PostBuildEvent>
<Command>taskkill /IM gta_sa.exe /F /FI "STATUS eq RUNNING"
xcopy /Y "$(OutDir)$(TargetName).*" "$(GTA_SA_DIR)\cleo\cleo_plugins\" </Command>
if defined GTA_SA_DIR (
xcopy /Y "$(OutDir)$(TargetName).*" "$(GTA_SA_DIR)\cleo\cleo_plugins\"
)</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
Expand All @@ -106,7 +108,9 @@ xcopy /Y "$(OutDir)$(TargetName).*" "$(GTA_SA_DIR)\cleo\cleo_plugins\" </Command
</Link>
<PostBuildEvent>
<Command>taskkill /IM gta_sa.exe /F /FI "STATUS eq RUNNING"
xcopy /Y "$(OutDir)$(TargetName).*" "$(GTA_SA_DIR)\cleo\cleo_plugins\" </Command>
if defined GTA_SA_DIR (
xcopy /Y "$(OutDir)$(TargetName).*" "$(GTA_SA_DIR)\cleo\cleo_plugins\"
)</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
155 changes: 49 additions & 106 deletions cleo_plugins/IniFiles/IniFiles.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <cstdio>
#include "CLEO.h"
#include "CLEO_Utils.h"
#include <string>

using namespace CLEO;
Expand Down Expand Up @@ -34,21 +35,14 @@ class IniFiles
0AF0=4,%4d% = get_int_from_ini_file %1s% section %2s% key %3s%
****************************************************************/
{
char path[MAX_PATH];
char sectionName[100];
char key[100];
int result;
auto path = OPCODE_READ_PARAM_FILEPATH();
char sectionName[64]; OPCODE_READ_PARAM_STRING_BUFF(sectionName, sizeof(sectionName));
char key[64]; OPCODE_READ_PARAM_STRING_BUFF(key, sizeof(key));
x87 marked this conversation as resolved.
Show resolved Hide resolved

CLEO_ReadStringPointerOpcodeParam(thread, path, sizeof(path));
CLEO_ReadStringPointerOpcodeParam(thread, sectionName, sizeof(sectionName));
CLEO_ReadStringPointerOpcodeParam(thread, key, sizeof(key));

CLEO_ResolvePath(thread, path, sizeof(path)); // convert to absolute path

result = GetPrivateProfileInt(sectionName, key, 0x80000000, path);
CLEO_SetIntOpcodeParam(thread, result);
CLEO_SetThreadCondResult(thread, result != 0x80000000);
auto result = GetPrivateProfileInt(sectionName, key, 0x80000000, path);

OPCODE_WRITE_PARAM_INT(result);
OPCODE_CONDITION_RESULT(result != 0x80000000);
x87 marked this conversation as resolved.
Show resolved Hide resolved
return OR_CONTINUE;
}

Expand All @@ -58,23 +52,16 @@ class IniFiles
0AF1=4,write_int %1d% to_ini_file %2s% section %3s% key %4s%
****************************************************************/
{
char path[MAX_PATH];
char sectionName[100];
char key[100];
DWORD value;
char strValue[100];
BOOL result;

value = CLEO_GetIntOpcodeParam(thread);
CLEO_ReadStringPointerOpcodeParam(thread, path, sizeof(path));
CLEO_ReadStringPointerOpcodeParam(thread, sectionName, sizeof(sectionName));
CLEO_ReadStringPointerOpcodeParam(thread, key, sizeof(key));
auto value = OPCODE_READ_PARAM_INT();
auto path = OPCODE_READ_PARAM_FILEPATH();
char sectionName[64]; OPCODE_READ_PARAM_STRING_BUFF(sectionName, sizeof(sectionName));
char key[64]; OPCODE_READ_PARAM_STRING_BUFF(key, sizeof(key));

CLEO_ResolvePath(thread, path, sizeof(path)); // convert to absolute path

result = WritePrivateProfileString(sectionName, key, _itoa(value, strValue, 10), path);
CLEO_SetThreadCondResult(thread, result);
char strValue[32];
_itoa(value, strValue, 10);
auto result = WritePrivateProfileString(sectionName, key, strValue, path);

OPCODE_CONDITION_RESULT(result);
return OR_CONTINUE;
}

Expand All @@ -84,30 +71,23 @@ class IniFiles
0AF2=4,%4d% = get_float_from_ini_file %1s% section %2s% key %3s%
****************************************************************/
{
char path[MAX_PATH];
char sectionName[100];
char key[100];
float value = 0.0f;
char strValue[100];
BOOL result;

CLEO_ReadStringPointerOpcodeParam(thread, path, sizeof(path));
CLEO_ReadStringPointerOpcodeParam(thread, sectionName, sizeof(sectionName));
CLEO_ReadStringPointerOpcodeParam(thread, key, sizeof(key));

CLEO_ResolvePath(thread, path, sizeof(path)); // convert to absolute path
auto path = OPCODE_READ_PARAM_FILEPATH();
char sectionName[64]; OPCODE_READ_PARAM_STRING_BUFF(sectionName, sizeof(sectionName));
char key[64]; OPCODE_READ_PARAM_STRING_BUFF(key, sizeof(key));

result = GetPrivateProfileString(sectionName, key, NULL, strValue, sizeof(strValue), path);
auto value = 0.0f;
char strValue[32];
auto result = GetPrivateProfileString(sectionName, key, NULL, strValue, sizeof(strValue), path);
if (result)
{
value = (float)atof(strValue);
CLEO_SetFloatOpcodeParam(thread, value);
OPCODE_WRITE_PARAM_FLOAT(value);
}
else
CLEO_SkipOpcodeParams(thread, 1);

CLEO_SetThreadCondResult(thread, result);

{
OPCODE_SKIP_PARAMS(1);
}
OPCODE_CONDITION_RESULT(result);
x87 marked this conversation as resolved.
Show resolved Hide resolved
return OR_CONTINUE;
}

Expand All @@ -117,25 +97,16 @@ class IniFiles
0AF3=4,write_float %1d% to_ini_file %2s% section %3s% key %4s%
****************************************************************/
{
char path[MAX_PATH];
char sectionName[100];
char key[100];
float value;
char strValue[100];
BOOL result;

value = CLEO_GetFloatOpcodeParam(thread);
CLEO_ReadStringPointerOpcodeParam(thread, path, sizeof(path));
CLEO_ReadStringPointerOpcodeParam(thread, sectionName, sizeof(sectionName));
CLEO_ReadStringPointerOpcodeParam(thread, key, sizeof(key));

CLEO_ResolvePath(thread, path, sizeof(path)); // convert to absolute path
auto value = OPCODE_READ_PARAM_FLOAT();
auto path = OPCODE_READ_PARAM_FILEPATH();
char sectionName[64]; OPCODE_READ_PARAM_STRING_BUFF(sectionName, sizeof(sectionName));
char key[64]; OPCODE_READ_PARAM_STRING_BUFF(key, sizeof(key));

char strValue[32];
sprintf(strValue, "%g", value);
auto result = WritePrivateProfileString(sectionName, key, strValue, path);

result = WritePrivateProfileString(sectionName, key, strValue, path);
CLEO_SetThreadCondResult(thread, result);

OPCODE_CONDITION_RESULT(result);
return OR_CONTINUE;
}

Expand All @@ -145,40 +116,21 @@ class IniFiles
0AF4=4,%4d% = read_string_from_ini_file %1s% section %2s% key %3s%
****************************************************************/
{
char path[MAX_PATH];
char sectionName[100];
char key[100];
char strValue[100];
char *strptr;
BOOL result;

CLEO_ReadStringPointerOpcodeParam(thread, path, sizeof(path));
CLEO_ReadStringPointerOpcodeParam(thread, sectionName, sizeof(sectionName));
CLEO_ReadStringPointerOpcodeParam(thread, key, sizeof(key));
auto path = OPCODE_READ_PARAM_FILEPATH();
char sectionName[64]; OPCODE_READ_PARAM_STRING_BUFF(sectionName, sizeof(sectionName));
char key[64]; OPCODE_READ_PARAM_STRING_BUFF(key, sizeof(key));

CLEO_ResolvePath(thread, path, sizeof(path)); // convert to absolute path

result = GetPrivateProfileString(sectionName, key, NULL, strValue, sizeof(strValue), path);
char strValue[MAX_STR_LEN];
auto result = GetPrivateProfileString(sectionName, key, NULL, strValue, sizeof(strValue), path);
if (result)
{
switch (CLEO_GetOperandType(thread))
{
case DT_VAR_STRING:
case DT_LVAR_STRING:
case DT_VAR_TEXTLABEL:
case DT_LVAR_TEXTLABEL:
CLEO_WriteStringOpcodeParam(thread, strValue);
break;
default:
strptr = (char *)CLEO_GetIntOpcodeParam(thread);
strcpy(strptr, strValue);
}
OPCODE_WRITE_PARAM_STRING(strValue);
}
else
CLEO_SkipOpcodeParams(thread, 1);

CLEO_SetThreadCondResult(thread, result);

{
OPCODE_SKIP_PARAMS(1);
}
OPCODE_CONDITION_RESULT(result);
return OR_CONTINUE;
}

Expand All @@ -188,23 +140,14 @@ class IniFiles
0AF5=4,write_string %1s% to_ini_file %2s% section %3s% key %4s%
****************************************************************/
{
char path[MAX_PATH];
char sectionName[100];
char key[100];
char strValue[100];
BOOL result;

CLEO_ReadStringPointerOpcodeParam(thread, strValue, sizeof(strValue));
CLEO_ReadStringPointerOpcodeParam(thread, path, sizeof(path));
CLEO_ReadStringPointerOpcodeParam(thread, sectionName, sizeof(sectionName));
CLEO_ReadStringPointerOpcodeParam(thread, key, sizeof(key));

CLEO_ResolvePath(thread, path, sizeof(path)); // convert to absolute path

result = WritePrivateProfileString(sectionName, key, strValue, path);
char strValue[MAX_STR_LEN]; OPCODE_READ_PARAM_STRING_BUFF(strValue, sizeof(strValue));
auto path = OPCODE_READ_PARAM_FILEPATH();
char sectionName[64]; OPCODE_READ_PARAM_STRING_BUFF(sectionName, sizeof(sectionName));
char key[64]; OPCODE_READ_PARAM_STRING_BUFF(key, sizeof(key));

CLEO_SetThreadCondResult(thread, result);
auto result = WritePrivateProfileString(sectionName, key, strValue, path);

OPCODE_CONDITION_RESULT(result);
return OR_CONTINUE;
}
} iniFiles;
8 changes: 4 additions & 4 deletions cleo_plugins/IniFiles/IniFiles.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir).output\</OutDir>
<IntDir>$(ProjectDir).obj\$(Configuration)\</IntDir>
<TargetName>IniFiles</TargetName>
<TargetExt>.cleo5</TargetExt>
<TargetName>SA.IniFiles</TargetName>
<TargetExt>.cleo</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir).output\</OutDir>
<IntDir>$(ProjectDir).obj\$(Configuration)\</IntDir>
<TargetName>IniFiles</TargetName>
<TargetExt>.cleo5</TargetExt>
<TargetName>SA.IniFiles</TargetName>
<TargetExt>.cleo</TargetExt>
</PropertyGroup>
<PropertyGroup>
<LocalDebuggerCommand>$(GTA_SA_DIR)\gta_sa.exe</LocalDebuggerCommand>
Expand Down
8 changes: 4 additions & 4 deletions cleo_plugins/IntOperations/IntOperations.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir).output\</OutDir>
<IntDir>$(ProjectDir).obj\$(Configuration)\</IntDir>
<TargetName>IntOperations</TargetName>
<TargetExt>.cleo5</TargetExt>
<TargetName>SA.IntOperations</TargetName>
<TargetExt>.cleo</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir).output\</OutDir>
<IntDir>$(ProjectDir).obj\$(Configuration)\</IntDir>
<TargetName>IntOperations</TargetName>
<TargetExt>.cleo5</TargetExt>
<TargetName>SA.IntOperations</TargetName>
<TargetExt>.cleo</TargetExt>
</PropertyGroup>
<PropertyGroup>
<LocalDebuggerCommand>$(GTA_SA_DIR)\gta_sa.exe</LocalDebuggerCommand>
Expand Down
Loading