some changes

This commit is contained in:
Nikolay Korolev 2020-02-23 13:12:44 +03:00
parent aa5266b1b3
commit 1ba696f5fc
6 changed files with 315 additions and 309 deletions

View File

@ -106,18 +106,18 @@ void COnscreenTimerEntry::Process() {
return;
}
uint32* timerPtr = (uint32*)&CTheScripts::ScriptSpace[m_nTimerOffset];
uint32 oldTime = *timerPtr;
int32 newTime = int32(oldTime - uint32(20.0f * CTimer::GetTimeStep()));
int32* timerPtr = CTheScripts::GetPointerToScriptVariable(m_nTimerOffset);
int32 oldTime = *timerPtr;
int32 newTime = oldTime - int32(CTimer::GetTimeStepInSeconds() * 1000);
if(newTime < 0) {
*timerPtr = 0;
m_bTimerProcessed = 0;
m_nTimerOffset = 0;
m_aTimerText[0] = 0;
} else {
*timerPtr = (uint32)newTime;
uint32 oldTimeSeconds = oldTime / 1000;
if(oldTimeSeconds <= 11 && newTime / 1000 != oldTimeSeconds) {
*timerPtr = newTime;
int32 oldTimeSeconds = oldTime / 1000;
if(oldTimeSeconds < 12 && newTime / 1000 != oldTimeSeconds) {
DMAudio.PlayFrontEndSound(SOUND_CLOCK_TICK, newTime / 1000);
}
}
@ -144,13 +144,13 @@ bool COnscreenTimerEntry::ProcessForDisplay() {
}
void COnscreenTimerEntry::ProcessForDisplayClock() {
uint32 time = *(uint32*)&CTheScripts::ScriptSpace[m_nTimerOffset];
uint32 time = *CTheScripts::GetPointerToScriptVariable(m_nTimerOffset);
sprintf(m_bTimerBuffer, "%02d:%02d", time / 1000 / 60,
time / 1000 % 60);
}
void COnscreenTimerEntry::ProcessForDisplayCounter() {
uint32 counter = *(uint32*)&CTheScripts::ScriptSpace[m_nCounterOffset];
uint32 counter = *CTheScripts::GetPointerToScriptVariable(m_nCounterOffset);
sprintf(m_bCounterBuffer, "%d", counter);
}

View File

@ -383,25 +383,25 @@ void CRunningScript::CollectParameters(uint32* pIp, int16 total)
{
for (int16 i = 0; i < total; i++){
float tmp;
switch (CTheScripts::Read1ByteFromScript(pIp))
switch (Read1ByteFromScript(pIp))
{
case ARGUMENT_INT32:
ScriptParams[i] = CTheScripts::Read4BytesFromScript(pIp);
ScriptParams[i] = Read4BytesFromScript(pIp);
break;
case ARGUMENT_GLOBALVAR:
ScriptParams[i] = *((int32*)&CTheScripts::ScriptSpace[CTheScripts::Read2BytesFromScript(pIp)]);
ScriptParams[i] = *((int32*)&CTheScripts::ScriptSpace[Read2BytesFromScript(pIp)]);
break;
case ARGUMENT_LOCALVAR:
ScriptParams[i] = m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)];
ScriptParams[i] = m_anLocalVariables[Read2BytesFromScript(pIp)];
break;
case ARGUMENT_INT8:
ScriptParams[i] = CTheScripts::Read1ByteFromScript(pIp);
ScriptParams[i] = Read1ByteFromScript(pIp);
break;
case ARGUMENT_INT16:
ScriptParams[i] = CTheScripts::Read2BytesFromScript(pIp);
ScriptParams[i] = Read2BytesFromScript(pIp);
break;
case ARGUMENT_FLOAT:
tmp = CTheScripts::ReadFloatFromScript(pIp);
tmp = ReadFloatFromScript(pIp);
ScriptParams[i] = *(int32*)&tmp;
break;
default:
@ -415,20 +415,20 @@ int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip)
{
uint32* pIp = &ip;
float tmp;
switch (CTheScripts::Read1ByteFromScript(pIp))
switch (Read1ByteFromScript(pIp))
{
case ARGUMENT_INT32:
return CTheScripts::Read4BytesFromScript(pIp);
return Read4BytesFromScript(pIp);
case ARGUMENT_GLOBALVAR:
return *((int32*)&CTheScripts::ScriptSpace[CTheScripts::Read2BytesFromScript(pIp)]);
return *((int32*)&CTheScripts::ScriptSpace[Read2BytesFromScript(pIp)]);
case ARGUMENT_LOCALVAR:
return m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)];
return m_anLocalVariables[Read2BytesFromScript(pIp)];
case ARGUMENT_INT8:
return CTheScripts::Read1ByteFromScript(pIp);
return Read1ByteFromScript(pIp);
case ARGUMENT_INT16:
return CTheScripts::Read2BytesFromScript(pIp);
return Read2BytesFromScript(pIp);
case ARGUMENT_FLOAT:
tmp = CTheScripts::ReadFloatFromScript(pIp);
tmp = ReadFloatFromScript(pIp);
return *(int32*)&tmp;
default:
assert(0);
@ -439,12 +439,12 @@ int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip)
void CRunningScript::StoreParameters(uint32* pIp, int16 number)
{
for (int16 i = 0; i < number; i++){
switch (CTheScripts::Read1ByteFromScript(pIp)) {
switch (Read1ByteFromScript(pIp)) {
case ARGUMENT_GLOBALVAR:
*(int32*)&CTheScripts::ScriptSpace[CTheScripts::Read2BytesFromScript(pIp)] = ScriptParams[i];
*(int32*)&CTheScripts::ScriptSpace[Read2BytesFromScript(pIp)] = ScriptParams[i];
break;
case ARGUMENT_LOCALVAR:
m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)] = ScriptParams[i];
m_anLocalVariables[Read2BytesFromScript(pIp)] = ScriptParams[i];
break;
default:
assert(0);
@ -454,14 +454,14 @@ void CRunningScript::StoreParameters(uint32* pIp, int16 number)
int32 *CRunningScript::GetPointerToScriptVariable(uint32* pIp, int16 type)
{
switch (CTheScripts::Read1ByteFromScript(pIp))
switch (Read1ByteFromScript(pIp))
{
case ARGUMENT_GLOBALVAR:
assert(type == VAR_GLOBAL);
return (int32*)&CTheScripts::ScriptSpace[CTheScripts::Read2BytesFromScript(pIp)];
return (int32*)&CTheScripts::ScriptSpace[Read2BytesFromScript(pIp)];
case ARGUMENT_LOCALVAR:
assert(type == VAR_LOCAL);
return &m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)];
return &m_anLocalVariables[Read2BytesFromScript(pIp)];
default:
assert(0);
}
@ -472,7 +472,7 @@ void CRunningScript::Init()
{
strcpy(m_abScriptName, "noname");
next = prev = nil;
m_nIp = 0;
SetIP(0);
for (int i = 0; i < MAX_STACK_DEPTH; i++)
m_anStack[i] = 0;
m_nStackPointer = 0;
@ -677,7 +677,7 @@ void CRunningScript::Process()
if (m_bIsMissionScript)
DoDeatharrestCheck();
if (m_bMissionFlag && CTheScripts::FailCurrentMission == 1 && m_nStackPointer == 1)
m_nIp = m_anStack[--m_nStackPointer];
SetIP(m_anStack[--m_nStackPointer]);
if (CTimer::GetTimeInMilliseconds() >= m_nWakeTime){
while (!ProcessOneCommand())
;
@ -699,7 +699,7 @@ void CRunningScript::Process()
int8 CRunningScript::ProcessOneCommand()
{
++CTheScripts::CommandsExecuted;
int32 command = CTheScripts::Read2BytesFromScript(&m_nIp);
int32 command = Read2BytesFromScript(&m_nIp);
m_bNotFlag = (command & 0x8000);
command &= 0x7FFF;
if (command < 100)
@ -1227,27 +1227,27 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
CollectParameters(&m_nIp, 1);
assert(ScriptParams[0] >= 0);
CRunningScript* pNew = CTheScripts::StartNewScript(ScriptParams[0]);
int8 type = CTheScripts::Read1ByteFromScript(&m_nIp);
int8 type = Read1ByteFromScript(&m_nIp);
float tmp;
for (int i = 0; type != ARGUMENT_END; type = CTheScripts::Read1ByteFromScript(&m_nIp), i++) {
for (int i = 0; type != ARGUMENT_END; type = Read1ByteFromScript(&m_nIp), i++) {
switch (type) {
case ARGUMENT_INT32:
pNew->m_anLocalVariables[i] = CTheScripts::Read4BytesFromScript(&m_nIp);
pNew->m_anLocalVariables[i] = Read4BytesFromScript(&m_nIp);
break;
case ARGUMENT_GLOBALVAR:
pNew->m_anLocalVariables[i] = *(int32*)&CTheScripts::ScriptSpace[CTheScripts::Read2BytesFromScript(&m_nIp)];
pNew->m_anLocalVariables[i] = *(int32*)&CTheScripts::ScriptSpace[Read2BytesFromScript(&m_nIp)];
break;
case ARGUMENT_LOCALVAR:
pNew->m_anLocalVariables[i] = m_anLocalVariables[CTheScripts::Read2BytesFromScript(&m_nIp)];
pNew->m_anLocalVariables[i] = m_anLocalVariables[Read2BytesFromScript(&m_nIp)];
break;
case ARGUMENT_INT8:
pNew->m_anLocalVariables[i] = CTheScripts::Read1ByteFromScript(&m_nIp);
pNew->m_anLocalVariables[i] = Read1ByteFromScript(&m_nIp);
break;
case ARGUMENT_INT16:
pNew->m_anLocalVariables[i] = CTheScripts::Read2BytesFromScript(&m_nIp);
pNew->m_anLocalVariables[i] = Read2BytesFromScript(&m_nIp);
break;
case ARGUMENT_FLOAT:
tmp = CTheScripts::ReadFloatFromScript(&m_nIp);
tmp = ReadFloatFromScript(&m_nIp);
pNew->m_anLocalVariables[i] = *(int32*)&tmp;
break;
default:
@ -1275,7 +1275,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
CollectParameters(&m_nIp, 4);
int32 index = ScriptParams[0];
assert(index < 1); /* Constant? Also no more double player glitch */
debug("&&&&&&&&&&&&&Creating player: %d\n", index);
printf("&&&&&&&&&&&&&Creating player: %d\n", index);
if (!CStreaming::HasModelLoaded(MI_PLAYER)) {
CStreaming::RequestSpecialModel(MI_PLAYER, "player", STREAMFLAGS_DONT_REMOVE | STREAMFLAGS_DEPENDENCY);
CStreaming::LoadAllRequestedModels(false);
@ -2669,7 +2669,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
CollectParameters(&m_nIp, 1);
CPlayerInfo* pPlayer = &CWorld::Players[ScriptParams[0]];
char label[12];
CTheScripts::ReadTextLabelFromScript(&m_nIp, label);
ReadTextLabelFromScript(&m_nIp, label);
int zoneToCheck = CTheZones::FindZoneByLabelAndReturnIndex(label);
if (zoneToCheck != -1)
m_nIp += KEY_LENGTH_IN_SCRIPT; /* why only if zone != 1? */
@ -2960,7 +2960,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
}
case COMMAND_ADD_PAGER_MESSAGE:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 3);
CUserDisplay::Pager.AddMessage(text, ScriptParams[0], ScriptParams[1], ScriptParams[2]);
return 0;
@ -2969,21 +2969,21 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
{
assert(CTheScripts::ScriptSpace[m_nIp] == ARGUMENT_GLOBALVAR);
m_nIp++;
CUserDisplay::OnscnTimer.AddClock(CTheScripts::Read2BytesFromScript(&m_nIp), nil);
CUserDisplay::OnscnTimer.AddClock(Read2BytesFromScript(&m_nIp), nil);
return 0;
}
case COMMAND_CLEAR_ONSCREEN_TIMER:
{
assert(CTheScripts::ScriptSpace[m_nIp] == ARGUMENT_GLOBALVAR);
m_nIp++;
CUserDisplay::OnscnTimer.ClearClock(CTheScripts::Read2BytesFromScript(&m_nIp));
CUserDisplay::OnscnTimer.ClearClock(Read2BytesFromScript(&m_nIp));
return 0;
}
case COMMAND_DISPLAY_ONSCREEN_COUNTER:
{
assert(CTheScripts::ScriptSpace[m_nIp] == ARGUMENT_GLOBALVAR);
m_nIp++;
int32 counter = CTheScripts::Read2BytesFromScript(&m_nIp);
int32 counter = Read2BytesFromScript(&m_nIp);
CollectParameters(&m_nIp, 1);
CUserDisplay::OnscnTimer.AddCounter(counter, ScriptParams[0], nil);
return 0;
@ -2992,13 +2992,13 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
{
assert(CTheScripts::ScriptSpace[m_nIp] == ARGUMENT_GLOBALVAR);
m_nIp++;
CUserDisplay::OnscnTimer.ClearCounter(CTheScripts::Read2BytesFromScript(&m_nIp));
CUserDisplay::OnscnTimer.ClearCounter(Read2BytesFromScript(&m_nIp));
return 0;
}
case COMMAND_SET_ZONE_CAR_INFO:
{
char label[12];
CTheScripts::ReadTextLabelFromScript(&m_nIp, label);
ReadTextLabelFromScript(&m_nIp, label);
m_nIp += KEY_LENGTH_IN_SCRIPT;
CollectParameters(&m_nIp, 16);
int zone = CTheZones::FindZoneByLabelAndReturnIndex(label);
@ -3021,7 +3021,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
char label[12];
CTheScripts::ReadTextLabelFromScript(&m_nIp, label);
ReadTextLabelFromScript(&m_nIp, label);
int zone = CTheZones::FindZoneByLabelAndReturnIndex(label);
if (zone != -1)
m_nIp += KEY_LENGTH_IN_SCRIPT;
@ -3032,7 +3032,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
case COMMAND_SET_CAR_DENSITY:
{
char label[12];
CTheScripts::ReadTextLabelFromScript(&m_nIp, label);
ReadTextLabelFromScript(&m_nIp, label);
int16 zone = CTheZones::FindZoneByLabelAndReturnIndex(label);
m_nIp += 8;
CollectParameters(&m_nIp, 2);
@ -3046,7 +3046,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
case COMMAND_SET_PED_DENSITY:
{
char label[12];
CTheScripts::ReadTextLabelFromScript(&m_nIp, label);
ReadTextLabelFromScript(&m_nIp, label);
int16 zone = CTheZones::FindZoneByLabelAndReturnIndex(label);
m_nIp += KEY_LENGTH_IN_SCRIPT;
CollectParameters(&m_nIp, 2);
@ -3089,7 +3089,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
case COMMAND_SET_ZONE_PED_INFO:
{
char label[12];
CTheScripts::ReadTextLabelFromScript(&m_nIp, label);
ReadTextLabelFromScript(&m_nIp, label);
m_nIp += KEY_LENGTH_IN_SCRIPT;
CollectParameters(&m_nIp, 10);
int16 zone = CTheZones::FindZoneByLabelAndReturnIndex(label);
@ -3381,11 +3381,11 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
case COMMAND_GET_CAMERA_POSITION_ALONG_SPLINE:
*/
case COMMAND_DECLARE_MISSION_FLAG:
CTheScripts::OnAMissionFlag = CTheScripts::Read2BytesFromScript(&++m_nIp);
CTheScripts::OnAMissionFlag = Read2BytesFromScript(&++m_nIp);
return 0;
case COMMAND_DECLARE_MISSION_FLAG_FOR_CONTACT:
CollectParameters(&m_nIp, 1);
CTheScripts::OnAMissionForContactFlag[ScriptParams[0]] = CTheScripts::Read2BytesFromScript(&++m_nIp);
CTheScripts::OnAMissionForContactFlag[ScriptParams[0]] = Read2BytesFromScript(&++m_nIp);
return 0;
case COMMAND_DECLARE_BASE_BRIEF_ID_FOR_CONTACT:
CollectParameters(&m_nIp, 2);
@ -4191,21 +4191,21 @@ int8 CRunningScript::ProcessCommands400To499(int32 command)
}
case COMMAND_PRINT_WITH_NUMBER_BIG:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 3);
CMessages::AddBigMessageWithNumber(text, ScriptParams[1], ScriptParams[2] - 1, ScriptParams[0], -1, -1, -1, -1, -1);
return 0;
}
case COMMAND_PRINT_WITH_NUMBER:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 3);
CMessages::AddMessageWithNumber(text, ScriptParams[1], ScriptParams[2], ScriptParams[0], -1, -1, -1, -1, -1);
return 0;
}
case COMMAND_PRINT_WITH_NUMBER_NOW:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 3);
CMessages::AddMessageJumpQWithNumber(text, ScriptParams[1], ScriptParams[2], ScriptParams[0], -1, -1, -1, -1, -1);
return 0;
@ -4395,7 +4395,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
}
case COMMAND_ADD_PAGER_MESSAGE_WITH_NUMBER:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 4);
CUserDisplay::Pager.AddMessageWithNumber(text, ScriptParams[0], -1, -1, -1, -1, -1,
ScriptParams[1], ScriptParams[2], ScriptParams[3]);
@ -4403,7 +4403,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
}
case COMMAND_START_KILL_FRENZY:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 8);
CDarkel::StartFrenzy((eWeaponType)ScriptParams[0], ScriptParams[1], ScriptParams[2],
ScriptParams[3], text, ScriptParams[4], ScriptParams[5],
@ -4580,14 +4580,14 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
}
case COMMAND_PRINT_BIG_Q:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 2);
CMessages::AddBigMessageQ(text, ScriptParams[0], ScriptParams[1] - 1);
return 0;
}
case COMMAND_PRINT_WITH_NUMBER_BIG_Q:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 3);
CMessages::AddBigMessageWithNumberQ(text, ScriptParams[1], ScriptParams[2] - 1,
ScriptParams[0], -1, -1, -1, -1, -1);
@ -5104,14 +5104,14 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
case COMMAND_SET_REPEATED_PHONE_MESSAGE:
{
CollectParameters(&m_nIp, 1);
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
gPhoneInfo.SetPhoneMessage_Repeatedly(ScriptParams[0], text, nil, nil, nil, nil, nil);
return 0;
}
case COMMAND_SET_PHONE_MESSAGE:
{
CollectParameters(&m_nIp, 1);
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
gPhoneInfo.SetPhoneMessage_JustOnce(ScriptParams[0], text, nil, nil, nil, nil, nil);
return 0;
}
@ -5668,7 +5668,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command)
CollectParameters(&m_nIp, 2);
assert(m_nStackPointer < MAX_STACK_DEPTH);
m_anStack[m_nStackPointer++] = m_nIp;
m_nIp = ScriptParams[0];
SetIP(ScriptParams[0]);
// ScriptParams[1] == filename
return 0;
}
@ -6181,105 +6181,105 @@ int8 CRunningScript::ProcessCommands700To799(int32 command)
}
case COMMAND_PRINT_WITH_2_NUMBERS:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 4);
CMessages::AddMessageWithNumber(text, ScriptParams[2], ScriptParams[3], ScriptParams[0], ScriptParams[1], -1, -1, -1, -1);
return 0;
}
case COMMAND_PRINT_WITH_2_NUMBERS_NOW:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 4);
CMessages::AddMessageJumpQWithNumber(text, ScriptParams[2], ScriptParams[3], ScriptParams[0], ScriptParams[1], -1, -1, -1, -1);
return 0;
}
case COMMAND_PRINT_WITH_2_NUMBERS_SOON:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 4);
CMessages::AddMessageSoonWithNumber(text, ScriptParams[2], ScriptParams[3], ScriptParams[0], ScriptParams[1], -1, -1, -1, -1);
return 0;
}
case COMMAND_PRINT_WITH_3_NUMBERS:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 5);
CMessages::AddMessageWithNumber(text, ScriptParams[3], ScriptParams[4], ScriptParams[0], ScriptParams[1], ScriptParams[2], -1, -1, -1);
return 0;
}
case COMMAND_PRINT_WITH_3_NUMBERS_NOW:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 5);
CMessages::AddMessageJumpQWithNumber(text, ScriptParams[3], ScriptParams[4], ScriptParams[0], ScriptParams[1], ScriptParams[2], -1, -1, -1);
return 0;
}
case COMMAND_PRINT_WITH_3_NUMBERS_SOON:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 5);
CMessages::AddMessageSoonWithNumber(text, ScriptParams[3], ScriptParams[4], ScriptParams[0], ScriptParams[1], ScriptParams[2], -1, -1, -1);
return 0;
}
case COMMAND_PRINT_WITH_4_NUMBERS:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 6);
CMessages::AddMessageWithNumber(text, ScriptParams[4], ScriptParams[5], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], -1, -1);
return 0;
}
case COMMAND_PRINT_WITH_4_NUMBERS_NOW:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 6);
CMessages::AddMessageJumpQWithNumber(text, ScriptParams[4], ScriptParams[5], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], -1, -1);
return 0;
}
case COMMAND_PRINT_WITH_4_NUMBERS_SOON:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 6);
CMessages::AddMessageSoonWithNumber(text, ScriptParams[4], ScriptParams[5], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], -1, -1);
return 0;
}
case COMMAND_PRINT_WITH_5_NUMBERS:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 7);
CMessages::AddMessageWithNumber(text, ScriptParams[5], ScriptParams[6], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], -1);
return 0;
}
case COMMAND_PRINT_WITH_5_NUMBERS_NOW:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 7);
CMessages::AddMessageJumpQWithNumber(text, ScriptParams[5], ScriptParams[6], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], -1);
return 0;
}
case COMMAND_PRINT_WITH_5_NUMBERS_SOON:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 7);
CMessages::AddMessageSoonWithNumber(text, ScriptParams[5], ScriptParams[6], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], -1);
return 0;
}
case COMMAND_PRINT_WITH_6_NUMBERS:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 8);
CMessages::AddMessageWithNumber(text, ScriptParams[6], ScriptParams[7], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], ScriptParams[5]);
return 0;
}
case COMMAND_PRINT_WITH_6_NUMBERS_NOW:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 8);
CMessages::AddMessageJumpQWithNumber(text, ScriptParams[6], ScriptParams[7], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], ScriptParams[5]);
return 0;
}
case COMMAND_PRINT_WITH_6_NUMBERS_SOON:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 8);
CMessages::AddMessageSoonWithNumber(text, ScriptParams[6], ScriptParams[7], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], ScriptParams[5]);
return 0;
@ -6475,7 +6475,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
case COMMAND_SET_ZONE_GROUP:
{
char zone[KEY_LENGTH_IN_SCRIPT];
CTheScripts::ReadTextLabelFromScript(&m_nIp, zone);
ReadTextLabelFromScript(&m_nIp, zone);
m_nIp += KEY_LENGTH_IN_SCRIPT;
CollectParameters(&m_nIp, 2);
int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone);
@ -6537,7 +6537,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
case COMMAND_GET_RANDOM_CAR_OF_TYPE_IN_ZONE:
{
char zone[KEY_LENGTH_IN_SCRIPT];
CTheScripts::ReadTextLabelFromScript(&m_nIp, zone);
ReadTextLabelFromScript(&m_nIp, zone);
int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone);
if (zone_id != -1)
m_nIp += KEY_LENGTH_IN_SCRIPT;
@ -6736,7 +6736,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
case COMMAND_DISPLAY_TEXT:
{
CollectParameters(&m_nIp, 2);
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtX = *(float*)&ScriptParams[0];
CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtY = *(float*)&ScriptParams[1];
uint16 len = CMessages::GetWideStringLength(text);
@ -6981,7 +6981,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
char name[KEY_LENGTH_IN_SCRIPT];
CTheScripts::ReadTextLabelFromScript(&m_nIp, name);
ReadTextLabelFromScript(&m_nIp, name);
for (int i = 0; i < KEY_LENGTH_IN_SCRIPT; i++)
name[i] = tolower(name[i]);
int mi = pPed->GetModelIndex();
@ -7043,7 +7043,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
{
CollectParameters(&m_nIp, 1);
char zone[KEY_LENGTH_IN_SCRIPT];
CTheScripts::ReadTextLabelFromScript(&m_nIp, zone);
ReadTextLabelFromScript(&m_nIp, zone);
int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone);
if (zone_id != -1)
m_nIp += KEY_LENGTH_IN_SCRIPT;
@ -7224,7 +7224,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
}
case COMMAND_START_KILL_FRENZY_HEADSHOT:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 8);
CDarkel::StartFrenzy((eWeaponType)ScriptParams[0], ScriptParams[1], ScriptParams[2],
ScriptParams[3], text, ScriptParams[4], ScriptParams[5],
@ -7278,35 +7278,35 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
//case COMMAND_SET_AUDIO_STREAM:
case COMMAND_PRINT_WITH_2_NUMBERS_BIG:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 4);
CMessages::AddBigMessageWithNumber(text, ScriptParams[2], ScriptParams[3] - 1, ScriptParams[0], ScriptParams[1], -1, -1, -1, -1);
return 0;
}
case COMMAND_PRINT_WITH_3_NUMBERS_BIG:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 5);
CMessages::AddBigMessageWithNumber(text, ScriptParams[3], ScriptParams[4] - 1, ScriptParams[0], ScriptParams[1], ScriptParams[2], -1, -1, -1);
return 0;
}
case COMMAND_PRINT_WITH_4_NUMBERS_BIG:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 6);
CMessages::AddBigMessageWithNumber(text, ScriptParams[4], ScriptParams[5] - 1, ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], -1, -1);
return 0;
}
case COMMAND_PRINT_WITH_5_NUMBERS_BIG:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 7);
CMessages::AddBigMessageWithNumber(text, ScriptParams[5], ScriptParams[6] - 1, ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], -1);
return 0;
}
case COMMAND_PRINT_WITH_6_NUMBERS_BIG:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 8);
CMessages::AddBigMessageWithNumber(text, ScriptParams[6], ScriptParams[7] - 1, ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], ScriptParams[5]);
return 0;
@ -7328,8 +7328,8 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
return 0;
case COMMAND_PRINT_STRING_IN_STRING:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* string = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
wchar* string = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 2);
CMessages::AddMessageWithString(text, ScriptParams[0], ScriptParams[1], string);
return 0;
@ -7384,54 +7384,54 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
case COMMAND_SET_2_REPEATED_PHONE_MESSAGES:
{
CollectParameters(&m_nIp, 1);
wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text1 = GetTextByKeyFromScript(&m_nIp);
wchar* text2 = GetTextByKeyFromScript(&m_nIp);
gPhoneInfo.SetPhoneMessage_Repeatedly(ScriptParams[0], text1, text2, nil, nil, nil, nil);
return 0;
}
case COMMAND_SET_2_PHONE_MESSAGES:
{
CollectParameters(&m_nIp, 1);
wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text1 = GetTextByKeyFromScript(&m_nIp);
wchar* text2 = GetTextByKeyFromScript(&m_nIp);
gPhoneInfo.SetPhoneMessage_JustOnce(ScriptParams[0], text1, text2, nil, nil, nil, nil);
return 0;
}
case COMMAND_SET_3_REPEATED_PHONE_MESSAGES:
{
CollectParameters(&m_nIp, 1);
wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text1 = GetTextByKeyFromScript(&m_nIp);
wchar* text2 = GetTextByKeyFromScript(&m_nIp);
wchar* text3 = GetTextByKeyFromScript(&m_nIp);
gPhoneInfo.SetPhoneMessage_Repeatedly(ScriptParams[0], text1, text2, text3, nil, nil, nil);
return 0;
}
case COMMAND_SET_3_PHONE_MESSAGES:
{
CollectParameters(&m_nIp, 1);
wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text1 = GetTextByKeyFromScript(&m_nIp);
wchar* text2 = GetTextByKeyFromScript(&m_nIp);
wchar* text3 = GetTextByKeyFromScript(&m_nIp);
gPhoneInfo.SetPhoneMessage_JustOnce(ScriptParams[0], text1, text2, text3, nil, nil, nil);
return 0;
}
case COMMAND_SET_4_REPEATED_PHONE_MESSAGES:
{
CollectParameters(&m_nIp, 1);
wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text4 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text1 = GetTextByKeyFromScript(&m_nIp);
wchar* text2 = GetTextByKeyFromScript(&m_nIp);
wchar* text3 = GetTextByKeyFromScript(&m_nIp);
wchar* text4 = GetTextByKeyFromScript(&m_nIp);
gPhoneInfo.SetPhoneMessage_Repeatedly(ScriptParams[0], text1, text2, text3, text4, nil, nil);
return 0;
}
case COMMAND_SET_4_PHONE_MESSAGES:
{
CollectParameters(&m_nIp, 1);
wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text4 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text1 = GetTextByKeyFromScript(&m_nIp);
wchar* text2 = GetTextByKeyFromScript(&m_nIp);
wchar* text3 = GetTextByKeyFromScript(&m_nIp);
wchar* text4 = GetTextByKeyFromScript(&m_nIp);
gPhoneInfo.SetPhoneMessage_JustOnce(ScriptParams[0], text1, text2, text3, text4, nil, nil);
return 0;
}
@ -7508,8 +7508,8 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
switch (command) {
case COMMAND_PRINT_STRING_IN_STRING_NOW:
{
wchar* source = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* pstr = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* source = GetTextByKeyFromScript(&m_nIp);
wchar* pstr = GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 2);
CMessages::AddMessageJumpQWithString(source, ScriptParams[0], ScriptParams[1], pstr);
return 0;
@ -7518,46 +7518,46 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
case COMMAND_SET_5_REPEATED_PHONE_MESSAGES:
{
CollectParameters(&m_nIp, 1);
wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text4 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text5 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text1 = GetTextByKeyFromScript(&m_nIp);
wchar* text2 = GetTextByKeyFromScript(&m_nIp);
wchar* text3 = GetTextByKeyFromScript(&m_nIp);
wchar* text4 = GetTextByKeyFromScript(&m_nIp);
wchar* text5 = GetTextByKeyFromScript(&m_nIp);
gPhoneInfo.SetPhoneMessage_Repeatedly(ScriptParams[0], text1, text2, text3, text4, text5, nil);
return 0;
}
case COMMAND_SET_5_PHONE_MESSAGES:
{
CollectParameters(&m_nIp, 1);
wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text4 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text5 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text1 = GetTextByKeyFromScript(&m_nIp);
wchar* text2 = GetTextByKeyFromScript(&m_nIp);
wchar* text3 = GetTextByKeyFromScript(&m_nIp);
wchar* text4 = GetTextByKeyFromScript(&m_nIp);
wchar* text5 = GetTextByKeyFromScript(&m_nIp);
gPhoneInfo.SetPhoneMessage_JustOnce(ScriptParams[0], text1, text2, text3, text4, text5, nil);
return 0;
}
case COMMAND_SET_6_REPEATED_PHONE_MESSAGES:
{
CollectParameters(&m_nIp, 1);
wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text4 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text5 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text6 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text1 = GetTextByKeyFromScript(&m_nIp);
wchar* text2 = GetTextByKeyFromScript(&m_nIp);
wchar* text3 = GetTextByKeyFromScript(&m_nIp);
wchar* text4 = GetTextByKeyFromScript(&m_nIp);
wchar* text5 = GetTextByKeyFromScript(&m_nIp);
wchar* text6 = GetTextByKeyFromScript(&m_nIp);
gPhoneInfo.SetPhoneMessage_Repeatedly(ScriptParams[0], text1, text2, text3, text4, text5, text6);
return 0;
}
case COMMAND_SET_6_PHONE_MESSAGES:
{
CollectParameters(&m_nIp, 1);
wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text4 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text5 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text6 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text1 = GetTextByKeyFromScript(&m_nIp);
wchar* text2 = GetTextByKeyFromScript(&m_nIp);
wchar* text3 = GetTextByKeyFromScript(&m_nIp);
wchar* text4 = GetTextByKeyFromScript(&m_nIp);
wchar* text5 = GetTextByKeyFromScript(&m_nIp);
wchar* text6 = GetTextByKeyFromScript(&m_nIp);
gPhoneInfo.SetPhoneMessage_JustOnce(ScriptParams[0], text1, text2, text3, text4, text5, text6);
return 0;
}
@ -8061,7 +8061,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
case COMMAND_DISPLAY_ONSCREEN_TIMER_WITH_STRING:
{
assert(CTheScripts::ScriptSpace[m_nIp++] == ARGUMENT_GLOBALVAR);
int16 var = CTheScripts::Read2BytesFromScript(&m_nIp);
int16 var = Read2BytesFromScript(&m_nIp);
wchar* text = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); // ???
strncpy(onscreen_str, (char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT);
m_nIp += KEY_LENGTH_IN_SCRIPT;
@ -8071,7 +8071,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
case COMMAND_DISPLAY_ONSCREEN_COUNTER_WITH_STRING:
{
assert(CTheScripts::ScriptSpace[m_nIp++] == ARGUMENT_GLOBALVAR);
int16 var = CTheScripts::Read2BytesFromScript(&m_nIp);
int16 var = Read2BytesFromScript(&m_nIp);
CollectParameters(&m_nIp, 1);
wchar* text = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); // ???
strncpy(onscreen_str, (char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT);
@ -8287,13 +8287,13 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
}
case COMMAND_CLEAR_THIS_PRINT:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CMessages::ClearThisPrint(text);
return 0;
}
case COMMAND_CLEAR_THIS_BIG_PRINT:
{
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CMessages::ClearThisBigPrint(text);
return 0;
}
@ -8383,7 +8383,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
m_nIp += KEY_LENGTH_IN_SCRIPT;
return 0;
}
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CHud::SetHelpMessage(text, false);
return 0;
}
@ -9124,7 +9124,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
CTimer::Update();
return 0;
case COMMAND_LOAD_SPLASH_SCREEN:
CTheScripts::ReadTextLabelFromScript(&m_nIp, tmp);
ReadTextLabelFromScript(&m_nIp, tmp);
for (int i = 0; i < KEY_LENGTH_IN_SCRIPT; i++)
tmp[i] = tolower(tmp[i]);
m_nIp += 8;
@ -9226,7 +9226,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
}
case COMMAND_TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME:
{
CTheScripts::ReadTextLabelFromScript(&m_nIp, tmp);
ReadTextLabelFromScript(&m_nIp, tmp);
for (int i = 0; i < KEY_LENGTH_IN_SCRIPT; i++)
tmp[i] = tolower(tmp[i]);
m_nIp += 8;
@ -9244,7 +9244,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
case COMMAND_DISPLAY_TEXT_WITH_NUMBER:
{
CollectParameters(&m_nIp, 2);
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtX = *(float*)&ScriptParams[0];
CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtY = *(float*)&ScriptParams[1];
CollectParameters(&m_nIp, 1);
@ -9255,7 +9255,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
case COMMAND_DISPLAY_TEXT_WITH_2_NUMBERS:
{
CollectParameters(&m_nIp, 2);
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp);
wchar* text = GetTextByKeyFromScript(&m_nIp);
CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtX = *(float*)&ScriptParams[0];
CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtY = *(float*)&ScriptParams[1];
CollectParameters(&m_nIp, 2);
@ -9989,27 +9989,7 @@ WRAPPER void CTheScripts::UpdateObjectIndices() { EAXJMP(0x454AD0); }
WRAPPER void CTheScripts::ReadMultiScriptFileOffsetsFromScript() { EAXJMP(0x454BC0); }
STARTPATCHES
InjectHook(0x437AE0, &CMissionCleanup::Init, PATCH_JUMP);
InjectHook(0x437BA0, &CMissionCleanup::AddEntityToList, PATCH_JUMP);
InjectHook(0x437BD0, &CMissionCleanup::RemoveEntityFromList, PATCH_JUMP);
InjectHook(0x437C10, &CMissionCleanup::Process, PATCH_JUMP);
InjectHook(0x437DC0, &CUpsideDownCarCheck::Init, PATCH_JUMP);
InjectHook(0x437EE0, &CUpsideDownCarCheck::UpdateTimers, PATCH_JUMP);
InjectHook(0x437F80, &CUpsideDownCarCheck::AreAnyCarsUpsideDown, PATCH_JUMP);
InjectHook(0x437FB0, &CUpsideDownCarCheck::AddCarToCheck, PATCH_JUMP);
InjectHook(0x437FE0, &CUpsideDownCarCheck::RemoveCarFromCheck, PATCH_JUMP);
InjectHook(0x438010, &CUpsideDownCarCheck::HasCarBeenUpsideDownForAWhile, PATCH_JUMP);
InjectHook(0x438050, &CStuckCarCheck::Init, PATCH_JUMP);
InjectHook(0x4380A0, &CStuckCarCheck::Process, PATCH_JUMP);
InjectHook(0x4381C0, &CStuckCarCheck::AddCarToCheck, PATCH_JUMP);
InjectHook(0x438240, &CStuckCarCheck::RemoveCarFromCheck, PATCH_JUMP);
InjectHook(0x4382A0, &CStuckCarCheck::HasCarBeenStuckForAWhile, PATCH_JUMP);
InjectHook(0x4382E0, &CRunningScript::CollectParameters, PATCH_JUMP);
InjectHook(0x438460, &CRunningScript::CollectNextParameterWithoutIncreasingPC, PATCH_JUMP);
InjectHook(0x4385A0, &CRunningScript::StoreParameters, PATCH_JUMP);
InjectHook(0x438640, &CRunningScript::GetPointerToScriptVariable, PATCH_JUMP);
InjectHook(0x438790, &CTheScripts::Init, PATCH_JUMP);
InjectHook(0x439000, &CTheScripts::StartNewScript, PATCH_JUMP);
InjectHook(0x439040, &CTheScripts::Process, PATCH_JUMP);
InjectHook(0x439400, &CTheScripts::StartTestScript, PATCH_JUMP);
InjectHook(0x439410, &CTheScripts::IsPlayerOnAMission, PATCH_JUMP);

View File

@ -11,6 +11,8 @@ class CPed;
class CObject;
class CPlayerInfo;
class CRunningScript;
#define KEY_LENGTH_IN_SCRIPT 8
struct CScriptRectangle
@ -81,123 +83,6 @@ struct CScriptSphere
float m_fRadius;
};
enum {
MAX_STACK_DEPTH = 6,
NUM_LOCAL_VARS = 16,
NUM_TIMERS = 2
};
class CRunningScript
{
CRunningScript *next;
CRunningScript *prev;
char m_abScriptName[8];
uint32 m_nIp;
uint32 m_anStack[MAX_STACK_DEPTH];
uint16 m_nStackPointer;
int32 m_anLocalVariables[NUM_LOCAL_VARS + NUM_TIMERS];
bool m_bCondResult;
bool m_bIsMissionScript;
bool m_bSkipWakeTime;
uint32 m_nWakeTime;
uint16 m_nAndOrState;
bool m_bNotFlag;
bool m_bDeatharrestEnabled;
bool m_bDeatharrestExecuted;
bool m_bMissionFlag;
public:
void SetIP(uint32 ip) { m_nIp = ip; }
CRunningScript* GetNext() { return next; }
void UpdateTimers(float timeStep){
m_anLocalVariables[NUM_LOCAL_VARS] += timeStep;
m_anLocalVariables[NUM_LOCAL_VARS + 1] += timeStep;
}
bool ThisIsAValidRandomPed(uint32 pedtype){
switch (pedtype){
case PEDTYPE_CIVMALE:
case PEDTYPE_CIVFEMALE:
case PEDTYPE_GANG1:
case PEDTYPE_GANG2:
case PEDTYPE_GANG3:
case PEDTYPE_GANG4:
case PEDTYPE_GANG5:
case PEDTYPE_GANG6:
case PEDTYPE_GANG7:
case PEDTYPE_GANG8:
case PEDTYPE_GANG9:
case PEDTYPE_CRIMINAL:
case PEDTYPE_PROSTITUTE:
return true;
default:
return false;
}
}
float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; }
void CollectParameters(uint32*, int16);
int32 CollectNextParameterWithoutIncreasingPC(uint32);
int32* GetPointerToScriptVariable(uint32*, int16);
void StoreParameters(uint32*, int16);
void Init();
void RemoveScriptFromList(CRunningScript**);
void AddScriptToList(CRunningScript**);
void Process();
int8 ProcessOneCommand();
void DoDeatharrestCheck();
int8 ProcessCommands0To99(int32);
int8 ProcessCommands100To199(int32);
int8 ProcessCommands200To299(int32);
int8 ProcessCommands300To399(int32);
int8 ProcessCommands400To499(int32);
int8 ProcessCommands500To599(int32);
int8 ProcessCommands600To699(int32);
int8 ProcessCommands700To799(int32);
int8 ProcessCommands800To899(int32);
int8 ProcessCommands900To999(int32);
int8 ProcessCommands1000To1099(int32);
#ifndef GTA_PS2
int8 ProcessCommands1100To1199(int32);
#endif
void UpdateCompareFlag(bool);
int16 GetPadState(uint16, uint16);
void LocatePlayerCommand(int32, uint32*);
void LocatePlayerCharCommand(int32, uint32*);
void LocatePlayerCarCommand(int32, uint32*);
void LocateCharCommand(int32, uint32*);
void LocateCharCharCommand(int32, uint32*);
void LocateCharCarCommand(int32, uint32*);
void LocateCharObjectCommand(int32, uint32*);
void LocateCarCommand(int32, uint32*);
void LocateSniperBulletCommand(int32, uint32*);
void PlayerInAreaCheckCommand(int32, uint32*);
void PlayerInAngledAreaCheckCommand(int32, uint32*);
void CharInAreaCheckCommand(int32, uint32*);
void CarInAreaCheckCommand(int32, uint32*);
private:
enum {
ANDOR_NONE = 0,
ANDS_1 = 1,
ANDS_2,
ANDS_3,
ANDS_4,
ANDS_5,
ANDS_6,
ANDS_7,
ANDS_8,
ORS_1 = 21,
ORS_2,
ORS_3,
ORS_4,
ORS_5,
ORS_6,
ORS_7,
ORS_8
};
};
enum {
CLEANUP_UNUSED = 0,
CLEANUP_CAR,
@ -337,7 +222,6 @@ enum {
class CTheScripts
{
public:
static uint8(&ScriptSpace)[SIZE_SCRIPT_SPACE];
static CRunningScript(&ScriptsArray)[MAX_NUM_SCRIPTS];
static int32(&BaseBriefIdForContact)[MAX_NUM_CONTACTS];
@ -377,16 +261,34 @@ public:
static bool &UseTextCommands;
static uint16 &CommandsExecuted;
static uint16 &ScriptsUpdated;
public:
static void Init();
static void Process();
static CRunningScript* StartTestScript();
static bool IsPlayerOnAMission();
static void ClearSpaceForMissionEntity(const CVector&, CEntity*);
static void ScriptDebugLine3D(float x1, float y1, float z1, float x2, float y2, float z2, int col, int col2);
static void UndoBuildingSwaps();
static void UndoEntityVisibilitySettings();
static bool IsDebugOn() { return DbgFlag; };
static void InvertDebugFlag() { DbgFlag = !DbgFlag; }
static int32* GetPointerToScriptVariable(int32 offset) { return (int32*)&ScriptSpace[offset]; }
static void ResetCountdownToMakePlayerUnsafe() { CountdownToMakePlayerUnsafe = 0; }
static bool IsCountdownToMakePlayerUnsafeOn() { return CountdownToMakePlayerUnsafe != 0; }
private:
static CRunningScript* StartNewScript(uint32);
static void CleanUpThisVehicle(CVehicle*);
static void CleanUpThisPed(CPed*);
static void CleanUpThisObject(CObject*);
static void Init();
static CRunningScript* StartNewScript(uint32);
static void Process();
static CRunningScript* StartTestScript();
static bool IsPlayerOnAMission();
static bool IsPedStopped(CPed*);
static bool IsPlayerStopped(CPlayerInfo*);
static bool IsVehicleStopped(CVehicle*);
@ -395,7 +297,6 @@ public:
static void UpdateObjectIndices();
static void ReadMultiScriptFileOffsetsFromScript();
static void DrawScriptSpheres();
static void ClearSpaceForMissionEntity(const CVector&, CEntity*);
static void HighlightImportantArea(uint32, float, float, float, float, float);
static void HighlightImportantAngledArea(uint32, float, float, float, float, float, float, float, float, float);
static void DrawDebugSquare(float, float, float, float);
@ -407,32 +308,89 @@ public:
static void LoadAllScripts(uint8*, uint32);
static void AddToInvisibilitySwapArray(CEntity*, bool);
static void AddToBuildingSwapArray(CBuilding*, int32, int32);
static void UndoBuildingSwaps();
static void UndoEntityVisibilitySettings();
static int32 GetActualScriptSphereIndex(int32 index);
static int32 AddScriptSphere(int32 id, CVector pos, float radius);
static int32 GetNewUniqueScriptSphereIndex(int32 index);
static void RemoveScriptSphere(int32 index);
friend class CRunningScript;
friend class CHud;
friend void CMissionCleanup::Process();
};
enum {
MAX_STACK_DEPTH = 6,
NUM_LOCAL_VARS = 16,
NUM_TIMERS = 2
};
class CRunningScript
{
enum {
ANDOR_NONE = 0,
ANDS_1 = 1,
ANDS_2,
ANDS_3,
ANDS_4,
ANDS_5,
ANDS_6,
ANDS_7,
ANDS_8,
ORS_1 = 21,
ORS_2,
ORS_3,
ORS_4,
ORS_5,
ORS_6,
ORS_7,
ORS_8
};
CRunningScript* next;
CRunningScript* prev;
char m_abScriptName[8];
uint32 m_nIp;
uint32 m_anStack[MAX_STACK_DEPTH];
uint16 m_nStackPointer;
int32 m_anLocalVariables[NUM_LOCAL_VARS + NUM_TIMERS];
bool m_bCondResult;
bool m_bIsMissionScript;
bool m_bSkipWakeTime;
uint32 m_nWakeTime;
uint16 m_nAndOrState;
bool m_bNotFlag;
bool m_bDeatharrestEnabled;
bool m_bDeatharrestExecuted;
bool m_bMissionFlag;
public:
void SetIP(uint32 ip) { m_nIp = ip; }
CRunningScript* GetNext() const { return next; }
void UpdateTimers(float timeStep) {
m_anLocalVariables[NUM_LOCAL_VARS] += timeStep;
m_anLocalVariables[NUM_LOCAL_VARS + 1] += timeStep;
}
static int32 Read4BytesFromScript(uint32* pIp) {
int32 retval = 0;
for (int i = 0; i < 4; i++) {
retval |= ScriptSpace[(*pIp)++] << (8 * i);
retval |= CTheScripts::ScriptSpace[(*pIp)++] << (8 * i);
}
return retval;
}
static int16 Read2BytesFromScript(uint32* pIp) {
int16 retval = 0;
for (int i = 0; i < 2; i++) {
retval |= ScriptSpace[(*pIp)++] << (8 * i);
retval |= CTheScripts::ScriptSpace[(*pIp)++] << (8 * i);
}
return retval;
}
static int8 Read1ByteFromScript(uint32* pIp) {
int8 retval = 0;
for (int i = 0; i < 1; i++) {
retval |= ScriptSpace[(*pIp)++] << (8 * i);
retval |= CTheScripts::ScriptSpace[(*pIp)++] << (8 * i);
}
return retval;
}
@ -440,11 +398,79 @@ public:
return Read2BytesFromScript(pIp) / 16.0f;
}
static void ReadTextLabelFromScript(uint32* pIp, char* buf) {
strncpy(buf, (const char*)&ScriptSpace[*pIp], KEY_LENGTH_IN_SCRIPT);
strncpy(buf, (const char*)&CTheScripts::ScriptSpace[*pIp], KEY_LENGTH_IN_SCRIPT);
}
static wchar* GetTextByKeyFromScript(uint32* pIp) {
wchar* text = TheText.Get((const char*)&ScriptSpace[*pIp]);
wchar* text = TheText.Get((const char*)&CTheScripts::ScriptSpace[*pIp]);
*pIp += KEY_LENGTH_IN_SCRIPT;
return text;
}
void Init();
void Process();
void RemoveScriptFromList(CRunningScript**);
void AddScriptToList(CRunningScript**);
private:
void CollectParameters(uint32*, int16);
int32 CollectNextParameterWithoutIncreasingPC(uint32);
int32* GetPointerToScriptVariable(uint32*, int16);
void StoreParameters(uint32*, int16);
int8 ProcessOneCommand();
void DoDeatharrestCheck();
void UpdateCompareFlag(bool);
int16 GetPadState(uint16, uint16);
int8 ProcessCommands0To99(int32);
int8 ProcessCommands100To199(int32);
int8 ProcessCommands200To299(int32);
int8 ProcessCommands300To399(int32);
int8 ProcessCommands400To499(int32);
int8 ProcessCommands500To599(int32);
int8 ProcessCommands600To699(int32);
int8 ProcessCommands700To799(int32);
int8 ProcessCommands800To899(int32);
int8 ProcessCommands900To999(int32);
int8 ProcessCommands1000To1099(int32);
#ifndef GTA_PS2
int8 ProcessCommands1100To1199(int32);
#endif
void LocatePlayerCommand(int32, uint32*);
void LocatePlayerCharCommand(int32, uint32*);
void LocatePlayerCarCommand(int32, uint32*);
void LocateCharCommand(int32, uint32*);
void LocateCharCharCommand(int32, uint32*);
void LocateCharCarCommand(int32, uint32*);
void LocateCharObjectCommand(int32, uint32*);
void LocateCarCommand(int32, uint32*);
void LocateSniperBulletCommand(int32, uint32*);
void PlayerInAreaCheckCommand(int32, uint32*);
void PlayerInAngledAreaCheckCommand(int32, uint32*);
void CharInAreaCheckCommand(int32, uint32*);
void CarInAreaCheckCommand(int32, uint32*);
float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; }
bool ThisIsAValidRandomPed(uint32 pedtype) {
switch (pedtype) {
case PEDTYPE_CIVMALE:
case PEDTYPE_CIVFEMALE:
case PEDTYPE_GANG1:
case PEDTYPE_GANG2:
case PEDTYPE_GANG3:
case PEDTYPE_GANG4:
case PEDTYPE_GANG5:
case PEDTYPE_GANG6:
case PEDTYPE_GANG7:
case PEDTYPE_GANG8:
case PEDTYPE_GANG9:
case PEDTYPE_CRIMINAL:
case PEDTYPE_PROSTITUTE:
return true;
default:
return false;
}
}
};

View File

@ -732,7 +732,7 @@ void CMenuManager::Draw()
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(gString);
break;
case MENUACTION_SETDBGFLAG:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(CTheScripts::DbgFlag ? "FEM_ON" : "FEM_OFF");
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(CTheScripts::IsDebugOn() ? "FEM_ON" : "FEM_OFF");
break;
case MENUACTION_SWITCHBIGWHITEDEBUGLIGHT:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(gbBigWhiteDebugLightSwitchedOn ? "FEM_ON" : "FEM_OFF");
@ -2150,7 +2150,7 @@ void CMenuManager::ProcessOnOffMenuOptions()
SaveSettings();
break;
case MENUACTION_SETDBGFLAG:
CTheScripts::DbgFlag = !CTheScripts::DbgFlag;
CTheScripts::InvertDebugFlag();
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0);
break;
case MENUACTION_SWITCHBIGWHITEDEBUGLIGHT:

View File

@ -164,7 +164,7 @@ void
CPlayerInfo::MakePlayerSafe(bool toggle)
{
if (toggle) {
CTheScripts::CountdownToMakePlayerUnsafe = 0;
CTheScripts::ResetCountdownToMakePlayerUnsafe();
m_pPed->m_pWanted->m_bIgnoredByEveryone = true;
CWorld::StopAllLawEnforcersInTheirTracks();
CPad::GetPad(0)->DisablePlayerControls |= PLAYERCONTROL_DISABLED_20;
@ -185,7 +185,7 @@ CPlayerInfo::MakePlayerSafe(bool toggle)
CWorld::ExtinguishAllCarFiresInArea(GetPos(), 4000.0f);
CReplay::DisableReplays();
} else if (!CGame::playingIntro && !CTheScripts::CountdownToMakePlayerUnsafe) {
} else if (!CGame::playingIntro && !CTheScripts::IsCountdownToMakePlayerUnsafeOn()) {
m_pPed->m_pWanted->m_bIgnoredByEveryone = false;
CPad::GetPad(0)->DisablePlayerControls &= ~PLAYERCONTROL_DISABLED_20;
m_pPed->bBulletProof = false;

View File

@ -325,7 +325,7 @@ void CRadar::DrawBlips()
if (blipEntity) {
uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim);
if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) {
if (CTheScripts::DbgFlag) {
if (CTheScripts::IsDebugOn()) {
ShowRadarMarker(blipEntity->GetPosition(), color, ms_RadarTrace[blipId].m_Radius);
ms_RadarTrace[blipId].m_Radius = ms_RadarTrace[blipId].m_Radius - 0.1f;
if (ms_RadarTrace[blipId].m_Radius < 1.0f)
@ -364,7 +364,7 @@ void CRadar::DrawBlips()
uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim);
if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) {
if (CTheScripts::DbgFlag) {
if (CTheScripts::IsDebugOn()) {
ShowRadarMarker(ms_RadarTrace[blipId].m_vecPos, color, ms_RadarTrace[blipId].m_Radius);
ms_RadarTrace[blipId].m_Radius = ms_RadarTrace[blipId].m_Radius - 0.1f;
if (ms_RadarTrace[blipId].m_Radius < 1.0f)
@ -429,7 +429,7 @@ void CRadar::DrawBlips()
if (blipEntity) {
uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim);
if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) {
if (CTheScripts::DbgFlag) {
if (CTheScripts::IsDebugOn()) {
ShowRadarMarker(blipEntity->GetPosition(), color, ms_RadarTrace[blipId].m_Radius);
ms_RadarTrace[blipId].m_Radius = ms_RadarTrace[blipId].m_Radius - 0.1f;
if (ms_RadarTrace[blipId].m_Radius < 1.0f)
@ -478,7 +478,7 @@ void CRadar::DrawBlips()
uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim);
if (ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_BOTH || ms_RadarTrace[blipId].m_eBlipDisplay == BLIP_DISPLAY_MARKER_ONLY) {
if (CTheScripts::DbgFlag) {
if (CTheScripts::IsDebugOn()) {
ShowRadarMarker(ms_RadarTrace[blipId].m_vecPos, color, ms_RadarTrace[blipId].m_Radius);
ms_RadarTrace[blipId].m_Radius = ms_RadarTrace[blipId].m_Radius - 0.1f;
if (ms_RadarTrace[blipId].m_Radius < 1.0f)