Skip to content

Commit

Permalink
Remove Actor variable from Object which could cause a crash
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-bckl committed Oct 2, 2020
1 parent de4dc97 commit cfd5438
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
24 changes: 15 additions & 9 deletions Mod/Classes/FOVChanger.uc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ var() config float FOV;
var() config float HudArmsFOVFactor;
var() config bool bLimitHudArmsFOV;

var CTPlayer Player;

var FunctionOverride CTPlayerEndZoomOverride;
var FunctionOverride CTPlayerResetFOVOverride;

Expand Down Expand Up @@ -39,13 +37,17 @@ function Init(){
}

function CTPlayerEndZoom(){
local CTPlayer Player;

Player = CTPlayer(CTPlayerEndZoomOverride.CurrentSelf);

Player.EndZoom();
SetViewFOV();
SetViewFOV(Player);
}

function CTPlayerResetFOV(){
local CTPlayer Player;

Player = CTPlayer(CTPlayerResetFOVOverride.CurrentSelf);

Player.DesiredFOV = Player.DefaultFOV;
Expand Down Expand Up @@ -89,15 +91,19 @@ function WeaponSetWeapFOV(float NewFOV){
//====================================================================================================

function UpdateWeaponZoomFOVs(Weapon Weapon){
local float DefaultFOV;

DefaultFOV = class'CTPlayer'.default.DefaultFOV;

Weapon.ZoomFOVs[0] = FOV;

// Changing the default zoom Fovs so that it will not zoom in as much with a higher Fov selected
Weapon.ZoomFOVs[1] = FOV - (Player.default.DefaultFOV - Weapon.default.ZoomFOVs[1]);
Weapon.ZoomFOVs[2] = FOV - (Player.default.DefaultFOV - Weapon.default.ZoomFOVs[2]);
Weapon.ZoomFOVs[3] = FOV - (Player.default.DefaultFOV - Weapon.default.ZoomFOVs[3]);
Weapon.ZoomFOVs[1] = FOV - (DefaultFOV - Weapon.default.ZoomFOVs[1]);
Weapon.ZoomFOVs[2] = FOV - (DefaultFOV - Weapon.default.ZoomFOVs[2]);
Weapon.ZoomFOVs[3] = FOV - (DefaultFOV - Weapon.default.ZoomFOVs[3]);
}

function SetViewFOV(){
function SetViewFOV(PlayerController Player){
local Weapon Weapon;
local float CurrentFOV;

Expand All @@ -118,11 +124,11 @@ function SetViewFOV(){
Player.FOVAngle = CurrentFOV;
}

function SetFOV(float NewFOV){
function SetFOV(PlayerController Player, float NewFOV){
FOV = NewFOV;

SaveConfig();
SetViewFOV();
SetViewFOV(Player);
}

// Menu stuff
Expand Down
8 changes: 3 additions & 5 deletions Mod/Classes/ModGameOptionsMenu.uc
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ simulated function Init( string Args )

FOVChanger = FOVChanger(FindObject("Transient.MainFOVChanger", class'FOVChanger'));

if(FOVChanger != None)
FOVChanger.Player = CTPlayer(GetPlayerOwner());
else
if(FOVChanger == None)
Warn("FOVCHANGER OBJECT NOT FOUND!!!!!");

Refresh();
Expand Down Expand Up @@ -350,13 +348,13 @@ simulated function ChangeOption( int i, int Delta )
break;

case 10:
FOVChanger.SetFov(float(Options[10].Items[Options[10].Current]));
FOVChanger.SetFov(GetPlayerOwner(), float(Options[10].Items[Options[10].Current]));

break;

case 11:
FOVChanger.HudArmsFOVFactor = float(Options[11].Items[Options[11].Current]);
FOVChanger.SetFOV(FOVChanger.FOV);
FOVChanger.SetFOV(GetPlayerOwner(), FOVChanger.FOV);
}

GetPlayerOwner().PropagateSettings();
Expand Down
16 changes: 13 additions & 3 deletions Mod/Src/ModRenderDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,10 +509,20 @@ class MOD_API UModRenderDevice : public UD3DRenderDevice{
virtual UBOOL Exec(const TCHAR* Cmd, FOutputDevice& Ar){
if(!GIsEditor){
if(ParseCommand(&Cmd, "SETFOV")){
float FOV = appAtof(Cmd);
struct{
APlayerController* Player;
FLOAT FOV;
} Params;

Ar.Logf("Setting field of view to %f", FOV);
FOVChanger->ProcessEvent(FName("SetFOV"), &FOV);
TObjectIterator<UViewport> It;

checkSlow(It);

Params.Player = It->Actor;
Params.FOV = appAtof(Cmd);

Ar.Logf("Setting field of view to %f", Params.FOV);
FOVChanger->ProcessEvent(FName("SetFOV"), &Params);

return 1;
}else if(ParseCommand(&Cmd, "SETFPSLIMIT")){
Expand Down

0 comments on commit cfd5438

Please sign in to comment.