summaryrefslogtreecommitdiff
path: root/src/control/Script5.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/control/Script5.cpp')
-rw-r--r--src/control/Script5.cpp651
1 files changed, 349 insertions, 302 deletions
diff --git a/src/control/Script5.cpp b/src/control/Script5.cpp
index e9f0967e..45952497 100644
--- a/src/control/Script5.cpp
+++ b/src/control/Script5.cpp
@@ -19,32 +19,20 @@
#include "main.h"
#include "SaveBuf.h"
-void CRunningScript::UpdateCompareFlag(bool flag)
+// LCS: file done except TODOs
+
+uint32 CRunningScript::CollectLocateParameters(uint32* pIp, bool b3D)
{
- if (m_bNotFlag)
- flag = !flag;
- if (m_nAndOrState == ANDOR_NONE) {
- m_bCondResult = flag;
- return;
- }
- if (m_nAndOrState >= ANDS_1 && m_nAndOrState <= ANDS_8) {
- m_bCondResult &= flag;
- if (m_nAndOrState == ANDS_1) {
- m_nAndOrState = ANDOR_NONE;
- return;
- }
- }
- else if (m_nAndOrState >= ORS_1 && m_nAndOrState <= ORS_8) {
- m_bCondResult |= flag;
- if (m_nAndOrState == ORS_1) {
- m_nAndOrState = ANDOR_NONE;
- return;
- }
- }
- else {
- return;
- }
- m_nAndOrState--;
+ CollectParameters(pIp, 1);
+ uint32 id = (uintptr)this + (*pIp - 16);
+ uint32 ip = *pIp;
+ uint8 type = CTheScripts::Read1ByteFromScript(&ip);
+ if (type >= ARGUMENT_LOCAL) {
+ ip--;
+ id = (uint32)(uintptr)GetPointerToScriptVariable(&ip, 0);
+ }
+ CollectParameters(pIp, b3D ? 7 : 5, &(ScriptParams[1]));
+ return id;
}
void CRunningScript::LocatePlayerCommand(int32 command, uint32* pIp)
@@ -64,8 +52,8 @@ void CRunningScript::LocatePlayerCommand(int32 command, uint32* pIp)
b3D = false;
break;
}
- CollectParameters(pIp, b3D ? 8 : 6);
- CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]];
+ uint32 id = CollectLocateParameters(pIp, b3D);
+ CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)];
switch (command) {
case COMMAND_LOCATE_STOPPED_PLAYER_ANY_MEANS_2D:
case COMMAND_LOCATE_STOPPED_PLAYER_ANY_MEANS_3D:
@@ -81,37 +69,23 @@ void CRunningScript::LocatePlayerCommand(int32 command, uint32* pIp)
default:
break;
}
- X = *(float*)&ScriptParams[1];
- Y = *(float*)&ScriptParams[2];
+ X = GET_FLOAT_PARAM(1);
+ Y = GET_FLOAT_PARAM(2);
if (b3D) {
- Z = *(float*)&ScriptParams[3];
- dX = *(float*)&ScriptParams[4];
- dY = *(float*)&ScriptParams[5];
- dZ = *(float*)&ScriptParams[6];
- debug = ScriptParams[7];
+ Z = GET_FLOAT_PARAM(3);
+ dX = GET_FLOAT_PARAM(4);
+ dY = GET_FLOAT_PARAM(5);
+ dZ = GET_FLOAT_PARAM(6);
+ debug = GET_INTEGER_PARAM(7);
} else {
- dX = *(float*)&ScriptParams[3];
- dY = *(float*)&ScriptParams[4];
- debug = ScriptParams[5];
+ dX = GET_FLOAT_PARAM(3);
+ dY = GET_FLOAT_PARAM(4);
+ debug = GET_INTEGER_PARAM(5);
}
+ CVector pos = pPlayerInfo->GetPos();
if (!decided) {
- CVector pos = pPlayerInfo->GetPos();
result = false;
- bool in_area;
- if (b3D) {
- in_area = X - dX <= pos.x &&
- X + dX >= pos.x &&
- Y - dY <= pos.y &&
- Y + dY >= pos.y &&
- Z - dZ <= pos.z &&
- Z + dZ >= pos.z;
- } else {
- in_area = X - dX <= pos.x &&
- X + dX >= pos.x &&
- Y - dY <= pos.y &&
- Y + dY >= pos.y;
- }
- if (in_area) {
+ if (Abs(pos.x - X) < dX && Abs(pos.y - Y) < dY && (!b3D || Abs(pos.z - Z) < dZ)) {
switch (command) {
case COMMAND_LOCATE_PLAYER_ANY_MEANS_2D:
case COMMAND_LOCATE_PLAYER_ANY_MEANS_3D:
@@ -138,14 +112,16 @@ void CRunningScript::LocatePlayerCommand(int32 command, uint32* pIp)
}
}
UpdateCompareFlag(result);
- if (debug)
- CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT);
+ if (debug && Abs(pos.x - X) < 80.0f && Abs(pos.y - Y) < 80.0f)
+ CTheScripts::HighlightImportantArea(id, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag) {
if (b3D)
CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ);
else
CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY);
}
+ */
}
void CRunningScript::LocatePlayerCharCommand(int32 command, uint32* pIp)
@@ -163,8 +139,8 @@ void CRunningScript::LocatePlayerCharCommand(int32 command, uint32* pIp)
break;
}
CollectParameters(pIp, b3D ? 6 : 5);
- CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]];
- CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]);
+ CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)];
+ CPed* pTarget = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1));
script_assert(pTarget);
CVector pos = pPlayerInfo->GetPos();
if (pTarget->bInVehicle) {
@@ -176,14 +152,14 @@ void CRunningScript::LocatePlayerCharCommand(int32 command, uint32* pIp)
Y = pTarget->GetPosition().y;
Z = pTarget->GetPosition().z;
}
- dX = *(float*)&ScriptParams[2];
- dY = *(float*)&ScriptParams[3];
+ dX = GET_FLOAT_PARAM(2);
+ dY = GET_FLOAT_PARAM(3);
if (b3D) {
- dZ = *(float*)&ScriptParams[4];
- debug = ScriptParams[5];
+ dZ = GET_FLOAT_PARAM(4);
+ debug = GET_INTEGER_PARAM(5);
}
else {
- debug = ScriptParams[4];
+ debug = GET_INTEGER_PARAM(4);
}
result = false;
bool in_area;
@@ -227,12 +203,14 @@ void CRunningScript::LocatePlayerCharCommand(int32 command, uint32* pIp)
#else
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dX, b3D ? Z : MAP_Z_LOW_LIMIT);
#endif
+ /*
if (CTheScripts::DbgFlag) {
if (b3D)
CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ);
else
CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY);
}
+ */
}
void CRunningScript::LocatePlayerCarCommand(int32 command, uint32* pIp)
@@ -250,21 +228,21 @@ void CRunningScript::LocatePlayerCarCommand(int32 command, uint32* pIp)
break;
}
CollectParameters(pIp, b3D ? 6 : 5);
- CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]];
- CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]);
+ CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)];
+ CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1));
script_assert(pTarget);
CVector pos = pPlayerInfo->GetPos();
X = pTarget->GetPosition().x;
Y = pTarget->GetPosition().y;
Z = pTarget->GetPosition().z;
- dX = *(float*)&ScriptParams[2];
- dY = *(float*)&ScriptParams[3];
+ dX = GET_FLOAT_PARAM(2);
+ dY = GET_FLOAT_PARAM(3);
if (b3D) {
- dZ = *(float*)&ScriptParams[4];
- debug = ScriptParams[5];
+ dZ = GET_FLOAT_PARAM(4);
+ debug = GET_INTEGER_PARAM(5);
}
else {
- debug = ScriptParams[4];
+ debug = GET_INTEGER_PARAM(4);
}
result = false;
bool in_area;
@@ -304,12 +282,14 @@ void CRunningScript::LocatePlayerCarCommand(int32 command, uint32* pIp)
UpdateCompareFlag(result);
if (debug)
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag) {
if (b3D)
CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ);
else
CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY);
}
+ */
}
void CRunningScript::LocateCharCommand(int32 command, uint32* pIp)
@@ -329,8 +309,8 @@ void CRunningScript::LocateCharCommand(int32 command, uint32* pIp)
b3D = false;
break;
}
- CollectParameters(pIp, b3D ? 8 : 6);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ uint32 id = CollectLocateParameters(pIp, b3D);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pPed);
CVector pos = pPed->InVehicle() ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition();
switch (command) {
@@ -348,19 +328,19 @@ void CRunningScript::LocateCharCommand(int32 command, uint32* pIp)
default:
break;
}
- X = *(float*)&ScriptParams[1];
- Y = *(float*)&ScriptParams[2];
+ X = GET_FLOAT_PARAM(1);
+ Y = GET_FLOAT_PARAM(2);
if (b3D) {
- Z = *(float*)&ScriptParams[3];
- dX = *(float*)&ScriptParams[4];
- dY = *(float*)&ScriptParams[5];
- dZ = *(float*)&ScriptParams[6];
- debug = ScriptParams[7];
+ Z = GET_FLOAT_PARAM(3);
+ dX = GET_FLOAT_PARAM(4);
+ dY = GET_FLOAT_PARAM(5);
+ dZ = GET_FLOAT_PARAM(6);
+ debug = GET_INTEGER_PARAM(7);
}
else {
- dX = *(float*)&ScriptParams[3];
- dY = *(float*)&ScriptParams[4];
- debug = ScriptParams[5];
+ dX = GET_FLOAT_PARAM(3);
+ dY = GET_FLOAT_PARAM(4);
+ debug = GET_INTEGER_PARAM(5);
}
if (!decided) {
result = false;
@@ -407,13 +387,15 @@ void CRunningScript::LocateCharCommand(int32 command, uint32* pIp)
}
UpdateCompareFlag(result);
if (debug)
- CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT);
+ CTheScripts::HighlightImportantArea(id, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag) {
if (b3D)
CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ);
else
CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY);
}
+ */
}
void CRunningScript::LocateCharCharCommand(int32 command, uint32* pIp)
@@ -431,9 +413,9 @@ void CRunningScript::LocateCharCharCommand(int32 command, uint32* pIp)
break;
}
CollectParameters(pIp, b3D ? 6 : 5);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pPed);
- CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]);
+ CPed* pTarget = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1));
script_assert(pTarget);
CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition();
if (pTarget->bInVehicle) {
@@ -446,14 +428,14 @@ void CRunningScript::LocateCharCharCommand(int32 command, uint32* pIp)
Y = pTarget->GetPosition().y;
Z = pTarget->GetPosition().z;
}
- dX = *(float*)&ScriptParams[2];
- dY = *(float*)&ScriptParams[3];
+ dX = GET_FLOAT_PARAM(2);
+ dY = GET_FLOAT_PARAM(3);
if (b3D) {
- dZ = *(float*)&ScriptParams[4];
- debug = ScriptParams[5];
+ dZ = GET_FLOAT_PARAM(4);
+ debug = GET_INTEGER_PARAM(5);
}
else {
- debug = ScriptParams[4];
+ debug = GET_INTEGER_PARAM(4);
}
result = false;
bool in_area;
@@ -497,12 +479,14 @@ void CRunningScript::LocateCharCharCommand(int32 command, uint32* pIp)
#else
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dX, b3D ? Z : MAP_Z_LOW_LIMIT);
#endif
+ /*
if (CTheScripts::DbgFlag) {
if (b3D)
CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ);
else
CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY);
}
+ */
}
void CRunningScript::LocateCharCarCommand(int32 command, uint32* pIp)
@@ -520,22 +504,22 @@ void CRunningScript::LocateCharCarCommand(int32 command, uint32* pIp)
break;
}
CollectParameters(pIp, b3D ? 6 : 5);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pPed);
- CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]);
+ CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1));
script_assert(pTarget);
CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition();
X = pTarget->GetPosition().x;
Y = pTarget->GetPosition().y;
Z = pTarget->GetPosition().z;
- dX = *(float*)&ScriptParams[2];
- dY = *(float*)&ScriptParams[3];
+ dX = GET_FLOAT_PARAM(2);
+ dY = GET_FLOAT_PARAM(3);
if (b3D) {
- dZ = *(float*)&ScriptParams[4];
- debug = ScriptParams[5];
+ dZ = GET_FLOAT_PARAM(4);
+ debug = GET_INTEGER_PARAM(5);
}
else {
- debug = ScriptParams[4];
+ debug = GET_INTEGER_PARAM(4);
}
result = false;
bool in_area;
@@ -575,12 +559,14 @@ void CRunningScript::LocateCharCarCommand(int32 command, uint32* pIp)
UpdateCompareFlag(result);
if (debug)
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag) {
if (b3D)
CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ);
else
CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY);
}
+ */
}
void CRunningScript::LocateCharObjectCommand(int32 command, uint32* pIp)
@@ -598,22 +584,22 @@ void CRunningScript::LocateCharObjectCommand(int32 command, uint32* pIp)
break;
}
CollectParameters(pIp, b3D ? 6 : 5);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pPed);
- CObject* pTarget = CPools::GetObjectPool()->GetAt(ScriptParams[1]);
+ CObject* pTarget = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(1));
script_assert(pTarget);
CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition();
X = pTarget->GetPosition().x;
Y = pTarget->GetPosition().y;
Z = pTarget->GetPosition().z;
- dX = *(float*)&ScriptParams[2];
- dY = *(float*)&ScriptParams[3];
+ dX = GET_FLOAT_PARAM(2);
+ dY = GET_FLOAT_PARAM(3);
if (b3D) {
- dZ = *(float*)&ScriptParams[4];
- debug = ScriptParams[5];
+ dZ = GET_FLOAT_PARAM(4);
+ debug = GET_INTEGER_PARAM(5);
}
else {
- debug = ScriptParams[4];
+ debug = GET_INTEGER_PARAM(4);
}
result = false;
bool in_area;
@@ -653,12 +639,14 @@ void CRunningScript::LocateCharObjectCommand(int32 command, uint32* pIp)
UpdateCompareFlag(result);
if (debug)
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag) {
if (b3D)
CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ);
else
CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY);
}
+ */
}
void CRunningScript::LocateCarCommand(int32 command, uint32* pIp)
@@ -674,8 +662,8 @@ void CRunningScript::LocateCarCommand(int32 command, uint32* pIp)
b3D = false;
break;
}
- CollectParameters(pIp, b3D ? 8 : 6);
- CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ uint32 id = CollectLocateParameters(pIp, b3D);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pVehicle);
CVector pos = pVehicle->GetPosition();
switch (command) {
@@ -689,19 +677,19 @@ void CRunningScript::LocateCarCommand(int32 command, uint32* pIp)
default:
break;
}
- X = *(float*)&ScriptParams[1];
- Y = *(float*)&ScriptParams[2];
+ X = GET_FLOAT_PARAM(1);
+ Y = GET_FLOAT_PARAM(2);
if (b3D) {
- Z = *(float*)&ScriptParams[3];
- dX = *(float*)&ScriptParams[4];
- dY = *(float*)&ScriptParams[5];
- dZ = *(float*)&ScriptParams[6];
- debug = ScriptParams[7];
+ Z = GET_FLOAT_PARAM(3);
+ dX = GET_FLOAT_PARAM(4);
+ dY = GET_FLOAT_PARAM(5);
+ dZ = GET_FLOAT_PARAM(6);
+ debug = GET_INTEGER_PARAM(7);
}
else {
- dX = *(float*)&ScriptParams[3];
- dY = *(float*)&ScriptParams[4];
- debug = ScriptParams[5];
+ dX = GET_FLOAT_PARAM(3);
+ dY = GET_FLOAT_PARAM(4);
+ debug = GET_INTEGER_PARAM(5);
}
if (!decided) {
result = false;
@@ -724,13 +712,15 @@ void CRunningScript::LocateCarCommand(int32 command, uint32* pIp)
}
UpdateCompareFlag(result);
if (debug)
- CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT);
+ CTheScripts::HighlightImportantArea(id, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag) {
if (b3D)
CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ);
else
CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY);
}
+ */
}
void CRunningScript::LocateObjectCommand(int32 command, uint32* pIp)
@@ -745,23 +735,23 @@ void CRunningScript::LocateObjectCommand(int32 command, uint32* pIp)
b3D = false;
break;
}
- CollectParameters(pIp, b3D ? 8 : 6);
- CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
+ uint32 id = CollectLocateParameters(pIp, b3D);
+ CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pObject);
CVector pos = pObject->GetPosition();
- X = *(float*)&ScriptParams[1];
- Y = *(float*)&ScriptParams[2];
+ X = GET_FLOAT_PARAM(1);
+ Y = GET_FLOAT_PARAM(2);
if (b3D) {
- Z = *(float*)&ScriptParams[3];
- dX = *(float*)&ScriptParams[4];
- dY = *(float*)&ScriptParams[5];
- dZ = *(float*)&ScriptParams[6];
- debug = ScriptParams[7];
+ Z = GET_FLOAT_PARAM(3);
+ dX = GET_FLOAT_PARAM(4);
+ dY = GET_FLOAT_PARAM(5);
+ dZ = GET_FLOAT_PARAM(6);
+ debug = GET_INTEGER_PARAM(7);
}
else {
- dX = *(float*)&ScriptParams[3];
- dY = *(float*)&ScriptParams[4];
- debug = ScriptParams[5];
+ dX = GET_FLOAT_PARAM(3);
+ dY = GET_FLOAT_PARAM(4);
+ debug = GET_INTEGER_PARAM(5);
}
result = false;
bool in_area;
@@ -782,13 +772,15 @@ void CRunningScript::LocateObjectCommand(int32 command, uint32* pIp)
result = in_area;
UpdateCompareFlag(result);
if (debug)
- CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT);
+ CTheScripts::HighlightImportantArea(id, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag) {
if (b3D)
CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ);
else
CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY);
}
+ */
}
void CRunningScript::LocateSniperBulletCommand(int32 command, uint32* pIp)
@@ -804,30 +796,32 @@ void CRunningScript::LocateSniperBulletCommand(int32 command, uint32* pIp)
break;
}
CollectParameters(pIp, b3D ? 7 : 5);
- X = *(float*)&ScriptParams[0];
- Y = *(float*)&ScriptParams[1];
+ X = GET_FLOAT_PARAM(0);
+ Y = GET_FLOAT_PARAM(1);
if (b3D) {
- Z = *(float*)&ScriptParams[2];
- dX = *(float*)&ScriptParams[3];
- dY = *(float*)&ScriptParams[4];
- dZ = *(float*)&ScriptParams[5];
- debug = ScriptParams[6];
+ Z = GET_FLOAT_PARAM(2);
+ dX = GET_FLOAT_PARAM(3);
+ dY = GET_FLOAT_PARAM(4);
+ dZ = GET_FLOAT_PARAM(5);
+ debug = GET_INTEGER_PARAM(6);
}
else {
- dX = *(float*)&ScriptParams[2];
- dY = *(float*)&ScriptParams[3];
- debug = ScriptParams[4];
+ dX = GET_FLOAT_PARAM(2);
+ dY = GET_FLOAT_PARAM(3);
+ debug = GET_INTEGER_PARAM(4);
}
result = CBulletInfo::TestForSniperBullet(X - dX, X + dX, Y - dY, Y + dY, b3D ? Z - dZ : -1000.0f, b3D ? Z + dZ : 1000.0f);
UpdateCompareFlag(result);
if (debug)
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag) {
if (b3D)
CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ);
else
CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY);
}
+ */
}
void CRunningScript::PlayerInAreaCheckCommand(int32 command, uint32* pIp)
@@ -847,8 +841,8 @@ void CRunningScript::PlayerInAreaCheckCommand(int32 command, uint32* pIp)
b3D = false;
break;
}
- CollectParameters(pIp, b3D ? 8 : 6);
- CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]];
+ uint32 id = CollectLocateParameters(pIp, b3D);
+ CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)];
switch (command) {
case COMMAND_IS_PLAYER_STOPPED_IN_AREA_3D:
case COMMAND_IS_PLAYER_STOPPED_IN_AREA_ON_FOOT_3D:
@@ -864,23 +858,23 @@ void CRunningScript::PlayerInAreaCheckCommand(int32 command, uint32* pIp)
default:
break;
}
- infX = *(float*)&ScriptParams[1];
- infY = *(float*)&ScriptParams[2];
+ infX = GET_FLOAT_PARAM(1);
+ infY = GET_FLOAT_PARAM(2);
if (b3D) {
- infZ = *(float*)&ScriptParams[3];
- supX = *(float*)&ScriptParams[4];
- supY = *(float*)&ScriptParams[5];
- supZ = *(float*)&ScriptParams[6];
+ infZ = GET_FLOAT_PARAM(3);
+ supX = GET_FLOAT_PARAM(4);
+ supY = GET_FLOAT_PARAM(5);
+ supZ = GET_FLOAT_PARAM(6);
if (infZ > supZ) {
- infZ = *(float*)&ScriptParams[6];
- supZ = *(float*)&ScriptParams[3];
+ infZ = GET_FLOAT_PARAM(6);
+ supZ = GET_FLOAT_PARAM(3);
}
- debug = ScriptParams[7];
+ debug = GET_INTEGER_PARAM(7);
}
else {
- supX = *(float*)&ScriptParams[3];
- supY = *(float*)&ScriptParams[4];
- debug = ScriptParams[5];
+ supX = GET_FLOAT_PARAM(3);
+ supY = GET_FLOAT_PARAM(4);
+ debug = GET_INTEGER_PARAM(5);
}
if (infX > supX) {
float tmp = infX;
@@ -939,12 +933,14 @@ void CRunningScript::PlayerInAreaCheckCommand(int32 command, uint32* pIp)
UpdateCompareFlag(result);
if (debug)
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag) {
if (b3D)
CTheScripts::DrawDebugCube(infX, infY, infZ, supX, supY, supZ);
else
CTheScripts::DrawDebugSquare(infX, infY, supX, supY);
}
+ */
}
void CRunningScript::PlayerInAngledAreaCheckCommand(int32 command, uint32* pIp)
@@ -965,7 +961,7 @@ void CRunningScript::PlayerInAngledAreaCheckCommand(int32 command, uint32* pIp)
break;
}
CollectParameters(pIp, b3D ? 9 : 7);
- CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]];
+ CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)];
switch (command) {
case COMMAND_IS_PLAYER_STOPPED_IN_ANGLED_AREA_3D:
case COMMAND_IS_PLAYER_STOPPED_IN_ANGLED_AREA_ON_FOOT_3D:
@@ -981,25 +977,25 @@ void CRunningScript::PlayerInAngledAreaCheckCommand(int32 command, uint32* pIp)
default:
break;
}
- infX = *(float*)&ScriptParams[1];
- infY = *(float*)&ScriptParams[2];
+ infX = GET_FLOAT_PARAM(1);
+ infY = GET_FLOAT_PARAM(2);
if (b3D) {
- infZ = *(float*)&ScriptParams[3];
- supX = *(float*)&ScriptParams[4];
- supY = *(float*)&ScriptParams[5];
- supZ = *(float*)&ScriptParams[6];
+ infZ = GET_FLOAT_PARAM(3);
+ supX = GET_FLOAT_PARAM(4);
+ supY = GET_FLOAT_PARAM(5);
+ supZ = GET_FLOAT_PARAM(6);
if (infZ > supZ) {
- infZ = *(float*)&ScriptParams[6];
- supZ = *(float*)&ScriptParams[3];
+ infZ = GET_FLOAT_PARAM(6);
+ supZ = GET_FLOAT_PARAM(3);
}
- side2length = *(float*)&ScriptParams[7];
- debug = ScriptParams[8];
+ side2length = GET_FLOAT_PARAM(7);
+ debug = GET_INTEGER_PARAM(8);
}
else {
- supX = *(float*)&ScriptParams[3];
- supY = *(float*)&ScriptParams[4];
- side2length = *(float*)&ScriptParams[5];
- debug = ScriptParams[6];
+ supX = GET_FLOAT_PARAM(3);
+ supY = GET_FLOAT_PARAM(4);
+ side2length = GET_FLOAT_PARAM(5);
+ debug = GET_INTEGER_PARAM(6);
}
float initAngle = CGeneral::GetRadianAngleBetweenPoints(infX, infY, supX, supY) + HALFPI;
while (initAngle < 0.0f)
@@ -1062,6 +1058,7 @@ void CRunningScript::PlayerInAngledAreaCheckCommand(int32 command, uint32* pIp)
if (debug)
CTheScripts::HighlightImportantAngledArea((uintptr)this + m_nIp, infX, infY, supX, supY,
rotatedSupX, rotatedSupY, rotatedInfX, rotatedInfY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag) {
if (b3D)
CTheScripts::DrawDebugAngledCube(infX, infY, infZ, supX, supY, supZ,
@@ -1070,6 +1067,7 @@ void CRunningScript::PlayerInAngledAreaCheckCommand(int32 command, uint32* pIp)
CTheScripts::DrawDebugAngledSquare(infX, infY, supX, supY,
rotatedSupX, rotatedSupY, rotatedInfX, rotatedInfY);
}
+ */
}
void CRunningScript::CharInAreaCheckCommand(int32 command, uint32* pIp)
@@ -1089,8 +1087,8 @@ void CRunningScript::CharInAreaCheckCommand(int32 command, uint32* pIp)
b3D = false;
break;
}
- CollectParameters(pIp, b3D ? 8 : 6);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ uint32 id = CollectLocateParameters(pIp, b3D);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pPed);
CVector pos = pPed->InVehicle() ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition();
switch (command) {
@@ -1108,23 +1106,23 @@ void CRunningScript::CharInAreaCheckCommand(int32 command, uint32* pIp)
default:
break;
}
- infX = *(float*)&ScriptParams[1];
- infY = *(float*)&ScriptParams[2];
+ infX = GET_FLOAT_PARAM(1);
+ infY = GET_FLOAT_PARAM(2);
if (b3D) {
- infZ = *(float*)&ScriptParams[3];
- supX = *(float*)&ScriptParams[4];
- supY = *(float*)&ScriptParams[5];
- supZ = *(float*)&ScriptParams[6];
+ infZ = GET_FLOAT_PARAM(3);
+ supX = GET_FLOAT_PARAM(4);
+ supY = GET_FLOAT_PARAM(5);
+ supZ = GET_FLOAT_PARAM(6);
if (infZ > supZ) {
- infZ = *(float*)&ScriptParams[6];
- supZ = *(float*)&ScriptParams[3];
+ infZ = GET_FLOAT_PARAM(6);
+ supZ = GET_FLOAT_PARAM(3);
}
- debug = ScriptParams[7];
+ debug = GET_INTEGER_PARAM(7);
}
else {
- supX = *(float*)&ScriptParams[3];
- supY = *(float*)&ScriptParams[4];
- debug = ScriptParams[5];
+ supX = GET_FLOAT_PARAM(3);
+ supY = GET_FLOAT_PARAM(4);
+ debug = GET_INTEGER_PARAM(5);
}
if (infX > supX) {
float tmp = infX;
@@ -1181,13 +1179,15 @@ void CRunningScript::CharInAreaCheckCommand(int32 command, uint32* pIp)
}
UpdateCompareFlag(result);
if (debug)
- CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT);
+ CTheScripts::HighlightImportantArea(id, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag) {
if (b3D)
CTheScripts::DrawDebugCube(infX, infY, infZ, supX, supY, supZ);
else
CTheScripts::DrawDebugSquare(infX, infY, supX, supY);
}
+ */
}
void CRunningScript::CarInAreaCheckCommand(int32 command, uint32* pIp)
@@ -1203,8 +1203,8 @@ void CRunningScript::CarInAreaCheckCommand(int32 command, uint32* pIp)
b3D = false;
break;
}
- CollectParameters(pIp, b3D ? 8 : 6);
- CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ uint32 id = CollectLocateParameters(pIp, b3D);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pVehicle);
CVector pos = pVehicle->GetPosition();
switch (command) {
@@ -1218,23 +1218,23 @@ void CRunningScript::CarInAreaCheckCommand(int32 command, uint32* pIp)
default:
break;
}
- infX = *(float*)&ScriptParams[1];
- infY = *(float*)&ScriptParams[2];
+ infX = GET_FLOAT_PARAM(1);
+ infY = GET_FLOAT_PARAM(2);
if (b3D) {
- infZ = *(float*)&ScriptParams[3];
- supX = *(float*)&ScriptParams[4];
- supY = *(float*)&ScriptParams[5];
- supZ = *(float*)&ScriptParams[6];
+ infZ = GET_FLOAT_PARAM(3);
+ supX = GET_FLOAT_PARAM(4);
+ supY = GET_FLOAT_PARAM(5);
+ supZ = GET_FLOAT_PARAM(6);
if (infZ > supZ) {
- infZ = *(float*)&ScriptParams[6];
- supZ = *(float*)&ScriptParams[3];
+ infZ = GET_FLOAT_PARAM(6);
+ supZ = GET_FLOAT_PARAM(3);
}
- debug = ScriptParams[7];
+ debug = GET_INTEGER_PARAM(7);
}
else {
- supX = *(float*)&ScriptParams[3];
- supY = *(float*)&ScriptParams[4];
- debug = ScriptParams[5];
+ supX = GET_FLOAT_PARAM(3);
+ supY = GET_FLOAT_PARAM(4);
+ debug = GET_INTEGER_PARAM(5);
}
if (infX > supX) {
float tmp = infX;
@@ -1279,13 +1279,15 @@ void CRunningScript::CarInAreaCheckCommand(int32 command, uint32* pIp)
}
UpdateCompareFlag(result);
if (debug)
- CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT);
+ CTheScripts::HighlightImportantArea(id, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag) {
if (b3D)
CTheScripts::DrawDebugCube(infX, infY, infZ, supX, supY, supZ);
else
CTheScripts::DrawDebugSquare(infX, infY, supX, supY);
}
+ */
}
void CRunningScript::ObjectInAreaCheckCommand(int32 command, uint32* pIp)
@@ -1300,27 +1302,27 @@ void CRunningScript::ObjectInAreaCheckCommand(int32 command, uint32* pIp)
b3D = false;
break;
}
- CollectParameters(pIp, b3D ? 8 : 6);
- CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
+ uint32 id = CollectLocateParameters(pIp, b3D);
+ CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pObject);
CVector pos = pObject->GetPosition();
- infX = *(float*)&ScriptParams[1];
- infY = *(float*)&ScriptParams[2];
+ infX = GET_FLOAT_PARAM(1);
+ infY = GET_FLOAT_PARAM(2);
if (b3D) {
- infZ = *(float*)&ScriptParams[3];
- supX = *(float*)&ScriptParams[4];
- supY = *(float*)&ScriptParams[5];
- supZ = *(float*)&ScriptParams[6];
+ infZ = GET_FLOAT_PARAM(3);
+ supX = GET_FLOAT_PARAM(4);
+ supY = GET_FLOAT_PARAM(5);
+ supZ = GET_FLOAT_PARAM(6);
if (infZ > supZ) {
- infZ = *(float*)&ScriptParams[6];
- supZ = *(float*)&ScriptParams[3];
+ infZ = GET_FLOAT_PARAM(6);
+ supZ = GET_FLOAT_PARAM(3);
}
- debug = ScriptParams[7];
+ debug = GET_INTEGER_PARAM(7);
}
else {
- supX = *(float*)&ScriptParams[3];
- supY = *(float*)&ScriptParams[4];
- debug = ScriptParams[5];
+ supX = GET_FLOAT_PARAM(3);
+ supY = GET_FLOAT_PARAM(4);
+ debug = GET_INTEGER_PARAM(5);
}
if (infX > supX) {
float tmp = infX;
@@ -1361,13 +1363,15 @@ void CRunningScript::ObjectInAreaCheckCommand(int32 command, uint32* pIp)
}
UpdateCompareFlag(result);
if (debug)
- CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT);
+ CTheScripts::HighlightImportantArea(id, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag) {
if (b3D)
CTheScripts::DrawDebugCube(infX, infY, infZ, supX, supY, supZ);
else
CTheScripts::DrawDebugSquare(infX, infY, supX, supY);
}
+ */
}
void CRunningScript::DoDeatharrestCheck()
@@ -1390,7 +1394,8 @@ void CRunningScript::DoDeatharrestCheck()
script_assert(m_nStackPointer > 0);
while (m_nStackPointer > 1)
--m_nStackPointer;
- m_nIp = m_anStack[--m_nStackPointer];
+ ReturnFromGosubOrFunction();
+ m_nLocalsPointer = 0;
CMessages::ClearSmallMessagesOnly();
*(int32*)&CTheScripts::ScriptSpace[CTheScripts::OnAMissionFlag] = 0;
m_bDeatharrestExecuted = true;
@@ -1444,24 +1449,24 @@ void CRunningScript::LocateCollectiveCommand(int32 command, uint32* pIp)
b3D = true;
break;
}
- CollectParameters(pIp, b3D ? 8 : 6);
- X = *(float*)&ScriptParams[1];
- Y = *(float*)&ScriptParams[2];
+ uint32 id = CollectLocateParameters(pIp, b3D);
+ X = GET_FLOAT_PARAM(1);
+ Y = GET_FLOAT_PARAM(2);
if (b3D) {
- Z = *(float*)&ScriptParams[3];
- dX = *(float*)&ScriptParams[4];
- dY = *(float*)&ScriptParams[5];
- dZ = *(float*)&ScriptParams[6];
- debug = ScriptParams[7];
+ Z = GET_FLOAT_PARAM(3);
+ dX = GET_FLOAT_PARAM(4);
+ dY = GET_FLOAT_PARAM(5);
+ dZ = GET_FLOAT_PARAM(6);
+ debug = GET_INTEGER_PARAM(7);
}
else {
- dX = *(float*)&ScriptParams[3];
- dY = *(float*)&ScriptParams[4];
- debug = ScriptParams[5];
+ dX = GET_FLOAT_PARAM(3);
+ dY = GET_FLOAT_PARAM(4);
+ debug = GET_INTEGER_PARAM(5);
}
result = true;
for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) {
- if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex)
+ if (GET_INTEGER_PARAM(0) != CTheScripts::CollectiveArray[i].colIndex)
continue;
CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex);
if (!pPed) {
@@ -1522,13 +1527,15 @@ void CRunningScript::LocateCollectiveCommand(int32 command, uint32* pIp)
}
UpdateCompareFlag(result);
if (debug)
- CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT);
+ CTheScripts::HighlightImportantArea(id, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag) {
if (b3D)
CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ);
else
CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY);
}
+ */
}
void CRunningScript::LocateCollectiveCharCommand(int32 command, uint32* pIp)
@@ -1546,7 +1553,7 @@ void CRunningScript::LocateCollectiveCharCommand(int32 command, uint32* pIp)
break;
}
CollectParameters(pIp, b3D ? 6 : 5);
- CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]);
+ CPed* pTarget = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1));
script_assert(pTarget);
if (pTarget->bInVehicle) {
X = pTarget->m_pMyVehicle->GetPosition().x;
@@ -1558,18 +1565,18 @@ void CRunningScript::LocateCollectiveCharCommand(int32 command, uint32* pIp)
Y = pTarget->GetPosition().y;
Z = pTarget->GetPosition().z;
}
- dX = *(float*)&ScriptParams[2];
- dY = *(float*)&ScriptParams[3];
+ dX = GET_FLOAT_PARAM(2);
+ dY = GET_FLOAT_PARAM(3);
if (b3D) {
- dZ = *(float*)&ScriptParams[4];
- debug = ScriptParams[5];
+ dZ = GET_FLOAT_PARAM(4);
+ debug = GET_INTEGER_PARAM(5);
}
else {
- debug = ScriptParams[4];
+ debug = GET_INTEGER_PARAM(4);
}
result = true;
for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) {
- if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex)
+ if (GET_INTEGER_PARAM(0) != CTheScripts::CollectiveArray[i].colIndex)
continue;
CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex);
if (!pPed) {
@@ -1614,12 +1621,14 @@ void CRunningScript::LocateCollectiveCharCommand(int32 command, uint32* pIp)
UpdateCompareFlag(result);
if (debug)
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag) {
if (b3D)
CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ);
else
CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY);
}
+ */
}
void CRunningScript::LocateCollectiveCarCommand(int32 command, uint32* pIp)
@@ -1637,23 +1646,23 @@ void CRunningScript::LocateCollectiveCarCommand(int32 command, uint32* pIp)
break;
}
CollectParameters(pIp, b3D ? 6 : 5);
- CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]);
+ CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1));
script_assert(pTarget);
X = pTarget->GetPosition().x;
Y = pTarget->GetPosition().y;
Z = pTarget->GetPosition().z;
- dX = *(float*)&ScriptParams[2];
- dY = *(float*)&ScriptParams[3];
+ dX = GET_FLOAT_PARAM(2);
+ dY = GET_FLOAT_PARAM(3);
if (b3D) {
- dZ = *(float*)&ScriptParams[4];
- debug = ScriptParams[5];
+ dZ = GET_FLOAT_PARAM(4);
+ debug = GET_INTEGER_PARAM(5);
}
else {
- debug = ScriptParams[4];
+ debug = GET_INTEGER_PARAM(4);
}
result = true;
for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) {
- if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex)
+ if (GET_INTEGER_PARAM(0) != CTheScripts::CollectiveArray[i].colIndex)
continue;
CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex);
if (!pPed) {
@@ -1698,12 +1707,14 @@ void CRunningScript::LocateCollectiveCarCommand(int32 command, uint32* pIp)
UpdateCompareFlag(result);
if (debug)
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag) {
if (b3D)
CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ);
else
CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY);
}
+ */
}
void CRunningScript::LocateCollectivePlayerCommand(int32 command, uint32* pIp)
@@ -1721,22 +1732,22 @@ void CRunningScript::LocateCollectivePlayerCommand(int32 command, uint32* pIp)
break;
}
CollectParameters(pIp, b3D ? 6 : 5);
- CVector pos = CWorld::Players[ScriptParams[1]].GetPos();
+ CVector pos = CWorld::Players[GET_INTEGER_PARAM(1)].GetPos();
X = pos.x;
Y = pos.y;
Z = pos.z;
- dX = *(float*)&ScriptParams[2];
- dY = *(float*)&ScriptParams[3];
+ dX = GET_FLOAT_PARAM(2);
+ dY = GET_FLOAT_PARAM(3);
if (b3D) {
- dZ = *(float*)&ScriptParams[4];
- debug = ScriptParams[5];
+ dZ = GET_FLOAT_PARAM(4);
+ debug = GET_INTEGER_PARAM(5);
}
else {
- debug = ScriptParams[4];
+ debug = GET_INTEGER_PARAM(4);
}
result = true;
for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) {
- if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex)
+ if (GET_INTEGER_PARAM(0) != CTheScripts::CollectiveArray[i].colIndex)
continue;
CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex);
if (!pPed) {
@@ -1781,12 +1792,14 @@ void CRunningScript::LocateCollectivePlayerCommand(int32 command, uint32* pIp)
UpdateCompareFlag(result);
if (debug)
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag) {
if (b3D)
CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ);
else
CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY);
}
+ */
}
void CRunningScript::CollectiveInAreaCheckCommand(int32 command, uint32* pIp)
@@ -1807,23 +1820,23 @@ void CRunningScript::CollectiveInAreaCheckCommand(int32 command, uint32* pIp)
break;
}
CollectParameters(pIp, b3D ? 8 : 6);
- infX = *(float*)&ScriptParams[1];
- infY = *(float*)&ScriptParams[2];
+ infX = GET_FLOAT_PARAM(1);
+ infY = GET_FLOAT_PARAM(2);
if (b3D) {
- infZ = *(float*)&ScriptParams[3];
- supX = *(float*)&ScriptParams[4];
- supY = *(float*)&ScriptParams[5];
- supZ = *(float*)&ScriptParams[6];
+ infZ = GET_FLOAT_PARAM(3);
+ supX = GET_FLOAT_PARAM(4);
+ supY = GET_FLOAT_PARAM(5);
+ supZ = GET_FLOAT_PARAM(6);
if (infZ > supZ) {
- infZ = *(float*)&ScriptParams[6];
- supZ = *(float*)&ScriptParams[3];
+ infZ = GET_FLOAT_PARAM(6);
+ supZ = GET_FLOAT_PARAM(3);
}
- debug = ScriptParams[7];
+ debug = GET_INTEGER_PARAM(7);
}
else {
- supX = *(float*)&ScriptParams[3];
- supY = *(float*)&ScriptParams[4];
- debug = ScriptParams[5];
+ supX = GET_FLOAT_PARAM(3);
+ supY = GET_FLOAT_PARAM(4);
+ debug = GET_INTEGER_PARAM(5);
}
if (infX > supX) {
float tmp = infX;
@@ -1837,7 +1850,7 @@ void CRunningScript::CollectiveInAreaCheckCommand(int32 command, uint32* pIp)
}
result = true;
for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) {
- if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex)
+ if (GET_INTEGER_PARAM(0) != CTheScripts::CollectiveArray[i].colIndex)
continue;
CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex);
if (!pPed) {
@@ -1899,12 +1912,14 @@ void CRunningScript::CollectiveInAreaCheckCommand(int32 command, uint32* pIp)
UpdateCompareFlag(result);
if (debug)
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag) {
if (b3D)
CTheScripts::DrawDebugCube(infX, infY, infZ, supX, supY, supZ);
else
CTheScripts::DrawDebugSquare(infX, infY, supX, supY);
}
+ */
}
#endif
@@ -1991,8 +2006,9 @@ void CTheScripts::PrintListSizes()
debug("active: %d, idle: %d", active, idle);
}
-uint32 DbgLineColour = 0x0000FFFF; // r = 0, g = 0, b = 255, a = 255
+//uint32 DbgLineColour = 0x0000FFFF; // r = 0, g = 0, b = 255, a = 255
+/*
void CTheScripts::DrawDebugSquare(float infX, float infY, float supX, float supY)
{
CColPoint tmpCP;
@@ -2099,9 +2115,10 @@ void CTheScripts::RenderTheScriptDebugLines()
NumScriptDebugLines = 0;
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)0);
}
+*/
-#define SCRIPT_DATA_SIZE sizeof(CTheScripts::OnAMissionFlag) +\
- 4 * sizeof(uint32) * MAX_NUM_BUILDING_SWAPS + 2 * sizeof(uint32) * MAX_NUM_INVISIBILITY_SETTINGS + 5 * sizeof(uint32)
+#define SCRIPT_DATA_SIZE sizeof(CTheScripts::OnAMissionFlag) + sizeof(tCollectiveData) * MAX_NUM_COLLECTIVES +\
+ 4 * sizeof(uint32) * MAX_NUM_BUILDING_SWAPS + 2 * sizeof(uint32) * MAX_NUM_INVISIBILITY_SETTINGS + 4 * sizeof(uint32)
void CTheScripts::SaveAllScripts(uint8* buf, uint32* size)
{
@@ -2110,7 +2127,7 @@ INITSAVEBUF
uint32 runningScripts = 0;
for (CRunningScript* pScript = pActiveScripts; pScript; pScript = pScript->GetNext())
runningScripts++;
- *size = CRunningScript::nSaveStructSize * runningScripts + varSpace + SCRIPT_DATA_SIZE + SAVE_HEADER_SIZE + 3 * sizeof(uint32);
+ *size = CRunningScript::nSaveStructSize * runningScripts + varSpace + SCRIPT_DATA_SIZE + SAVE_HEADER_SIZE + 5 * sizeof(uint32);
WriteSaveHeader(buf, 'S', 'C', 'R', '\0', *size - SAVE_HEADER_SIZE);
WriteSaveBuf(buf, varSpace);
for (uint32 i = 0; i < varSpace; i++)
@@ -2122,6 +2139,9 @@ INITSAVEBUF
WriteSaveBuf(buf, script_data_size);
WriteSaveBuf(buf, OnAMissionFlag);
WriteSaveBuf(buf, LastMissionPassedTime);
+ for (uint32 i = 0; i < MAX_NUM_COLLECTIVES; i++)
+ WriteSaveBuf(buf, CollectiveArray[i]);
+ WriteSaveBuf(buf, NextFreeCollectiveIndex);
for (uint32 i = 0; i < MAX_NUM_BUILDING_SWAPS; i++) {
CBuilding* pBuilding = BuildingSwapArray[i].m_pBuilding;
uint32 type, handle;
@@ -2183,24 +2203,37 @@ INITSAVEBUF
VALIDATESAVEBUF(*size)
}
-void CTheScripts::LoadAllScripts(uint8* buf, uint32 size)
+bool CTheScripts::LoadAllScripts(uint8* buf, uint32 size)
{
- Init();
INITSAVEBUF
CheckSaveHeader(buf, 'S', 'C', 'R', '\0', size - SAVE_HEADER_SIZE);
uint32 varSpace, type, handle;
uint32 tmp;
ReadSaveBuf(&varSpace, buf);
- for (uint32 i = 0; i < varSpace; i++)
- ReadSaveBuf(&ScriptSpace[i], buf);
+ if (*(int32*)&ScriptSpace[0] != *(int32*)&buf[0] || *(int32*)&ScriptSpace[4] != *(int32*)&buf[4]) {
+ printf("\n===================================================\nSave Game Mismatch!!!\n");
+ return false;
+ }
+ for (uint32 i = 0; i < varSpace; i++) { // this is not exactly what function does
+ if (i < 8)
+ ReadSaveBuf(&ScriptSpace[i], buf);
+ else if (GetSaveVarIndex(i / 4 * 4) != -1)
+ ReadSaveBuf(&ScriptSpace[i], buf);
+ else
+ SkipSaveBuf(buf, 1);
+ }
ReadSaveBuf(&tmp, buf);
script_assert(tmp == SCRIPT_DATA_SIZE);
ReadSaveBuf(&OnAMissionFlag, buf);
ReadSaveBuf(&LastMissionPassedTime, buf);
+ for (uint32 i = 0; i < MAX_NUM_COLLECTIVES; i++)
+ ReadSaveBuf(&CollectiveArray[i], buf);
+ ReadSaveBuf(&NextFreeCollectiveIndex, buf);
for (uint32 i = 0; i < MAX_NUM_BUILDING_SWAPS; i++) {
ReadSaveBuf(&type, buf);
ReadSaveBuf(&handle, buf);
+ /*
switch (type) {
case 0:
BuildingSwapArray[i].m_pBuilding = nil;
@@ -2214,14 +2247,19 @@ INITSAVEBUF
default:
script_assert(false);
}
- ReadSaveBuf(&BuildingSwapArray[i].m_nNewModel, buf);
- ReadSaveBuf(&BuildingSwapArray[i].m_nOldModel, buf);
+ */
+ /*BuildingSwapArray[i].m_nNewModel = ReadSaveBuf<uint32>(buf);*/
+ /*BuildingSwapArray[i].m_nOldModel = ReadSaveBuf<uint32>(buf);*/
+ SkipSaveBuf(buf, 8);
+ /*
if (BuildingSwapArray[i].m_pBuilding)
BuildingSwapArray[i].m_pBuilding->ReplaceWithNewModel(BuildingSwapArray[i].m_nNewModel);
+ */
}
for (uint32 i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++) {
ReadSaveBuf(&type, buf);
ReadSaveBuf(&handle, buf);
+ /*
switch (type) {
case 0:
InvisibilitySettingArray[i] = nil;
@@ -2243,12 +2281,16 @@ INITSAVEBUF
}
if (InvisibilitySettingArray[i])
InvisibilitySettingArray[i]->bIsVisible = false;
+ */
}
bool tmpBool;
ReadSaveBuf(&tmpBool, buf);
script_assert(tmpBool == bUsingAMultiScriptFile);
- ReadSaveBuf(&bPlayerHasMetDebbieHarry, buf);
- SkipSaveBuf(buf, 2);
+ ///*bPlayerHasMetDebbieHarry = */ReadSaveBuf<uint8>(buf);
+ //ReadSaveBuf<uint16>(buf);
+
+ SkipSaveBuf(buf, 3);
+
ReadSaveBuf(&tmp, buf);
script_assert(tmp == MainScriptSize);
ReadSaveBuf(&tmp, buf);
@@ -2261,7 +2303,8 @@ INITSAVEBUF
uint32 runningScripts;
ReadSaveBuf(&runningScripts, buf);
for (uint32 i = 0; i < runningScripts; i++)
- StartNewScript(0)->Load(buf);
+ CRunningScript().Load(buf);
+ return true;
VALIDATESAVEBUF(size)
}
@@ -2271,6 +2314,7 @@ void CRunningScript::Save(uint8*& buf)
{
#ifdef COMPATIBLE_SAVES
ZeroSaveBuf(buf, 8);
+ WriteSaveBuf<int32>(buf, m_nId);
for (int i = 0; i < 8; i++)
WriteSaveBuf(buf, m_abScriptName[i]);
WriteSaveBuf(buf, m_nIp);
@@ -2282,10 +2326,11 @@ void CRunningScript::Save(uint8*& buf)
WriteSaveBuf(buf, m_nStackPointer);
ZeroSaveBuf(buf, 2);
#ifdef CHECK_STRUCT_SIZES
- static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18");
+ static_assert(NUM_LOCAL_VARS + 8 + NUM_TIMERS == 106, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 106");
#endif
- for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++)
+ for (int i = 0; i < NUM_LOCAL_VARS + 8 + NUM_TIMERS; i++)
WriteSaveBuf(buf, m_anLocalVariables[i]);
+ WriteSaveBuf(buf, m_nLocalsPointer);
WriteSaveBuf(buf, m_bIsActive);
WriteSaveBuf(buf, m_bCondResult);
WriteSaveBuf(buf, m_bIsMissionScript);
@@ -2306,6 +2351,7 @@ void CRunningScript::Load(uint8*& buf)
{
#ifdef COMPATIBLE_SAVES
SkipSaveBuf(buf, 8);
+ ReadSaveBuf(&m_nId, buf);
for (int i = 0; i < 8; i++)
ReadSaveBuf(&m_abScriptName[i], buf);
ReadSaveBuf(&m_nIp, buf);
@@ -2317,10 +2363,11 @@ void CRunningScript::Load(uint8*& buf)
ReadSaveBuf(&m_nStackPointer, buf);
SkipSaveBuf(buf, 2);
#ifdef CHECK_STRUCT_SIZES
- static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18");
+ static_assert(NUM_LOCAL_VARS + 8 + NUM_TIMERS == 106, "Compatibility loss: NUM_LOCAL_VARS + 8 + NUM_TIMERS != 106");
#endif
- for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++)
+ for (int i = 0; i < NUM_LOCAL_VARS + 8 + NUM_TIMERS; i++)
ReadSaveBuf(&m_anLocalVariables[i], buf);
+ ReadSaveBuf(&m_nLocalsPointer, buf);
ReadSaveBuf(&m_bIsActive, buf);
ReadSaveBuf(&m_bCondResult, buf);
ReadSaveBuf(&m_bIsMissionScript, buf);
@@ -2429,7 +2476,7 @@ void CTheScripts::HighlightImportantArea(uint32 id, float x1, float y1, float x2
center.x = (infX + supX) / 2;
center.y = (infY + supY) / 2;
center.z = (z <= MAP_Z_LOW_LIMIT) ? CWorld::FindGroundZForCoord(center.x, center.y) : z;
- CShadows::RenderIndicatorShadow(id, 2, gpGoalTex, &center, supX - center.x, 0.0f, 0.0f, center.y - supY, 0);
+ CShadows::RenderIndicatorShadow(id, 2, nil, &center, supX - center.x, 0.0f, 0.0f, center.y - supY, 0);
}
void CTheScripts::HighlightImportantAngledArea(uint32 id, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float z)
@@ -2623,7 +2670,10 @@ void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective ob
}
else {
pPed->bScriptObjectiveCompleted = false;
- pPed->SetObjective(objective);
+ if (objective == OBJECTIVE_LEAVE_CAR)
+ pPed->SetObjective(objective);
+ else
+ pPed->SetObjective(objective, pPed->m_pMyVehicle);
}
}
}
@@ -2699,8 +2749,14 @@ void CTheScripts::CleanUpThisPed(CPed* pPed)
}
else {
if (pPed->m_pMyVehicle->m_vehType == VEHICLE_TYPE_CAR) {
- pPed->SetObjective(OBJECTIVE_LEAVE_CAR, pPed->m_pMyVehicle);
- pPed->bWanderPathAfterExitingCar = true;
+ if ((pPed->m_fHealth < 1.0f && !pPed->IsPedHeadAbovePos(-0.3f)) || pPed->bBodyPartJustCameOff) {
+ pPed->SetObjective(OBJECTIVE_LEAVE_CAR_AND_DIE, pPed->m_pMyVehicle);
+ pPed->bWanderPathAfterExitingCar = false;
+ }
+ else {
+ pPed->SetObjective(OBJECTIVE_LEAVE_CAR, pPed->m_pMyVehicle);
+ pPed->bWanderPathAfterExitingCar = true;
+ }
}
}
}
@@ -2713,6 +2769,7 @@ void CTheScripts::CleanUpThisPed(CPed* pPed)
flees = true;
}
pPed->ClearObjective();
+ pPed->SetWaitState(WAITSTATE_FALSE, nil);
pPed->bRespondsToThreats = true;
pPed->bScriptObjectiveCompleted = false;
pPed->bKindaStayInSamePlace = false;
@@ -2756,6 +2813,9 @@ void CTheScripts::ReadObjectNamesFromScript()
{
int32 varSpace = GetSizeOfVariableSpace();
uint32 ip = varSpace + 8;
+ NumSaveVars = Read4BytesFromScript(&ip);
+ SavedVarIndices = (uint16*)&ScriptSpace[ip];
+ ip += 2 * NumSaveVars;
NumberOfUsedObjects = Read2BytesFromScript(&ip);
ip += 2;
for (uint16 i = 0; i < NumberOfUsedObjects; i++) {
@@ -2767,30 +2827,16 @@ void CTheScripts::ReadObjectNamesFromScript()
void CTheScripts::UpdateObjectIndices()
{
- char name[USED_OBJECT_NAME_LENGTH];
char error[112];
for (int i = 1; i < NumberOfUsedObjects; i++) {
- bool found = false;
- for (int j = 0; j < MODELINFOSIZE && !found; j++) {
- CBaseModelInfo* pModel = CModelInfo::GetModelInfo(j);
- if (!pModel)
- continue;
- strcpy(name, pModel->GetModelName());
-#ifdef FIX_BUGS
- for (int k = 0; k < USED_OBJECT_NAME_LENGTH && name[k]; k++)
-#else
- for (int k = 0; k < USED_OBJECT_NAME_LENGTH; k++)
-#endif
- name[k] = toupper(name[k]);
- if (strcmp(name, UsedObjectArray[i].name) == 0) {
- found = true;
- UsedObjectArray[i].index = j;
- }
- }
- if (!found) {
+ UsedObjectArray[i].index = -1;
+ CModelInfo::GetModelInfo(UsedObjectArray[i].name, &UsedObjectArray[i].index);
+#ifndef FINAL
+ if (UsedObjectArray[i].index == -1) {
sprintf(error, "CTheScripts::UpdateObjectIndices - Couldn't find %s", UsedObjectArray[i].name);
debug("%s\n", error);
}
+#endif
}
}
@@ -2800,7 +2846,8 @@ void CTheScripts::ReadMultiScriptFileOffsetsFromScript()
uint32 ip = varSpace + 3;
int32 objectSize = Read4BytesFromScript(&ip);
ip = objectSize + 8;
- MainScriptSize = Read4BytesFromScript(&ip);
+ NumTrueGlobals = Read2BytesFromScript(&ip);
+ MostGlobals = Read2BytesFromScript(&ip);
LargestMissionScriptSize = Read4BytesFromScript(&ip);
NumberOfMissionScripts = Read2BytesFromScript(&ip);
NumberOfExclusiveMissionScripts = Read2BytesFromScript(&ip);