CPopulation 3 and fixes

This commit is contained in:
eray orçunus 2020-02-27 19:07:36 +03:00
parent cbf396e6e9
commit 750d3229a3
8 changed files with 430 additions and 95 deletions

View File

@ -3757,7 +3757,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command)
CollectParameters(&m_nIp, 2); CollectParameters(&m_nIp, 2);
CPlayerInfo* pPlayer = &CWorld::Players[ScriptParams[0]]; CPlayerInfo* pPlayer = &CWorld::Players[ScriptParams[0]];
if (ScriptParams[1]){ if (ScriptParams[1]){
if (CReplay::IsPlayingBack() || CTheScripts::DelayMakingPlayerUnsafeThisTime){ if (CGame::playingIntro || CTheScripts::DelayMakingPlayerUnsafeThisTime){
CTheScripts::CountdownToMakePlayerUnsafe = 50; CTheScripts::CountdownToMakePlayerUnsafe = 50;
if (CTheScripts::DelayMakingPlayerUnsafeThisTime) if (CTheScripts::DelayMakingPlayerUnsafeThisTime)
CTheScripts::DelayMakingPlayerUnsafeThisTime--; CTheScripts::DelayMakingPlayerUnsafeThisTime--;

View File

@ -580,23 +580,26 @@ void CMenuManager::Draw()
float usableLineHeight = lineHeight * 0.9f; // also height of biggest bar in slider float usableLineHeight = lineHeight * 0.9f; // also height of biggest bar in slider
float freeSpaceInLine = lineHeight * 0.1f; // also height of smallest bar in slider(weird) float freeSpaceInLine = lineHeight * 0.1f; // also height of smallest bar in slider(weird)
bool foundTheHoveringItem = false; bool foundTheHoveringItem = false;
wchar unicodeTemp[64];
for (int i = 0; i < NUM_MENUROWS; ++i) { for (int i = 0; i < NUM_MENUROWS; ++i) {
if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action != MENUACTION_LABEL && aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName[0] != '\0') { if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action != MENUACTION_LABEL && aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName[0] != '\0') {
wchar *textToPrint[MENUCOLUMNS] = { nil, nil, nil }; wchar *rightText = nil;
wchar *leftText;
if (aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot >= SAVESLOT_1 && aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot <= SAVESLOT_8) { if (aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot >= SAVESLOT_1 && aScreens[m_nCurrScreen].m_aEntries[i].m_SaveSlot <= SAVESLOT_8) {
CFont::SetRightJustifyOff(); CFont::SetRightJustifyOff();
textToPrint[MENUCOLUMN_LEFT] = GetNameOfSavedGame(i - 1); leftText = GetNameOfSavedGame(i - 1);
if (Slots[i] != SLOT_EMPTY) if (Slots[i] != SLOT_EMPTY)
textToPrint[MENUCOLUMN_RIGHT] = GetSavedGameDateAndTime(i - 1); rightText = GetSavedGameDateAndTime(i - 1);
if (textToPrint[MENUCOLUMN_LEFT][0] == '\0') { if (leftText[0] == '\0') {
sprintf(gString, "FEM_SL%d", i); sprintf(gString, "FEM_SL%d", i);
textToPrint[MENUCOLUMN_LEFT] = TheText.Get(gString); leftText = TheText.Get(gString);
} }
} else { } else {
textToPrint[MENUCOLUMN_LEFT] = TheText.Get(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName); leftText = TheText.Get(aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName);
} }
switch (aScreens[m_nCurrScreen].m_aEntries[i].m_Action) { switch (aScreens[m_nCurrScreen].m_aEntries[i].m_Action) {
@ -605,28 +608,28 @@ void CMenuManager::Draw()
case MENUPAGE_MULTIPLAYER_MAP: case MENUPAGE_MULTIPLAYER_MAP:
switch (sthWithButtons) { switch (sthWithButtons) {
case 0: case 0:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEM_MA0"); rightText = TheText.Get("FEM_MA0");
break; break;
case 1: case 1:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEM_MA1"); rightText = TheText.Get("FEM_MA1");
break; break;
case 2: case 2:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEM_MA2"); rightText = TheText.Get("FEM_MA2");
break; break;
case 3: case 3:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEM_MA3"); rightText = TheText.Get("FEM_MA3");
break; break;
case 4: case 4:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEM_MA4"); rightText = TheText.Get("FEM_MA4");
break; break;
case 5: case 5:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEM_MA5"); rightText = TheText.Get("FEM_MA5");
break; break;
case 6: case 6:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEM_MA6"); rightText = TheText.Get("FEM_MA6");
break; break;
case 7: case 7:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEM_MA7"); rightText = TheText.Get("FEM_MA7");
break; break;
default: default:
break; break;
@ -635,28 +638,28 @@ void CMenuManager::Draw()
case MENUPAGE_MULTIPLAYER_MODE: case MENUPAGE_MULTIPLAYER_MODE:
switch (sthWithButtons2) { switch (sthWithButtons2) {
case 0: case 0:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEN_TY0"); rightText = TheText.Get("FEN_TY0");
break; break;
case 1: case 1:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEN_TY1"); rightText = TheText.Get("FEN_TY1");
break; break;
case 2: case 2:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEN_TY2"); rightText = TheText.Get("FEN_TY2");
break; break;
case 3: case 3:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEN_TY3"); rightText = TheText.Get("FEN_TY3");
break; break;
case 4: case 4:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEN_TY4"); rightText = TheText.Get("FEN_TY4");
break; break;
case 5: case 5:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEN_TY5"); rightText = TheText.Get("FEN_TY5");
break; break;
case 6: case 6:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEN_TY6"); rightText = TheText.Get("FEN_TY6");
break; break;
case 7: case 7:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEN_TY7"); rightText = TheText.Get("FEN_TY7");
break; break;
default: default:
break; break;
@ -669,57 +672,57 @@ void CMenuManager::Draw()
} }
case MENUACTION_CTRLVIBRATION: case MENUACTION_CTRLVIBRATION:
if (CMenuManager::m_PrefsUseVibration) if (CMenuManager::m_PrefsUseVibration)
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEM_ON"); rightText = TheText.Get("FEM_ON");
else else
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEM_OFF"); rightText = TheText.Get("FEM_OFF");
break; break;
case MENUACTION_CTRLCONFIG: case MENUACTION_CTRLCONFIG:
switch (CPad::GetPad(0)->Mode) { switch (CPad::GetPad(0)->Mode) {
case 0: case 0:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEC_CF1"); rightText = TheText.Get("FEC_CF1");
break; break;
case 1: case 1:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEC_CF2"); rightText = TheText.Get("FEC_CF2");
break; break;
case 2: case 2:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEC_CF3"); rightText = TheText.Get("FEC_CF3");
break; break;
case 3: case 3:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEC_CF4"); rightText = TheText.Get("FEC_CF4");
break; break;
} }
break; break;
case MENUACTION_CTRLDISPLAY: case MENUACTION_CTRLDISPLAY:
if (m_DisplayControllerOnFoot) if (m_DisplayControllerOnFoot)
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEC_ONF"); rightText = TheText.Get("FEC_ONF");
else else
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEC_INC"); rightText = TheText.Get("FEC_INC");
break; break;
case MENUACTION_FRAMESYNC: case MENUACTION_FRAMESYNC:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_PrefsVsyncDisp ? "FEM_ON" : "FEM_OFF"); rightText = TheText.Get(m_PrefsVsyncDisp ? "FEM_ON" : "FEM_OFF");
break; break;
case MENUACTION_FRAMELIMIT: case MENUACTION_FRAMELIMIT:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_PrefsFrameLimiter ? "FEM_ON" : "FEM_OFF"); rightText = TheText.Get(m_PrefsFrameLimiter ? "FEM_ON" : "FEM_OFF");
break; break;
case MENUACTION_TRAILS: case MENUACTION_TRAILS:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(CMBlur::BlurOn ? "FEM_ON" : "FEM_OFF"); rightText = TheText.Get(CMBlur::BlurOn ? "FEM_ON" : "FEM_OFF");
break; break;
case MENUACTION_SUBTITLES: case MENUACTION_SUBTITLES:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_PrefsShowSubtitles ? "FEM_ON" : "FEM_OFF"); rightText = TheText.Get(m_PrefsShowSubtitles ? "FEM_ON" : "FEM_OFF");
break; break;
case MENUACTION_WIDESCREEN: case MENUACTION_WIDESCREEN:
#ifndef ASPECT_RATIO_SCALE #ifndef ASPECT_RATIO_SCALE
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_PrefsUseWideScreen ? "FEM_ON" : "FEM_OFF"); rightText = TheText.Get(m_PrefsUseWideScreen ? "FEM_ON" : "FEM_OFF");
#else #else
switch (m_PrefsUseWideScreen) { switch (m_PrefsUseWideScreen) {
case AR_AUTO: case AR_AUTO:
textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"AUTO"; rightText = (wchar*)L"AUTO";
break; break;
case AR_4_3: case AR_4_3:
textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"4:3"; rightText = (wchar*)L"4:3";
break; break;
case AR_16_9: case AR_16_9:
textToPrint[MENUCOLUMN_RIGHT] = (wchar*)L"16:9"; rightText = (wchar*)L"16:9";
break; break;
} }
#endif #endif
@ -729,42 +732,39 @@ void CMenuManager::Draw()
break; break;
sprintf(gString, "FEA_FM%d", m_PrefsRadioStation); sprintf(gString, "FEA_FM%d", m_PrefsRadioStation);
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(gString); rightText = TheText.Get(gString);
break; break;
case MENUACTION_SETDBGFLAG: case MENUACTION_SETDBGFLAG:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(CTheScripts::DbgFlag ? "FEM_ON" : "FEM_OFF"); rightText = TheText.Get(CTheScripts::DbgFlag ? "FEM_ON" : "FEM_OFF");
break; break;
case MENUACTION_SWITCHBIGWHITEDEBUGLIGHT: case MENUACTION_SWITCHBIGWHITEDEBUGLIGHT:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(gbBigWhiteDebugLightSwitchedOn ? "FEM_ON" : "FEM_OFF"); rightText = TheText.Get(gbBigWhiteDebugLightSwitchedOn ? "FEM_ON" : "FEM_OFF");
break; break;
case MENUACTION_PEDROADGROUPS: case MENUACTION_PEDROADGROUPS:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(gbShowPedRoadGroups ? "FEM_ON" : "FEM_OFF"); rightText = TheText.Get(gbShowPedRoadGroups ? "FEM_ON" : "FEM_OFF");
break; break;
case MENUACTION_CARROADGROUPS: case MENUACTION_CARROADGROUPS:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(gbShowCarRoadGroups ? "FEM_ON" : "FEM_OFF"); rightText = TheText.Get(gbShowCarRoadGroups ? "FEM_ON" : "FEM_OFF");
break; break;
case MENUACTION_COLLISIONPOLYS: case MENUACTION_COLLISIONPOLYS:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(gbShowCollisionPolys ? "FEM_ON" : "FEM_OFF"); rightText = TheText.Get(gbShowCollisionPolys ? "FEM_ON" : "FEM_OFF");
break; break;
case MENUACTION_SHOWCULL: case MENUACTION_SHOWCULL:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(gbShowCullZoneDebugStuff ? "FEM_ON" : "FEM_OFF"); rightText = TheText.Get(gbShowCullZoneDebugStuff ? "FEM_ON" : "FEM_OFF");
break; break;
case MENUACTION_SHOWHEADBOB: case MENUACTION_SHOWHEADBOB:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(TheCamera.m_bHeadBob ? "FEM_ON" : "FEM_OFF"); rightText = TheText.Get(TheCamera.m_bHeadBob ? "FEM_ON" : "FEM_OFF");
break; break;
case MENUACTION_INVVERT: case MENUACTION_INVVERT:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(MousePointerStateHelper.bInvertVertically ? "FEM_OFF" : "FEM_ON"); rightText = TheText.Get(MousePointerStateHelper.bInvertVertically ? "FEM_OFF" : "FEM_ON");
break; break;
case MENUACTION_SCREENRES: { case MENUACTION_SCREENRES:
RwChar* res = _psGetVideoModeList()[m_nDisplayVideoMode]; AsciiToUnicode(_psGetVideoModeList()[m_nDisplayVideoMode], unicodeTemp);
wchar temp[32]; rightText = unicodeTemp;
AsciiToUnicode(res, temp);
textToPrint[MENUCOLUMN_RIGHT] = temp;
break; break;
} case MENUACTION_AUDIOHW:
case MENUACTION_AUDIOHW: {
if (m_nPrefsAudio3DProviderIndex == -1) if (m_nPrefsAudio3DProviderIndex == -1)
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEA_NAH"); rightText = TheText.Get("FEA_NAH");
else { else {
char *provider = DMAudio.Get3DProviderName(m_nPrefsAudio3DProviderIndex); char *provider = DMAudio.Get3DProviderName(m_nPrefsAudio3DProviderIndex);
@ -773,25 +773,23 @@ void CMenuManager::Draw()
} else if (!strcmp(strupr(provider), "DIRECTSOUND3D SOFTWARE EMULATION")) { } else if (!strcmp(strupr(provider), "DIRECTSOUND3D SOFTWARE EMULATION")) {
strcpy(provider, "DSOUND3D SOFTWARE EMULATION"); strcpy(provider, "DSOUND3D SOFTWARE EMULATION");
} }
wchar temp[64]; AsciiToUnicode(provider, unicodeTemp);
AsciiToUnicode(provider, temp); rightText = unicodeTemp;
textToPrint[MENUCOLUMN_RIGHT] = temp;
} }
break; break;
}
case MENUACTION_SPEAKERCONF: { case MENUACTION_SPEAKERCONF: {
if (m_nPrefsAudio3DProviderIndex == -1) if (m_nPrefsAudio3DProviderIndex == -1)
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEA_NAH"); rightText = TheText.Get("FEA_NAH");
else { else {
switch (m_PrefsSpeakers) { switch (m_PrefsSpeakers) {
case 0: case 0:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEA_2SP"); rightText = TheText.Get("FEA_2SP");
break; break;
case 1: case 1:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEA_EAR"); rightText = TheText.Get("FEA_EAR");
break; break;
case 2: case 2:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get("FEA_4SP"); rightText = TheText.Get("FEA_4SP");
break; break;
} }
} }
@ -800,19 +798,19 @@ void CMenuManager::Draw()
case MENUACTION_CTRLMETHOD: { case MENUACTION_CTRLMETHOD: {
switch (m_ControlMethod) { switch (m_ControlMethod) {
case 0: case 0:
textToPrint[MENUCOLUMN_LEFT] = TheText.Get("FET_SCN"); leftText = TheText.Get("FET_SCN");
break; break;
case 1: case 1:
textToPrint[MENUCOLUMN_LEFT] = TheText.Get("FET_CCN"); leftText = TheText.Get("FET_CCN");
break; break;
} }
break; break;
} }
case MENUACTION_DYNAMICACOUSTIC: case MENUACTION_DYNAMICACOUSTIC:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_PrefsDMA ? "FEM_ON" : "FEM_OFF"); rightText = TheText.Get(m_PrefsDMA ? "FEM_ON" : "FEM_OFF");
break; break;
case MENUACTION_MOUSESTEER: case MENUACTION_MOUSESTEER:
textToPrint[MENUCOLUMN_RIGHT] = TheText.Get(m_bDisableMouseSteering ? "FEM_OFF" : "FEM_ON"); rightText = TheText.Get(m_bDisableMouseSteering ? "FEM_OFF" : "FEM_ON");
break; break;
} }
@ -885,8 +883,8 @@ void CMenuManager::Draw()
float itemY = MENU_Y(textLayer + nextItemY); float itemY = MENU_Y(textLayer + nextItemY);
float itemX = MENU_X_LEFT_ALIGNED(textLayer + columnWidth); float itemX = MENU_X_LEFT_ALIGNED(textLayer + columnWidth);
CFont::PrintString(itemX, itemY, textToPrint[MENUCOLUMN_LEFT]); CFont::PrintString(itemX, itemY, leftText);
if (textToPrint[MENUCOLUMN_RIGHT]) { if (rightText) {
if (!CFont::Details.centre) if (!CFont::Details.centre)
CFont::SetRightJustifyOn(); CFont::SetRightJustifyOn();
@ -894,7 +892,7 @@ void CMenuManager::Draw()
&& !m_bGameNotLoaded && textLayer == 1) { && !m_bGameNotLoaded && textLayer == 1) {
CFont::SetColor(CRGBA(155, 117, 6, FadeIn(255))); CFont::SetColor(CRGBA(155, 117, 6, FadeIn(255)));
} }
CFont::PrintString(MENU_X_RIGHT_ALIGNED(columnWidth - textLayer), itemY, textToPrint[MENUCOLUMN_RIGHT]); CFont::PrintString(MENU_X_RIGHT_ALIGNED(columnWidth - textLayer), itemY, rightText);
} }
if (i == m_nCurrOption && itemsAreSelectable) { if (i == m_nCurrOption && itemsAreSelectable) {
CFont::SetColor(CRGBA(255, 217, 106, FadeIn(255))); CFont::SetColor(CRGBA(255, 217, 106, FadeIn(255)));
@ -1017,7 +1015,7 @@ void CMenuManager::Draw()
} }
} }
nextYToUse += lineHeight * CFont::GetNumberLines(menuXYpadding, nextYToUse, textToPrint[MENUCOLUMN_LEFT]); nextYToUse += lineHeight * CFont::GetNumberLines(menuXYpadding, nextYToUse, leftText);
// Radio icons. // Radio icons.
// TO-DO: This is missing/broken // TO-DO: This is missing/broken

View File

@ -340,14 +340,6 @@ enum eCheckHover
HOVEROPTION_42, HOVEROPTION_42,
}; };
enum eMenuColumns
{
MENUCOLUMN_LEFT,
MENUCOLUMN_CENTER,
MENUCOLUMN_RIGHT,
MENUCOLUMNS,
};
enum enum
{ {
NUM_MENUROWS = 18, NUM_MENUROWS = 18,

View File

@ -55,6 +55,21 @@ CObject::CObject(int32 mi, bool createRW)
Init(); Init();
} }
CObject::CObject(CDummyObject *dummy)
{
SetModelIndexNoCreate(dummy->m_modelIndex);
if (dummy->m_rwObject)
AttachToRwObject(dummy->m_rwObject);
else
GetMatrix() = dummy->GetMatrix();
m_objectMatrix = dummy->GetMatrix();
dummy->DetachFromRwObject();
Init();
m_level = dummy->m_level;
}
CObject::~CObject(void) CObject::~CObject(void)
{ {
CRadar::ClearBlipForEntity(BLIP_OBJECT, CPools::GetObjectPool()->GetIndex(this)); CRadar::ClearBlipForEntity(BLIP_OBJECT, CPools::GetObjectPool()->GetIndex(this));
@ -109,14 +124,37 @@ CObject::RefModelInfo(int32 modelId)
CModelInfo::GetModelInfo(modelId)->AddRef(); CModelInfo::GetModelInfo(modelId)->AddRef();
} }
bool
CObject::CanBeDeleted(void)
{
switch (ObjectCreatedBy) {
case GAME_OBJECT:
return true;
case MISSION_OBJECT:
return false;
case TEMP_OBJECT:
return true;
case CUTSCENE_OBJECT:
return false;
default:
return true;
}
}
class CObject_ : public CObject class CObject_ : public CObject
{ {
public: public:
void dtor(void) { this->CObject::~CObject(); } CObject *ctor(void) { return ::new (this) CObject(); }
CObject *ctor(int32 mi, bool createRW) { return ::new (this) CObject(mi, createRW); }
CObject *ctor(CDummyObject *dummy) { return ::new (this) CObject(dummy); }
void dtor(void) { CObject::~CObject(); }
void Render_(void) { CObject::Render(); } void Render_(void) { CObject::Render(); }
}; };
STARTPATCHES STARTPATCHES
InjectHook(0x4BABD0, (CObject* (CObject::*)(void)) &CObject_::ctor, PATCH_JUMP);
InjectHook(0x4BACE0, (CObject* (CObject::*)(int32, bool)) &CObject_::ctor, PATCH_JUMP);
InjectHook(0x4BAD50, (CObject* (CObject::*)(CDummyObject*)) &CObject_::ctor, PATCH_JUMP);
InjectHook(0x4BAE00, &CObject_::dtor, PATCH_JUMP); InjectHook(0x4BAE00, &CObject_::dtor, PATCH_JUMP);
InjectHook(0x4BB1E0, &CObject_::Render_, PATCH_JUMP); InjectHook(0x4BB1E0, &CObject_::Render_, PATCH_JUMP);
ENDPATCHES ENDPATCHES

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "Physical.h" #include "Physical.h"
#include "DummyObject.h"
enum { enum {
GAME_OBJECT = 1, GAME_OBJECT = 1,
@ -69,6 +70,7 @@ public:
CObject(void); CObject(void);
CObject(int32, bool); CObject(int32, bool);
CObject(CDummyObject*);
~CObject(void); ~CObject(void);
void ProcessControl(void); void ProcessControl(void);
@ -80,6 +82,7 @@ public:
void ObjectDamage(float amount); void ObjectDamage(float amount);
void RefModelInfo(int32 modelId); void RefModelInfo(int32 modelId);
void Init(void); void Init(void);
bool CanBeDeleted(void);
static void DeleteAllTempObjectInArea(CVector, float); static void DeleteAllTempObjectInArea(CVector, float);
}; };

View File

@ -1519,7 +1519,7 @@ CPed::BeingDraggedFromCar(void)
#ifdef VC_PED_PORTS #ifdef VC_PED_PORTS
if (m_objective == OBJECTIVE_LEAVE_CAR_AND_DIE) { if (m_objective == OBJECTIVE_LEAVE_CAR_AND_DIE) {
if (m_pMyVehicle) { if (m_pMyVehicle) {
m_pMyVehicle->ProcessOpenDoor(m_vehEnterType, NUM_ANIMS, m_pVehicleAnim->currentTime); m_pMyVehicle->ProcessOpenDoor(m_vehEnterType, NUM_ANIMS, m_pVehicleAnim->currentTime * 5.0f);
} }
} }
#endif #endif
@ -2954,6 +2954,11 @@ CPed::QuitEnteringCar(void)
if (veh->m_nNumGettingIn != 0) if (veh->m_nNumGettingIn != 0)
veh->m_nNumGettingIn--; veh->m_nNumGettingIn--;
#ifdef VC_PED_PORTS
if (m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER)
RestorePreviousObjective();
#endif
veh->m_nGettingInFlags &= ~GetCarDoorFlag(m_vehEnterType); veh->m_nGettingInFlags &= ~GetCarDoorFlag(m_vehEnterType);
} }
@ -2965,7 +2970,7 @@ CPed::QuitEnteringCar(void)
animAssoc = m_pVehicleAnim; animAssoc = m_pVehicleAnim;
if (animAssoc) { if (animAssoc) {
animAssoc->blendDelta = -4.0f; animAssoc->blendDelta = -4.0f;
animAssoc->flags |= ASSOC_FADEOUTWHENDONE; animAssoc->flags |= ASSOC_DELETEFADEDOUT;
animAssoc = m_pVehicleAnim; animAssoc = m_pVehicleAnim;
animAssoc->flags &= ~ASSOC_RUNNING; animAssoc->flags &= ~ASSOC_RUNNING;
} }
@ -4161,7 +4166,10 @@ CPed::ClearObjective(void)
{ {
if (IsPedInControl() || m_nPedState == PED_DRIVING) { if (IsPedInControl() || m_nPedState == PED_DRIVING) {
m_objective = OBJECTIVE_NONE; m_objective = OBJECTIVE_NONE;
#ifdef VC_PED_PORTS
m_pedInObjective = nil;
m_carInObjective = nil;
#endif
if (m_nPedState == PED_DRIVING && m_pMyVehicle) { if (m_nPedState == PED_DRIVING && m_pMyVehicle) {
if (m_pMyVehicle->pDriver != this) { if (m_pMyVehicle->pDriver != this) {
@ -13603,7 +13611,10 @@ CPed::ProcessObjective(void)
if (InVehicle()) { if (InVehicle()) {
if (m_nPedState != PED_EXIT_CAR && m_nPedState != PED_DRAG_FROM_CAR && m_nPedState != PED_EXIT_TRAIN if (m_nPedState != PED_EXIT_CAR && m_nPedState != PED_DRAG_FROM_CAR && m_nPedState != PED_EXIT_TRAIN
&& (m_nPedType != PEDTYPE_COP && (m_nPedType != PEDTYPE_COP
|| m_pMyVehicle->m_vecMoveSpeed.MagnitudeSqr2D() < 0.000025f)) { #ifdef VC_PED_PORTS
|| m_pMyVehicle->IsBoat()
#endif
|| m_pMyVehicle->m_vecMoveSpeed.MagnitudeSqr2D() < sq(0.005f))) {
if (m_pMyVehicle->IsTrain()) if (m_pMyVehicle->IsTrain())
SetExitTrain(m_pMyVehicle); SetExitTrain(m_pMyVehicle);
#ifdef VC_PED_PORTS #ifdef VC_PED_PORTS

View File

@ -17,6 +17,7 @@
#include "VisibilityPlugins.h" #include "VisibilityPlugins.h"
#include "PedPlacement.h" #include "PedPlacement.h"
#include "DummyObject.h" #include "DummyObject.h"
#include "Script.h"
#define CREATION_DIST_MULT_TO_DIST 40.0f #define CREATION_DIST_MULT_TO_DIST 40.0f
#define CREATION_RANGE 10.0f // Being added over the CREATION_DIST_MULT_TO_DIST. #define CREATION_RANGE 10.0f // Being added over the CREATION_DIST_MULT_TO_DIST.
@ -56,10 +57,8 @@ CVector &CPopulation::RegenerationPoint_a = *(CVector*)0x8E2AA4;
CVector &CPopulation::RegenerationPoint_b = *(CVector*)0x8E2A98; CVector &CPopulation::RegenerationPoint_b = *(CVector*)0x8E2A98;
CVector &CPopulation::RegenerationForward = *(CVector*)0x8F1AD4; CVector &CPopulation::RegenerationForward = *(CVector*)0x8F1AD4;
WRAPPER CPed *CPopulation::AddPedInCar(CVehicle *vehicle) { EAXJMP(0x4F5800); }
WRAPPER void CPopulation::ManagePopulation(void) { EAXJMP(0x4F3B90); } WRAPPER void CPopulation::ManagePopulation(void) { EAXJMP(0x4F3B90); }
WRAPPER void CPopulation::MoveCarsAndPedsOutOfAbandonedZones(void) { EAXJMP(0x4F5BE0); } WRAPPER bool CPopulation::TestSafeForRealObject(CDummyObject*) { EAXJMP(0x4F4700); }
WRAPPER void CPopulation::ConvertToRealObject(CDummyObject* obj) { EAXJMP(0x4F45A0); }
void void
CPopulation::Initialise() CPopulation::Initialise()
@ -470,13 +469,13 @@ CPopulation::PedCreationDistMultiplier()
} }
CPed* CPed*
CPopulation::AddPed(ePedType pedType, uint32 mi, CVector const &coors) CPopulation::AddPed(ePedType pedType, uint32 miOrCopType, CVector const &coors)
{ {
switch (pedType) { switch (pedType) {
case PEDTYPE_CIVMALE: case PEDTYPE_CIVMALE:
case PEDTYPE_CIVFEMALE: case PEDTYPE_CIVFEMALE:
{ {
CCivilianPed *ped = new CCivilianPed(pedType, mi); CCivilianPed *ped = new CCivilianPed(pedType, miOrCopType);
ped->GetPosition() = coors; ped->GetPosition() = coors;
ped->SetOrientation(0.0f, 0.0f, 0.0f); ped->SetOrientation(0.0f, 0.0f, 0.0f);
CWorld::Add(ped); CWorld::Add(ped);
@ -490,7 +489,7 @@ CPopulation::AddPed(ePedType pedType, uint32 mi, CVector const &coors)
} }
case PEDTYPE_COP: case PEDTYPE_COP:
{ {
CCopPed *ped = new CCopPed((eCopType)mi); CCopPed *ped = new CCopPed((eCopType)miOrCopType);
ped->GetPosition() = coors; ped->GetPosition() = coors;
ped->SetOrientation(0.0f, 0.0f, 0.0f); ped->SetOrientation(0.0f, 0.0f, 0.0f);
CWorld::Add(ped); CWorld::Add(ped);
@ -506,7 +505,7 @@ CPopulation::AddPed(ePedType pedType, uint32 mi, CVector const &coors)
case PEDTYPE_GANG8: case PEDTYPE_GANG8:
case PEDTYPE_GANG9: case PEDTYPE_GANG9:
{ {
CCivilianPed *ped = new CCivilianPed(pedType, mi); CCivilianPed *ped = new CCivilianPed(pedType, miOrCopType);
ped->GetPosition() = coors; ped->GetPosition() = coors;
ped->SetOrientation(0.0f, 0.0f, 0.0f); ped->SetOrientation(0.0f, 0.0f, 0.0f);
CWorld::Add(ped); CWorld::Add(ped);
@ -538,7 +537,7 @@ CPopulation::AddPed(ePedType pedType, uint32 mi, CVector const &coors)
case PEDTYPE_CRIMINAL: case PEDTYPE_CRIMINAL:
case PEDTYPE_PROSTITUTE: case PEDTYPE_PROSTITUTE:
{ {
CCivilianPed *ped = new CCivilianPed(pedType, mi); CCivilianPed *ped = new CCivilianPed(pedType, miOrCopType);
ped->GetPosition() = coors; ped->GetPosition() = coors;
ped->SetOrientation(0.0f, 0.0f, 0.0f); ped->SetOrientation(0.0f, 0.0f, 0.0f);
CWorld::Add(ped); CWorld::Add(ped);
@ -721,6 +720,292 @@ CPopulation::AddToPopulation(float minDist, float maxDist, float minDistOffScree
} }
} }
CPed*
CPopulation::AddPedInCar(CVehicle* car)
{
int defaultModel = MI_MALE01;
bool imSureThatModelIsLoaded = true;
CVector coors = FindPlayerCoors();
CZoneInfo zoneInfo;
int pedType;
// May be eCopType, model index or non-sense(for medic), AddPed knows that by looking to ped type.
int preferredModel;
CTheZones::GetZoneInfoForTimeOfDay(&coors, &zoneInfo);
switch (car->m_modelIndex) {
case MI_FIRETRUCK:
preferredModel = 0;
pedType = PEDTYPE_FIREMAN;
break;
case MI_AMBULAN:
preferredModel = 0;
pedType = PEDTYPE_EMERGENCY;
break;
case MI_FBICAR:
preferredModel = COP_FBI;
pedType = PEDTYPE_COP;
break;
case MI_POLICE:
preferredModel = COP_STREET;
pedType = PEDTYPE_COP;
break;
case MI_ENFORCER:
preferredModel = COP_SWAT;
pedType = PEDTYPE_COP;
break;
case MI_RHINO:
case MI_BARRACKS:
preferredModel = COP_ARMY;
pedType = PEDTYPE_COP;
break;
case MI_TAXI:
case MI_CABBIE:
case MI_BORGNINE:
if (CGeneral::GetRandomTrueFalse()) {
pedType = PEDTYPE_CIVMALE;
preferredModel = MI_TAXI_D;
break;
}
defaultModel = MI_TAXI_D;
// fall through
default:
int gangOfPed = GANG_MAFIA;
imSureThatModelIsLoaded = false;
while (gangOfPed < NUM_GANGS && CGangs::GetGangInfo(gangOfPed)->m_nVehicleMI != car->m_modelIndex)
gangOfPed++;
if (gangOfPed < NUM_GANGS) {
pedType = gangOfPed + PEDTYPE_GANG1;
preferredModel = ChooseGangOccupation(gangOfPed);
} else if (gangOfPed == NUM_GANGS) {
CVehicleModelInfo *carModelInfo = ((CVehicleModelInfo*)CModelInfo::GetModelInfo(car->m_modelIndex));
int i = 15;
for(; i >= 0; i--) {
// Should return random model each time
preferredModel = ChooseCivilianOccupation(zoneInfo.pedGroup);
if (preferredModel == -1)
preferredModel = defaultModel;
if (((CPedModelInfo*)CModelInfo::GetModelInfo(preferredModel))->m_carsCanDrive & (1 << carModelInfo->m_vehicleClass))
break;
}
if (i == -1)
preferredModel = defaultModel;
pedType = ((CPedModelInfo*)CModelInfo::GetModelInfo(preferredModel))->m_pedType;
}
break;
}
if (!imSureThatModelIsLoaded && !((CPedModelInfo*)CModelInfo::GetModelInfo(preferredModel))->GetRwObject()) {
preferredModel = defaultModel;
pedType = ((CPedModelInfo*)CModelInfo::GetModelInfo(defaultModel))->m_pedType;
}
CPed *newPed = CPopulation::AddPed((ePedType)pedType, preferredModel, car->GetPosition());
newPed->bUsesCollision = false;
// what??
if (pedType != PEDTYPE_COP) {
newPed->SetCurrentWeapon(WEAPONTYPE_COLT45);
newPed->RemoveWeaponModel(CWeaponInfo::GetWeaponInfo(newPed->GetWeapon()->m_eWeaponType)->m_nModelId);
}
/*
// Miami leftover
if (car->m_vehType == VEHICLE_TYPE_BIKE) {
newPed->m_pVehicleAnim = CAnimManager::BlendAnimation(newPed->GetClump(), ASSOCGRP_STD, *((CBike*)car + 308h), 100.0f);
} else */
// FIX: Make peds comfortable while driving car/boat
#ifdef FIX_BUGS
if (car->IsBoat()) {
newPed->m_pVehicleAnim = CAnimManager::BlendAnimation(newPed->GetClump(), ASSOCGRP_STD, ANIM_DRIVE_BOAT, 100.0f);
} else if (car->IsVehicle() && ((CVehicle*)car)->bLowVehicle) {
newPed->m_pVehicleAnim = CAnimManager::BlendAnimation(newPed->GetClump(), ASSOCGRP_STD, ANIM_CAR_LSIT, 100.0f);
} else
#endif
{
newPed->m_pVehicleAnim = CAnimManager::BlendAnimation(newPed->GetClump(), ASSOCGRP_STD, ANIM_CAR_SIT, 100.0f);
}
newPed->StopNonPartialAnims();
return newPed;
}
void
CPopulation::MoveCarsAndPedsOutOfAbandonedZones()
{
eLevelName level;
int zone;
int frame = CTimer::GetFrameCounter() & 7;
if (frame == 1) {
int movedVehicleCount = 0;
int poolSize = CPools::GetVehiclePool()->GetSize();
for (int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) {
CVehicle* veh = CPools::GetVehiclePool()->GetSlot(poolIndex);
if (veh && veh->m_nZoneLevel == LEVEL_NONE && veh->IsCar()) {
if(veh->m_status != STATUS_ABANDONED && veh->m_status != STATUS_WRECKED && veh->m_status != STATUS_PLAYER &&
veh->m_status != STATUS_PLAYER_REMOTE) {
CVector vehPos(veh->GetPosition());
CPopulation::FindCollisionZoneForCoors(&vehPos, &zone, &level);
// Level 0 is transition zones, and we don't wanna touch cars on transition zones.
if (level != LEVEL_NONE && level != CCollision::ms_collisionInMemory && vehPos.z > -4.0f) {
if (veh->bIsLocked || !veh->CanBeDeleted()) {
switch (movedVehicleCount & 3) {
case 0:
veh->GetPosition() = RegenerationPoint_a;
break;
case 1:
veh->GetPosition() = RegenerationPoint_b;
break;
case 2:
veh->GetPosition() = CVector(RegenerationPoint_a.x, RegenerationPoint_b.y, RegenerationPoint_a.z);
break;
case 3:
veh->GetPosition() = CVector(RegenerationPoint_b.x, RegenerationPoint_a.y, RegenerationPoint_a.z);
break;
default:
break;
}
veh->GetPosition().z += (movedVehicleCount / 4) * 7.0f;
veh->GetForward() = RegenerationForward;
((CAutomobile*)veh)->PlaceOnRoadProperly();
CCarCtrl::JoinCarWithRoadSystem(veh);
CTheScripts::ClearSpaceForMissionEntity(veh->GetPosition(), veh);
++movedVehicleCount;
} else {
CWorld::Remove(veh);
delete veh;
}
}
}
}
}
} else if (frame == 5) {
int poolSize = CPools::GetPedPool()->GetSize();
for (int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) {
CPed *ped = CPools::GetPedPool()->GetSlot(poolIndex);
if (ped && ped->m_nZoneLevel == LEVEL_NONE && !ped->bInVehicle) {
CVector pedPos(ped->GetPosition());
CPopulation::FindCollisionZoneForCoors(&pedPos, &zone, &level);
// Level 0 is transition zones, and we don't wanna touch peds on transition zones.
if (level != LEVEL_NONE && level != CCollision::ms_collisionInMemory && pedPos.z > -4.0f) {
if (ped->CanBeDeleted()) {
CWorld::Remove(ped);
delete ped;
} else if (ped->m_nPedType != PEDTYPE_PLAYER1 && ped->m_nPedType != PEDTYPE_PLAYER2) {
ped->GetPosition() = RegenerationPoint_a;
bool foundGround;
float groundZ = CWorld::FindGroundZFor3DCoord(ped->GetPosition().x, ped->GetPosition().y,
ped->GetPosition().z + 2.0f, &foundGround);
if (foundGround) {
ped->GetPosition().z = 1.0f + groundZ;
//ped->GetPosition().z += 0.0f;
CTheScripts::ClearSpaceForMissionEntity(ped->GetPosition(), ped);
}
}
}
}
}
}
}
void
CPopulation::ConvertAllObjectsToDummyObjects()
{
int poolSize = CPools::GetObjectPool()->GetSize();
for (int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) {
CObject *obj = CPools::GetObjectPool()->GetSlot(poolIndex);
if (obj) {
if (obj->CanBeDeleted())
ConvertToDummyObject(obj);
}
}
}
void
CPopulation::ConvertToRealObject(CDummyObject *dummy)
{
if (!TestSafeForRealObject(dummy))
return;
CObject *obj = new CObject(dummy);
if (!obj)
return;
bool makeInvisible;
CWorld::Remove(dummy);
delete dummy;
CWorld::Add(obj);
int16 mi = obj->m_modelIndex;
if (mi == MI_GLASS1 || mi == MI_GLASS2 || mi == MI_GLASS3 || mi == MI_GLASS4 ||
mi == MI_GLASS5 || mi == MI_GLASS6 || mi == MI_GLASS7 || mi == MI_GLASS8)
makeInvisible = true;
else
makeInvisible = false;
if (makeInvisible) {
obj->bIsVisible = false;
} else if (obj->m_modelIndex == MI_BUOY) {
obj->bIsStatic = false;
obj->m_vecMoveSpeed = CVector(0.0f, 0.0f, -0.001f);
obj->m_flagD8 = true;
obj->AddToMovingList();
}
}
void
CPopulation::ConvertToDummyObject(CObject *obj)
{
CDummyObject *dummy = new CDummyObject(obj);
if (!dummy)
return;
dummy->GetMatrix() = obj->GetMatrix();
dummy->GetMatrix().UpdateRW();
dummy->UpdateRwFrame();
bool makeInvisible;
int16 mi = obj->m_modelIndex;
if (mi == MI_GLASS1 || mi == MI_GLASS2 || mi == MI_GLASS3 || mi == MI_GLASS4 ||
mi == MI_GLASS5 || mi == MI_GLASS6 || mi == MI_GLASS7 || mi == MI_GLASS8)
makeInvisible = true;
else
makeInvisible = false;
if (makeInvisible) {
dummy->bIsVisible = false;
}
CWorld::Remove(obj);
delete obj;
CWorld::Add(dummy);
}
bool
CPopulation::TestRoomForDummyObject(CObject *obj)
{
int16 collidingObjs;
CWorld::FindObjectsKindaColliding(obj->GetPosition(),
CModelInfo::GetModelInfo(obj->m_modelIndex)->GetColModel()->boundingSphere.radius,
false, &collidingObjs, 2, nil, false, true, true, false, false);
return collidingObjs == 0;
}
STARTPATCHES STARTPATCHES
InjectHook(0x4F3770, &CPopulation::Initialise, PATCH_JUMP); InjectHook(0x4F3770, &CPopulation::Initialise, PATCH_JUMP);
InjectHook(0x4F5780, &CPopulation::ChooseGangOccupation, PATCH_JUMP); InjectHook(0x4F5780, &CPopulation::ChooseGangOccupation, PATCH_JUMP);
@ -728,4 +1013,8 @@ STARTPATCHES
InjectHook(0x4F6010, &CPopulation::FindCollisionZoneForCoors, PATCH_JUMP); InjectHook(0x4F6010, &CPopulation::FindCollisionZoneForCoors, PATCH_JUMP);
InjectHook(0x4F6410, &CPopulation::PedCreationDistMultiplier, PATCH_JUMP); InjectHook(0x4F6410, &CPopulation::PedCreationDistMultiplier, PATCH_JUMP);
InjectHook(0x4F5280, &CPopulation::AddPed, PATCH_JUMP); InjectHook(0x4F5280, &CPopulation::AddPed, PATCH_JUMP);
InjectHook(0x4F4470, &CPopulation::ConvertToRealObject, PATCH_JUMP);
InjectHook(0x4F4690, &CPopulation::TestRoomForDummyObject, PATCH_JUMP);
InjectHook(0x4F45A0, &CPopulation::ConvertToDummyObject, PATCH_JUMP);
InjectHook(0x4F4410, &CPopulation::ConvertAllObjectsToDummyObjects, PATCH_JUMP);
ENDPATCHES ENDPATCHES

View File

@ -67,7 +67,7 @@ public:
static void LoadPedGroups(); static void LoadPedGroups();
static void UpdatePedCount(ePedType, bool); static void UpdatePedCount(ePedType, bool);
static void DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool); static void DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool);
static CPed *AddPedInCar(CVehicle *vehicle); static CPed *AddPedInCar(CVehicle *car);
static bool IsPointInSafeZone(CVector *coors); static bool IsPointInSafeZone(CVector *coors);
static void RemovePed(CPed *ent); static void RemovePed(CPed *ent);
static int32 ChooseCivilianOccupation(int32); static int32 ChooseCivilianOccupation(int32);
@ -81,5 +81,9 @@ public:
static void AddToPopulation(float, float, float, float); static void AddToPopulation(float, float, float, float);
static void ManagePopulation(void); static void ManagePopulation(void);
static void MoveCarsAndPedsOutOfAbandonedZones(void); static void MoveCarsAndPedsOutOfAbandonedZones(void);
static void ConvertToRealObject(CDummyObject* obj); static void ConvertToRealObject(CDummyObject*);
static void ConvertToDummyObject(CObject*);
static void ConvertAllObjectsToDummyObjects(void);
static bool TestRoomForDummyObject(CObject*);
static bool TestSafeForRealObject(CDummyObject*);
}; };