Skip to content

Commit

Permalink
Merge pull request #7 from thelink2012/feature-nogtasa
Browse files Browse the repository at this point in the history
Replace GTASA dependency with plugin-sdk
  • Loading branch information
thelink2012 authored Nov 27, 2016
2 parents 8efc5ba + 6efb399 commit eab7b11
Show file tree
Hide file tree
Showing 8 changed files with 418 additions and 80 deletions.
102 changes: 48 additions & 54 deletions CCustomOpcodeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,17 +334,17 @@ namespace CLEO
inline CRunningScript& operator>>(CRunningScript& thread, CVector& vec)
{
GetScriptParams(&thread, 3);
vec.fX = opcodeParams[0].fParam;
vec.fY = opcodeParams[1].fParam;
vec.fZ = opcodeParams[2].fParam;
vec.x = opcodeParams[0].fParam;
vec.y = opcodeParams[1].fParam;
vec.z = opcodeParams[2].fParam;
return thread;
}

inline CRunningScript& operator<<(CRunningScript& thread, const CVector& vec)
{
opcodeParams[0].fParam = vec.fX;
opcodeParams[1].fParam = vec.fY;
opcodeParams[2].fParam = vec.fZ;
opcodeParams[0].fParam = vec.x;
opcodeParams[1].fParam = vec.y;
opcodeParams[2].fParam = vec.z;
SetScriptParams(&thread, 3);
return thread;
}
Expand Down Expand Up @@ -1016,7 +1016,7 @@ namespace CLEO
{
DWORD handle;
*thread >> handle;
*thread << GetPedPool().GetAt(handle);
*thread << GetPedPool().AtHandle(handle);
return OR_CONTINUE;
}

Expand All @@ -1025,7 +1025,7 @@ namespace CLEO
{
DWORD handle;
*thread >> handle;
*thread << GetVehiclePool().GetAt(handle);
*thread << GetVehiclePool().AtHandle(handle);
return OR_CONTINUE;
}

Expand All @@ -1034,7 +1034,7 @@ namespace CLEO
{
DWORD handle;
*thread >> handle;
*thread << GetObjectPool().GetAt(handle);
*thread << GetObjectPool().AtHandle(handle);
return OR_CONTINUE;
}

Expand Down Expand Up @@ -1643,24 +1643,24 @@ namespace CLEO
{
DWORD actor;
*thread >> actor;
auto pPlayerPed = GetPedPool().GetAt(actor);
auto pPlayerPed = GetPedPool().AtHandle(actor);
CPedIntelligence * pedintel;
if(pPlayerPed && (pedintel = pPlayerPed->GetPedIntelligence()))
if(pPlayerPed && (pedintel = pPlayerPed->m_pIntelligence))
{
CVehicle * pVehicle = nullptr;
for(int i=0; i<NUM_SCAN_ENTITIES; i++)
{
pVehicle = pedintel->m_VehicleScanner.m_pEntities[i];
if(pVehicle && pVehicle->GetOwner() != 2 && !pVehicle->m_nVehicleFlags.bFadeOut)
pVehicle = (CVehicle*) pedintel->m_vehicleScanner.m_apEntities[i];
if(pVehicle && pVehicle->m_nCreatedBy != 2 && !pVehicle->m_nFlags.bFadeOut)
break;
pVehicle = nullptr;
}

CPed * pPed = nullptr;
for(int i=0; i<NUM_SCAN_ENTITIES; i++)
{
pPed = pedintel->m_PedScanner.m_pEntities[i];
if(pPed && pPed != pPlayerPed && pPed->GetOwner() == 1 && !pPed->GetPedFlags().bFadeOut)
pPed = (CPed*) pedintel->m_pedScanner.m_apEntities[i];
if(pPed && pPed != pPlayerPed && (pPed->m_dwUsageType & 0xFF) == 1 && !pPed->m_nPedFlags.bFadeOut)
break;
pPed = nullptr;
}
Expand All @@ -1676,12 +1676,12 @@ namespace CLEO
{
// steam offset is different, so get it manually for now
CGameVersionManager& gvm = GetInstance().VersionManager;
DWORD hMarker = gvm.GetGameVersion() != GV_STEAM ? MenuManager->GetWaypointHandle() : *((DWORD*)0xC3312C);
DWORD hMarker = gvm.GetGameVersion() != GV_STEAM ? MenuManager->m_nTargetBlipIndex : *((DWORD*)0xC3312C);
CMarker *pMarker;
if(hMarker && (pMarker = &RadarBlips[LOWORD(hMarker)]) && /*pMarker->m_nPoolIndex == HIWORD(hMarker) && */pMarker->m_nBlipDisplayFlag)
{
CVector coords(pMarker->m_vCoords);
coords.fZ = FindGroundZ(coords.fX, coords.fY);
CVector coords(pMarker->m_vPosition);
coords.z = FindGroundZ(coords.x, coords.y);
*thread << coords;
SetScriptCondResult(thread, true);
}
Expand All @@ -1699,8 +1699,8 @@ namespace CLEO
{
DWORD hVehicle;
*thread >> hVehicle;
auto id = reinterpret_cast<CVehicleModelInfo*>(Models[GetVehiclePool().GetAt(hVehicle)->GetModelIndex() - 400])->vehicleHandlingID;
*thread << Handling->Automobile[id].m_Transmission.ucNumberOfGears;
auto id = reinterpret_cast<CVehicleModelInfo*>(Models[GetVehiclePool().AtHandle(hVehicle)->m_wModelIndex - 400])->m_wHandlingIndex;
*thread << Handling->m_aVehicleHandling[id].m_transmissionData.m_nNumberOfGears;
return OR_CONTINUE;
}

Expand All @@ -1709,7 +1709,7 @@ namespace CLEO
{
DWORD hVehicle;
*thread >> hVehicle;
*thread << GetVehiclePool().GetAt(hVehicle)->m_nCurrentGear;
*thread << GetVehiclePool().AtHandle(hVehicle)->m_nCurrentGear;
return OR_CONTINUE;
}

Expand Down Expand Up @@ -1759,7 +1759,7 @@ namespace CLEO
{
DWORD hVehicle;
*thread >> hVehicle;
SetScriptCondResult(thread, GetVehiclePool().GetAt(hVehicle)->m_nVehicleFlags.bSirenOrAlarm);
SetScriptCondResult(thread, GetVehiclePool().AtHandle(hVehicle)->m_nFlags.bSirenOrAlarm);
return OR_CONTINUE;
}

Expand All @@ -1768,7 +1768,7 @@ namespace CLEO
{
DWORD hVehicle;
*thread >> hVehicle;
SetScriptCondResult(thread, GetVehiclePool().GetAt(hVehicle)->m_nVehicleFlags.bEngineOn);
SetScriptCondResult(thread, GetVehiclePool().AtHandle(hVehicle)->m_nFlags.bEngineOn);
return OR_CONTINUE;
}

Expand All @@ -1778,8 +1778,8 @@ namespace CLEO
DWORD hVehicle,
state;
*thread >> hVehicle >> state;
auto veh = GetVehiclePool().GetAt(hVehicle);
veh->m_nVehicleFlags.bEngineOn = state != false;
auto veh = GetVehiclePool().AtHandle(hVehicle);
veh->m_nFlags.bEngineOn = state != false;
return OR_CONTINUE;
}

Expand Down Expand Up @@ -1818,7 +1818,7 @@ namespace CLEO
CAudioStream *stream;
DWORD handle;
*thread >> stream >> handle;
if(stream) stream->Link(GetObjectPool().GetAt(handle));
if(stream) stream->Link(GetObjectPool().AtHandle(handle));
return OR_CONTINUE;
}

Expand All @@ -1828,7 +1828,7 @@ namespace CLEO
CAudioStream *stream;
DWORD handle;
*thread >> stream >> handle;
if(stream) stream->Link(GetPedPool().GetAt(handle));
if(stream) stream->Link(GetPedPool().AtHandle(handle));
return OR_CONTINUE;
}

Expand All @@ -1838,7 +1838,7 @@ namespace CLEO
CAudioStream *stream;
DWORD handle;
*thread >> stream >> handle;
if(stream) stream->Link(GetVehiclePool().GetAt(handle));
if(stream) stream->Link(GetVehiclePool().AtHandle(handle));
return OR_CONTINUE;
}

Expand Down Expand Up @@ -1979,9 +1979,9 @@ namespace CLEO
DWORD playerId;
*thread >> playerId;
auto pPlayerPed = GetPlayerPed(playerId);
auto pTargetEntity = pPlayerPed->GetWeaponTarget();
if(!pTargetEntity) pTargetEntity = pPlayerPed->GetManualWeaponTarget();
if(pTargetEntity && pTargetEntity->IsPed())
auto pTargetEntity = GetWeaponTarget(pPlayerPed);
if(!pTargetEntity) pTargetEntity = (CEntity*) pPlayerPed->m_pPlayerTargettedPed;
if(pTargetEntity && pTargetEntity->m_nType == ENTITY_TYPE_PED)
{
*thread << GetPedPool().GetIndex(reinterpret_cast<CPed*>(pTargetEntity));
SetScriptCondResult(thread, true);
Expand Down Expand Up @@ -2149,7 +2149,7 @@ namespace CLEO
auto model = reinterpret_cast<CVehicleModelInfo*>(Models[mi]);
if (*thread->GetBytePointer() >= 1 && *thread->GetBytePointer() <= 8) *thread >> buf;
else buf = (char *)GetScriptParamPointer(thread);
memcpy(buf, model->Name, 8);
memcpy(buf, model->m_szGameName, 8);
return OR_CONTINUE;
}

Expand All @@ -2166,7 +2166,7 @@ namespace CLEO
DWORD mi;
*thread >> mi;
auto model = reinterpret_cast<CVehicleModelInfo*>(Models[mi]);
if(model->VehicleType != VEHICLE_TYPE_TRAIN && model->VehicleType != VEHICLE_TYPE_UNKNOWN) SpawnCar(mi);
if(model->m_dwType != VEHICLE_TYPE_TRAIN && model->m_dwType != VEHICLE_TYPE_UNKNOWN) SpawnCar(mi);
return OR_CONTINUE;
}

Expand Down Expand Up @@ -2207,7 +2207,7 @@ namespace CLEO
float radius;
DWORD next, pass_deads;
static DWORD stat_last_found = 0;
auto pool = GetPedPool();
auto& pool = GetPedPool();
*thread >> center >> radius >> next >> pass_deads;

DWORD& last_found = reinterpret_cast<CCustomScript *>(thread)->IsCustom() ?
Expand All @@ -2216,16 +2216,14 @@ namespace CLEO

if (!next) last_found = 0;

for(int index = last_found; index < pool.GetSize(); ++index)
for(int index = last_found; index < pool.m_Size; ++index)
{
if(!pool.IsValid(index)) continue;

if(auto obj = pool.Get(index))
if(auto obj = pool.GetAt(index))
{
if(obj->IsPlayer() || (pass_deads && !obj->IsAvailable())/* || obj->GetOwner() == 2*/ || obj->PedFlags.bFadeOut)
if(obj->IsPlayer() || (pass_deads && !IsAvailable(obj))/* || obj->GetOwner() == 2*/ || obj->m_nPedFlags.bFadeOut)
continue;

if((obj->GetPos() - center).Length() <= radius)
if((obj->GetPosition() - center).Magnitude() <= radius)
{
last_found = index + 1; // on next opcode call start search from next index
//if(last_found >= (unsigned)pool.GetSize()) last_found = 0;
Expand All @@ -2252,7 +2250,7 @@ namespace CLEO
DWORD next, pass_wrecked;
static DWORD stat_last_found = 0;

auto pool = GetVehiclePool();
auto& pool = GetVehiclePool();
*thread >> center >> radius >> next >> pass_wrecked;

DWORD& last_found = reinterpret_cast<CCustomScript*>(thread)->IsCustom() ?
Expand All @@ -2261,16 +2259,14 @@ namespace CLEO

if (!next) last_found = 0;

for (int index = last_found; index < pool.GetSize(); ++index)
for (int index = last_found; index < pool.m_Size; ++index)
{
if (!pool.IsValid(index)) continue;

if(auto obj = pool.Get(index))
if(auto obj = pool.GetAt(index))
{
if((pass_wrecked && obj->IsWrecked()) || (/*obj->GetOwner() == 2 ||*/ obj->m_nVehicleFlags.bFadeOut))
if((pass_wrecked && IsWrecked(obj)) || (/*obj->GetOwner() == 2 ||*/ obj->m_nFlags.bFadeOut))
continue;

if((obj->GetPos() - center).Length() <= radius)
if((obj->GetPosition() - center).Magnitude() <= radius)
{
last_found = index + 1; // on next opcode call start search from next index
//if(last_found >= (unsigned)pool.GetSize()) last_found = 0;
Expand All @@ -2295,23 +2291,21 @@ namespace CLEO
float radius;
DWORD next;
static DWORD stat_last_found = 0;
auto pool = GetObjectPool();
auto& pool = GetObjectPool();
*thread >> center >> radius >> next;

auto cs = reinterpret_cast<CCustomScript *>(thread);
DWORD& last_found = cs->IsCustom() ? cs->GetLastSearchObject() : stat_last_found;

if(!next) last_found = 0;

for(int index = last_found; index < pool.GetSize(); ++index)
for(int index = last_found; index < pool.m_Size; ++index)
{
if (!pool.IsValid(index)) continue; // empty slot

if(auto obj = pool.Get(index))
if(auto obj = pool.GetAt(index))
{
if(obj->GetFlags().bFadeOut) continue;
if(obj->m_nObjectFlags.bFadingIn) continue; // this is actually .bFadingOut

if((obj->GetPos() - center).Length() <= radius)
if((obj->GetPosition() - center).Magnitude() <= radius)
{
last_found = index + 1; // on next opcode call start search from next index
//if(last_found >= (unsigned)pool.GetSize()) last_found = 0;
Expand Down
1 change: 0 additions & 1 deletion CGameMenu.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "stdafx.h"
#include "StdInc.h"
#include "CGameMenu.h"
#include "cleo.h"
#include "CDebug.h"
Expand Down
4 changes: 2 additions & 2 deletions CScriptEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ namespace CLEO

// steam offset is different, so get it manually for now
CGameVersionManager& gvm = GetInstance().VersionManager;
int nSlot = gvm.GetGameVersion() != GV_STEAM ? MenuManager->GetSaveSlot() : *((BYTE*)MenuManager+0x15B);
int nSlot = gvm.GetGameVersion() != GV_STEAM ? *(BYTE*)&MenuManager->m_bSelectedSaveGame : *((BYTE*)MenuManager+0x15B);

sprintf(safe_name, "./cleo/cleo_saves/cs%d.sav", nSlot);

Expand Down Expand Up @@ -805,7 +805,7 @@ namespace CLEO

// steam offset is different, so get it manually for now
CGameVersionManager& gvm = GetInstance().VersionManager;
int nSlot = gvm.GetGameVersion() != GV_STEAM ? MenuManager->GetSaveSlot() : *((BYTE*)MenuManager+0x15B);
int nSlot = gvm.GetGameVersion() != GV_STEAM ? *(BYTE*)&MenuManager->m_bSelectedSaveGame : *((BYTE*)MenuManager+0x15B);

char safe_name[MAX_PATH];
sprintf(safe_name, "./cleo/cleo_saves/cs%d.sav", nSlot);
Expand Down
19 changes: 9 additions & 10 deletions CSoundSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "bass\bass.h"
#include "CDebug.h"
#include "cleo.h"
#include "CMenuManager.h"
#include <windows.h>

namespace CLEO
Expand Down Expand Up @@ -187,14 +186,14 @@ namespace CLEO
// not in menu
// process camera movements

RwMatrix * pMatrix = nullptr;
RwV3D * pVec = nullptr;
if(camera->matrix)
CMatrixLink * pMatrix = nullptr;
CVector * pVec = nullptr;
if(camera->m_matrix)
{
pMatrix = &camera->matrix->matrix;
pMatrix = camera->m_matrix;
pVec = &pMatrix->pos;
}
else pVec = &camera->m_transform.m_translate;
else pVec = &camera->m_placement.m_vPosn;

BASS_Set3DPosition(
&BASS_3DVECTOR(pVec->y, pVec->z, pVec->x),
Expand Down Expand Up @@ -353,9 +352,9 @@ namespace CLEO

void C3DAudioStream::Set3dPosition(const CVector& pos)
{
position.x = pos.fY;
position.y = pos.fZ;
position.z = pos.fX;
position.x = pos.y;
position.y = pos.z;
position.z = pos.x;
link = nullptr;
BASS_ChannelSet3DPosition(streamInternal, &position, nullptr, nullptr);
}
Expand Down Expand Up @@ -386,7 +385,7 @@ namespace CLEO
{
if (link)
{
RwV3D * pVec = link->matrix ? &link->matrix->matrix.pos : &link->m_transform.m_translate;
CVector * pVec = link->m_matrix ? &link->m_matrix->pos : &link->m_placement.m_vPosn;
BASS_ChannelSet3DPosition(streamInternal, &BASS_3DVECTOR(pVec->y, pVec->z, pVec->x), nullptr, nullptr);
}
else
Expand Down
9 changes: 4 additions & 5 deletions CTextManager.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "stdafx.h"
#include "StdInc.h"

#include "CTextManager.h"
#include "cleo.h"
Expand All @@ -23,7 +22,7 @@ namespace CLEO

char message_buf[0x80];

const char * __fastcall CText__TKey__locate(CText::CKeyArray *key, int dummy, const char *gxt, bool& found)
const char * __fastcall CText__TKey__locate(CText__TKey *key, int dummy, const char *gxt, bool& found)
{
const char * result;
_asm
Expand Down Expand Up @@ -86,13 +85,13 @@ namespace CLEO
szResult = GetInstance().TextManager.LocateFxt(gxt);
if(szResult) return szResult;

szResult = CText__TKey__locate(&text->MainKeys, 0, gxt, bFound);
szResult = CText__TKey__locate(&text->tkeyMain, 0, gxt, bFound);

if(!bFound)
{
if (text->m_bMissionLoaded || *mpackNumber || text->haveTabl)
if (text->missionTableLoaded || *mpackNumber || text->haveTabl)
{
szResult = CText__TKey__locate(&text->MissionKeys, 0, gxt, bFound);
szResult = CText__TKey__locate(&text->tkeyMission, 0, gxt, bFound);
if (!bFound) return "";
//else TRACE("Failed to find used text label '%s'", gxt);
}
Expand Down
Loading

0 comments on commit eab7b11

Please sign in to comment.