Skip to content

Commit

Permalink
Fixed problems with ModLoader support. (#65)
Browse files Browse the repository at this point in the history
* Fixed problems with ModLoader support.

* fixup! Fixed problems with ModLoader support.

* Fixed directories creation in case if CLEO.asi is not placed in game's root.

* Update source/CleoBase.cpp

Co-authored-by: Seemann <[email protected]>

* Update source/CPluginSystem.h

Co-authored-by: Seemann <[email protected]>

* fixup! Update source/CleoBase.cpp

* Name buffers enlarged.

* Review fixes.

---------

Co-authored-by: Seemann <[email protected]>
  • Loading branch information
MiranDMC and x87 authored Feb 26, 2024
1 parent 9228040 commit a2ff5d4
Show file tree
Hide file tree
Showing 13 changed files with 138 additions and 163 deletions.
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>
File renamed without changes.
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
162 changes: 56 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 @@ -28,27 +29,24 @@ class IniFiles
}
}

// resused globals to cut down allocations
static char section[128];
static char key[128];

static OpcodeResult WINAPI Script_InifileGetInt(CScriptThread* thread)
/****************************************************************
Opcode Format
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;

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();
OPCODE_READ_PARAM_STRING_BUFF(section, sizeof(section));
OPCODE_READ_PARAM_STRING_BUFF(key, sizeof(key));

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

OPCODE_WRITE_PARAM_INT(result);
OPCODE_CONDITION_RESULT(result != 0x80000000);
return OR_CONTINUE;
}

Expand All @@ -58,23 +56,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;
auto value = OPCODE_READ_PARAM_INT();
auto path = OPCODE_READ_PARAM_FILEPATH();
OPCODE_READ_PARAM_STRING_BUFF(section, sizeof(section));
OPCODE_READ_PARAM_STRING_BUFF(key, sizeof(key));

value = CLEO_GetIntOpcodeParam(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

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

OPCODE_CONDITION_RESULT(result);
return OR_CONTINUE;
}

Expand All @@ -84,30 +75,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));
auto path = OPCODE_READ_PARAM_FILEPATH();
OPCODE_READ_PARAM_STRING_BUFF(section, sizeof(section));
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);
auto value = 0.0f;
char strValue[32];
auto result = GetPrivateProfileString(section, 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);
return OR_CONTINUE;
}

Expand All @@ -117,25 +101,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();
OPCODE_READ_PARAM_STRING_BUFF(section, sizeof(section));
OPCODE_READ_PARAM_STRING_BUFF(key, sizeof(key));

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

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

OPCODE_CONDITION_RESULT(result);
return OR_CONTINUE;
}

Expand All @@ -145,40 +120,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();
OPCODE_READ_PARAM_STRING_BUFF(section, sizeof(section));
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(section, 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 +144,17 @@ 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));
char strValue[MAX_STR_LEN]; OPCODE_READ_PARAM_STRING_BUFF(strValue, sizeof(strValue));
auto path = OPCODE_READ_PARAM_FILEPATH();
OPCODE_READ_PARAM_STRING_BUFF(section, sizeof(section));
OPCODE_READ_PARAM_STRING_BUFF(key, sizeof(key));

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

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

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

OPCODE_CONDITION_RESULT(result);
return OR_CONTINUE;
}
} iniFiles;

char IniFiles::section[128];
char IniFiles::key[128];
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

0 comments on commit a2ff5d4

Please sign in to comment.