Jump to content

[CLEO SDK] thread unambiguous identifier


Recommended Posts

It's known, that CScriptThread::threadName can be used as unique identifier - it tell us which script the plugin is communicating to. The only problem is that threadName is a string. It's easier and faster to work with integers than with char arrays. My question is... maybe there is an integer parameter inside CScriptThread structure, that tells us unambiguously, which script the plugin is communicating to?

Edited by gokuta
Link to comment
https://gtaforums.com/topic/759187-cleo-sdk-thread-unambiguous-identifier/
Share on other sites

There's not afaik. When sticking to non-CLEO scripts, you could extract script's index in the scripts array by doing simple pointer arithmetic, but I don't think one is allowed to do any math on CLEO script pointers.

 

Also, CRunningScript.

Edited by Silent

 

you could extract script's index in the scripts array by doing simple pointer arithmetic, but I don't think one is allowed to do any math on CLEO script pointers.

 

Not really sure what you mean by that :S Some quick example would be much appreciated

 

 

Also, CRunningScript.

 

Maybe CScriptThread is not the right way to say it, but that's the way it's declared in CLEO.h. Deji should consider renaming it in the next CLEO release

Edited by gokuta

No, there's no problem if you call it as CScriptThread.

Also, there must be something like unique id inside CLEO script struct. I remember it is related to script size somehow.

Edited by DK22Pac

Not really sure what you mean by that :S Some quick example would be much appreciated

 

ptrdiff_t CTheScripts::GetScriptIndexFromPointer(CRunningScript* pScript){	return pScript - ScriptsArray;}

As mentioned the thread name is not really unique, usually the thread must be made to accept communication (i.e. have a script name that may not be ambiguous with another thread), examples of conflicts:

  • Two cleos scripts that have the same starting 7 letters
  • Two scm scripts that didn't set it's thread name

The best you can do indeed, depending on what you are supposed to do with this unique identifier, is to do what Silent said, but if you need the unique identifier to persist between different game runs, you are out of luck, for this case you could take a hash/checksum of the script (as CLEO does to save it's state in CLEO_SAVES) but you are unable to do so since CLEO SDK do not expose neither the checksum of the script nor the length of it so you could do it manually.

 

No, there's no problem if you call it as CScriptThread.
Also, there must be something like unique id inside CLEO script struct. I remember it is related to script size somehow.

Yeah, it's a checksum, but it is not exposed through the CLEO SDK :(

A CRC of an entire CLEO script could do then, probably? If only CKeyGen supports this.

 

EDIT:

Yep, although it's supposed to take a string as an argument, one of the overloads doesn't terminate on null terminator so should be just fine to use.

Edited by Silent

A CRC of an entire CLEO script could do then, probably? If only CKeyGen supports this.

 

EDIT:

Yep, although it's supposed to take a string as an argument, one of the overloads doesn't terminate on null terminator so should be just fine to use.

Nope, you don't have the lenght of the script so you'd not know how many bytes from base_ip to hash.

Edited by LINK/2012

uh yeah, for some reason been thinking of it as hashing the script by itself, from CLEO level. Not from the SDK level.

 

The best you can do indeed, depending on what you are supposed to do with this unique identifier, is to do what Silent said, but if you need the unique identifier to persist between different game runs <...>

Those identifiers need to persist during the same run. They can be different during another run in my case. What kind of class is CTheScripts huh? Didn't notice it in CLEO SDK.

Edited by gokuta

 

CTheScripts::AddScriptCheckpoint(float,float,float,float,float,float,float,int) .text 002DFF40 000000E2 00000078 00000010 R . . . B T .CTheScripts::AddScriptEffectSystem(FxSystem_c *) .text 002DF1E0 0000003E 00000010 00000000 R . . . B . .CTheScripts::AddScriptSearchLight(float,float,float,CEntity *,float,float,float,float,float) .text 002DF254 0000017C 00000038 00000014 R . . . B T .CTheScripts::AddScriptSphere(uint,CVector,float) .text 002CEBD4 0000006E 00000028 00000004 R . . . B T .CTheScripts::AddToBuildingSwapArray(CBuilding *,int,int) .text 002CEC7C 000000D4 00000018 00000000 R . . . B . .CTheScripts::AddToInvisibilitySwapArray(CEntity *,bool) .text 002D08B4 0000008A 00000010 00000000 R . . . B . .CTheScripts::AddToListOfConnectedLodObjects(CObject *,CObject *) .text 002BEB48 0000008C 00000014 00000000 R . . . B . .CTheScripts::AddToListOfSpecialAnimGroupsAttachedToCharModels(int,char *) .text 002C237C 00000070 00000020 00000000 R . . . B . .CTheScripts::AddToSuppressedCarModelArray(int) .text 002B94C8 00000042 00000018 00000000 R . . . B . .CTheScripts::AddToSwitchJumpTable(int,int) .text 002BE664 00000026 0000000C 00000000 R . . . B . .CTheScripts::AddToVehicleModelsBlockedByScript(int) .text 002B95A4 00000042 00000018 00000000 R . . . B . .CTheScripts::AddToWaitingForScriptBrainArray(CEntity *,short) .text 002B9928 00000052 00000018 00000000 R . . . B . .CTheScripts::AttachSearchlightToSearchlightObject(int,CObject *,CObject *,CObject *,float,float,float) .text 002DF83C 000000BE 00000030 0000000C R . . . B T .CTheScripts::CheckScriptVersion(int,char *) .text 002B688C 0000000C 00000004 00000000 R . . . B . .CTheScripts::CheckStreamedScriptVersion(RwStream *,char *) .text 002B71A0 0000000C 00000004 00000000 R . . . B . .CTheScripts::CleanUpThisObject(CObject *) .text 002D64B8 00000054 00000010 00000000 R . . . B . .CTheScripts::CleanUpThisPed(CPed *) .text 002D6204 0000024C 00000038 FFFFFFD4 R . . . B . .CTheScripts::CleanUpThisVehicle(CVehicle *) .text 002D6468 0000004E 00000010 00000000 R . . . B . .CTheScripts::ClearAllSuppressedCarModels(void) .text 002B9434 00000022 00000004 00000000 R . . . B . .CTheScripts::ClearAllVehicleModelsBlockedByScript(void) .text 002B9514 00000022 00000004 00000000 R . . . B . .CTheScripts::ClearSpaceForMissionEntity(CVector const&,CEntity *) .text 002D3540 0000023C 000000A8 FFFFFF90 R . . . B . .CTheScripts::DoScriptSetupAfterPoolsHaveLoaded(void) .text 003EA414 00000028 00000010 00000000 R . . . B . .CTheScripts::DrawDebugAngledCube(float,float,float,float,float,float,float,float,float,float) .text 002D2F18 00000162 00000048 00000018 R . . . B . .CTheScripts::DrawDebugAngledSquare(float,float,float,float,float,float,float,float) .text 002D31D4 000001A6 000000B8 00000010 R . . . B T .CTheScripts::DrawDebugCube(float,float,float,float,float,float) .text 002D3084 00000148 00000038 00000008 R . . . B . .CTheScripts::DrawDebugSquare(float,float,float,float) .text 002D3388 0000019E 000000B0 FFFFFFB0 R . . . B . .CTheScripts::DrawScriptSpheres(void) .text 002CEB40 00000086 00000050 00000000 R . . . B . .CTheScripts::DrawScriptSpritesAndRectangles(uchar) .text 002B48B8 0000024C 00000078 FFFFFFC0 R . . . B . .CTheScripts::GetActualScriptThingIndex(int,uchar) .text 002CE9D4 00000132 00000020 00000000 R . . . B . .CTheScripts::GetNewUniqueScriptThingIndex(int,uchar) .text 002CE80C 0000019C 00000018 00000000 R . . . B . .CTheScripts::GetScriptIndexFromPointer(CRunningScript *) .text 002B4D18 00000018 00000004 00000000 R . . . B . .CTheScripts::GetUniqueScriptThingIndex(int,uchar) .text 002CE7A4 00000058 00000018 00000000 R . . . B . .CTheScripts::HasCarModelBeenSuppressed(int) .text 002B9494 0000002A 00000004 00000000 R . . . B . .CTheScripts::HasVehicleModelBeenBlockedByScript(int) .text 002B9574 00000028 00000004 00000000 R . . . B . .CTheScripts::HighlightImportantAngledArea(uint,float,float,float,float,float,float,float,float,float) .text 002D4518 000001B6 00000040 00000018 R . . . B T .CTheScripts::HighlightImportantArea(uint,float,float,float,float,float) .text 002D378C 000000D8 00000040 00000008 R . . . B T .CTheScripts::Init(void) .text 002B6898 000008D4 00000060 FFFFFFC8 R . . . B . .CTheScripts::InitialiseAllConnectLodObjects(void) .text 002BEB30 00000016 00000010 00000000 R . . . B . .CTheScripts::InitialiseConnectLodObjects(ushort) .text 002BEB08 00000020 00000004 00000000 R . . . B . .CTheScripts::InitialiseSpecialAnimGroup(ushort) .text 002C2338 00000024 00000008 00000000 R . . . B . .CTheScripts::InitialiseSpecialAnimGroupsAttachedToCharModels(void) .text 002C2364 00000016 00000010 00000000 R . . . B . .CTheScripts::IsEntityWithinAnySearchLight(CEntity *,int *) .text 002DF62C 00000076 00000030 00000000 R . . . B . .CTheScripts::IsEntityWithinSearchLight(int,CEntity *) .text 002DF5EC 00000040 00000020 00000000 R . . . B . .CTheScripts::IsPedStopped(CPed *) .text 002D4F24 000000C8 00000010 00000000 R . . . B . .CTheScripts::IsPlayerOnAMission(void) .text 002B4D54 00000022 00000004 00000000 R . . . B . .CTheScripts::IsPointWithinSearchLight(CVector &,int) .text 002DF508 000000DA 00000040 FFFFFFD8 R . . . B . .CTheScripts::IsVehicleStopped(CVehicle *) .text 002D5BBC 00000046 00000004 00000000 R . . . B . .CTheScripts::Load(void) .text 003E9EDC 000004C0 00000070 00000000 R . . . B . .CTheScripts::LoadAfter(void) .text 003E9E14 000000BA 00000020 FFFFFFE8 R . . . B . .CTheScripts::MoveSearchLightBetweenTwoPoints(int,float,float,float,float,float,float,float) .text 002DF6AC 000000A6 00000028 00000010 R . . . B T .CTheScripts::MoveSearchLightToEntity(int,CEntity *,float) .text 002DF75C 00000068 00000018 00000000 R . . . B . .CTheScripts::MoveSearchLightToPointAndStop(int,float,float,float,float) .text 002DF7D0 00000060 00000020 00000004 R . . . B T .CTheScripts::PrintListSizes(void) .text 002B468C 00000022 00000004 00000000 R . . . B . .CTheScripts::Process(void) .text 002B5220 00000468 00000468 FFFFFFC0 R . . . B . .CTheScripts::ProcessAllSearchLights(void) .text 002DF904 00000462 00000048 FFFFFFC8 R . . . B . .CTheScripts::ProcessWaitingForScriptBrainArray(void) .text 002B9D48 000000C4 00000048 FFFFFFC8 R . . . B . .CTheScripts::ReadMultiScriptFileOffsetsFromScript(void) .text 002D65DC 0000007E 0000001C 00000000 R . . . B . .CTheScripts::ReadObjectNamesFromScript(void) .text 002D6518 00000066 00000014 00000000 R . . . B . .CTheScripts::ReinitialiseSwitchStatementData(void) .text 002BE61C 0000002E 00000010 00000000 R . . . B . .CTheScripts::RemoveFromSuppressedCarModelArray(int) .text 002B9460 0000002A 00000008 00000000 R . . . B . .CTheScripts::RemoveFromVehicleModelsBlockedByScript(int) .text 002B9540 0000002A 00000008 00000000 R . . . B . .CTheScripts::RemoveFromWaitingForScriptBrainArray(CEntity *,short) .text 002B9984 000000B0 00000028 00000000 R . . . B . .CTheScripts::RemoveScriptCheckpoint(int) .text 002E0034 0000003E 00000018 00000000 R . . . B . .CTheScripts::RemoveScriptEffectSystem(int) .text 002DF228 00000024 00000010 00000000 R . . . B . .CTheScripts::RemoveScriptSearchLight(int) .text 002DF3E0 00000118 00000028 00000000 R . . . B . .CTheScripts::RemoveScriptSphere(int) .text 002CEC4C 00000026 00000010 00000000 R . . . B . .CTheScripts::RemoveScriptTextureDictionary(void) .text 002B4858 00000050 00000018 00000000 R . . . B . .CTheScripts::RemoveThisPed(CPed *) .text 002D6160 0000009C 00000018 00000000 R . . . B . .CTheScripts::RenderAllSearchLights(void) .text 002DFD68 000001CA 00000098 FFFFFFD0 R . . . B . .CTheScripts::RenderTheScriptDebugLines(void) .text 002D3534 0000000A 00000004 00000000 R . . . B . .CTheScripts::Save(void) .text 003E9950 0000043C 00000078 FFFFFFD8 R . . . B . .CTheScripts::SaveAfter(void) .text 003E9874 000000D0 00000020 FFFFFFE8 R . . . B . .CTheScripts::ScriptAttachAnimGroupToCharModel(int,char *) .text 002C23F4 00000040 00000018 00000000 R . . . B . .CTheScripts::ScriptConnectLodsFunction(int,int) .text 002BEBE0 0000005E 00000010 00000000 R . . . B . .CTheScripts::ScriptDebugCircle2D(float,float,float,float,int) .text 002D2D3C 000001B6 00000098 00000004 R . . . B . .CTheScripts::ScriptDebugLine3D(float,float,float,float,float,float,uint,uint) .text 002D2F0C 0000000A 00000004 00000000 R . . . B . .CTheScripts::StartNewScript(uchar *) .text 002B4C78 00000032 00000018 00000000 R . . . B . .CTheScripts::StartNewScript(uchar *,ushort) .text 002B4CB8 00000050 00000018 00000000 R . . . B . .CTheScripts::StartTestScript(void) .text 002B4D38 00000014 00000004 00000000 R . . . B . .CTheScripts::UndoBuildingSwaps(void) .text 002D2B1C 00000040 00000020 00000000 R . . . B . .CTheScripts::UndoEntityInvisibilitySettings(void) .text 002D2B64 0000003A 00000008 00000000 R . . . B . .CTheScripts::UpdateObjectIndices(void) .text 002D6590 00000040 00000018 00000000 R . . . B . .CTheScripts::UseSwitchJumpTable(int *) .text 002BE698 00000094 00000014 00000000 R . . . B . .CTheScripts::WipeLocalVariableMemoryForMissionScript(void) .text 002B4B14 00000022 00000004 00000000 R . . . B . .

It's not included in CLEO SDK. Such functions exist in game executable.

Edited by fastman92

It's not included in CLEO SDK. Such functions exist in game executable.

 

Silent is offering to me to use this smart function:

 

 

ptrdiff_t CTheScripts::GetScriptIndexFromPointer(CRunningScript* pScript)

{

return pScript - ScriptsArray;

}

 

But well, I have no idea how on Earth I can implement this on my CLEO plugin :O

Edited by gokuta

oh well, it wouldn't work for CLEO scripts anyway, they aren't allocated on the ScriptsArray but CLEO.asi heap.

But in any case, you'd declare ScriptsArray as

CRunningScript* ScriptsArray = (CRunningScript*) 0xA8B430;
Edited by LINK/2012

It'd still give some sort of an index... but hell knows what.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 0 User Currently Viewing
    0 members, 0 Anonymous, 0 Guests

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.